Search in sources :

Example 1 with LogicalDevice

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

the class DistributionAutomationGetDeviceModelRequestMessageProcessor method processLogicalDevices.

private synchronized List<LogicalDeviceDto> processLogicalDevices(final ServerModel model) {
    final List<LogicalDeviceDto> logicalDevices = new ArrayList<>();
    for (final ModelNode node : model.getChildren()) {
        if (node instanceof LogicalDevice) {
            final List<LogicalNodeDto> logicalNodes = this.processLogicalNodes((LogicalDevice) node);
            logicalDevices.add(new LogicalDeviceDto(node.getName(), logicalNodes));
        }
    }
    return logicalDevices;
}
Also used : LogicalDeviceDto(org.opensmartgridplatform.dto.da.iec61850.LogicalDeviceDto) LogicalDevice(com.beanit.openiec61850.LogicalDevice) LogicalNodeDto(org.opensmartgridplatform.dto.da.iec61850.LogicalNodeDto) ArrayList(java.util.ArrayList) ModelNode(com.beanit.openiec61850.ModelNode)

Example 2 with LogicalDevice

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

the class DeviceConnection method getFcModelNode.

/**
 * Returns a {@link NodeContainer} for the given {@link ObjectReference} data and the Functional
 * constraint.
 *
 * @throws NodeNotFoundException
 */
public NodeContainer getFcModelNode(final LogicalDevice logicalDevice, final LogicalNode logicalNode, final DataAttribute dataAttribute, final Fc fc) throws NodeNotFoundException {
    final ObjectReference objectReference = this.createObjectReference(logicalDevice, logicalNode, dataAttribute);
    final FcModelNode fcModelNode = (FcModelNode) this.connection.getServerModel().findModelNode(objectReference, fc);
    if (fcModelNode == null) {
        LOGGER.error("FcModelNode is null, most likely the data attribute: {} does not exist", dataAttribute.getDescription());
        throw new NodeNotFoundException(String.format("FcModelNode with objectReference %s does not exist", objectReference));
    }
    return new NodeContainer(this, fcModelNode);
}
Also used : NodeNotFoundException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeNotFoundException) ObjectReference(com.beanit.openiec61850.ObjectReference) FcModelNode(com.beanit.openiec61850.FcModelNode)

Example 3 with LogicalDevice

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

the class Iec61850ClientDaRTUEventListener method processReport.

private void processReport(final Report report, final String reportDescription) throws ProtocolAdapterException {
    final List<FcModelNode> dataSetMembers = report.getValues();
    final List<LogicalDevice> logicalDevices = new ArrayList<>();
    if (CollectionUtils.isEmpty(dataSetMembers)) {
        this.logger.warn("No dataSet members available for {}", reportDescription);
        return;
    }
    for (final FcModelNode member : dataSetMembers) {
        // we are only interested in measurements
        if (member.getFc() == Fc.MX) {
            this.processMeasurementNode(logicalDevices, member);
        }
    }
    final List<LogicalDeviceDto> logicalDevicesDtos = new ArrayList<>();
    for (final LogicalDevice logicalDevice : logicalDevices) {
        final List<LogicalNodeDto> logicalNodeDtos = new ArrayList<>();
        for (final LogicalNode logicalNode : logicalDevice.getLogicalNodes()) {
            final LogicalNodeDto logicalNodeDto = new LogicalNodeDto(logicalNode.getName(), logicalNode.getDataSamples());
            logicalNodeDtos.add(logicalNodeDto);
        }
        final LogicalDeviceDto logicalDeviceDto = new LogicalDeviceDto(logicalDevice.getName(), logicalNodeDtos);
        logicalDevicesDtos.add(logicalDeviceDto);
    }
    final GetPQValuesResponseDto response = new GetPQValuesResponseDto(logicalDevicesDtos);
    this.deviceManagementService.sendPqValues(this.deviceIdentification, report.getRptId(), response);
}
Also used : GetPQValuesResponseDto(org.opensmartgridplatform.dto.da.GetPQValuesResponseDto) LogicalDeviceDto(org.opensmartgridplatform.dto.da.iec61850.LogicalDeviceDto) LogicalNodeDto(org.opensmartgridplatform.dto.da.iec61850.LogicalNodeDto) ArrayList(java.util.ArrayList) FcModelNode(com.beanit.openiec61850.FcModelNode)

