use of org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto in project open-smart-grid-platform by OSGP.
the class DlmsHelper method readListOfWindowElement.
public List<WindowElementDto> readListOfWindowElement(final DataObject resultData, final String description) throws ProtocolAdapterException {
final List<DataObject> listOfWindowElement = this.readList(resultData, description);
if (listOfWindowElement == null) {
return Collections.emptyList();
}
final List<WindowElementDto> windowElementList = new ArrayList<>();
for (final DataObject windowElementObject : listOfWindowElement) {
windowElementList.add(this.readWindowElement(windowElementObject, "Window Element from " + description));
}
return windowElementList;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method checkNonEmptyListMapping.
// method to test non-empty list mapping
private void checkNonEmptyListMapping(final PushSetupAlarm pushSetupAlarm, final PushSetupAlarmDto pushSetupAlarmDto) {
// test pushObjectList mapping
assertThat(pushSetupAlarm.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getPushObjectList()).isNotNull();
assertThat(pushSetupAlarmDto.getPushObjectList().size()).isEqualTo(pushSetupAlarm.getPushObjectList().size());
final CosemObjectDefinition cosemObjectDefinition = pushSetupAlarm.getPushObjectList().get(0);
final CosemObjectDefinitionDto cosemObjectDefinitionDto = pushSetupAlarmDto.getPushObjectList().get(0);
assertThat(cosemObjectDefinitionDto.getAttributeIndex()).isEqualTo(cosemObjectDefinition.getAttributeIndex());
assertThat(cosemObjectDefinitionDto.getClassId()).isEqualTo(cosemObjectDefinition.getClassId());
assertThat(cosemObjectDefinitionDto.getDataIndex()).isEqualTo(cosemObjectDefinition.getDataIndex());
this.checkCosemObisCodeMapping(cosemObjectDefinition.getLogicalName(), cosemObjectDefinitionDto.getLogicalName());
// test communicationWindow mapping
assertThat(pushSetupAlarm.getCommunicationWindow()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNotNull();
assertThat(pushSetupAlarmDto.getCommunicationWindow().size()).isEqualTo(pushSetupAlarm.getCommunicationWindow().size());
final WindowElement windowElement = pushSetupAlarm.getCommunicationWindow().get(0);
final WindowElementDto windowElementDto = pushSetupAlarmDto.getCommunicationWindow().get(0);
this.checkCosemDateTimeMapping(windowElement.getStartTime(), windowElementDto.getStartTime());
this.checkCosemDateTimeMapping(windowElement.getEndTime(), windowElementDto.getEndTime());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method checkNonEmptyListMapping.
// method to test non-empty list mapping
private void checkNonEmptyListMapping(final PushSetupSms pushSetupSms, final PushSetupSmsDto pushSetupSmsDto) {
// test pushObjectList mapping
assertThat(pushSetupSms.getPushObjectList()).isNotNull();
assertThat(pushSetupSmsDto.getPushObjectList()).isNotNull();
assertThat(pushSetupSmsDto.getPushObjectList().size()).isEqualTo(pushSetupSms.getPushObjectList().size());
final CosemObjectDefinition cosemObjectDefinition = pushSetupSms.getPushObjectList().get(0);
final CosemObjectDefinitionDto cosemObjectDefinitionDto = pushSetupSmsDto.getPushObjectList().get(0);
assertThat(cosemObjectDefinitionDto.getAttributeIndex()).isEqualTo(cosemObjectDefinition.getAttributeIndex());
assertThat(cosemObjectDefinitionDto.getClassId()).isEqualTo(cosemObjectDefinition.getClassId());
assertThat(cosemObjectDefinitionDto.getDataIndex()).isEqualTo(cosemObjectDefinition.getDataIndex());
this.checkCosemObisCodeMapping(cosemObjectDefinition.getLogicalName(), cosemObjectDefinitionDto.getLogicalName());
// test communicationWindow mapping
assertThat(pushSetupSms.getCommunicationWindow()).isNotNull();
assertThat(pushSetupSmsDto.getCommunicationWindow()).isNotNull();
assertThat(pushSetupSmsDto.getCommunicationWindow().size()).isEqualTo(pushSetupSms.getCommunicationWindow().size());
final WindowElement windowElement = pushSetupSms.getCommunicationWindow().get(0);
final WindowElementDto windowElementDto = pushSetupSmsDto.getCommunicationWindow().get(0);
this.checkCosemDateTimeMapping(windowElement.getStartTime(), windowElementDto.getStartTime());
this.checkCosemDateTimeMapping(windowElement.getEndTime(), windowElementDto.getEndTime());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto in project open-smart-grid-platform by OSGP.
the class DlmsHelper method buildWindowElementFromDataObjects.
private WindowElementDto buildWindowElementFromDataObjects(final List<DataObject> elements, final String description) throws ProtocolAdapterException {
if (elements.size() != 2) {
LOGGER.error("Unexpected number of ResultData elements for WindowElement value: {}", elements.size());
throw new ProtocolAdapterException("Expected list for WindowElement to contain 2 elements, got: " + elements.size());
}
final CosemDateTimeDto startTime = this.readDateTime(elements.get(0), "Start Time from " + description);
final CosemDateTimeDto endTime = this.readDateTime(elements.get(1), "End Time from " + description);
return new WindowElementDto(startTime, endTime);
}
Aggregations