From 623e3e3f6faf03754f24dd27c1ab9204c17e941a Mon Sep 17 00:00:00 2001 From: matteo porta Date: Wed, 27 Jul 2022 17:09:17 +0200 Subject: [PATCH] wip --- src/components/modbus_component.py | 31 +- src/ui/editor/editor.py | 2 + src/ui/editor/editor.ui | 358 +----------------- src/ui/recipe_selection/recipe_selection.py | 28 ++ .../recipe_spec_and_step_editor.py | 2 +- src/ui/test/test.py | 2 +- src/ui/test_leak/test_leak.py | 5 +- src/ui/test_leak/test_leak.ui | 206 +++++----- 8 files changed, 163 insertions(+), 471 deletions(-) diff --git a/src/components/modbus_component.py b/src/components/modbus_component.py index ddd10cb..2ae2d78 100644 --- a/src/components/modbus_component.py +++ b/src/components/modbus_component.py @@ -1,4 +1,5 @@ import sys +import traceback if "--sim-serial" in sys.argv: from components.dummies.serial import serial @@ -53,21 +54,27 @@ class ModbusComponent(Component): self.lock.unlock() def _read(self, register, count=1): - self.lock.lock() - read = self.client.read_holding_registers(register, count=count) - self.lock.unlock() - if read.isError(): - # self.log.exception(traceback.format_exception(type(read), read, read.__traceback__)) - raise read + while True: + self.lock.lock() + read = self.client.read_holding_registers(register, count=count) + self.lock.unlock() + if read.isError(): + self.log.exception(traceback.format_exception(type(read), read, read.__traceback__)) + # raise read + else: + break return read def _write(self, register, value): - self.lock.lock() - wrote = self.client.write_registers(register, value, skip_encode=True) - self.lock.unlock() - if wrote.isError(): - # self.log.exception(traceback.format_exception(type(wrote), wrote, wrote.__traceback__)) - raise wrote + while True: + self.lock.lock() + wrote = self.client.write_registers(register, value, skip_encode=True) + self.lock.unlock() + if wrote.isError(): + self.log.exception(traceback.format_exception(type(wrote), wrote, wrote.__traceback__)) + # raise wrote + else: + break def _decode(self, read, *args, data_type="16bit_uint", gain=1, offset=0, **kwargs): decoder = BinaryPayloadDecoder.fromRegisters(read.registers, byteorder=self.byteorder, wordorder=self.wordorder) diff --git a/src/ui/editor/editor.py b/src/ui/editor/editor.py index 38973f8..defa791 100644 --- a/src/ui/editor/editor.py +++ b/src/ui/editor/editor.py @@ -26,6 +26,8 @@ class Editor(Widget): if autocomplete is None: return for k, v in autocomplete.items(): + if k not in self.spec: + continue w = self.spec[k] if isinstance(w, QCheckBox): w.setChecked(bool(v)) diff --git a/src/ui/editor/editor.ui b/src/ui/editor/editor.ui index b287ea4..cfb88e7 100644 --- a/src/ui/editor/editor.ui +++ b/src/ui/editor/editor.ui @@ -6,366 +6,14 @@ 0 0 - 845 - 696 + 94 + 18 Editor - - - - - Scarico - - - - - - Tempo - - - - - - - Pressione - - - - - - - 9999 - - - - - - - 9999 - - - - - - - s - - - - - - - mbar - - - - - - - - - - Riempimento - - - - - - Soglia min - - - - - - - Tempo - - - - - - - s - - - - - - - 100 - - - - - - - 9999 - - - - - - - Soglia max - - - - - - - 100 - - - - - - - % - - - - - - - % - - - - - - - Assestamento - - - - - - - 9999 - - - - - - - s - - - - - - - - - - Visione - - - - - - Ricetta visione - - - - - - - - - - - - - Pre-Riempimento - - - - - - 9999 - - - - - - - 9999 - - - - - - - Tempo - - - - - - - mbar - - - - - - - s - - - - - - - Pressione - - - - - - - - - - Test - - - - - - mbar - - - - - - - Delta min - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - mbar - - - - - - - Delta max - - - - - - - mbar - - - - - - - Tempo - - - - - - - 0 - - - 9999 - - - - - - - Pressione - - - - - - - s - - - - - - - - - - Ricetta - - - - - - N° disegno - - - - - - - Descrizione - - - - - - - - - - - - Cliente - - - - - - - - - - - - - + diff --git a/src/ui/recipe_selection/recipe_selection.py b/src/ui/recipe_selection/recipe_selection.py index 2a3328b..a4a0e73 100755 --- a/src/ui/recipe_selection/recipe_selection.py +++ b/src/ui/recipe_selection/recipe_selection.py @@ -51,6 +51,34 @@ class Recipe_Selection(Widget): autocomplete={ "spec": { "step_editors": { + "leak_1": { + "pre_filling_time": 1, + "pre_filling_pressure": 1000, + "filling_time": 1, + "settling_time": 1, + "settling_pressure_min_percent": 5, + "settling_pressure_max_percent": 5, + "test_time": 5, + "test_pressure_min_delta": 100, + "test_pressure": 1000, + "test_pressure_max_delta": 100, + "flush_time": 1, + "flush_pressure": 100, + }, + "leak_2": { + "pre_filling_time": 1, + "pre_filling_pressure": 1000, + "filling_time": 1, + "settling_time": 1, + "settling_pressure_min_percent": 5, + "settling_pressure_max_percent": 5, + "test_time": 5, + "test_pressure_min_delta": 100, + "test_pressure": 1000, + "test_pressure_max_delta": 100, + "flush_time": 1, + "flush_pressure": 100, + }, "vision": { # "recipe": sorted(glob("*.ini", root_dir="./config/vision/recipes/")), # only in python3.10 "recipe": sorted(map(os.path.basename, glob("./config/vision/recipes/*.ini"))), diff --git a/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py b/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py index 722cc2d..bec3257 100644 --- a/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py +++ b/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py @@ -60,7 +60,7 @@ class Recipe_Spec_And_Step_Editor(Editor): def do_autocomplete(self, autocomplete): if autocomplete is None: return - step_editors_autocomplete = autocomplete.pop("step_editors", None) + step_editors_autocomplete = autocomplete.get("step_editors", None) super().do_autocomplete(autocomplete) if step_editors_autocomplete is not None: for step_name, map in self.map.items(): diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 1dc7b5d..c5533ea 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"ESECUZIONE TEST IN CORSO - ATTENDERE", Test_Leak(components=self.components, recipe=self.recipe, step=self.step)), + "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)), "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)), diff --git a/src/ui/test_leak/test_leak.py b/src/ui/test_leak/test_leak.py index 97dd767..649e9c4 100644 --- a/src/ui/test_leak/test_leak.py +++ b/src/ui/test_leak/test_leak.py @@ -58,7 +58,10 @@ class Test_Leak(Test_Test): "Running test: test type": self.test_type_l, "Running test: sequence index": self.sequence_index_l, }.items(): - l.setText(str(d.get(k, "-"))) + v = d.get(k, "-") + if type(v) is float: + v = round(v, 2) + l.setText(str(v)) super().visualize(data) def save_last(self): diff --git a/src/ui/test_leak/test_leak.ui b/src/ui/test_leak/test_leak.ui index 244efe2..2ed8e36 100644 --- a/src/ui/test_leak/test_leak.ui +++ b/src/ui/test_leak/test_leak.ui @@ -6,8 +6,8 @@ 0 0 - 881 - 614 + 305 + 459 @@ -518,86 +518,7 @@ PROVA TENUTA - - - - - 12 - 75 - true - - - - Stato strumento - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 12 - 75 - true - - - - Pressione del circuito - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 12 - 75 - true - - - - Perdita - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -614,7 +535,41 @@ - + + + + + 12 + 75 + true + + + + Pressione del circuito + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 24 + 75 + true + + + + Fase del test + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + @@ -631,15 +586,22 @@ - - + + - - - + + + + - + + + + + 12 @@ -648,21 +610,34 @@ - Fase del test + Perdita Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + - - + + + + - + + + + @@ -679,21 +654,50 @@ - - + + + + mbar + + + + + + + mbar + + + + + + + mbar + + + + + + + + 24 + 75 + true + + - - - - - - 0 - 0 - + + + + - + + + + - @@ -1169,7 +1173,7 @@ background-color:rgb(85, 255, 127); - AVVIA PROVA TENUTA + START