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;
}
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;
}
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;
}
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;
}
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...
}
Aggregations