main.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python3
  2. from sensors.acousticSensor import AcousticSensor
  3. from sensors.opticalSensor import OpticalSensor
  4. from sensors.magneticSensor import MagneticSensor
  5. from gui.mainWindow import MainWindow
  6. import configparser
  7. import tkinter as tk
  8. import traceback
  9. import logHandler
  10. conf = configparser.ConfigParser()
  11. conf.read('config.ini')
  12. print(conf.sections())
  13. def main():
  14. log_handler = logHandler.get_log_handler(int(conf['gui']['log_lines']))
  15. ac_sensor = AcousticSensor(conf)
  16. opt_sensor = OpticalSensor(conf)
  17. mag_sensor = MagneticSensor(conf)
  18. try:
  19. ac_sensor.start()
  20. opt_sensor.start()
  21. mag_sensor.start()
  22. root = tk.Tk()
  23. root.title("Tracking System")
  24. root.attributes('-fullscreen', conf['gui']['fullscreen'] == "yes")
  25. view = MainWindow(root, conf, ac_sensor, opt_sensor, mag_sensor)
  26. view.pack(side="top", fill="both", expand=True)
  27. view.update()
  28. root.mainloop()
  29. except KeyboardInterrupt:
  30. print("stop")
  31. except Exception as e:
  32. print("Error: ",e)
  33. traceback.print_exc()
  34. finally:
  35. ac_sensor.stop()
  36. opt_sensor.stop()
  37. mag_sensor.stop()
  38. main()