use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllAttributesInRequestOnlySomeInRetrievedValues.
@Test
public void testAllAttributesInRequestOnlySomeInRetrievedValues() {
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.noManufacturerIdentification, this.noVersion, this.noDeviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should not match " + channelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllAttributesInRequestOnlyPrimaryAddressInRetrievedValues.
@Test
public void testAllAttributesInRequestOnlyPrimaryAddressInRetrievedValues() {
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.noIdentificationNumber, this.noManufacturerIdentification, this.noVersion, this.noDeviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should not match " + channelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.
the class ConfigurationService method getMbusKeyExchangeData.
public GMeterInfoDto getMbusKeyExchangeData(final DlmsConnectionManager conn, final DlmsDevice device, final SetMbusUserKeyByChannelRequestDataDto setMbusUserKeyByChannelRequestData, final MessageMetadata messageMetadata) throws OsgpException {
final GetMBusDeviceOnChannelRequestDataDto mbusDeviceOnChannelRequest = new GetMBusDeviceOnChannelRequestDataDto(device.getDeviceIdentification(), setMbusUserKeyByChannelRequestData.getChannel());
final ChannelElementValuesDto channelElementValues = this.getMBusDeviceOnChannelCommandExecutor.execute(conn, device, mbusDeviceOnChannelRequest, messageMetadata);
final DlmsDevice mbusDevice = this.domainHelperService.findMbusDevice(channelElementValues.getIdentificationNumber(), channelElementValues.getManufacturerIdentification());
return new GMeterInfoDto(setMbusUserKeyByChannelRequestData.getChannel(), mbusDevice.getDeviceIdentification());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelper method writeUpdatedMbus.
protected ChannelElementValuesDto writeUpdatedMbus(final DlmsConnectionManager conn, final DlmsDevice device, final MbusChannelElementsDto requestDto, final short channel, final String executorName) throws ProtocolAdapterException {
final DlmsObject mbusClientSetupObject = this.dlmsObjectConfigService.getDlmsObject(device, DlmsObjectType.MBUS_CLIENT_SETUP);
final ObisCode obiscode = mbusClientSetupObject.getObisCodeWithChannel(channel);
final int classId = mbusClientSetupObject.getClassId();
final DataObject identificationNumberDataObject;
if (this.identificationNumberStoredAsBcdOnDevice(mbusClientSetupObject)) {
identificationNumberDataObject = IdentificationNumber.fromTextualRepresentation(requestDto.getMbusIdentificationNumber()).asDataObjectInBcdRepresentation();
} else {
identificationNumberDataObject = IdentificationNumber.fromTextualRepresentation(requestDto.getMbusIdentificationNumber()).asDataObject();
}
final DataObjectAttrExecutors dataObjectExecutors = new DataObjectAttrExecutors(executorName).addExecutor(this.getMbusAttributeExecutor(MbusClientAttribute.IDENTIFICATION_NUMBER, identificationNumberDataObject, obiscode, classId)).addExecutor(this.getMbusAttributeExecutor(MbusClientAttribute.MANUFACTURER_ID, ManufacturerId.fromIdentification(requestDto.getMbusManufacturerIdentification()).asDataObject(), obiscode, classId)).addExecutor(this.getMbusAttributeExecutor(MbusClientAttribute.VERSION, DataObject.newUInteger8Data(requestDto.getMbusVersion()), obiscode, classId)).addExecutor(this.getMbusAttributeExecutor(MbusClientAttribute.DEVICE_TYPE, DataObject.newUInteger8Data(requestDto.getMbusDeviceTypeIdentification()), obiscode, classId));
if (requestDto.getPrimaryAddress() != null) {
dataObjectExecutors.addExecutor(this.getMbusAttributeExecutor(MbusClientAttribute.PRIMARY_ADDRESS, DataObject.newUInteger8Data(requestDto.getPrimaryAddress()), obiscode, classId));
}
conn.getDlmsMessageListener().setDescription(String.format("Write updated MBus attributes to channel %d, set attributes: %s", channel, dataObjectExecutors.describeAttributes()));
dataObjectExecutors.execute(conn);
log.info("Finished coupling the mbus device to the gateway device");
return new ChannelElementValuesDto(channel, requestDto.getPrimaryAddress(), requestDto.getMbusIdentificationNumber(), requestDto.getMbusManufacturerIdentification(), requestDto.getMbusVersion(), requestDto.getMbusDeviceTypeIdentification());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto in project open-smart-grid-platform by OSGP.
the class GetMbusEncryptionKeyStatusByChannelCommandExecutor method execute.
@Override
public GetMbusEncryptionKeyStatusByChannelResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final GetMbusEncryptionKeyStatusByChannelRequestDataDto request, final MessageMetadata messageMetadata) throws OsgpException {
final GetMBusDeviceOnChannelRequestDataDto mbusDeviceOnChannelRequest = new GetMBusDeviceOnChannelRequestDataDto(device.getDeviceIdentification(), request.getChannel());
final ChannelElementValuesDto channelElementValues = this.getMBusDeviceOnChannelCommandExecutor.execute(conn, device, mbusDeviceOnChannelRequest, messageMetadata);
if (!channelElementValues.hasChannel() || !channelElementValues.hasDeviceTypeIdentification() || !channelElementValues.hasManufacturerIdentification()) {
throw new FunctionalException(FunctionalExceptionType.NO_DEVICE_FOUND_ON_CHANNEL, ComponentType.DOMAIN_SMART_METERING);
}
final EncryptionKeyStatusTypeDto encryptionKeyStatusType = this.getMbusEncryptionKeyStatusCommandExecutor.getEncryptionKeyStatusTypeDto(request.getChannel(), conn);
return new GetMbusEncryptionKeyStatusByChannelResponseDto(device.getDeviceIdentification(), encryptionKeyStatusType, request.getChannel());
}
Aggregations