use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850ClientRTUEventListener 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());
sb.append("\t \t\t").append(member);
}
}
}
this.logger.info(sb.append(System.lineSeparator()).toString());
}
use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850ClientRTUEventListener method processReport.
private void processReport(final Report report, final String reportDescription, final Iec61850ReportHandler reportHandler) throws ProtocolAdapterException {
if (report.getDataSet() == null) {
this.logger.warn("No DataSet available for {}", reportDescription);
return;
}
final List<FcModelNode> members = report.getDataSet().getMembers();
if ((members == null) || members.isEmpty()) {
this.logger.warn("No members in DataSet available for {}", reportDescription);
return;
}
final List<MeasurementDto> measurements = new ArrayList<>();
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 {
final MeasurementDto dto = reportHandler.handleMember(new ReadOnlyNodeContainer(this.deviceIdentification, member));
if (dto != null) {
measurements.add(dto);
} else {
this.logger.warn("Unsupprted member {}, skipping", member.getName());
}
} catch (final Exception e) {
this.logger.error("Error adding event notification for member {} from {}", member.getReference(), reportDescription, e);
}
}
final GetDataSystemIdentifierDto systemResult = reportHandler.createResult(measurements);
final List<GetDataSystemIdentifierDto> systems = new ArrayList<>();
systems.add(systemResult);
final ReportDto reportDto = new ReportDto(report.getSqNum(), new DateTime(report.getTimeOfEntry().getTimestampValue() + IEC61850_ENTRY_TIME_OFFSET), report.getRptId());
this.deviceManagementService.sendMeasurements(this.deviceIdentification, new GetDataResponseDto(systems, reportDto));
}
use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850DeviceConnectionService method readNodeDataValues.
public void readNodeDataValues(final String deviceIdentification, final FcModelNode fcModelNode) throws NodeReadException {
final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
if (iec61850Connection == null) {
return;
}
final ClientAssociation clientAssociation = iec61850Connection.getClientAssociation();
this.iec61850Client.readNodeDataValues(clientAssociation, fcModelNode);
}
use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850DeviceConnectionService method testIfConnectionIsCachedAndAlive.
private boolean testIfConnectionIsCachedAndAlive(final String deviceIdentification, final IED ied, final String serverName, final String logicalDevice) throws ProtocolAdapterException {
try {
LOGGER.info("Trying to find connection in cache for deviceIdentification: {}", deviceIdentification);
final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
if (iec61850Connection != null) {
// Already connected, check if connection is still usable.
LOGGER.info("Connection found for deviceIdentification: {}", deviceIdentification);
// requires manual reads of remote data.
if (ied != null && logicalDevice != null) {
final String description = this.getActualServerName(ied, serverName);
LOGGER.info("Testing if connection is alive using {}{}/{}.{} for deviceIdentification: {}", description, logicalDevice, LogicalNode.LOGICAL_NODE_ZERO.getDescription(), DataAttribute.NAME_PLATE.getDescription(), deviceIdentification);
final FcModelNode modelNode = this.getModelNode(logicalDevice, iec61850Connection, description);
this.iec61850Client.readNodeDataValues(iec61850Connection.getClientAssociation(), modelNode);
} else {
// Read all data values, which is much slower, but requires
// no manual reads of remote data.
LOGGER.info("Testing if connection is alive using readAllDataValues() for deviceIdentification: {}", deviceIdentification);
this.iec61850Client.readAllDataValues(iec61850Connection.getClientAssociation());
}
LOGGER.info("Connection is still active for deviceIdentification: {}", deviceIdentification);
return true;
}
} catch (final NodeReadException e) {
LOGGER.error("Connection is no longer active, removing connection from cache for deviceIdentification: " + deviceIdentification, e);
this.removeIec61850Connection(deviceIdentification);
}
return false;
}
use of org.openmuc.openiec61850.FcModelNode in project Protocol-Adapter-IEC61850 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<Fc>());
}
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;
}
Aggregations