Merge remote-tracking branch 'origin/st-ten-2' into st-ten-2

This commit is contained in:
matteo porta 2022-08-31 12:56:53 +02:00
commit c93a826b49
5 changed files with 35 additions and 14 deletions

View File

@ -9,4 +9,4 @@ tecna_t3: present
port: COM5 port: COM5
[multicomp] [multicomp]
port: COM4 port: COM8

View File

@ -10,7 +10,7 @@ from .component import Component
class Multicomp730424(Component): class Multicomp730424(Component):
def __init__(self, config=None, name=None, period=1, lazy=True, paused=False, threaded=True): def __init__(self, config=None, name=None, period=1/4, lazy=True, paused=False, threaded=True):
self.conn = None self.conn = None
super().__init__(config=config, name=name, period=period, lazy=lazy, paused=paused, threaded=threaded) super().__init__(config=config, name=name, period=period, lazy=lazy, paused=paused, threaded=threaded)
@ -29,8 +29,14 @@ class Multicomp730424(Component):
parity=self.parity, parity=self.parity,
bytesize=self.bytesize, bytesize=self.bytesize,
) )
self.write("FUNC1 \"RES\"")
self.write("RATE L")
self.write("AUTO 1")
def set_resistance_scale(self, resistance): def set_resistance_scale(self, resistance=None):
if resistance is None:
self.write("AUTO 1")
else:
self.write(f"CONF:RES {resistance}") self.write(f"CONF:RES {resistance}")
def read(self): def read(self):
@ -40,7 +46,7 @@ class Multicomp730424(Component):
self.log.exception(traceback.format_exc()) self.log.exception(traceback.format_exc())
return None return None
try: try:
decoded = response.decode("ascii") decoded = response.decode("ascii", errors="ignore").strip()
except UnicodeDecodeError: except UnicodeDecodeError:
return response return response
try: try:
@ -59,8 +65,9 @@ class Multicomp730424(Component):
info = {} info = {}
try: try:
for value_name, command in { for value_name, command in {
"scale": "CONF:RES?", "function": "FUNC1?",
"measure": "MEAS?", "scale": "RANGE?",
"measure": "MEAS1?",
}.items(): }.items():
self.write(command) self.write(command)
info[value_name] = self.read() info[value_name] = self.read()

View File

@ -3,7 +3,7 @@ import time
import serial import serial
# tester_port="/dev/ttyUSB0" # tester_port="/dev/ttyUSB0"
tester_port = "COM1" tester_port = "COM8"
conn = serial.Serial( conn = serial.Serial(
tester_port, tester_port,
@ -16,18 +16,28 @@ conn = serial.Serial(
cmd_list = [ cmd_list = [
["*IDN?\n", True], # QUERY ID ["*IDN?\n", True], # QUERY ID
["CONF:RES 500\n", False], # SET RESISTANCE MEASURE, 500 Ohm range ["FUNC1 \"RES\"\n", False], # QUERY ID
["MEAS?\n", True], # GET MEASURE ["FUNC1?\n", True], # QUERY ID
["MEAS?\n", True], # GET MEASURE ["FUNC2 \"FRES\"\n", False], # QUERY ID
["FUNC2?\n", True], # QUERY ID
["RATE L\n", True], # QUERY ID
["RATE?\n", True], # QUERY ID
["AUTO 1\n", False], # SET RESISTANCE MEASURE, 500 Ohm range
["AUTO?\n", True], # SET RESISTANCE MEASURE, 500 Ohm range
# ["CONF:RES 500\n", False], # SET RESISTANCE MEASURE, 500 Ohm range
# ["AUTO?\n", True], # SET RESISTANCE MEASURE, 500 Ohm range
["RANGE:RES?\n", True], # SET RESISTANCE MEASURE, 500 Ohm range
["MEAS?\n", True], # GET MEASURE ["MEAS?\n", True], # GET MEASURE
["MEAS1?\n", True], # GET MEASURE
["MEAS2?\n", True], # GET MEASURE
] ]
for [cmd, expect_response] in cmd_list: for [cmd, expect_response] in cmd_list:
conn.write(bytes(cmd, encoding="ascii")) conn.write(bytes(cmd, encoding="ascii"))
if expect_response: if expect_response:
response = conn.readline() response = conn.readline()
print(f"{cmd} RESPONSE: " + response.decode("ascii")) print(f"{cmd} RESPONSE: " + response.decode("ascii", errors="backslashreplace"))
else: else:
print(f"{cmd}") print(f"{cmd}")
time.sleep(1) # time.sleep(1)
conn.close() conn.close()

View File

@ -2,6 +2,10 @@ from ui.test_test import Test_Test
class Test_Resistance(Test_Test): class Test_Resistance(Test_Test):
def __init__(self, components=None, recipe=None, step=None, run_once=False):
super().__init__(components=components, recipe=recipe, step=step, run_once=run_once)
self.ok_counter_limit = 4
def start(self, recipe=None, step=None): def start(self, recipe=None, step=None):
super().start(recipe=recipe, step=step) super().start(recipe=recipe, step=step)
if self.run_once is True and self.done is True and self.done_ok is True: if self.run_once is True and self.done is True and self.done_ok is True:

View File

@ -11,6 +11,7 @@ class Test_Vision(Test_Test):
request_frame = pyqtSignal() request_frame = pyqtSignal()
def __init__(self, components=None, recipe=None, step=None, run_once=False): def __init__(self, components=None, recipe=None, step=None, run_once=False):
super().__init__(components=components, recipe=recipe, step=step, run_once=run_once)
if "--sim-camera" not in sys.argv: if "--sim-camera" not in sys.argv:
self.ok_counter_limit = 2 self.ok_counter_limit = 2
else: else:
@ -21,7 +22,6 @@ class Test_Vision(Test_Test):
"expected": "ATTESO", "expected": "ATTESO",
"score": "PUNTEGGIO", "score": "PUNTEGGIO",
} }
super().__init__(components=components, recipe=recipe, step=step, run_once=run_once)
self.results_tw.setColumnCount(len(self.results_table_headers)) self.results_tw.setColumnCount(len(self.results_table_headers))
self.results_tw.setHorizontalHeaderLabels(self.results_table_headers.values()) self.results_tw.setHorizontalHeaderLabels(self.results_table_headers.values())
self.results_tw.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.results_tw.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)