use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto in project open-smart-grid-platform by OSGP.
the class ReadAlarmRegisterResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) {
final AlarmRegisterResponseDto alarmRegisterDto = (AlarmRegisterResponseDto) responseMessage.getDataObject();
this.monitoringService.handleReadAlarmRegisterResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, alarmRegisterDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithEmptySet.
// Test if mapping with an empty set succeeds
@Test
public void testWithEmptySet() {
// build test data
final Set<AlarmTypeDto> alarmTypes = new TreeSet<>();
final AlarmRegisterResponseDto alarmRegisterDto = new AlarmRegisterResponseDto(alarmTypes);
// actual mapping
final AlarmRegister alarmRegister = this.monitoringMapper.map(alarmRegisterDto, AlarmRegister.class);
// test mapping
assertThat(alarmRegister).isNotNull();
assertThat(alarmRegister.getAlarmTypes()).isEmpty();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithNonEmptySet.
// Test if mapping with a non-empty set succeeds
@Test
public void testWithNonEmptySet() {
// build test data
final Set<AlarmTypeDto> alarmTypes = new TreeSet<>();
alarmTypes.add(AlarmTypeDto.CLOCK_INVALID);
final AlarmRegisterResponseDto alarmRegisterDto = new AlarmRegisterResponseDto(alarmTypes);
// actual mapping
final AlarmRegister alarmRegister = this.monitoringMapper.map(alarmRegisterDto, AlarmRegister.class);
// test mapping
assertThat(alarmRegister).isNotNull();
assertThat(alarmRegister.getAlarmTypes().size()).isEqualTo(alarmRegisterDto.getAlarmTypes().size());
assertThat(alarmRegister.getAlarmTypes().contains(AlarmType.CLOCK_INVALID)).isTrue();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto in project open-smart-grid-platform by OSGP.
the class ReadAlarmRegisterCommandExecutor method execute.
@Override
public AlarmRegisterResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final ReadAlarmRegisterRequestDto object, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final AttributeAddress alarmRegister1AttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.ALARM_REGISTER_1, null);
final Set<AlarmTypeDto> alarmList = this.readAlarmRegister(conn, alarmRegister1AttributeAddress, DlmsObjectType.ALARM_REGISTER_1);
final Optional<AttributeAddress> alarmRegister2AttributeAddress = this.dlmsObjectConfigService.findAttributeAddress(device, DlmsObjectType.ALARM_REGISTER_2, null);
if (alarmRegister2AttributeAddress.isPresent()) {
alarmList.addAll(this.readAlarmRegister(conn, alarmRegister2AttributeAddress.get(), DlmsObjectType.ALARM_REGISTER_2));
}
return new AlarmRegisterResponseDto(alarmList);
}
Aggregations