Search in sources :

Example 1 with SetDataRequestDto

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

the class AdHocManagementService method handleSetDataRequest.

// === SET DATA ===
public void handleSetDataRequest(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final SetDataRequest setDataRequest) throws FunctionalException {
    LOGGER.info("Set data for device [{}] with correlation id [{}]", deviceIdentification, correlationUid);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    final SetDataRequestDto dto = this.mapper.map(setDataRequest, SetDataRequestDto.class);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, dto), messageType, device.getIpAddress());
}
Also used : SetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataRequestDto) Device(org.opensmartgridplatform.domain.core.entities.Device) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 2 with SetDataRequestDto

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

the class Iec61850RtuDeviceService method handleSetData.

private void handleSetData(final DeviceConnection connection, final SetDataDeviceRequest deviceRequest) throws ProtocolAdapterException {
    final SetDataRequestDto setDataRequest = deviceRequest.getSetDataRequest();
    final Function<Void> function = new Function<Void>() {

        @Override
        public Void apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
            for (final SetDataSystemIdentifierDto identifier : setDataRequest.getSetDataSystemIdentifiers()) {
                final SystemService systemService = Iec61850RtuDeviceService.this.systemServiceFactory.getSystemService(identifier.getSystemType());
                systemService.setData(identifier, Iec61850RtuDeviceService.this.iec61850Client, connection);
            }
            return null;
        }
    };
    this.iec61850Client.sendCommandWithRetry(function, deviceRequest.getDeviceIdentification());
}
Also used : Function(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function) DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) SystemService(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.SystemService) SetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataRequestDto) SetDataSystemIdentifierDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataSystemIdentifierDto)

Example 3 with SetDataRequestDto

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

the class MicrogridsSetDataRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.info("Processing microgrids set data request message");
    MessageMetadata messageMetadata;
    SetDataRequestDto setDataRequest;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        setDataRequest = (SetDataRequestDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
    this.printDomainInfo(requestMessageData);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
    this.deviceService.setData(new SetDataDeviceRequest(deviceRequestBuilder, setDataRequest), iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataRequestDto) SetDataDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.SetDataDeviceRequest) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) SetDataDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.SetDataDeviceRequest) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

SetDataRequestDto (org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataRequestDto)3 JMSException (javax.jms.JMSException)1 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 SetDataDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.SetDataDeviceRequest)1 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 SystemService (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.SystemService)1 Function (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 RtuDevice (org.opensmartgridplatform.domain.core.entities.RtuDevice)1 SetDataSystemIdentifierDto (org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataSystemIdentifierDto)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1