Search in sources :

Example 1 with ObisCodeValuesDto

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);
}
Also used : ObisCode(org.openmuc.jdlms.ObisCode) ObisCodeValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto) Test(org.junit.jupiter.api.Test)

Example 2 with ObisCodeValuesDto

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;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) HashMap(java.util.HashMap) CosemObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto) ObisCodeValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto) CaptureObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)

Example 3 with ObisCodeValuesDto

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode) ObisCodeValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto)

Aggregations

ObisCodeValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ObisCodeValuesDto)3 ObisCode (org.openmuc.jdlms.ObisCode)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 GetResult (org.openmuc.jdlms.GetResult)1 CaptureObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)1 CosemObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObjectDefinitionDto)1