use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class CoupleMbusDeviceCommandExecutorTest method testNoMatchAndNoEmptyChannel.
@Test
public void testNoMatchAndNoEmptyChannel() throws ProtocolAdapterException {
final MbusChannelElementsDto mbusChannelElementsDto = new MbusChannelElementsDto((short) -1, "noMatch", "noMatch", "noMatch", (short) -1, (short) -1);
when(this.deviceChannelsHelper.findCandidateChannelsForDevice(eq(this.conn), eq(this.device), any(MbusChannelElementsDto.class))).thenReturn(this.candidateChannelElementValues);
final MbusChannelElementsResponseDto responseDto = this.commandExecutor.execute(this.conn, this.device, mbusChannelElementsDto, this.messageMetadata);
assertThat(responseDto.getChannel()).isNull();
assertThat(responseDto.getRetrievedChannelElements().get(0).getDeviceTypeIdentification()).isEqualTo(this.deviceTypeIdentification);
assertThat(responseDto.getRetrievedChannelElements().get(0).getIdentificationNumber()).isEqualTo(this.identificationNumber);
assertThat(responseDto.getRetrievedChannelElements().get(0).getManufacturerIdentification()).isEqualTo(this.manufacturerIdentification);
assertThat(responseDto.getRetrievedChannelElements().get(0).getPrimaryAddress()).isEqualTo(this.primaryAddress);
assertThat(responseDto.getRetrievedChannelElements().get(0).getVersion()).isEqualTo(this.version);
verify(this.deviceChannelsHelper, times(1)).findCandidateChannelsForDevice(eq(this.conn), eq(this.device), any(MbusChannelElementsDto.class));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class CoupleMbusDeviceCommandExecutorTest method testExactMatch.
@Test
public void testExactMatch() throws ProtocolAdapterException {
final MbusChannelElementsDto mbusChannelElementsDto = new MbusChannelElementsDto(this.primaryAddress, this.mbusDeviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
when(this.deviceChannelsHelper.findCandidateChannelsForDevice(eq(this.conn), eq(this.device), any(MbusChannelElementsDto.class))).thenReturn(this.candidateChannelElementValues);
final MbusChannelElementsResponseDto responseDto = this.commandExecutor.execute(this.conn, this.device, mbusChannelElementsDto, this.messageMetadata);
assertThat(responseDto.getChannel()).isEqualTo(this.channel);
assertThat(responseDto.getRetrievedChannelElements().get(0).getDeviceTypeIdentification()).isEqualTo(this.deviceTypeIdentification);
assertThat(responseDto.getRetrievedChannelElements().get(0).getIdentificationNumber()).isEqualTo(this.identificationNumber);
assertThat(responseDto.getRetrievedChannelElements().get(0).getManufacturerIdentification()).isEqualTo(this.manufacturerIdentification);
assertThat(responseDto.getRetrievedChannelElements().get(0).getPrimaryAddress()).isEqualTo(this.primaryAddress);
assertThat(responseDto.getRetrievedChannelElements().get(0).getVersion()).isEqualTo(this.version);
verify(this.deviceChannelsHelper, times(1)).findCandidateChannelsForDevice(eq(this.conn), eq(this.device), any(MbusChannelElementsDto.class));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class CoupleMbusDeviceRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(MbusChannelElementsDto.class, requestObject);
final MbusChannelElementsDto requestDto = (MbusChannelElementsDto) requestObject;
return this.installationService.coupleMbusDevice(conn, device, requestDto, messageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class MBusGatewayService method coupleMbusDevice.
/**
* @param messageMetadata the metadata of the message, including the correlationUid, the
* deviceIdentification and the organization
* @param requestData the requestData of the message, including the identification of the m-bus
* device and the channel
*/
public void coupleMbusDevice(final MessageMetadata messageMetadata, final CoupleMbusDeviceRequestData requestData) throws FunctionalException {
final String deviceIdentification = messageMetadata.getDeviceIdentification();
final String mbusDeviceIdentification = requestData.getMbusDeviceIdentification();
log.debug("coupleMbusDevice for organizationIdentification: {} for gateway: {}, m-bus device {} ", messageMetadata.getOrganisationIdentification(), deviceIdentification, mbusDeviceIdentification);
final SmartMeter gatewayDevice = this.domainHelperService.findSmartMeter(deviceIdentification);
final SmartMeter mbusDevice = this.domainHelperService.findSmartMeter(mbusDeviceIdentification);
this.checkAndHandleInactiveMbusDevice(mbusDevice);
this.checkAndHandleIfGivenMBusAlreadyCoupled(mbusDevice);
this.checkAndHandleIfAllMBusChannelsAreAlreadyOccupied(gatewayDevice);
final MbusChannelElementsDto requestDto = this.makeMbusChannelElementsDto(mbusDevice);
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(gatewayDevice.getIpAddress()).withNetworkSegmentIds(gatewayDevice.getBtsId(), gatewayDevice.getCellId()).build());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllFilled.
@Test
public void testAllFilled() {
/*
* All attributes for requestData and channelValues are defined and
* matching.
*/
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should match " + channelValues).isTrue();
}
Aggregations