Search in sources :

Example 11 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method determineDescription.

private String determineDescription(final FcModelNode evnRpn) {
    final StringBuilder sb = new StringBuilder();
    final BdaInt8U trgTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_TRIGGER_TYPE);
    if (trgTypeNode != null && trgTypeNode.getValue() > 0) {
        final short trgType = trgTypeNode.getValue();
        final String trigger = TRG_TYPE_DESCRIPTION_PER_CODE.get(trgType);
        if (trigger == null) {
            sb.append("trgType=").append(trgType);
        } else {
            sb.append(trigger);
        }
    }
    final BdaInt8U evnTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_EVENT_TYPE);
    if (evnTypeNode != null && evnTypeNode.getValue() > 0) {
        final short evnType = evnTypeNode.getValue();
        final String event = EventType.forCode(evnType).getDescription();
        if (event.startsWith("FUNCTION_FIRMWARE")) {
            if (sb.length() > 0) {
                sb.append("; ");
            }
            sb.append("functional firmware");
        } else if (event.startsWith("SECURITY_FIRMWARE")) {
            if (sb.length() > 0) {
                sb.append("; ");
            }
            sb.append("security firmware");
        }
    }
    final BdaVisibleString remarkNode = (BdaVisibleString) evnRpn.getChild(EVENT_NODE_REMARK);
    if (remarkNode != null && !EVENT_NODE_REMARK.equalsIgnoreCase(remarkNode.getStringValue())) {
        if (sb.length() > 0) {
            sb.append(' ');
        }
        sb.append('(').append(remarkNode.getStringValue()).append(')');
    }
    return sb.toString();
}
Also used : BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString) BdaInt8U(org.openmuc.openiec61850.BdaInt8U) BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString)

Example 12 with FcModelNode

use of org.openmuc.openiec61850.FcModelNode 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 13 with FcModelNode

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

the class Iec61850DeviceConnectionService method getModelNode.

private FcModelNode getModelNode(final String logicalDevice, final Iec61850Connection iec61850Connection, final String description) throws ProtocolAdapterException {
    final ServerModel serverModel = iec61850Connection.getServerModel();
    if (serverModel == null) {
        final String msg = String.format("ServerModel is null for logicalDevice {%s}", logicalDevice);
        throw new ProtocolAdapterException(msg);
    }
    final String objRef = description + logicalDevice + "/" + LogicalNode.LOGICAL_NODE_ZERO.getDescription() + "." + DataAttribute.NAME_PLATE.getDescription();
    final FcModelNode modelNode = (FcModelNode) serverModel.findModelNode(objRef, Fc.DC);
    if (modelNode == null) {
        final String msg = String.format("ModelNode is null for {%s}", objRef);
        throw new ProtocolAdapterException(msg);
    }
    return modelNode;
}
Also used : ServerModel(org.openmuc.openiec61850.ServerModel) FcModelNode(org.openmuc.openiec61850.FcModelNode) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Aggregations

FcModelNode (org.openmuc.openiec61850.FcModelNode)7 DateTime (org.joda.time.DateTime)6 BdaInt8U (org.openmuc.openiec61850.BdaInt8U)4 BdaVisibleString (org.openmuc.openiec61850.BdaVisibleString)4 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 DataSet (org.openmuc.openiec61850.DataSet)3 Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)2 Iec61850BdaOptFldsHelper (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850BdaOptFldsHelper)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BdaReasonForInclusion (org.openmuc.openiec61850.BdaReasonForInclusion)2 EventType (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.EventType)1 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)1 ReadOnlyNodeContainer (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.ReadOnlyNodeContainer)1 EventNotificationDto (com.alliander.osgp.dto.valueobjects.EventNotificationDto)1 EventTypeDto (com.alliander.osgp.dto.valueobjects.EventTypeDto)1 GetDataResponseDto (com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto)1 GetDataSystemIdentifierDto (com.alliander.osgp.dto.valueobjects.microgrids.GetDataSystemIdentifierDto)1 MeasurementDto (com.alliander.osgp.dto.valueobjects.microgrids.MeasurementDto)1