Search in sources :

Example 16 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DynamicValues method getDlmsAttributeValue.

public DataObject getDlmsAttributeValue(final CosemInterfaceObject cosemInterfaceObject, final Integer attributeId) {
    final int classId = cosemInterfaceObject.getClass().getAnnotation(CosemClass.class).id();
    final ObisCode obisCode = cosemInterfaceObject.getInstanceId();
    final DataObject result = this.getDlmsAttributeValue(classId, obisCode, attributeId);
    if (result != null) {
        return result;
    }
    return this.getDefaultAttributeValue(classId, obisCode, attributeId);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ObisCode(org.openmuc.jdlms.ObisCode) CosemClass(org.openmuc.jdlms.CosemClass)

Example 17 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class CosemDateTimeFilterTest method createRangeDescriptor.

private List<DataObject> createRangeDescriptor() {
    final DataObject captureObject = new CaptureObject(8, "0.0.1.0.0.255", (byte) 2, 0).asDataObject();
    final DataObject dateTimeFrom = this.asDataObject(new DateTime(2017, 1, 1, 0, 0), 0, false);
    final DataObject dateTimeTo = this.asDataObject(new DateTime(2017, 1, 2, 0, 0), 0, false);
    return Arrays.asList(captureObject, dateTimeFrom, dateTimeTo);
}
Also used : CaptureObject(org.opensmartgridplatform.simulator.protocol.dlms.cosem.CaptureObject) DataObject(org.openmuc.jdlms.datatypes.DataObject) DateTime(org.joda.time.DateTime) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime)

Example 18 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DlmsAttributeValuesClient method asDataObjectList.

private static List<DataObject> asDataObjectList(final JsonNode valueNode) {
    if (!valueNode.isArray()) {
        throw new IllegalArgumentException("JSON node for complex data must be an array: " + valueNode);
    }
    final List<DataObject> dataObjectList = new ArrayList<>();
    final Iterator<JsonNode> elements = valueNode.elements();
    while (elements.hasNext()) {
        final JsonNode element = elements.next();
        if (!element.isObject()) {
            throw new IllegalArgumentException("JSON node for complex data must be an array of object nodes: " + valueNode);
        }
        dataObjectList.add(jsonNodeAsDataObject((ObjectNode) element));
    }
    return dataObjectList;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 19 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DlmsAttributeValuesClient method setComplexValue.

private void setComplexValue(final ObjectNode attributeNode, final DataObject dataObject) {
    if (!dataObject.isComplex()) {
        throw new IllegalArgumentException("DataObject must be complex: " + dataObject);
    }
    if (dataObject.getType() == DataObject.Type.COMPACT_ARRAY) {
        throw new IllegalArgumentException("DataObject values of type " + dataObject.getType() + " are not yet supported");
    }
    final List<JsonNode> jsonElements = new ArrayList<>();
    final List<DataObject> elements = dataObject.getValue();
    for (final DataObject element : elements) {
        jsonElements.add(this.dataObjectAsJsonNode(element));
    }
    final JsonNode valueNode = new ArrayNode(new JsonNodeFactory(false), jsonElements);
    attributeNode.set(JSON_VALUE_FIELD, valueNode);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory)

Example 20 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class CaptureObjectDefinitionCollection method selectedCaptureObjects.

private List<CaptureObject> selectedCaptureObjects(final List<DataObject> rangeDescriptor) {
    final List<CaptureObject> selectedObjects = new ArrayList<>();
    final List<DataObject> selectedValues = rangeDescriptor.get(3).getValue();
    for (final DataObject selectedValue : selectedValues) {
        selectedObjects.add(CaptureObject.newCaptureObject(selectedValue));
    }
    return selectedObjects;
}
Also used : CaptureObject(org.opensmartgridplatform.simulator.protocol.dlms.cosem.CaptureObject) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Aggregations

DataObject (org.openmuc.jdlms.datatypes.DataObject)176 ArrayList (java.util.ArrayList)46 AttributeAddress (org.openmuc.jdlms.AttributeAddress)36 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)34 Test (org.junit.jupiter.api.Test)31 GetResult (org.openmuc.jdlms.GetResult)23 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)16 DateTime (org.joda.time.DateTime)15 CosemDateTime (org.openmuc.jdlms.datatypes.CosemDateTime)14 SetParameter (org.openmuc.jdlms.SetParameter)12 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)11 BitString (org.openmuc.jdlms.datatypes.BitString)10 ObisCode (org.openmuc.jdlms.ObisCode)9 IOException (java.io.IOException)8 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)7 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)6 List (java.util.List)5 MethodResultCode (org.openmuc.jdlms.MethodResultCode)5 AttributeAddressForProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.AttributeAddressForProfile)5 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)5