def loop(r, i): data = i.split('|') sensors = defaultNonedict() for d in data: k, v = d.split(':') if ';' in v: # Some sensors send multiple values, separated by semicolon v = v.split(';') vconv = [] for vv in v: try: vvconv = int(vv) except: vvconv = vv vconv.append(vvconv) else: try: vconv = int(v) except: vconv = v sensors[k] = vconv timeout = conf.tick_timeout user_thread = Thread(target=get_response, args=(r, sensors)) response = None user_thread.start() user_thread.join(timeout) if user_thread.isAlive(): global _overtime_count _overtime_count += 1 response = 'TIMEOUT' if _overtime_count > 10: os.kill(os.getpid(), 9) else: _overtime_count = 0 rresponse = r.response if rresponse == 'LOG': start_logging(r) elif rresponse == 'NOLOG': stop_logging(r) return response or rresponse
def __init__(self, name): self.name = name self._overtime_count = 0 self.sensors = defaultNonedict() self._steps = [] self._err = False self._finished = False self.force(0) self.torque(0) self._fire = '_' self._ping = 0 self._turretangle = 0 self.logfile = None
def __init__(self, name): self._p__name = name self._p__overtime_count = 0 self.sensors = defaultNonedict() self._p__steps = [] self._p__err = False self._p__finished = False self.force(0) self.torque(0) self._p__fire = '_' self._p__ping = 0 self._p__turret_speed = 0 self._p__logfile = None self._p__log = None