diff --git a/frappy_psi/tnmr/OTFModule.py b/frappy_psi/tnmr/OTFModule.py index cc67bb26..7efcae99 100644 --- a/frappy_psi/tnmr/OTFModule.py +++ b/frappy_psi/tnmr/OTFModule.py @@ -309,7 +309,8 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality self.approx_sequence_length += float(self.post_acquisition_time)*1e-6 # then, save the thing - filepath = os.getcwd() + # save it in a reasonable location, within frappy + filepath = os.path.dirname(os.path.realpath(__file__)) filename = self.title + f'_{time.time()}' filename = filepath + '/sequences/' + filename.replace('.','') seq_gen.save_sequence(filename, seq) diff --git a/frappy_psi/tnmr/sequence_fileformat.py b/frappy_psi/tnmr/sequence_fileformat.py index 51af2ff9..744b1093 100644 --- a/frappy_psi/tnmr/sequence_fileformat.py +++ b/frappy_psi/tnmr/sequence_fileformat.py @@ -211,7 +211,7 @@ def get_event_header(event_type, vals, tables, table_reg, tuning_number, col_del if(len(codes) == 6): # regular header headerstr += f'{tuning_number}{Z*3}{codes[0]}1{codes[1]}{codes[2]}' headerstr += f'{codes[5]}{Z*3}{codes[3]}{codes[4]}{Z*2}\x01' - elif(len(codes) == 4): # exteension + elif(len(codes) == 4): # extension headerstr += f'{tuning_number}{Z*3}{codes[0]}{Z*3}{codes[1]}{Z*3}{codes[2]}{Z*3}{codes[3]}' else: print('PANIC') diff --git a/frappy_psi/tnmr/sequences/.touch b/frappy_psi/tnmr/sequences/.touch new file mode 100644 index 00000000..e69de29b diff --git a/frappy_psi/tnmr/tnmr_interface.py b/frappy_psi/tnmr/tnmr_interface.py index 551847c4..5b937c0a 100644 --- a/frappy_psi/tnmr/tnmr_interface.py +++ b/frappy_psi/tnmr/tnmr_interface.py @@ -17,6 +17,8 @@ import win32com.client import pythoncom import frappy_psi.tnmr.NTNMR as NTNMR +import winapps + import time import json import traceback @@ -102,8 +104,21 @@ class TNMR: pythoncom.CoInitialize() return win32com.client.GetActiveObject("NTNMR.Application") except pythoncom.com_error: + try: + self.open_TNMR() + time.sleep(10) + # try again + pythoncom.CoInitialize() + return win32com.client.GetActiveObject("NTNMR.Application") + except: + raise TNMRNotRunnningError raise TNMRNotRunnningError + def open_TNMR(self): + '''Tries to open up TNMR, using its registration in the Windows registry''' + for app in winapps.search_installed('TNMR'): + os.system('start ' + str(app.install_location.absolute()) + '\\bin\\TNMR.exe') + def execute_cmd(self, cmd): '''Sends an arbitrary command through to TNMR''' print('W: Executing arbitrary command: ' + f'out = self.get_instance().{cmd}')