Commit 125a650d authored by bliss administrator's avatar bliss administrator

Counter which generates pulses on opiom

Used for PEL interferometer and LION encoders
parent 9c95c21c
# -*- coding: utf-8 -*-
# This file is part of the bliss project
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
YAML_ configuration example:
.. code-block:: yaml
- class: TrigCounter
package: pel.TrigCounter
name: interf
type: opiom
counter_number: 1 # CNT 1
import gevent
from bliss.common.measurement import IntegratingCounter
from bliss.config.settings import HashSetting
from bliss.scanning.chain import AcquisitionMaster
class TrigCounter(IntegratingCounter):
def __init__(self, name, config):
IntegratingCounter.__init__(self, name, None, self)
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.__trigger_clock = config.get('_clock', 2000000)
self._counter_config = HashSetting('%s:counter_config' %,
default_values={'high_time' : high_time,
'period' : period,
'nb_pulses' : nb_pulses})
def clock(self):
return self.__trigger_clock
def high_time(self):
High time in second for the pulse
return self._counter_config['high_time']
def high_time(self, value):
self._counter_config['high_time'] = value
def period(self):
period in second for the pulse (high + low level)
return self._counter_config['period']
def period(self, value):
self._counter_config['period'] = value
def nb_pulses(self):
Nb pulses generated when trigged
return self._counter_config['nb_pulses']
def nb_pulses(self, value):
self._counter_config['nb_pulses'] = value
def get_value(self, from_index=0):
return [self.nb_pulses]
def create_master_device(self, scan_pars, **settings):
npoints = scan_pars.get('npoints', 1)
count_time = scan_pars.get('count_time', 1)
return _TrigCounterAcqMaster(self,,
def __repr__(self):
params = ' '.join(['%s=%s' % (k, v) for k, v in
return "TrigCounter %s: %s" % (, params)
class _TrigCounterAcqMaster(AcquisitionMaster):
def __init__(self, device, name, npoints=None, count_time=None):
AcquisitionMaster.__init__(self, device, name, npoints=npoints,
prepare_once=True, start_once=True)
self._count_time = count_time
def prepare(self):
opiom = self.device._opiom_card
counter = self.device._opiom_counter
high_time = 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
opiom.comm("CNT %d RESET" % counter)
opiom.comm("CNT %d CLK2 PULSE %d %d %d" %\
(counter, high_time, low_time, nb_pulses))
def add_counter(self, counter):
def start(self):
if not self.parent:
def stop(self):
opiom = self.device._opiom_card
counter = self.device._opiom_counter
opiom.comm("#CNT %d STOP" % counter)
def trigger(self):
opiom = self.device._opiom_card
counter = self.device._opiom_counter
opiom.comm("CNT %d START" % counter)
def wait_ready(self):
opiom = self.device._opiom_card
counter = self.device._opiom_counter
comm = "?SCNT %d" % counter
while True:
running = opiom.comm(comm) == "RUN"
if not running:
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