Search in sources :

Example 16 with FcModelNode

use of com.beanit.openiec61850.FcModelNode in project open-smart-grid-platform 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(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.EventType) BdaInt8U(com.beanit.openiec61850.BdaInt8U)

Example 17 with FcModelNode

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

the class Iec61850ClientSSLDEventListener method evnRpnInfo.

private String evnRpnInfo(final String linePrefix, final FcModelNode evnRpn) {
    final StringBuilder sb = new StringBuilder();
    final BdaInt8U evnTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_EVENT_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_EVENT_TYPE).append(": ");
    if (evnTypeNode == null) {
        sb.append("null");
    } else {
        final short evnType = evnTypeNode.getValue();
        sb.append(evnType).append(" = ").append(EventType.forCode(evnType).getDescription());
    }
    sb.append(System.lineSeparator());
    final BdaInt8U swNumNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_SWITCH_NUMBER);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_NUMBER).append(": ");
    if (swNumNode == null) {
        sb.append("null");
    } else {
        final short swNum = swNumNode.getValue();
        sb.append(swNum).append(" = ").append("get external index for switch ").append(swNum);
    }
    sb.append(System.lineSeparator());
    final BdaInt8U trgTypeNode = (BdaInt8U) evnRpn.getChild(EVENT_NODE_TRIGGER_TYPE);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TYPE).append(": ");
    if (trgTypeNode == null) {
        sb.append("null");
    } else {
        final short trgType = trgTypeNode.getValue();
        sb.append(trgType).append(" = ").append(TRG_TYPE_DESCRIPTION_PER_CODE.get(trgType));
    }
    sb.append(System.lineSeparator());
    final BdaBoolean swValNode = (BdaBoolean) evnRpn.getChild(EVENT_NODE_SWITCH_VALUE);
    sb.append(linePrefix).append(EVENT_NODE_SWITCH_VALUE).append(": ");
    if (swValNode == null) {
        sb.append("null");
    } else {
        final boolean swVal = swValNode.getValue();
        sb.append(swVal).append(" = ").append(swVal ? "ON" : "OFF");
    }
    sb.append(System.lineSeparator());
    final BdaTimestamp trgTimeNode = (BdaTimestamp) evnRpn.getChild(EVENT_NODE_TRIGGER_TIME);
    sb.append(linePrefix).append(EVENT_NODE_TRIGGER_TIME).append(": ");
    if (trgTimeNode == null || trgTimeNode.getDate() == null) {
        sb.append("null");
    } else {
        final DateTime trgTime = new DateTime(trgTimeNode.getDate());
        sb.append(trgTime);
    }
    sb.append(System.lineSeparator());
    final BdaVisibleString remarkNode = (BdaVisibleString) evnRpn.getChild(EVENT_NODE_REMARK);
    sb.append(linePrefix).append(EVENT_NODE_REMARK).append(": ");
    if (remarkNode == null) {
        sb.append("null");
    } else {
        final String remark = remarkNode.getStringValue();
        sb.append(remark);
    }
    sb.append(System.lineSeparator());
    return sb.toString();
}
Also used : BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) BdaInt8U(com.beanit.openiec61850.BdaInt8U) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaBoolean(com.beanit.openiec61850.BdaBoolean) BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime)

Example 18 with FcModelNode

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

the class Iec61850ClientDaRTUEventListener method processSingleMeasurementNode.

private void processSingleMeasurementNode(final FcModelNode member, final LogicalNode logicalNode, final ModelNode childNode) {
    final BdaFloat32 singleMeasurement = this.getSingleMeasurementModelNode(childNode);
    final BdaTimestamp timestampMeasurement = this.getTimestampModelNode(childNode);
    String type = member.getName() + "." + childNode.getName();
    type += "." + singleMeasurement.getParent().getParent().getName() + "." + singleMeasurement.getParent().getName() + "." + singleMeasurement.getName();
    final BigDecimal value = new BigDecimal(singleMeasurement.getFloat(), new MathContext(3, RoundingMode.HALF_EVEN));
    final DataSampleDto sample = new DataSampleDto(type, timestampMeasurement.getDate(), value);
    logicalNode.getDataSamples().add(sample);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaFloat32(com.beanit.openiec61850.BdaFloat32) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 19 with FcModelNode

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

the class Iec61850ClientDaRTUEventListener method processTotalMeasurementNode.

private void processTotalMeasurementNode(final FcModelNode member, final LogicalNode logicalNode) {
    final BdaFloat32 totalMeasurement = this.getTotalMeasurementModelNode(member);
    final BdaTimestamp timestampMeasurement = this.getTimestampModelNode(member);
    String type = member.getName();
    type += "." + totalMeasurement.getParent().getName() + "." + totalMeasurement.getName();
    final BigDecimal value = new BigDecimal(totalMeasurement.getFloat(), new MathContext(3, RoundingMode.HALF_EVEN));
    final DataSampleDto sample = new DataSampleDto(type, timestampMeasurement.getDate(), value);
    logicalNode.getDataSamples().add(sample);
}
Also used : DataSampleDto(org.opensmartgridplatform.dto.da.iec61850.DataSampleDto) BdaTimestamp(com.beanit.openiec61850.BdaTimestamp) BdaFloat32(com.beanit.openiec61850.BdaFloat32) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 20 with FcModelNode

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

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