Ejemplo n.º 1
0
def createControllerConfiguration(pool_ctrl, pool_channels):
    conf_ctrl = ControllerConfiguration(pool_ctrl)
    for pool_channel in pool_channels:
        channel = ChannelConfiguration(pool_channel)
        channel.controller = conf_ctrl
        conf_ctrl.add_channel(channel)
    return conf_ctrl
Ejemplo n.º 2
0
def createControllerConfiguration(pool_ctrl, pool_channels):
    conf_ctrl = ControllerConfiguration(pool_ctrl)
    for pool_channel in pool_channels:
        channel = ChannelConfiguration(pool_channel)
        channel.controller = conf_ctrl
        conf_ctrl.add_channel(channel)
    return conf_ctrl
Ejemplo n.º 3
0
 def __init__(self, **kwargs):
     PoolBaseChannel.__init__(self, **kwargs)
     # TODO: part of the configuration could be moved to the base class
     # so other experimental channels could reuse it
     self._conf_channel = ChannelConfiguration(self)
     self._conf_ctrl = ControllerConfiguration(self.controller)
     self._conf_ctrl.add_channel(self._conf_channel)
     self._timer = "__default"
     self._conf_timer = None
Ejemplo n.º 4
0
 def __init__(self, **kwargs):
     PoolBaseChannel.__init__(self, **kwargs)
     # TODO: part of the configuration could be moved to the base class
     # so other experimental channels could reuse it
     self._conf_channel = ChannelConfiguration(self)
     self._conf_ctrl = ControllerConfiguration(self.controller)
     self._conf_ctrl.add_channel(self._conf_channel)
     self._timer = "__default"
     self._conf_timer = None
Ejemplo n.º 5
0
class PoolTimerableChannel(PoolBaseChannel):

    def __init__(self, **kwargs):
        PoolBaseChannel.__init__(self, **kwargs)
        # TODO: part of the configuration could be moved to the base class
        # so other experimental channels could reuse it
        self._conf_channel = ChannelConfiguration(self)
        self._conf_ctrl = ControllerConfiguration(self.controller)
        self._conf_ctrl.add_channel(self._conf_channel)
        self._timer = "__default"
        self._conf_timer = None

    # ------------------------------------------------------------------------
    # timer
    # ------------------------------------------------------------------------

    def get_timer(self):
        """Return the timer for this object.

        :return: the current timer
        :rtype: :obj:`str`
        """
        return self._timer

    def set_timer(self, timer, propagate=1):
        """Set timer for this object.

        :param timer: new timer to set
        :type timer: :obj:`str`
        :param propagate:
            0 for not propagating, 1 to propagate, 2 propagate with priority
        :type propagate: :obj:`int`
        """
        if timer == self._timer:
            return
        if self._conf_timer is not None:
            timer_elem = self._conf_timer.element
            if timer_elem is not self:
                self.acquisition.remove_element(timer_elem)
                self._conf_ctrl.remove_channel(self._conf_timer)
        self._timer = timer
        self._conf_timer = None
        if not propagate:
            return
        self.fire_event(EventType("timer", priority=propagate), timer)

    timer = property(get_timer, set_timer,
                     doc="timer for the timerable channel")

    def _configure_timer(self):
        timer = self.timer
        if timer == "__self":
            conf_timer = self._conf_channel
        else:
            ctrl = self.get_controller()
            if timer == "__default":
                axis = ctrl.get_default_timer()
                if axis is None:
                    msg = "default_timer not defined in controller"
                    raise ValueError(msg)
                timer_elem = ctrl.get_element(axis=axis)
            else:
                timer_elem = self.pool.get_element_by_name(timer)
            if timer_elem is self:
                conf_timer = self._conf_channel
            else:
                self.acquisition.add_element(timer_elem)
                conf_timer = ChannelConfiguration(timer_elem)
                self._conf_ctrl.add_channel(conf_timer)
        self._conf_ctrl.timer = conf_timer
        self._conf_timer = conf_timer

    def start_acquisition(self):
        """Start software triggered acquisition"""
        self._aborted = False
        self._stopped = False
        if self._simulation_mode:
            return
        if self.timer is None:
            msg = "no timer configured - acquisition is not possible"
            raise RuntimeError(msg)
        self._prepare()
        ctrls, master = get_timerable_items(
            [self._conf_ctrl], self._conf_timer, AcqMode.Timer)
        self.acquisition.run(ctrls, self.integration_time, master, None)

    def _prepare(self):
        # TODO: think of implementing the preparation in the software
        # acquisition action, similarly as it is done for the global
        # acquisition action
        PoolBaseChannel._prepare(self)
        if self._conf_timer is None:
            self._configure_timer()
        axis = self._conf_timer.axis
        repetitions = 1
        latency = 0
        nb_starts = 1
        self.controller.set_ctrl_par("synchronization",
                                     AcqSynch.SoftwareTrigger)
        self.controller.ctrl.PrepareOne(axis, self.integration_time,
                                        repetitions, latency, nb_starts)
