implemented -- it runs C program and passes log filename to the plotter
This commit is contained in:
46
plotter.py
46
plotter.py
@ -4,6 +4,15 @@ from decimal import *
|
||||
from sys import argv
|
||||
|
||||
|
||||
t_x502_sync_mode = ["INTERNAL", "EXTERNAL_MASTER", "SYN1_RISE", "SYN1_FALL", "SYN2_RISE", "SYN2_FALL", "???"]
|
||||
t_x502_lch_mode = ["COMM", "DIFF", "ZERO", "???"]
|
||||
t_x502_adc_range = ["+-10V", "+-5V", "+-2V", "+-1V", "+-0.5V", "+-0.2V", "???"]
|
||||
|
||||
|
||||
|
||||
ADC_settings = {"sync_frec_source":"???", "sync_start_source": "???", "chans":{}}
|
||||
|
||||
|
||||
def main():
|
||||
chart = go.Figure()
|
||||
chart.add_trace(go.Scatter(x=[1,2,3], y=[1,2,3]))
|
||||
@ -11,6 +20,8 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("parsing")
|
||||
print("=======================")
|
||||
if len(argv) == 1:
|
||||
main()
|
||||
else:
|
||||
@ -33,9 +44,33 @@ if __name__ == "__main__":
|
||||
data[header] = []
|
||||
data[header + "_N"] = []
|
||||
data[header + "_hex"] = []
|
||||
data[header].append(int(value,16))
|
||||
value_unsigned = int(value, 16)
|
||||
if (value_unsigned > 0x7FFFFF):
|
||||
value_signed = (value_unsigned) - 0xFFFFFF
|
||||
else:
|
||||
value_signed = value_unsigned
|
||||
data[header].append(value_signed)
|
||||
data[header + "_hex"].append(value)
|
||||
data[header + "_N"].append(values_N)
|
||||
else:
|
||||
line_splt = line.split()
|
||||
print(line_splt)
|
||||
if line_splt[0] == "sync_frec_source:":
|
||||
val = int(line_splt[1])
|
||||
ADC_settings["sync_frec_source"] = t_x502_sync_mode[val]
|
||||
elif line_splt[0] == "sync_start_source:":
|
||||
val = int(line_splt[1])
|
||||
ADC_settings["sync_start_source"] = t_x502_sync_mode[val]
|
||||
elif line_splt[0] == "chan:":
|
||||
chan_N = int(line_splt[1][:-1])
|
||||
chan_mode = int(line_splt[3][:-1])
|
||||
chan_range = int(line_splt[5])
|
||||
ADC_settings["chans"][chan_N] = {"mode":t_x502_lch_mode[chan_mode], "range":t_x502_adc_range[chan_range]}
|
||||
else:
|
||||
print("strange line:")
|
||||
print(line)
|
||||
|
||||
|
||||
except ValueError:
|
||||
pass
|
||||
except IndexError:
|
||||
@ -45,12 +80,19 @@ if __name__ == "__main__":
|
||||
pass
|
||||
f.close()
|
||||
print("data samples:", values_N)
|
||||
print(ADC_settings)
|
||||
ADC_settings_str = ""
|
||||
ADC_settings_str += "sync_frec_source: " + ADC_settings["sync_frec_source"] + "<br>"
|
||||
ADC_settings_str += "sync_start_source: " + ADC_settings["sync_start_source"] + "<br>"
|
||||
for key, val in ADC_settings["chans"].items():
|
||||
ADC_settings_str += " chan" + str(key) + ": " + str(val)+ "<br>"
|
||||
print(ADC_settings_str)
|
||||
chart = go.Figure()
|
||||
chart.update_layout(title=argv[1] + "<br>" + ADC_settings_str)
|
||||
for key, val in data.items():
|
||||
if (key.count("_N") + key.count("_hex")) == 0:
|
||||
#print(key+"_hex :", data[key+"_hex"])
|
||||
chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines", text=data[key+"_hex"]))
|
||||
# chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines+markers", text=data[key+"_hex"]))
|
||||
chart.update_layout(title=argv[1])
|
||||
chart.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user