use of com.beanit.openiec61850.LogicalDevice in project open-smart-grid-platform by OSGP.
the class DistributionAutomationGetDeviceModelRequestMessageProcessor method processLogicalDevices.
private synchronized List<LogicalDeviceDto> processLogicalDevices(final ServerModel model) {
final List<LogicalDeviceDto> logicalDevices = new ArrayList<>();
for (final ModelNode node : model.getChildren()) {
if (node instanceof LogicalDevice) {
final List<LogicalNodeDto> logicalNodes = this.processLogicalNodes((LogicalDevice) node);
logicalDevices.add(new LogicalDeviceDto(node.getName(), logicalNodes));
}
}
return logicalDevices;
}
use of com.beanit.openiec61850.LogicalDevice 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);
}
use of com.beanit.openiec61850.LogicalDevice 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);
}
use of com.beanit.openiec61850.LogicalDevice in project open-smart-grid-platform 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.disconnect(deviceIdentification);
}
return false;
}
use of com.beanit.openiec61850.LogicalDevice in project Protocol-Adapter-IEC61850 by OSGP.
the class DistributionAutomationGetDeviceModelRequestMessageProcessor method processLogicalDevices.
private synchronized List<LogicalDeviceDto> processLogicalDevices(final ServerModel model) {
final List<LogicalDeviceDto> logicalDevices = new ArrayList<>();
for (final ModelNode node : model.getChildren()) {
if (node instanceof LogicalDevice) {
final List<LogicalNodeDto> logicalNodes = this.processLogicalNodes((LogicalDevice) node);
logicalDevices.add(new LogicalDeviceDto(node.getName(), logicalNodes));
}
}
return logicalDevices;
}
Aggregations