import queue import time import threading from sensors.calibration import CalibrationStateMashine from sensors.connection import globalArduinoSlave import logHandler conn = globalArduinoSlave() class MagneticSensor: def __init__(self, conf): self.conf = conf self.queue = queue.Queue() self.calibration_state = CalibrationStateMashine() self.log_handler = logHandler.get_log_handler() # neu self.field_height = float(conf["field"]["y"]) self.field_width = float(conf["field"]["x"]) self.n = 0 #pass def start(self): self.log_handler.log_and_print("start acoustic sensor") if not conn.isConnected(): conn.open() conn.addRecvCallback(self._readCb) self.dummyActive = True dummyThread = threading.Thread(target=self._readCb_dummy) def _readCb(self, raw): print("mag: ", conn.getMagneticField()) def _readCb_dummy(self): pass def calibrate(self, x, y): pass def read(self): return conn.getMagneticField() def stop(self): # neu self.log_handler.log_and_print("stop magnetic sensor") conn.close