Which Sardana Controller to mesure distance with a laser distance sensor.

Hello,
I hope this is not the wrong place where to post this but I did not find a Form for Sardana.
I'm new to pyTango and Sardana but I managed to make MyOwnMotorController.py and acquire position and mouve properly my motors.
I also did the Simple TaurusForm with my 5 motors.
I use:
python2.7
python-pytango/stable,now 9.2.5-1 amd64 [installé] with all what goes with that install
python-sardana/stable,now 2.6.2+dfsg-1 all [installé]
python-taurus/stable,now 4.5.0+dfsg-1 all [installé]

Now I do not know how to make mesure with a distance laser detector.
I want to switch the laser On then take n mesures (exemple 20 with 1 mesure each second) and then switch it off for exemple.
And also in other case switch the laser On and mesure until I call stop.

I have a class That does only this:
——————————
class ILD1320Mesure(object):
def __init__(self):
…some init

def startLaser(self):
# THIS CODE SWITCH The Laser ON

def stopLaser(self):
# THIS CODE SWITCH The Laser OFF

def getMesure(self):
# THIS code aquire only 1 mesure
return value

def getState(self):
return someState

——————————
I created a class ILD1320CounterTimerController(CounterTimerController),
I also tryed a class ILD1320ZeroDController(ZeroDController),
but I do not understand what it is exactly (I read the doc) but I'm pure soft dev.
In namings: ct stand for CounterTimer and zd for ZeroD.

============================
1/ For the ILD1320CounterTimerController I have with spock done all the process until : defelem ctild1320
using the code here after WITH THE lines containing # MUST BE REMOVED (they switch on and off the laser while it is not here I want it to happen)
—-
class ILD1320CounterTimerController(CounterTimerController):

MaxDevice = 1

def __init__(self, inst, props, *args, **kwargs):
"""Constructor"""
super(ILD1320CounterTimerController, self).__init__(inst, props, *args, **kwargs)
self.channels = self.MaxDevice * [None, ]

def AddDevice(self, axis):
CounterTimerController.AddDevice(self, axis)
self._log.debug("====>>>> AddDevice START <<<<<<====")
idx = axis - 1
if len(self.channels) < axis:
raise Exception("Invalid axis %d" % axis)
self.channels[idx] = ILD1320Mesure()

def DeleteDevice(self, axis):
CounterTimerController.DeleteDevice(self, axis)
self._log.debug("====>>>> DeleteDevice START <<<<<<====")
idx = axis - 1
if len(self.channels) < axis or not self.channels[idx]:
self._log.error("Invalid axis %d" % axis)

def ReadOne(self, axis):
"""Get the specified counter value"""
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.startLaser() # MUST BE REMOVED
mesure = ild1320.getMesure()
ild1320.stopLaser() # MUST BE REMOVED
return mesure

def StateOne(self, axis):
"""Get the specified counter state"""
idx = axis - 1
ild1320 = self.channels[idx]
return ild1320.getState()

#MBJ TODO BUG THIS METHOD NEVER HAPPEN
def StartAll(self):
self._log.debug("====>>>> StartAll START <<<<<<====")
pass

#MBJ TODO BUG THIS METHOD NEVER HAPPEN
def PreStartOne(self, axis):
self._log.debug("====>>>> PreStartOne START <<<<<<====")
return True

