use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto in project open-smart-grid-platform by OSGP.
the class ManagementService method findEvents.
// === FIND EVENTS ===
public EventMessageDataResponseDto findEvents(final DlmsConnectionManager conn, final DlmsDevice device, final FindEventsRequestList findEventsQueryMessageDataContainer, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final List<EventDto> events = new ArrayList<>();
log.info("findEvents setting up connection with meter {}", device.getDeviceIdentification());
for (final FindEventsRequestDto findEventsQuery : findEventsQueryMessageDataContainer.getFindEventsQueryList()) {
log.info("findEventsQuery.eventLogCategory: {}, findEventsQuery.from: {}, findEventsQuery.until: {}", findEventsQuery.getEventLogCategory().toString(), findEventsQuery.getFrom(), findEventsQuery.getUntil());
events.addAll(this.findEventsCommandExecutor.execute(conn, device, findEventsQuery, messageMetadata));
}
return new EventMessageDataResponseDto(events);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto in project open-smart-grid-platform by OSGP.
the class EventMessageDataContainerMappingTest method testWithNullList.
// Test if mapping with a null List succeeds
@Test
public void testWithNullList() {
// build test data
final EventMessageDataResponseDto containerDto = new EventMessageDataResponseDto(null);
// actual mapping
final EventMessagesResponse container = this.managementMapper.map(containerDto, EventMessagesResponse.class);
// test mapping
assertThat(container).isNotNull();
assertThat(container.getEvents()).isNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto in project open-smart-grid-platform by OSGP.
the class EventServiceTest method testWrongEventCode.
@Test
void testWrongEventCode() {
final FunctionalException functionalException = Assertions.assertThrows(FunctionalException.class, () -> {
final ProtocolInfo protocolInfo = mock(ProtocolInfo.class);
when(protocolInfo.getProtocol()).thenReturn("SMR");
when(this.smartMeter.getProtocolInfo()).thenReturn(protocolInfo);
final EventDto event = new EventDto(new DateTime(), 266, 2, "STANDARD_EVENT_LOG");
final ArrayList<EventDto> events = new ArrayList<>();
events.add(event);
final EventMessageDataResponseDto responseDto = new EventMessageDataResponseDto(events);
this.eventService.enrichEvents(this.deviceMessageMetadata, responseDto);
});
assertThat(functionalException.getExceptionType()).isEqualTo(FunctionalExceptionType.VALIDATION_ERROR);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto in project open-smart-grid-platform by OSGP.
the class BundleService method checkIfAdditionalActionIsNeeded.
private void checkIfAdditionalActionIsNeeded(final MessageMetadata messageMetadata, final BundleMessagesRequestDto bundleMessagesRequestDto) throws FunctionalException {
for (final ActionResponseDto action : bundleMessagesRequestDto.getAllResponses()) {
if (action instanceof CoupleMbusDeviceByChannelResponseDto) {
this.mBusGatewayService.handleCoupleMbusDeviceByChannelResponse(messageMetadata, (CoupleMbusDeviceByChannelResponseDto) action);
} else if (action instanceof DecoupleMbusDeviceResponseDto) {
this.mBusGatewayService.handleDecoupleMbusDeviceResponse(messageMetadata, (DecoupleMbusDeviceResponseDto) action);
} else if (action instanceof SetDeviceLifecycleStatusByChannelResponseDto) {
this.managementService.setDeviceLifecycleStatusByChannel((SetDeviceLifecycleStatusByChannelResponseDto) action);
} else if (action instanceof EventMessageDataResponseDto) {
this.eventService.enrichEvents(messageMetadata, (EventMessageDataResponseDto) action);
} else if (action instanceof FirmwareVersionResponseDto) {
final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(((FirmwareVersionResponseDto) action).getFirmwareVersions(), FirmwareVersion.class);
this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
} else if (action instanceof FirmwareVersionGasResponseDto) {
final FirmwareVersionGasResponseDto firmwareVersionGasResponseDto = (FirmwareVersionGasResponseDto) action;
final FirmwareVersion firmwareVersion = this.configurationMapper.map(firmwareVersionGasResponseDto.getFirmwareVersion(), FirmwareVersion.class);
this.firmwareService.saveFirmwareVersionsReturnedFromDevice(firmwareVersionGasResponseDto.getFirmwareVersion().getMbusDeviceIdentification(), Arrays.asList(firmwareVersion));
}
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto in project open-smart-grid-platform by OSGP.
the class FindEventsResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
final EventMessageDataResponseDto eventMessageDataContainer = (EventMessageDataResponseDto) responseMessage.getDataObject();
this.managementService.handleFindEventsResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, eventMessageDataContainer);
}
Aggregations