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