Commit cc1c1344 authored by bliss administrator's avatar bliss administrator

Blackify PEL code

parent c1474216
Pipeline #10097 failed with stages
from bliss.common.scans import * from bliss.common.scans import *
from bliss.common.plot import * from bliss.common.plot import *
def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs): def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs):
display_help = kwargs.pop('help', False) display_help = kwargs.pop("help", False)
if display_help: if display_help:
print "PELscan(mot, start, stop, nbp, int_time, interf1, counter.... nbscan=n, backlash=val, bidir=True/False, sleep_time=t(s)" print(
"PELscan(mot, start, stop, nbp, int_time, interf1, counter.... nbscan=n, backlash=val, bidir=True/False, sleep_time=t(s)"
)
return return
nbs = kwargs.pop('nbs', 1) nbs = kwargs.pop("nbs", 1)
backlash = kwargs.pop('backlash', 0) backlash = kwargs.pop("backlash", 0)
bidir = kwargs.pop('bidir', False) bidir = kwargs.pop("bidir", False)
return_scan = kwargs.get('return_scan', False) return_scan = kwargs.get("return_scan", False)
kwargs['return_scan'] = True kwargs["return_scan"] = True
for loop in range(nbs): for loop in range(nbs):
if bidir and loop%2 == 1: if bidir and loop % 2 == 1:
pos_bckl = p_en + backlash pos_bckl = p_en + backlash
pos_start = p_en pos_start = p_en
pos_end = p_st pos_end = p_st
...@@ -26,17 +29,20 @@ def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs): ...@@ -26,17 +29,20 @@ def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs):
pos_start = p_st pos_start = p_st
pos_end = p_en pos_end = p_en
print "Move motor \"%s\" to %g"%(mot.name, pos_bckl) print('Move motor "%s" to %g' % (mot.name, pos_bckl))
mot.move(pos_bckl) mot.move(pos_bckl)
print mot.position() print(mot.position())
scan = ascan(mot, pos_start, pos_end, nbp, t_int, *counters, **kwargs) scan = ascan(mot, pos_start, pos_end, nbp, t_int, *counters, **kwargs)
data = get_data(scan) data = get_data(scan)
# plot motor pos vs. counters by default # plot motor pos vs. counters by default
# do not plot interferometer since it doesn't give a useful result # do not plot interferometer since it doesn't give a useful result
counters_to_plot = [name for name in data.dtype.fields counters_to_plot = [
if name not in ('timestamp', mot.name) and not name.startswith('interf')] name
for name in data.dtype.fields
if name not in ("timestamp", mot.name) and not name.startswith("interf")
]
# Plotting de-activated by CG 6 aug. 2018... causes crash with flint :( # Plotting de-activated by CG 6 aug. 2018... causes crash with flint :(
# x = data[mot.name] # x = data[mot.name]
......
...@@ -22,26 +22,31 @@ from bliss.common.measurement import IntegratingCounter ...@@ -22,26 +22,31 @@ from bliss.common.measurement import IntegratingCounter
from bliss.config.settings import HashSetting from bliss.config.settings import HashSetting
from bliss.scanning.chain import AcquisitionMaster from bliss.scanning.chain import AcquisitionMaster
class TrigCounter(IntegratingCounter): class TrigCounter(IntegratingCounter):
def __init__(self, name, config): def __init__(self, name, config):
IntegratingCounter.__init__(self, name, None, self) IntegratingCounter.__init__(self, name, None, self)
trig_config = config['trigger_device'] trig_config = config["trigger_device"]
self._opiom_card = trig_config.get("name")
self._opiom_counter = trig_config.get("counter_number", 1) # default 1
high_time = trig_config.get("high_time", 1)
period = trig_config.get("period", 1)
nb_pulses = trig_config.get("nb_pulses", 1)
self._opiom_card = trig_config.get('name') self.__trigger_clock = config.get("_clock", 2000000)
self._opiom_counter = trig_config.\
get('counter_number', 1) # default 1
high_time = trig_config.get('high_time', 1)
period = trig_config.get('period', 1)
nb_pulses = trig_config.get('nb_pulses', 1)
self.__trigger_clock = config.get('_clock', 2000000) self._counter_config = HashSetting(
"%s:counter_config" % self.name,
default_values={
"high_time": high_time,
"period": period,
"nb_pulses": nb_pulses,
},
)
self._counter_config = HashSetting('%s:counter_config' % self.name,
default_values={'high_time' : high_time,
'period' : period,
'nb_pulses' : nb_pulses})
@property @property
def clock(self): def clock(self):
return self.__trigger_clock return self.__trigger_clock
...@@ -51,51 +56,57 @@ class TrigCounter(IntegratingCounter): ...@@ -51,51 +56,57 @@ class TrigCounter(IntegratingCounter):
""" """
High time in second for the pulse High time in second for the pulse
""" """
return self._counter_config['high_time'] return self._counter_config["high_time"]
@high_time.setter @high_time.setter
def high_time(self, value): def high_time(self, value):
self._counter_config['high_time'] = value self._counter_config["high_time"] = value
@property @property
def period(self): def period(self):
""" """
period in second for the pulse (high + low level) period in second for the pulse (high + low level)
""" """
return self._counter_config['period'] return self._counter_config["period"]
@period.setter @period.setter
def period(self, value): def period(self, value):
self._counter_config['period'] = value self._counter_config["period"] = value
@property @property
def nb_pulses(self): def nb_pulses(self):
""" """
Nb pulses generated when trigged Nb pulses generated when trigged
""" """
return self._counter_config['nb_pulses'] return self._counter_config["nb_pulses"]
@nb_pulses.setter @nb_pulses.setter
def nb_pulses(self, value): def nb_pulses(self, value):
self._counter_config['nb_pulses'] = value self._counter_config["nb_pulses"] = value
def get_value(self, from_index=0): def get_value(self, from_index=0):
return [self.nb_pulses] return [self.nb_pulses]
def create_master_device(self, scan_pars, **settings): def create_master_device(self, scan_pars, **settings):
npoints = scan_pars.get('npoints', 1) npoints = scan_pars.get("npoints", 1)
count_time = scan_pars.get('count_time', 1) count_time = scan_pars.get("count_time", 1)
return _TrigCounterAcqMaster(self, self.name, return _TrigCounterAcqMaster(
npoints=npoints, self, self.name, npoints=npoints, count_time=count_time
count_time=count_time) )
def __repr__(self): def __repr__(self):
params = ' '.join(['%s=%s' % (k, v) for k, v in params = " ".join(
self._counter_config.iteritems()]) ["%s=%s" % (k, v) for k, v in self._counter_config.iteritems()]
)
return "TrigCounter %s: %s" % (self.name, params) return "TrigCounter %s: %s" % (self.name, params)
class _TrigCounterAcqMaster(AcquisitionMaster): class _TrigCounterAcqMaster(AcquisitionMaster):
def __init__(self, device, name, npoints=None, count_time=None): def __init__(self, device, name, npoints=None, count_time=None):
AcquisitionMaster.__init__(self, device, name, npoints=npoints, AcquisitionMaster.__init__(
prepare_once=True, start_once=True) self, device, name, npoints=npoints, prepare_once=True, start_once=True
)
self._count_time = count_time self._count_time = count_time
def prepare(self): def prepare(self):
...@@ -105,8 +116,9 @@ class _TrigCounterAcqMaster(AcquisitionMaster): ...@@ -105,8 +116,9 @@ class _TrigCounterAcqMaster(AcquisitionMaster):
low_time = (self.device.period - self.device.high_time) * self.device.clock low_time = (self.device.period - self.device.high_time) * self.device.clock
nb_pulses = self.device.nb_pulses nb_pulses = self.device.nb_pulses
opiom.comm("CNT %d RESET" % counter) opiom.comm("CNT %d RESET" % counter)
opiom.comm("CNT %d CLK2 PULSE %d %d %d" %\ opiom.comm(
(counter, high_time, low_time, nb_pulses)) "CNT %d CLK2 PULSE %d %d %d" % (counter, high_time, low_time, nb_pulses)
)
def add_counter(self, counter): def add_counter(self, counter):
pass pass
...@@ -135,5 +147,3 @@ class _TrigCounterAcqMaster(AcquisitionMaster): ...@@ -135,5 +147,3 @@ class _TrigCounterAcqMaster(AcquisitionMaster):
if not running: if not running:
break break
gevent.idle() gevent.idle()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment