class EV3RotaterRedisDaemon(EV3Rotater): def __init__(self, redis_conn): EV3Rotater.__init__(self) self._redis = redis_conn self._redis_notifier_state = RedisNotifier( self._redis, 'hics:rotater:state', (self, '_redis_rotater_state')) self._redis_notifier_state.notification_interval = 0.1 self._redis_link = RedisLink(self._redis, 'hics:rotater', self) def _redis_rotater_state(self): moving, position = self.moving, self.position if moving: moving = '1' else: moving = '0' return '{0}:{1}'.format(moving, position) def __del__(self): self.stop() def stop(self, dummy=None): self._redis_link.stop() self._redis_notifier_state.stop() @property def notification_interval(self): return self._redis_notifier_state.notification_interval @notification_interval.setter def notification_interval(self, new_value): self._redis_notifier_state.notification_interval = float(new_value)
def __init__(self, redis_conn, port): Scanner.__init__(self, port) self._redis = redis_conn self._redis_notifier_state = RedisNotifier(self._redis, 'hics:scanner:state', (self, '_redis_scanner_state')) self._redis_notifier_state.notification_interval = 0.1 self._redis_link = RedisLink(self._redis, 'hics:scanner', self)
def __init__(self, redis_conn): EV3Focus.__init__(self) self._redis = redis_conn self._redis_notifier_state = RedisNotifier(self._redis, 'hics:focus:state', (self, '_redis_focus_state')) self._redis_notifier_state.notification_interval = 0.1 self._redis_link = RedisLink(self._redis, 'hics:focus', self)
def run(self): self._framegrabber.start() redis_link_camera = RedisLink(self._redis, 'hics:camera', self._camera) redis_link_scanner = RedisLink(self._redis, 'hics:scanner', self._scanner) redis_notifier_scanner = RedisNotifier(self._redis, 'hics:scanner:state', (self._scanner, '_state')) redis_notifier_scanner.notification_interval = 0.1 redis_link_focus = RedisLink(self._redis, 'hics:focus', self._focus) redis_notifier_focus = RedisNotifier(self._redis, 'hics:focus:state', (self._focus, '_state')) redis_notifier_focus.notification_interval = 0.1 ts = time.time() while self.running: time.sleep(0.01) dt = time.time() - ts self._scanner._update_state(dt) self._focus._update_state(dt) ts += dt redis_link_focus.stop() redis_notifier_focus.stop() redis_link_camera.stop() redis_link_scanner.stop() redis_notifier_scanner.stop()
def __init__(self, redis_conn): EV3Rotater.__init__(self) self._redis = redis_conn self._redis_notifier_state = RedisNotifier( self._redis, 'hics:rotater:state', (self, '_redis_rotater_state')) self._redis_notifier_state.notification_interval = 0.1 self._redis_link = RedisLink(self._redis, 'hics:rotater', self)