2 global DlogFile, Dlog_open, dlog, UserAString, UserBString, MeasUserA, MeasUserB
4 tstr1 = time.time()-Ztime
5 DlogString =
'{0:.3f}, '.format(tstr1)
6 if MeasUserA.get() == 1:
8 TempValue = eval(UserAString)
9 V1String =
'{0:.4f}'.format(TempValue) +
", "
12 DlogString = DlogString + V1String
13 if MeasUserB.get() == 1:
15 TempValue = eval(UserBString)
16 V1String =
'{0:.4f} '.format(TempValue) +
", "
19 DlogString = DlogString + V1String
20 DlogString = DlogString +
" \n"
21 DlogFile.write( DlogString )
24 global Dlog_open, dlog, Ztime
25 if Dlog_open.get() == 1
and dlog.get() > 0:
27 elif Dlog_open.get() == 0
and dlog.get() > 0:
37 Filemenu.menu.add_checkbutton(label=
'"DLog to file"', variable=dlog, command=Dloger_on_off)
41 global DlogFile, Dlog_open, dlog
45 print(
"Opening Dlog file")
48 print(
"Closing Dlog file")
51 global DlogFile, Dlog_open, dlog
53 if Dlog_open.get() == 1:
56 print(
"Closing Dlog file")
63 global DlogFile, Dlog_open, dlog
66 tme = strftime(
"%Y%b%d-%H%M%S", gmtime())
67 filename =
"DataLogger-" + tme
68 filename = filename +
".csv"
70 DlogFile = open(filename,
'a')
72 filename = asksaveasfilename(defaultextension =
".csv", filetypes=[(
"Comma Separated Values",
"*.csv")])
73 DlogFile = open(filename,
'a')
74 DlogFile.write(
'Time, UserA, UserB \n' )
78 global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
79 global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
80 global SV1, SI1, SV2, SI2, CHABphase, SVA_B
81 global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
82 global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
83 global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
84 global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
85 global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
86 global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
87 global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
90 if FirstDlog.get() == 1:
92 filename = asksaveasfilename(defaultextension =
".csv", filetypes=[(
"Comma Separated Values",
"*.csv")])
93 DataFile = open(filename,
'w')
95 if MeasAHW.get() == 1:
96 txt = txt +
"CA Hi Width, "
97 if MeasALW.get() == 1:
98 txt = txt +
"CA Lo Width, "
99 if MeasADCy.get() == 1:
100 txt = txt +
"CA DutyCycle, "
101 if MeasAPER.get() == 1:
102 txt = txt +
"CA Period, "
103 if MeasAFREQ.get() == 1:
104 txt = txt +
"CA Freq, "
106 if MeasBHW.get() == 1:
107 txt = txt +
"CB Hi Width, "
108 if MeasBLW.get() == 1:
109 txt = txt +
"CB Lo Width, "
110 if MeasBDCy.get() == 1:
111 txt = txt +
"CB DutyCycle, "
112 if MeasBPER.get() == 1:
113 txt = txt +
"CB Period,"
114 if MeasBFREQ.get() == 1:
115 txt = txt +
"CB Freq, "
117 if MeasPhase.get() == 1:
118 txt = txt +
"CA-B Phase, "
119 if MeasDelay.get() == 1:
120 txt = txt +
"CB-A Delay, "
122 if MeasDCV1.get() == 1:
123 txt = txt +
"CA AvgV, "
124 if MeasMaxV1.get() == 1:
125 txt = txt +
"CA MaxV, "
126 if MeasTopV1.get() == 1:
127 txt = txt +
"CA Top, "
128 if MeasMinV1.get() == 1:
129 txt = txt +
"CA MinV, "
130 if MeasBaseV1.get() == 1:
131 txt = txt +
"CA Base, "
132 if MeasMidV1.get() == 1:
133 MidV1 = (MaxV1+MinV1)/2.0
134 txt = txt +
"CA MidV, "
135 if MeasPPV1.get() == 1:
137 txt = txt +
"CA P-PV, "
138 if MeasRMSV1.get() == 1:
139 txt = txt +
"CA RMS, "
140 if MeasRMSVA_B.get() == 1:
141 txt = txt +
"A-B RMS, "
142 if MeasDiffAB.get() == 1:
143 txt = txt +
"CA-CB, "
144 if MeasUserA.get() == 1:
145 txt = txt + UserALabel +
", "
147 if MeasDCI1.get() == 1:
148 txt = txt +
"CA AvgI, "
150 if MeasMaxI1.get() == 1:
151 txt = txt +
"CA MaxI, "
152 if MeasMinI1.get() == 1:
153 txt = txt +
"CA MinI, "
154 if MeasMidI1.get() == 1:
155 MidI1 = (MaxI1+MinI1)/2.0
156 txt = txt +
"CA MidV, "
157 if MeasPPI1.get() == 1:
159 txt = txt +
"CA P-PI, "
160 if MeasRMSI1.get() == 1:
161 txt = txt +
"CA RMS, "
163 if MeasDCV2.get() == 1:
164 txt = txt +
"CB AvgV' "
165 if MeasMaxV2.get() == 1:
166 txt = txt +
"CB MaxV, "
167 if MeasTopV2.get() == 1:
168 txt = txt +
"CB Top, "
169 if MeasMinV2.get() == 1:
170 txt = txt +
"CB MinV, "
171 if MeasBaseV2.get() == 1:
172 txt = txt +
"CB Base, "
173 if MeasMidV2.get() == 1:
174 MidV2 = (MaxV2+MinV2)/2.0
175 txt = txt +
"CB MidV, "
176 if MeasPPV2.get() == 1:
178 txt = txt +
"CB P-PV, "
179 if MeasRMSV2.get() == 1:
180 txt = txt +
"CB RMS, "
181 if MeasDiffBA.get() == 1:
182 txt = txt +
"CB-CA, "
183 if MeasUserB.get() == 1:
184 txt = txt + UserBLabel +
", "
185 if MeasDCI2.get() == 1:
186 txt = txt +
"CB AvgI, "
187 if MeasMaxI2.get() == 1:
188 txt = txt +
"CB MaxI, "
189 if MeasMinI2.get() == 1:
190 txt = txt +
"CB MinI, "
191 if MeasMidI2.get() == 1:
192 MidI2 = (MaxI2+MinI2)/2.0
193 txt = txt +
"CB MidV, "
194 if MeasPPI2.get() == 1:
196 txt = txt +
"CB P-PI, "
197 if MeasRMSI2.get() == 1:
198 txt = txt +
"CB RMS, "
201 if MeasAHW.get() == 1:
202 txt = txt +
'{0:.3f}'.format(CHAHW/Mulx) +
", "
203 if MeasALW.get() == 1:
204 txt = txt +
'{0:.3f}'.format(CHALW/Mulx) +
", "
205 if MeasADCy.get() == 1:
206 txt = txt +
'{0:.1f}'.format(CHADCy) +
", "
207 if MeasAPER.get() == 1:
208 txt = txt +
'{0:.3f}'.format(CHAperiod) +
", "
209 if MeasAFREQ.get() == 1:
210 txt = txt +
'{0:.3f}'.format(CHAfreq) +
", "
212 if MeasBHW.get() == 1:
213 txt = txt +
'{0:.3f}'.format(CHBHW/Mulx) +
", "
214 if MeasBLW.get() == 1:
215 txt = txt +
'{0:.3f}'.format(CHBLW/Mulx) +
", "
216 if MeasBDCy.get() == 1:
217 txt = txt +
'{0:.1f}'.format(CHBDCy) +
", "
218 if MeasBPER.get() == 1:
219 txt = txt +
'{0:.3f}'.format(CHBperiod) +
", "
220 if MeasBFREQ.get() == 1:
221 txt = txt +
'{0:.3f}'.format(CHBfreq) +
", "
222 if MeasPhase.get() == 1:
223 txt = txt +
'{0:.1f}'.format(CHABphase) +
", "
224 if MeasDelay.get() == 1:
225 txt = txt +
'{0:.3f}'.format(CHBADelayR1) +
", "
227 if MeasDCV1.get() == 1:
228 txt = txt +
'{0:.4f}'.format(DCV1)
229 if MeasMaxV1.get() == 1:
230 txt = txt +
'{0:.4f}'.format(MaxV1)
231 if MeasTopV1.get() == 1:
232 txt = txt +
'{0:.4f}'.format(VATop)
233 if MeasMinV1.get() == 1:
234 txt = txt +
'{0:.4f}'.format(MinV1)
235 if MeasBaseV1.get() == 1:
236 txt = txt +
'{0:.4f}'.format(VABase)
237 if MeasMidV1.get() == 1:
238 MidV1 = (MaxV1+MinV1)/2.0
239 txt = txt +
'{0:.4f}'.format(MidV1)
240 if MeasPPV1.get() == 1:
242 txt = txt +
'{0:.4f}'.format(PPV1)
243 if MeasRMSV1.get() == 1:
244 txt = txt +
'{0:.4f}'.format(SV1)
245 if MeasRMSVA_B.get() == 1:
246 txt = txt +
'{0:.4f}'.format(SVA_B)
247 if MeasDiffAB.get() == 1:
248 txt = txt +
'{0:.4f}'.format(DCV1-DCV2)
249 if MeasUserA.get() == 1:
251 TempValue = eval(UserAString)
252 V1String =
' {0:.4f}'.format(TempValue)
258 txt = txt + str(CH1IpdvRange) +
" mA/div"
259 elif (ShowC1_I.get() == 1
and ShowC1_V.get() == 1):
261 txt = txt + str(CH1IpdvRange) +
" mA/div"
262 if ShowC1_I.get() == 1:
263 if MeasDCI1.get() == 1:
264 V1String =
' {0:.2f} '.format(DCI1)
265 txt = txt +
" AvgI = " + V1String
267 if MeasMaxI1.get() == 1:
268 txt = txt +
" MaxI = " +
' {0:.2f} '.format(MaxI1)
269 if MeasMinI1.get() == 1:
270 txt = txt +
" MinI = " +
' {0:.2f} '.format(MinI1)
271 if MeasMidI1.get() == 1:
272 MidI1 = (MaxI1+MinI1)/2.0
273 txt = txt +
" MidV = " +
' {0:.2f} '.format(MidI1)
274 if MeasPPI1.get() == 1:
276 txt = txt +
" P-PI = " +
' {0:.2f} '.format(PPI1)
277 if MeasRMSI1.get() == 1:
278 txt = txt +
" RMS = " +
' {0:.2f} '.format(SI1)
280 if MeasDCV2.get() == 1:
281 txt = txt +
" AvgV = " +
' {0:.4f} '.format(DCV2)
282 if MeasMaxV2.get() == 1:
283 txt = txt +
" MaxV = " +
' {0:.4f} '.format(MaxV2)
284 if MeasTopV2.get() == 1:
285 txt = txt +
" Top = " +
' {0:.4f} '.format(VBTop)
286 if MeasMinV2.get() == 1:
287 txt = txt +
" MinV = " +
' {0:.4f} '.format(MinV2)
288 if MeasBaseV2.get() == 1:
289 txt = txt +
" Base = " +
' {0:.4f} '.format(VBBase)
290 if MeasMidV2.get() == 1:
291 MidV2 = (MaxV2+MinV2)/2.0
292 txt = txt +
" MidV = " +
' {0:.4f} '.format(MidV2)
293 if MeasPPV2.get() == 1:
295 txt = txt +
" P-PV = " +
' {0:.4f} '.format(PPV2)
296 if MeasRMSV2.get() == 1:
297 txt = txt +
" RMS = " +
' {0:.4f} '.format(SV2)
298 if MeasDiffBA.get() == 1:
299 txt = txt +
" CB-CA = " +
' {0:.4f} '.format(DCV2-DCV1)
300 if MeasUserB.get() == 1:
302 TempValue = eval(UserBString)
303 V1String =
' {0:.4f} '.format(TempValue)
306 txt = txt + UserBLabel +
" = " + V1String
307 if (ShowC2_I.get() == 1
and ShowC2_V.get() == 0):
309 txt = txt + str(CH2IpdvRange) +
" mA/div"
310 elif (ShowC2_I.get() == 1
and ShowC2_V.get() == 1):
312 txt = txt + str(CH2IpdvRange) +
" mA/div"
313 if ShowC2_I.get() == 1:
314 if MeasDCI2.get() == 1:
315 V1String =
' {0:.2f} '.format(DCI2)
316 txt = txt +
" AvgI = " + V1String
317 if MeasMaxI2.get() == 1:
318 txt = txt +
" MaxI = " +
' {0:.2f} '.format(MaxI2)
319 if MeasMinI2.get() == 1:
320 txt = txt +
" MinI = " +
' {0:.2f} '.format(MinI2)
321 if MeasMidI2.get() == 1:
322 MidI2 = (MaxI2+MinI2)/2.0
323 txt = txt +
" MidV = " +
' {0:.2f} '.format(MidI2)
324 if MeasPPI2.get() == 1:
326 txt = txt +
" P-PI = " +
' {0:.2f} '.format(PPI2)
327 if MeasRMSI2.get() == 1:
328 txt = txt +
" RMS = " +
' {0:.2f} '.format(SI2)
330 DataFile.write( txt +
'\n' )