Ejemplo n.º 1
0
 def do_rewind(self, steps=None):
     """Start a pause"""
     # make some sequences for config
     plugins = [self.simDetectorDriver.stateMachine,
                self.positionPlugin.stateMachine]
     for d in plugins:
         assert d.state in DState.canAbort(), \
             "Child device {} in state {} is not abortable"\
             .format(d, d.state)
     seq_items = []
     # if we need to abort
     if self.simDetectorDriver.state not in DState.canConfig() or \
             self.positionPlugin.state not in DState.canConfig():
         seq_items += [
             SeqFunctionItem(
                 "Stopping simDetectorDriver", self.simDetectorDriver.abort,
                 block=False),
             SeqFunctionItem(
                 "Stopping positionPlugin", self.positionPlugin.abort,
                 block=False),
             SeqTransitionItem(
                 "Wait for plugins to stop", plugins,
                 DState.Aborted, DState.rest()),
             SeqFunctionItem(
                 "Reset simDetectorDriver", self.simDetectorDriver.reset,
                 block=False),
             SeqFunctionItem(
                 "Reset positionPlugin", self.positionPlugin.reset,
                 block=False),
             SeqTransitionItem(
                 "Wait for plugins to reset", plugins,
                 DState.Idle, DState.rest())
         ]
     # Add the config stages
     seq_items += [
         SeqFunctionItem(
             "Configuring positionPlugin", self._configure_positionPlugin),
         SeqFunctionItem(
             "Configuring simDetectorDriver", self._configure_simDetectorDriver),
         SeqTransitionItem(
             "Wait for plugins to configure", plugins,
             DState.Ready, DState.rest()),
     ]
     # Add a configuring object
     self._spause = Sequence(self.name + ".SPause", *seq_items)
     if self.state == DState.Ready:
         self._post_rewind_state = DState.Ready
     else:
         self._post_rewind_state = DState.Paused
     if steps is not None:
         self.currentStep -= steps
     # Start the sequence
     item_done, msg = self._spause.start()
     if item_done:
         # Arrange for a callback to process the next item
         self.post_changes(None, None)
     return DState.Rewinding, msg
Ejemplo n.º 2
0
 def do_abort(self):
     """Stop acquisition
     """
     if self.state == DState.Configuring:
         self._sconfig.abort()
     elif self.state == DState.Running:
         self._srun.abort()
     elif self.state == DState.Rewinding:
         self._spause.abort()
     for d in self.children:
         if d.state in DState.canAbort():
             d.abort(block=False)
     self.post_changes(None, None)
     return DState.Aborting, "Aborting started"
Ejemplo n.º 3
0
 def do_rewind(self, steps=None):
     """Start a pause"""
     # make some sequences for config
     assert self.progScan.state in DState.canAbort(), \
         "progScan in state {} is not abortable"\
         .format(self.progScan.state)
     seq_items = []
     need_prog_abort = self.progScan.state not in DState.canConfig()
     need_det_pause = self.det1.state == DState.Running
     if not need_det_pause:
         assert self.det1.state in DState.canRewind(), \
             "SimDetector state {} isn't paused and can't rewind" \
             .format(self.det1.state)
     if self.state == DState.Ready:
         self._post_rewind_state = DState.Ready
     else:
         self._post_rewind_state = DState.Paused
     # if we need to abort progScan
     if need_prog_abort:
         seq_items.append(
             SeqFunctionItem(
                 "Stopping progScan", self.progScan.abort,
                 block=False))
     # either pause or resume det1
     if need_det_pause:
         seq_items += [
             SeqFunctionItem(
                 "Pausing det1", self.det1.pause,
                 block=False),
             SeqFunctionItem(
                 "Pausing det2", self.det2.pause,
                 block=False)
         ]
     else:
         seq_items += [
             SeqFunctionItem(
                 "Rewinding det1", self.det1.rewind,
                 steps=steps, block=False),
             SeqFunctionItem(
                 "Rewinding det2", self.det2.rewind,
                 steps=steps, block=False)
         ]
     # wait for progScan to stop
     if need_prog_abort:
         seq_items += [
             SeqTransitionItem(
                 "Wait for progScan to stop", self.progScan.stateMachine,
                 DState.Aborted, DState.rest()),
             SeqFunctionItem(
                 "Reset progScan", self.progScan.reset,
                 block=False),
             SeqTransitionItem(
                 "Wait for progScan to reset", self.progScan.stateMachine,
                 DState.Idle, DState.rest())
         ]
     # Add the config stages
     seq_items += [
         SeqTransitionItem(
             "Wait for det1 to rewind", self.det1.stateMachine,
             self._post_rewind_state, DState.doneRewind()),
         SeqTransitionItem(
             "Wait for det2 to rewind", self.det2.stateMachine,
             self._post_rewind_state, DState.doneRewind()),
         SeqFunctionItem(
             "Configuring progScan", self._configure_progScan),
         SeqTransitionItem(
             "Wait for progScan to configure", self.progScan.stateMachine,
             DState.Ready, DState.rest()),
     ]
     # Add a configuring object
     self._spause = Sequence(self.name + ".SPause", *seq_items)
     if steps is not None:
         self.currentStep -= steps
     # Start the sequence
     item_done, msg = self._spause.start()
     if item_done:
         # Arrange for a callback to process the next item
         self.post_changes(None, None)
     return DState.Rewinding, msg