@@ -148,7 +148,7 @@ def get_board(self):
148148 (str): Either "pico1" for a Pi Pico 1 board or "pico2" for a Pi Pico 2 board.'''
149149 self .conn .write (b'board\n ' )
150150 resp = self .conn .readline ().decode ()
151- return ( resp )
151+ return resp
152152
153153 def get_freqs (self ):
154154 '''Responds with a dictionary containing
@@ -385,24 +385,17 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
385385 'phase' : cache_phase * self .intf .tuning_words_to_SI ['phase' ]
386386 }
387387
388+ if dds_data is None and stat_data is None :
389+ self .logger .debug ('No instructions to set' )
390+ return self .initial_values
391+
388392 if dds_data is not None :
389393 self .logger .debug (f'Dynamic Data found' )
390394
391- if self .smart_cache ['dds_data' ] is None :
392- # self.logger.debug('Initializing dds_data smart cache')
393- self .logger .debug ('First time run ' )
394- self .intf .set_channels (len (dyn_chans ))
395- self .intf .set_batch (dds_data )
396- self .intf .stop (len (dds_data ))
397- self .smart_cache ['dds_data' ] = dds_data .copy ()
398- self ._update_final_values (dds_data , dyn_chans )
399- self .intf .start ()
400- return self .final_values
401-
402395 # check if it is more efficient to fully refresh
403- ## define boolean mask of lines that differ here for later line-by-line programming
404- # if not fresh and self.smart_cache['dds_data'] is not None:
405- if not fresh :
396+ # using boolean mask of lines that differ here for later
397+ # line-by-line programming
398+ if not fresh and self . smart_cache [ 'dds_data' ] is not None :
406399 self .logger .debug ('Checking to see if more efficient to fully refresh' )
407400
408401 cache = self .smart_cache ['dds_data' ]
@@ -421,6 +414,9 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
421414 if changed_ratio > 0.1 :
422415 self .logger .debug (f'Changed ratio: { changed_ratio :.2%} , refreshing fully' )
423416 fresh = True
417+
418+ elif self .smart_cache ['dds_data' ] is None :
419+ fresh = True
424420
425421 # Fresh starts use the faster binary batch mode
426422 if fresh :
@@ -433,8 +429,8 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
433429 self ._update_final_values (dds_data , dyn_chans )
434430 self .intf .start ()
435431
436- # If only a few changes, it should be fast to go through and change
437- # just the new instructions
432+ # If only a few changes, incrementally program only the differing
433+ # instructions
438434 else :
439435 self .intf .set_channels (len (dyn_chans ))
440436 self .logger .debug ('Comparing changed instructions' )
@@ -490,11 +486,6 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
490486 self ._update_final_values (self .smart_cache ['dds_data' ], dyn_chans )
491487 self .intf .start ()
492488
493- if dds_data is None and stat_data is None :
494- self .logger .debug ('No instructions to set' )
495- return {}
496-
497- self .logger .debug ('Ending buffered execution\n ' )
498489 return self .final_values
499490
500491 def transition_to_manual (self ):
0 commit comments