Search in sources :

Example 1 with GetDataRequestDto

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

the class MicrogridsGetDataRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing microgrids get data request message");
    final MessageMetadata messageMetadata;
    final GetDataRequestDto getDataRequest;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        getDataRequest = (GetDataRequestDto) 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.getData(new GetDataDeviceRequest(deviceRequestBuilder, getDataRequest), iec61850DeviceResponseHandler);
}
Also used : Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) GetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto) GetDataDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.GetDataDeviceRequest) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) GetDataDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.GetDataDeviceRequest) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Example 2 with GetDataRequestDto

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

the class CommunicationRecoveryService method createRequest.

private GetDataRequestDto createRequest(final RtuDevice rtu) {
    LOGGER.debug("Creating data request for rtu {}.", rtu.getDeviceIdentification());
    final List<MeasurementFilterDto> measurementFilters = new ArrayList<>();
    measurementFilters.add(new MeasurementFilterDto(MEASUREMENT_ID, MEASUREMENT_NODE, false));
    final List<SystemFilterDto> systemFilters = new ArrayList<>();
    systemFilters.add(new SystemFilterDto(SYSTEM_ID, SYSTEM_TYPE, measurementFilters, false));
    return new GetDataRequestDto(systemFilters);
}
Also used : GetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto) SystemFilterDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SystemFilterDto) ArrayList(java.util.ArrayList) MeasurementFilterDto(org.opensmartgridplatform.dto.valueobjects.microgrids.MeasurementFilterDto)

Example 3 with GetDataRequestDto

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

the class CommunicationRecoveryService method createMessage.

private RequestMessage createMessage(final RtuDevice rtu) {
    LOGGER.debug("Creating message for device {}.", rtu.getDeviceIdentification());
    final String correlationUid = this.createCorrelationUid(rtu);
    final String organisationIdentification = rtu.getOwner().getOrganisationIdentification();
    final String deviceIdentification = rtu.getDeviceIdentification();
    final GetDataRequestDto request = this.createRequest(rtu);
    return new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, request);
}
Also used : GetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 4 with GetDataRequestDto

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

the class Iec61850RtuDeviceService method handleGetData.

// ========================
// PRIVATE HELPER METHODS =
// ========================
private GetDataResponseDto handleGetData(final DeviceConnection connection, final GetDataDeviceRequest deviceRequest) throws ProtocolAdapterException {
    final GetDataRequestDto requestedData = deviceRequest.getDataRequest();
    final Function<GetDataResponseDto> function = new Function<GetDataResponseDto>() {

        @Override
        public GetDataResponseDto apply(final DeviceMessageLog deviceMessageLog) throws ProtocolAdapterException {
            final List<GetDataSystemIdentifierDto> identifiers = new ArrayList<>();
            for (final SystemFilterDto systemFilter : requestedData.getSystemFilters()) {
                final SystemService systemService = Iec61850RtuDeviceService.this.systemServiceFactory.getSystemService(systemFilter);
                final GetDataSystemIdentifierDto getDataSystemIdentifier = systemService.getData(systemFilter, Iec61850RtuDeviceService.this.iec61850Client, connection);
                identifiers.add(getDataSystemIdentifier);
            }
            return new GetDataResponseDto(identifiers, null);
        }
    };
    return this.iec61850Client.sendCommandWithRetry(function, deviceRequest.getDeviceIdentification());
}
Also used : Function(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.Function) GetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto) DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) SystemFilterDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SystemFilterDto) SystemService(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.SystemService) GetDataResponseDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataResponseDto) GetDataSystemIdentifierDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataSystemIdentifierDto) ArrayList(java.util.ArrayList)

Example 5 with GetDataRequestDto

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

the class AdHocManagementService method getData.

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

Aggregations

GetDataRequestDto (org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto)5 ArrayList (java.util.ArrayList)2 SystemFilterDto (org.opensmartgridplatform.dto.valueobjects.microgrids.SystemFilterDto)2 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)2 JMSException (javax.jms.JMSException)1 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 GetDataDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.rtu.requests.GetDataDeviceRequest)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 GetDataResponseDto (org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataResponseDto)1 GetDataSystemIdentifierDto (org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataSystemIdentifierDto)1 MeasurementFilterDto (org.opensmartgridplatform.dto.valueobjects.microgrids.MeasurementFilterDto)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1