Search in sources :

Example 1 with WindowElementDto

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;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) WindowElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto) ArrayList(java.util.ArrayList)

Example 2 with WindowElementDto

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());
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) WindowElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)

Example 3 with WindowElementDto

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());
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) WindowElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)

Example 4 with WindowElementDto

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);
}
Also used : WindowElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)

Aggregations

WindowElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto)4 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 CosemObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto)2 ArrayList (java.util.ArrayList)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1