diff --git a/config/machine_settings/defaults.ini b/config/machine_settings/defaults.ini index bf05854..23ac1bd 100644 --- a/config/machine_settings/defaults.ini +++ b/config/machine_settings/defaults.ini @@ -87,7 +87,7 @@ baudrate: 9600 id: USB-5862,BID#0 [vision] -neural_network: hs5-20000 +neural_network: none [recipe] recipe_name_field: codice_ricetta diff --git a/config/machine_settings/laptop.ini b/config/machine_settings/laptop.ini index 05750e2..11a0374 100644 --- a/config/machine_settings/laptop.ini +++ b/config/machine_settings/laptop.ini @@ -10,7 +10,7 @@ neo_pixels: absent remote_api: absent tecna_t3: present vision_saver: absent -vision: absent +vision: present screwdriver: absent [tecna_t3] @@ -27,7 +27,7 @@ label_template_field: modello_etichetta horizontal_resolution: 3264 vertical_resolution: 2448 exposure_time: 1000 -focus: 235 -balance_red: 1 +focus: 611 +balance_red: 1.0 balance_green: 1.0 balance_blue: 1.0 diff --git a/src/components/uvc_camera.py b/src/components/uvc_camera.py index 43a1572..bfd2b52 100644 --- a/src/components/uvc_camera.py +++ b/src/components/uvc_camera.py @@ -64,7 +64,7 @@ class UVCCamera(Component): self.camera.set(cv2.CAP_PROP_FPS, 15) self.camera.set(cv2.CAP_PROP_FRAME_WIDTH, self.resolution["w"]) self.camera.set(cv2.CAP_PROP_FRAME_HEIGHT, self.resolution["h"]) - self.camera.set(cv2.CAP_PROP_AUTOFOCUS, 1) + #self.camera.set(cv2.CAP_PROP_AUTOFOCUS, 1) if self.exposure_time is not None: self.camera.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0) self.camera.set(cv2.CAP_PROP_EXPOSURE, self.exposure_time) diff --git a/src/components/vision.py b/src/components/vision.py index 57e6a9a..5f0bc65 100644 --- a/src/components/vision.py +++ b/src/components/vision.py @@ -76,10 +76,9 @@ class Vision(Component): self.vision_consumer.moveToThread(self.vision_consumer_thread) self.vision_consumer_thread.started.connect(self.vision_consumer.start) self.vision_consumer_thread.start() - if "--debugger-workaround" in sys.argv: - QApplication.processEvents() - QThread.msleep(1000) - QApplication.processEvents() + QApplication.processEvents() + QThread.msleep(1000) + QApplication.processEvents() self.vision_consumer.wait_completion() # RENDER THREAD self.render_consumer = Consumer(work=self.render_consumer_work, work_fifo=True, drop_fifo=True, work_maxlen=1, name="render_consumer", paused=False) @@ -88,10 +87,9 @@ class Vision(Component): self.render_consumer.moveToThread(self.render_consumer_thread) self.render_consumer_thread.started.connect(self.render_consumer.start) self.render_consumer_thread.start() - if "--debugger-workaround" in sys.argv: - QApplication.processEvents() - QThread.msleep(1000) - QApplication.processEvents() + QApplication.processEvents() + QThread.msleep(1000) + QApplication.processEvents() self.render_consumer.wait_completion() # CONNECT CONSUMERS self.vision_consumer.out.connect(self.process_vision_consumed) diff --git a/src/lib/helpers/config_reader.py b/src/lib/helpers/config_reader.py index 7e32d76..f248296 100644 --- a/src/lib/helpers/config_reader.py +++ b/src/lib/helpers/config_reader.py @@ -12,6 +12,7 @@ class ConfigReader(QObject): def __init__(self, system_id=None, *args, **kwargs): super().__init__() + self.system_id_param = system_id self.system_id = system_id if system_id is not None else socket.gethostname() self._args, self._kwargs = args, kwargs self.configs_dir = Path(".") / "config" / "machine_settings" @@ -29,6 +30,8 @@ class ConfigReader(QObject): config_paths.append(self.configs_dir / f"{specific_config}.ini") else: self.machine_id = self.system_id + if self.system_id_param is not None: + config_paths.append(self.configs_dir / f"{self.system_id_param}.ini") config_paths += self.extra_paths # remove duplicate paths keeping their order (keeps the last) config_paths = list(reversed(dict.fromkeys(reversed(config_paths)))) diff --git a/src/main.py b/src/main.py index 76995dc..81b0949 100644 --- a/src/main.py +++ b/src/main.py @@ -135,10 +135,10 @@ try: component = self.components[component_name] thread.started.connect(component.start) thread.start() - if "--debugger-workaround" in sys.argv: - QApplication.processEvents() - QThread.msleep(1000) - QApplication.processEvents() + # DEBUGGER WORKAROUND + QApplication.processEvents() + QThread.msleep(1000) + QApplication.processEvents() if component_name == "vision": component.wait_completion(timeout=60) else: diff --git a/src/test/tdb.py b/src/test/tdb.py index 4387a76..0e7816c 100644 --- a/src/test/tdb.py +++ b/src/test/tdb.py @@ -4,6 +4,7 @@ import signal import sys from uuid import uuid4 as uuid +from PyQt5.QtWidgets import QApplication from peewee import AutoField, Model, TextField from playhouse.sqlite_ext import SqliteExtDatabase from PyQt5.QtCore import QObject, QThread, QTimer @@ -82,10 +83,9 @@ for component_name, thread in threads.items(): component = components[component_name] thread.started.connect(component.start) thread.start() - if "--debugger-workaround" in sys.argv: - QApplication.processEvents() - # QThread.msleep(1000) - QApplication.processEvents() + QApplication.processEvents() + # QThread.msleep(1000) + QApplication.processEvents() while True: for data in list(Data.select().order_by(Data.id.desc()))[:1] + [Data()]: data.save() diff --git a/src/test/uvc_camera/test_uvc_camera.py b/src/test/uvc_camera/test_uvc_camera.py index e33aa85..7f4ab8b 100644 --- a/src/test/uvc_camera/test_uvc_camera.py +++ b/src/test/uvc_camera/test_uvc_camera.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import argparse import faulthandler import logging import os @@ -15,6 +16,10 @@ from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QMainWindow from src.components import Vision +parser = argparse.ArgumentParser(prog='ST-TEN', description='Leak test system') +parser.add_argument('-s', '--system-id') +args,unspec = parser.parse_known_args() + # SETUP FAULTHANDLER faulthandler.enable(file=sys.stderr, all_threads=True) @@ -61,7 +66,7 @@ class Main_Window(QMainWindow): try: # IMPORT PROJECT ONLY AFTER SETTING UP SIGNAL, FAULTHANDLER AND LOGGHING - from components import (NeoPixels, UVCCamera, VisionSaver) + from components import (GalaxyCamera, NeoPixels, UVCCamera, VisionSaver) from lib.db import Users from lib.helpers import ConfigReader from PyQt5.QtCore import QObject, QThread, pyqtSignal @@ -76,7 +81,9 @@ try: self.frame = None try: # READ CONFIG - self.config = ConfigReader() + system_id = args.system_id if "system_id" in args else None + + self.config = ConfigReader(system_id=system_id) # INIT COMPONENT self.components_specs = { "uvc_camera": {"c": UVCCamera, "k": {"paused": False}}, @@ -96,10 +103,9 @@ try: component = self.components[component_name] thread.started.connect(component.start) thread.start() - if "--debugger-workaround" in sys.argv: - QApplication.processEvents() - QThread.msleep(1000) - QApplication.processEvents() + QApplication.processEvents() + QThread.msleep(1000) + QApplication.processEvents() component.wait_completion(timeout=60)