Search in sources :

Example 1 with AlarmRegisterResponseDto

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);
}
Also used : AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto)

Example 2 with AlarmRegisterResponseDto

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();
}
Also used : AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) TreeSet(java.util.TreeSet) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto) Test(org.junit.jupiter.api.Test)

Example 3 with AlarmRegisterResponseDto

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();
}
Also used : AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) TreeSet(java.util.TreeSet) AlarmRegister(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister) AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto) Test(org.junit.jupiter.api.Test)

Example 4 with AlarmRegisterResponseDto

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);
}
Also used : AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) AlarmRegisterResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto)

Aggregations

AlarmRegisterResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto)4 AlarmTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto)3 TreeSet (java.util.TreeSet)2 Test (org.junit.jupiter.api.Test)2 AlarmRegister (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1