Hi,
I am trying to create a device server that can create new attributes during run-time. I am following the guide which gives the following example:
from PyTango import Util, Attr
from PyTango.server import DeviceMeta, Device, command
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())
Since I am not using the high-level Python API, I have created a command via POGO that creates a scalar attribute like so:
def createScalarAttribute(self, argin):
""" A method that creates a new scalar attribute.
:param argin: New attribute name.
:type: PyTango.DevString
:return:
:rtype: PyTango.DevVoid """
self.debug_stream("In createScalarAttribute()")
#----- PROTECTED REGION ID(TPM_DS.createScalarAttribute) ENABLED START -----#
attr = Attr(argin, PyTango.DevULong)
self.add_attribute(attr, self.read_GeneralScalar, self.write_GeneralScalar)
#----- PROTECTED REGION END -----# // TPM_DS.createScalarAttribute
Following this, I need to create new methods that are used for reading and writing this attribute. I can create these new methods in my python code, but since they are not in a protected region, every time I re-run POGO to add some other commands etc. these read/write methods are removed. Where would be the best place to put my methods?
Thanks. 0_o