This commit is contained in:
germano laptop 2023-03-13 18:38:30 +01:00
parent d5cd7c4501
commit 609e432e8d
8 changed files with 34 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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))))

View File

@ -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:

View File

@ -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()

View File

@ -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)