use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto in project open-smart-grid-platform by OSGP.
the class Iec61850SsldDeviceService method getFirmwareVersion.
@Override
public void getFirmwareVersion(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
final List<FirmwareVersionDto> firmwareVersions = new Iec61850GetFirmwareVersionCommand(this.deviceMessageLoggingService).getFirmwareVersionFromDevice(this.iec61850Client, deviceConnection);
final GetFirmwareVersionDeviceResponse deviceResponse = new GetFirmwareVersionDeviceResponse(deviceRequest, firmwareVersions);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
}
this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto 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.dto.valueobjects.FirmwareVersionDto in project open-smart-grid-platform by OSGP.
the class CommonGetFirmwareResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common get firmware version response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
@SuppressWarnings("unchecked") final List<FirmwareVersionDto> firmwareVersions = (List<FirmwareVersionDto>) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.firmwareManagementService.handleGetFirmwareVersionResponse(firmwareVersions, ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto in project open-smart-grid-platform by OSGP.
the class GetFirmwareVersionResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (responseMessage.getDataObject() instanceof ArrayList) {
@SuppressWarnings("unchecked") final List<FirmwareVersionDto> firmwareVersionList = (List<FirmwareVersionDto>) responseMessage.getDataObject();
this.configurationService.handleGetFirmwareVersionResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, firmwareVersionList);
} else if (responseMessage.getDataObject() instanceof FirmwareVersionGasDto) {
this.configurationService.handleGetFirmwareVersionGasResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, (FirmwareVersionGasDto) responseMessage.getDataObject());
} else {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new OsgpException(ComponentType.DOMAIN_SMART_METERING, "DataObject for response message should be of type ArrayList"));
}
}
use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto in project open-smart-grid-platform by OSGP.
the class GetFirmwareVersionsCommandExecutor method getFirmwareVersions.
private List<FirmwareVersionDto> getFirmwareVersions(final DlmsConnectionManager conn, final DlmsDevice device, final AttributeAddress[] attributes) throws ProtocolAdapterException {
conn.getDlmsMessageListener().setDescription("GetFirmwareVersions, retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(attributes));
final List<GetResult> results = this.dlmsHelper.getAndCheck(conn, device, "retrieve firmware versions", attributes);
final List<FirmwareVersionDto> firmwareVersionDtos = new ArrayList<>();
for (int i = 0; i < attributes.length; i++) {
final FirmwareModuleType firmwareModuleType = FIRMWARE_MODULE_TYPES.get(i);
final String description = firmwareModuleType.getDescription();
final String version = this.dlmsHelper.readString(results.get(i).getResultData(), description);
firmwareVersionDtos.add(new FirmwareVersionDto(firmwareModuleType, version));
}
return firmwareVersionDtos;
}
Aggregations