Merge remote-tracking branch 'origin/master'

This commit is contained in:
Utente 2023-07-13 16:07:46 +02:00
commit f713c95af5
9 changed files with 115 additions and 84 deletions

View File

@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QMessageBox
from .component import Component
if platform.system() == "Windows":
if platform.system().lower() == "windows":
import win32print
@ -43,7 +43,7 @@ class Os_Label_Printer(Component):
for key, val in context.items():
key = "{" + key + "}"
label_file_contents = label_file_contents.replace(key, val)
if platform.system() == "Windows":
if platform.system().lower() == "windows":
try:
printer = win32print.OpenPrinter(self.printer)
job = win32print.StartDocPrinter(printer, 1, ("label", None, "RAW"))

View File

@ -1,3 +1,4 @@
import copy
import ctypes
import sys
import platform
@ -14,13 +15,14 @@ class RFID_PN532(Component):
new_id_signal = pyqtSignal(str)
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.data_to_write = None
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.is_win = platform.system().lower() == "windows"
self.dev_list = [f"{self.config['fixture_rfid']['port']}:pn532"] if self.is_win else ['tty:USB0:pn532','tty:USB1:pn532']
self._period = 1
@ -43,30 +45,36 @@ class RFID_PN532(Component):
@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].text
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")
if self.mutex.tryLock():
try:
if not self.connected:
self.open_device()
else:
if self.current_data:
self.log.info(f"tag removed:{self.current_data}")
self.current_data = None
self.new_id_signal.emit(None)
self.log.debug("no target present")
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].text
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:
if self.current_data:
self.log.info(f"tag removed:{self.current_data}")
self.current_data = None
self.new_id_signal.emit(None)
self.log.debug("no target present")
except Exception as e:
self.log.info(f"{e}")
self.connected = False
except Exception as e:
self.log.info(f"{e}")
self.connected = False
finally:
self.mutex.unlock()
def write_tag(self,data):
self.data_to_write=copy.deepcopy(data)

View File

@ -8,7 +8,7 @@ from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
from .component import Component
is_win = platform.system() == "Windows"
is_win = platform.system().lower() == "windows"
if "--sim-io" not in sys.argv:
if is_win:

View File

@ -1,5 +1,5 @@
-- REMEMBER TO BACKUP DB FIRST --
update steps set spec = json_insert(spec,"$.test_pressure_qpos",(json_extract(steps.spec, '$.test_pressure_max_delta'))) where type == "leak_1" or type=="leak_2";
update steps set spec = json_insert(spec,"$.test_pressure_qneg",(json_extract(steps.spec, '$.test_pressure_min_delta'))) where type == "leak_1" or type=="leak_2";
update steps set spec = json_(spec,"$.test_pressure_qpos",(json_extract(steps.spec, '$.test_pressure_max_delta'))) where type == "leak_1" or type=="leak_2";
update steps set spec = json_insert(spec,"$.test_pressure_qpos",(json_extract(steps.spec, '$.test_pressure_max_delta'))) where type == "leak_1" or type=="leak_2";
update steps set spec = json_insert(spec,"$.test_pressure_qneg",(json_extract(steps.spec, '$.test_pressure_min_delta'))) where type == "leak_1" or type=="leak_2";

View File

@ -0,0 +1,13 @@
codice_ricetta,cliente,codice_prodotto,descrizione,avvitatura_abilitata,viti,prova_tenuta_abilitata,tempo_riempimento,tempo_assestamento,percentuale_minima_pressione_assestamento,percentuale_massima_pressione_assestamento,tempo_di_test,pressione_di_test_delta_minimo,pressione_di_test,pressione_di_test_delta_massimo,tempo_svuotamento,pressione_svuotamento,stampa_etichetta_abilitata,modello_etichetta
5803148257,IVECO,5803148257,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148256,IVECO,5803148256,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148263,IVECO,5803148263,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148261,IVECO,5803148261,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148264,IVECO,5803148264,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148265,IVECO,5803148265,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148267,IVECO,5803148267,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148266,IVECO,5803148266,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803166717,IVECO,5803166717,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148269,IVECO,5803148269,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803148268,IVECO,5803148268,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
5803167128,IVECO,5803167128,Daily Himatic MY24,,,x,5,5,10,10,5,30,5000,30,1,100,x,ETA30x16.prn
1 codice_ricetta cliente codice_prodotto descrizione avvitatura_abilitata viti prova_tenuta_abilitata tempo_riempimento tempo_assestamento percentuale_minima_pressione_assestamento percentuale_massima_pressione_assestamento tempo_di_test pressione_di_test_delta_minimo pressione_di_test pressione_di_test_delta_massimo tempo_svuotamento pressione_svuotamento stampa_etichetta_abilitata modello_etichetta
2 5803148257 IVECO 5803148257 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
3 5803148256 IVECO 5803148256 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
4 5803148263 IVECO 5803148263 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
5 5803148261 IVECO 5803148261 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
6 5803148264 IVECO 5803148264 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
7 5803148265 IVECO 5803148265 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
8 5803148267 IVECO 5803148267 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
9 5803148266 IVECO 5803148266 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
10 5803166717 IVECO 5803166717 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
11 5803148269 IVECO 5803148269 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
12 5803148268 IVECO 5803148268 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn
13 5803167128 IVECO 5803167128 Daily Himatic MY24 x 5 5 10 10 5 30 5000 30 1 100 x ETA30x16.prn

View File

@ -1,4 +1,5 @@
import logging
import platform
import sys
import time
from datetime import datetime
@ -31,7 +32,12 @@ logging.basicConfig(
)
connected=False
dev_list=['tty:USB0:pn532','tty:USB1:pn532','tty:USB2:pn532']
is_win = platform.system().lower() == "windows"
if is_win:
dev_list=['COM5:pn532']
else:
dev_list = ['tty:USB0:pn532', 'tty:USB1:pn532', 'tty:USB2:pn532']
while True:
try:
if not connected:

View File

@ -3,7 +3,7 @@ import platform
import sys
import time
if platform.system() == "Windows":
if platform.system().lower() == "windows":
sys.path.append(f"{os.getcwd()}\src\components")
from src.components.usb_586x import USB_586x
from lib.helpers import ConfigReader

View File

@ -71,24 +71,27 @@ class Barcode_Recipe_Selection(Test_Test):
if data is None:
return
else:
lines = data.splitlines()
candidates = [i for i in lines if len(i)==10]
if len(candidates)>0:
# RECIPE CODE FOUND
self.recipe=candidates[-1]
self.barcode_input_l.setPalette(self.status_palettes[True])
self.ok_timer.start(2000)
if "--write-tags" not in sys.argv:
self.ok_timer.start(2000)
else:
self.parent.components["rfid"].write_tag(data)
else:
# RECIPE CODE NOT FOUND
self.barcode_input_l.setPalette(self.status_palettes[False])
self.focus_timer.start(3000)
# LOOKUP RECIPE
def set_recipe(self):
try:
# LOOKUP RECIPE
recipe = self.recipe_db_model.get_by_id(self.recipe)
self.parent.set_recipe(recipe)
except peewee.DoesNotExist:

View File

