-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDP_Config.py
89 lines (86 loc) · 2.44 KB
/
SDP_Config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Project: Serial Data Plotter
# provides default config for SerialDataPlotter.py
import json
def parseconfig(file):
# parse the config file
# check if all keys are present
with open(file) as f:
config = json.load(f)
default_config = getdefaultconfig()
for key in default_config:
if key not in config:
config[key] = default_config[key]
print(F'SDP_Config: Added missing key "{key}" to config')
return config
def getdefaultconfig():
# config file is a json file with the following structure:
default_config = """
{
"title": "Liveplot of serial data",
"background": "k",
"foreground": "w",
"framecolor": null,
"com": "COM3",
"plots": 3,
"autostart": false,
"samples": 500,
"refresh": 40,
"delimiter": ";",
"autoscaleinterval": 150,
"csvpath": "<home>/Documents/data_<date>_<time>.csv",
"cmdstartwritecsv": null,
"cmdstopwritecsv": null,
"cmdconnect": null,
"channels": [
{
"label": "Channel 1",
"color": "#FF00FF",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
},
{
"label": "Channel 2",
"color": "#FF0000",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
},
{
"label": "Channel 3",
"color": "#00FF00",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
},
{
"label": "Channel 4",
"color": "#0000FF",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
},
{
"label": "Channel 5",
"color": "#FFFF00",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
},
{
"label": "Channel 6",
"color": "#00FFFF",
"offset": 0,
"scale_factor": 1,
"min": null,
"max": null
}
]
}
"""
return json.loads(default_config)