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_config(self, **config_params):
     """Start doing a configuration using config_params.
     Return DState.Configuring, message when started
     """
     for d in self.children:
         assert d.state in DState.canConfig(), \
             "Child device {} in state {} is not configurable"\
             .format(d, d.state)
     # Setup self
     for name, value in config_params.items():
         setattr(self, name, value)
     self.stepsPerRun = 1
     self.currentStep = 0
     # make some sequences for config
     self._sconfig = Sequence(
         self.name + ".SConfig",
         SeqFunctionItem(
             "Configuring dets", self._configure_simDetector),
         SeqFunctionItem(
             "Configuring progScan", self._configure_progScan),
         SeqTransitionItem(
             "Wait for plugins to configure", self.child_statemachines,
             DState.Ready, DState.rest()),
     )
     item_done, msg = self._sconfig.start()
     if item_done:
         # Arrange for a callback to process the next item
         self.post_changes(None, None)
     return DState.Configuring, msg
 def do_configure(self, config_params, task):
     """Start doing a configuration using config_params.
     Return DState.Configuring, message when started
     """
     for d in self.children:
         assert d.state in DState.canConfig(), \
             "Child device {} in state {} is not configurable"\
             .format(d, d.state)
     # Setup self
     for name, value in config_params.items():
         setattr(self, name, value)
     self.stepsPerRun = 1
     self.currentStep = 0
     task.report("Configuring simDetectorDriver")
     self._configure_simDetectorDriver()
     task.report("Configuring positionPlugin")
     self._configure_positionPlugin()
     # Setup config matcher
     self._sconfig = ConfigMatcher(
         SeqTransitionItem(
             self.child_statemachines,
             DState.Ready, DState.rest()))
     name, changes = task.report_wait("Wait for plugins to configure")
     while not self._sconfig.check_done(name, changes):
         name, changes = task.report_wait()
     task.report("Configuring hdf5Writer")
     self._configure_hdf5Writer(self.positionPlugin.dimensions)
     # Finished
     task.report("Configuring done", DState.Ready)
Ejemplo n.º 4
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