dev wip
This commit is contained in:
parent
d4e18cd249
commit
d05d94ed7f
@ -1,7 +1,7 @@
|
||||
from time import perf_counter, time
|
||||
|
||||
ref = time() - perf_counter()
|
||||
|
||||
pass
|
||||
|
||||
def timing():
|
||||
global ref
|
||||
|
||||
@ -4,31 +4,43 @@ import nfc
|
||||
from nfc.clf import RemoteTarget
|
||||
|
||||
clf = nfc.ContactlessFrontend()
|
||||
assert clf.open('tty:USB0:pn532') is True # open /dev/ttyUSB0 with pn532 driver
|
||||
|
||||
connected=False
|
||||
while True:
|
||||
target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
|
||||
if target is not None:
|
||||
tag = nfc.tag.activate(clf, target)
|
||||
print(tag)
|
||||
if tag.ndef is not None:
|
||||
for record in tag.ndef.records:
|
||||
print(record)
|
||||
else:
|
||||
print("EMPTY TAG - WRITING...")
|
||||
if not tag.ndef.is_writeable:
|
||||
print("This Tag is not writeable.")
|
||||
break
|
||||
tag.format()
|
||||
ret = tag.wr
|
||||
try:
|
||||
if not connected:
|
||||
connected=clf.open('tty:USB0:pn532')
|
||||
if connected:
|
||||
target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
|
||||
if target is not None:
|
||||
tag = nfc.tag.activate(clf, target)
|
||||
if tag is not None:
|
||||
print(tag)
|
||||
if tag.ndef is not None:
|
||||
if not len(tag.ndef.records):
|
||||
print("EMPTY TAG - WRITING...")
|
||||
if not tag.ndef.is_writeable:
|
||||
print("This Tag is not writeable.")
|
||||
break
|
||||
else:
|
||||
tag.format()
|
||||
#tag.ndef.records = [ndef.TextRecord("Errecinque"),ndef.TextRecord("5812345678")]
|
||||
record=ndef.TextRecord("Errecinque,fixture,5812345678")
|
||||
tag.ndef.records = [record]
|
||||
if tag.ndef.has_changed:
|
||||
print("WRITE ERROR")
|
||||
else:
|
||||
print("WRITE OK")
|
||||
|
||||
if ret:
|
||||
print("ERROR")
|
||||
for record in tag.ndef.records:
|
||||
print(record)
|
||||
else:
|
||||
print("ERROR NOT NDEF")
|
||||
else:
|
||||
print("OK")
|
||||
else:
|
||||
print("NO TARGET")
|
||||
time.sleep(0.1)
|
||||
print("NO TARGET")
|
||||
except Exception as e:
|
||||
print(f"EXCEPTION {e}")
|
||||
connected=False
|
||||
time.sleep(0.3)
|
||||
|
||||
print("EXITING")
|
||||
clf.close()
|
||||
@ -461,7 +461,11 @@ class Test(Widget):
|
||||
self.next()
|
||||
|
||||
def done(self, ok=True):
|
||||
self.log.info("cycle done")
|
||||
self.log.info("cycle done, saving data...")
|
||||
|
||||
#remove useless info
|
||||
self.data.get("spec",{}).pop("steps")
|
||||
self.data.get("spec",{}).pop("available_steps")
|
||||
if "vision" in self.data:
|
||||
vision_test_1 = self.data.get("vision", {}).get("0", {})
|
||||
out_paths = self.components["vision_saver"].save(
|
||||
|
||||
@ -150,7 +150,8 @@ class Test_Leak(Test_Test):
|
||||
for k, l in {
|
||||
"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 differential pressure output": self.leak_l,
|
||||
"Running test: measured leak": self.leak_l,
|
||||
"Real time pressure line regulator": self.regulated_pressure_l,
|
||||
# "Active alarm flags": self._l,
|
||||
"Running test: test type": self.test_type_l,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
import sys
|
||||
import time
|
||||
import weakref
|
||||
from datetime import datetime
|
||||
|
||||
from lib.helpers import timing
|
||||
from PyQt5.QtCore import Qt, QTimer, pyqtSignal
|
||||
@ -119,6 +121,7 @@ class Test_Test(Widget):
|
||||
self.last = None
|
||||
|
||||
def get(self, data=None, override=False, fail=False, preserve_counter=False, skip_delay=False):
|
||||
cur_timing = timing()
|
||||
if self.done: # avoid proccessing if completed
|
||||
return
|
||||
if data is None:
|
||||
@ -130,17 +133,18 @@ class Test_Test(Widget):
|
||||
else:
|
||||
data = data[-data_usable.index(True) - 1]
|
||||
if data.get("time", None) is None:
|
||||
data["time"] = timing()
|
||||
data["time"] = datetime.now().strftime("%H:%M:%S")
|
||||
if fail:
|
||||
result_ok = False
|
||||
elif override:
|
||||
result_ok = True
|
||||
else:
|
||||
result_ok = data.get("results", {}).get("ok", None)
|
||||
duration=cur_timing - self.start_time
|
||||
self.last = {
|
||||
**data,
|
||||
"overridden": override,
|
||||
"duration": timing() - self.start_time,
|
||||
"duration": f"{duration:.2f}",
|
||||
"ok": result_ok,
|
||||
}
|
||||
if fail:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user