Search in sources :

Example 6 with BdaTimestamp

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

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

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

the class LogicalDevice method setTime.

protected BasicDataAttribute setTime(final String node, final Fc fc, final Date date) {
    final BdaTimestamp value = (BdaTimestamp) this.serverModel.findModelNode(this.createNodeName(node), fc);
    value.setDate(date);
    return value;
}
Also used : BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

Example 9 with BdaTimestamp

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

the class NodeContainer method writeDateArray.

public void writeDateArray(final SubDataAttribute child, final Date[] 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 BdaTimestamp bdaTimestamp = (BdaTimestamp) array.getChild(i);
        bdaTimestamp.setDate(values[i]);
        this.writeNode(bdaTimestamp);
    }
// 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) BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

Example 10 with BdaTimestamp

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

the class NodeContainer method getDate.

/**
     * Returns a {@link Date} for {@link BdaTimestamp} values
     */
public Date getDate(final SubDataAttribute child) {
    final BdaTimestamp dBdaTimestamp = (BdaTimestamp) this.parent.getChild(child.getDescription());
    if (dBdaTimestamp == null) {
        LOGGER.error("BdaTimeStamp is null, most likely attribute: {} does not exist");
    }
    LOGGER.info("device: {}, {} has value {}", this.deviceIdentification, child.getDescription(), dBdaTimestamp.getDate());
    return dBdaTimestamp.getDate();
}
Also used : BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

Aggregations

BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)9 BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)5 Array (com.beanit.openiec61850.Array)2 BdaBoolean (com.beanit.openiec61850.BdaBoolean)2 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)2 BdaInt8U (com.beanit.openiec61850.BdaInt8U)2 BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)2 BigDecimal (java.math.BigDecimal)2 MathContext (java.math.MathContext)2 DateTime (org.joda.time.DateTime)2 DataSampleDto (org.opensmartgridplatform.dto.da.iec61850.DataSampleDto)2 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 Date (java.util.Date)1 Array (org.openmuc.openiec61850.Array)1 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)1 BdaInt8U (org.openmuc.openiec61850.BdaInt8U)1 BdaVisibleString (org.openmuc.openiec61850.BdaVisibleString)1 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 NodeWriteException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)1