Ejemplo n.º 1
0
 def _calculate_element_state(self, elem, elem_state_info):
     u_state, u_status = elem_state_info
     if u_status is None:
         state_str = "None" if u_state is None else State.whatis(u_state)
         u_status = '{} is {}'.format(elem.name, state_str)
     else:
         u_status = u_status.split("\n", 1)[0]
     return u_state, u_status
Ejemplo n.º 2
0
 def _from_ctrl_state_info(self, state_info):
     try:
         state_str = State.whatis(state_info)
         return int(state_info), "{0} is in {1}".format(self.name, state_str)
     except KeyError:
         pass
     state_info, _ = state_info
     state, status = state_info[:2]
     state = int(state)
     return state, status
Ejemplo n.º 3
0
 def _from_ctrl_state_info(self, state_info):
     try:
         state_str = State.whatis(state_info)
         return int(state_info), "{0} is in {1}".format(
             self.name, state_str)
     except KeyError:
         pass
     state_info, _ = state_info
     state, status = state_info[:2]
     state = int(state)
     return state, status
Ejemplo n.º 4
0
 def abort(self, configuration, abort):
     """ Helper for test the abort
     """
     self.configuration = configuration
     self.ctrl.SynchOne(self.AXIS, configuration)
     self.post_configuration_hook()
     # PreStartOne the axis
     self.ctrl.PreStartOne(self.AXIS)
     self.ctrl.StartOne(self.AXIS)
     while self.ctrl.StateOne(self.AXIS)[0] == State.Moving:
         time.sleep(abort)
         self.ctrl.AbortOne(self.AXIS)
     self.isAborted = True
     self.post_generation_hook()
     state, status = self.ctrl.StateOne(self.AXIS)
     msg = ('The axis %d is not Stopped, its status is %s' %
            (self.AXIS, status))
     self.assertEqual(state, State.get('On'), msg)
Ejemplo n.º 5
0
 def abort(self, configuration, abort):
     """ Helper for test the abort
     """
     self.configuration = configuration
     self.ctrl.SynchOne(self.AXIS, configuration)
     self.post_configuration_hook()
     # PreStartOne the axis
     self.ctrl.PreStartOne(self.AXIS)
     self.ctrl.StartOne(self.AXIS)
     while self.ctrl.StateOne(self.AXIS)[0] == State.Moving:
         time.sleep(abort)
         self.ctrl.AbortOne(self.AXIS)
     self.isAborted = True
     self.post_generation_hook()
     state, status = self.ctrl.StateOne(self.AXIS)
     msg = ('The axis %d is not Stopped, its status is %s'
            % (self.AXIS, status))
     self.assertEqual(state, State.get('On'), msg)
Ejemplo n.º 6
0
    def _from_ctrl_state_info(self, state_info):
        state_info, _ = state_info

        try:
            state_str = State.whatis(state_info)
            return int(state_info), "{0} is in {1}".format(self.name, state_str), 0
        except KeyError:
            pass

        if len(state_info) > 2:
            state, status, ls = state_info[:3]
        else:
            state, other = state_info[:2]
            if is_number(other):
                ls, status = other, ''
            else:
                ls, status = 0, other
        state, ls = int(state), tuple(map(bool, (ls & 1, ls & 2, ls & 4)))
        return state, status, ls
Ejemplo n.º 7
0
 def generation(self, configuration):
     """ Helper for test a simple generation
     """
     self.configuration = configuration
     repetitions = 0
     for group in configuration:
         repetitions += group[SynchParam.Repeats]
     # store repeats for the assers against received triggers
     self.repetitions = repetitions
     self.ctrl.SynchOne(self.AXIS, configuration)
     # execute Hook
     self.post_configuration_hook()
     # PreStartOne the axis
     self.ctrl.PreStartOne(self.AXIS)
     self.ctrl.StartOne(self.AXIS)
     while self.ctrl.StateOne(self.AXIS)[0] == State.Moving:
         time.sleep(0.001)
     self.post_generation_hook()
     state, status = self.ctrl.StateOne(self.AXIS)
     msg = ('The axis %d is not Stopped, its status is %s' %
            (self.AXIS, status))
     self.assertEqual(state, State.get('On'), msg)
Ejemplo n.º 8
0
 def generation(self, configuration):
     """ Helper for test a simple generation
     """
     self.configuration = configuration
     repetitions = 0
     for group in configuration:
         repetitions += group[SynchParam.Repeats]
     # store repeats for the assers against received triggers
     self.repetitions = repetitions
     self.ctrl.SynchOne(self.AXIS, configuration)
     # execute Hook
     self.post_configuration_hook()
     # PreStartOne the axis
     self.ctrl.PreStartOne(self.AXIS)
     self.ctrl.StartOne(self.AXIS)
     while self.ctrl.StateOne(self.AXIS)[0] == State.Moving:
         time.sleep(0.001)
     self.post_generation_hook()
     state, status = self.ctrl.StateOne(self.AXIS)
     msg = ('The axis %d is not Stopped, its status is %s'
            % (self.AXIS, status))
     self.assertEqual(state, State.get('On'), msg)