Search in sources :

Example 31 with FcModelNode

use of com.beanit.openiec61850.FcModelNode in project open-smart-grid-platform 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 (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) {
        skipRecordBecauseOfOldSqNum = true;
    }
    this.logReportDetails(report);
    final List<FcModelNode> dataSetMembers = report.getValues();
    if (CollectionUtils.isEmpty(dataSetMembers)) {
        this.logger.warn("No dataSet members available for {}", reportDescription);
        return;
    } else {
        this.logger.debug("Handling {} DataSet members for {}", dataSetMembers.size(), reportDescription);
    }
    for (final FcModelNode member : dataSetMembers) {
        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);
                this.logEventNotificationDeviceMessage(member);
            }
        } catch (final Exception e) {
            this.logger.error("Error adding event notification for member {} from {}", member.getReference(), reportDescription, e);
        }
    }
}
Also used : FcModelNode(com.beanit.openiec61850.FcModelNode) BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) IOException(java.io.IOException)

Example 32 with FcModelNode

use of com.beanit.openiec61850.FcModelNode in project open-smart-grid-platform 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<>());
        }
        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 : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FcModelNode(com.beanit.openiec61850.FcModelNode) ModelNode(com.beanit.openiec61850.ModelNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 33 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 int logicalDeviceIndex, final LogicalNode logicalNode, final DataAttribute dataAttribute, final Fc fc) throws NodeNotFoundException {
    final ObjectReference objectReference = this.createObjectReference(logicalDevice, logicalDeviceIndex, 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)

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