Search in sources :

Example 6 with BdaFloat32

use of com.beanit.openiec61850.BdaFloat32 in project open-smart-grid-platform by OSGP.

the class Iec61850ClientDaRTUEventListener method processSingleMeasurementNode.

private void processSingleMeasurementNode(final FcModelNode member, final LogicalNode logicalNode, final ModelNode childNode) {
    final BdaFloat32 singleMeasurement = this.getSingleMeasurementModelNode(childNode);
    final BdaTimestamp timestampMeasurement = this.getTimestampModelNode(childNode);
    String type = member.getName() + "." + childNode.getName();
    type += "." + singleMeasurement.getParent().getParent().getName() + "." + singleMeasurement.getParent().getName() + "." + singleMeasurement.getName();
    final BigDecimal value = new BigDecimal(singleMeasurement.getFloat(), new MathContext(3, RoundingMode.HALF_EVEN));
    final DataSampleDto sample = new DataSampleDto(type, timestampMeasurement.getDate(), value);
    logicalNode.getDataSamples().add(sample);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaFloat32(com.beanit.openiec61850.BdaFloat32) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 7 with BdaFloat32

use of com.beanit.openiec61850.BdaFloat32 in project open-smart-grid-platform by OSGP.

the class Iec61850ClientDaRTUEventListener method processTotalMeasurementNode.

private void processTotalMeasurementNode(final FcModelNode member, final LogicalNode logicalNode) {
    final BdaFloat32 totalMeasurement = this.getTotalMeasurementModelNode(member);
    final BdaTimestamp timestampMeasurement = this.getTimestampModelNode(member);
    String type = member.getName();
    type += "." + totalMeasurement.getParent().getName() + "." + totalMeasurement.getName();
    final BigDecimal value = new BigDecimal(totalMeasurement.getFloat(), new MathContext(3, RoundingMode.HALF_EVEN));
    final DataSampleDto sample = new DataSampleDto(type, timestampMeasurement.getDate(), value);
    logicalNode.getDataSamples().add(sample);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaFloat32(com.beanit.openiec61850.BdaFloat32) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 8 with BdaFloat32

use of com.beanit.openiec61850.BdaFloat32 in project Protocol-Adapter-IEC61850 by OSGP.

the class LogicalDevice method setRandomFloat.

protected BasicDataAttribute setRandomFloat(final String node, final Fc fc, final int min, final int max) {
    final BdaFloat32 value = (BdaFloat32) this.serverModel.findModelNode(this.createNodeName(node), fc);
    value.setFloat((float) ThreadLocalRandom.current().nextInt(min, max));
    return value;
}
Also used : BdaFloat32(org.openmuc.openiec61850.BdaFloat32)

Example 9 with BdaFloat32

use of com.beanit.openiec61850.BdaFloat32 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)

Example 10 with BdaFloat32

use of com.beanit.openiec61850.BdaFloat32 in project open-smart-grid-platform by OSGP.

the class NodeContainer method writeFloat.

public void writeFloat(final SubDataAttribute child, final Float value) throws NodeWriteException {
    final BdaFloat32 bdaFloat = (BdaFloat32) this.parent.getChild(child.getDescription());
    bdaFloat.setFloat(value);
    this.writeNode(bdaFloat);
}
Also used : BdaFloat32(com.beanit.openiec61850.BdaFloat32)

Aggregations

BdaFloat32 (com.beanit.openiec61850.BdaFloat32)8 BdaFloat32 (org.openmuc.openiec61850.BdaFloat32)5 BigDecimal (java.math.BigDecimal)4 MathContext (java.math.MathContext)4 DataSampleDto (org.opensmartgridplatform.dto.da.iec61850.DataSampleDto)3 Array (com.beanit.openiec61850.Array)2 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)2 Date (java.util.Date)2 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 FcModelNode (com.beanit.openiec61850.FcModelNode)1 ModelNode (com.beanit.openiec61850.ModelNode)1 Array (org.openmuc.openiec61850.Array)1 FcModelNode (org.openmuc.openiec61850.FcModelNode)1 ModelNode (org.openmuc.openiec61850.ModelNode)1 NodeWriteException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)1 DataSampleDto (org.osgpfoundation.osgp.dto.da.iec61850.DataSampleDto)1