use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method handle.
protected GetPowerQualityProfileResponseDto handle(final DlmsConnectionManager conn, final DlmsDevice device, final GetPowerQualityProfileRequestDataDto getPowerQualityProfileRequestDataDto) throws ProtocolAdapterException {
final String profileType = getPowerQualityProfileRequestDataDto.getProfileType();
final List<Profile> profiles = this.determineProfileForDevice(profileType);
final GetPowerQualityProfileResponseDto response = new GetPowerQualityProfileResponseDto();
final List<PowerQualityProfileDataDto> responseDatas = new ArrayList<>();
for (final Profile profile : profiles) {
final ObisCode obisCode = this.makeObisCode(profile.getObisCodeValuesDto());
final DateTime beginDateTime = new DateTime(getPowerQualityProfileRequestDataDto.getBeginDate());
final DateTime endDateTime = new DateTime(getPowerQualityProfileRequestDataDto.getEndDate());
// all value types that can be selected within this profile.
final List<GetResult> captureObjects = this.retrieveCaptureObjects(conn, device, obisCode);
// the values that are allowed to be retrieved from the meter, used
// as filter either before (SMR 5.1+) or
// after data retrieval
final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects = this.createSelectableCaptureObjects(captureObjects, profile.getLogicalNames());
// the units of measure for all Selectable Capture objects
final List<ScalerUnitInfo> scalerUnitInfos = this.createScalerUnitInfos(conn, device, selectableCaptureObjects.values());
final List<GetResult> bufferList = this.retrieveBuffer(conn, device, obisCode, beginDateTime, endDateTime, new ArrayList<>(selectableCaptureObjects.values()));
final PowerQualityProfileDataDto responseDataDto = this.processData(profile, captureObjects, scalerUnitInfos, selectableCaptureObjects, bufferList);
responseDatas.add(responseDataDto);
}
response.setPowerQualityProfileDatas(responseDatas);
return response;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method createScalerUnitInfos.
private List<ScalerUnitInfo> createScalerUnitInfos(final DlmsConnectionManager conn, final DlmsDevice device, final Collection<CaptureObjectDefinitionDto> values) throws ProtocolAdapterException {
final List<ScalerUnitInfo> scalerUnitInfos = new ArrayList<>();
for (final CaptureObjectDefinitionDto dto : values) {
final ScalerUnitInfo newScalerUnitInfo = this.createScalerUnitInfo(conn, device, dto);
scalerUnitInfos.add(newScalerUnitInfo);
}
return scalerUnitInfos;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto 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.CaptureObjectDefinitionDto in project open-smart-grid-platform by OSGP.
the class ConfigureDefinableLoadProfileCommandExecutor method mapCaptureObjects.
private List<DataObject> mapCaptureObjects(final List<CaptureObjectDefinitionDto> captureObjects) {
final List<DataObject> captureObjectsArray = new ArrayList<>();
/*
* Always make sure the capture object definition of the clock time is
* included as first capture object in the list, and that the clock time
* is not included anywhere else as part of the capture objects.
*/
captureObjectsArray.add(CLOCK_TIME_DEFINITION);
for (final CaptureObjectDefinitionDto captureObject : captureObjects) {
if (!this.isClockTimeDefinition(captureObject)) {
captureObjectsArray.add(this.configurationMapper.map(captureObject, DataObject.class));
}
}
return captureObjectsArray;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileSelectiveAccessHandler method convertSelectableCaptureObjects.
@Override
protected DataObject convertSelectableCaptureObjects(final List<CaptureObjectDefinitionDto> selectableCaptureObjects) {
final List<DataObject> objectDefinitions = new ArrayList<>();
if (!selectableCaptureObjects.isEmpty()) {
// The captured clock is always included.
objectDefinitions.add(this.dlmsHelper.getClockDefinition());
for (final CaptureObjectDefinitionDto captureObjectDefinition : selectableCaptureObjects) {
final int classId = captureObjectDefinition.getClassId();
final byte[] obisBytes = captureObjectDefinition.getLogicalName().toByteArray();
final byte attributeIndex = captureObjectDefinition.getAttributeIndex();
final int dataIndex = captureObjectDefinition.getDataIndex() == null ? 0 : captureObjectDefinition.getDataIndex();
objectDefinitions.add(DataObject.newStructureData(Arrays.asList(DataObject.newUInteger16Data(classId), DataObject.newOctetStringData(obisBytes), DataObject.newInteger8Data(attributeIndex), DataObject.newUInteger16Data(dataIndex))));
}
}
return DataObject.newArrayData(objectDefinitions);
}
Aggregations