Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
494dd3dc91
|
|
@ -1,13 +1,15 @@
|
|||
[galaxy_camera]
|
||||
exposure time: 10000
|
||||
horizontal crop offset: 0
|
||||
horizontal crop resolution: 2448
|
||||
vertical crop offset: 724
|
||||
vertical crop resolution: 800
|
||||
rotate 90 clockwise times: 0
|
||||
balance red: 1.0
|
||||
balance green: 1.0
|
||||
balance blue: 1.0
|
||||
horizontal_resolution: 2448
|
||||
vertical_resolution: 2048
|
||||
exposure_time: 10000
|
||||
; horizontal_crop_offset: 0
|
||||
; horizontal_crop_resolution: 2448
|
||||
; vertical_crop_offset: 0
|
||||
; vertical_crop_resolution: 2048
|
||||
; rotate_90_clockwise times: 0
|
||||
; balance_red: 1.0
|
||||
; balance_green: 1.0
|
||||
; balance_blue: 1.0
|
||||
|
||||
[vision_saver]
|
||||
time_format: %Y-%m-%d_%H-%M-%S
|
||||
|
|
@ -31,6 +33,10 @@ printer:
|
|||
address: COM3
|
||||
baudrate: 115200
|
||||
|
||||
[neo_pixels]
|
||||
address: COM1
|
||||
baudrate: 9600
|
||||
|
||||
[vision]
|
||||
detection_threshold: 0.3
|
||||
; recipes_path: ./config/vision_test_recipes
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ python -B -u "./src/main.py" \
|
|||
--sim-camera \
|
||||
--sim-modbus \
|
||||
--sim-os-label-printer \
|
||||
--sim-serial-neo-pixels \
|
||||
--style windows \
|
||||
$* 2> >(sed $'s/.*/\e[31m&\e[m/' >&2) # &
|
||||
# --about \
|
||||
|
|
@ -27,6 +28,8 @@ $* 2> >(sed $'s/.*/\e[31m&\e[m/' >&2) # &
|
|||
# --auto-login-user \
|
||||
# --autotests-archive \
|
||||
# --camera-edits \
|
||||
# --interact \
|
||||
# --no-gui \
|
||||
# --no-tflite \
|
||||
# --sim-archiver \
|
||||
# --sim-serial-label-printer \
|
||||
|
|
|
|||
|
|
@ -14,5 +14,12 @@ class Serial:
|
|||
self.log.debug(f"read: {d!r}")
|
||||
return d
|
||||
|
||||
def readline(self, n=-1):
|
||||
if n < 0:
|
||||
n = 8
|
||||
d = b"\x00" * n
|
||||
self.log.debug(f"readline: {d!r}")
|
||||
return d
|
||||
|
||||
def close(self):
|
||||
self.log.debug("close")
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import serial
|
||||
|
||||
from .serial import Serial
|
||||
from .Serial import Serial
|
||||
|
||||
serial.Serial = Serial
|
||||
|
|
|
|||
|
|
@ -30,19 +30,23 @@ class GalaxyCamera(Component):
|
|||
|
||||
def config_changed(self):
|
||||
self._period = int(self.config[self.name].get("frame time ms", 300)) / 1000
|
||||
self.exposure_time = int(self.config[self.name]["exposure time"])
|
||||
self.resolution = {
|
||||
"w": int(self.round_4(self.config[self.name]["horizontal_resolution"])),
|
||||
"h": int(self.round_4(self.config[self.name]["vertical_resolution"])),
|
||||
}
|
||||
self.exposure_time = int(self.config[self.name]["exposure_time"])
|
||||
self.roi = {
|
||||
"x": int(self.round_4(self.config[self.name]["horizontal crop offset"])),
|
||||
"w": int(self.round_4(self.config[self.name]["horizontal crop resolution"])),
|
||||
"y": int(self.round_4(self.config[self.name]["vertical crop offset"])),
|
||||
"h": int(self.round_4(self.config[self.name]["vertical crop resolution"])),
|
||||
"r": int(self.config[self.name]["rotate 90 clockwise times"]),
|
||||
"x": int(self.round_4(self.config[self.name].get("horizontal_crop_offset", 0))),
|
||||
"w": int(self.round_4(self.config[self.name].get("horizontal_crop_resolution", self.resolution["w"]))),
|
||||
"y": int(self.round_4(self.config[self.name].get("vertical_crop_offset", 0))),
|
||||
"h": int(self.round_4(self.config[self.name].get("vertical_crop_resolution", self.resolution["h"]))),
|
||||
"r": int(self.config[self.name].get("rotate_90_clockwise_times", 0)),
|
||||
}
|
||||
self.auto_white_balance = bool(self.config[self.name].get("auto white balance", False))
|
||||
self.balance = {
|
||||
"r": float(self.config[self.name].get("balance red", 1)),
|
||||
"g": float(self.config[self.name].get("balance green", 1)),
|
||||
"b": float(self.config[self.name].get("balance blue", 1)),
|
||||
"r": float(self.config[self.name].get("balance_red", 1)),
|
||||
"g": float(self.config[self.name].get("balance_green", 1)),
|
||||
"b": float(self.config[self.name].get("balance_blue", 1)),
|
||||
}
|
||||
self.lock.lock()
|
||||
self.camera.stream_off()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import traceback
|
||||
|
||||
if "--sim-serial-neo-pixels" in sys.argv:
|
||||
import components.dummies.serial as serial
|
||||
from components.dummies.serial import serial
|
||||
else:
|
||||
import serial
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import sys
|
||||
|
||||
if "--sim-serial-label-printer" in sys.argv:
|
||||
import components.dummies.serial as serial
|
||||
from components.dummies.serial import serial
|
||||
else:
|
||||
import serial
|
||||
|
||||
|
|
|
|||
79
src/main.py
79
src/main.py
|
|
@ -10,8 +10,8 @@ from datetime import datetime
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
def quit_app(signalnum, handler):
|
||||
print(signalnum, handler)
|
||||
def quit_app(signalnum=None, handler=None):
|
||||
logging.info(f"quitting app. signal: {signalnum!r}, handler: {handler!r}")
|
||||
global app
|
||||
app.quit()
|
||||
quit()
|
||||
|
|
@ -46,7 +46,7 @@ logging.basicConfig(
|
|||
|
||||
try:
|
||||
# IMPORT PROJECT ONLY AFTER SETTING UP SIGNAL, FAULTHANDLER AND LOGGHING
|
||||
from components import (ArchiveSynchronizer, GalaxyCamera,
|
||||
from components import (ArchiveSynchronizer, GalaxyCamera, NeoPixels,
|
||||
Os_Label_Printer, RemoteAPI,
|
||||
TecnaMarpossProvasetT3, TestComponent, Vision,
|
||||
VisionSaver)
|
||||
|
|
@ -76,6 +76,7 @@ try:
|
|||
"archive_synchronizer": {"c": ArchiveSynchronizer},
|
||||
"galaxy_camera": {"c": GalaxyCamera, "k": {"paused": True}},
|
||||
"label_printer": {"c": Os_Label_Printer, "t": False},
|
||||
"neo_pixels": {"c": NeoPixels, "t": False},
|
||||
"remote_api": {"c": RemoteAPI, "k": {"main": self}},
|
||||
"tecna_marposs_provaset_t3": {"c": TecnaMarpossProvasetT3},
|
||||
"vision_saver": {"c": VisionSaver, "t": False},
|
||||
|
|
@ -102,35 +103,38 @@ try:
|
|||
QMessageBox.critical(None, "Errore Banco", f"Non e stato possibile connettersi al banco:\n\n{e}")
|
||||
quit()
|
||||
# connect camera frames to vision
|
||||
self.components["vision"].set_sources({"galaxy_camera": self.components["galaxy_camera"].out})
|
||||
if "vision" in self.components and "galaxy_camera" in self.components:
|
||||
self.components["vision"].set_sources({"galaxy_camera": self.components["galaxy_camera"].out})
|
||||
# GUI INIT
|
||||
# self.main_window = Main_Window(self.bench)
|
||||
self.main_window = Main_Window()
|
||||
# CONNECT MAIN WINDOW ACTIONS
|
||||
self.main_window.archive_a.triggered.connect(self.open_archive)
|
||||
if "--archive" in sys.argv:
|
||||
self.main_window.archive_a.trigger()
|
||||
self.main_window.autotests_archive_a.triggered.connect(self.open_autotests_archive)
|
||||
if "--autotests-archive" in sys.argv:
|
||||
self.main_window.autotests_archive_a.trigger()
|
||||
self.main_window.about_a.triggered.connect(self.open_about)
|
||||
if "--about" in sys.argv:
|
||||
self.main_window.about_a.trigger()
|
||||
self.main_window.admin_m.menuAction().setVisible(False) # admin menu should not be visible before an admin logs in
|
||||
self.main_window.users_management_a.triggered.connect(self.open_users_management)
|
||||
if "--users-management" in sys.argv:
|
||||
self.main_window.users_management_a.trigger()
|
||||
# OPEN LOGIN TAB
|
||||
self.open_login()
|
||||
# SHOW MAIN WINDOW
|
||||
if "--panel" in sys.argv:
|
||||
self.main_window.show()
|
||||
elif "--maximized" in sys.argv:
|
||||
self.main_window.showMaximized()
|
||||
elif "--full-screen" in sys.argv:
|
||||
self.main_window.showFullScreen()
|
||||
else:
|
||||
self.main_window.showFullScreen()
|
||||
if "--no-gui" not in sys.argv:
|
||||
# self.main_window = Main_Window(self.bench)
|
||||
self.main_window = Main_Window()
|
||||
# CONNECT MAIN WINDOW ACTIONS
|
||||
self.main_window.archive_a.triggered.connect(self.open_archive)
|
||||
if "--archive" in sys.argv:
|
||||
self.main_window.archive_a.trigger()
|
||||
self.main_window.autotests_archive_a.triggered.connect(self.open_autotests_archive)
|
||||
if "--autotests-archive" in sys.argv:
|
||||
self.main_window.autotests_archive_a.trigger()
|
||||
self.main_window.about_a.triggered.connect(self.open_about)
|
||||
if "--about" in sys.argv:
|
||||
self.main_window.about_a.trigger()
|
||||
self.main_window.admin_m.menuAction().setVisible(False) # admin menu should not be visible before an admin logs in
|
||||
self.main_window.quit_a.triggered.connect(quit_app)
|
||||
self.main_window.users_management_a.triggered.connect(self.open_users_management)
|
||||
if "--users-management" in sys.argv:
|
||||
self.main_window.users_management_a.trigger()
|
||||
# OPEN LOGIN TAB
|
||||
self.open_login()
|
||||
# SHOW MAIN WINDOW
|
||||
if "--panel" in sys.argv:
|
||||
self.main_window.show()
|
||||
elif "--maximized" in sys.argv:
|
||||
self.main_window.showMaximized()
|
||||
elif "--full-screen" in sys.argv:
|
||||
self.main_window.showFullScreen()
|
||||
else:
|
||||
self.main_window.showFullScreen()
|
||||
|
||||
def open_archive(self):
|
||||
self.main_window.open_dialog(Archive())
|
||||
|
|
@ -162,10 +166,21 @@ try:
|
|||
def open_test(self):
|
||||
self.main_window.open_tab(Test(self.config.machine_id, self.components))
|
||||
|
||||
def open_test(self):
|
||||
self.main_window.open_tab(Test(self.config.machine_id, self.components))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
main = Main()
|
||||
app.exec()
|
||||
if "--no-gui" not in sys.argv:
|
||||
app.exec()
|
||||
if "--interact" in sys.argv:
|
||||
import code
|
||||
import readline
|
||||
variables = globals().copy()
|
||||
variables.update(locals())
|
||||
shell = code.InteractiveConsole(variables)
|
||||
shell.interact()
|
||||
except Exception:
|
||||
logging.exception(traceback.format_exc())
|
||||
# extype, value, tb = sys.exc_info()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
<string>Amministrazione</string>
|
||||
</property>
|
||||
<addaction name="users_management_a"/>
|
||||
<addaction name="quit_a"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuStrumenti">
|
||||
<property name="title">
|
||||
|
|
@ -63,6 +64,11 @@
|
|||
<string>Archivio autotest</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="quit_a">
|
||||
<property name="text">
|
||||
<string>Esci</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user