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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations