Search in sources :

Example 1 with BasicDataAttribute

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

the class RtuSimulator method assertValue.

public void assertValue(final String logicalDeviceName, final String node, final String value) {
    final LogicalDevice logicalDevice = this.getLogicalDevice(logicalDeviceName);
    // Get a new model copy to see values that have been set on the server.
    logicalDevice.refreshServerModel(this.server.getModelCopy());
    final ModelNode actual = logicalDevice.getBasicDataAttribute(node);
    if (actual == null) {
        throw new AssertionError("RTU Simulator does not have expected node \"" + node + "\" on logical device \"" + logicalDeviceName + "\".");
    }
    if (!(actual instanceof BasicDataAttribute)) {
        throw new AssertionError("RTU Simulator value has node \"" + node + "\" on logical device \"" + logicalDeviceName + "\", but it is not a BasicDataAttribute: " + actual.getClass().getName());
    }
    final BasicDataAttribute expected = this.getCopyWithNewValue((BasicDataAttribute) actual, value);
    if (!BasicDataAttributesHelper.attributesEqual(expected, (BasicDataAttribute) actual)) {
        throw new AssertionError("RTU Simulator attribute for node \"" + node + "\" on logical device \"" + logicalDeviceName + "\" - expected: [" + expected + "], actual: [" + actual + "]");
    }
}
Also used : LogicalDevice(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice) BasicDataAttribute(org.openmuc.openiec61850.BasicDataAttribute) ModelNode(org.openmuc.openiec61850.ModelNode)

Example 2 with BasicDataAttribute

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

the class RtuSimulator method generateData.

@Scheduled(fixedDelay = 60000)
public void generateData() {
    synchronized (this.stopGeneratingValues) {
        if (!this.stopGeneratingValues.get()) {
            final Date timestamp = new Date();
            final List<BasicDataAttribute> values = new ArrayList<>();
            for (final LogicalDevice ld : this.logicalDevices) {
                values.addAll(ld.getAttributesAndSetValues(timestamp));
            }
            this.server.setValues(values);
            LOGGER.info("Generated values");
        }
    }
}
Also used : LogicalDevice(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice) ArrayList(java.util.ArrayList) BasicDataAttribute(org.openmuc.openiec61850.BasicDataAttribute) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 3 with BasicDataAttribute

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

the class RtuSimulator method getCopyWithNewValue.

private BasicDataAttribute getCopyWithNewValue(final BasicDataAttribute original, final String value) {
    final BasicDataAttribute copy = (BasicDataAttribute) original.copy();
    BasicDataAttributesHelper.setValue(copy, value);
    return copy;
}
Also used : BasicDataAttribute(com.beanit.openiec61850.BasicDataAttribute)

Example 4 with BasicDataAttribute

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

the class UpdateHealthStatusEventListener method updateServerValue.

private void updateServerValue(final ServerSap serverSap) {
    LOGGER.debug("updateServerValue");
    final ServerModel serverModel = serverSap.getModelCopy();
    final ModelNode modelNode = serverModel.findModelNode(HEALTH_NODE, Fc.ST);
    if (modelNode != null) {
        final ModelNode dataNode = modelNode.getChild(STATUS_VALUE);
        if (dataNode != null && dataNode instanceof BdaInt8) {
            final List<BasicDataAttribute> changedAttributes = new ArrayList<>();
            final BdaInt8 bda = (BdaInt8) dataNode;
            bda.setValue(bda.getValue() == OK ? WARNING : (bda.getValue() == WARNING ? ALARM : OK));
            changedAttributes.add(bda);
            serverSap.setValues(changedAttributes);
        }
    }
}
Also used : BdaInt8(com.beanit.openiec61850.BdaInt8) ServerModel(com.beanit.openiec61850.ServerModel) ArrayList(java.util.ArrayList) BasicDataAttribute(com.beanit.openiec61850.BasicDataAttribute) ModelNode(com.beanit.openiec61850.ModelNode)

Example 5 with BasicDataAttribute

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

the class LogicalDevice method setQuality.

protected BasicDataAttribute setQuality(final LogicalDeviceNode node, final QualityType q) {
    final BdaQuality value = (BdaQuality) this.serverModel.findModelNode(this.createNodeName(node), node.getFc());
    value.setValue(this.shortToByteArray(q.getValue()));
    return value;
}
Also used : BdaQuality(com.beanit.openiec61850.BdaQuality)

Aggregations

BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)11 ArrayList (java.util.ArrayList)7 BasicDataAttribute (org.openmuc.openiec61850.BasicDataAttribute)4 LogicalDevice (org.opensmartgridplatform.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)4 LogicalDevice (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)3 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)3 BdaInt32 (com.beanit.openiec61850.BdaInt32)3 BdaInt8 (com.beanit.openiec61850.BdaInt8)3 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)2 BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)2 ModelNode (com.beanit.openiec61850.ModelNode)2 ServerModel (com.beanit.openiec61850.ServerModel)2 Date (java.util.Date)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 BdaBoolean (com.beanit.openiec61850.BdaBoolean)1 BdaInt64 (com.beanit.openiec61850.BdaInt64)1 BdaQuality (com.beanit.openiec61850.BdaQuality)1 SclParseException (com.beanit.openiec61850.SclParseException)1 IOException (java.io.IOException)1 Matcher (java.util.regex.Matcher)1