seqfil = 'sammymstlk2d'

//------------------------------
// Receiver Delays
//------------------------------

exists('rd','parameter'):$e
if $e < 0.5 then
   create('rd','pulse')
   setlimit('rd',8192,0,0.0125)  
endif 

exists('ad','parameter'):$e
if $e < 0.5 then
   create('ad','pulse')
   setlimit('ad',8192,0,0.0125)  
endif

exists('ddrtc','parameter'):$e
if $e < 0.5 then
   create('ddrtc','pulse')
   setlimit('ddrtc',8192,0,0.0125)  
endif

//------------------------------
// Spin Rate
//------------------------------

exists('srate','parameter'):$e
if $e < 0.5 then
   create('srate','frequency')
endif 

exists('hsrotor','parameter'):$e
if $e < 0.5 then
   create('hsrotor','flag') 
endif

//------------------------------
// Basic Transmitter Properties
//------------------------------

exists('aX90','parameter'):$e
if $e < 0.5 then
   create('aX90','real')
   setlimit('aX90',4095,0,0)  
endif 

exists('aH90','parameter'):$e
if $e < 0.5 then
   create('aH90','real')
   setlimit('aH90',4095,0,0)  
endif 

exists('aY90','parameter'):$e
if $e < 0.5 then
   create('aY90','real')
   setlimit('aY90',4095,0,0)  
endif

exists('aZ90','parameter'):$e
if $e < 0.5 then
   create('aZ90','real')
   setlimit('aZ90',4095,0,0)  
endif

exists('pwX90','parameter'):$e
if $e < 0.5 then
   create('pwX90','pulse')
   setlimit('pwX90',8192,0,0.0125)
endif 

exists('pwH90','parameter'):$e
if $e < 0.5 then
   create('pwH90','pulse')
   setlimit('pwH90',8192,0,0.0125)
endif 

exists('pwY90','parameter'):$e
if $e < 0.5 then
   create('pwY90','pulse')
   setlimit('pwY90',8192,0,0.0125)
endif

exists('pwZ90','parameter'):$e
if $e < 0.5 then
   create('pwZ90','pulse')
   setlimit('pwZ90',8192,0,0.0125)
endif

//---------------
// cpHX elements
//---------------

exists('shHX','parameter'):$e
if $e < 0.5 then
    create('shHX','flag')
endif

exists('toHX','parameter'):$e
if $e < 0.5 then
   create('toHX','flag')
endif 
setvalue('toHX','obs')

exists('frHX','parameter'):$e
if $e < 0.5 then
   create('frHX','flag')
endif
setvalue('frHX','dec')  

exists('chHX','parameter'):$e
if $e < 0.5 then
   create('chHX','flag')
endif 

exists('aHhx','parameter'):$e
if $e < 0.5 then
   create('aHhx','real')
   setlimit('aHhx',4095,0,0)
endif 

exists('aXhx','parameter'):$e
if $e < 0.5 then
   create('aXhx','real')
   setlimit('aXhx',4095,0,0)
endif 

exists('bHX','parameter'):$e
if $e < 0.5 then
   create('bHX','real')
   setlimit('bHX',1000000,0,1.0e-6)
endif 

exists('dHX','parameter'):$e
if $e < 0.5 then
   create('dHX','real')
   setlimit('dHX',4095,-4095,1)
endif 

exists('tHX','parameter'):$e
if $e < 0.5 then
   create('tHX','pulse')
   setlimit('tHX',50000,0,0.0125)
endif
setlimit('tHX',20000,1.0,0.1)

exists('ofHX','parameter'):$e
if $e < 0.5 then
    create('ofHX','frequency')
endif  

//=====================
// decoupling options
//======================

exists('Hseq','parameter'):$e
if $e < 0.5 then
    create('Hseq','flag')
endif

//-----------
// tppm
//-----------

exists('aHtppm','parameter'):$e
if $e < 0.5 then
    create('aHtppm','real')
    setlimit('aHtppm',4095,0,0)
endif

exists('pwHtppm','parameter'):$e
if $e < 0.5 then
    create('pwHtppm','pulse')
    setlimit('pwHtppm',8192,0,0.0125)
endif

exists('phHtppm','parameter'):$e
if $e < 0.5 then
    create('phHtppm','real')
    setlimit('phHtppm',180,-180,0.0)
endif

exists('chHtppm','parameter'):$e
if $e < 0.5 then
   create('chHtppm','flag')
endif 
setvalue('chHtppm','dec')

//------------------------------
//  spinal 
//------------------------------

exists('aHspinal','parameter'):$e
if $e < 0.5 then
    create('aHspinal','real')
    setlimit('aHspinal',4095,0,0)
endif

exists('pwHspinal','parameter'):$e
if $e < 0.5 then
    create('pwHspinal','pulse')
    setlimit('pwHspinal',8192,0,0.0125)
endif

exists('phHspinal','parameter'):$e
if $e < 0.5 then
    create('phHspinal','real')
    setlimit('phHspinal',180,-180,0.0)
