Search in sources :

Example 11 with BdaBoolean

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

the class Iec61850ClientSSLDEventListener method evnRpnInfo.

private String evnRpnInfo(final String linePrefix, final FcModelNode evnRpn) {
    final StringBuilder sb = new StringBuilder();
    final BdaInt8U evnTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_EVENT_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_EVENT_TYPE).append(": ");
    if (evnTypeNode == null) {
        sb.append("null");
    } else {
        final short evnType = evnTypeNode.getValue();
        sb.append(evnType).append(" = ").append(EventType.forCode(evnType).getDescription());
    }
    sb.append(System.lineSeparator());
    final BdaInt8U swNumNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_SWITCH_NUMBER);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_NUMBER).append(": ");
    if (swNumNode == null) {
        sb.append("null");
    } else {
        final short swNum = swNumNode.getValue();
        sb.append(swNum).append(" = ").append("get external index for switch ").append(swNum);
    }
    sb.append(System.lineSeparator());
    final BdaInt8U trgTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_TRIGGER_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TYPE).append(": ");
    if (trgTypeNode == null) {
        sb.append("null");
    } else {
        final short trgType = trgTypeNode.getValue();
        sb.append(trgType).append(" = ").append(TRG_TYPE_DESCRIPTION_PER_CODE.get(trgType));
    }
    sb.append(System.lineSeparator());
    final BdaBoolean swValNode = (BdaBoolean) evnRpn.getChild(EVENT_NODE_SWITCH_VALUE);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_VALUE).append(": ");
    if (swValNode == null) {
        sb.append("null");
    } else {
        final boolean swVal = swValNode.getValue();
        sb.append(swVal).append(" = ").append(swVal ? "ON" : "OFF");
    }
    sb.append(System.lineSeparator());
    final BdaTimestamp trgTimeNode = (BdaTimestamp) evnRpn.getChild(EVENT_NODE_TRIGGER_TIME);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TIME).append(": ");
    if (trgTimeNode == null || trgTimeNode.getDate() == null) {
        sb.append("null");
    } else {
        final DateTime trgTime = new DateTime(trgTimeNode.getDate());
        sb.append(trgTime);
    }
    sb.append(System.lineSeparator());
    final BdaVisibleString remarkNode = (BdaVisibleString) evnRpn.getChild(EVENT_NODE_REMARK);
    sb.append(linePrefix).append(EVENT_NODE_REMARK).append(": ");
    if (remarkNode == null) {
        sb.append("null");
    } else {
        final String remark = remarkNode.getStringValue();
        sb.append(remark);
    }
    sb.append(System.lineSeparator());
    return sb.toString();
}
Also used : BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) BdaInt8U(com.beanit.openiec61850.BdaInt8U) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaBoolean(com.beanit.openiec61850.BdaBoolean) BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime)

Example 12 with BdaBoolean

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

the class Iec61850RebootCommand method rebootDevice.

public void rebootDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws ProtocolAdapterException {
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
            final NodeContainer rebootOperationNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REBOOT_OPERATION, Fc.CO);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), rebootOperationNode.getFcmodelNode());
            LOGGER.info("device: {}, rebootOperationNode: {}", deviceConnection.getDeviceIdentification(), rebootOperationNode);
            final NodeContainer oper = rebootOperationNode.getChild(SubDataAttribute.OPERATION);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), oper.getFcmodelNode());
            LOGGER.info("device: {}, oper: {}", deviceConnection.getDeviceIdentification(), oper);
            final BdaBoolean ctlVal = oper.getBoolean(SubDataAttribute.CONTROL_VALUE);
            LOGGER.info("device: {}, ctlVal: {}", deviceConnection.getDeviceIdentification(), ctlVal);
            ctlVal.setValue(true);
            LOGGER.info("device: {}, set ctlVal to true in order to reboot the device", deviceConnection.getDeviceIdentification());
            oper.write();
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REBOOT_OPERATION, Fc.ST, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Boolean.toString(true));
            DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            return null;
        }
    };
    iec61850Client.sendCommandWithRetry(function, "Reboot", deviceConnection.getDeviceIdentification());
}
Also used : Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)

Example 13 with BdaBoolean

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

the class Iec61850TransitionCommand method transitionDevice.

