Search in sources :

Example 1 with CosemObjectDefinitionDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto in project open-smart-grid-platform by OSGP.

the class DlmsHelper method readObjectDefinition.

public CosemObjectDefinitionDto readObjectDefinition(final DataObject resultData, final String description) throws ProtocolAdapterException {
    final List<DataObject> objectDefinitionElements = this.readList(resultData, description);
    if (objectDefinitionElements == null) {
        return null;
    }
    if (objectDefinitionElements.size() != 4) {
        LOGGER.error("Unexpected ResultData for Object Definition value: {}", this.getDebugInfo(resultData));
        throw new ProtocolAdapterException("Expected list for Object Definition to contain 4 elements, got: " + objectDefinitionElements.size());
    }
    final Long classId = this.readLongNotNull(objectDefinitionElements.get(0), "Class ID from " + description);
    final CosemObisCodeDto logicalName = this.readLogicalName(objectDefinitionElements.get(1), "Logical Name from " + description);
    final Long attributeIndex = this.readLongNotNull(objectDefinitionElements.get(2), "Attribute Index from " + description);
    final Long dataIndex = this.readLongNotNull(objectDefinitionElements.get(3), "Data Index from " + description);
    return new CosemObjectDefinitionDto(classId.intValue(), logicalName, attributeIndex.intValue(), dataIndex.intValue());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)

Example 2 with CosemObjectDefinitionDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto in project open-smart-grid-platform by OSGP.

the class AbstractGetPowerQualityProfileHandler method createSelectableCaptureObjects.

private Map<Integer, CaptureObjectDefinitionDto> createSelectableCaptureObjects(final List<GetResult> captureObjects, final List<SelectableObisCode> logicalNames) throws ProtocolAdapterException {
    final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects = new HashMap<>();
    // there is always only one GetResult
    for (final GetResult captureObjectResult : captureObjects) {
        final List<DataObject> dataObjects = captureObjectResult.getResultData().getValue();
        for (int positionInDataObjectsList = 0; positionInDataObjectsList < dataObjects.size(); positionInDataObjectsList++) {
            final DataObject dataObject = dataObjects.get(positionInDataObjectsList);
            final CosemObjectDefinitionDto cosemObjectDefinitionDto = this.dlmsHelper.readObjectDefinition(dataObject, CAPTURE_OBJECT);
            final Optional<SelectableObisCode> logicalName = SelectableObisCode.getByObisCode(cosemObjectDefinitionDto.getLogicalName().toString());
            if (logicalName.isPresent() && logicalNames.contains(logicalName.get())) {
                selectableCaptureObjects.put(positionInDataObjectsList, new CaptureObjectDefinitionDto(cosemObjectDefinitionDto.getClassId(), new ObisCodeValuesDto(logicalName.get().obisCode), (byte) cosemObjectDefinitionDto.getAttributeIndex(), cosemObjectDefinitionDto.getDataIndex()));
            }
        }
    }
    return selectableCaptureObjects;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) HashMap(java.util.HashMap) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) ObisCodeValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto) CaptureObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)

Example 3 with CosemObjectDefinitionDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto 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 4 with CosemObjectDefinitionDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto 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 5 with CosemObjectDefinitionDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto in project open-smart-grid-platform by OSGP.

the class DlmsHelper method readListOfObjectDefinition.

public List<CosemObjectDefinitionDto> readListOfObjectDefinition(final DataObject resultData, final String description) throws ProtocolAdapterException {
    final List<DataObject> listOfObjectDefinition = this.readList(resultData, description);
    if (listOfObjectDefinition == null) {
        return Collections.emptyList();
    }
    final List<CosemObjectDefinitionDto> objectDefinitionList = new ArrayList<>();
    for (final DataObject objectDefinitionObject : listOfObjectDefinition) {
        objectDefinitionList.add(this.readObjectDefinition(objectDefinitionObject, "Object Definition from " + description));
    }
    return objectDefinitionList;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) ArrayList(java.util.ArrayList)

Aggregations

CosemObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto)5 DataObject (org.openmuc.jdlms.datatypes.DataObject)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 WindowElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.WindowElementDto)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 GetResult (org.openmuc.jdlms.GetResult)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 CaptureObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1 ObisCodeValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto)1