use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto in project open-smart-grid-platform by OSGP.
the class ObisCodeValuesTest method testObisCodeValues.
@Test
public void testObisCodeValues() {
final ObisCodeValuesDto obisCodeValues = new ObisCodeValuesDto((byte) 1, (byte) 2, (byte) 3, (byte) 234, (byte) 5, (byte) 255);
final ObisCode obisCode = new ObisCode(this.toInt(obisCodeValues.getA()), this.toInt(obisCodeValues.getB()), this.toInt(obisCodeValues.getC()), this.toInt(obisCodeValues.getD()), this.toInt(obisCodeValues.getE()), this.toInt(obisCodeValues.getF()));
assertThat(obisCode.bytes()[0]).isEqualTo((byte) 1);
assertThat(obisCode.bytes()[1]).isEqualTo((byte) 2);
assertThat(obisCode.bytes()[2]).isEqualTo((byte) 3);
assertThat(obisCode.bytes()[3]).isEqualTo((byte) 234);
assertThat(obisCode.bytes()[4]).isEqualTo((byte) 5);
assertThat(obisCode.bytes()[5]).isEqualTo((byte) 255);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto 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.ObisCodeValuesDto 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);
}
Aggregations