Search in sources :

Example 6 with FcModelNode

use of com.beanit.openiec61850.FcModelNode 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 7 with FcModelNode

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

the class Iec61850ClientLMDEventListener method determineLightSensorValue.

private boolean determineLightSensorValue(final FcModelNode evnRpn, final String reportDescription) {
    final String dataObjectName = SubDataAttribute.STATE.getDescription();
    final BdaBoolean stVal = (BdaBoolean) evnRpn.getChild(dataObjectName);
    if (stVal == null) {
        throw this.childNodeNotAvailableException(evnRpn, dataObjectName, reportDescription);
    }
    return stVal.getValue();
}
Also used : BdaBoolean(com.beanit.openiec61850.BdaBoolean)

Example 8 with FcModelNode

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

the class Iec61850ClientLMDEventListener 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);
    if (Boolean.TRUE.equals(report.getBufOvfl())) {
        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) {
        this.logger.warn("report.getSqNum() < this.firstNewSqNum, report.getSqNum() = {}, this.firstNewSqNum = {}", report.getSqNum(), this.firstNewSqNum);
    }
    this.logReportDetails(report);
    if (CollectionUtils.isEmpty(report.getValues())) {
        this.logger.warn("No dataSet members available for {}", reportDescription);
        return;
    }
    final Map<LightMeasurementDevice, FcModelNode> reportMemberPerDevice = this.processReportedDataForLightMeasurementDevices(report.getValues());
    for (final LightMeasurementDevice lmd : reportMemberPerDevice.keySet()) {
        final String deviceIdentification = lmd.getDeviceIdentification();
        final Short index = lmd.getDigitalInput();
        final FcModelNode member = reportMemberPerDevice.get(lmd);
        final EventNotificationDto eventNotification = this.getEventNotificationForReportedData(member, timeOfEntry, reportDescription, deviceIdentification, index.intValue());
        try {
            this.deviceManagementService.addEventNotifications(deviceIdentification, Arrays.asList(eventNotification));
        } catch (final ProtocolAdapterException pae) {
            this.logger.error("Error adding device notifications for device: " + deviceIdentification, pae);
        }
    }
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.core.db.api.iec61850.entities.LightMeasurementDevice) FcModelNode(com.beanit.openiec61850.FcModelNode) EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) DateTime(org.joda.time.DateTime)

Example 9 with FcModelNode

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

the class Iec61850ClientLMDEventListener method evnRpnInfo.

private String evnRpnInfo(final String linePrefix, final FcModelNode evnRpn) {
    final String dataObjectName = SubDataAttribute.STATE.getDescription();
    final StringBuilder sb = new StringBuilder();
    final BdaBoolean stValNode = (BdaBoolean) evnRpn.getChild(dataObjectName);
    sb.append(linePrefix).append(dataObjectName).append(": ");
    if (stValNode == null) {
        sb.append("null");
    } else {
        final boolean stVal = stValNode.getValue();
        sb.append(stVal).append(" = ").append(stVal ? "true" : "false");
    }
    sb.append(System.lineSeparator());
    return sb.toString();
}
Also used : BdaBoolean(com.beanit.openiec61850.BdaBoolean)

Example 10 with FcModelNode

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

the class Iec61850ClientLMDEventListener method logDataSetMembersDetails.

private void logDataSetMembersDetails(final Report report, final List<FcModelNode> dataSetMembers, final StringBuilder sb) {
    if (dataSetMembers == null) {
        sb.append("\t           DataSet members:\tnull").append(System.lineSeparator());
    } else {
        sb.append("\t           DataSet:\t").append(report.getDataSetRef()).append(System.lineSeparator());
        if (!dataSetMembers.isEmpty()) {
            sb.append("\t   DataSet members:\t").append(dataSetMembers.size()).append(System.lineSeparator());
            for (final FcModelNode member : dataSetMembers) {
                sb.append("\t            member:\t").append(member).append(System.lineSeparator());
                this.checkNodeType(member, sb, "CSLC.EvnRpn");
            }
        }
    }
}
Also used : FcModelNode(com.beanit.openiec61850.FcModelNode)

Aggregations

FcModelNode (com.beanit.openiec61850.FcModelNode)13 DateTime (org.joda.time.DateTime)9 BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)8 FcModelNode (org.openmuc.openiec61850.FcModelNode)7 BdaInt8U (com.beanit.openiec61850.BdaInt8U)6 ArrayList (java.util.ArrayList)5 BdaBoolean (com.beanit.openiec61850.BdaBoolean)4 BdaTimestamp (com.beanit.openiec61850.BdaTimestamp)4 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 DataSet (org.openmuc.openiec61850.DataSet)3 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)3 DataSampleDto (org.opensmartgridplatform.dto.da.iec61850.DataSampleDto)3 Iec61850BdaOptFldsHelper (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.Iec61850BdaOptFldsHelper)2 BdaFloat32 (com.beanit.openiec61850.BdaFloat32)2 ObjectReference (com.beanit.openiec61850.ObjectReference)2 BigDecimal (java.math.BigDecimal)2 MathContext (java.math.MathContext)2 HashSet (java.util.HashSet)2