From 0705d40a09b265ce09e7e43ac17480c727ff4ba5 Mon Sep 17 00:00:00 2001 From: neo-dl Date: Tue, 11 Apr 2023 17:01:17 +0200 Subject: [PATCH] new sensor id ok --- .../st-ten-5/5802850926.svg | 72 +++++++++++++++ .../st-ten-5/5802963598.svg | 91 +++++++++++++++++++ .../st-ten-5/5802963681.svg | 79 ++++++++++++++++ simulate.sh | 1 - src/components/usb_586x.py | 2 +- src/ui/test_instructions/test_instructions.py | 35 +++---- 6 files changed, 261 insertions(+), 19 deletions(-) create mode 100644 config/instruction_images/st-ten-5/5802850926.svg create mode 100644 config/instruction_images/st-ten-5/5802963598.svg create mode 100644 config/instruction_images/st-ten-5/5802963681.svg diff --git a/config/instruction_images/st-ten-5/5802850926.svg b/config/instruction_images/st-ten-5/5802850926.svg new file mode 100644 index 0000000..06ac2b0 --- /dev/null +++ b/config/instruction_images/st-ten-5/5802850926.svg @@ -0,0 +1,72 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/config/instruction_images/st-ten-5/5802963598.svg b/config/instruction_images/st-ten-5/5802963598.svg new file mode 100644 index 0000000..2cf4889 --- /dev/null +++ b/config/instruction_images/st-ten-5/5802963598.svg @@ -0,0 +1,91 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/config/instruction_images/st-ten-5/5802963681.svg b/config/instruction_images/st-ten-5/5802963681.svg new file mode 100644 index 0000000..009baaf --- /dev/null +++ b/config/instruction_images/st-ten-5/5802963681.svg @@ -0,0 +1,79 @@ + + + + diff --git a/simulate.sh b/simulate.sh index d84e9bf..52c9e61 100755 --- a/simulate.sh +++ b/simulate.sh @@ -16,7 +16,6 @@ python -B -u "./src/main.py" \ --auto-accept-test-admin-permission \ --auto-login-admin \ --auto-select \ ---debugger-workaround \ --no-edgetpu \ --no-gpu \ --panel \ diff --git a/src/components/usb_586x.py b/src/components/usb_586x.py index 2236480..e4d12c1 100644 --- a/src/components/usb_586x.py +++ b/src/components/usb_586x.py @@ -158,7 +158,7 @@ class USB_586x(Component): read = [] if is_win or self.simulate: if self.simulate: - read.append(bytearray(0)) + read=[1,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0] else: ret = self.di_read(0, self.in_size) if ret[0].value == ErrorCode.Success.value: diff --git a/src/ui/test_instructions/test_instructions.py b/src/ui/test_instructions/test_instructions.py index 925620b..0c18da5 100644 --- a/src/ui/test_instructions/test_instructions.py +++ b/src/ui/test_instructions/test_instructions.py @@ -21,6 +21,7 @@ class Test_Instructions(Test_Test): self.svgWidget=None self.svg_root=None self.flag=False + self.inputs={} self.svg_widget=QtSvg.QSvgWidget() self.layout = QVBoxLayout() self.layout.addWidget(self.svg_widget) @@ -31,12 +32,7 @@ class Test_Instructions(Test_Test): def start(self, recipe=None, step=None, pieces=None): show = super().start(recipe=recipe, step=step) - ring_ids=[f"ring_{i+1}" for i in range(step.spec["num_ring"])] - piece_ids=[f"piece_{i+1}" for i in range(step.spec["num_piece"])] - tape_ids=[f"tape_{i+1}" for i in range(step.spec["num_tape"])] - self.ids=ring_ids+piece_ids - self.inputs= {idx: {"id":id,"status":False} for idx,id in enumerate(self.ids)} - self.tapes = {idx: {"id": id, "status": False} for idx, id in enumerate(tape_ids)} + self.timer.start(1000) # setup test loop self.get_connection = self.components["digital_io"].out.connect(self.get) @@ -48,22 +44,26 @@ class Test_Instructions(Test_Test): self.svg_root = etree.parse(svg_path) self.svg_str = etree.tostring(self.svg_root) self.svg_str=etree.tostring(self.svg_root) + + self.monitored_ids=self.svg_root.xpath(f'''.//*[starts-with(@id, 'sensor_')]''') + + self.tape_ids=self.svg_root.xpath(f'''.//*[starts-with(@id, 'tape_')]''') + self.done = False return show def toggle_icons(self): self.flag = not self.flag - for idx,tape in self.tapes.items(): - elem = self.svg_root.findall(f'''.//*[@id='{tape["id"]}']''')[0] + for elem in self.tape_ids: if self.flag: self.show_tape(elem) else: self.hide_tape(elem) - for idx,input in self.inputs.items(): - elem = self.svg_root.findall(f'''.//*[@id='{input["id"]}']''')[0] - if input["status"]: + for elem in self.monitored_ids: + sensor_index = int(elem.attrib['id'].split("_")[1]) - 3 + if self.inputs[sensor_index]: self.show_ok(elem) self.show_icon(elem) else: @@ -76,9 +76,9 @@ class Test_Instructions(Test_Test): self.show_svg() def show_ok(self,id): - id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}ok.png" + id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}img/ok.png" def show_ko(self,id): - id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}arw-yel-down.png" + id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}img/arw-yel-down.png" def show_icon(self,id): id.set("display", "inline") @@ -87,7 +87,7 @@ class Test_Instructions(Test_Test): id.set("display", "none") def show_tape(self,id): - id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}tape_black.png" + id.attrib["{http://www.w3.org/1999/xlink}href"]= f"{self.svg_path}img/tape_black.png" id.set("display", "inline") def hide_tape(self,id): @@ -110,13 +110,14 @@ class Test_Instructions(Test_Test): ok = True if len(data[0]["digital_io"])==0: return - for sensor_index,sensor in enumerate(self.ids): + for sensor in self.monitored_ids: + sensor_index = int(sensor.attrib['id'].split("_")[1])-3 byte_idx=int(sensor_index/8) bit_idx=sensor_index%8 if data[0]["digital_io"][byte_idx][bit_idx]: - self.inputs[sensor_index]["status"]=True + self.inputs[sensor_index] = True else: - self.inputs[sensor_index]["status"] = False + self.inputs[sensor_index] = False ok = False if ok: super().get([{