Search in sources :

Example 6 with FcModelNode

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

the class Iec61850ClientRTUEventListener method logReportDetails.

private void logReportDetails(final Report report) {
    final StringBuilder sb = new StringBuilder("Report details for device ").append(this.deviceIdentification).append(System.lineSeparator());
    sb.append("\t             RptId:\t").append(report.getRptId()).append(System.lineSeparator());
    sb.append("\t        DataSetRef:\t").append(report.getDataSetRef()).append(System.lineSeparator());
    sb.append("\t           ConfRev:\t").append(report.getConfRev()).append(System.lineSeparator());
    sb.append("\t           BufOvfl:\t").append(report.isBufOvfl()).append(System.lineSeparator());
    sb.append("\t           EntryId:\t").append(report.getEntryId()).append(System.lineSeparator());
    sb.append("\tInclusionBitString:\t").append(Arrays.toString(report.getInclusionBitString())).append(System.lineSeparator());
    sb.append("\tMoreSegmentsFollow:\t").append(report.isMoreSegmentsFollow()).append(System.lineSeparator());
    sb.append("\t             SqNum:\t").append(report.getSqNum()).append(System.lineSeparator());
    sb.append("\t          SubSqNum:\t").append(report.getSubSqNum()).append(System.lineSeparator());
    sb.append("\t       TimeOfEntry:\t").append(report.getTimeOfEntry()).append(System.lineSeparator());
    if (report.getTimeOfEntry() != null) {
        sb.append("\t                   \t(").append(new DateTime(report.getTimeOfEntry().getTimestampValue() + IEC61850_ENTRY_TIME_OFFSET)).append(')').append(System.lineSeparator());
    }
    final List<BdaReasonForInclusion> reasonCodes = report.getReasonCodes();
    if ((reasonCodes != null) && !reasonCodes.isEmpty()) {
        sb.append("\t       ReasonCodes:").append(System.lineSeparator());
        for (final BdaReasonForInclusion reasonCode : reasonCodes) {
            sb.append("\t                   \t").append(reasonCode.getReference() == null ? HexConverter.toHexString(reasonCode.getValue()) : reasonCode).append("\t(").append(new Iec61850BdaReasonForInclusionHelper(reasonCode).getInfo()).append(')').append(System.lineSeparator());
        }
    }
    sb.append("\t           optFlds:").append(report.getOptFlds()).append("\t(").append(new Iec61850BdaOptFldsHelper(report.getOptFlds()).getInfo()).append(')').append(System.lineSeparator());
    final DataSet dataSet = report.getDataSet();
    if (dataSet == null) {
        sb.append("\t           DataSet:\tnull").append(System.lineSeparator());
    } else {
        sb.append("\t           DataSet:\t").append(dataSet.getReferenceStr()).append(System.lineSeparator());
        final List<FcModelNode> members = dataSet.getMembers();
        if ((members != null) && !members.isEmpty()) {
            sb.append("\t   DataSet members:\t").append(members.size()).append(System.lineSeparator());
            for (final FcModelNode member : members) {
                sb.append("\t            member:\t").append(member).append(System.lineSeparator());
                sb.append("\t                   \t\t").append(member);
            }
        }
    }
    this.logger.info(sb.append(System.lineSeparator()).toString());
}
Also used : BdaReasonForInclusion(org.openmuc.openiec61850.BdaReasonForInclusion) DataSet(org.openmuc.openiec61850.DataSet) FcModelNode(org.openmuc.openiec61850.FcModelNode) Iec61850BdaOptFldsHelper(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850BdaOptFldsHelper) DateTime(org.joda.time.DateTime)

Example 7 with FcModelNode

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

the class Iec61850ClientRTUEventListener method processReport.

