barcode recipe selection wip

This commit is contained in:
neo-dl 2023-03-03 18:51:35 +01:00
parent 59ead323b7
commit d686e3310c
19 changed files with 184 additions and 16 deletions

View File

@ -5174,7 +5174,7 @@ YII=
width="50"
height="50"
preserveAspectRatio="none"
xlink:href="arw-yel-down.png"
xlink:href="img/arw-yel-down.png"
id="ring_2"
x="886.45483"
y="346.43152"
@ -5182,7 +5182,7 @@ YII=
width="50"
height="50"
preserveAspectRatio="none"
xlink:href="arw-yel-down.png"
xlink:href="img/arw-yel-down.png"
id="ring_1"
x="546.44611"
y="107.80315"
@ -5190,7 +5190,7 @@ YII=
width="50"
height="50"
preserveAspectRatio="none"
xlink:href="arw-yel-down.png"
xlink:href="img/arw-yel-down.png"
id="piece_1"
x="326.59402"
y="-311.50909"
@ -5199,7 +5199,7 @@ YII=
width="50"
height="50"
preserveAspectRatio="none"
xlink:href="arw-yel-down.png"
xlink:href="img/arw-yel-down.png"
id="piece_2"
x="-390.95227"
y="180.27826"
@ -5208,7 +5208,7 @@ YII=
width="32.995815"
height="32.995815"
preserveAspectRatio="none"
xlink:href="tape_black.png"
xlink:href="img/tape_black.png"
id="tape_1"
x="504.52493"
y="60.613148"
@ -5216,7 +5216,7 @@ YII=
width="32.995815"
height="32.995815"
preserveAspectRatio="none"
xlink:href="tape_black.png"
xlink:href="img/tape_black.png"
id="tape_3"
x="725.1795"
y="444.87793"
@ -5224,7 +5224,7 @@ YII=
width="32.995815"
height="32.995815"
preserveAspectRatio="none"
xlink:href="tape_black.png"
xlink:href="img/tape_black.png"
id="tape_2"
x="444.4454"
y="125.63869"

Before

Width:  |  Height:  |  Size: 388 KiB

After

Width:  |  Height:  |  Size: 388 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -6,6 +6,7 @@ tecna_t3: present
galaxy_camera: absent
digital_io: absent
second_leak_test: absent
barcode_recipe_selection: absent
; archive_synchronizer: present
; label_printer: present
; extra_label_printer: absent

View File

@ -2,14 +2,14 @@
description = ST-TEN-5 IVECO DAILY ELETTRICO
[hardware_config]
#archive_synchronizer: present
archive_synchronizer: absent
archive_synchronizer: present
uvc_camera: absent
label_printer: present
extra_label_printer: present
remote_api: absent
tecna_t3: present
digital_io: present
barcode_recipe_selection: present
[tecna_t3]
port: COM4

View File

@ -20,6 +20,9 @@ python -B -u "./src/main.py" \
--no-edgetpu \
--no-gpu \
--panel \
--sim-io \
--system-id=st-ten-5 \
--no-autotest \
--sim-camera \
--sim-modbus \
--sim-os-label-printer \

View File

@ -20,7 +20,7 @@ if "--sim-io" not in sys.argv:
else:
is_win=False
import components.dummies.libbiodaq as libbiodaq
from components.dummies.libbiodaq import ErrorCode
class USB_586x(Component):
class DeviceInformation(ctypes.Structure):
@ -179,10 +179,13 @@ class USB_586x(Component):
def set_bit(self, byte, bit, val):
self.mutex.lock()
# print("set", byte, bit, not val, flush=True)
if is_win:
ret=self.do_write_bit(byte, bit, int(val))
if not self.simulate:
if is_win:
ret=self.do_write_bit(byte, bit, int(val))
else:
ret=self.do_write_bit(self.do_ctrl, byte, bit, int(val))
else:
ret=self.do_write_bit(self.do_ctrl, byte, bit, int(val))
ret = ErrorCode.Success
self.mutex.unlock()
return ret

View File

@ -11,10 +11,13 @@ fieldnames = [
"prova_tenuta_abilitata_2"
]
# FOLDER CONFIGURATION
in_path="../../tmp/ricette/"
files=glob(f"{in_path}/**/*.dsg",recursive=True)
csv_path="../test/csv_import/importazione da banco montaggio.csv"
data=[]
#FOR EACH FILE CREATE A TEST RECIPE
for file in files:
print(f"READING {file}")
config = ConfigParser(allow_no_value=True)
@ -32,6 +35,7 @@ for file in files:
}
data.append(line)
# SAVE RECIPES TO CSV FILE
with open(csv_path, "w", newline="") as f:
w = csv.DictWriter(f, fieldnames, extrasaction="ignore")
w.writeheader()

