Search in sources :

Example 1 with FcModelNode

use of com.beanit.iec61850bean.FcModelNode in project OpenMUC by isc-konstanz.

the class Iec61850Connection method setRecordContainer.

private FcModelNode setRecordContainer(ChannelRecordContainer container) throws ConnectionException {
    if (container.getChannelHandle() == null) {
        return null;
    }
    FcModelNode fcModelNode = (FcModelNode) container.getChannelHandle();
    try {
        clientAssociation.getDataValues(fcModelNode);
    } catch (ServiceError e) {
        logger.debug("Error reading channel: service error calling getDataValues on {}: {}", container.getChannelAddress(), e);
        container.setRecord(new Record(Flag.DRIVER_ERROR_CHANNEL_NOT_ACCESSIBLE));
        return fcModelNode;
    } catch (IOException e) {
        throw new ConnectionException(e);
    }
    if (fcModelNode instanceof BasicDataAttribute) {
        long receiveTime = System.currentTimeMillis();
        setRecord(container, (BasicDataAttribute) fcModelNode, receiveTime);
    } else {
        StringBuilder sb = new StringBuilder("");
        for (BasicDataAttribute bda : fcModelNode.getBasicDataAttributes()) {
            sb.append(bda2String(bda) + STRING_SEPARATOR);
        }
        // remove last separator
        sb.delete(sb.length() - 1, sb.length());
        long receiveTime = System.currentTimeMillis();
        setRecord(container, sb.toString(), receiveTime);
    }
    return null;
}
Also used : ServiceError(com.beanit.iec61850bean.ServiceError) FcModelNode(com.beanit.iec61850bean.FcModelNode) Record(org.openmuc.framework.data.Record) IOException(java.io.IOException) BasicDataAttribute(com.beanit.iec61850bean.BasicDataAttribute) ConnectionException(org.openmuc.framework.driver.spi.ConnectionException)

Example 2 with FcModelNode

use of com.beanit.iec61850bean.FcModelNode in project OpenMUC by isc-konstanz.

the class Iec61850Connection method setChannelHandleWithFcModelNode.

private void setChannelHandleWithFcModelNode(ChannelRecordContainer container) {
    if (container.getChannelHandle() == null) {
        String[] args = container.getChannelAddress().split(":", 3);
        if (args.length != 2) {
            logger.debug("Wrong channel address syntax: {}", container.getChannelAddress());
            container.setRecord(new Record(Flag.DRIVER_ERROR_CHANNEL_WITH_THIS_ADDRESS_NOT_FOUND));
            return;
        }
        ModelNode modelNode = serverModel.findModelNode(args[0], Fc.fromString(args[1]));
        if (modelNode == null) {
            logger.debug("No Basic Data Attribute for the channel address {} was found in the server model.", container.getChannelAddress());
            container.setRecord(new Record(Flag.DRIVER_ERROR_CHANNEL_WITH_THIS_ADDRESS_NOT_FOUND));
            return;
        }
        FcModelNode fcModelNode;
        try {
            fcModelNode = (FcModelNode) modelNode;
        } catch (ClassCastException e) {
            logger.debug("ModelNode with object reference {} was found in the server model but is not a Basic Data Attribute.", container.getChannelAddress());
            container.setRecord(new Record(Flag.DRIVER_ERROR_CHANNEL_WITH_THIS_ADDRESS_NOT_FOUND));
            return;
        }
        container.setChannelHandle(fcModelNode);
    }
}
Also used : FcModelNode(com.beanit.iec61850bean.FcModelNode) Record(org.openmuc.framework.data.Record) BdaVisibleString(com.beanit.iec61850bean.BdaVisibleString) BdaBitString(com.beanit.iec61850bean.BdaBitString) BdaUnicodeString(com.beanit.iec61850bean.BdaUnicodeString) BdaOctetString(com.beanit.iec61850bean.BdaOctetString) FcModelNode(com.beanit.iec61850bean.FcModelNode) ModelNode(com.beanit.iec61850bean.ModelNode)

Example 3 with FcModelNode

use of com.beanit.iec61850bean.FcModelNode in project OpenMUC by isc-konstanz.

the class Iec61850Connection method fillRequestedNodes.

void fillRequestedNodes(List<FcModelNode> fcNodesToBeRequested, List<FcModelNode> remainingFcModelNodes, ServerModel serverModel) {
    FcModelNode currentFcModelNode = remainingFcModelNodes.get(0);
    if (!checkParent(currentFcModelNode, fcNodesToBeRequested, remainingFcModelNodes, serverModel)) {
        remainingFcModelNodes.remove(currentFcModelNode);
        fcNodesToBeRequested.add(currentFcModelNode);
    }
}
Also used : FcModelNode(com.beanit.iec61850bean.FcModelNode)

Example 4 with FcModelNode

use of com.beanit.iec61850bean.FcModelNode in project OpenMUC by isc-konstanz.

the class Iec61850Connection method setRecordContainerWithSamplingGroup.

