@@ -244,35 +244,35 @@ def start_timer(self):
244
244
"""
245
245
global start_time , last_ten_minute_time , total_packet_count , cumulative_packet_count
246
246
current_time = time .time ()
247
- start_time = current_time # Session start time
248
- last_ten_minute_time = current_time # 10-minute interval start time
249
- total_packet_count = 0 # Counter for packets in current second
250
- cumulative_packet_count = 0 # Counter for all packets
247
+ self . start_time = current_time # Session start time
248
+ self . last_ten_minute_time = current_time # 10-minute interval start time
249
+ self . total_packet_count = 0 # Counter for packets in current second
250
+ self . cumulative_packet_count = 0 # Counter for all packets
251
251
252
252
def log_one_second_data (self ):
253
253
"""
254
254
Log data for one second intervals and displays: Number of packets received in the last second, Number of missing samples (if any)
255
255
"""
256
256
global total_packet_count , samples_per_second , missing_samples
257
- samples_per_second = total_packet_count
257
+ self . samples_per_second = total_packet_count
258
258
print (f"Data count for the last second: { total_packet_count } samples, " f"Missing samples: { missing_samples } " )
259
- total_packet_count = 0 # Reset for next interval
259
+ self . total_packet_count = 0 # Reset for next interval
260
260
261
261
def log_ten_minute_data (self ):
262
262
"""
263
263
Log data for 10-minute intervals and displays: Total packets received, Actual sampling rate, Drift from expected rate
264
264
"""
265
265
global cumulative_packet_count , last_ten_minute_time , supported_boards , board
266
- print (f"Total data count after 10 minutes: { cumulative_packet_count } " )
267
- sampling_rate = cumulative_packet_count / (10 * 60 ) # Calculate actual sampling rate
266
+ print (f"Total data count after 10 minutes: { self . cumulative_packet_count } " )
267
+ sampling_rate = self . cumulative_packet_count / (10 * 60 ) # Calculate actual sampling rate
268
268
print (f"Sampling rate: { sampling_rate :.2f} samples/second" )
269
- expected_sampling_rate = supported_boards [board ]["sampling_rate" ]
269
+ expected_sampling_rate = self . supported_boards [board ]["sampling_rate" ]
270
270
drift = ((sampling_rate - expected_sampling_rate ) / expected_sampling_rate ) * 3600 # Calculate drift from expected rate
271
271
print (f"Drift: { drift :.2f} seconds/hour" )
272
272
273
273
# Reset counters
274
- cumulative_packet_count = 0
275
- last_ten_minute_time = time .time ()
274
+ self . cumulative_packet_count = 0
275
+ self . last_ten_minute_time = time .time ()
276
276
277
277
if __name__ == "__main__" :
278
278
client = Chords_USB () # Create and run the USB client
0 commit comments