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();
}
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();
}
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);
}
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);
}
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);
}
Aggregations