MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / run

Method run

examples/NI DAQmx/daqbridge.py:271–305  ·  view source on GitHub ↗

Main acquisition loop.

(self)

Source from the content-addressed store, hash-verified

269 self._loop_times = deque(maxlen=1000)
270
271 def run(self) -> None:
272 """Main acquisition loop."""
273 self.running = True
274 signal.signal(signal.SIGINT, self._signal_handler)
275 signal.signal(signal.SIGTERM, self._signal_handler)
276
277 print("=" * 50)
278 print("DAQBridge - NI DAQmx")
279 print("=" * 50)
280 print(f"Device: {DEVICE_NAME}")
281 print(f"Sample Rate: {SAMPLE_RATE} Hz | Samples/Read: {SAMPLES_PER_READ}")
282 print(f"UDP: {UDP_HOST}:{UDP_PORT}")
283 print(f"Channels: {self.num_channels}")
284 print("-" * 50)
285
286 try:
287 self.daq.setup()
288 print("Press Ctrl+C to stop\n")
289
290 while self.running:
291 loop_start = time.perf_counter()
292
293 raw_data = self.daq.read()
294 processed = process_readings(raw_data, CHANNEL_CONFIG)
295 self.publisher.publish(processed)
296
297 self._loop_times.append(time.perf_counter() - loop_start)
298 if ENABLE_STATS:
299 self._print_stats()
300
301 except Exception as e:
302 print(f"\nError: {e}")
303 raise
304 finally:
305 self._cleanup()
306
307 def _signal_handler(self, signum, frame) -> None:
308 print("\nShutting down...")

Callers 2

plc_simulator.pyFile · 0.45
daqbridge.pyFile · 0.45

Calls 8

_print_statsMethod · 0.95
_cleanupMethod · 0.95
process_readingsFunction · 0.85
signalMethod · 0.80
setupMethod · 0.80
publishMethod · 0.80
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected