use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850UpdateFirmwareCommand method updateSecurityFirmware.
private void updateSecurityFirmware(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final String fullUrl, final DeviceMessageLog deviceMessageLog) throws NodeException {
LOGGER.info("Reading the security firmware node for device: {}", deviceConnection.getDeviceIdentification());
final NodeContainer securityFirmwareNode = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SECURITY_FIRMWARE, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), securityFirmwareNode.getFcmodelNode());
final String currentSecurityFirmwareDownloadUrl = securityFirmwareNode.getString(SubDataAttribute.URL);
final Date currentSecurityFirmwareUpdateDateTime = securityFirmwareNode.getDate(SubDataAttribute.START_TIME);
LOGGER.info("Current security firmware download url: {}, start time: {} for device: {}", currentSecurityFirmwareDownloadUrl, currentSecurityFirmwareUpdateDateTime, deviceConnection.getDeviceIdentification());
LOGGER.info("Updating the security firmware download url to : {} for device: {}", fullUrl, deviceConnection.getDeviceIdentification());
securityFirmwareNode.writeString(SubDataAttribute.URL, fullUrl);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SECURITY_FIRMWARE, Fc.CF, SubDataAttribute.URL, fullUrl);
final Date oneMinuteFromNow = this.determineFirmwareUpdateDateTime(iec61850Client, deviceConnection);
LOGGER.info("Updating the security firmware download start time to: {} for device: {}", oneMinuteFromNow, deviceConnection.getDeviceIdentification());
securityFirmwareNode.writeDate(SubDataAttribute.START_TIME, oneMinuteFromNow);
deviceMessageLog.addVariable(LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.SECURITY_FIRMWARE, Fc.CF, SubDataAttribute.START_TIME, simpleDateFormat.format(oneMinuteFromNow));
}
use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850UpdateFirmwareCommand method pushFirmwareToDevice.
public void pushFirmwareToDevice(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection, final String fullUrl, final FirmwareModuleData firmwareModuleData) throws ProtocolAdapterException {
final Function<Void> function = new Function<Void>() {
@Override
public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
final int count = firmwareModuleData.countNumberOfModules();
if (count != 1) {
throw new ProtocolAdapterException(String.format("Number of firmware modules is not equal to 1 but %d", count));
}
// updated.
if (FirmwareModuleType.FUNCTIONAL.name().equalsIgnoreCase(firmwareModuleData.getModuleVersionFunc())) {
Iec61850UpdateFirmwareCommand.this.updateFunctionalFirmware(iec61850Client, deviceConnection, fullUrl, deviceMessageLog);
} else if (FirmwareModuleType.SECURITY.name().equalsIgnoreCase(firmwareModuleData.getModuleVersionSec())) {
Iec61850UpdateFirmwareCommand.this.updateSecurityFirmware(iec61850Client, deviceConnection, fullUrl, deviceMessageLog);
} else {
throw new ProtocolAdapterException(String.format("Unsupported firmwareModuleData (only functional and security are allowed): communication: %s, functional: %s, module-active: %s, m-bus: %s, security: %s, fullUrl: %s", firmwareModuleData.getModuleVersionComm(), firmwareModuleData.getModuleVersionFunc(), firmwareModuleData.getModuleVersionMa(), firmwareModuleData.getModuleVersionMbus(), firmwareModuleData.getModuleVersionSec(), fullUrl));
}
DeviceMessageLoggingService.logMessage(deviceMessageLog, deviceConnection.getDeviceIdentification(), deviceConnection.getOrganisationIdentification(), false);
return null;
}
};
iec61850Client.sendCommandWithRetry(function, "UpdateFirmware", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850UpdateFirmwareCommand method determineFirmwareUpdateDateTime.
private Date determineFirmwareUpdateDateTime(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws NodeReadException {
final NodeContainer clock = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.CLOCK, Fc.CF);
iec61850Client.readNodeDataValues(deviceConnection.getConnection().getClientAssociation(), clock.getFcmodelNode());
final DateTime deviceTime = new DateTime(clock.getDate(SubDataAttribute.CURRENT_TIME));
// Creating a DateTime one minute from now.
return deviceTime.plusMinutes(1).toDate();
}
use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850VlmCapCommand method execute.
@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeReadException {
final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.TANK_CHARACTERISTICS_ONE, DataAttribute.VLMCAP, Fc.SP);
client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
return this.translate(containingNode);
}
use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850TotalEnergyCommand method execute.
@Override
public MeasurementDto execute(final Iec61850Client client, final DeviceConnection connection, final LogicalDevice logicalDevice, final int logicalDeviceIndex) throws NodeReadException {
final NodeContainer containingNode = connection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.GENERATOR_ONE, DataAttribute.TOTAL_ENERGY, Fc.MX);
client.readNodeDataValues(connection.getConnection().getClientAssociation(), containingNode.getFcmodelNode());
return this.translate(containingNode);
}
Aggregations