|
7 | 7 | from math import floor, log2, log10 |
8 | 8 | import shutil |
9 | 9 | import os |
| 10 | +import toml |
10 | 11 |
|
11 | 12 | def dataImporter(name): |
12 | 13 |
|
@@ -104,34 +105,31 @@ def BitEnumSelector(bits): |
104 | 105 |
|
105 | 106 | def saveConfigFile(channels, bits, sampleRate,captureLength, segments): |
106 | 107 |
|
107 | | - configValues = [channels, bits, sampleRate, captureLength, segments] |
| 108 | + # configValues = [channels, bits, sampleRate, captureLength, segments] |
| 109 | + data = { |
| 110 | + "Active Channels" : channels, |
| 111 | + "Scope Bit Resolution" : bits, |
| 112 | + "Sampling Rate (MHz)" : sampleRate, |
| 113 | + "Capture Length (Samples)" : captureLength, |
| 114 | + "Number of Capture Segments for Rapid Block" : segments, |
| 115 | + } |
| 116 | + # # Save the list to a text file |
| 117 | + with open('configValues.toml', 'w') as file: |
| 118 | + toml.dump(data,file) |
108 | 119 |
|
109 | | - # Save the list to a text file |
110 | | - with open('configValues.txt', 'w') as file: |
111 | | - # Write each element of the list on a new line |
112 | | - for value in configValues: |
113 | | - file.write(f"{value}\n") |
114 | 120 |
|
115 | 121 | return |
116 | 122 |
|
117 | 123 | def loadConfigValues(): |
118 | 124 |
|
119 | | - restored_configValues = [] |
120 | | - |
121 | | - with open('configValues.txt', 'r') as file: |
122 | | - for line in file: |
123 | | - value = line.strip() |
124 | | - # Convert to integer or float as necessary |
125 | | - if '.' in value: |
126 | | - restored_configValues.append(float(value)) |
127 | | - else: |
128 | | - restored_configValues.append(int(value)) |
| 125 | + with open('configValues.toml', 'r') as file: |
| 126 | + restored_configValues = toml.load(file) |
129 | 127 |
|
130 | | - channels = restored_configValues[0] |
131 | | - bits = restored_configValues[1] |
132 | | - sampleRate = restored_configValues[2] |
133 | | - captureLength = restored_configValues[3] |
134 | | - segments = restored_configValues[5] |
| 128 | + channels = int(restored_configValues["Active Channels"]) |
| 129 | + bits = int(restored_configValues["Scope Bit Resolution"]) |
| 130 | + sampleRate = float(restored_configValues["Sampling Rate (MHz)"]) |
| 131 | + captureLength = int(float(restored_configValues["Capture Length (Samples)"])) |
| 132 | + segments = int(restored_configValues["Number of Capture Segments for Rapid Block"]) |
135 | 133 |
|
136 | 134 | return channels, bits, sampleRate, captureLength, segments |
137 | 135 |
|
|
0 commit comments