Search in sources :

Example 1 with LightSensorStatusDto

use of org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto in project open-smart-grid-platform by OSGP.

the class PublicLightingGetLightSensorStatusResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing public lighting get light sensor status 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);
        final LightSensorStatusDto lightSensorStatus = (LightSensorStatusDto) dataObject;
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.adHocManagementService.handleGetLightSensorStatusResponse(lightSensorStatus, 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) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) LightSensorStatusDto(org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Example 2 with LightSensorStatusDto

use of org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto in project open-smart-grid-platform by OSGP.

the class OsgpCoreResponseSteps method protocolResponseMessage.

private ProtocolResponseMessage protocolResponseMessage(final Map<String, String> map) {
    final String deviceIdentification = map.get("device_identification");
    final Iec60870Device device = this.deviceSteps.getDevice(deviceIdentification).orElse(null);
    final DomainInfo domainInfo = DomainInfoFactory.forDeviceType(device.getDeviceType());
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.GET_LIGHT_SENSOR_STATUS.name()).withDomain(domainInfo.getDomain()).withDomainVersion(domainInfo.getDomainVersion()).build();
    return ProtocolResponseMessage.newBuilder().messageMetadata(deviceMessageMetadata).dataObject(new LightSensorStatusDto(LightSensorStatusTypeDto.valueOf(map.get("status")))).result(ResponseMessageResultType.OK).build();
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DomainInfo(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) LightSensorStatusDto(org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto)

Example 3 with LightSensorStatusDto

use of org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto in project open-smart-grid-platform by OSGP.

the class Iec61850LmdDeviceService method getLightSensorStatus.

@Override
public void getLightSensorStatus(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    DeviceConnection devCon = null;
    try {
        final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
        devCon = deviceConnection;
        final LightMeasurementDevice lmd = this.lmdDataService.findDevice(deviceRequest.getDeviceIdentification());
        LOGGER.info("Iec61850LmdDeviceService.getLightSensorStatus() called for LMD: {}", lmd);
        final LightSensorStatusDto lightSensorStatus = new Iec61850GetLightSensorStatusCommand(this.deviceMessageLoggingService).getStatusFromDevice(this.iec61850Client, deviceConnection, lmd);
        final GetLightSensorStatusResponse lightSensorStatusResponse = new GetLightSensorStatusResponse(deviceRequest, lightSensorStatus);
        deviceResponseHandler.handleResponse(lightSensorStatusResponse);
        this.enableReporting(deviceConnection, deviceRequest);
    } catch (final ConnectionFailureException se) {
        this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    } catch (final Exception e) {
        this.handleException(deviceRequest, deviceResponseHandler, e);
        this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
    }
}
Also used : Iec61850GetLightSensorStatusCommand(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850GetLightSensorStatusCommand) LightMeasurementDevice(org.opensmartgridplatform.core.db.api.iec61850.entities.LightMeasurementDevice) GetLightSensorStatusResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.lmd.GetLightSensorStatusResponse) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) LightSensorStatusDto(org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) JMSException(javax.jms.JMSException) NodeException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)

Aggregations

LightSensorStatusDto (org.opensmartgridplatform.dto.valueobjects.LightSensorStatusDto)3 JMSException (javax.jms.JMSException)2 Iec60870Device (org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)1 DomainInfo (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DomainInfo)1 GetLightSensorStatusResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.lmd.GetLightSensorStatusResponse)1 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)1 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)1 Iec61850GetLightSensorStatusCommand (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850GetLightSensorStatusCommand)1 LightMeasurementDevice (org.opensmartgridplatform.core.db.api.iec61850.entities.LightMeasurementDevice)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1