endif

exists('chHspinal','parameter'):$e
if $e < 0.5 then
   create('chHspinal','flag')
endif 
setvalue('chHspinal','dec')

//-------------------------------
// Decoupler Offset
//-------------------------------

exists('ofHdec','parameter'):$e
if $e < 0.5 then
    create('ofHdec','frequency')
endif  

//---------------------------
// Prelock Pulse - uses aH90
//---------------------------

exists('onHlock','parameter'):$e
if $e < 0.5 then
    create('onHlock','real')
    setlimit('onHlock',1,0,1)
endif

exists('pwHlock','parameter'):$e
if $e < 0.5 then
   create('pwHlock','pulse')
   setlimit('pwHlock',8192,0,0.0125)
endif 

//--------------------
// Compensation Pulse 
//--------------------

exists('pwHcomp','parameter'):$e
if $e < 0.5 then
   create('pwHcomp','pulse')
   setlimit('pwHcomp',8192,0,0.0125)
endif 

exists('aHcomp','parameter'):$e
if $e < 0.5 then
   create('aHcomp','real')
   setlimit('aHcomp',4095,0,0)
endif 

//==================
// X SAMMY ELEMENTS
//==================

exists('qXsmyo','parameter'):$e
if $e < 0.5 then
   create('qXsmyo','real')
   setlimit('qXsmyo',512,0,1)
endif 

exists('chXsmyo','parameter'):$e
if $e < 0.5 then
   create('chXsmyo','flag')
endif 
setvalue('chXsmyo','obs')

exists('ofXsmyo','parameter'):$e
if $e < 0.5 then
   create('ofXsmyo','frequency')
endif 

exists('aXsmyo','parameter'):$e
if $e < 0.5 then
   create('aXsmyo','real')
   setlimit('aXsmyo',4095,0,0)
endif 

exists('pwXsmyo','parameter'):$e
if $e < 0.5 then
   create('pwXsmyo','pulse')
   setlimit('pwXsmyo',8192,0,0.0125)
endif 

exists('t1Xsmyo','parameter'):$e
if $e < 0.5 then
   create('t1Xsmyo','pulse')
   setlimit('t1Xsmyo',8192,-8192,0.0125)
endif 

exists('t2Xsmyo','parameter'):$e
if $e < 0.5 then
   create('t2Xsmyo','pulse')
   setlimit('t2Xsmyo',8192,-8192,0.0125)
endif 

//==================
// H SAMMY ELEMENTS
//==================

exists('qHsmyd','parameter'):$e
if $e < 0.5 then
   create('qHsmyd','real')
   setlimit('qHsmyd',512,0,1)
endif 

exists('chHsmyd','parameter'):$e
if $e < 0.5 then
   create('chHsmyd','flag')
endif 
setvalue('chHsmyd','obs')

exists('ofHsmyd','parameter'):$e
if $e < 0.5 then
   create('ofHsmyd','frequency')
endif 

exists('aHsmyd','parameter'):$e
if $e < 0.5 then
   create('aHsmyd','real')
   setlimit('aHsmyd',4095,0,0)
endif 

exists('pwHsmyd','parameter'):$e
if $e < 0.5 then
   create('pwHsmyd','pulse')
   setlimit('pwHsmyd',8192,0,0.0125)
endif 

exists('t1Hsmyd','parameter'):$e
if $e < 0.5 then
   create('t1Hsmyd','pulse')
   setlimit('t1Hsmyd',8192,-8192,0.0125)
endif 

exists('t2Hsmyd','parameter'):$e
if $e < 0.5 then
   create('t2Hsmyd','pulse')
   setlimit('t2Hsmyd',8192,-8192,0.0125)
endif 

//==================
// Additional ELEMENTS
//==================

exists('pwHtilt','parameter'):$e
if $e < 0.5 then
   create('pwHtilt','pulse')
   setlimit('pwHtilt',8192,0,0.0125)
endif 

exists('scalesw1','parameter'):$e
if $e < 0.5 then
   create('scalesw1')
   scalesw1 = 1.5
   setgroup('scalesw1','processing')
endif 

exists('refsource1','parameter'):$e
if $e < 0.5 then
   create('refsource1','string')
   refsource1 = 'dfrq'
   setgroup('refsource1','processing')
endif 

exists('axis','parameter'):$e
if $e < 0.5 then
   create('axis','string')
   axis = 'pd'
   setgroup('axis','processing')
endif 

// --------------------------------------------------
// Set parameters specific to the experiment
// --------------------------------------------------

exists('wrtp','parameter'):$e
if ($e < 0.5) then 
   create('wrtp','string')
endif
wrtp = 'reset_sammy'
reset_sammy

//------------------------------------------------
//  Set Bit 14 for new parameters of the .par file 
//------------------------------------------------

