use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorDsmr4IT method execute.
@Test
public void execute() throws IOException, ProtocolAdapterException {
// SETUP
// configurationToSet: 0111-----1------
final GprsOperationModeTypeDto gprsModeToSet = GprsOperationModeTypeDto.TRIGGERED;
final ConfigurationObjectDto configurationToSet = this.createConfigurationObjectDto(gprsModeToSet, this.createFlagDto(ConfigurationFlagTypeDto.DISCOVER_ON_OPEN_COVER, false), this.createFlagDto(ConfigurationFlagTypeDto.DISCOVER_ON_POWER_ON, true), this.createFlagDto(ConfigurationFlagTypeDto.DYNAMIC_MBUS_ADDRESS, true), this.createFlagDto(ConfigurationFlagTypeDto.PO_ENABLE, true), this.createFlagDto(ConfigurationFlagTypeDto.HLS_5_ON_PO_ENABLE, true));
// flagsOnDevice: 1000101010000000
final byte[] flagsOnDevice = this.createFlagBytes(ConfigurationFlagTypeDto.DISCOVER_ON_OPEN_COVER, ConfigurationFlagTypeDto.HLS_3_ON_P_3_ENABLE, ConfigurationFlagTypeDto.HLS_5_ON_P_3_ENABLE, ConfigurationFlagTypeDto.HLS_4_ON_PO_ENABLE);
// result of merging configurationToSet and flagsOnDevice
final byte firstExpectedByte = this.asByte("01111010");
final byte secondExpectedByte = this.asByte("11000000");
final GprsOperationModeTypeDto gprsModeOnDevice = GprsOperationModeTypeDto.ALWAYS_ON;
final DataObject deviceData = this.createStructureData(flagsOnDevice, gprsModeOnDevice);
when(this.getResult.getResultData()).thenReturn(deviceData);
final DlmsDevice device = new DlmsDevice();
device.setProtocol(Protocol.DSMR_4_2_2);
// CALL
final AccessResultCode result = this.instance.execute(this.conn, device, configurationToSet, this.messageMetadata);
// VERIFY
assertThat(result).isEqualTo(AccessResultCode.SUCCESS);
final List<DataObject> elements = this.captureSetParameterStructureData();
final Number gprsOperationMode = elements.get(INDEX_OF_GPRS_OPERATION_MODE).getValue();
assertThat(gprsOperationMode).isEqualTo(gprsModeToSet.getNumber());
final BitString configurationFlags = elements.get(INDEX_OF_CONFIGURATION_FLAGS).getValue();
final byte[] flagsSentToDevice = configurationFlags.getBitString();
assertThat(flagsSentToDevice[0]).isEqualTo(firstExpectedByte);
assertThat(flagsSentToDevice[1]).isEqualTo(secondExpectedByte);
}
Aggregations