supporto assemblati whip
This commit is contained in:
parent
7f489d6634
commit
51ba135e14
|
|
@ -384,7 +384,24 @@ class Test(Widget):
|
|||
print_found = False
|
||||
count_found = False
|
||||
# create step sequence list
|
||||
barcode_names = ['serial', 'barcode_input_1', 'barcode_input_2', 'barcode_input_3', 'barcode_input_4']
|
||||
for i, step in enumerate(steps):
|
||||
#if step.spec:
|
||||
# n_pieces = int(step.spec.get("n_pieces", "1"))
|
||||
#else:
|
||||
# n_pieces = 1 # default to 1 if spec does not exist
|
||||
|
||||
if step.type == "barcodes":
|
||||
n_pieces = int(step.spec.get("n_pieces", 1))
|
||||
if n_pieces == 1:
|
||||
step.spec["barcode_name"] = 'serial'
|
||||
else:
|
||||
step.spec["barcode_name"] = barcode_names[(n_pieces - 1) % len(barcode_names)]
|
||||
|
||||
if step.type == "barcodes" and n_pieces > 1:
|
||||
step.spec["n_pieces"] = str(n_pieces - 1)
|
||||
new_barcode_step = copy.deepcopy(step) # create a deep copy of the step
|
||||
steps.insert(i + 1, new_barcode_step)
|
||||
if i in skip:
|
||||
continue
|
||||
if step.type == "vision":
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@ class Test_Barcodes(Test_Test):
|
|||
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.barcodes_spec = {
|
||||
"serial": self.check_serial_barcode
|
||||
"serial": self.check_serial_barcode,
|
||||
"barcode_input_1": self.check_serial_barcode,
|
||||
"barcode_input_2": self.check_serial_barcode,
|
||||
"barcode_input_3": self.check_serial_barcode,
|
||||
"barcode_input_4": self.check_serial_barcode,
|
||||
|
||||
}
|
||||
QShortcut(QKeySequence("Return"), self).activated.connect(self.get)
|
||||
QShortcut(QKeySequence("Enter"), self).activated.connect(self.get)
|
||||
|
|
@ -59,31 +64,32 @@ class Test_Barcodes(Test_Test):
|
|||
super().get(None, override=override)
|
||||
return
|
||||
barcode_ok = False
|
||||
for barcode_name, barcode_check in self.barcodes_spec.items():
|
||||
if barcode_check(data):
|
||||
self.barcodes[barcode_name] = data
|
||||
barcode_ok = True
|
||||
break
|
||||
if barcode_ok:
|
||||
self.current_step_barcode_name = self.step.spec.get('barcode_name') # get current step's barcode name
|
||||
barcode_check = self.barcodes_spec.get(self.current_step_barcode_name)
|
||||
|
||||
# If the current step's barcode type exists in barcodes_spec and it's valid, store it
|
||||
if barcode_check and barcode_check(data):
|
||||
self.barcodes[self.current_step_barcode_name] = data
|
||||
barcode_ok = True
|
||||
self.barcodes_le.setPalette(self.status_palettes[True])
|
||||
if self.current_step_barcode_name in self.barcodes: # if the barcode for the current step is stored in self.barcodes
|
||||
result = self.barcodes
|
||||
ok = True
|
||||
else:
|
||||
result = None
|
||||
ok = None
|
||||
super().get([{
|
||||
"time": timing(),
|
||||
"results": {
|
||||
"ok": ok,
|
||||
"result": result,
|
||||
"data": self.barcodes,
|
||||
},
|
||||
}], override=override, fail=ok is False)
|
||||
else:
|
||||
self.barcodes_le.setPalette(self.status_palettes[False])
|
||||
self.barcodes_le.setText("")
|
||||
self.barcodes_le.setFocus()
|
||||
if len(self.barcodes_spec.keys() - self.barcodes.keys()) == 0:
|
||||
result = self.barcodes
|
||||
ok = True
|
||||
else:
|
||||
result = None
|
||||
ok = None
|
||||
super().get([{
|
||||
"time": timing(),
|
||||
"results": {
|
||||
"ok": ok,
|
||||
"result": result,
|
||||
"data": self.barcodes,
|
||||
},
|
||||
}], override=override, fail=ok is False)
|
||||
|
||||
def visualize(self, data=None):
|
||||
if data is None:
|
||||
|
|
@ -98,7 +104,7 @@ class Test_Barcodes(Test_Test):
|
|||
def check_serial_barcode(self, barcode=None):
|
||||
if not isinstance(barcode, str) or len(barcode) == 0:
|
||||
return False
|
||||
barcode_regex = self.step.spec.get("serial", ".*")
|
||||
barcode_regex = self.step.spec.get(self.current_step_barcode_name, ".*")
|
||||
barcode_regex = barcode_regex.replace("{RECIPE}", self.recipe.name)
|
||||
for n in range(32):
|
||||
barcode_regex = barcode_regex.replace(f"{{N{n}}}", f"[0-9]{{{n}}}")
|
||||
|
|
|
|||
|
|
@ -6,43 +6,15 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>169</width>
|
||||
<height>144</height>
|
||||
<width>938</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Test Barcodes</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="13" column="0">
|
||||
<widget class="QLineEdit" name="barcodes_le"/>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QPushButton" name="override_b">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>FORZA ACCETTAZIONE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
|
|
@ -54,13 +26,6 @@
|
|||
<string>Stato</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="serial_l">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
|
@ -68,6 +33,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="serial_l">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="state_l">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -90,6 +62,45 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="override_b">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>FORZA ACCETTAZIONE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="barcodes_expected_le"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Barcode in entrata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLineEdit" name="barcodes_le"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Barcode atteso</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user