Minor changes, final backup. It's been real nice here at PSI.

This commit is contained in:
2025-08-29 09:19:07 +02:00
parent 0e01193240
commit 01dd256858
3 changed files with 11 additions and 17 deletions

View File

@@ -85,7 +85,8 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
default={ 'reals': [], 'imags': [], 't': [] }, readonly=True, visibility='w--')
status = fc.Parameter(datatype=frappy.datatypes.StatusType(fc.Drivable, "DISABLED", 'PREPARED', 'BUSY'), default=('IDLE', 'ok - uncompiled'))
pollinterval = fc.Parameter(default=1)
pollinterval = fc.Parameter(default=0.5)
slowinterval = fc.Parameter('slowinterval', fc.FloatRange(), default=0.5)
# basic
title = fc.Parameter('title', fc.StringType(), default='sequence', readonly=False)
@@ -98,7 +99,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
pulse_height=fc.FloatRange(unit='%'),
delay_time=fc.FloatRange(unit='usecs'),
phase_cycle=fc.StringType()), minlen=0), default=[{'pulse_width':0,'pulse_height':0,'delay_time':0,'phase_cycle':''}]*TNMR_MAX_PULSES, readonly=False)
num_acqs_actual = fc.Parameter('num_acqs', fc.IntRange(), readonly=True, default=0)
num_acqs_actual = fc.Parameter('actual_num_acqs', fc.IntRange(), readonly=True, default=0)
# final details
acquisition_time = fc.Parameter('acquisition_time', fc.FloatRange(unit='usecs'), readonly=False, group='sequence_editor', default=204.8) # this is a limit set by the dwell limit and number of acquisition points
@@ -163,14 +164,6 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
traceback.print_exc()
pass
@fc.Command(description='Updates any device parameters via a dictionary', argument={'type': 'dict'})
def update_parameters(self, dct):
for k, v in dct.items():
if(hasattr(self, k)):
setattr(self, k, v)
else:
self.logger.info(f'Bad TNMR parameter: {k}')
### READ/WRITE
def read_status(self):
@@ -279,6 +272,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
newvals['t'] = []
return newvals
#@fc.Command('pulls the number of acquisitions live. Better than waiting for a poll')
def read_num_acqs_actual(self):
try:
n = self.tnmr().get_nmrparameter('Actual Scans 1D')
@@ -287,7 +281,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
return 0
### PRIVATE (Utility)
def __compile_sequence(self):
def __compile_sequence(self, lockstatus=False):
'''Compiles the sequence loaded in sequence_data.
This involves:
@@ -362,6 +356,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
self.tnmr().set_nmrparameter(key, val)
# finally, let ourselves know we're ready
if not(lockstatus): # this is so that we don't get the weird situation of frappy thinking we're ready for new stuff before acquiring
self.status = ('PREPARED', 'compiled')
else:
traceback.print_exc()
@@ -370,6 +365,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
'''Tells TNMR to acquire data. Only call after __compile_sequence().'''
if(self.status[0] != 'BUSY' or self.starting):
self.tnmr().ZeroGo(lock=False, check_time=max(int(self.approx_sequence_length*1.5), 5))
self.actual_num_acqs = self.read_num_acqs_actual()
def __compile_and_run(self, thread=True):
'''Compiles and runs the currently-loaded sequence
@@ -379,8 +375,7 @@ class TNMRModule(fc.Drivable): # Drivable only for kill() funcitonality
thread: bool, determines if this should open a child thread and detach the process
'''
self.starting = True
self.__compile_sequence()
time.sleep(1.0)
self.__compile_sequence(lockstatus=True)
self.__zero_go()
self.starting = False

View File

@@ -341,7 +341,7 @@ def create_sequence_file(filename, data, author='NA'):
for i in column_names:
evnt_data_values += [ str(data['columns'][i][evnt]['value']) ]
evnt_data_tables += [ data['columns'][i][evnt]['table'] ]
content += get_event_header(evnt, evnt_data_values, evnt_data_tables, data['tables'], tuning_number, column_delays, data['num_acq_points'])
content += get_event_header(evnt, evnt_data_values, evnt_data_tables, data['tables'], tuning_number, column_delays, int(data['num_acq_points']))
content += ' '
content += get_table_spec(data['tables'])

View File

@@ -236,7 +236,6 @@ class TNMR:
print("Application locked during acquisition. Waiting...")
while self.acquisition_running():
time.sleep(interval)
# TODO: https://stackoverflow.com/questions/27586411/how-do-i-close-window-with-handle-using-win32gui-in-python to close any tecmag dialogues that show up. Need to determine proper search string, so next time it pops up, run some tests.
print("Acquisition done")
def acquisition_running(self):