autotest window fix
This commit is contained in:
parent
ce525e99e5
commit
79d99bd718
@ -12,7 +12,7 @@ vision_saver: absent
|
||||
vision: absent
|
||||
screwdriver: absent
|
||||
digital_io: present
|
||||
second_leak_test: absent
|
||||
barcode_recipe_selection: present
|
||||
fixture_id: present
|
||||
discard_box: present
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ from .tecna_marposs_provaset_t3 import TecnaMarpossProvasetT3
|
||||
from .tecna_screwdriver import TecnaScrewdriver
|
||||
from .test_component import TestComponent
|
||||
from .usb_586x import USB_586x
|
||||
from .rfid_pn532 import RFID_PN532
|
||||
if "--vision" in sys.argv:
|
||||
from .galaxy_camera import GalaxyCamera
|
||||
from .neo_pixels import NeoPixels
|
||||
|
||||
@ -85,6 +85,7 @@ class Component(QObject):
|
||||
"""
|
||||
super().__init__()
|
||||
self.config = config
|
||||
self.log=logging.getLogger(f"{self.__class__.__name__}")
|
||||
self.name = name if name is not None else str(id(self))
|
||||
self._threaded = threaded
|
||||
self._period = period
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
import ctypes
|
||||
import sys
|
||||
import platform
|
||||
from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
|
||||
from .component import Component
|
||||
import nfc
|
||||
from nfc.clf import RemoteTarget
|
||||
|
||||
|
||||
|
||||
is_win = platform.system() == "Windows"
|
||||
|
||||
class RFID(Component):
|
||||
def __init__(self, config=None, name=None, period=1, lazy=True, paused=False, threaded=True):
|
||||
super().__init__(config=config, name=name, period=period, lazy=lazy, paused=paused, threaded=threaded)
|
||||
self.mutex = QMutex()
|
||||
self.simulate="--sim-rfid" in sys.argv
|
||||
self.clf = nfc.ContactlessFrontend()
|
||||
|
||||
def open_device(self):
|
||||
self.clf.open('tty:USB0:pn532')
|
||||
|
||||
def close_device(self):
|
||||
pass
|
||||
|
||||
@pyqtSlot()
|
||||
def start(self):
|
||||
# ACQUISITION TIMER
|
||||
self.timer = QTimer()
|
||||
self.timer.setTimerType(Qt.PreciseTimer)
|
||||
self.timer.setInterval(int(1000 / 20))
|
||||
self.timer.timeout.connect(self.get)
|
||||
self.timer.start()
|
||||
super().start()
|
||||
|
||||
@pyqtSlot()
|
||||
def get(self):
|
||||
data=None
|
||||
if data is not None:
|
||||
super()._get([data])
|
||||
|
||||
|
||||
67
src/components/rfid_pn532.py
Normal file
67
src/components/rfid_pn532.py
Normal file
@ -0,0 +1,67 @@
|
||||
import ctypes
|
||||
import sys
|
||||
import platform
|
||||
from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
|
||||
from .component import Component
|
||||
import nfc
|
||||
from nfc.clf import RemoteTarget
|
||||
|
||||
|
||||
|
||||
|
||||
class RFID_PN532(Component):
|
||||
new_id_signal = pyqtSignal()
|
||||
def __init__(self, config=None, name=None, period=1, lazy=True, paused=False, threaded=True):
|
||||
super().__init__(config=config, name=name, period=period, lazy=lazy, paused=paused, threaded=threaded)
|
||||
self.mutex = QMutex()
|
||||
self.simulate="--sim-rfid" in sys.argv
|
||||
self.clf = None
|
||||
self.connected=False
|
||||
self.tag_present=False
|
||||
self.current_data=None
|
||||
self.is_win = platform.system() == "Windows"
|
||||
self.dev_list = ["tty:USB0:pn532","tty:USB1:pn532"] if self.is_win else [f"{self.config['fixture_rfid']['port']}:pn532"]
|
||||
|
||||
def open_device(self):
|
||||
clf = nfc.ContactlessFrontend()
|
||||
for dev in self.dev_list:
|
||||
connected = clf.open(dev)
|
||||
if connected:
|
||||
self.log.info(f"CONNECTED TO {dev}")
|
||||
break
|
||||
else:
|
||||
self.log.info(f"UNABLE TO CONNECT TO {dev}")
|
||||
|
||||
def close_device(self):
|
||||
self.clf.close()
|
||||
|
||||
@pyqtSlot()
|
||||
def start(self):
|
||||
super().start()
|
||||
|
||||
@pyqtSlot()
|
||||
def get(self):
|
||||
try:
|
||||
if not self.connected:
|
||||
self.open_device()
|
||||
else:
|
||||
target = self.clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
|
||||
if target is not None:
|
||||
tag = nfc.tag.activate(self.clf, target)
|
||||
if tag is not None:
|
||||
self.log.debug("tag present")
|
||||
if tag.ndef is not None:
|
||||
tag_content=tag.ndef.records[0]
|
||||
if tag_content!=self.current_data:
|
||||
self.log.info(f"new tag detected:{tag_content}")
|
||||
self.current_data=tag_content
|
||||
self.new_id_signal.emit(self.current_data)
|
||||
else:
|
||||
self.log.error("tag is not NDEF")
|
||||
else:
|
||||
self.log.debug("no target present")
|
||||
|
||||
except Exception as e:
|
||||
self.log.exception(f"{e}")
|
||||
self.connected = False
|
||||
|
||||
@ -11,6 +11,7 @@ import weakref
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
if platform.system().lower() == "windows":
|
||||
sys.path.append(f"{os.getcwd()}\src\components")
|
||||
else:
|
||||
@ -63,7 +64,7 @@ try:
|
||||
# IMPORT PROJECT ONLY AFTER SETTING UP SIGNAL, FAULTHANDLER AND LOGGHING
|
||||
from components import (ArchiveSynchronizer, Multicomp730424,
|
||||
Os_Label_Printer, RemoteAPI,
|
||||
TecnaMarpossProvasetT3, TecnaScrewdriver, USB_586x)
|
||||
TecnaMarpossProvasetT3, TecnaScrewdriver, USB_586x,RFID_PN532)
|
||||
from lib.db import Users
|
||||
from lib.helpers import ConfigReader
|
||||
from PyQt5.QtCore import QObject, QThread, pyqtSignal
|
||||
@ -101,7 +102,8 @@ try:
|
||||
"remote_api": {"c": RemoteAPI, "k": {"main": self}},
|
||||
"screwdriver": {"c": TecnaScrewdriver, "k": {"paused": True}},
|
||||
"tecna_t3": {"c": TecnaMarpossProvasetT3, "k": {"paused": True}},
|
||||
"digital_io":{"c":USB_586x,"k":{"paused":True}}
|
||||
"digital_io":{"c":USB_586x,"k":{"paused":True}},
|
||||
"fixture_id":{"c":RFID_PN532,"k":{"paused":False}},
|
||||
}
|
||||
# VISION COMPONENT IS OPTIONAL AND DISABLED BY DEFAULT
|
||||
if "--vision" in sys.argv:
|
||||
@ -146,15 +148,18 @@ try:
|
||||
logging.exception(traceback.format_exc())
|
||||
QMessageBox.critical(None, "Errore", f"Errore di avvio del programma di collaudo:\n\n{e}")
|
||||
quit()
|
||||
|
||||
# connect camera frames to vision
|
||||
if "vision" in self.components and "uvc_camera" in self.components:
|
||||
self.components["vision"].set_sources({"uvc_camera": self.components["uvc_camera"].out})
|
||||
elif "vision" in self.components and "galaxy_camera" in self.components:
|
||||
self.components["vision"].set_sources({"galaxy_camera": self.components["galaxy_camera"].out})
|
||||
|
||||
# connect tecna to screwdriver
|
||||
if "screwdriver" in self.components and "tecna_t3" in self.components:
|
||||
self.components["tecna_t3"].set_requestors({"screwdriver": self.components["screwdriver"].request})
|
||||
self.components["screwdriver"].set_sources({"tecna_t3": self.components["tecna_t3"].out})
|
||||
|
||||
# GUI INIT
|
||||
if "--no-gui" not in sys.argv:
|
||||
# self.main_window = Main_Window(self.bench)
|
||||
|
||||
@ -3,12 +3,19 @@ import ndef
|
||||
import nfc
|
||||
from nfc.clf import RemoteTarget
|
||||
|
||||
clf = nfc.ContactlessFrontend()
|
||||
connected=False
|
||||
while True:
|
||||
try:
|
||||
if not connected:
|
||||
clf = nfc.ContactlessFrontend()
|
||||
connected=clf.open('tty:USB0:pn532')
|
||||
if connected:
|
||||
print("CONNECTED TO TTYUSB0")
|
||||
else:
|
||||
connected = clf.open('tty:USB1:pn532')
|
||||
if connected:
|
||||
print("CONNECTED TO TTYUSB1")
|
||||
|
||||
if connected:
|
||||
target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
|
||||
if target is not None:
|
||||
@ -37,6 +44,8 @@ while True:
|
||||
print("ERROR NOT NDEF")
|
||||
else:
|
||||
print("NO TARGET")
|
||||
else:
|
||||
print("NOT CONNECTED")
|
||||
except Exception as e:
|
||||
print(f"EXCEPTION {e}")
|
||||
connected=False
|
||||
|
||||
@ -76,7 +76,7 @@ class RFID(Widget):
|
||||
self.rfid_input_l.setFocus()
|
||||
self.rfid_input_l.setPlainText("")
|
||||
self.rfid_input_l.setPalette(self.status_palettes[""])
|
||||
self.instruction_text("SCANSIONARE BARCODE SELEZIONE RICETTA")
|
||||
self.instruction_text("INSERIRE IL CONNETTORE DI COLLEGAMENTO DIMA PER SELEZIONARE AUTOMATICAMENTE LA RICETTA DI COLLAUDO")
|
||||
|
||||
def instruction_text(self,text,color=None):
|
||||
if getattr(self.parent.centralWidget, "set_text"):
|
||||
|
||||
@ -8,7 +8,7 @@ from datetime import datetime
|
||||
from lib.db import Archive, Steps, Users
|
||||
from lib.helpers import get_shift
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
from PyQt5.QtCore import QTimer
|
||||
from PyQt5.QtCore import QTimer, pyqtSlot
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from ui.helpers import replace_widget
|
||||
from ui.recipe_selection import Recipe_Selection
|
||||
@ -644,3 +644,8 @@ class Test(Widget):
|
||||
labels = printer_fields["extra_label"].split(",")
|
||||
for label in labels:
|
||||
self.components["extra_label_printer"].print_label(f"{label}.prn", context=None)
|
||||
|
||||
@pyqtSlot()
|
||||
def load_recipe_from_rfid(self,data):
|
||||
if self.step.type == "barcode_recipe_selection":
|
||||
self.cycle_available_steps["barcode_recipe_selection"].get(data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user