use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.
the class Iec61850GetFirmwareVersionCommand method getFirmwareVersionFromDevice.
public List<FirmwareVersionDto> getFirmwareVersionFromDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws ProtocolAdapterException {
final Function<List<FirmwareVersionDto>> function = new Function<List<FirmwareVersionDto>>() {
@Override
public List<FirmwareVersionDto> apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
final List<FirmwareVersionDto> output = new ArrayList<>();
// Getting the functional firmware version
LOGGER.info("Reading the functional firmware version");
final NodeContainer functionalFirmwareNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.FUNCTIONAL_FIRMWARE, Fc.ST);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), functionalFirmwareNode.getFcmodelNode());
final String functionalFirmwareVersion = functionalFirmwareNode.getString(SubDataAttribute.CURRENT_VERSION);
// Adding it to the list
output.add(new FirmwareVersionDto(FirmwareModuleType.FUNCTIONAL, functionalFirmwareVersion));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.FUNCTIONAL_FIRMWARE, Fc.ST, SubDataAttribute.CURRENT_VERSION, functionalFirmwareVersion);
// Getting the security firmware version
LOGGER.info("Reading the security firmware version");
final NodeContainer securityFirmwareNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SECURITY_FIRMWARE, Fc.ST);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), securityFirmwareNode.getFcmodelNode());
final String securityFirmwareVersion = securityFirmwareNode.getString(SubDataAttribute.CURRENT_VERSION);
// Adding it to the list
output.add(new FirmwareVersionDto(FirmwareModuleType.SECURITY, securityFirmwareVersion));
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SECURITY_FIRMWARE, Fc.ST, SubDataAttribute.CURRENT_VERSION, securityFirmwareVersion);
Iec61850GetFirmwareVersionCommand.this.loggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
return output;
}
};
return iec61850Client.sendCommandWithRetry(function, "GetFirmwareVersion", deviceConnection.getDeviceIdentification());
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.
the class Iec61850GetStatusCommand method getStatusFromDevice.
public DeviceStatusDto getStatusFromDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final Ssld ssld) throws ProtocolAdapterException {
final Function<DeviceStatusDto> function = new Function<DeviceStatusDto>() {
@Override
public DeviceStatusDto apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
// getting the light relay values
final List<LightValueDto> lightValues = new ArrayList<>();
for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) {
final LogicalNode logicalNode = LogicalNode.getSwitchComponentByIndex(deviceOutputSetting.getInternalId());
final NodeContainer position = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, logicalNode, DataAttribute.POSITION, Fc.ST);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), position.getFcmodelNode());
final BdaBoolean state = position.getBoolean(SubDataAttribute.STATE);
final boolean on = state.getValue();
lightValues.add(new LightValueDto(deviceOutputSetting.getExternalId(), on, null));
LOGGER.info(String.format("Got status of relay %d => %s", deviceOutputSetting.getInternalId(), on ? "on" : "off"));
deviceMessageLog.addVariable(logicalNode, DataAttribute.POSITION, Fc.ST, SubDataAttribute.STATE, Boolean.toString(on));
}
final NodeContainer eventBuffer = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), eventBuffer.getFcmodelNode());
final String filter = eventBuffer.getString(SubDataAttribute.EVENT_BUFFER_FILTER);
LOGGER.info("Got EvnBuf.enbEvnType filter {}", filter);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.EVENT_BUFFER, Fc.CF, SubDataAttribute.EVENT_BUFFER_FILTER, filter);
final Set<EventNotificationTypeDto> notificationTypes = EventType.getNotificationTypesForFilter(filter);
int eventNotificationsMask = 0;
for (final EventNotificationTypeDto notificationType : notificationTypes) {
eventNotificationsMask |= notificationType.getValue();
}
final NodeContainer softwareConfiguration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), softwareConfiguration.getFcmodelNode());
String lightTypeValue = softwareConfiguration.getString(SubDataAttribute.LIGHT_TYPE);
// Fix for Kaifa bug KI-31
if (lightTypeValue == null || lightTypeValue.isEmpty()) {
lightTypeValue = "RELAY";
}
final LightTypeDto lightType = LightTypeDto.valueOf(lightTypeValue);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SOFTWARE_CONFIGURATION, Fc.CF, SubDataAttribute.LIGHT_TYPE, lightTypeValue);
Iec61850GetStatusCommand.this.loggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
/*
* The preferredLinkType and actualLinkType are hard-coded to
* LinkTypeDto.ETHERNET, other link types do not apply to the
* device type in use.
*/
return new DeviceStatusDto(lightValues, LinkTypeDto.ETHERNET, LinkTypeDto.ETHERNET, lightType, eventNotificationsMask);
}
};
return iec61850Client.sendCommandWithRetry(function, "GetStatus", deviceConnection.getDeviceIdentification());
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.
the class Iec61850LoadMaximumActualPowerCommand method execute.
@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeException {
final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, this.logicalNode, DataAttribute.MAX_ACTUAL_POWER, Fc.MX);
client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
return this.translate(containingNode);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.
the class Iec61850LoadTotalEnergyCommand method execute.
@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeException {
final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, this.logicalNode, DataAttribute.TOTAL_ENERGY, Fc.ST);
client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
return this.translate(containingNode);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project open-smart-grid-platform by OSGP.
the class Iec61850MaterialStatusCommand method execute.
@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeException {
final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, this.logicalNode, DataAttribute.MATERIAL_STATUS, Fc.SP);
client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
return this.translate(containingNode);
}
Aggregations