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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations