Pogo with PythonHL creates invalid code for dynamic attriubtes
Pogo version: Language: Python HL When creating dynamic attributes with pogo, the code created is invalid on runtime
Inside the initalize_dynamic_attribute, the following (correct!) code is created, in comment to be uncommented by the user
myTrajectory1 = PyTango.SpectrumAttr('MyTrajectory1', PyTango.DevDouble, PyTango.READ_WRITE, 10000)
self.add_attribute(myTrajectory1,LabDaqServer.read_Trajectory1, LabDaqServer.write_Trajectory1, None)
self.attr_Trajectory1_read = [0.0] `
But, the methods ready_Trajectory1 and write_Trajectory1 should accept an attribute parameter. Instead, the following code is created
def read_Trajectory1(self):
# PROTECTED REGION ID(LabDaqServer.Trajectory1_read) ENABLED START #
return [0.0]
# PROTECTED REGION END # // LabDaqServer.Trajectory1_read
def write_Trajectory1(self, value):
# PROTECTED REGION ID(LabDaqServer.Trajectory1_write) ENABLED START #
self.trajectories[1] = value
# PROTECTED REGION END # // LabDaqServer.Trajectory1_write
Obviously, an error follows
DevError[
desc = TypeError: read_Trajectory0() takes 1 positional argument but 2 were given
origin =
reason = PyDs_PythonError
severity = ERR]
DevError[
desc = Failed to read_attribute on device test/test/daq, attribute Trajectory0
origin = DeviceProxy::read_attribute()
reason = API_AttributeFailed
severity = ERR]
]
According to the forum [1], a read and write method for dynamic attribute goes like this
class MyDevice(Device):
__metaclass__ = DeviceMeta
@command(dtype_in=str)
def CreateFloatAttribute(self, attr_name):
attr = Attr(attr_name, PyTango.DevDouble)
self.add_attribute(attr, self.read_General, self.write_General)`
def read_General(self, attr):
self.info_stream("Reading attribute %s", attr.get_name())
attr.set_value(99.99)
def write_General(self, attr):
self.info_stream("Writting attribute %s", attr.get_name())