debugged for Q mode integration

This commit is contained in:
gertjan 2026-03-24 01:28:34 +01:00
parent f73dcd0a22
commit a64bfe98c5

View file

@ -18,16 +18,15 @@ blacklist = []
Inoise_baseline = 0.1
PATTERN = re.compile(
r"Va=(?P<Va>[\d.-]+)\s+Vp=(?P<Vp>[\d.-]+)\s+\|\s+"
r"Ia=(?P<Ia>[\d.-]+)\s+Ip=(?P<Ip>[\d.-]+)\s+\|\s+"
r"ZR=(?P<ZR>[\d.-]+)\s+ZX=(?P<ZX>[\d.-]+).*?\|\s+" # Skips R=...
r".*?irq=\w+\s+" # Skips the first irq value (59)
r"Va=(?P<Va>[\d.-]+)\s+Vp=(?P<Vp>[\d.-]+)\s*\|\s*"
r"Ia=(?P<Ia>[\d.-]+)\s+Ip=(?P<Ip>[\d.-]+)\s*\|\s*"
r"ZR=(?P<ZR>[\d.-]+)\s+ZX=(?P<ZX>[\d.-]+).*?\|\s*"
r".*?irq=\w+\s+"
r"(?P<adc_vmin>[0-9a-fA-F]+)-(?P<adc_vmax>[0-9a-fA-F]+)\s+"
r"(?P<adc_imin>[0-9a-fA-F]+)-(?P<adc_imax>[0-9a-fA-F]+).*?\|\s+"
r"nv=(?P<nv>[\d.-]+)\s+ni=(?P<ni>[\d.-]+)"
r"(?P<adc_imin>[0-9a-fA-F]+)-(?P<adc_imax>[0-9a-fA-F]+).*?\|\s*"
r"nv=(?P<nv>[\d.-]+)\s+ni=(?P<ni>[\d.-]+)\s*\|\s*"
r"QZR=(?P<QZR>[\d.-]+)\s+QZX=(?P<QZX>[\d.-]+)"
)
Va=16.376152 Vp=5.82 | Ia=30.656820 Ip=5.84 | ZR=0.534176 ZX=-0.000190 R=516.000 | freq=1000.0 ampl=100.0 | BW=0.500| irq=59 0c-7b 18-83 | nv=4.494 ni=8.487 | QZR=0.654321 QZX=12.123456
config_path = '/home/bart/python-scanner/config.yaml' # XXXDB
#config_path = 'config.yaml'
@ -64,7 +63,7 @@ def dump_into_database():
if state["noise_scan"]==False:
# regular scan data
formatted_rows = [
[sweep_insert_time, r[0], r[5], r[6], r[1], r[2], r[3], r[4], r[11], r[12]]
[sweep_insert_time, r[0], r[13], r[14], r[1], r[2], r[3], r[4], r[11], r[12]]
for r in data_rows
]
sql = """
@ -98,7 +97,7 @@ def dump_into_database():
def dump_csv(filename="data.csv"):
df = pd.DataFrame(
data_rows,
columns=["Freq", "Va", "Vp", "Ia", "Ip", "ZR", "ZX", "adc_vmin", "adc_vmax", "adc_imin", "adc_imax", "nv", "ni"]
columns=["Freq", "Va", "Vp", "Ia", "Ip", "QZR", "QZX", "adc_vmin", "adc_vmax", "adc_imin", "adc_imax", "nv", "ni"]
)
df.to_csv(filename, index=False)
@ -151,6 +150,7 @@ def extract_to_dataframe(line):
float(match.group("QZR")), # row 13
float(match.group("QZX")), # row 14
]
# print(row) #### XX
data_rows.append(row)
def process_line(line):
@ -188,12 +188,14 @@ class TelnetReader:
# Main loop: reads incoming lines forever
try:
while state["freq"] > state["stop_freq"]:
line = self.tn.read_until(b"\n") # read line
if not line:
break
decoded = line.decode("utf-8", errors="ignore").strip()
self.process_line(decoded) # extract all info from line
if state["initializing"] == 1:
self.process_line("Va=")
else:
line = self.tn.read_until(b"\n") # read line
if not line:
break
decoded = line.decode("utf-8", errors="ignore").strip()
self.process_line(decoded) # extract all info from line
except KeyboardInterrupt:
print("Interrupted by user.")
@ -227,7 +229,7 @@ class TelnetReader:
# since we just start a frequency scan, let's set the R, Max and Amplitude
response = f"\rr516\r" # set Resistance value for scaling HAL sensor
self.tn.write(response.encode("utf-8"))
response = f"m1600\r" # set max amplitude value
response = f"m1600\r" # set max amplitude value
self.tn.write(response.encode("utf-8"))
# for noise scans the amplitude is zero, else the state["ampl"]
if state["noise_scan"]==True: