Search in sources :

Example 1 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method newReport.

@Override
public void newReport(final Report report) {
    final DateTime timeOfEntry = this.getTimeOfEntry(report);
    final String reportDescription = this.getReportDescription(report, timeOfEntry);
    this.logger.info("newReport for {}", reportDescription);
    boolean skipRecordBecauseOfOldSqNum = false;
    if (report.isBufOvfl()) {
        this.logger.warn("Buffer Overflow reported for {} - entries within the buffer may have been lost.", reportDescription);
    }
    if (this.firstNewSqNum != null && report.getSqNum() != null && report.getSqNum() < this.firstNewSqNum) {
        skipRecordBecauseOfOldSqNum = true;
    }
    this.logReportDetails(report);
    final DataSet dataSet = report.getDataSet();
    if (dataSet == null) {
        this.logger.warn("No DataSet available for {}", reportDescription);
        return;
    }
    final List<FcModelNode> members = dataSet.getMembers();
    if (members == null || members.isEmpty()) {
        this.logger.warn("No members in DataSet available for {}", reportDescription);
        return;
    } else {
        this.logger.debug("Handling {} DataSet members for {}", members.size(), reportDescription);
    }
    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 {
            if (skipRecordBecauseOfOldSqNum) {
                this.logger.warn("Skipping report because SqNum: {} is less than what should be the first new value: {}", report.getSqNum(), this.firstNewSqNum);
            } else {
                this.addEventNotificationForReportedData(member, timeOfEntry, reportDescription);
            }
        } catch (final Exception e) {
            this.logger.error("Error adding event notification for member {} from {}", member.getReference(), reportDescription, e);
        }
    }
}
Also used : DataSet(org.openmuc.openiec61850.DataSet) FcModelNode(org.openmuc.openiec61850.FcModelNode) BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime) IOException(java.io.IOException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Example 2 with FcModelNode

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

the class Iec61850ClientSSLDEventListener 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());
                if (member.getReference().toString().contains("CSLC.EvnRpn")) {
                    sb.append(this.evnRpnInfo("\t                   \t\t", 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 3 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method determineRelayIndex.

private Integer determineRelayIndex(final FcModelNode evnRpn, final String reportDescription) throws ProtocolAdapterException {
    final BdaInt8U swNumNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_SWITCH_NUMBER);
    if (swNumNode == null) {
        throw this.childNodeNotAvailableException(evnRpn, EVENT_NODE_SWITCH_NUMBER, reportDescription);
    }
    final Short swNum = swNumNode.getValue();
    final Integer externalIndex = this.externalIndexByInternalIndex.get(swNum.intValue());
    if (externalIndex == null) {
        this.logger.error("No external index configured for internal index: {} for device: {}, using '0' for event", swNum, this.deviceIdentification);
        return 0;
    }
    return externalIndex;
}
Also used : BdaInt8U(org.openmuc.openiec61850.BdaInt8U)

Example 4 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method addEventNotificationForReportedData.

private void addEventNotificationForReportedData(final FcModelNode evnRpn, final DateTime timeOfEntry, final String reportDescription) throws ProtocolAdapterException {
    final EventTypeDto eventType = this.determineEventType(evnRpn, reportDescription);
    final Integer index = this.determineRelayIndex(evnRpn, reportDescription);
    final String description = this.determineDescription(evnRpn);
    final DateTime dateTime = this.determineDateTime(evnRpn, timeOfEntry);
    final EventNotificationDto eventNotification = new EventNotificationDto(this.deviceIdentification, dateTime, eventType, description, index);
    synchronized (this.eventNotifications) {
        this.eventNotifications.add(eventNotification);
    }
}
Also used : EventNotificationDto(com.alliander.osgp.dto.valueobjects.EventNotificationDto) BdaVisibleString(org.openmuc.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime) EventTypeDto(com.alliander.osgp.dto.valueobjects.EventTypeDto)

Example 5 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method determineEventType.

private EventTypeDto determineEventType(final FcModelNode evnRpn, final String reportDescription) {
    final BdaInt8U evnTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_EVENT_TYPE);
    if (evnTypeNode == null) {
        throw this.childNodeNotAvailableException(evnRpn, EVENT_NODE_EVENT_TYPE, reportDescription);
    }
    final short evnTypeCode = evnTypeNode.getValue();
    final EventType eventType = EventType.forCode(evnTypeCode);
    return eventType.getOsgpEventType();
}
Also used : EventType(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.EventType) BdaInt8U(org.openmuc.openiec61850.BdaInt8U)

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