use of org.openmuc.jdlms.ObisCode 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.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutor method readScalerUnit.
private DataObject readScalerUnit(final List<GetResult> getResultList, final List<AttributeAddress> attributeAddresses, final AttributeAddressForProfile attributeAddressForProfile, final Integer channel) {
final DlmsCaptureObject captureObject = attributeAddressForProfile.getCaptureObject(DlmsObjectType.MBUS_MASTER_VALUE);
int index = 0;
Integer scalerUnitIndex = null;
for (final AttributeAddress address : attributeAddresses) {
final String obisCode = captureObject.getRelatedObject().getObisCodeAsString().replace("<c>", channel.toString());
if (address.getInstanceId().equals(new ObisCode(obisCode))) {
scalerUnitIndex = index;
}
index++;
}
// and should be skipped. The first scaler unit is at index 1.
if (scalerUnitIndex != null) {
return getResultList.get(scalerUnitIndex + 1).getResultData();
}
return null;
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class GetSpecificAttributeValueCommandExecutor method execute.
@Override
public String execute(final DlmsConnectionManager conn, final DlmsDevice device, final SpecificAttributeValueRequestDto requestData, final MessageMetadata messageMetadata) throws FunctionalException {
final ObisCodeValuesDto obisCodeValues = requestData.getObisCode();
final byte[] obisCodeBytes = { obisCodeValues.getA(), obisCodeValues.getB(), obisCodeValues.getC(), obisCodeValues.getD(), obisCodeValues.getE(), obisCodeValues.getF() };
final ObisCode obisCode = new ObisCode(obisCodeBytes);
LOGGER.debug("Get specific attribute value, class id: {}, obis code: {}, attribute id: {}", requestData.getClassId(), obisCode, requestData.getAttribute());
final AttributeAddress attributeAddress = new AttributeAddress(requestData.getClassId(), obisCode, requestData.getAttribute());
conn.getDlmsMessageListener().setDescription("GetSpecificAttributeValue, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
final DataObject attributeValue = this.dlmsHelper.getAttributeValue(conn, attributeAddress);
return this.dlmsHelper.getDebugInfo(attributeValue);
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutor method readScalerUnit.
private DataObject readScalerUnit(final List<GetResult> getResultList, final List<AttributeAddress> attributeAddresses, final AttributeAddressForProfile attributeAddressForProfile, final DlmsObjectType objectType) {
final DlmsCaptureObject captureObject = attributeAddressForProfile.getCaptureObject(objectType);
int index = 0;
Integer scalerUnitIndex = null;
for (final AttributeAddress address : attributeAddresses) {
final ObisCode obisCode = captureObject.getRelatedObject().getObisCode();
if (address.getInstanceId().equals(obisCode)) {
scalerUnitIndex = index;
}
index++;
}
// and should be skipped. The first scaler unit is at index 1.
if (scalerUnitIndex != null) {
return getResultList.get(scalerUnitIndex + 1).getResultData();
}
return null;
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class GetActualMeterReadsGasCommandExecutor method execute.
@Override
public MeterReadsGasResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final ActualMeterReadsQueryDto actualMeterReadsRequest, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final ObisCode obisCodeMbusMasterValue = this.masterValueForChannel(actualMeterReadsRequest.getChannel());
LOGGER.debug("Retrieving current MBUS master value for ObisCode: {}", obisCodeMbusMasterValue);
final AttributeAddress mbusValue = new AttributeAddress(CLASS_ID_MBUS, this.masterValueForChannel(actualMeterReadsRequest.getChannel()), ATTRIBUTE_ID_VALUE);
LOGGER.debug("Retrieving current MBUS master capture time for ObisCode: {}", obisCodeMbusMasterValue);
final AttributeAddress mbusTime = new AttributeAddress(CLASS_ID_MBUS, obisCodeMbusMasterValue, ATTRIBUTE_ID_TIME);
final AttributeAddress scalerUnit = new AttributeAddress(CLASS_ID_MBUS, this.masterValueForChannel(actualMeterReadsRequest.getChannel()), ATTRIBUTE_ID_SCALER_UNIT);
conn.getDlmsMessageListener().setDescription("GetActualMeterReadsGas for channel " + actualMeterReadsRequest.getChannel() + ", retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(mbusValue, mbusTime, scalerUnit));
final List<GetResult> getResultList = this.dlmsHelper.getAndCheck(conn, device, "retrieve actual meter reads for mbus " + actualMeterReadsRequest.getChannel(), mbusValue, mbusTime, scalerUnit);
final DlmsMeterValueDto consumption = this.dlmsHelper.getScaledMeterValue(getResultList.get(0), getResultList.get(2), "retrieve scaled value for mbus " + actualMeterReadsRequest.getChannel());
final CosemDateTimeDto cosemDateTime = this.dlmsHelper.readDateTime(getResultList.get(1), "captureTime gas");
final Date captureTime;
if (cosemDateTime.isDateTimeSpecified()) {
captureTime = cosemDateTime.asDateTime().toDate();
} else {
throw new ProtocolAdapterException("Unexpected null/unspecified value for M-Bus Capture Time");
}
return new MeterReadsGasResponseDto(new Date(), consumption, captureTime);
}
Aggregations