from sensors.acusticSensor import AcusticSensor
from sensors.calibration import CalibrationStateMashine
from gui.mainWindow import MainWindow

import queue
import configparser
import tkinter as tk
import traceback

conf = configparser.ConfigParser()
conf.read('config.ini')

def main():
  ac_queue = queue.Queue()
  ac_calibration_state = CalibrationStateMashine()
  ac_sensor = AcusticSensor(conf, ac_queue, ac_calibration_state)

  try:
    ac_sensor.start()
    root = tk.Tk()
    root.title("Tracking System")
    root.attributes('-fullscreen', True)
    view = MainWindow(root, ac_sensor, ac_queue, ac_calibration_state)
    view.pack(side="top", fill="both", expand=True)
    view.update()
    root.mainloop()

  except KeyboardInterrupt:
    print("stop")
  except Exception as e:
    print("Error: ",e)
    traceback.print_exc()
  finally:
    ac_sensor.stop()

main()



