Hello,
I am currently developing a perspective component for manipulating Bacnet schedules.
I would like to call the system.bacnet.readRaw function from the Bacnet Driver module directly within the Java code of my module to simplify its usage.
The RPC approach is not feasible because there are no instances of it instantiated in the Bacnet module.
The Script Manager approach, using runFunction, seems to encounter some difficulties during the conversion of Bacnet types.
public static Object readRaw (GatewayContext gatewayContext, String deviceName, ObjectType objectType, Integer objectId, PropertyIdentifier propertyId, Integer propertyArrayIndex) throws Exception{
PyObject systemModule = gatewayContext.getScriptManager().createLocalsMap().__finditem__("system");
PyObject bacnetModule = systemModule.__finditem__("bacnet");
PyObject readRawFunction = bacnetModule.__finditem__("readRaw");
PyObject[] arguments = new PyObject[] { new PyString(deviceName), Py.java2py(objectType), new PyInteger(objectId), Py.java2py(propertyId), new PyInteger(propertyArrayIndex) };
return gatewayContext.getScriptManager().runFunction(readRawFunction, arguments);
}
JythonExecException: TypeError: readRaw(): argument objectType: expected ObjectType instance, got PyObjectDerived
Does anyone know of a solution or have an idea?