load-controller/main.py

35 lines
798 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 00:22:27 +01:00
from PyQt6.QtCore import QThread
2023-01-03 22:57:18 +01:00
from PyQt6.QtWidgets import QApplication
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
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()
gui = GUI(profile_handler)
2023-01-03 22:57:18 +01:00
gui.show()
2023-01-04 00:22:27 +01:00
load = Load(argv[1], profile_handler)
load_thread = QThread()
load.moveToThread(load_thread)
load_thread.started.connect(load.do_work)
load_thread.start()
2023-01-03 22:57:18 +01:00
return app.exec()
if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} LOAD-PORT BMS-PORT", file=sys.stderr)
sys.exit(os.EX_USAGE)
sys.exit(main(sys.argv))