private void processReport(final Report report, final String reportDescription, final Iec61850ReportHandler reportHandler) throws ProtocolAdapterException {
    if (report.getDataSet() == null) {
        this.logger.warn("No DataSet available for {}", reportDescription);
        return;
    }
    final List<FcModelNode> members = report.getDataSet().getMembers();
    if ((members == null) || members.isEmpty()) {
        this.logger.warn("No members in DataSet available for {}", reportDescription);
        return;
    }
    final List<MeasurementDto> measurements = new ArrayList<>();
    for (final FcModelNode member : members) {
        if (member == null) {
            this.logger.warn("Member == null in DataSet for {}", reportDescription);
            continue;
        }
        this.logger.info("Handle member {} for {}", member.getReference(), reportDescription);
        try {
            final MeasurementDto dto = reportHandler.handleMember(new ReadOnlyNodeContainer(this.deviceIdentification, member));
            if (dto != null) {
                measurements.add(dto);
            } else {
                this.logger.warn("Unsupprted member {}, skipping", member.getName());
            }
        } catch (final Exception e) {
            this.logger.error("Error adding event notification for member {} from {}", member.getReference(), reportDescription, e);
        }
    }
    final GetDataSystemIdentifierDto systemResult = reportHandler.createResult(measurements);
    final List<GetDataSystemIdentifierDto> systems = new ArrayList<>();
    systems.add(systemResult);
    final ReportDto reportDto = new ReportDto(report.getSqNum(), new DateTime(report.getTimeOfEntry().getTimestampValue() + IEC61850_ENTRY_TIME_OFFSET), report.getRptId());
    this.deviceManagementService.sendMeasurements(this.deviceIdentification, new GetDataResponseDto(systems, reportDto));
}
Also used : GetDataResponseDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto) GetDataSystemIdentifierDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataSystemIdentifierDto) ArrayList(java.util.ArrayList) FcModelNode(org.openmuc.openiec61850.FcModelNode) ReportDto(com.alliander.osgp.dto.valueobjects.microgrids.ReportDto) ReadOnlyNodeContainer(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.ReadOnlyNodeContainer) MeasurementDto(com.alliander.osgp.dto.valueobjects.microgrids.MeasurementDto) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) DateTime(org.joda.time.DateTime)

Example 8 with FcModelNode

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

the class Iec61850DeviceConnectionService method readNodeDataValues.

public void readNodeDataValues(final String deviceIdentification, final FcModelNode fcModelNode) throws NodeReadException {
    final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
    if (iec61850Connection == null) {
        return;
    }
    final ClientAssociation clientAssociation = iec61850Connection.getClientAssociation();
    this.iec61850Client.readNodeDataValues(clientAssociation, fcModelNode);
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(org.openmuc.openiec61850.ClientAssociation)

Example 9 with FcModelNode

use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 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.removeIec61850Connection(deviceIdentification);
    }
    return false;
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) FcModelNode(org.openmuc.openiec61850.FcModelNode)

Example 10 with FcModelNode

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

the class DistributionAutomationGetPQValuesRequestMessageProcessor method processPQValueNodeChildren.

private List<DataSampleDto> processPQValueNodeChildren(final LogicalNode node) {
    final List<DataSampleDto> data = new ArrayList<>();
    final Collection<ModelNode> children = node.getChildren();
    final Map<String, Set<Fc>> childMap = new HashMap<>();
    for (final ModelNode child : children) {
        if (!childMap.containsKey(child.getName())) {
            childMap.put(child.getName(), new HashSet<Fc>());
        }
        childMap.get(child.getName()).add(((FcModelNode) child).getFc());
    }
    for (final Map.Entry<String, Set<Fc>> childEntry : childMap.entrySet()) {
        final List<DataSampleDto> childData = this.processPQValuesFunctionalConstraintObject(node, childEntry.getKey(), childEntry.getValue());
        if (!childData.isEmpty()) {
            data.addAll(childData);
        }
    }
    return data;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataSampleDto(org.osgpfoundation.osgp.dto.da.iec61850.DataSampleDto) FcModelNode(org.openmuc.openiec61850.FcModelNode) ModelNode(org.openmuc.openiec61850.ModelNode) Fc(org.openmuc.openiec61850.Fc) HashMap(java.util.HashMap) Map(java.util.Map)

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