@ -10,55 +10,56 @@ class CopyPastableCrudQTableWidget(QTableWidget):
def eventFilter(self, target, event):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_C and (event.modifiers() & Qt.ControlModifier):
if event.key() == Qt.Key_C and (event.modifiers() & Qt.ControlModifier):
copied_cells = sorted(self.selectedIndexes())
min_row, max_row, min_col, max_col = sys.maxsize, 0, sys.maxsize, 0
for cell in copied_cells:
row = cell.row()
min_row, max_row = min(row, min_row), max(row, max_row)
col = cell.column()
min_col, max_col = min(col, min_col), max(col, max_col)
if min_row == 0: # if filters row
return False
copy_sparse = {}
for cell in copied_cells:
row = cell.row()
col = cell.column()
if row not in copy_sparse:
copy_sparse[row] = {}
cell = self.cellWidget(row, col)
if cell is not None:
copy_sparse[row][col] = cell.parse(row_number=row, crud=weakref.ref(self.crud))
copy_dense = [["" for col in range(max_col - min_col + 1)] for row in range(max_row - min_row + 1)]
for row, row_cells in copy_sparse.items():
for col, cell_text in row_cells.items():
if cell_text is not None:
copy_dense[row - min_row][col - min_col] = str(cell_text)
copy_text = "\n".join(["\t".join(row) for row in copy_dense])
QApplication.clipboard().setText(copy_text)
super().keyPressEvent(event)
QApplication.sendEvent(self, event)
return True
elif event.key() == Qt.Key_V and (event.modifiers() & Qt.ControlModifier):
min_row = self.currentRow()
min_col = self.currentColumn()
if min_row == 0: # if filters row
return False
copy_text = QApplication.clipboard().text()
copy_dense = [row.split("\t") for row in copy_text.split("\n")]
if len(copy_dense) > 1 and len(copy_dense[-1]) == 1 and not len(copy_dense[-1][-1]):
copy_dense.pop(-1)
for row, row_cells in enumerate(copy_dense):
for col, cell_text in enumerate(row_cells):
r = min_row + row
c = min_col + col
cell = self.cellWidget(r, c)
if cell is not None:
cell.render(cell_text, field_name=self.crud.select[c] if self.crud is not None else None, row_number=r, crud=weakref.ref(self.crud))
super().keyPressEvent(event)
QApplication.sendEvent(self, event)
return True
pass
# if event.key() == Qt.Key_C and (event.modifiers() & Qt.ControlModifier):
# if event.key() == Qt.Key_C and (event.modifiers() & Qt.ControlModifier):
# copied_cells = sorted(self.selectedIndexes())
# min_row, max_row, min_col, max_col = sys.maxsize, 0, sys.maxsize, 0
# for cell in copied_cells:
# row = cell.row()
# min_row, max_row = min(row, min_row), max(row, max_row)
# col = cell.column()
# min_col, max_col = min(col, min_col), max(col, max_col)
# if min_row == 0: # if filters row
# return False
# copy_sparse = {}
# for cell in copied_cells:
# row = cell.row()
# col = cell.column()
# if row not in copy_sparse:
# copy_sparse[row] = {}
# cell = self.cellWidget(row, col)
# if cell is not None:
# copy_sparse[row][col] = cell.parse(row_number=row, crud=weakref.ref(self.crud))
# copy_dense = [["" for col in range(max_col - min_col + 1)] for row in range(max_row - min_row + 1)]
# for row, row_cells in copy_sparse.items():
# for col, cell_text in row_cells.items():
# if cell_text is not None:
# copy_dense[row - min_row][col - min_col] = str(cell_text)
# copy_text = "\n".join(["\t".join(row) for row in copy_dense])
# QApplication.clipboard().setText(copy_text)
# super().keyPressEvent(event)
# QApplication.sendEvent(self, event)
# return True
# elif event.key() == Qt.Key_V and (event.modifiers() & Qt.ControlModifier):
# min_row = self.currentRow()
# min_col = self.currentColumn()
# if min_row == 0: # if filters row
# return False
# copy_text = QApplication.clipboard().text()
# copy_dense = [row.split("\t") for row in copy_text.split("\n")]
# if len(copy_dense) > 1 and len(copy_dense[-1]) == 1 and not len(copy_dense[-1][-1]):
# copy_dense.pop(-1)
# for row, row_cells in enumerate(copy_dense):
# for col, cell_text in enumerate(row_cells):
# r = min_row + row
# c = min_col + col
# cell = self.cellWidget(r, c)
# if cell is not None:
# cell.render(cell_text, field_name=self.crud.select[c] if self.crud is not None else None, row_number=r, crud=weakref.ref(self.crud))
# super().keyPressEvent(event)
# QApplication.sendEvent(self, event)
# return True
return super().eventFilter(target, event)
def setCellWidget(self, row, column, widget):