private Object setRecordContainerWithSamplingGroup(List<ChannelRecordContainer> containers, Object containerListHandle, String samplingGroup) throws ConnectionException {
    FcModelNode fcModelNode;
    if (containerListHandle != null) {
        fcModelNode = (FcModelNode) containerListHandle;
    } else {
        String[] args = samplingGroup.split(":", 3);
        if (args.length != 2) {
            logger.debug("Wrong sampling group syntax: {}", samplingGroup);
            for (ChannelRecordContainer container : containers) {
                container.setRecord(new Record(Flag.DRIVER_ERROR_SAMPLING_GROUP_NOT_FOUND));
            }
            return null;
        }
        ModelNode modelNode = serverModel.findModelNode(args[0], Fc.fromString(args[1]));
        if (modelNode == null) {
            logger.debug("Error reading sampling group: no FCDO/DA or DataSet with object reference {} was not found in the server model.", samplingGroup);
            for (ChannelRecordContainer container : containers) {
                container.setRecord(new Record(Flag.DRIVER_ERROR_SAMPLING_GROUP_NOT_FOUND));
            }
            return null;
        }
        try {
            fcModelNode = (FcModelNode) modelNode;
        } catch (ClassCastException e) {
            logger.debug("Error reading channel: ModelNode with sampling group reference {} was found in the server model but is not a FcModelNode.", samplingGroup);
            for (ChannelRecordContainer container : containers) {
                container.setRecord(new Record(Flag.DRIVER_ERROR_SAMPLING_GROUP_NOT_FOUND));
            }
            return null;
        }
    }
    try {
        clientAssociation.getDataValues(fcModelNode);
    } catch (ServiceError e) {
        logger.debug("Error reading sampling group: service error calling getDataValues on {}: {}", samplingGroup, e);
        for (ChannelRecordContainer container : containers) {
            container.setRecord(new Record(Flag.DRIVER_ERROR_SAMPLING_GROUP_NOT_ACCESSIBLE));
        }
        return fcModelNode;
    } catch (IOException e) {
        throw new ConnectionException(e);
    }
    long receiveTime = System.currentTimeMillis();
    for (ChannelRecordContainer container : containers) {
        if (container.getChannelHandle() != null) {
            setRecord(container, (BasicDataAttribute) container.getChannelHandle(), receiveTime);
        } else {
            container.setRecord(new Record(Flag.DRIVER_ERROR_CHANNEL_NOT_PART_OF_SAMPLING_GROUP));
        }
    }
    return fcModelNode;
}
Also used : ServiceError(com.beanit.iec61850bean.ServiceError) ChannelRecordContainer(org.openmuc.framework.driver.spi.ChannelRecordContainer) FcModelNode(com.beanit.iec61850bean.FcModelNode) Record(org.openmuc.framework.data.Record) BdaVisibleString(com.beanit.iec61850bean.BdaVisibleString) BdaBitString(com.beanit.iec61850bean.BdaBitString) BdaUnicodeString(com.beanit.iec61850bean.BdaUnicodeString) BdaOctetString(com.beanit.iec61850bean.BdaOctetString) IOException(java.io.IOException) FcModelNode(com.beanit.iec61850bean.FcModelNode) ModelNode(com.beanit.iec61850bean.ModelNode) ConnectionException(org.openmuc.framework.driver.spi.ConnectionException)

Example 5 with FcModelNode

use of com.beanit.iec61850bean.FcModelNode in project OpenMUC by isc-konstanz.

the class Iec61850Connection method checkParent.

boolean checkParent(ModelNode modelNode, List<FcModelNode> fcNodesToBeRequested, List<FcModelNode> remainingModelNodes, ServerModel serverModel) {
    if (!(modelNode instanceof FcModelNode)) {
        return false;
    }
    FcModelNode fcModelNode = (FcModelNode) modelNode;
    ModelNode parentNode = serverModel;
    for (int i = 0; i < fcModelNode.getReference().size() - 1; i++) {
        parentNode = parentNode.getChild(fcModelNode.getReference().get(i), fcModelNode.getFc());
    }
    List<BasicDataAttribute> basicDataAttributes = parentNode.getBasicDataAttributes();
    for (BasicDataAttribute bda : basicDataAttributes) {
        if (!remainingModelNodes.contains(bda)) {
            return false;
        }
    }
    if (!checkParent(parentNode, fcNodesToBeRequested, remainingModelNodes, serverModel)) {
        for (BasicDataAttribute bda : basicDataAttributes) {
            remainingModelNodes.remove(bda);
        }
        fcNodesToBeRequested.add((FcModelNode) parentNode);
    }
    return true;
}
Also used : FcModelNode(com.beanit.iec61850bean.FcModelNode) BasicDataAttribute(com.beanit.iec61850bean.BasicDataAttribute) FcModelNode(com.beanit.iec61850bean.FcModelNode) ModelNode(com.beanit.iec61850bean.ModelNode)

Aggregations

FcModelNode (com.beanit.iec61850bean.FcModelNode)7 ModelNode (com.beanit.iec61850bean.ModelNode)5 BasicDataAttribute (com.beanit.iec61850bean.BasicDataAttribute)3 BdaBitString (com.beanit.iec61850bean.BdaBitString)3 BdaOctetString (com.beanit.iec61850bean.BdaOctetString)3 BdaUnicodeString (com.beanit.iec61850bean.BdaUnicodeString)3 BdaVisibleString (com.beanit.iec61850bean.BdaVisibleString)3 ServiceError (com.beanit.iec61850bean.ServiceError)3 IOException (java.io.IOException)3 Record (org.openmuc.framework.data.Record)3 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)3 ArrayList (java.util.ArrayList)1 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)1 ChannelValueContainer (org.openmuc.framework.driver.spi.ChannelValueContainer)1