Ejemplo n.º 6
0
class PoolTimerableChannel(PoolBaseChannel):

    def __init__(self, **kwargs):
        PoolBaseChannel.__init__(self, **kwargs)
        # TODO: part of the configuration could be moved to the base class
        # so other experimental channels could reuse it
        self._conf_channel = ChannelConfiguration(self)
        self._conf_ctrl = ControllerConfiguration(self.controller)
        self._conf_ctrl.add_channel(self._conf_channel)
        self._timer = "__default"
        self._conf_timer = None

    # ------------------------------------------------------------------------
    # timer
    # ------------------------------------------------------------------------

    def get_timer(self):
        """Return the timer for this object.

        :return: the current timer
        :rtype: :obj:`str`
        """
        return self._timer

    def set_timer(self, timer, propagate=1):
        """Set timer for this object.

        :param timer: new timer to set
        :type timer: :obj:`str`
        :param propagate:
            0 for not propagating, 1 to propagate, 2 propagate with priority
        :type propagate: :obj:`int`
        """
        if timer == self._timer:
            return
        if self._conf_timer is not None:
            timer_elem = self._conf_timer.element
            if timer_elem is not self:
                self.acquisition.remove_element(timer_elem)
                self._conf_ctrl.remove_channel(self._conf_timer)
        self._timer = timer
        self._conf_timer = None
        if not propagate:
            return
        self.fire_event(EventType("timer", priority=propagate), timer)

    timer = property(get_timer, set_timer,
                     doc="timer for the timerable channel")

    def _configure_timer(self):
        timer = self.timer
        if timer == "__self":
            conf_timer = self._conf_channel
        else:
            ctrl = self.get_controller()
            if timer == "__default":
                axis = ctrl.get_default_timer()
                if axis is None:
                    msg = "default_timer not defined in controller"
                    raise ValueError(msg)
                timer_elem = ctrl.get_element(axis=axis)
            else:
                timer_elem = self.pool.get_element_by_name(timer)
            if timer_elem is self:
                conf_timer = self._conf_channel
            else:
                self.acquisition.add_element(timer_elem)
                conf_timer = ChannelConfiguration(timer_elem)
                self._conf_ctrl.add_channel(conf_timer)
        self._conf_ctrl.timer = conf_timer
        self._conf_timer = conf_timer

    def start_acquisition(self):
        """Start software triggered acquisition"""
        self._aborted = False
        self._stopped = False
        if self._simulation_mode:
            return
        if self.timer is None:
            msg = "no timer configured - acquisition is not possible"
            raise RuntimeError(msg)

        if self._conf_timer is None:
            self._configure_timer()
        self.controller.set_ctrl_par("synchronization",
                                     AcqSynch.SoftwareTrigger)
        ctrls, master = get_timerable_items(
            [self._conf_ctrl], self._conf_timer, AcqMode.Timer)
        self.acquisition.run(ctrls, self.integration_time, master, None)