Esempio n. 1
0
    def initialize_axis(self, axis):
        self._axis_moves[axis] = {
            "end_t": 0,
            "end_pos": self._pos0}

        # "end of move" event
        event.connect(axis, "move_done", self.move_done_event_received)
 def test_state_callback(self):
     old={"state":None}
     def callback(state, old=old): #{}):
         old["state"] = state
     robz = emotion.get_axis("robz")
     event.connect(robz, "state", callback)
     robz.rmove(10, wait=False)
     while old["state"]=="MOVING":
         time.sleep(0)
     self.assertEquals(robz.state(), "READY")
Esempio n. 3
0
 def axis_group_move(self, axes_pos):
     axes = map(get_bliss_obj, axes_pos[::2])
     axes_positions = map(float, axes_pos[1::2])
     axes_pos_dict = dict(zip(axes, axes_positions))
     group = Group(*axes)
     event.connect(group, 'move_done', self.__on_axis_group_move_done)
     group.move(axes_pos_dict, wait=False)
     group_id = ','.join(map(':'.join, grouped(axes_pos, 2)))
     self.group_dict[group_id] = group
     return group_id
Esempio n. 4
0
def test_state_callback(robz):
    ready_event = gevent.event.AsyncResult()
    def callback(state):
      ready_event.set(state == 'READY')

    event.connect(robz, "state", callback)

    robz.rmove(1)

    assert ready_event.get(timeout=0.1)
    assert robz.state() == "READY"
    def test_move_done_event(self):
        res = {"ok": False}

        def callback(move_done, res=res):
            if move_done:
                res["ok"] = True
        robz = emotion.get_axis('robz')
        event.connect(robz, "move_done", callback)
        robz.rmove(10)
        robz.wait_move()
        self.assertEquals(res["ok"], True)
Esempio n. 6
0
def test_move_done_callback(robz):
    ready_event = gevent.event.AsyncResult()
    
    def callback(move_done):
        if move_done:
            ready_event.set(robz.is_moving is False)

    event.connect(robz, "move_done", callback)
   
    robz.rmove(1)

    assert ready_event.get(timeout=0.1)
 def test_position_callback(self):
     storage={"last_pos":None, "last_dial_pos":None}
     def callback(pos,old=storage):
       old["last_pos"]=pos
     def dial_callback(pos,old=storage):
       old["last_dial_pos"]=pos
     robz = emotion.get_axis("robz")
     event.connect(robz, "position", callback)
     event.connect(robz, "dial_position", dial_callback)
     robz.position(1)
     pos = robz.position()
     robz.rmove(1)
     self.assertEquals(storage["last_pos"], pos+1)
     self.assertEquals(storage["last_dial_pos"], robz.user2dial(pos+1))
Esempio n. 8
0
def test_position_callback(robz):
    storage={"last_pos":None, "last_dial_pos":None}
    def callback(pos, old=storage):
        old["last_pos"]=pos
    def dial_callback(pos,old=storage):
        old["last_dial_pos"]=pos

    event.connect(robz, "position", callback)
    event.connect(robz, "dial_position", dial_callback)

    robz.position(1)
    pos = robz.position()
    robz.rmove(1)
    assert storage["last_pos"] == pytest.approx(pos+1)
    assert storage["last_dial_pos"] == pytest.approx(robz.user2dial(pos+1))
 def test_state_callback(self):
     e = gevent.event.AsyncResult()
     old={"state":None}
     def callback(state, old=old): #{}):
         #if old.get("state") == state:
         #    return
         old["state"] = state
         #e.set(state)
     robz = emotion.get_axis("robz")
     event.connect(robz, "state", callback)
     robz.rmove(10, wait=False)
     while old["state"]=="MOVING":
         time.sleep(0)
     robz.state()
     self.assertEqual(robz.state(), "READY")
Esempio n. 10
0
    def initialize_axis(self, axis):
        self._axis_moves[axis] = {"end_t": 0, "end_pos": self._pos0}

        # "end of move" event
        event.connect(axis, "move_done", self.move_done_event_received)