Search in sources :

Example 6 with BdaVisibleString

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

use of com.beanit.openiec61850.BdaVisibleString 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 8 with BdaVisibleString

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

the class NodeContainer method getString.

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

Example 9 with BdaVisibleString

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

the class NodeContainer method writeString.

/**
 * Writes a String value to the given child on the device
 */
public void writeString(final SubDataAttribute child, final String value) throws NodeWriteException {
    final BdaVisibleString stringNode = (BdaVisibleString) this.parent.getChild(child.getDescription());
    LOGGER.info(DEVICE_WRITE_LOG_MESSAGE, this.deviceIdentification, value, child.getDescription());
    stringNode.setValue(value);
    this.writeNode(stringNode);
}
Also used : BdaVisibleString(com.beanit.openiec61850.BdaVisibleString)

Example 10 with BdaVisibleString

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

the class LightMeasurementRtu method writeValueAndUpdateRelatedAttributes.

@Override
public List<BasicDataAttribute> writeValueAndUpdateRelatedAttributes(final String node, final BasicDataAttribute value) {
    final List<BasicDataAttribute> values = new ArrayList<>();
    if (LogicalDeviceNode.SPGGIO1_IND_D.getDescription().equals(node)) {
        LOGGER.info("Update the values for the light sensors");
        final byte[] newValue = ((BdaVisibleString) value).getValue();
        LOGGER.info("New value for {}: {}", node, new String(newValue));
        // Update the status of the 4 SPGGIO nodes, which represent the
        // light sensors, because we use changes in SPGGIO.Ind.d to trigger
        // their update.
        values.addAll(this.setGeneralIO(newValue));
    } else if (LogicalDeviceNode.SPGGIO2_IND_D.getDescription().equals(node)) {
        LOGGER.info("Update reporting control block enabled value");
        final byte[] bool = ((BdaVisibleString) value).getValue();
        final BasicDataAttribute bda = this.setReportingControlBlock(bool);
        if (bda != null) {
            values.add(bda);
        }
    } else {
        LOGGER.info("No special update action needed for setting node {}", value);
    }
    return values;
}
Also used : BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) ArrayList(java.util.ArrayList) BasicDataAttribute(com.beanit.openiec61850.BasicDataAttribute) BdaVisibleString(com.beanit.openiec61850.BdaVisibleString)

Aggregations

BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)6 BdaVisibleString (org.openmuc.openiec61850.BdaVisibleString)4 BdaBoolean (com.beanit.openiec61850.BdaBoolean)2 BdaInt8U (com.beanit.openiec61850.BdaInt8U)2 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)2 DateTime (org.joda.time.DateTime)2 BdaInt8U (org.openmuc.openiec61850.BdaInt8U)2 BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)1 ArrayList (java.util.ArrayList)1 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)1 BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)1 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1