Search in sources :

Example 1 with Array

use of org.openmuc.openiec61850.Array in project Protocol-Adapter-IEC61850 by OSGP.

the class NodeContainer method getFloatArray.

public Float[] getFloatArray(final SubDataAttribute child) {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    final int size = array.size();
    final Float[] result = new Float[size];
    for (int i = 0; i < size; i++) {
        result[i] = ((BdaFloat32) array.getChild(i)).getFloat();
    }
    return result;
}
Also used : Array(org.openmuc.openiec61850.Array)

Example 2 with Array

use of org.openmuc.openiec61850.Array in project Protocol-Adapter-IEC61850 by OSGP.

the class NodeContainer method getDateArray.

public Date[] getDateArray(final SubDataAttribute child) {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    final int size = array.size();
    final Date[] result = new Date[size];
    for (int i = 0; i < size; i++) {
        result[i] = ((BdaTimestamp) array.getChild(i)).getDate();
    }
    return result;
}
Also used : Array(org.openmuc.openiec61850.Array) Date(java.util.Date)

Example 3 with Array

use of org.openmuc.openiec61850.Array in project vcell by virtualcell.

the class NetCDFEvaluator method getDataOverTrials.

/**
 * Get Data series based on a specific time point over trials.
 */
public Array getDataOverTrials(int timePointNo) throws IOException, InvalidRangeException {
    if ((ncreader != null) && (ncreader.getState() != null) && (timePointNo >= 0) && (timePointNo < ncreader.getNumTimePoints())) {
        String readIdx = 0 + ":" + (ncreader.getNumTrials() - 1) + ":" + "1," + timePointNo + ":" + timePointNo + ":1," + "0:" + (ncreader.getNumSpecies() - 1) + ":1";
        System.out.println(readIdx);
        try {
            Array result = ncreader.getState().read(readIdx).reduce();
            return result;
        } catch (IOException e) {
            e.printStackTrace(System.err);
            throw new IOException("Unable to read variable " + ncreader.getState().getName() + "!");
        }
    }
    return null;
}
Also used : Array(ucar.ma2.Array) IOException(java.io.IOException)

Example 4 with Array

use of org.openmuc.openiec61850.Array in project vcell by virtualcell.

the class NetCDFEvaluator method getTimeSeriesData.

/**
 * Get time series data based on a specific trial number.
 * The state variable has 3 dimensions. The time series data removes the first dimension
 * containing only time and species in a specific trial.
 */
public Array getTimeSeriesData(int trialNo) throws IOException, InvalidRangeException {
    if ((ncreader != null) && (ncreader.getState() != null) && (trialNo > 0) && (trialNo <= ncreader.getNumTrials())) {
        String readIdx = (trialNo - 1) + ":" + (trialNo - 1) + ":" + "1," + "0:" + (ncreader.getNumTimePoints() - 1) + ":1," + "0:" + (ncreader.getNumSpecies() - 1) + ":1";
        System.out.println(readIdx);
        try {
            Array result = ncreader.getState().read(readIdx).reduce();
            return result;
        } catch (IOException e) {
            e.printStackTrace(System.err);
            throw new IOException("Unable to read variable " + ncreader.getState().getName() + "!");
        }
    }
    return null;
}
Also used : Array(ucar.ma2.Array) IOException(java.io.IOException)

Example 5 with Array

use of org.openmuc.openiec61850.Array in project Protocol-Adapter-IEC61850 by OSGP.

the class NodeContainer method writeFloatArray.

public void writeFloatArray(final SubDataAttribute child, final Float[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaFloat32 bdaFloat = (BdaFloat32) array.getChild(i);
        bdaFloat.setFloat(values[i]);
        this.writeNode(bdaFloat);
    }
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
Also used : Array(org.openmuc.openiec61850.Array) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaFloat32(org.openmuc.openiec61850.BdaFloat32)

Aggregations

Array (org.openmuc.openiec61850.Array)4 Array (ucar.ma2.Array)3 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)2 IOException (java.io.IOException)2 Date (java.util.Date)1 DataStoreContentException (org.apache.sis.storage.DataStoreContentException)1 BdaFloat32 (org.openmuc.openiec61850.BdaFloat32)1 BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)1 InvalidRangeException (ucar.ma2.InvalidRangeException)1 Section (ucar.ma2.Section)1