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());
}
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;
}
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());
}
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());
}
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;
}
Aggregations