Search in sources :

Example 1 with BdaTimestamp

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

the class NodeContainer method getDateArray.

public Date[] getDateArray(final SubDataAttribute child) {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    final int size = array.size();
    final Date[] result = new Date[size];
    for (int i = 0; i < size; i++) {
        result[i] = ((BdaTimestamp) array.getChild(i)).getDate();
    }
    return result;
}
Also used : Array(org.openmuc.openiec61850.Array) Date(java.util.Date)

Example 2 with BdaTimestamp

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

the class LogicalDevice method setTime.

protected BasicDataAttribute setTime(final String node, final Fc fc, final Date date) {
    final BdaTimestamp value = (BdaTimestamp) this.serverModel.findModelNode(this.createNodeName(node), fc);
    value.setDate(date);
    return value;
}
Also used : BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

Example 3 with BdaTimestamp

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

the class NodeContainer method writeDateArray.

public void writeDateArray(final SubDataAttribute child, final Date[] values) throws NodeWriteException {
    final Array array = (Array) this.parent.getChild(child.getDescription());
    if (array.size() != values.length) {
        throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
    }
    for (int i = 0; i < values.length; i++) {
        final BdaTimestamp bdaTimestamp = (BdaTimestamp) array.getChild(i);
        bdaTimestamp.setDate(values[i]);
        this.writeNode(bdaTimestamp);
    }
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
Also used : Array(org.openmuc.openiec61850.Array) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) BdaTimestamp(org.openmuc.openiec61850.BdaTimestamp)

Example 4 with BdaTimestamp

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

the class NodeContainer method getDate.

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

Example 5 with BdaTimestamp

use of org.openmuc.openiec61850.BdaTimestamp 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)

Aggregations

BdaTimestamp (org.openmuc.openiec61850.BdaTimestamp)5 Array (org.openmuc.openiec61850.Array)2 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 BdaBoolean (org.openmuc.openiec61850.BdaBoolean)1 BdaInt8U (org.openmuc.openiec61850.BdaInt8U)1 BdaVisibleString (org.openmuc.openiec61850.BdaVisibleString)1