# MBJ TODO BUG THIS METHOD NEVER WORK Both of the declaration
#def StartOne(self, axis, value=None):
def StartOne(self, axis):
"""acquire the specified counter"""
self._log.debug("====>>>> StartOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.startLaser()

#MBJ TODO BUG THIS METHOD NEVER WORK
def LoadOne(self, axis, value, repetitions):
self._log.debug("====>>>> LoadOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
# I DO NOT KNOW WHAT TODO HERE

def StopOne(self, axis):
"""Stop the specified counter"""
self._log.debug("====>>>> StopOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.stopLaser()

def AbortOne(self, axis):
"""Abort the specified counter"""
self._log.debug("====>>>> AbortOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.stopLaser()
————————–
Here the infos about my elem from spock:
Door_ipadiffx_1 [6]: ctild1320.get_attribute_list()
Result [6]: ['Instrument', 'SimulationMode', 'Data', 'Value', 'State', 'Status']

Door_ipadiffx_1 [7]: ctild1320.get_command_list()
Result [7]: ['Abort', 'Init', 'Restore', 'Start', 'State', 'Status', 'Stop']

If I call in spock: ctild1320.value
=> I get My proper mesure.
If I call in spock: ctild1320.Stop() or ctild1320.Abort()
=> I get the proper infos in sardana log (it goes in my code) all OK.

But when I try to call in spock: ctild1320.Start()
=>I have this error:
DevFailed[
DevError[
desc = AttributeError: 'PoolCounterTimer' object has no attribute 'get_write_value'

origin = File "/usr/lib/python2.7/dist-packages/sardana/tango/pool/CTExpChannel.py", line 219, in Start
self.ct.start_acquisition()
File "/usr/lib/python2.7/dist-packages/sardana/pool/poolbasechannel.py", line 285, in start_acquisition
value = self.get_write_value()

reason = PyDs_PythonError
severity = ERR]

DevError[
desc = Failed to execute command_inout on device expchan/ild1320ctrl/1, command Start
origin = Connection::command_inout()
reason = API_CommandFailed
severity = ERR]
]

——————-
But I call in spock: ctild1320.Load()
Like expected I have AttributeError: Load
I putted that code because in the documentation exemple there is this LoadOne method, I do not understand what it suppose to do.
=================================

At this point I tried the ZeroDController
2/ For the ILD1320ZeroDController I have with spock done all the process until : defelem zdild1320
using the code here after WITH THE lines containing # MUST BE REMOVED (they switch on and off the laser while it is not here I want it to happen)
———————
class ILD1320ZeroDController(ZeroDController):

MaxDevice = 1

def __init__(self, inst, props, *args, **kwargs):
"""Constructor"""
super(ILD1320ZeroDController, self).__init__(inst, props, *args, **kwargs)
self.channels = self.MaxDevice * [None, ]

def AddDevice(self, axis):
ZeroDController.AddDevice(self, axis)
self._log.debug("====>>>> AddDevice START <<<<<<====")
idx = axis - 1
if len(self.channels) < axis:
raise Exception("Invalid axis %d" % axis)
self.channels[idx] = ILD1320Mesure()

def DeleteDevice(self, axis):
ZeroDController.DeleteDevice(self, axis)
self._log.debug("====>>>> DeleteDevice START <<<<<<====")
idx = axis - 1
if len(self.channels) < axis or not self.channels[idx]:
self._log.error("Invalid axis %d" % axis)

def ReadOne(self, axis):
"""Get the specified counter value"""
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.startLaser() # MUST BE REMOVED
mesure = ild1320.getMesure()
ild1320.stopLaser() # MUST BE REMOVED
return mesure

def StateOne(self, axis):
"""Get the specified counter state"""
idx = axis - 1
ild1320 = self.channels[idx]
return ild1320.getState()

def StopOne(self, axis):
"""Stop the specified counter"""
self._log.debug("====>>>> StopOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.stopLaser()

def AbortOne(self, axis):
"""Abort the specified counter"""
self._log.debug("====>>>> AbortOne START <<<<<<====")
idx = axis - 1
ild1320 = self.channels[idx]
ild1320.stopLaser()
———————-
Here the infos about my elem from spock:

Door_ipadiffx_1 [19]: zdild1320.get_attribute_list()
Result [19]: ['AccumulationBuffer', 'SimulationMode', 'ValueBuffer', 'Instrument', 'AccumulationType', 'TimeBuffer', 'CurrentValue', 'Data', 'Value', 'State', 'Status']

Door_ipadiffx_1 [20]: zdild1320.get_command_list()
Result [20]: ['Abort', 'Init', 'Restore', 'Start', 'State', 'Status', 'Stop']

If I call in spock: zdild1320.currentvalue
=> I get My proper mesure.
If I call in spock: zdild1320.Stop() or zdild1320.Abort()
=> I get the proper infos in sardana log (it goes in my code) all OK.

But when I try to call in spock: zdild1320.Start()
=>I have this error
DevFailed[
DevError[
desc = Exception: Invalid integration_time 'None'. Hint set a new value for 'value' first

origin = File "/usr/lib/python2.7/dist-packages/sardana/tango/pool/ZeroDExpChannel.py", line 201, in Start
self.zerod.start_acquisition()
File "/usr/lib/python2.7/dist-packages/sardana/pool/poolzerodexpchannel.py", line 338, in start_acquisition
"Invalid integration_time '%s'. Hint set a new value for 'value' first" % value)

reason = PyDs_PythonError
severity = ERR]

DevError[
desc = Failed to execute command_inout on device expchan/ild1320zdctrl/1, command start
origin = Connection::command_inout()
reason = API_CommandFailed
severity = ERR]
]
—–
When I call in spock: zdild1320.value
=>I have this error
DevFailed[
DevError[
desc = Exception: Value not available: no successful acquisition done so far!

origin = File "/usr/lib/python2.7/dist-packages/sardana/tango/pool/PoolDevice.py", line 376, in _read_DynamicAttribute
return read(attr)
File "/usr/lib/python2.7/dist-packages/sardana/tango/pool/ZeroDExpChannel.py", line 183, in read_Value
self.set_attribute(attr, value=value.value,
File "/usr/lib/python2.7/dist-packages/sardana/sardanaattribute.py", line 146, in get_value
return self._get_value()
File "/usr/lib/python2.7/dist-packages/sardana/pool/poolzerodexpchannel.py", line 168, in _get_value
raise Exception("Value not available: no successful acquisition"

reason = PyDs_PythonError
severity = ERR]

DevError[
desc = Failed to read_attribute on device expchan/ild1320zdctrl/1, attribute value
origin = DeviceProxy::read_attribute()
reason = API_AttributeFailed
severity = ERR]
]
——————

Can Someone Please explain me which controller I should use and also How to use it for my current goal:
Distance mesure:
1. switch the laser On then take n mesures (exemple 20 with 1 mesure each second) and then switch it off for exemple.
2. switch the laser On and mesure until I call stop.

If you have a Hint or more for a Taurus interface (a Start button a stop button and autoupdating value) It would be the TOP.

At least Thank for having read until the End.
I realy need help.

Marouane BEN JELLOUL
IPANEMA - CNRS - located in the field of Soleil Synchrotron
Hi Marouane,
You can raise your Sardana questions directly on GitHub: https://github.com/sardana-org/sardana/issues/new. This is the recommended way of getting help on this project. Regarding your question I will read it carefully and will try to answer tomorrow.
Thanks for your interest in Sardana!
Zibi
Just for the reference, the same question was asked on the sardana-devel mailing list. We will continue this discussion there:
https://sourceforge.net/p/sardana/mailman/message/36928524/
 
Register or login to create to post a reply.