use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class MeasurementAsduHandler method handleAsdu.
@Override
public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) {
LOGGER.debug("Received measurement of type {}.", asdu.getTypeIdentification());
final MeasurementReportDto measurementReportDto = this.converter.convert(asdu);
this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()).process(measurementReportDto, responseMetadata);
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class SinglePointInformationWithTimeTagAsduHandler method handleAsdu.
@Override
public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) {
LOGGER.debug("Received asdu {} for device {}.", asdu, responseMetadata.getDeviceIdentification());
final MeasurementReportDto measurementReportDto = this.converter.convert(asdu);
final DeviceResponseService deviceResponseService = this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType());
if (CauseOfTransmission.SPONTANEOUS == asdu.getCauseOfTransmission()) {
deviceResponseService.processEvent(measurementReportDto, responseMetadata);
} else {
deviceResponseService.process(measurementReportDto, responseMetadata);
}
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class GetMeasurementReportResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing Measurement Report message");
String correlationUid = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage = null;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
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("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 MeasurementReportDto dataResponse = (MeasurementReportDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.monitoringService.handleGetMeasurementReportResponse(dataResponse, ids, messageType, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
}
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class DomainDistributionAutomationMapperTest method testMeasurementReportMapping.
@Test
public void testMeasurementReportMapping() {
// Arrange
final int commonAddress = 55;
final String groupIdentification = "137";
final float[] gasFlowMeasurements = { 78.733f, 21.000f };
// Arrange domain
final MeasurementGroup expectedGroup = DomainMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
final List<MeasurementGroup> expectedGroups = new ArrayList<>();
expectedGroups.add(expectedGroup);
final MeasurementReport expected = new MeasurementReport(DomainMeasurementsFactory.spontaneousReportHeader(commonAddress), expectedGroups);
// Arrange DTO
final MeasurementReportHeaderDto dtoHeader = DtoMeasurementsFactory.spontaneousReportHeader(commonAddress);
final MeasurementGroupDto dtoGroup = DtoMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
final List<MeasurementGroupDto> dtoGroups = new ArrayList<>();
dtoGroups.add(dtoGroup);
final MeasurementReportDto dtoReport = new MeasurementReportDto(dtoHeader, dtoGroups);
// Act
final MeasurementReport actual = this.mapper.map(dtoReport, MeasurementReport.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class SinglePointWithQualityAsduHandlerTest method testHandleAsduShouldSendMeasurementReport.
/**
* Test method for {@link
* org.opensmartgridplatform.adapter.protocol.iec60870.domain.lightmeasurement.asduhandlers.SinglePointWithQualityAsduHandler#handleAsdu(org.openmuc.j60870.ASdu,
* org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)}.
*
* @throws Exception
*/
@Test
void testHandleAsduShouldSendMeasurementReport() throws Exception {
// Arrange
when(this.deviceResponseServiceMap.forDeviceType(DeviceType.LIGHT_MEASUREMENT_RTU)).thenReturn(this.deviceResponseService);
final ASdu asdu = this.createAsdu();
final ResponseMetadata responseMetadata = this.createResponseMetadata();
final MeasurementReportDto measurementReport = this.createMeasurementReportDto();
when(this.converterService.convert(asdu)).thenReturn(measurementReport);
when(this.deviceResponseServiceMap.forDeviceType(GATEWAY_DEVICE_TYPE)).thenReturn(this.deviceResponseService);
// Act
this.asduHandler.handleAsdu(asdu, responseMetadata);
// Assert
verify(this.deviceResponseService).process(any(MeasurementReportDto.class), eq(responseMetadata));
}
Aggregations