View File

@ -0,0 +1,3 @@
xyz123
5802850925

View File

@ -0,0 +1 @@
from .barcode_recipe_selection import Barcode_Recipe_Selection

View File

@ -0,0 +1,60 @@
import sys
from PyQt5 import Qt
from lib.helpers import timing
from PyQt5.QtCore import Qt, QTimer, QThread
from PyQt5.QtGui import QKeySequence, QPixmap, QPalette, QColor
from PyQt5.QtWidgets import QShortcut, QApplication
from ui.widget import Widget
test_scan="xxx\nyyy\nzzz"
class Barcode_Recipe_Selection(Widget):
def __init__(self, config):
super().__init__()
self.barcode_input_l.textChanged.connect(self.get)
self.status_palettes = {
True: QPalette(),
"": QPalette(),
"warning": QPalette(),
False: QPalette(),
None: QPalette(),
}
self.status_palettes[True].setColor(QPalette.Base, Qt.green)
self.status_palettes[False].setColor(QPalette.Base, Qt.red)
self.status_palettes["warning"].setColor(QPalette.Base, QColor(255, 165, 0))
self.status_palettes[""].setColor(QPalette.Base, QColor(255, 255, 0))
self.barcode_input_l.setFocus()
self.focus_timer = QTimer()
self.focus_timer.setSingleShot(True)
self.focus_timer.timeout.connect(self.set_focus)
def start(self, recipe=None, step=None, pieces=None):
self.barcode_input_l.setPalette(self.status_palettes[None])
self.barcode_input_l.setPlainText("")
self.barcode_input_l.setFocus()
self.focus_timer.start(500)
def get(self, data=None, override=False):
if data is None:
data = self.barcode_input_l.toPlainText()
if not len(data):
data = None
if data is None:
return
self.barcode_input_l.setPalette(self.status_palettes[True])
else:
self.barcode_input_l.setPalette(self.status_palettes[False])
self.focus_timer.start(1000)
# LOOKUP RECIPE
def set_focus(self):
self.barcode_input_l.setFocus()
self.barcode_input_l.setPlainText("")
self.barcode_input_l.setPalette(self.status_palettes[""])

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Test_Connector</class>
<widget class="QWidget" name="Test_Connector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1147</width>
<height>625</height>
</rect>
</property>
<property name="windowTitle">
<string>Test Connector</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="3" column="0">
<widget class="QPlainTextEdit" name="barcode_input_l">
<property name="maximumSize">
<size>
<width>400</width>
<height>200</height>
</size>
</property>
<property name="plainText">
<string>123
456
abc</string>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="state_l">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -12,6 +12,7 @@ from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QMessageBox
from ui.helpers import replace_widget
from ui.recipe_selection import Recipe_Selection
from ui.barcode_recipe_selection import Barcode_Recipe_Selection
from ui.test_assembly import Test_Assembly
from ui.test_barcodes import Test_Barcodes
from ui.test_connector import Test_Connector
@ -93,6 +94,7 @@ class Test(Widget):
"resistance": Test_Assembly(img_path=None, text=u"COLLEGARE CONNETTORE ELETTRICO PER EFFETTUARE PROVA RESISTENZA", widget=Test_Resistance(components=self.components, recipe=self.recipe, step=self.step, pieces=self.pieces)),
"screws": Test_Assembly(img_path=None, text=u"AVVITARE TUTE LE VITI COME INDICATO", widget=Test_Screws(components=self.components, recipe=self.recipe, step=self.step, pieces=self.pieces)),
"select_recipe": Test_Assembly(img_path=None, text=u"SELEZIONARE IL CODICE DA COLLAUDARE", widget=Recipe_Selection(config=self.config, unsupported_steps=self.unsupported_steps)),
"barcode_recipe_selection": Test_Assembly(img_path=self.select_step_img("scan"), text=u"LEGGERE IL BARCODE SULLA DIMA DEL COMPONENTE DA COLLAUDARE", widget=Barcode_Recipe_Selection(config=self.config)),
"vision": Test_Assembly(img_path=None, text=u"VERIFICARE CONTROLLO CON TELECAMERA", widget=Test_Vision(components=self.components, recipe=self.recipe, step=self.step, pieces=self.pieces)),
"wait": Test_Assembly(img_path=self.select_step_img("wait"), text=u"ATTENDERE - PAUSA INTER CICLO", widget=None),
None: Test_Assembly(img_path=self.select_step_img("warning"), text=u"ATTENZIONE - LA RICETTA SELEZIONATA NON CONTIENE FASI DI TEST", widget=None),
@ -215,7 +217,10 @@ class Test(Widget):
# set next cycle step normally
if self.recipe is None or self.cycle_steps is None:
# if recipe not set: select_recipe
self.step = Steps(type="select_recipe")
if self.config["hardware_config"]["barcode_recipe_selection"]=="present":
self.step = Steps(type="barcode_recipe_selection")
else:
self.step = Steps(type="select_recipe")
elif action is None:
if self.autotest_request is not False and self.autotest_cycle_steps is not None and not self.autotesting and (self.cycle_index == -1 or self.cycle_index + 1 >= len(self.cycle_steps)):
# if autotest was requested

