We are using a wrapper class for Zotino channels for user-friendly programming of ramps and sequences and general readability. The minimal class looks like this
class ZotinoChannel:
def __init__(self,dmgr,host_zotino, channel):
self.channel = channel
self.zotino = dmgr.get(host_zotino)
@kernel
def setVoltage(self, val, load = True):
self.zotino.write_dac(self.channel, val)
if load:
self.zotino.load()
def initRamp(self,name:str , start:float, stop:float, points:int=100, length:float=None, interval:float=None):
setattr(self, name, self._Ramp(self, start, stop, points, length, interval))
class _Ramp:
def __init__(self,obj, start:float, stop:float, points:int, interval):
self.rampVals = np.linspace(start,stop,points)
self.zotino = obj
self.interval = interval
@kernel
def start(self):
with sequential:
for val in self.rampVals:
self.zotino.setVoltage(val)
delay(self.interval)
and is called via an entry in the device_db
device_db["zotino_ch0"]={
'type':'local',
"module":"libcrs.devices",
"class":"ZotinoChannel",
"arguments":{
"channel":0,
"host_zotino":"zotino0"
}
}
calling the device like
self.setattr_device("zotino_ch0")
self.zotino_ch0("ramp1", 0., 1., 10, interval=2*ms)
and on the kernel
self.zotino_ch0.ramp.start()
works for one channel but as soon as I want to address multiple channels that way
for example:
self.zotino_ch1.setVoltage(x)
The compiler fails with the following error:
root:While compiling <repository>/2021-08/myExp.py
<synthesized>:1:1-1:58: error: host object does not have an attribute 'ramp1'
`<libcrs.devices.ZotinoChannel object at 0x7f947e002a00>`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<repository>/2021-08/myExp.py:38:1: note: expanded from here
def run_kernel(self):
^
<repository>/libcrs/experiments.py:305:17-305:60: note: attribute accessed here
self.zotino_ch0.ramp1.start()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Outside of kernel functions I can access the object normaly.
I suspect that the Kasli compiler does not distinguish correctly between the two objects. Right now I fixed it by not implementing the ramp as a class which takes away flexibility.