Example 4 with LogicalDevice

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

the class Iec61850DeviceConnectionService method testIfConnectionIsCachedAndAlive.

private boolean testIfConnectionIsCachedAndAlive(final String deviceIdentification, final IED ied, final String serverName, final String logicalDevice) throws ProtocolAdapterException {
    try {
        LOGGER.info("Trying to find connection in cache for deviceIdentification: {}", deviceIdentification);
        final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
        if (iec61850Connection != null) {
            // Already connected, check if connection is still usable.
            LOGGER.info("Connection found for deviceIdentification: {}", deviceIdentification);
            // requires manual reads of remote data.
            if (ied != null && logicalDevice != null) {
                final String description = this.getActualServerName(ied, serverName);
                LOGGER.info("Testing if connection is alive using {}{}/{}.{} for deviceIdentification: {}", description, logicalDevice, LogicalNode.LOGICAL_NODE_ZERO.getDescription(), DataAttribute.NAME_PLATE.getDescription(), deviceIdentification);
                final FcModelNode modelNode = this.getModelNode(logicalDevice, iec61850Connection, description);
                this.iec61850Client.readNodeDataValues(iec61850Connection.getClientAssociation(), modelNode);
            } else {
                // Read all data values, which is much slower, but requires
                // no manual reads of remote data.
                LOGGER.info("Testing if connection is alive using readAllDataValues() for deviceIdentification: {}", deviceIdentification);
                this.iec61850Client.readAllDataValues(iec61850Connection.getClientAssociation());
            }
            LOGGER.info("Connection is still active for deviceIdentification: {}", deviceIdentification);
            return true;
        }
    } catch (final NodeReadException e) {
        LOGGER.error("Connection is no longer active, removing connection from cache for deviceIdentification: " + deviceIdentification, e);
        this.disconnect(deviceIdentification);
    }
    return false;
}
Also used : Iec61850Connection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.Iec61850Connection) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) FcModelNode(com.beanit.openiec61850.FcModelNode)

Example 5 with LogicalDevice

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

the class DistributionAutomationGetDeviceModelRequestMessageProcessor method processLogicalDevices.

private synchronized List<LogicalDeviceDto> processLogicalDevices(final ServerModel model) {
    final List<LogicalDeviceDto> logicalDevices = new ArrayList<>();
    for (final ModelNode node : model.getChildren()) {
        if (node instanceof LogicalDevice) {
            final List<LogicalNodeDto> logicalNodes = this.processLogicalNodes((LogicalDevice) node);
            logicalDevices.add(new LogicalDeviceDto(node.getName(), logicalNodes));
        }
    }
    return logicalDevices;
}
Also used : LogicalDeviceDto(org.osgpfoundation.osgp.dto.da.iec61850.LogicalDeviceDto) LogicalDevice(org.openmuc.openiec61850.LogicalDevice) LogicalNodeDto(org.osgpfoundation.osgp.dto.da.iec61850.LogicalNodeDto) ArrayList(java.util.ArrayList) ModelNode(org.openmuc.openiec61850.ModelNode)

Aggregations

FcModelNode (com.beanit.openiec61850.FcModelNode)5 BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)4 ArrayList (java.util.ArrayList)4 LogicalDevice (org.opensmartgridplatform.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)4 ModelNode (com.beanit.openiec61850.ModelNode)2 ObjectReference (com.beanit.openiec61850.ObjectReference)2 NodeNotFoundException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeNotFoundException)2 LogicalDeviceDto (org.opensmartgridplatform.dto.da.iec61850.LogicalDeviceDto)2 LogicalNodeDto (org.opensmartgridplatform.dto.da.iec61850.LogicalNodeDto)2 LogicalDevice (com.beanit.openiec61850.LogicalDevice)1 SclParseException (com.beanit.openiec61850.SclParseException)1 ServerModel (com.beanit.openiec61850.ServerModel)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 LogicalDevice (org.openmuc.openiec61850.LogicalDevice)1 ModelNode (org.openmuc.openiec61850.ModelNode)1 NodeReadException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1