2022-07-12 12:49:39 +00:00
|
|
|
import weakref
|
|
|
|
|
|
2022-07-12 08:48:04 +00:00
|
|
|
from ui.test_test import Test_Test
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Test_Leak(Test_Test):
|
2022-07-19 09:59:00 +00:00
|
|
|
def __init__(self, components=None, recipe=None, step=None):
|
|
|
|
|
super().__init__(components=components, recipe=recipe, step=step)
|
2022-07-12 12:49:39 +00:00
|
|
|
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())
|
2022-07-12 12:28:19 +00:00
|
|
|
|
2022-07-19 09:59:00 +00:00
|
|
|
def start(self, recipe=None, step=None):
|
|
|
|
|
super().start(recipe=recipe, step=step)
|
2022-07-12 08:48:04 +00:00
|
|
|
# setup test loop
|
2022-07-19 09:59:00 +00:00
|
|
|
self.components["tecna_t3"].write_recipe(self.recipe, self.step)
|
2022-07-12 08:48:04 +00:00
|
|
|
self.get_connection = self.components["tecna_t3"].out.connect(self.get)
|
|
|
|
|
self.components["tecna_t3"].resume()
|
|
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
|
# disable tes loop
|
|
|
|
|
self.components["tecna_t3"].stop_test()
|
|
|
|
|
self.components["tecna_t3"].pause()
|
|
|
|
|
self.disconnect(self.get_connection)
|
|
|
|
|
super().stop()
|
|
|
|
|
|
|
|
|
|
def get(self, data=None, override=False):
|
2022-07-27 12:54:19 +00:00
|
|
|
if self.done: # avoid proccessing if completed
|
2022-07-12 08:48:04 +00:00
|
|
|
return
|
|
|
|
|
if data is None or data[-1] is None:
|
|
|
|
|
super().get(None, override=override)
|
|
|
|
|
return
|
|
|
|
|
data = data[-1]
|
2022-07-18 10:32:05 +00:00
|
|
|
if "Running test: result" in data["tecna_t3"]:
|
|
|
|
|
result = data["tecna_t3"]["Running test: result"]
|
|
|
|
|
ok = type(result) is str and "passed" in result.lower()
|
|
|
|
|
else:
|
|
|
|
|
result = None
|
2022-07-19 09:59:00 +00:00
|
|
|
ok = None
|
2022-07-12 08:48:04 +00:00
|
|
|
super().get([{
|
|
|
|
|
"time": data.get("time", None),
|
|
|
|
|
"results": {
|
2022-07-18 10:32:05 +00:00
|
|
|
"ok": ok,
|
|
|
|
|
"result": result,
|
2022-07-12 08:48:04 +00:00
|
|
|
"data": data["tecna_t3"],
|
|
|
|
|
},
|
2022-07-19 09:59:00 +00:00
|
|
|
}], override=override, fail=ok is False)
|
2022-07-12 08:48:04 +00:00
|
|
|
|
|
|
|
|
def visualize(self, data=None):
|
|
|
|
|
if data is None:
|
|
|
|
|
data = {}
|
|
|
|
|
d = data.get("results", {}).get("data", {})
|
2022-07-25 13:36:42 +00:00
|
|
|
for k, l in {
|
2022-07-18 10:32:05 +00:00
|
|
|
"Running test: active phase": self.test_phase_l,
|
|
|
|
|
"Real time test pressure output": self.circuit_pressure_l,
|
|
|
|
|
"Real time differential pressure output": self.leak_l,
|
|
|
|
|
"Real time pressure line regulator": self.regulated_pressure_l,
|
2022-07-12 08:48:04 +00:00
|
|
|
# "Active alarm flags": self._l,
|
2022-07-18 10:32:05 +00:00
|
|
|
"Running test: test type": self.test_type_l,
|
|
|
|
|
"Running test: sequence index": self.sequence_index_l,
|
2022-07-12 08:48:04 +00:00
|
|
|
}.items():
|
2022-07-27 15:09:17 +00:00
|
|
|
v = d.get(k, "-")
|
|
|
|
|
if type(v) is float:
|
|
|
|
|
v = round(v, 2)
|
|
|
|
|
l.setText(str(v))
|
2022-07-12 08:48:04 +00:00
|
|
|
super().visualize(data)
|
|
|
|
|
|
|
|
|
|
def save_last(self):
|
|
|
|
|
if self.last is None:
|
|
|
|
|
return
|