public void transitionDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final TransitionMessageDataContainerDto transitionMessageDataContainer) throws ProtocolAdapterException {
    final TransitionTypeDto transitionType = transitionMessageDataContainer.getTransitionType();
    LOGGER.info("device: {}, transition: {}", deviceConnection.getDeviceIdentification(), transitionType);
    final boolean controlValueForTransition = transitionType.equals(TransitionTypeDto.DAY_NIGHT);
    final DateTime dateTime = transitionMessageDataContainer.getDateTime();
    if (dateTime != null) {
        LOGGER.warn("device: {}, setting date/time {} for transition {} not supported", deviceConnection.getDeviceIdentification(), dateTime, transitionType);
    }
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
            final NodeContainer sensorNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SENSOR, Fc.CO);
            iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), sensorNode.getFcmodelNode());
            LOGGER.info("device: {}, sensorNode: {}", deviceConnection.getDeviceIdentification(), sensorNode);
            final NodeContainer oper = sensorNode.getChild(SubDataAttribute.OPERATION);
            LOGGER.info("device: {}, oper: {}", deviceConnection.getDeviceIdentification(), oper);
            final BdaBoolean ctlVal = oper.getBoolean(SubDataAttribute.CONTROL_VALUE);
            LOGGER.info("device: {}, ctlVal: {}", deviceConnection.getDeviceIdentification(), ctlVal);
            ctlVal.setValue(controlValueForTransition);
            LOGGER.info("device: {}, set ctlVal to {} in order to transition the device", deviceConnection.getDeviceIdentification(), controlValueForTransition);
            oper.write();
            deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SENSOR, Fc.CO, SubDataAttribute.OPERATION, SubDataAttribute.CONTROL_VALUE, Boolean.toString(controlValueForTransition));
            DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
            return null;
        }
    };
    iec61850Client.sendCommandWithRetry(function, "SetTransition", deviceConnection.getDeviceIdentification());
}
Also used : Function(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) TransitionTypeDto(com.alliander.osgp.dto.valueobjects.TransitionTypeDto) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) NodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) DateTime(org.joda.time.DateTime)

Example 14 with BdaBoolean

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

the class Iec61850ClientSSLDEventListener method evnRpnInfo.

private String evnRpnInfo(final String linePrefix, final FcModelNode evnRpn) {
    final StringBuilder sb = new StringBuilder();
    final BdaInt8U evnTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_EVENT_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_EVENT_TYPE).append(": ");
    if (evnTypeNode == null) {
        sb.append("null");
    } else {
        final short evnType = evnTypeNode.getValue();
        sb.append(evnType).append(" = ").append(EventType.forCode(evnType).getDescription());
    }
    sb.append(System.lineSeparator());
    final BdaInt8U swNumNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_SWITCH_NUMBER);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_NUMBER).append(": ");
    if (swNumNode == null) {
        sb.append("null");
    } else {
        final short swNum = swNumNode.getValue();
        sb.append(swNum).append(" = ").append("get external index for switch " + swNum);
    }
    sb.append(System.lineSeparator());
    final BdaInt8U trgTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_TRIGGER_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TYPE).append(": ");
    if (trgTypeNode == null) {
        sb.append("null");
    } else {
        final short trgType = trgTypeNode.getValue();
        sb.append(trgType).append(" = ").append(TRG_TYPE_DESCRIPTION_PER_CODE.get(trgType));
    }
    sb.append(System.lineSeparator());
    final BdaBoolean swValNode = (BdaBoolean) evnRpn.getChild(EVENT_NODE_SWITCH_VALUE);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_VALUE).append(": ");
    if (swValNode == null) {
        sb.append("null");
    } else {
        final boolean swVal = swValNode.getValue();
        sb.append(swVal).append(" = ").append(swVal ? "ON" : "OFF");
    }
    sb.append(System.lineSeparator());
    final BdaTimestamp trgTimeNode = (BdaTimestamp) evnRpn.getChild(EVENT_NODE_TRIGGER_TIME);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TIME).append(": ");
    if (trgTimeNode == null || trgTimeNode.getDate() == null) {
        sb.append("null");
    } else {
        final DateTime trgTime = new DateTime(trgTimeNode.getDate());
        sb.append(trgTime);
    }
    sb.append(System.lineSeparator());
    final BdaVisibleString remarkNode = (BdaVisibleString) evnRpn.getChild(EVENT_NODE_REMARK);
    sb.append(linePrefix).append(EVENT_NODE_REMARK).append(": ");
    if (remarkNode == null) {
        sb.append("null");
    } else {
        final String remark = remarkNode.getStringValue();
        sb.append(remark);
    }
    sb.append(System.lineSeparator());
    return sb.toString();
}
Also used : BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString) BdaInt8U(org.openmuc.openiec61850.BdaInt8U) BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp) BdaBoolean(org.openmuc.openiec61850.BdaBoolean) BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime)

Example 15 with BdaBoolean

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

the class NodeContainer method writeBoolean.

public void writeBoolean(final SubDataAttribute child, final boolean value) throws NodeWriteException {
    final BdaBoolean bdaBoolean = (BdaBoolean) this.parent.getChild(child.getDescription());
    bdaBoolean.setValue(value);
    this.writeNode(bdaBoolean);
}
Also used : BdaBoolean(org.openmuc.openiec61850.BdaBoolean)

Aggregations

BdaBoolean (com.beanit.openiec61850.BdaBoolean)12 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)8 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)5 Function (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.Function)5 NodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)5 NodeContainer (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer)5 DateTime (org.joda.time.DateTime)4 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)4 LogicalNode (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)3 ArrayList (java.util.ArrayList)3 Function (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function)3 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 BdaInt8U (com.beanit.openiec61850.BdaInt8U)2 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)2 BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)2 LogicalNode (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.LogicalNode)2 ScheduleEntry (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.ScheduleEntry)1 DeviceOutputSetting (com.alliander.osgp.core.db.api.iec61850.entities.DeviceOutputSetting)1 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)1 EventNotificationTypeDto (com.alliander.osgp.dto.valueobjects.EventNotificationTypeDto)1