@@ -249,6 +249,8 @@ def _run_start(self):
249
249
# Start sampling timer, initialise threshold, aquire first sample.
250
250
self .timer .init (freq = self .channel .sampling_rate )
251
251
self .timer .callback (self ._timer_ISR )
252
+ for trigger in self .triggers :
253
+ trigger .run_start ()
252
254
self ._timer_ISR (0 )
253
255
254
256
def _run_stop (self ):
@@ -354,7 +356,7 @@ def __init__(self, threshold, rising_event=None, falling_event=None):
354
356
raise ValueError ("Either rising_event or falling_event or both must be specified." )
355
357
self .rising_event = rising_event
356
358
self .falling_event = falling_event
357
- self .set_threshold ( threshold )
359
+ self .threshold = threshold
358
360
self .timestamp = 0
359
361
self .crossing_direction = False
360
362
assign_ID (self )
@@ -365,6 +367,9 @@ def _initialise(self):
365
367
self .falling_event_ID = sm .events [self .falling_event ] if self .falling_event in sm .events else False
366
368
self .threshold_active = self .rising_event_ID or self .falling_event_ID
367
369
370
+ def run_start (self ):
371
+ self .set_threshold (self .threshold )
372
+
368
373
def _process_interrupt (self ):
369
374
# Put event generated by threshold crossing in event queue.
370
375
if self .crossing_direction :
@@ -394,6 +399,15 @@ def set_threshold(self, threshold):
394
399
self .threshold = threshold
395
400
self .reset_above_threshold = True
396
401
402
+ fw .data_output_queue .put (
403
+ fw .Datatuple (
404
+ fw .current_time ,
405
+ fw .PRINT_TYP ,
406
+ "s" ,
407
+ "({}, {}) threshold = {}" .format (self .rising_event , self .falling_event , self .threshold ),
408
+ )
409
+ )
410
+
397
411
398
412
class Crossing :
399
413
above = "above"
@@ -420,12 +434,15 @@ class SchmittTrigger(IO_object):
420
434
def __init__ (self , bounds , rising_event = None , falling_event = None ):
421
435
if rising_event is None and falling_event is None :
422
436
raise ValueError ("Either rising_event or falling_event or both must be specified." )
423
- self .set_bounds (bounds )
424
437
self .rising_event = rising_event
425
438
self .falling_event = falling_event
439
+ self .bounds = bounds
426
440
self .timestamp = 0
427
441
assign_ID (self )
428
442
443
+ def run_start (self ):
444
+ self .set_bounds (self .bounds )
445
+
429
446
def set_bounds (self , threshold ):
430
447
if isinstance (threshold , tuple ):
431
448
threshold_requirements_str = "The threshold must be a tuple of two integers (lower_bound, upper_bound) where lower_bound <= upper_bound."
@@ -444,6 +461,17 @@ def set_bounds(self, threshold):
444
461
raise ValueError ("{} is not a valid threshold. {}" .format (threshold , threshold_requirements_str ))
445
462
self .reset_crossing = True
446
463
464
+ fw .data_output_queue .put (
465
+ fw .Datatuple (
466
+ fw .current_time ,
467
+ fw .PRINT_TYP ,
468
+ "s" ,
469
+ "({}, {}) bounds = ({},{})" .format (
470
+ self .rising_event , self .falling_event , self .upper_threshold , self .lower_threshold
471
+ ),
472
+ )
473
+ )
474
+
447
475
def _initialise (self ):
448
476
# Set event codes for rising and falling events.
449
477
self .rising_event_ID = sm .events [self .rising_event ] if self .rising_event in sm .events else False
0 commit comments