load-controller/main.py

37 lines
911 B
Python
Raw Normal View History

2023-01-03 22:57:18 +01:00
#!/usr/bin/env python3
import os
import sys
2023-01-04 16:53:42 +01:00
from PySide6.QtCore import QThread
from PySide6.QtWidgets import QApplication
2023-01-03 22:57:18 +01:00
from load_controller.gui import GUI
2023-01-04 00:22:27 +01:00
from load_controller.load import Load
from load_controller.profile_handler import ProfileHandler
from load_controller.temperatures import Temperatures
2023-01-03 22:57:18 +01:00
def main(argv: list[str]) -> int:
app = QApplication(sys.argv)
2023-01-04 00:22:27 +01:00
profile_handler = ProfileHandler()
2023-01-03 22:57:18 +01:00
2023-01-04 00:22:27 +01:00
load = Load(argv[1], profile_handler)
temps = Temperatures(argv[2])
temp_thread = QThread()
temps.moveToThread(temp_thread)
temp_thread.started.connect(temps.run)
temp_thread.start()
gui = GUI(profile_handler, temps.temperaturesUpdated)
2023-01-04 00:22:27 +01:00
2023-01-03 22:57:18 +01:00
return app.exec()
if __name__ == "__main__":
if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} LOAD-PORT TEMP-PORT BMS-PORT", file=sys.stderr)
2023-01-03 22:57:18 +01:00
sys.exit(os.EX_USAGE)
sys.exit(main(sys.argv))