View File

@ -17,6 +17,9 @@ class Test_Barcodes(Test_Test):
QShortcut(QKeySequence("Return"), self).activated.connect(self.get)
QShortcut(QKeySequence("Enter"), self).activated.connect(self.get)
self.barcodes_le.setFocus()
self.focus_timer = QTimer()
self.focus_timer.setSingleShot(True)
self.focus_timer.timeout.connect(self.set_focus)
def start(self, recipe=None, step=None, pieces=None):
show = super().start(recipe=recipe, step=step, pieces=pieces)
@ -26,6 +29,8 @@ class Test_Barcodes(Test_Test):
self.barcodes_le.setPalette(self.status_palettes[None])
self.barcodes_le.setText("")
self.barcodes_le.setFocus()
self.focus_timer.start(500)
# TESTING
if "--test-barcodes" in sys.argv or "--test" in sys.argv:
self.barcodes_le.setText("-----TEST_BARCODE-----")
@ -98,3 +103,6 @@ class Test_Barcodes(Test_Test):
for n in range(32):
barcode_regex = barcode_regex.replace(f"{{N{n}}}", f"[0-9]{{{n}}}")
return re.fullmatch(barcode_regex, barcode) is not None
def set_focus(self):
self.barcodes_le.setFocus()

View File

@ -13,6 +13,9 @@ class Test_Connector(Test_Test):
QShortcut(QKeySequence("Return"), self).activated.connect(self.get)
QShortcut(QKeySequence("Enter"), self).activated.connect(self.get)
self.connector_le.setFocus()
self.focus_timer = QTimer()
self.focus_timer.setSingleShot(True)
self.focus_timer.timeout.connect(self.set_focus)
def start(self, recipe=None, step=None, pieces=None):
show = super().start(recipe=recipe, step=step, pieces=pieces)
@ -25,6 +28,8 @@ class Test_Connector(Test_Test):
self.connector_le.setPalette(self.status_palettes[None])
self.connector_le.setText("")
self.connector_le.setFocus()
self.focus_timer.start(500)
# TESTING
if "--test-connector" in sys.argv or "--test" in sys.argv:
self.connector_le.setText(expected)
@ -83,3 +88,6 @@ class Test_Connector(Test_Test):
def check_serial_barcode(self, barcode=None):
return barcode is not None and len(barcode)
def set_focus(self):
self.barcodes_le.setFocus()

View File

@ -14,7 +14,7 @@ from lxml import etree
class Test_Instructions(Test_Test):
def __init__(self, components=None, recipe=None, step=None, run_once=False, reset_on_start=False, enable_override=False,bench_name="generic"):
def __init__(self, components=None, recipe=None, step=None, run_once=False, reset_on_start=False, enable_override=True,bench_name="generic"):
super().__init__(components=components, recipe=recipe, step=step, run_once=run_once, reset_on_start=reset_on_start, enable_override=enable_override)
self.bench_name = bench_name
self.recipe=recipe

View File

@ -8,7 +8,7 @@ from ui.test_test import Test_Test
from components.Automation.BDaq import ErrorCode
class Test_Leak(Test_Test):
def __init__(self, components=None, recipe=None, step=None, pieces=None, run_once=False, reset_on_start=True, enable_override=True):
def __init__(self, components=None, recipe=None, step=None, pieces=None, run_once=False, reset_on_start=True, enable_override=False):
super().__init__(components=components, recipe=recipe, step=step, pieces=pieces, run_once=run_once, reset_on_start=reset_on_start, enable_override=enable_override)
self.start_b.clicked.connect(lambda checked, self=weakref.ref(self): self().components["tecna_t3"].start_test())
self.stop_b.clicked.connect(lambda checked, self=weakref.ref(self): self().components["tecna_t3"].stop_test())