Search in sources :

Example 6 with BasicDataAttribute

use of org.openmuc.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 7 with BasicDataAttribute

use of org.openmuc.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 8 with BasicDataAttribute

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

the class LogicalDevice method setRandomByte.

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

Example 9 with BasicDataAttribute

use of org.openmuc.openiec61850.BasicDataAttribute 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 10 with BasicDataAttribute

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

the class LogicalDevice method setInt.

protected BasicDataAttribute setInt(final String node, final Fc fc, final int val) {
    final BdaInt32 value = (BdaInt32) this.serverModel.findModelNode(this.createNodeName(node), fc);
    value.setValue(val);
    return value;
}
Also used : BdaInt32(org.openmuc.openiec61850.BdaInt32)

Aggregations

BasicDataAttribute (org.openmuc.openiec61850.BasicDataAttribute)4 LogicalDevice (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)3 BdaInt32 (org.openmuc.openiec61850.BdaInt32)3 BdaFloat32 (org.openmuc.openiec61850.BdaFloat32)2 BdaInt8 (org.openmuc.openiec61850.BdaInt8)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)1 BdaInt64 (org.openmuc.openiec61850.BdaInt64)1 BdaQuality (org.openmuc.openiec61850.BdaQuality)1 BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)1 ModelNode (org.openmuc.openiec61850.ModelNode)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1