Search in sources :

Example 1 with ScalerUnitInfo

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo in project open-smart-grid-platform by OSGP.

the class AbstractGetPowerQualityProfileHandler method createScalerUnitInfo.

private ScalerUnitInfo createScalerUnitInfo(final DlmsConnectionManager conn, final DlmsDevice device, final CaptureObjectDefinitionDto captureObjectDefinitionDto) throws ProtocolAdapterException {
    final int classId = captureObjectDefinitionDto.getClassId();
    final String logicalName = captureObjectDefinitionDto.getLogicalName().toString();
    if (this.hasScalerUnit(classId)) {
        final AttributeAddress addr = new AttributeAddress(classId, logicalName, SCALER_UNITS_MAP.get(classId));
        final List<GetResult> scalerUnitResult = this.dlmsHelper.getAndCheck(conn, device, "retrieve scaler unit for capture object", addr);
        final DataObject scalerUnitDataObject = scalerUnitResult.get(0).getResultData();
        return new ScalerUnitInfo(logicalName, classId, scalerUnitDataObject);
    } else {
        return new ScalerUnitInfo(logicalName, classId, null);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ScalerUnitInfo(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo)

Example 2 with ScalerUnitInfo

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo 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;
}
Also used : PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) GetResult(org.openmuc.jdlms.GetResult) ArrayList(java.util.ArrayList) ObisCode(org.openmuc.jdlms.ObisCode) LocalDateTime(java.time.LocalDateTime) DateTime(org.joda.time.DateTime) CaptureObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto) ScalerUnitInfo(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)

Example 3 with ScalerUnitInfo

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo 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;
}
Also used : ArrayList(java.util.ArrayList) ScalerUnitInfo(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo) CaptureObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)

Aggregations

ScalerUnitInfo (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo)3 ArrayList (java.util.ArrayList)2 GetResult (org.openmuc.jdlms.GetResult)2 CaptureObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)2 LocalDateTime (java.time.LocalDateTime)1 DateTime (org.joda.time.DateTime)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 ObisCode (org.openmuc.jdlms.ObisCode)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 GetPowerQualityProfileResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)1 PowerQualityProfileDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto)1