Search in sources :

Example 6 with FirmwareVersionDto

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);
}
Also used : GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetFirmwareVersionDeviceResponse) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) JMSException(javax.jms.JMSException) NodeException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) Iec61850GetFirmwareVersionCommand(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850GetFirmwareVersionCommand)

Example 7 with FirmwareVersionDto

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());
}
Also used : Function(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NodeContainer(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.NodeContainer) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)

Example 8 with FirmwareVersionDto

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);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) List(java.util.List) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds)

Example 9 with FirmwareVersionDto

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"));
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) FirmwareVersionGasDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)

Example 10 with FirmwareVersionDto

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;
}
Also used : GetResult(org.openmuc.jdlms.GetResult) ArrayList(java.util.ArrayList) FirmwareModuleType(org.opensmartgridplatform.dto.valueobjects.FirmwareModuleType) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)

Aggregations

FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)18 Test (org.junit.jupiter.api.Test)11 ArrayList (java.util.ArrayList)8 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)6 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)5 JMSException (javax.jms.JMSException)4 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)4 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)4 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)4 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)4 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)4 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)4 List (java.util.List)3 GetResult (org.openmuc.jdlms.GetResult)3 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)3 Serializable (java.io.Serializable)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 GetResultBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultBuilder)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2