Added ease-of-access function update_parameters to OTFModule. Updated code reference
This commit is contained in:
@@ -18,6 +18,8 @@ import frappy_psi.tnmr.sequence_generation as seq_gen
|
||||
import frappy.core as fc
|
||||
import frappy
|
||||
|
||||
from frappy.errors import ProgrammingError
|
||||
|
||||
import win32com
|
||||
import pythoncom
|
||||
import numpy as np
|
||||
@@ -27,6 +29,8 @@ import time
|
||||
import os
|
||||
import traceback
|
||||
|
||||
TNMR_MAX_PULSES = 100
|
||||
|
||||
class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
"""An NMR device being driven by an instance of TNMR. Requires that an instance of TNMR is opened before creation.
|
||||
|
||||
@@ -43,6 +47,8 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
|
||||
Acquisition Parameters
|
||||
----------------------
|
||||
These parameters can be set from a dictionary, using the update_parameters method/command.
|
||||
|
||||
title: a title which will be embedded to the sequence files. Use this for identification.
|
||||
acquisition_time: float (usecs) which describes the length of acquisition
|
||||
ringdown_time: float (usecs) which describes the length of ringdown
|
||||
@@ -51,6 +57,7 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
acq_phase_cycle: str, the phase cycle to run on acquisition (eg., '0 1 1 2', '0 1 2 3', '1 1 2 2 0 0 3 3 1 2 3 4', ...)
|
||||
num_acqs: int (ct), the number of 1D scans to take per sequence
|
||||
obs_freq: float (MHz), the NMR frequency
|
||||
|
||||
|
||||
Commands
|
||||
--------
|
||||
@@ -90,7 +97,7 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
sequence_data = fc.Parameter('sequence_config', fc.ArrayOf(fc.StructOf(pulse_width=fc.FloatRange(unit='usecs'),
|
||||
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':''}]*100, readonly=False)
|
||||
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)
|
||||
|
||||
# final details
|
||||
@@ -155,6 +162,14 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
except:
|
||||
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
|
||||
|
||||
@@ -246,7 +261,7 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
seq = []
|
||||
seq += t
|
||||
print(seq)
|
||||
seq += [{'pulse_width':0,'pulse_height':0,'delay_time':0,'phase_cycle':''}] * (100-self.sequence_length) # because nicos will only send the smallest size it has ever sent...
|
||||
seq += [{'pulse_width':0,'pulse_height':0,'delay_time':0,'phase_cycle':''}] * (TNMR_MAX_PULSES-self.sequence_length) # because nicos will only send the smallest size it has ever sent...
|
||||
self.sequence_data = seq
|
||||
|
||||
return self.read_sequence_data()
|
||||
@@ -336,10 +351,10 @@ class ProgrammedSequence(fc.Drivable): # Drivable only for kill() funcitonality
|
||||
# then, load the thing into TNMR
|
||||
success = self.tnmr().load_sequence(filename)
|
||||
if not(success):
|
||||
print('Retrying load sequence')
|
||||
self.logger.info('Retrying load pulse sequence')
|
||||
success = self.tnmr().load_sequence(filename)
|
||||
if not(success):
|
||||
print('WARNING: Failed!')
|
||||
self.logger.info('Failed pulse sequence load!')
|
||||
raise Exception()
|
||||
|
||||
# load some parameters back to TNMR
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user