$params = 'chHspinal chHtppm chXsmyo chHsmyd '
$params = $params + 'qXsmyo ofXsmyo aXsmyo pwXsmyo t1Xsmyo t2Xsmyo '
$params = $params + 'qHsmyd ofHsmyd aHsmyd pwHsmyd t1Hsmyd t2Hsmyd '
$params = $params + 'pwHcomp onHlock pwHlock aHcomp ofHdec '
$params = $params + 'pwHtilt scalesw1 refsource1 axis wrtp'
setprotect('','clear',16384)
setprotect($params,'on',16384)

//--------------------------------------------------------
//  Clear parameters in 'clearparams' in the apptype macro
//--------------------------------------------------------

exists('clearparams','parameter'):$e
if $e < 0.5 then
   create('clearparams','string')
endif
setprotect('clearparams','on',16384)
$clearparams = 'chHspinal chHtppm chXsmyo chHsmyd' 
setvalue('clearparams',$clearparams)

//------------------------------------------------
//  Set the parameter templates
//------------------------------------------------

setprotect('dg','clear',4)
$dg = '1:ACQUISITION:sw:1,at:6,np:0,d1:6,nt:0,ct:0,bs:0,'
$dg = $dg + 'ss:0,rd:1,ad:1,ddrtc:1,rof3(rof3):1,gain:0,temp:0,srate:1;'
$dg = $dg + '2:cpHX:aHhx:0,aXhx:0,tHX:1;'
$dg = $dg + '2:lockH:onHlock:0,pwHlock:1;'
$dg = $dg + '2:compH:aHcomp:0,pwHcomp:1;'
$dg = $dg + '2(Hseq=\'tppm\'):TPPM:aHtppm:0,pwHtppm:1,phHtppm:2;'
$dg = $dg + '2(Hseq=\'spinal\'):SPINAL:aHspinal:0,pwHspinal:1,phHspinal:2;'
$dg = $dg + '3:smyoX:qXsmyo:0,aXsmyo:0,pwXsmyo:1,ofXsmyo:1,pwXsmyo:1,t1Xsmyo:1,t2Xsmyo:1;'
$dg = $dg + '4:smydH:qHsmyd:0,aHsmyd:0,pwHsmyd:1,ofHsmyd:1,pwHsmyd:1,t1Hsmyd:1,t2Hsmyd:1;'
dg = $dg
setprotect('dg','on',4)

setprotect('dg2','clear',4)
$dg2 = '1:OBSERVE:tn,sfrq:6,tof:1,tpwr:0,aX90:0,pwX90:1;'
$dg2=$dg2+'2:DECOUPLE:dn,dfrq:6,dof:1,dpwr:0,aH90:0,pwH90:1;'
$dg2=$dg2+'3:DECOUPLE2:dn2,dfrq2:6,dof2:1,dpwr2:0,aY90:0,pwY90:1;'
$dg2=$dg2+'4:DECOUPLE3:dn3,dfrq3:6,dof3:1,dpwr3:0,aZ90:0,pwZ90:1;'
dg2 = $dg2
setprotect('dg2','on',4)

setprotect('ap','clear',4)
$ap = '1:SAMPLE:date,temp:1,srate:1,file;'
$ap = $ap + '1:ACQUISITION:tn,sfrq:6,tof:1,tpwr:0,sw:1,at:6,np:0,d1:6,nt:0,ct:0,ss:0,rd:1,ad:1,aX90:0,pwX90:1;'
$ap = $ap + '1(ni):2D ACQUISITION:d2:6,sw1:1,ni:0,phase:0;'
$ap = $ap + '1:DECOUPLE:dn,dfrq:6,dof:1,dpwr:0,aH90:0,pwH90:1;'
$ap = $ap + '1(dfrq2>0):DECOUPLE2:dn2,dfrq2:6,dof2:1,dpwr2:0,aY90:0,pwY90:1;'
$ap = $ap + '1(dfrq3>0):DECOUPLE3:dn3,dfrq3:6,dof3:1,dpwr3:0,aZ90:0,pwZ90:1;'
$ap = $ap + '1:cpHX:aHhx:0,aXhx:0,tHX:1;'
$ap = $ap + '1:lockH:onHlock:0,pwHlock:1;'
$ap = $ap + '1:compH:aHcomp:0,pwHcomp:1;'
$ap = $ap + '2:smyoX:qXsmyo:0,aXsmyo:0,ofXsmyo:1,pwXsmyo:1,t1Xsmyo:1,t2Xsmyo:1;'
$ap = $ap + '2:smydH:qHsmyd:0,aHsmyd:0,ofHsmyd:1,pwHsmyd:1,t1Hsmyd:1,t2Hsmyd:1;'
$ap = $ap + '2(Hseq=\'tppm\'):TPPM:aHtppm:0,pwHtppm:1,phHtppm:2;'
$ap = $ap + '2(Hseq=\'spinal\'):SPINAL:aHspinal:0,pwHspinal:1,phHspinal:2;'
ap = $ap
setvalue('ap',$ap,'processed')
setprotect('ap','on',4)




