From 3c2d6f37752f9b25e33c842605dcda8d7762325a Mon Sep 17 00:00:00 2001 From: stres1 Date: Thu, 28 Jul 2022 12:27:54 +0200 Subject: [PATCH] dev --- config/machine_settings/defaults.ini | 2 +- config/machine_settings/hostnames.ini | 1 + config/machine_settings/stres1.ini | 8 + config/vision/labels/labels.pbtxt | 2 +- designer_win.sh | 2 + run_chart_example.sh | 4 - run_lifecycle.sh | 4 - src/components/neo_pixels.py | 21 +- src/components/tecna_marposs_provaset_t3p.py | 2 +- .../tecna_marposs_provaset_t3p_registers.py | 18 +- src/components/vision.py | 6 +- src/test/multicomp.py | 5 +- src/test/neo_lights.py | 4 +- src/ui/test/test.py | 12 +- src/ui/test_leak/test_leak.ui | 977 +++++++++--------- 15 files changed, 533 insertions(+), 535 deletions(-) create mode 100644 config/machine_settings/stres1.ini create mode 100644 designer_win.sh delete mode 100755 run_chart_example.sh delete mode 100755 run_lifecycle.sh diff --git a/config/machine_settings/defaults.ini b/config/machine_settings/defaults.ini index 3ac4deb..912cb44 100644 --- a/config/machine_settings/defaults.ini +++ b/config/machine_settings/defaults.ini @@ -43,7 +43,7 @@ port: COM1 baudrate: 9600 [vision] -detection_threshold: 0.5 +detection_threshold: 0.75 neural_network: hs3-20000 ; recipes_path: ./config/vision_test_recipes diff --git a/config/machine_settings/hostnames.ini b/config/machine_settings/hostnames.ini index ec8cff8..50cc150 100644 --- a/config/machine_settings/hostnames.ini +++ b/config/machine_settings/hostnames.ini @@ -2,3 +2,4 @@ this: this mino: mino DESKTOP-VOCOB38: vm +ST-RES-1: stres1 \ No newline at end of file diff --git a/config/machine_settings/stres1.ini b/config/machine_settings/stres1.ini new file mode 100644 index 0000000..b338022 --- /dev/null +++ b/config/machine_settings/stres1.ini @@ -0,0 +1,8 @@ +[tecna_t3] +port: COM5 + +[neo_pixels] +port: COM4 +baudrate: 9600 + + diff --git a/config/vision/labels/labels.pbtxt b/config/vision/labels/labels.pbtxt index 5cc99f0..4ab5798 100644 --- a/config/vision/labels/labels.pbtxt +++ b/config/vision/labels/labels.pbtxt @@ -1,7 +1,7 @@ item { id: 1 name: 'hs-ok' - color: '0x000000' + color: '0x55AA55' } item { id: 2 diff --git a/designer_win.sh b/designer_win.sh new file mode 100644 index 0000000..11fefa5 --- /dev/null +++ b/designer_win.sh @@ -0,0 +1,2 @@ +#!/bin/bash +venv/Lib/site-packages/qt5_applications/Qt/bin/designer diff --git a/run_chart_example.sh b/run_chart_example.sh deleted file mode 100755 index 6b7f73c..0000000 --- a/run_chart_example.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -e -cd "$(dirname "$0")" -source "./venv/Scripts/activate" || source "./venv/bin/activate" -python -O "./src/lib/charts/MultiAxisExample.py" diff --git a/run_lifecycle.sh b/run_lifecycle.sh deleted file mode 100755 index 49e80f6..0000000 --- a/run_lifecycle.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -e -cd "$(dirname "$0")" -source "./venv/Scripts/activate" || source "./venv/bin/activate" -python -O "./src/lifecycle.py" diff --git a/src/components/neo_pixels.py b/src/components/neo_pixels.py index 7481d8a..6fb296d 100644 --- a/src/components/neo_pixels.py +++ b/src/components/neo_pixels.py @@ -1,4 +1,5 @@ import sys +import time import traceback if "--sim-serial" in sys.argv: @@ -16,6 +17,13 @@ C_UINT32_MAX = c_uint32(-1).value class NeoPixels(Component): def __init__(self, config=None, name=None): super().__init__(config=config, name=name, threaded=False) + self.conn = serial.Serial( + self.port, + baudrate=self.baudrate, + stopbits=self.stopbits, + parity=self.parity, + bytesize=self.bytesize, + ) def config_changed(self): self.port = self.config[self.name]["port"] @@ -30,18 +38,11 @@ class NeoPixels(Component): if not color.startswith("#") or len(color) != 7: raise ValueError("the color parameter must be in the html hex format: '#RRGGBB'") try: - conn = serial.Serial( - self.port, - baudrate=self.baudrate, - stopbits=self.stopbits, - parity=self.parity, - bytesize=self.bytesize, - ) - conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n") - response = conn.readline() + self.conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n") + response = self.conn.readline() if response != "ok\n": self.log.error(response.strip()) - conn.close() + # conn.close() except serial.serialutil.SerialException: self.log.exception(traceback.format_exc()) diff --git a/src/components/tecna_marposs_provaset_t3p.py b/src/components/tecna_marposs_provaset_t3p.py index 3daee7b..6db4684 100644 --- a/src/components/tecna_marposs_provaset_t3p.py +++ b/src/components/tecna_marposs_provaset_t3p.py @@ -180,7 +180,7 @@ class TecnaMarpossProvasetT3P(ModbusComponent): "Running test: test type", "Running test: sequence index", ]} - if info["Running test: active phase"] == "END TEST, WAITING THE START OF A NEW TEST": + if info["Running test: active phase"] == "FINE TEST": info.update(self.get_test_results()) self.log.debug(str(info)) super()._get([info]) diff --git a/src/components/tecna_marposs_provaset_t3p_registers.py b/src/components/tecna_marposs_provaset_t3p_registers.py index 071c46a..cdfeedf 100644 --- a/src/components/tecna_marposs_provaset_t3p_registers.py +++ b/src/components/tecna_marposs_provaset_t3p_registers.py @@ -7,7 +7,7 @@ registers = { "Life counter: TOTAL TESTS": [8 - 1, {"dt": "32bit_uint", }], "Real time test pressure output": [11 - 1, {"dt": "32bit_int", "f": 21, }], "Real time differential pressure output": [13 - 1, {"dt": "32bit_int", "f": 22, }], - "Real time pressure line regulator": [15 - 1, {"dt": "16bit_int", "f": 23, }], + "Real time pressure line regulator": [15 - 1, {"dt": "16bit_int", "f": 23,"g":0.1 }], "Active alarm flags": [16 - 1, {"dt": "16bit_uint", }], # | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | # | | | | A5 | A4 | A3 | A2 | A1 | | | | | | E3 | E2 | E1 | @@ -28,9 +28,9 @@ registers = { "Running test: flow rate format": [27 - 1, {"dt": "16bit_uint", }], # white "Active test program number": [31 - 1, {"dt": "16bit_uint", }], "Running test: active phase": [32 - 1, {"dt": "16bit_uint", "decoding": { - 0: "WAITING START", - 10: "CHECK BARCODE", - 20: "WAITING BARCODE", + 0: "ATTESA START", + 10: "CONTROLLO BARCODE", + 20: "ATTESA BARCODE", 30: "START TEST", 40: "START CAGE", 50: "START PLUG", @@ -38,10 +38,10 @@ registers = { 70: "WAIT DELAY ACKNOWLEDGE COMMAND", 80: "WAIT DELAY", 90: "WAIT ACKNOWLEDGE", - 100: "T0 PRE-FILL", - 110: "T1 FILLING", - 120: "T2 SETTLING", - 130: "T3 MEASURE", + 100: "T0 PRE-RIEMPIMENTO", + 110: "T1 RIEMPIMENTO", + 120: "T2 ASSESTAMENTO", + 130: "T3 MISURA", 140: "WAITING OPERATOR RESULT ACKNOWLEDGE", 150: "RESULT PRESENT", 160: "MARKING", @@ -49,7 +49,7 @@ registers = { 180: "END SEQUENCE PROGRAM", 190: "END PLUG", 200: "END CAGE", - 210: "END TEST, WAITING THE START OF A NEW TEST", + 210: "FINE TEST", }, }], "Running test: phase backwards time": [33 - 1, {"dt": "16bit_uint", "f": 26, }], "Running test: filling pressure": [34 - 1, {"dt": "32bit_int", "f": 21, }], diff --git a/src/components/vision.py b/src/components/vision.py index bce2d84..a189c83 100644 --- a/src/components/vision.py +++ b/src/components/vision.py @@ -381,9 +381,9 @@ class Vision(Component): if lock: self.lock.unlock() detections = { - "detection_scores": [scores], - "detection_boxes": [boxes], - "detection_classes": [map(lambda class_id: class_id + 1, class_ids)], + "detection_scores": [scores][0:1], + "detection_boxes": [boxes][0:1], + "detection_classes": [map(lambda class_id: class_id + 1, class_ids)][0:1], } else: detections = self.model(tensor) diff --git a/src/test/multicomp.py b/src/test/multicomp.py index c06d821..f23cacd 100644 --- a/src/test/multicomp.py +++ b/src/test/multicomp.py @@ -2,8 +2,11 @@ import time import serial +#tester_port="/dev/ttyUSB0" +tester_port="COM1" + conn = serial.Serial( - "/dev/ttyUSB0", + tester_port, baudrate=115200, stopbits=serial.STOPBITS_ONE, parity=serial.PARITY_NONE, diff --git a/src/test/neo_lights.py b/src/test/neo_lights.py index c9a3394..2d29090 100644 --- a/src/test/neo_lights.py +++ b/src/test/neo_lights.py @@ -4,11 +4,13 @@ import serial C_UINT32_MAX = c_uint32(-1).value conn = serial.Serial( - "/dev/ttyACM1", + "COM4", baudrate=9600, stopbits=serial.STOPBITS_ONE, parity=serial.PARITY_NONE, bytesize=serial.EIGHTBITS, + rtscts=False, + xonxoff=False ) pixel = C_UINT32_MAX color = "#ff00ff" diff --git a/src/ui/test/test.py b/src/ui/test/test.py index c5533ea..a3ada99 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -44,7 +44,7 @@ class Test(Widget): "done": Test_Assembly(self.select_step_img("success"), u"COLLAUDO COMPLETATO"), "emergency": Test_Assembly(self.select_step_img("reset_emergency"), u"EMERGENZA INTERVENUTA - RIPRISTINARE PULSANTE E SELEZIONARE \"RESET EMERGENZA\" DAL MEN\u00d9 \"STRUMENTI\""), "fail": Test_Assembly(self.select_step_img("fail"), u"CICLO INTERROTTO"), - "leak": Test_Assembly(None, u"PREMERE START PER COMINCIARE LA PROVA TENUTA E ATTENDERE IL SUO COMPLETAMENTO", Test_Leak(components=self.components, recipe=self.recipe, step=self.step)), + "leak": Test_Assembly(None, u"PREMERE START PER INIZIARE LA PROVA TENUTA", Test_Leak(components=self.components, recipe=self.recipe, step=self.step)), "print": Test_Assembly(self.select_step_img("print"), u"STAMPA ETICHETTA IN CORSO"), "select_recipe": Test_Assembly(None, u"SELEZIONARE IL CODICE DA COLLAUDARE", Recipe_Selection()), "vision": Test_Assembly(None, u"VERIFICARE CONTROLLO CON TELECAMERA", Test_Vision(components=self.components, recipe=self.recipe, step=self.step)), @@ -279,11 +279,13 @@ class Test(Widget): def print(self, archived=None): self.log.info("cycle print") # LABEL PRINT + datamatrix= archived.recipe.part_number+ archived.time.strftime("%m%y")+f"{archived.id:0>5}" + dt_label=archived.time.strftime("%d/%m/%Y %H:%M:%S") context = { - "DATAMATRIX": str(self.data.get("barcodes", {}).get("serial", "")), - "DATAMATRIX_TEXT": str(self.data.get("barcodes", {}).get("serial", "-")), - "PIECE_NUM": str(self.data.get("barcodes", {}).get("serial", "-")), - "DATETIME": str(archived.time.isoformat()), + "DATAMATRIX": datamatrix, + "DATAMATRIX_TEXT": datamatrix, + "PIECE_NUM": str(archived.id), + "DATETIME": dt_label, "SHIFT": str(get_shift(archived.time)), "STATION": str(self.machine_id), "OPERATOR": str(Users.get_session().user.username), diff --git a/src/ui/test_leak/test_leak.ui b/src/ui/test_leak/test_leak.ui index 2ed8e36..0c4e305 100644 --- a/src/ui/test_leak/test_leak.ui +++ b/src/ui/test_leak/test_leak.ui @@ -6,505 +6,14 @@ 0 0 - 305 - 459 + 854 + 704 Test Leak - - - - - 0 - 0 - - - - - 0 - 100 - - - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 127 - 127 - - - - - - - 255 - 63 - 63 - - - - - - - 127 - 0 - 0 - - - - - - - 170 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 112 - 114 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 127 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 127 - 127 - - - - - - - 255 - 63 - 63 - - - - - - - 127 - 0 - 0 - - - - - - - 170 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 112 - 114 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 127 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 127 - 127 - - - - - - - 255 - 63 - 63 - - - - - - - 127 - 0 - 0 - - - - - - - 170 - 0 - 0 - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 112 - 114 - - - - - - - 255 - 112 - 114 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 20 - 75 - true - - - - background-color:rgb(255, 112, 114); - - - STOP - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - FORZA ACCETTAZIONE - - - @@ -556,7 +65,7 @@ - 24 + 12 75 true @@ -679,7 +188,7 @@ - 24 + 12 75 true @@ -1231,6 +740,477 @@ + + + + + 0 + 0 + + + + + 0 + 100 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 127 + 127 + + + + + + + 255 + 63 + 63 + + + + + + + 127 + 0 + 0 + + + + + + + 170 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 112 + 114 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 127 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 127 + 127 + + + + + + + 255 + 63 + 63 + + + + + + + 127 + 0 + 0 + + + + + + + 170 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 112 + 114 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 127 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 127 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 127 + 127 + + + + + + + 255 + 63 + 63 + + + + + + + 127 + 0 + 0 + + + + + + + 170 + 0 + 0 + + + + + + + 127 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 0 + 0 + + + + + + + 255 + 112 + 114 + + + + + + + 255 + 112 + 114 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 20 + 75 + true + + + + background-color:rgb(255, 112, 114); + + + STOP + + + @@ -1239,6 +1219,13 @@ 0 + + + 12 + 75 + true + + FORZA ACCETTAZIONE