pulsesequence() { /* DECLARE AND LOAD VARIABLES */ char f1180[MAXSTR], /* Flag to start t1 @ halfdwell */ f2180[MAXSTR], /* Flag to start t2 @ halfdwell */ mag_flg[MAXSTR], /* magic-angle coherence transfer gradients */ TROSY[MAXSTR]; /* do TROSY on N15 and H1 */ int icosel, /* used to get n and p type */ t1_counter, /* used for states tppi in t1 */ t2_counter, /* used for states tppi in t2 */ ni = getval("ni"), ni2 = getval("ni2"); double tau1, /* t1 delay */ tau2, /* t2 delay */ t1a, /* time increments for first dimension */ BPdpwrspinlock, /* user-defined upper limit for spinlock(Hz) */ BPpwrlimits, /* =0 for no limit, =1 for limit */ t1b, t1c, tauCH = getval("tauCH"), /* 1/4J delay for CH */ timeTN = getval("timeTN"), /* constant time for 15N evolution */ epsilon = 1.05e-3, /* other delays */ zeta = 3.0e-3, eta = 4.6e-3, theta = 14.0e-3, kappa = 5.4e-3, lambda = 2.4e-3, sheila, /* to transfer J evolution time hyperbolically into tau1 */ pwClvl = getval("pwClvl"), /* coarse power for C13 pulse */ pwC = getval("pwC"), /* C13 90 degree pulse length at pwClvl */ rf0, /* maximum fine power when using pwC pulses */ /* 90 degree pulse at Cab(46ppm), first off-resonance null at CO (174ppm) */ pwC1, /* 90 degree pulse length on C13 at rf1 */ rf1, /* fine power for 5.1 kHz rf for 600MHz magnet */ /* 180 degree pulse at Cab(46ppm), first off-resonance null at CO(174ppm) */ pwC2, /* 180 degree pulse length at rf2 */ rf2, /* fine power for 11.4 kHz rf for 600MHz magnet */ /* p_d is used to calculate the selective decoupling on the Cab region */ p_d, /* 50 degree pulse for DIPSI-3 at rfd */ rfd, /* fine power for DIPSI-3 spinlock */ spinlock = getval("spinlock"), /* DIPSI-3 filed strength */ ncyc = getval("ncyc"), /* no. of cycles of DIPSI-3 */ /* the following pulse lengths for SLP pulses are automatically calculated */ /* by the macro "proteincal". SLP pulse shapes, "offC4" etc are called */ /* directly from your shapelib. */ pwC4 = getval("pwC4"), /*180 degree pulse at Ca(56ppm) null at CO(174ppm) */ pwC5 = getval("pwC5"), /* 90 degree selective sinc pulse on CO(174ppm) */ pwC7 = getval("pwC7"), /* 180 degree selective sinc pulse on CO(174ppm) */ rf4, /* fine power for the pwC4 ("offC4") pulse */ rf5, /* fine power for the pwC5 ("offC5") pulse */ rf7, /* fine power for the pwC7 ("offC7") pulse */ compH = getval("compH"), /* adjustment for C13 amplifier compression */ compC = getval("compC"), /* adjustment for C13 amplifier compression */ phi7cal = getval("phi7cal"), /* phase in degrees of the last C13 90 pulse */ pwH, /* H1 90 degree pulse length at tpwr1 */ tpwr1, /* rf for DIPSI-2 */ DIPSI2time, /* total length of DIPSI-2 decoupling */ waltzB1 = getval("waltzB1"), /*Dipsi-2 decoupling field strength (Hz) */ ncyc_dec, pwNlvl = getval("pwNlvl"), /* power for N15 pulses */ pwN = getval("pwN"), /* N15 90 degree pulse length at pwNlvl */ sw1 = getval("sw1"), sw2 = getval("sw2"), gt1 = getval("gt1"), /* coherence pathway gradients */ gzcal = getval("gzcal"), /* g/cm to DAC conversion factor */ gzlvl1 = getval("gzlvl1"), gzlvl2 = getval("gzlvl2"), gt0 = getval("gt0"), /* other gradients */ gt3 = getval("gt3"), gt4 = getval("gt4"), gt5 = getval("gt5"), gstab = getval("gstab"), gzlvl0 = getval("gzlvl0"), gzlvl3 = getval("gzlvl3"), gzlvl4 = getval("gzlvl4"), gzlvl5 = getval("gzlvl5"), gzlvl6 = getval("gzlvl6"); getstr("f1180",f1180); getstr("f2180",f2180); getstr("mag_flg",mag_flg); getstr("TROSY",TROSY); /* LOAD PHASE TABLE */ settable(t3,1,phx); settable(t4,1,phx); settable(t5,2,phi5); settable(t6,2,phi6); if (TROSY[A]=='y') { settable(t8,1,phy); settable(t9,1,phx); settable(t10,1,phy); settable(t11,1,phx); settable(t12,2,recT); } else { settable(t8,1,phx); settable(t9,8,phi9); settable(t10,1,phx); settable(t11,1,phy); settable(t12,4,rec); } /* INITIALIZE VARIABLES */ P_getreal(GLOBAL,"BPpwrlimits",&BPpwrlimits,1); P_getreal(GLOBAL,"BPdpwrspinlock",&BPdpwrspinlock,1); if (BPpwrlimits > 0.5) { if (spinlock > BPdpwrspinlock) { spinlock = BPdpwrspinlock; printf("spinlock too large, reset to user-defined limit (BPdpwrspinlock)"); psg_abort(1); } } if( dpwrf < 4095 ) { printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse"); psg_abort(1); } if( pwC > 24.0*600.0/sfrq ) { printf("increase pwClvl so that pwC < 24*600/sfrq"); psg_abort(1); } /* maximum fine power for pwC pulses */ rf0 = 4095.0; /* 90 degree pulse on Cab, null at CO 128ppm away */ pwC1 = sqrt(15.0)/(4.0*128.0*dfrq); rf1 = (compC*4095.0*pwC)/pwC1; rf1 = (int) (rf1 + 0.5); /* 180 degree pulse on Cab, null at CO 128ppm away */ pwC2 = sqrt(3.0)/(2.0*128.0*dfrq); rf2 = (4095.0*compC*pwC*2.0)/pwC2; rf2 = (int) (rf2 + 0.5); /* 180 degree pulse on Ca, null at CO 118ppm away */ rf4 = (compC*4095.0*pwC*2.0)/pwC4; rf4 = (int) (rf4 + 0.5); /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */ rf5 = (compC*4095.0*pwC*1.69)/pwC5; /* needs 1.69 times more */ rf5 = (int) (rf5 + 0.5); /* power than a square pulse */ /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */ rf7 = (compC*4095.0*pwC*2.0*1.65)/pwC7; /* needs 1.65 times more */ rf7 = (int) (rf7 + 0.5); /* power than a square pulse */ /* power level and pulse times for DIPSI 1H decoupling */ DIPSI2time = 2.0*3.0e-3 + 2.0*14.0e-3 + 2.0*timeTN - 5.4e-3 + 0.5*pwC1 + 2.0*pwC5 + 5.0*pwN + 2*gt3 + 1.0e-4 + 4.0*GRADIENT_DELAY + 2.0* POWER_DELAY + 8.0*PRG_START_DELAY; pwH = 1.0/(4.0*waltzB1); ncyc_dec = DIPSI2time*90/(pwH*2590*4.0); ncyc_dec = (int) (ncyc_dec + 0.5); pwH = (DIPSI2time*90.0)/(ncyc_dec*2590*4.0); /* fine correction of pwH based of ncyc_dec */ tpwr1 = 4095.0*(compH*pw/pwH); tpwr1 = (int) (2.0*tpwr1 + 0.5); /* x2 because obs atten will be reduced by 6dB */ if (ix == 1) { fprintf(stdout, "\nNo of DIPSI-2 cycles = %4.1f\n",ncyc_dec); fprintf(stdout, "\nfine power for DIPSI-2 pulse =%6.1f\n",tpwr1); } /* dipsi-3 decoupling on CbCa */ p_d = (5.0)/(9.0*4.0*spinlock); /* DIPSI-3 spinlock*/ rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0); rfd = (int) (rfd + 0.5); ncyc = (int) (ncyc + 0.5); ncyc = (int) (ncyc + 0.5); /* CHECK VALIDITY OF PARAMETER RANGES */ if ( 0.5*ni2*1/(sw2) > timeTN - WFG3_START_DELAY) { printf(" ni2 is too big. Make ni2 equal to %d or less.\n", ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2))); psg_abort(1); } if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' ) { printf("incorrect dec1 decoupler flags! Should be 'nnn' "); psg_abort(1); } if ( dm2[A] == 'y' || dm2[B] == 'y' ) { printf("incorrect dec2 decoupler flags! Should be 'nny' "); psg_abort(1); } if ( dm3[A] == 'y' || dm3[C] == 'y' ) { printf("incorrect dec3 decoupler flags! Should be 'nyn' or 'nnn' "); psg_abort(1); } if ( dpwr2 > 50 ) { printf("dpwr2 too large! recheck value "); psg_abort(1); } if ( pw > 20.0e-6 ) { printf(" pw too long ! recheck value "); psg_abort(1); } if ( pwN > 100.0e-6 ) { printf(" pwN too long! recheck value "); psg_abort(1); } if ( TROSY[A]=='y' && dm2[C] == 'y' ) { text_error("Choose either TROSY='n' or dm2='n' ! "); psg_abort(1); } /* PHASES AND INCREMENTED TIMES */ /* Phase incrementation for hypercomplex 2D data, States-Haberkorn element */ if (phase1 == 2) tsadd(t3,1,4); if (TROSY[A]=='y') { if (phase2 == 2) icosel = +1; else { tsadd(t4,2,4); tsadd(t10,2,4); icosel = -1; } } else { if (phase2 == 2) { tsadd(t10,2,4); icosel = +1; } else icosel = -1; } /* C13 TIME INCREMENTATION and set up f1180 */ /* Set up f1180 */ tau1 = d2; if((f1180[A] == 'y') && (ni > 1.0)) { tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; } tau1 = tau1/2.0; /* Hyperbolic sheila seems superior to original zeta approach */ /* subtract unavoidable delays from epsilon */ epsilon = epsilon -pwC7 -WFG_START_DELAY -gt4 -2.0*GRADIENT_DELAY -5.0e-5; if ((ni-1)/(2.0*sw1) > 2.0*epsilon) { if (tau1 > 2.0*epsilon) sheila = epsilon; else if (tau1 > 0) sheila = 1.0/(1.0/tau1+1.0/epsilon-1.0/(2.0*epsilon)); else sheila = 0.0; } else { if (tau1 > 0) sheila = 1.0/(1.0/tau1 + 1.0/epsilon - 2.0*sw1/((double)(ni-1))); else sheila = 0.0; } t1a = tau1; t1b = tau1 - sheila; t1c = epsilon - sheila; /* Set up f2180 */ tau2 = d3; if((f2180[A] == 'y') && (ni2 > 1.0)) { tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; } tau2 = tau2/2.0; /* Calculate modifications to phases for States-TPPI acquisition */ if( ix == 1) d2_init = d2; t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 ); if(t1_counter % 2) { tsadd(t3,2,4); tsadd(t12,2,4); } if( ix == 1) d3_init = d3; t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 ); if(t2_counter % 2) { tsadd(t8,2,4); tsadd(t12,2,4); } /* BEGIN PULSE SEQUENCE */ status(A); if (dm3[B]=='y') lk_sample(); delay(d1); if ((ni/sw1-d2)>0) delay(ni/sw1-d2); /*decreases as t1 increases for const.heating*/ if ((ni2/sw2-d3)>0) delay(ni2/sw2-d3); /*decreases as t2 increases for const.heating*/ if ( dm3[B] == 'y' ) { lk_hold(); /*freezes z0 correction, stops lock pulsing*/ lk_sampling_off(); } rcvroff(); obspower(tpwr); decpower(pwClvl); dec2power(pwNlvl); decpwrf(rf0); obsoffset(tof); txphase(one); delay(1.0e-5); if (TROSY[A] == 'n') dec2rgpulse(pwN, zero, 0.0, 0.0); /*destroy X magnetization*/ decrgpulse(pwC, zero, 0.0, 0.0); zgradpulse(gzlvl0, 0.5e-3); delay(1.0e-4); if (TROSY[A] == 'n') dec2rgpulse(pwN, one, 0.0, 0.0); decrgpulse(pwC, zero, 0.0, 0.0); zgradpulse(0.7*gzlvl0, 0.5e-3); delay(5.0e-4); rgpulse(pw, one, 0.0, 0.0); /* 1H pulse excitation */ /* point a */ txphase(zero); decphase(zero); zgradpulse(gzlvl0, gt0); delay(tauCH - gt0); simpulse(2*pw, 2.0*pwC, zero, zero, 0.0, 0.0); decphase(t3); zgradpulse(gzlvl0, gt0); delay(tauCH - gt0); /* point b */ rgpulse(pw, zero, 0.0, 0.0); zgradpulse(gzlvl3, gt3); delay(2.0e-4); if ( dm3[B] == 'y' ) /* begins optional 2H decoupling */ { gt4=0.0; /* no gradients during 2H decoupling */ dec3rgpulse(1/dmf3,one,10.0e-6,2.0e-6); dec3unblank(); dec3phase(zero); delay(2.0e-6); setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3); } decrgpulse(pwC, t3, 0.0, 0.0); /* point c */ decphase(zero); decpwrf(rf7); delay(t1a); decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0); decpwrf(rf2); zgradpulse(gzlvl4, gt4); /* 2.0*GRADIENT_DELAY */ delay(5.0e-5); delay(epsilon - 2.0*pw); rgpulse(2.0*pw, zero, 0.0, 0.0); delay(t1b); decrgpulse(pwC2, zero, 0.0, 0.0); zgradpulse(gzlvl4, gt4); /* 2.0*GRADIENT_DELAY */ delay(5.0e-5); decpwrf(rf7); delay(t1c); decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0); decpwrf(rfd); /* point d */ decrgpulse(1.0e-3, zero, 2.0e-6, 0.0); initval(ncyc, v2); starthardloop(v2); decrgpulse(4.9*p_d,one,0.0,0.0); decrgpulse(7.9*p_d,three,0.0,0.0); decrgpulse(5.0*p_d,one,0.0,0.0); decrgpulse(5.5*p_d,three,0.0,0.0); decrgpulse(0.6*p_d,one,0.0,0.0); decrgpulse(4.6*p_d,three,0.0,0.0); decrgpulse(7.2*p_d,one,0.0,0.0); decrgpulse(4.9*p_d,three,0.0,0.0); decrgpulse(7.4*p_d,one,0.0,0.0); decrgpulse(6.8*p_d,three,0.0,0.0); decrgpulse(7.0*p_d,one,0.0,0.0); decrgpulse(5.2*p_d,three,0.0,0.0); decrgpulse(5.4*p_d,one,0.0,0.0); decrgpulse(0.6*p_d,three,0.0,0.0); decrgpulse(4.5*p_d,one,0.0,0.0); decrgpulse(7.3*p_d,three,0.0,0.0); decrgpulse(5.1*p_d,one,0.0,0.0); decrgpulse(7.9*p_d,three,0.0,0.0); decrgpulse(4.9*p_d,three,0.0,0.0); decrgpulse(7.9*p_d,one,0.0,0.0); decrgpulse(5.0*p_d,three,0.0,0.0); decrgpulse(5.5*p_d,one,0.0,0.0); decrgpulse(0.6*p_d,three,0.0,0.0); decrgpulse(4.6*p_d,one,0.0,0.0); decrgpulse(7.2*p_d,three,0.0,0.0); decrgpulse(4.9*p_d,one,0.0,0.0); decrgpulse(7.4*p_d,three,0.0,0.0); decrgpulse(6.8*p_d,one,0.0,0.0); decrgpulse(7.0*p_d,three,0.0,0.0); decrgpulse(5.2*p_d,one,0.0,0.0); decrgpulse(5.4*p_d,three,0.0,0.0); decrgpulse(0.6*p_d,one,0.0,0.0); decrgpulse(4.5*p_d,three,0.0,0.0); decrgpulse(7.3*p_d,one,0.0,0.0); decrgpulse(5.1*p_d,three,0.0,0.0); decrgpulse(7.9*p_d,one,0.0,0.0); decrgpulse(4.9*p_d,three,0.0,0.0); decrgpulse(7.9*p_d,one,0.0,0.0); decrgpulse(5.0*p_d,three,0.0,0.0); decrgpulse(5.5*p_d,one,0.0,0.0); decrgpulse(0.6*p_d,three,0.0,0.0); decrgpulse(4.6*p_d,one,0.0,0.0); decrgpulse(7.2*p_d,three,0.0,0.0); decrgpulse(4.9*p_d,one,0.0,0.0); decrgpulse(7.4*p_d,three,0.0,0.0); decrgpulse(6.8*p_d,one,0.0,0.0); decrgpulse(7.0*p_d,three,0.0,0.0); decrgpulse(5.2*p_d,one,0.0,0.0); decrgpulse(5.4*p_d,three,0.0,0.0); decrgpulse(0.6*p_d,one,0.0,0.0); decrgpulse(4.5*p_d,three,0.0,0.0); decrgpulse(7.3*p_d,one,0.0,0.0); decrgpulse(5.1*p_d,three,0.0,0.0); decrgpulse(7.9*p_d,one,0.0,0.0); decrgpulse(4.9*p_d,one,0.0,0.0); decrgpulse(7.9*p_d,three,0.0,0.0); decrgpulse(5.0*p_d,one,0.0,0.0); decrgpulse(5.5*p_d,three,0.0,0.0); decrgpulse(0.6*p_d,one,0.0,0.0); decrgpulse(4.6*p_d,three,0.0,0.0); decrgpulse(7.2*p_d,one,0.0,0.0); decrgpulse(4.9*p_d,three,0.0,0.0); decrgpulse(7.4*p_d,one,0.0,0.0); decrgpulse(6.8*p_d,three,0.0,0.0); decrgpulse(7.0*p_d,one,0.0,0.0); decrgpulse(5.2*p_d,three,0.0,0.0); decrgpulse(5.4*p_d,one,0.0,0.0); decrgpulse(0.6*p_d,three,0.0,0.0); decrgpulse(4.5*p_d,one,0.0,0.0); decrgpulse(7.3*p_d,three,0.0,0.0); decrgpulse(5.1*p_d,one,0.0,0.0); decrgpulse(7.9*p_d,three,0.0,0.0); endhardloop(); /* point e */ obspwrf(tpwr1); obspower(tpwr-6); obsprgon("dipsi2", pwH, 5.0); /* PRG_START_DELAY */ xmtron(); decpwrf(rf0); decphase(t5); delay(zeta - 2.0*POWER_DELAY - PRG_START_DELAY - 0.5*10.933*pwC); decrgpulse(pwC*158.0/90.0, t5, 0.0, 0.0); decrgpulse(pwC*171.2/90.0, t6, 0.0, 0.0); decrgpulse(pwC*342.8/90.0, t5, 0.0, 0.0); /* Shaka composite */ decrgpulse(pwC*145.5/90.0, t6, 0.0, 0.0); decrgpulse(pwC*81.2/90.0, t5, 0.0, 0.0); decrgpulse(pwC*85.3/90.0, t6, 0.0, 0.0); decpwrf(rf1); decphase(zero); delay(zeta - 0.5*10.933*pwC - 0.5*pwC1); /* point f */ decrgpulse(pwC1, zero, 0.0, 0.0); decphase(t5); decpwrf(rf5); if ( dm3[B] == 'y' ) /* turns off 2H decoupling */ { setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3); dec3rgpulse(1/dmf3,three,2.0e-6,2.0e-6); dec3blank(); lk_autotrig(); /* resumes lock pulsing */ } zgradpulse(gzlvl3, gt3); delay(2.0e-4); decshaped_pulse("offC5", pwC5, t5, 0.0, 0.0); /* point g */ decpwrf(rf4); decphase(zero); delay(eta); decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); decpwrf(rf7); dec2phase(zero); delay(theta - eta - pwC4 - WFG3_START_DELAY); /* WFG3_START_DELAY */ sim3shaped_pulse("", "offC7", "", 0.0, pwC7, 2.0*pwN, zero, zero, zero, 0.0, 0.0); decpwrf(rf5); decpwrf(rf5); initval(phi7cal, v7); decstepsize(1.0); dcplrphase(v7); /* SAPS_DELAY */ dec2phase(t8); delay(theta - SAPS_DELAY); /* point h */ decshaped_pulse("offC5", pwC5, zero, 0.0, 0.0); /* xxxxxxxxxxxxxxxxxx OPTIONS FOR N15 EVOLUTION xxxxxxxxxxxxxxxxxxxxx */ zgradpulse(gzlvl3, gt3); if (TROSY[A]=='y') { xmtroff(); obsprgoff(); } delay(2.0e-4); dcplrphase(zero); dec2rgpulse(pwN, t8, 0.0, 0.0); /* point i */ decpwrf(rf7); decphase(zero); dec2phase(t9); delay(timeTN - WFG3_START_DELAY - tau2); /* WFG3_START_DELAY */ sim3shaped_pulse("", "offC7", "", 0.0, pwC7, 2.0*pwN, zero, zero, t9, 0.0, 0.0); dec2phase(t10); decpwrf(rf4); if (TROSY[A]=='y') { if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4) { txphase(t4); delay(timeTN - pwC4 - WFG_START_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); } else { txphase(t4); delay(timeTN -pwC4 -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(tau2); } } else { if (tau2 > kappa) { delay(timeTN - pwC4 - WFG_START_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(tau2 - kappa - PRG_STOP_DELAY); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ txphase(t4); delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); /* WFG_START_DELAY */ } else if (tau2 > (kappa - pwC4 - WFG_START_DELAY)) { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ txphase(t4); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(kappa -pwC4 -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); /* WFG_START_DELAY */ } else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4) { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ txphase(t4); delay(kappa - tau2 - pwC4 - WFG_START_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); /* WFG_START_DELAY */ } else { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ txphase(t4); delay(kappa-tau2-pwC4-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); obspwrf(4095.0); /* POWER_DELAY */ delay(1.0e-4 - 2.0*POWER_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0); delay(tau2); } } /* point j */ /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ if (TROSY[A]=='y') rgpulse(pw, t4, 0.0, 0.0); else sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0); txphase(zero); dec2phase(zero); zgradpulse(gzlvl5, gt5); if (TROSY[A]=='y') delay(lambda - 0.65*(pw + pwN) - gt5); else delay(lambda - 1.3*pwN - gt5); sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0); zgradpulse(gzlvl5, gt5); txphase(one); dec2phase(t11); delay(lambda - 1.3*pwN - gt5); sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0); txphase(zero); dec2phase(zero); zgradpulse(gzlvl6, gt5); delay(lambda - 1.3*pwN - gt5); sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0); dec2phase(t10); zgradpulse(gzlvl6, gt5); if (TROSY[A]=='y') delay(lambda - 1.6*pwN - gt5); else delay(lambda - 0.65*pwN - gt5); if (TROSY[A]=='y') dec2rgpulse(pwN, t10, 0.0, 0.0); else rgpulse(pw, zero, 0.0, 0.0); delay((gt1/10.0) + 1.0e-4 +gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY); rgpulse(2.0*pw, zero, 0.0, rof1); dec2power(dpwr2); /* POWER_DELAY */ if (mag_flg[A] == 'y') magradpulse(icosel*gzcal*gzlvl2, gt1/10.0); else zgradpulse(icosel*gzlvl2, gt1/10.0); /* 2.0*GRADIENT_DELAY */ delay(gstab); rcvron(); statusdelay(C,1.0e-4 - rof1); if (dm3[B]=='y') lk_sample(); setreceiver(t12); }
void Smtp::connected() { emit status( tr( "Connected to %1" ).arg( socket->peerName() ) ); }
bool Response::ok() const { // "The ok attribute's getter must return true // if response's status is in the range 200 to 299, and false otherwise." return 200 <= status() && status() <= 299; }
pulsesequence() { double gtE = getval("gtE"), gzlvlE=getval("gzlvlE"), selpwrPS = getval("selpwrPS"), selpwPS = getval("selpwPS"), gzlvlPS = getval("gzlvlPS"), droppts=getval("droppts"), gstab = getval("gstab"); char selshapePS[MAXSTR]; //synchronize gradients to srate for probetype='nano' // Preserve gradient "area" gtE = syncGradTime("gtE","gzlvlE",1.0); gzlvlE = syncGradLvl("gtE","gzlvlE",1.0); getstr("selshapePS",selshapePS); settable(t1,4,ph1); settable(t2,32,ph2); settable(t3,8,ph3); settable(t4,16,ph4); getelem(t1,ct,v1); getelem(t2,ct,v2); getelem(t3,ct,v3); getelem(t4,ct,v4); assign(v4,oph); assign(v1,v6); /* BEGIN THE ACTUAL PULSE SEQUENCE */ status(A); obspower(tpwr); delay(5.0e-5); if (getflag("sspul")) steadystate(); if (satmode[0] == 'y') { if ((d1-satdly) > 0.02) delay(d1-satdly); else delay(0.02); satpulse(satdly,v6,rof1,rof1); } else delay(d1); if (getflag("wet")) wet4(zero,one); status(B); obspower(tpwr); rgpulse(pw, v1, rof1, rof2); delay(d2/2.0); delay((0.25/sw1) - gtE - gstab - 2*pw/PI - rof2 - 2*GRADIENT_DELAY); zgradpulse(gzlvlE,gtE); delay(gstab); rgpulse(2*pw,v2,rof1,rof1); delay(0.25/sw1); delay(gstab); zgradpulse(-1.0*gzlvlE,gtE); delay(gstab); obspower(selpwrPS); rgradient('z',gzlvlPS); shaped_pulse(selshapePS,selpwPS,v3,rof1,rof1); rgradient('z',0.0); obspower(tpwr); delay(gstab); zgradpulse(-2.0*gzlvlE,gtE); delay(gstab - droppts/sw); delay(d2/2.0); status(C); }
void AutoBoot::handleCommand(quint8 command, quint16 aux) { switch (command) { case 0x3F: // Speed poll { if (!sio->port()->writeCommandAck()) { return; } sio->port()->writeComplete(); QByteArray speed(1, 0); speed[0] = sio->port()->speedByte(); sio->port()->writeDataFrame(speed); qDebug() << "!n" << tr("[%1] Speed poll.").arg(deviceName()); break; } case 0x52: { /* Read sector */ if (loaded) { passToOldHandler(command, aux); return; } if (aux >= 1 && aux <= sectorCount) { if (!sio->port()->writeCommandAck()) { return; } if (!started) { emit booterStarted(); started = true; } QByteArray data; if (readSector(aux, data)) { sio->port()->writeComplete(); sio->port()->writeDataFrame(data); qDebug() << "!n" << tr("[%1] Read sector %2 (%3 bytes).") .arg(deviceName()) .arg(aux) .arg(data.size()); } else { sio->port()->writeError(); qCritical() << "!e" << tr("[%1] Read sector %2 failed.") .arg(deviceName()) .arg(aux); } } else { passToOldHandler(command, aux); } break; } case 0x53: { /* Get status */ if (loaded) { passToOldHandler(command, aux); return; } if (!sio->port()->writeCommandAck()) { return; } QByteArray status(4, 0); status[0] = 8; status[3] = 1; sio->port()->writeComplete(); sio->port()->writeDataFrame(status); qDebug() << "!n" << tr("[%1] Get status.") .arg(deviceName()); break; } case 0xFD: { if (!sio->port()->writeCommandAck()) { return; } qDebug() << "!n" << tr("[%1] Atari is jumping to %2.") .arg(deviceName()) .arg(aux); emit loaderDone(); sio->port()->writeComplete(); break; } case 0xFE: { /* Get chunk */ if(aux >= chunks.count()) { qDebug() << "!e" << tr("[%1] Invalid chunk in get chunk: aux = %2") .arg(deviceName()) .arg(aux); return; } if (!sio->port()->writeCommandAck()) { return; } qDebug() << "!n" << tr("[%1] Get chunk %2 (%3 bytes).") .arg(deviceName()) .arg(aux) .arg(chunks.at(aux).data.size()); sio->port()->writeComplete(); sio->port()->writeDataFrame(chunks.at(aux).data); emit blockRead(aux + 1, chunks.count()); break; } case 0xFF: { /* Get chunk info */ if(aux >= chunks.count()) { qDebug() << "!e" << tr("[%1] Invalid chunk in get chunk info: aux = %2") .arg(deviceName()) .arg(aux); return; } if (!sio->port()->writeCommandAck()) { return; } if (!loaded) { loaded = true; emit booterLoaded(); } QByteArray data; data[0] = chunks.at(aux).address % 256; data[1] = chunks.at(aux).address / 256; data[2] = 1; data[3] = chunks.size() != aux + 1; data[4] = chunks.at(aux).data.size() % 256; data[5] = chunks.at(aux).data.size() / 256; qDebug() << "!d" << tr("[%1] Get chunk info %2 (%3 bytes at %4).") .arg(deviceName()) .arg(aux) .arg(chunks.at(aux).data.size()) .arg(chunks.at(aux).address); sio->port()->writeComplete(); sio->port()->writeDataFrame(data); break; } default: passToOldHandler(command, aux); return; break; } }
void bv_refinementt::check_SAT(approximationt &a) { // get values get_values(a); // see if the satisfying assignment is spurious in any way const typet &type=ns.follow(a.expr.type()); if(type.id()==ID_floatbv) { // these are all trinary assert(a.expr.operands().size()==3); if(a.over_state==MAX_STATE) return; ieee_float_spect spec(to_floatbv_type(type)); ieee_floatt o0(spec), o1(spec); o0.unpack(a.op0_value); o1.unpack(a.op1_value); ieee_floatt result=o0; o0.rounding_mode=RM; o1.rounding_mode=RM; result.rounding_mode=RM; if(a.expr.id()==ID_floatbv_plus) result+=o1; else if(a.expr.id()==ID_floatbv_minus) result-=o1; else if(a.expr.id()==ID_floatbv_mult) result*=o1; else if(a.expr.id()==ID_floatbv_div) result/=o1; else assert(false); if(result.pack()==a.result_value) // ok return; #ifdef DEBUG ieee_floatt rr(spec); rr.unpack(a.result_value); std::cout << "S1: " << o0 << " " << a.expr.id() << " " << o1 << " != " << rr << std::endl; std::cout << "S2: " << integer2binary(a.op0_value, spec.width()) << " " << a.expr.id() << " " << integer2binary(a.op1_value, spec.width()) << "!=" << integer2binary(a.result_value, spec.width()) << std::endl; std::cout << "S3: " << integer2binary(a.op0_value, spec.width()) << " " << a.expr.id() << " " << integer2binary(a.op1_value, spec.width()) << "==" << integer2binary(result.pack(), spec.width()) << std::endl; #endif //if(a.over_state==1) { std::cout << "DISAGREEMENT!\n"; exit(1); } if(a.over_state<max_node_refinement) { bvt r; float_utilst float_utils(prop); float_utils.spec=spec; float_utils.rounding_mode_bits.set(RM); literalt op0_equal= bv_utils.equal(a.op0_bv, float_utils.build_constant(o0)); literalt op1_equal= bv_utils.equal(a.op1_bv, float_utils.build_constant(o1)); literalt result_equal= bv_utils.equal(a.result_bv, float_utils.build_constant(result)); literalt op0_and_op1_equal= prop.land(op0_equal, op1_equal); prop.l_set_to_true( prop.limplies(op0_and_op1_equal, result_equal)); } else { // give up // remove any previous over-approximation a.over_assumptions.clear(); a.over_state=MAX_STATE; bvt r; float_utilst float_utils(prop); float_utils.spec=spec; float_utils.rounding_mode_bits.set(RM); bvt op0=a.op0_bv, op1=a.op1_bv, res=a.result_bv; if(a.expr.id()==ID_floatbv_plus) r=float_utils.add(op0, op1); else if(a.expr.id()==ID_floatbv_minus) r=float_utils.sub(op0, op1); else if(a.expr.id()==ID_floatbv_mult) r=float_utils.mul(op0, op1); else if(a.expr.id()==ID_floatbv_div) r=float_utils.div(op0, op1); else assert(0); assert(r.size()==res.size()); bv_utils.set_equal(r, res); } } else if(type.id()==ID_signedbv || type.id()==ID_unsignedbv) { // these are all binary assert(a.expr.operands().size()==2); // already full interpretation? if(a.over_state>0) return; bv_spect spec(type); bv_arithmetict o0(spec), o1(spec); o0.unpack(a.op0_value); o1.unpack(a.op1_value); // division by zero is never spurious if((a.expr.id()==ID_div || a.expr.id()==ID_mod) && o1==0) return; if(a.expr.id()==ID_mult) o0*=o1; else if(a.expr.id()==ID_div) o0/=o1; else if(a.expr.id()==ID_mod) o0%=o1; else assert(false); if(o0.pack()==a.result_value) // ok return; if(a.over_state==0) { // we give up right away and add the full interpretation bvt r; if(a.expr.id()==ID_mult) { r=bv_utils.multiplier( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else if(a.expr.id()==ID_div) { r=bv_utils.divider( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else if(a.expr.id()==ID_mod) { r=bv_utils.remainder( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else assert(0); bv_utils.set_equal(r, a.result_bv); } else assert(0); } else assert(0); status() << "Found spurious `" << a.as_string() << "' (state " << a.over_state << ")" << eom; progress=true; if(a.over_state<MAX_STATE) a.over_state++; }
pulsesequence() { char shname1[MAXSTR], f1180[MAXSTR], f2180[MAXSTR], SE_flg[MAXSTR], href_flg[MAXSTR]; int icosel = 0, t1_counter, t2_counter, ni2 = getval("ni2"), phase; double d2_init=0.0, d3_init=0.0, pwS1,pwS2,pwS3,pwS4,pwS5,pwS6, lambda = getval("lambda"), gzlvl1 = getval("gzlvl1"), gzlvl2 = getval("gzlvl2"), gzlvl3 = getval("gzlvl3"), gzlvl5 = getval("gzlvl5"), gzlvl6 = getval("gzlvl6"), gt1 = getval("gt1"), /* gt2 = getval("gt2"), */ gt3 = getval("gt3"), gt5 = getval("gt5"), gt6 = getval("gt6"), gstab = getval("gstab"), shlvl1 = getval("shlvl1"), shpw1 = getval("shpw1"), pwClvl = getval("pwClvl"), pwNlvl = getval("pwNlvl"), pwN = getval("pwN"), dpwr2 = getval("dpwr2"), d2 = getval("d2"), timeTN = getval("timeTN"), tau1 = getval("tau1"), tau2 = getval("tau2"), taunh = getval("taunh"); getstr("shname1", shname1); getstr("SE_flg",SE_flg); getstr("f1180",f1180); getstr("f2180",f2180); getstr("href_flg",href_flg); phase = (int) (getval("phase") + 0.5); settable(t1,4,phi1); settable(t3,4,phi3); settable(t5,4,phi5); settable(t10,1,phi10); settable(t12,4,phi12); settable(t13,4,phi13); /* INITIALIZE VARIABLES */ pwS1 = c13pulsepw("co", "ca", "sinc", 90.0); pwS2 = c13pulsepw("co", "ca", "sinc", 180.0); pwS3 = c13pulsepw("ca", "co", "square", 180.0); pwS4 = h_shapedpw("eburp2",4.0,3.5,zero, 0.0, 0.0); pwS6 = h_shapedpw("reburp",4.0,3.5,zero, 0.0, 0.0); pwS5 = h_shapedpw("pc9f",4.0,3.5,zero, 2.0e-6, 0.0); if (SE_flg[0] == 'y') { if ( ni2*1/(sw2)/2.0 > (timeTN-pwS2*0.5-pwS4)) { printf(" ni2 is too big. Make ni2 equal to %d or less.\n", ((int)((timeTN-pwS2*0.5-pwS4)*2.0*sw2))); psg_abort(1);} } else { if ( ni2*1/(sw2)/2.0 > (timeTN-pwS2*0.5)) { printf(" ni2 is too big. Make ni2 equal to %d or less.\n", ((int)((timeTN-pwS2*0.5)*2.0*sw2))); psg_abort(1);} } if (phase == 1) ; if (phase == 2) tsadd(t1,1,4); if (SE_flg[0] =='y') { if (phase2 == 2) {tsadd(t10,2,4); icosel = +1;} else icosel = -1; } else { if (phase2 == 2) {tsadd(t3,1,4);tsadd(t5,1,4); icosel=1;} } tau1 = d2; if((f1180[A] == 'y') ) { tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; } tau1 = tau1; tau2 = d3; if((f2180[A] == 'y') ) { tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; } tau2 = tau2; if( ix == 1) d2_init = d2; t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 ); if(t1_counter % 2) { tsadd(t1,2,4); tsadd(t12,2,4); tsadd(t13,2,4); } if( ix == 1) d3_init = d3; t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 ); if(t2_counter % 2) { tsadd(t3,2,4); tsadd(t5,2,4);tsadd(t12,2,4); tsadd(t13,2,4); } status(A); rcvroff(); decpower(pwClvl); decoffset(dof); dec2power(pwNlvl); dec2offset(dof2); decpwrf(4095.0); obsoffset(tof); set_c13offset("co"); zgradpulse(gzlvl6, gt6); delay(1.0e-4); delay(d1-gt6); lk_hold(); h_shapedpulse("pc9f",4.0,3.5,zero, 2.0e-6, 0.0); delay(lambda-pwS5*0.5-pwS6*0.4); h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, one, zero, zero, 0.0, 0.0); delay(lambda-pwS5*0.5-pwS6*0.4); h_shapedpulse("pc9f_",4.0,3.5,one, 0.0, 0.0); obspower(shlvl1); /**************************************************************************/ dec2rgpulse(pwN,zero,0.0,0.0); zgradpulse(gzlvl3, gt3); delay(timeTN-pwS2*0.5-gt3); sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 2.0e-6); if (href_flg[0] == 'y') { delay(timeTN-pwS2*0.5-taunh*0.5-shpw1); shaped_pulse(shname1,shpw1,two,0.0,0.0); zgradpulse(gzlvl3, gt3); delay(taunh*0.5-gt3); dec2rgpulse(pwN,zero,0.0,0.0); } else { delay(timeTN-pwS2*0.5-taunh*0.5); zgradpulse(gzlvl3, gt3); delay(taunh*0.5-gt3); dec2rgpulse(pwN,one,0.0,0.0); } /**************************************************************************/ /* xxxxxxxxxxxxxxxxxxxxxx 13CO EVOLUTION xxxxxxxxxxxxxxxxxx */ /**************************************************************************/ c13pulse("co", "ca", "sinc", 90.0, t1, 2.0e-6, 0.0); delay(tau1*0.5); sim3_c13pulse(shname1, "ca", "co", "square", "", shpw1, 180.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 0.0); delay(tau1*0.5); c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0); sim3_c13pulse("", "ca", "co", "square", "", 0.0, 180.0, 0.0, one, zero, zero, 2.0e-6, 0.0); if (pwN*2.0 > pwS3) delay(pwN*2.0-pwS3); c13pulse("co", "ca", "sinc", 90.0, zero, 0.0, 0.0); /**************************************************************************/ obspower(tpwr); if (href_flg[0] == 'y') { shaped_pulse(shname1,shpw1,two,0.0,0.0); dec2rgpulse(pwN,t3,0.0,0.0); } else dec2rgpulse(pwN,t5,0.0,0.0); if (SE_flg[0] == 'y') { if (href_flg[0] == 'y') { delay(tau2*0.5); c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0); delay(taunh*0.5-pwS3); shaped_pulse(shname1,shpw1,two,0.0,0.0); delay(timeTN-pwS2*0.5-shpw1-taunh*0.5-gt1-1.0e-4); } else { delay(tau2*0.5); sim_c13pulse(shname1,"ca", "co", "square",shpw1, 180.0, two,zero, 0.0, 0.0); if (shpw1 >= pwS3) delay(taunh*0.5-shpw1); else delay(taunh*0.5-pwS3); delay(timeTN-pwS2*0.5-taunh*0.5-gt1-1.0e-4); } zgradpulse(-gzlvl1, gt1); delay(1.0e-4); sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 2.0e-6); delay(timeTN-pwS2*0.5-tau2*0.5-pwS4); h_shapedpulse("eburp2",4.0,3.5,zero, 2.0e-6, 0.0); dec2rgpulse(pwN, t10, 0.0, 0.0); } else { if (href_flg[0] == 'y') { delay(tau2*0.5); c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0); delay(taunh*0.5-pwS3); shaped_pulse(shname1,shpw1,two,0.0,0.0); delay(timeTN-pwS2*0.5-shpw1-taunh*0.5); } else { delay(tau2*0.5); sim_c13pulse(shname1,"ca", "co", "square",shpw1, 180.0, two,zero, 0.0, 0.0); if (shpw1 >= pwS3) delay(taunh*0.5-shpw1); else delay(taunh*0.5-pwS3); delay(timeTN-pwS2*0.5-taunh*0.5); } sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 2.0e-6); delay(timeTN-pwS2*0.5-tau2*0.5); dec2rgpulse(pwN, zero, 0.0, 0.0); } /**************************************************************************/ if (SE_flg[0] == 'y') { zgradpulse(gzlvl5, gt5); delay(lambda-pwS6*0.4 - gt5); h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0); zgradpulse(gzlvl5, gt5); delay(lambda-pwS6*0.4 - gt5); dec2rgpulse(pwN, one, 0.0, 0.0); h_shapedpulse("eburp2_",4.0,3.5,one, 0.0, 0.0); txphase(zero); dec2phase(zero); delay(lambda-pwS4*0.5-pwS6*0.4); h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0); dec2phase(t10); delay(lambda-pwS4*0.5-pwS6*0.4); h_shapedpulse("eburp2",4.0,3.5,zero, 0.0, 0.0); delay((gt1/10.0) + 1.0e-4 +gstab + 2.0*GRADIENT_DELAY + POWER_DELAY); h_shapedpulse("reburp",4.0,3.5,zero, 0.0, 0.0); zgradpulse(icosel*gzlvl2, gt1/10.0); /* 2.0*GRADIENT_DELAY */ delay(gstab); } else { h_shapedpulse("eburp2",4.0,3.5,zero, 2.0e-6, 0.0); zgradpulse(gzlvl5, gt5); delay(lambda-pwS6*0.4 - gt5); h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0); zgradpulse(gzlvl5, gt5); delay(lambda-pwS6*0.4 - gt5-POWER_DELAY-1.0e-4); } dec2power(dpwr2); /* POWER_DELAY */ lk_sample(); if (SE_flg[0] == 'y') setreceiver(t13); else setreceiver(t12); rcvron(); statusdelay(C,1.0e-4 ); }
UINT64 vmsBtDownloadImpl::get_TotalDownloadedBytesCount () { if (m_handle.is_valid () == false) return 0; return status ().total_done; }
UINT vmsBtDownloadImpl::GetUploadSpeed () { if (m_handle.is_valid () == false) return 0; return (UINT)status ().upload_payload_rate; }
int main(int argc, char* argv[]) { status(); printf(">> int *a (int*)my_malloc(sizeof(int))\n"); int *a = (int*)my_malloc(sizeof(int)); printf(">> *a = %d\n\n",*a); *a = 5; status(); printf(">> char* b = (char*)my_malloc(256)\n"); char* b = (char*)my_malloc(16); printf(">> *b = '%s'\n\n",b); b[0] = 'c'; b[1] = 'o'; b[2] = 'o'; b[3] = 'l'; b[4] = '\0'; status(); printf(">> char* c = (char*)my_malloc(256)\n\n"); char* c = (char*)my_malloc(256); status(); printf(">> char* d = (char*)my_malloc(9728)\n"); char* d = (char*)my_malloc(9728); printf(">> d[9959] = '%c' \n\n", d[9727]); d[9727] = '\0'; status(); printf(">> my_free(b)\n\n"); my_free((void*)b); status(); printf(">> my_free(d)\n\n"); my_free((void*) d); status(); printf(">> char *e = (char*)my_malloc(80)\n\n"); char *e = (char*)my_malloc(80); status(); printf(">> my_free(c)\n\n"); my_free((void*)c); status(); printf(">> my_free(a)\n\n"); my_free((void*)a); status(); printf(">> my_free(e)\n\n"); my_free((void*)e); status(); char buffer[3]; printf("Press any key to continue..."); fgets(buffer, 2, stdin); }
void pulsesequence() { double ss, arraydim, p1lvl, trim, mix, window, cycles, phase; int iphase; char sspul[MAXSTR]; /* LOAD AND INITIALIZE VARIABLES */ ni = getval("ni"); arraydim = getval("arraydim"); mix = getval("mix"); trim = getval("trim"); phase = getval("phase"); iphase = (int) (phase + 0.5); p1lvl = getval("p1lvl"); ss = getval("ss"); window=getval("window"); getstr("sspul", sspul); if (iphase == 3) { initval((double)((int)((ix-1)/(arraydim/ni)+1.0e-6)), v14); } else { assign(zero, v14); } /* CHECK CONDITIONS */ if ((iphase != 3) && (arrayelements > 2)) { fprintf(stdout, "PHASE=3 is required if MIX is arrayed!\n"); psg_abort(1); } if (satdly > 9.999) { fprintf(stdout, "Presaturation period is too long.\n"); psg_abort(1); } if (!newtransamp) { fprintf(stdout, "TOCSY requires linear amplifiers on transmitter.\n"); fprintf(stdout, "Use DECTOCSY with the appropriate re-cabling,\n"); psg_abort(1); } if ((p1 == 0.0) && (ix == 1)) fprintf(stdout, "Warning: P1 has a zero value.\n"); if ((rof1 < 9.9e-6) && (ix == 1)) fprintf(stdout,"Warning: ROF1 is less than 10 us\n"); if (satpwr > 40) { printf("satpwr too large - acquisition aborted./n"); psg_abort(1); } /* DETERMINE STEADY-STATE MODE */ if (ss < 0) { ss = (-1) * ss; } else { if ((ss > 0) && (ix == 1)) { ss = ss; } else { ss = 0; } } initval(ss, ssctr); initval(ss, ssval); /* STEADY-STATE PHASECYCLING */ /* This section determines if the phase calculations trigger off of (SS - SSCTR) or off of CT */ ifzero(ssctr); hlv(ct, v13); mod2(ct, v1); hlv(ct, v2); elsenz(ssctr); sub(ssval, ssctr, v12); /* v12 = 0,...,ss-1 */ hlv(v12, v13); mod2(v12, v1); hlv(v12, v2); endif(ssctr); /* CALCULATE PHASES */ /* A 2-step cycle is performed on the first pulse (90 degrees) to suppress axial peaks in the first instance. Second, the 2-step F2 quadrature image suppression subcycle is added to all pulse phases and receiver phase. Finally, a 2-step cycle is performed on the spin-lock pulses. */ mod2(v13, v13); dbl(v1, v1); incr(v1); hlv(v2, v2); mod2(v2, v2); dbl(v2, v2); incr(v2); add(v13, v2, v2); sub(v2, one, v3); add(two, v2, v4); add(two, v3, v5); add(v1, v13, v1); assign(v1, oph); if (iphase == 2) incr(v1); if (iphase == 3) add(v1, v14, v1); /*HYPERCOMPLEX MODE USES REDFIELD TRICK TO MOVE AXIAL PEAKS TO EDGE*/ initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v6); if ((iphase==1)||(iphase==2)) {add(v1,v6,v1); add(oph,v6,oph);} /* CALCULATE AND INITIALIZE LOOP COUNTER */ if (pw > 0.0) { cycles = (mix - trim) / (64.66*pw+32*window); cycles = 2.0*(double) (int) (cycles/2.0); } else { cycles = 0.0; } initval(cycles, v9); /* V9 is the MIX loop count */ /* BEGIN ACTUAL PULSE SEQUENCE CODE */ status(A); rlpower(p1lvl, TODEV); if (sspul[0] == 'y') { rgpulse(1000*1e-6, zero, rof1, 0.0e-6); rgpulse(1000*1e-6, one, 0.0e-6, rof1); } hsdelay(d1); if (getflag("wet")) wet4(zero,one); rlpower(p1lvl, TODEV); if (satmode[A] == 'y') { rlpower(satpwr,TODEV); rgpulse(satdly,zero,rof1,rof2); rlpower(p1lvl,TODEV);} status(B); rgpulse(p1, v1, rof1, 1.0e-6); if (satmode[B] =='y') { if (d2 > 0.0) { rlpower(satpwr,TODEV); rgpulse(d2 - (2*POWER_DELAY) - 1.0e-6 - (2*p1/3.1416),zero,0.0,0.0); } } else { if (d2 > 0.0) delay(d2 - POWER_DELAY - 1.0e-6 - (2*p1/3.1416)); } rcvroff(); rlpower(tpwr,TODEV); txphase(v13); xmtron(); delay(trim); if (cycles > 1.0) { starthardloop(v9); mleva(window); mleva(window); mlevb(window); mlevb(window); mlevb(window); mleva(window); mleva(window); mlevb(window); mlevb(window); mlevb(window); mleva(window); mleva(window); mleva(window); mlevb(window); mlevb(window); mleva(window); rgpulse(.66*pw,v3,rof1,rof2); endhardloop(); } txphase(v13); xmtroff(); /* detection */ delay(rof2); rcvron(); status(C); }
void pulsesequence() { double mix; char sspul[MAXSTR]; /* LOAD VARIABLES */ mix = getval("mix"); getstr("sspul", sspul); if (phase1 == 3) initval( (double)d2_index, v14); else assign(zero, v14); /* CHECK CONDITIONS */ if ((rof1 < 9.9e-6) && (ix == 1)) fprintf(stdout,"Warning: ROF1 is less than 10 us\n"); if (satpwr > 40) { printf("satpwr too large - acquisition aborted.\n"); psg_abort(1); } /* STEADY-STATE PHASECYCLING */ /* This section determines if the phase calculations trigger off of (SS - SSCTR) or off of CT */ ifzero(ssctr); mod2(ct, v2); hlv(ct, v3); elsenz(ssctr); sub(ssval, ssctr, v12); /* v12 = 0,...,ss-1 */ mod2(v12, v2); hlv(v12, v3); endif(ssctr); /* CALCULATE PHASECYCLE */ dbl(v2, v2); hlv(v3, v10); hlv(v10, v10); if (phase1 == 0) { assign(v10, v9); hlv(v10, v10); mod2(v9, v9); } else { assign(zero, v9); } assign(v10,v1); hlv(v10, v10); mod2(v1, v1); dbl(v1, v1); add(v9, v2, v2); mod2(v10, v10); add(v1, v2, oph); add(v3, oph, oph); add(v10, oph, oph); add(v10, v1, v1); add(v10, v2, v2); add(v10, v3, v3); add(v10,v14,v5); if (phase1 == 2) { incr(v2); incr(v5); } if (phase1 == 3) add(v2, v14, v2); /* TPPI phase increment */ /*HYPERCOMPLEX MODE USES REDFIELD TRICK TO MOVE AXIAL PEAKS TO EDGE */ if ((phase1==1)||(phase1==2)) { initval(2.0*(double)(d2_index%2),v6); add(v2,v6,v2); add(oph,v6,oph); add(v5,v6,v5); } /* BEGIN THE ACTUAL PULSE SEQUENCE */ status(A); if (sspul[A] == 'y') { obspower(tpwr-12); rgpulse(200*pw, zero, rof1, 0.0e-6); rgpulse(200*pw, one, 0.0e-6, rof1); obspower(tpwr); } if (d1>hst) hsdelay(d1); if (satmode[A] == 'y') { obspower(satpwr); rgpulse(satdly,v5,rof1,rof1); obspower(tpwr); } status(B); rgpulse(pw, v2, rof1, 1.0e-6); if (satmode[B] =='y') { if (d2 > 0.0) { obspower(satpwr); rgpulse(d2 - (2*POWER_DELAY) - rof1 - 11.0e-6 - (4.0*pw/3.14159),zero,5.0e-6,5.0e-6); obspower(tpwr); } } else { if (d2 > 0.0) delay(d2 - 1.0e-6 - rof1 - (4.0*pw/3.14159)); } rgpulse(pw, v1, rof1, 1.0e-6); if (satmode[B] == 'y') { hsdelay(hst); obspower(satpwr); rgpulse(mix-hst,zero,2.0e-6,rof1); obspower(tpwr); } else hsdelay(mix); rgpulse(pw, v3, rof1, rof2); status(C); /* Phase cycle: ...satdly(v5)...pw(v2)..d2..pw(v1)..mix...pw(v3)..at(oph) (for phase=1. for phase = 2 incr(v2) and incr(v5) ) v2 =[02] for axial peaks v1 =[02]16 for axial peaks v3 =[0123]2 "4 step phase cycle selection" v10 =[01]8 for quad image oph = v1+v2+v3+v10 v5: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v2: 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 v1: 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 v3: 0 0 1 1 2 2 3 3 0 0 1 1 2 2 3 3 1 1 2 2 3 3 0 0 1 1 2 2 3 3 0 0 oph:0 2 1 3 2 0 3 1 2 0 3 1 0 2 1 3 1 3 2 0 3 1 0 2 3 1 0 2 1 3 2 0 */ }
int main(int argc, char *argv[]) { int c, all, namesonly, downonly, uponly; const struct afswtch *afp = NULL; int ifindex; struct ifaddrs *ifap, *ifa; struct ifreq paifr; const struct sockaddr_dl *sdl; char options[1024], *cp, *namecp = NULL; const char *ifname; struct option *p; size_t iflen; all = downonly = uponly = namesonly = noload = verbose = 0; /* Parse leading line options */ strlcpy(options, "adklmnuv", sizeof(options)); for (p = opts; p != NULL; p = p->next) strlcat(options, p->opt, sizeof(options)); while ((c = getopt(argc, argv, options)) != -1) { switch (c) { case 'a': /* scan all interfaces */ all++; break; case 'd': /* restrict scan to "down" interfaces */ downonly++; break; case 'k': printkeys++; break; case 'l': /* scan interface names only */ namesonly++; break; case 'm': /* show media choices in status */ supmedia = 1; break; case 'n': /* suppress module loading */ noload++; break; case 'u': /* restrict scan to "up" interfaces */ uponly++; break; case 'v': verbose++; break; default: for (p = opts; p != NULL; p = p->next) if (p->opt[0] == c) { p->cb(optarg); break; } if (p == NULL) usage(); break; } } argc -= optind; argv += optind; /* -l cannot be used with -a or -m */ if (namesonly && (all || supmedia)) usage(); /* nonsense.. */ if (uponly && downonly) usage(); /* no arguments is equivalent to '-a' */ if (!namesonly && argc < 1) all = 1; /* -a and -l allow an address family arg to limit the output */ if (all || namesonly) { if (argc > 1) usage(); ifname = NULL; ifindex = 0; if (argc == 1) { afp = af_getbyname(*argv); if (afp == NULL) { warnx("Address family '%s' unknown.", *argv); usage(); } if (afp->af_name != NULL) argc--, argv++; /* leave with afp non-zero */ } } else { /* not listing, need an argument */ if (argc < 1) usage(); ifname = *argv; argc--, argv++; /* check and maybe load support for this interface */ ifmaybeload(ifname); ifindex = if_nametoindex(ifname); if (ifindex == 0) { /* * NOTE: We must special-case the `create' command * right here as we would otherwise fail when trying * to find the interface. */ if (argc > 0 && (strcmp(argv[0], "create") == 0 || strcmp(argv[0], "plumb") == 0)) { iflen = strlcpy(name, ifname, sizeof(name)); if (iflen >= sizeof(name)) errx(1, "%s: cloning name too long", ifname); ifconfig(argc, argv, 1, NULL); exit(0); } #ifdef JAIL /* * NOTE: We have to special-case the `-vnet' command * right here as we would otherwise fail when trying * to find the interface as it lives in another vnet. */ if (argc > 0 && (strcmp(argv[0], "-vnet") == 0)) { iflen = strlcpy(name, ifname, sizeof(name)); if (iflen >= sizeof(name)) errx(1, "%s: interface name too long", ifname); ifconfig(argc, argv, 0, NULL); exit(0); } #endif errx(1, "interface %s does not exist", ifname); } } /* Check for address family */ if (argc > 0) { afp = af_getbyname(*argv); if (afp != NULL) argc--, argv++; } if (getifaddrs(&ifap) != 0) err(EXIT_FAILURE, "getifaddrs"); cp = NULL; ifindex = 0; for (ifa = ifap; ifa; ifa = ifa->ifa_next) { memset(&paifr, 0, sizeof(paifr)); strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name)); if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) { memcpy(&paifr.ifr_addr, ifa->ifa_addr, ifa->ifa_addr->sa_len); } if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0) continue; if (ifa->ifa_addr->sa_family == AF_LINK) sdl = (const struct sockaddr_dl *) ifa->ifa_addr; else sdl = NULL; if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly) continue; iflen = strlcpy(name, ifa->ifa_name, sizeof(name)); if (iflen >= sizeof(name)) { warnx("%s: interface name too long, skipping", ifa->ifa_name); continue; } cp = ifa->ifa_name; if ((ifa->ifa_flags & IFF_CANTCONFIG) != 0) continue; if (downonly && (ifa->ifa_flags & IFF_UP) != 0) continue; if (uponly && (ifa->ifa_flags & IFF_UP) == 0) continue; /* * Are we just listing the interfaces? */ if (namesonly) { if (namecp == cp) continue; if (afp != NULL) { /* special case for "ether" address family */ if (!strcmp(afp->af_name, "ether")) { if (sdl == NULL || (sdl->sdl_type != IFT_ETHER && sdl->sdl_type != IFT_L2VLAN && sdl->sdl_type != IFT_BRIDGE) || sdl->sdl_alen != ETHER_ADDR_LEN) continue; } else { if (ifa->ifa_addr->sa_family != afp->af_af) continue; } } namecp = cp; ifindex++; if (ifindex > 1) printf(" "); fputs(name, stdout); continue; } ifindex++; if (argc > 0) ifconfig(argc, argv, 0, afp); else status(afp, sdl, ifa); } if (namesonly) printf("\n"); freeifaddrs(ifap); exit(0); }
void pulsesequence() { int i, relay; /* GET NEW PARAMETERS */ relay = (int) (getval("relay") + 0.5); /* CHECK CONDITIONS */ if (p1 == 0.0) p1 = pw; /* CALCULATE PHASES */ sub(ct, ssctr, v11); /* v11 = ct-ss */ initval(256.0, v12); add(v11, v12, v11); /* v11 = ct-ss+256 */ hlv(v11, v1); /* v1 = cyclops = 00112233 */ for (i = 0; i < relay + 1; i++) hlv(v1, v1); /* cyclops = 2**(relay+2) 0's, 1's, 2's, 3's */ mod4(v11, v2); /* v2 = 0123 0123... */ dbl(v2, oph); /* oph = 0202 0202 */ add(v2, v1, v2); /* v2 = 0123 0123 + cyclops */ add(oph, v1, oph); /* oph = 0202 0202 + cyclops */ hlv(v11, v3); /* v3 = 0011 2233 4455 ... */ /* PULSE SEQUENCE */ status(A); if (rof1 == 0.0) { rof1 = 1.0e-6; /* phase switching time */ rcvroff(); } hsdelay(d1); /* preparation period */ status(B); rgpulse(pw, v1, rof1, rof1); delay(d2); /* evolution period */ status(A); if (relay == 0) delay(tau); /* for delayed cosy */ rgpulse(p1, v2, rof1, rof1); /* start of mixing period */ if (relay == 0) delay(tau); /* for delayed cosy */ for (i = 0; i < relay; i++) /* relay coherence */ { hlv(v3, v3); /* v3=2**(relay+1) 0's, 1's, 2's, 3's */ dbl(v3, v4); /* v4=2**(relay+1) 0's, 2's, 0's, 2's */ add(v2, v4, v5); /* v5=v4+v2 (including cyclops) */ delay(tau/2); rgpulse(2.0*pw, v2, rof1, rof1); delay(tau/2); rgpulse(pw, v5, rof1, rof1); } status(C); delay(rof2); rcvron(); }
nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, nsIURI* aURL) { nsresult rv = NS_OK; // If we don't yet have a stream listener, we need to get // one from the plugin. // NOTE: this should only happen when a stream was NOT created // with GetURL or PostURL (i.e. it's the initial stream we // send to the plugin as determined by the SRC or DATA attribute) if (!mPStreamListener) { if (!mPluginInstance) { return NS_ERROR_FAILURE; } nsRefPtr<nsNPAPIPluginStreamListener> streamListener; rv = mPluginInstance->NewStreamListener(nullptr, nullptr, getter_AddRefs(streamListener)); if (NS_FAILED(rv) || !streamListener) { return NS_ERROR_FAILURE; } mPStreamListener = static_cast<nsNPAPIPluginStreamListener*>(streamListener.get()); } mPStreamListener->SetStreamListenerPeer(this); bool useLocalCache = false; // get httpChannel to retrieve some info we need for nsIPluginStreamInfo setup nsCOMPtr<nsIChannel> channel = do_QueryInterface(request); nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel); /* * Assumption * By the time nsPluginStreamListenerPeer::OnDataAvailable() gets * called, all the headers have been read. */ if (httpChannel) { // Reassemble the HTTP response status line and provide it to our // listener. Would be nice if we could get the raw status line, // but nsIHttpChannel doesn't currently provide that. // Status code: required; the status line isn't useful without it. uint32_t statusNum; if (NS_SUCCEEDED(httpChannel->GetResponseStatus(&statusNum)) && statusNum < 1000) { // HTTP version: provide if available. Defaults to empty string. nsCString ver; nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal = do_QueryInterface(channel); if (httpChannelInternal) { uint32_t major, minor; if (NS_SUCCEEDED(httpChannelInternal->GetResponseVersion(&major, &minor))) { ver = nsPrintfCString("/%lu.%lu", major, minor); } } // Status text: provide if available. Defaults to "OK". nsCString statusText; if (NS_FAILED(httpChannel->GetResponseStatusText(statusText))) { statusText = "OK"; } // Assemble everything and pass to listener. nsPrintfCString status("HTTP%s %lu %s", ver.get(), statusNum, statusText.get()); static_cast<nsIHTTPHeaderListener*>(mPStreamListener)->StatusLine(status.get()); } // Also provide all HTTP response headers to our listener. httpChannel->VisitResponseHeaders(this); mSeekable = false; // first we look for a content-encoding header. If we find one, we tell the // plugin that stream is not seekable, because the plugin always sees // uncompressed data, so it can't make meaningful range requests on a // compressed entity. Also, we force the plugin to use // nsPluginStreamType_AsFile stream type and we have to save decompressed // file into local plugin cache, because necko cache contains original // compressed file. nsAutoCString contentEncoding; if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"), contentEncoding))) { useLocalCache = true; } else { // set seekability (seekable if the stream has a known length and if the // http server accepts byte ranges). uint32_t length; GetLength(&length); if (length) { nsAutoCString range; if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("accept-ranges"), range)) && range.Equals(NS_LITERAL_CSTRING("bytes"), nsCaseInsensitiveCStringComparator())) { mSeekable = true; } } } // we require a content len // get Last-Modified header for plugin info nsAutoCString lastModified; if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("last-modified"), lastModified)) && !lastModified.IsEmpty()) { PRTime time64; PR_ParseTimeString(lastModified.get(), true, &time64); //convert string time to integer time // Convert PRTime to unix-style time_t, i.e. seconds since the epoch double fpTime; LL_L2D(fpTime, time64); mModified = (uint32_t)(fpTime * 1e-6 + 0.5); } } rv = mPStreamListener->OnStartBinding(this); mStartBinding = true; if (NS_FAILED(rv)) return rv; mPStreamListener->GetStreamType(&mStreamType); if (!useLocalCache && mStreamType >= NP_ASFILE) { // check it out if this is not a file channel. nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(request); if (!fileChannel) { // and browser cache is not available nsCOMPtr<nsICachingChannel> cacheChannel = do_QueryInterface(request); if (!(cacheChannel && (NS_SUCCEEDED(cacheChannel->SetCacheAsFile(true))))) { useLocalCache = true; } } } if (useLocalCache) { SetupPluginCacheFile(channel); } return NS_OK; }
UINT vmsBtDownloadImpl::GetUploadSpeedIncludingServiceTraffic () { if (m_handle.is_valid () == false) return 0; return (UINT)status ().upload_rate; }
void RBBIAPITest::TestGetSetAdoptText() { logln((UnicodeString)"Testing getText setText "); IcuTestErrorCode status(*this, "TestGetSetAdoptText"); UnicodeString str1="first string."; UnicodeString str2="Second string."; LocalPointer<RuleBasedBreakIterator> charIter1((RuleBasedBreakIterator*)RuleBasedBreakIterator::createCharacterInstance(Locale::getDefault(), status)); LocalPointer<RuleBasedBreakIterator> wordIter1((RuleBasedBreakIterator*)RuleBasedBreakIterator::createWordInstance(Locale::getDefault(), status)); if(status.isFailure()){ errcheckln(status, "Fail : in construction - %s", status.errorName()); return; } CharacterIterator* text1= new StringCharacterIterator(str1); CharacterIterator* text1Clone = text1->clone(); CharacterIterator* text2= new StringCharacterIterator(str2); CharacterIterator* text3= new StringCharacterIterator(str2, 3, 10, 3); // "ond str" wordIter1->setText(str1); CharacterIterator *tci = &wordIter1->getText(); UnicodeString tstr; tci->getText(tstr); TEST_ASSERT(tstr == str1); if(wordIter1->current() != 0) errln((UnicodeString)"ERROR:1 setText did not set the iteration position to the beginning of the text, it is" + wordIter1->current() + (UnicodeString)"\n"); wordIter1->next(2); wordIter1->setText(str2); if(wordIter1->current() != 0) errln((UnicodeString)"ERROR:2 setText did not reset the iteration position to the beginning of the text, it is" + wordIter1->current() + (UnicodeString)"\n"); charIter1->adoptText(text1Clone); TEST_ASSERT(wordIter1->getText() != charIter1->getText()); tci = &wordIter1->getText(); tci->getText(tstr); TEST_ASSERT(tstr == str2); tci = &charIter1->getText(); tci->getText(tstr); TEST_ASSERT(tstr == str1); LocalPointer<RuleBasedBreakIterator> rb((RuleBasedBreakIterator*)wordIter1->clone()); rb->adoptText(text1); if(rb->getText() != *text1) errln((UnicodeString)"ERROR:1 error in adoptText "); rb->adoptText(text2); if(rb->getText() != *text2) errln((UnicodeString)"ERROR:2 error in adoptText "); // Adopt where iterator range is less than the entire orignal source string. // (With the change of the break engine to working with UText internally, // CharacterIterators starting at positions other than zero are not supported) rb->adoptText(text3); TEST_ASSERT(rb->preceding(2) == 0); TEST_ASSERT(rb->following(11) == BreakIterator::DONE); //if(rb->preceding(2) != 3) { // errln((UnicodeString)"ERROR:3 error in adoptText "); //} //if(rb->following(11) != BreakIterator::DONE) { // errln((UnicodeString)"ERROR:4 error in adoptText "); //} // UText API // // Quick test to see if UText is working at all. // const char *s1 = "\x68\x65\x6C\x6C\x6F\x20\x77\x6F\x72\x6C\x64"; /* "hello world" in UTF-8 */ const char *s2 = "\x73\x65\x65\x20\x79\x61"; /* "see ya" in UTF-8 */ // 012345678901 status.reset(); LocalUTextPointer ut(utext_openUTF8(NULL, s1, -1, status)); wordIter1->setText(ut.getAlias(), status); TEST_ASSERT_SUCCESS(status); int32_t pos; pos = wordIter1->first(); TEST_ASSERT(pos==0); pos = wordIter1->next(); TEST_ASSERT(pos==5); pos = wordIter1->next(); TEST_ASSERT(pos==6); pos = wordIter1->next(); TEST_ASSERT(pos==11); pos = wordIter1->next(); TEST_ASSERT(pos==UBRK_DONE); status.reset(); LocalUTextPointer ut2(utext_openUTF8(NULL, s2, -1, status)); TEST_ASSERT_SUCCESS(status); wordIter1->setText(ut2.getAlias(), status); TEST_ASSERT_SUCCESS(status); pos = wordIter1->first(); TEST_ASSERT(pos==0); pos = wordIter1->next(); TEST_ASSERT(pos==3); pos = wordIter1->next(); TEST_ASSERT(pos==4); pos = wordIter1->last(); TEST_ASSERT(pos==6); pos = wordIter1->previous(); TEST_ASSERT(pos==4); pos = wordIter1->previous(); TEST_ASSERT(pos==3); pos = wordIter1->previous(); TEST_ASSERT(pos==0); pos = wordIter1->previous(); TEST_ASSERT(pos==UBRK_DONE); status.reset(); UnicodeString sEmpty; LocalUTextPointer gut2(utext_openUnicodeString(NULL, &sEmpty, status)); wordIter1->getUText(gut2.getAlias(), status); TEST_ASSERT_SUCCESS(status); status.reset(); }
int vmsBtDownloadImpl::get_ConnectionCount () { if (m_handle.is_valid () == false) return 0; return status ().num_peers; }
void bv_refinementt::check_UNSAT(approximationt &a) { // part of the conflict? if(!is_in_conflict(a)) return; status() << "Found assumption for `" << a.as_string() << "' in proof (state " << a.under_state << ")" << eom; assert(!a.under_assumptions.empty()); a.under_assumptions.clear(); if(a.expr.type().id()==ID_floatbv) { const floatbv_typet &floatbv_type=to_floatbv_type(a.expr.type()); ieee_float_spect spec=floatbv_type; a.under_assumptions.reserve(a.op0_bv.size()+a.op1_bv.size()); float_utilst float_utils(prop); float_utils.spec=spec; // the fraction without hidden bit const bvt fraction0=float_utils.get_fraction(a.op0_bv); const bvt fraction1=float_utils.get_fraction(a.op1_bv); if(a.under_state==0) { // we first set sign and exponent free, // but keep the fraction zero for(unsigned i=0; i<fraction0.size(); i++) a.add_under_assumption(prop.lnot(fraction0[i])); for(unsigned i=0; i<fraction1.size(); i++) a.add_under_assumption(prop.lnot(fraction1[i])); } else { // now fraction: make this grow quadratically unsigned x=a.under_state*a.under_state; if(x>=MAX_FLOAT_UNDERAPPROX && x>=a.result_bv.size()) { // make it free altogether, this guarantees progress } else { // set x bits of both exponent and mantissa free // need to start with most-significant bits #if 0 for(unsigned i=x; i<fraction0.size(); i++) a.add_under_assumption(prop.lnot( fraction0[fraction0.size()-i-1])); for(unsigned i=x; i<fraction1.size(); i++) a.add_under_assumption(prop.lnot( fraction1[fraction1.size()-i-1])); #endif } } } else { unsigned x=a.under_state+1; if(x>=MAX_INTEGER_UNDERAPPROX && x>=a.result_bv.size()) { // make it free altogether, this guarantees progress } else { // set x least-significant bits free a.under_assumptions.reserve(a.op0_bv.size()+a.op1_bv.size()); for(unsigned i=x; i<a.op0_bv.size(); i++) a.add_under_assumption(prop.lnot(a.op0_bv[i])); for(unsigned i=x; i<a.op1_bv.size(); i++) a.add_under_assumption(prop.lnot(a.op1_bv[i])); } } a.under_state++; progress=true; }
bool vmsBtDownloadImpl::is_PieceCompleted (int nIndex) { if (m_handle.is_valid ()) return status().pieces.empty() ? false : m_status.pieces[nIndex]; return false; }
void CNcdServerReportManager::NodeSetAsInstalledRequestL( MCatalogsBaseMessage& aMessage ) { HBufC8* input = HBufC8::NewLC( aMessage.InputLength() ); TPtr8 inputPtr = input->Des(); aMessage.ReadInput( inputPtr ); RDesReadStream inputStream( *input ); CleanupClosePushL( inputStream ); TInt errorCode( inputStream.ReadInt32L() ); CNcdNodeIdentifier* identifier( CNcdNodeIdentifier::NewLC( inputStream ) ); CNcdReportManager& reportManager( ReportManagerL( aMessage ) ); CNcdNode& node( Provider().NodeManager().NodeL( *identifier ) ); CNcdNodeMetaData& metaData( node.NodeMetaDataL() ); TNcdReportStatusInfo info( ENcdReportCreate, errorCode ); // Use the node identifier to identify the content in install report. // Node id uniquely identifies the node that contains contents // that will be installed. One node may contains multiple contents but // they are all thought as one bundle, in one operation. Also, notice that // multiple nodes can contain same metadata and same content. TNcdReportId reportId = reportManager.RegisterInstallL( identifier->NodeId(), metaData.Identifier(), info, metaData.Identifier().ServerUri(), metaData.Identifier().NodeNameSpace() ); // Set access point for report. UpdateInstallReportAccessPointL( aMessage.Session().Context().FamilyId(), reportId, node, metaData, reportManager, HttpSessionL( aMessage.Session().Context() ) ); // Set the final success information directly into the report instead of // reporting other install statuses here. TNcdReportStatus status( ENcdReportSuccess ); if ( errorCode == KErrNone ) { status = ENcdReportSuccess; } else if ( errorCode == KErrCancel ) { status = ENcdReportCancel; } else { status = ENcdReportFail; } // Create the status info object with the given info. info.iStatus = status; info.iErrorCode = errorCode; reportManager.ReportInstallStatusL( reportId, info ); CleanupStack::PopAndDestroy( identifier ); CleanupStack::PopAndDestroy( &inputStream ); CleanupStack::PopAndDestroy( input ); aMessage.CompleteAndRelease( KErrNone ); }
UINT64 vmsBtDownloadImpl::get_TotalUploadedByteCount () { if (m_handle.is_valid () == false) return 0; return status ().total_payload_upload; }
int main(int argc, char *argv[]) { Teuchos::GlobalMPISession mpiSession(&argc, &argv); // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided. int iprint = argc - 1; Teuchos::RCP<std::ostream> outStream; Teuchos::oblackholestream bhs; // outputs nothing if (iprint > 0) outStream = Teuchos::rcp(&std::cout, false); else outStream = Teuchos::rcp(&bhs, false); int errorFlag = 0; // *** Example body. try { int dim = 128; // Set problem dimension. ROL::ZOO::Objective_PoissonInversion<RealT> obj(dim, 1e-6); Teuchos::ParameterList parlist; // Basic algorithm. parlist.set("Trust-Region Subproblem Solver Type", "Truncated CG"); // Krylov parameters. parlist.set("Absolute Krylov Tolerance", 1.e-4); parlist.set("Relative Krylov Tolerance", 1.e-2); parlist.set("Maximum Number of Krylov Iterations", 50); // Define step. ROL::TrustRegionStep<RealT> step(parlist); // Define status test. RealT gtol = 1e-12; // norm of gradient tolerance RealT stol = 1e-14; // norm of step tolerance int maxit = 100; // maximum number of iterations ROL::StatusTest<RealT> status(gtol, stol, maxit); // Define algorithm. ROL::DefaultAlgorithm<RealT> algo(step,status,false); // Iteration vector. Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp( new std::vector<RealT> (dim, 0.0) ); // Set initial guess. for (int i=0; i<dim; i++) { (*x_rcp)[i] = 0.1; } ROL::StdVector<RealT> x(x_rcp); // Run algorithm. std::vector<std::string> output = algo.run(x, obj, false); for ( unsigned i = 0; i < output.size(); i++ ) { std::cout << output[i]; } // Compute dense Hessian matrix. Teuchos::SerialDenseMatrix<int, RealT> H(x.dimension(), x.dimension()); H = ROL::computeDenseHessian<RealT>(obj, x); //H.print(*outStream); // Compute and print eigenvalues. std::vector<std::vector<RealT> > eigenvals = ROL::computeEigenvalues<RealT>(H); *outStream << "\nEigenvalues:\n"; for (unsigned i=0; i<(eigenvals[0]).size(); i++) { if (i==0) { *outStream << std::right << std::setw(28) << "Real" << std::setw(28) << "Imag" << "\n"; } *outStream << std::scientific << std::setprecision(16) << std::right << std::setw(28) << (eigenvals[0])[i] << std::setw(28) << (eigenvals[1])[i] << "\n"; } // Compute and print generalized eigenvalues. Teuchos::SerialDenseMatrix<int, RealT> M = computeDotMatrix(x); //M.print(*outStream); std::vector<std::vector<RealT> > genEigenvals = ROL::computeGenEigenvalues<RealT>(H, M); *outStream << "\nGeneralized eigenvalues:\n"; for (unsigned i=0; i<(genEigenvals[0]).size(); i++) { if (i==0) { *outStream << std::right << std::setw(28) << "Real" << std::setw(28) << "Imag" << "\n"; } *outStream << std::scientific << std::setprecision(16) << std::right << std::setw(28) << (genEigenvals[0])[i] << std::setw(28) << (genEigenvals[1])[i] << "\n"; } // Sort and compare eigenvalues and generalized eigenvalues - should be close. std::sort((eigenvals[0]).begin(), (eigenvals[0]).end()); std::sort((eigenvals[1]).begin(), (eigenvals[1]).end()); std::sort((genEigenvals[0]).begin(), (genEigenvals[0]).end()); std::sort((genEigenvals[1]).begin(), (genEigenvals[1]).end()); RealT errtol = std::sqrt(ROL::ROL_EPSILON); for (unsigned i=0; i<(eigenvals[0]).size(); i++) { if ( std::abs( (genEigenvals[0])[i] - (eigenvals[0])[i] ) > errtol*((eigenvals[0])[i]+ROL::ROL_THRESHOLD) ) { errorFlag++; *outStream << std::scientific << std::setprecision(20) << "Real genEigenvals - eigenvals (" << i << ") = " << std::abs( (genEigenvals[0])[i] - (eigenvals[0])[i] ) << " > " << errtol*((eigenvals[0])[i]+1e4*ROL::ROL_THRESHOLD) << "\n"; } if ( std::abs( (genEigenvals[1])[i] - (eigenvals[1])[i] ) > errtol*((eigenvals[1])[i]+ROL::ROL_THRESHOLD) ) { errorFlag++; *outStream << std::scientific << std::setprecision(20) << "Imag genEigenvals - eigenvals (" << i << ") = " << std::abs( (genEigenvals[1])[i] - (eigenvals[1])[i] ) << " > " << errtol*((eigenvals[1])[i]+ROL::ROL_THRESHOLD) << "\n"; } } // Compute inverse of Hessian. Teuchos::SerialDenseMatrix<int, RealT> invH = ROL::computeInverse<RealT>(H); Teuchos::SerialDenseMatrix<int, RealT> HinvH(H); // Multiply with Hessian and verify that it gives the identity (l2 dot matrix M from above). HinvH.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, H, invH, 0.0); //*outStream << std::scientific << std::setprecision(6); HinvH.print(*outStream); HinvH -= M; if (HinvH.normOne() > errtol) { errorFlag++; *outStream << std::scientific << std::setprecision(20) << "1-norm of H*inv(H) - I = " << HinvH.normOne() << " > " << errtol << "\n"; } // Use Newton algorithm. parlist.set("Descent Type", "Newton's Method"); // Define step. ROL::LineSearchStep<RealT> newton_step(parlist); // Define algorithm. ROL::DefaultAlgorithm<RealT> newton_algo(newton_step,status,false); // Reset initial guess. for (int i=0; i<dim; i++) { (*x_rcp)[i] = 0.1; } // Run Newton algorithm. output = newton_algo.run(x, obj, false); for ( unsigned i = 0; i < output.size(); i++ ) { std::cout << output[i]; } Teuchos::RCP<const ROL::AlgorithmState<RealT> > new_state = newton_algo.getState(); Teuchos::RCP<const ROL::AlgorithmState<RealT> > old_state = algo.getState(); if ( std::abs(new_state->value - old_state->value) > errtol ) { errorFlag++; *outStream << std::scientific << std::setprecision(20) << "\nabs(new_optimal_value - old_optimal_value) = " << std::abs(new_state->value - old_state->value) << " > " << errtol << "\n"; } } catch (std::logic_error err) { *outStream << err.what() << "\n"; errorFlag = -1000; }; // end try if (errorFlag != 0) std::cout << "End Result: TEST FAILED\n"; else std::cout << "End Result: TEST PASSED\n"; return 0; }
pulsesequence() { /* DECLARE VARIABLES */ char autocal[MAXSTR], /* auto-calibration flag */ fsat[MAXSTR], fscuba[MAXSTR], f1180[MAXSTR], /* Flag to start t1 @ halfdwell */ f2180[MAXSTR], /* Flag to start t2 @ halfdwell */ fc180[MAXSTR], /* Flag for checking sequence */ ddseq[MAXSTR], /* deuterium decoupling sequence */ spcosed[MAXSTR], /* waveform Co seduce 180 */ spcareb[MAXSTR], /* waveform Ca reburp 180 */ spca180[MAXSTR], /* waveform Ca hard 180 */ sel_flg[MAXSTR], shp_sl[MAXSTR], cacb_dec[MAXSTR], cacbdecseq[MAXSTR], nietl_flg[MAXSTR]; int phase, phase2, ni, icosel, t1_counter, /* used for states tppi in t1 */ t2_counter; /* used for states tppi in t2 */ double tau1, /* t1 delay */ tau2, /* t2 delay */ taua, /* ~ 1/4JNH = 2.25 ms */ taub, /* ~ 1/4JNH = 2.25 ms */ tauc, /* ~ 1/4JNCa = ~13 ms */ taud, /* ~ 1/4JCaC' = 3~4.5 ms ms */ bigTN, /* nitrogen T period */ pwc90, /* PW90 for ca nucleus @ d_c90 */ pwca180, /* PW180 for ca nucleus @ d_c180 */ pwca180dec, /* pwca180+pad */ pwcareb, /* pw180 at d_creb ~ 1.6 ms at 600 MHz */ pwcosed, /* PW180 at d_csed ~ 200us at 600 MHz */ tsatpwr, /* low level 1H trans.power for presat */ d_c90, /* power level for 13C pulses(pwc90=sqrt(15)/4delta delta is the separation between Ca and Co */ d_c180, /* power level for pwca180(sqrt(3)/2delta) */ d_creb, /* power level for pwcareb */ d_csed, /* power level for pwcosed */ sw1, /* sweep width in f1 */ sw2, /* sweep width in f2 */ pw_sl, /* selective pulse on water */ tpwrsl, /* power for pw_sl */ at, sphase, /* small angle phase shift */ sphase1, phase_sl, d_cacbdec, pwcacbdec, dres_dec, pwD, /* PW90 for higher power (pwDlvl) deut 90 */ pwDlvl, /* high power for deut 90 hard pulse */ compC, /* C-13 RF calibration parameters */ pwC, pwClvl, pwN, /* PW90 for 15N pulse */ pwNlvl, /* high dec2 pwr for 15N hard pulses */ gstab, gt1, gt2, gt3, gt4, gt5, gt6, gt7, gt8, gt9, gt10, gzlvl1, gzlvl2, gzlvl3, gzlvl4, gzlvl5, gzlvl6, gzlvl7, gzlvl8, gzlvl9, gzlvl10; /* LOAD VARIABLES */ getstr("autocal",autocal); getstr("fsat",fsat); getstr("f1180",f1180); getstr("f2180",f2180); getstr("fc180",fc180); getstr("fscuba",fscuba); getstr("ddseq",ddseq); getstr("shp_sl",shp_sl); getstr("sel_flg",sel_flg); getstr("cacb_dec",cacb_dec); getstr("nietl_flg",nietl_flg); taua = getval("taua"); taub = getval("taub"); tauc = getval("tauc"); taud = getval("taud"); bigTN = getval("bigTN"); pwN = getval("pwN"); tpwr = getval("tpwr"); tsatpwr = getval("tsatpwr"); dpwr = getval("dpwr"); pwNlvl = getval("pwNlvl"); pwD = getval("pwD"); pwDlvl = getval("pwDlvl"); phase = (int) ( getval("phase") + 0.5); phase2 = (int) ( getval("phase2") + 0.5); sw1 = getval("sw1"); sw2 = getval("sw2"); ni = getval("ni"); pw_sl = getval("pw_sl"); tpwrsl = getval("tpwrsl"); at = getval("at"); sphase = getval("sphase"); sphase1 = getval("sphase1"); phase_sl = getval("phase_sl"); gstab = getval("gstab"); gt1 = getval("gt1"); if (getval("gt2") > 0) gt2=getval("gt2"); else gt2=gt1*0.1; gt3 = getval("gt3"); gt4 = getval("gt4"); gt5 = getval("gt5"); gt6 = getval("gt6"); gt7 = getval("gt7"); gt8 = getval("gt8"); gt9 = getval("gt9"); gt10 = getval("gt10"); gzlvl1 = getval("gzlvl1"); gzlvl2 = getval("gzlvl2"); gzlvl3 = getval("gzlvl3"); gzlvl4 = getval("gzlvl4"); gzlvl5 = getval("gzlvl5"); gzlvl6 = getval("gzlvl6"); gzlvl7 = getval("gzlvl7"); gzlvl8 = getval("gzlvl8"); gzlvl9 = getval("gzlvl9"); gzlvl10 = getval("gzlvl10"); if(autocal[0]=='n') { getstr("spcosed",spcosed); getstr("spcareb",spcareb); getstr("spca180",spca180); getstr("cacbdecseq",cacbdecseq); d_c90 = getval("d_c90"); d_c180 = getval("d_c180"); d_creb = getval("d_creb"); d_csed = getval("d_csed"); pwc90 = getval("pwc90"); pwca180 = getval("pwca180"); pwca180dec = getval("pwca180dec"); pwcareb = getval("pwcareb"); pwcosed = getval("pwcosed"); d_cacbdec = getval("d_cacbdec"); pwcacbdec = getval("pwcacbdec"); dres_dec = getval("dres_dec"); } else { strcpy(spcosed,"Phard_118p"); strcpy(spcareb,"Preburp_-15p"); strcpy(spca180,"Phard_-118p"); strcpy(cacbdecseq,"Pcb_dec"); if (FIRST_FID) { compC = getval("compC"); pwC = getval("pwC"); pwClvl = getval("pwClvl"); co180 = pbox(spcosed, CO180, CA180ps, dfrq, compC*pwC, pwClvl); creb = pbox(spcareb, CREB180, CAB180ps, dfrq, compC*pwC, pwClvl); ca180 = pbox(spca180, CA180, CA180ps, dfrq, compC*pwC, pwClvl); cbdec = pbox(cacbdecseq, CBDEC,CBDECps, dfrq, compC*pwC, pwClvl); c90 = pbox("Phard90", C90, CA180ps, dfrq, compC*pwC, pwClvl); } d_c90 = c90.pwr; d_c180 = ca180.pwr; d_creb = creb.pwr; d_csed = co180.pwr; pwc90 = c90.pw; pwca180 = ca180.pw; pwca180dec = ca180.pw; pwcareb = creb.pw; pwcosed = co180.pw; d_cacbdec = cbdec.pwr; pwcacbdec = 1.0/cbdec.dmf; dres_dec = cbdec.dres; } /* LOAD PHASE TABLE */ settable(t1,2,phi1); settable(t2,4,phi2); settable(t3,8,phi3); settable(t4,2,phi4); settable(t5,1,phi5); settable(t6,8,rec); /* CHECK VALIDITY OF PARAMETER RANGES */ if(ix==1) printf("Uses shared AT in the N dimension. Choose ni2 as desired\n"); if((dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' )) { printf("incorrect dec1 decoupler flags! "); psg_abort(1); } if((dm2[A] == 'y' || dm2[B] == 'y' || dm2[C] == 'y')) { printf("incorrect dec2 decoupler flags! Should be 'nnn' "); psg_abort(1); } if( tsatpwr > 6 ) { printf("TSATPWR too large !!! "); psg_abort(1); } if( dpwr > -16 ) { printf("DPWR too large! "); psg_abort(1); } if( dpwr2 > -16 ) { printf("DPWR2 too large! "); psg_abort(1); } if( pw > 200.0e-6 ) { printf("dont fry the probe, pw too high ! "); psg_abort(1); } if( pwN > 200.0e-6 ) { printf("dont fry the probe, pwN too high ! "); psg_abort(1); } if( gt1 > 3e-3 || gt2 > 3e-3 || gt3 > 3e-3 || gt4 > 3e-3 || gt5 > 3e-3 || gt6 > 3e-3 || gt7 > 3e-3 || gt8 > 3e-3 || gt9 > 3e-3 || gt10 > 3e-3) { printf("gti values must be < 3e-3\n"); psg_abort(1); } if(tpwrsl > 30) { printf("tpwrsl must be less than 25\n"); psg_abort(1); } if( pwDlvl > 59) { printf("pwDlvl too high\n"); psg_abort(1); } if( dpwr3 > 50) { printf("dpwr3 too high\n"); psg_abort(1); } if( pw_sl > 10e-3) { printf("too long pw_sl\n"); psg_abort(1); } if(d_cacbdec > 40) { printf("d_cacbdec is too high; < 41\n"); psg_abort(1); } if(nietl_flg[A] == 'y' && sel_flg[A] == 'y') { printf("nietl_flg and sel_flg cannot both be y\n"); psg_abort(1); } if (fc180[A] =='y' && ni > 1.0) { text_error("must set fc180='n' to allow C' evolution (ni>1)\n"); psg_abort(1); } /* Phase incrementation for hypercomplex 2D data */ if (phase == 2) tsadd(t2,1,4); if (phase2 == 2) { tsadd(t5,2,4); icosel = 1; } else icosel = -1; if (nietl_flg[A] == 'y') icosel = -1*icosel; /* Set up f1180 tau2 = t1 */ tau1 = d2; if(f1180[A] == 'y') { tau1 += ( 1.0 / (2.0*sw1) - 4.0/PI*pwc90 - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwca180dec - WFG_STOP_DELAY - 2.0*pwN - POWER_DELAY - 4.0e-6); } if(f1180[A] == 'n') tau1 = ( tau1 - 4.0/PI*pwc90 - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwca180dec - WFG_STOP_DELAY - 2.0*pwN - POWER_DELAY - 4.0e-6); if(tau1 < 0.2e-6) tau1 = 0.2e-6; tau1 = tau1/2.0; /* Set up f2180 tau2 = t2 */ tau2 = d3; if(f2180[A] == 'y') { tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.2e-6; } tau2 = tau2/2.0; /* Calculate modifications to phases for States-TPPI acquisition */ if( ix == 1) d2_init = d2 ; t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 ); if(t1_counter % 2) { tsadd(t2,2,4); tsadd(t6,2,4); } if( ix == 1) d3_init = d3 ; t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 ); if(t2_counter % 2) { tsadd(t3,2,4); tsadd(t6,2,4); } /* BEGIN ACTUAL PULSE SEQUENCE */ status(A); obspower(tsatpwr); /* Set transmitter power for 1H presaturation */ decpower(d_c180); /* Set Dec1 power to high power */ dec2power(pwNlvl); /* Set Dec2 power for 15N hard pulses */ decoffset(dof); /* Presaturation Period */ if (fsat[0] == 'y') { delay(2.0e-5); rgpulse(d1,zero,2.0e-6,2.0e-6); obspower(tpwr); /* Set transmitter power for hard 1H pulses */ delay(2.0e-5); if(fscuba[0] == 'y') { delay(2.2e-2); rgpulse(pw,zero,2.0e-6,0.0); rgpulse(2*pw,one,2.0e-6,0.0); rgpulse(pw,zero,2.0e-6,0.0); delay(2.2e-2); } } else { delay(d1); } obspower(tpwr); /* Set transmitter power for hard 1H pulses */ txphase(zero); dec2phase(zero); delay(1.0e-5); /* Begin Pulses */ status(B); rcvroff(); lk_hold(); delay(20.0e-6); initval(1.0,v2); obsstepsize(phase_sl); xmtrphase(v2); /* shaped pulse */ obspower(tpwrsl); shaped_pulse(shp_sl,pw_sl,one,4.0e-6,0.0); xmtrphase(zero); obspower(tpwr); txphase(zero); delay(4.0e-6); /* shaped pulse */ rgpulse(pw,zero,0.0,0.0); /* 90 deg 1H pulse */ delay(0.2e-6); zgradpulse(gzlvl5,gt5); delay(2.0e-6); delay(taua - gt5 - 2.2e-6); /* taua <= 1/4JNH */ sim3pulse(2*pw,0.0,2*pwN,zero,zero,zero,0.0,0.0); txphase(three); dec2phase(zero); decphase(zero); delay(taua - gt5 - 200.2e-6 - 2.0e-6); delay(0.2e-6); zgradpulse(gzlvl5,gt5); delay(200.0e-6); if (sel_flg[A] == 'n') { rgpulse(pw,three,2.0e-6,0.0); decpower(d_c180); delay(0.2e-6); zgradpulse(gzlvl3,gt3); delay(200.0e-6); dec2rgpulse(pwN,zero,0.0,0.0); delay(tauc); dec2rgpulse(2*pwN,zero,0.0,0.0); decrgpulse(pwca180,zero,0.0,0.0); dec2phase(one); delay(tauc - pwca180); dec2rgpulse(pwN,one,0.0,0.0); } else { rgpulse(pw,one,2.0e-6,0.0); decpower(d_c180); initval(1.0,v5); dec2stepsize(45.0); dcplr2phase(v5); delay(0.2e-6); zgradpulse(gzlvl3,gt3); delay(200.0e-6); dec2rgpulse(pwN,zero,0.0,0.0); dcplr2phase(zero); delay(1.34e-3 - SAPS_DELAY - 2.0*pw); rgpulse(pw,one,0.0,0.0); rgpulse(2.0*pw,zero,0.0,0.0); rgpulse(pw,one,0.0,0.0); delay(tauc - 1.34e-3 - 2.0*pw); dec2rgpulse(2*pwN,zero,0.0,0.0); decrgpulse(pwca180,zero,0.0,0.0); dec2phase(one); delay(tauc - pwca180); dec2rgpulse(pwN,one,0.0,0.0); } /* END sel_flg */ decphase(t1); decpower(d_c90); delay(0.2e-6); zgradpulse(gzlvl8,gt8); delay(200.0e-6); /* Cay to CaxC'z */ dec2phase(zero); txphase(zero); /* Turn on D decoupling using the third decoupler */ dec3phase(one); dec3power(pwDlvl); dec3rgpulse(pwD,one,4.0e-6,0.0); dec3phase(zero); dec3power(dpwr3); dec3unblank(); setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3); /* Turn on D decoupling */ if (cacb_dec[A] == 'n') { decrgpulse(pwc90,t1,2.0e-6,0.0); delay(taud -POWER_DELAY -4.0e-6 -WFG_START_DELAY); initval(1.0,v3); decstepsize(sphase); dcplrphase(v3); decpower(d_creb); decshaped_pulse(spcareb,pwcareb,zero,4.0e-6,0.0); dcplrphase(zero); decpower(d_csed); decshaped_pulse(spcosed,pwcosed,zero,4.0e-6,0.0); delay(taud - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY - POWER_DELAY - 2.0e-6); decpower(d_c90); decrgpulse(pwc90,one,2.0e-6,0.0); } else { decrgpulse(pwc90,t1,2.0e-6,0.0); /* CaCb dec on */ decpower(d_cacbdec); decprgon(cacbdecseq,pwcacbdec,dres_dec); decon(); /* CaCb dec on */ delay(taud - POWER_DELAY - PRG_START_DELAY - PRG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY); /* CaCb dec off */ decoff(); decprgoff(); /* CaCb dec off */ initval(1.0,v3); decstepsize(sphase); dcplrphase(v3); decpower(d_creb); decshaped_pulse(spcareb,pwcareb,zero,4.0e-6,0.0); dcplrphase(zero); decpower(d_csed); decshaped_pulse(spcosed,pwcosed,zero,4.0e-6,0.0); /* CaCb dec on */ decpower(d_cacbdec); decprgon(cacbdecseq,pwcacbdec,dres_dec); decon(); /* CaCb dec on */ delay(taud - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY - POWER_DELAY - PRG_START_DELAY - PRG_STOP_DELAY - POWER_DELAY - 2.0e-6); /* CaCb dec off */ decoff(); decprgoff(); /* CaCb dec off */ decpower(d_c90); decrgpulse(pwc90,one,2.0e-6,0.0); } /* END cacb_dec */ /* Turn off D decoupling */ setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3); dec3blank(); dec3phase(three); dec3power(pwDlvl); dec3rgpulse(pwD,three,4.0e-6,0.0); /* Turn off D decoupling */ decoffset(dof+(174-56)*dfrq); /* change Dec1 carrier to Co */ delay(2.0e-7); zgradpulse(gzlvl4,gt4); delay(100.0e-6); /* t1 period for C' chemical shift evolution; Ca 180 and N 180 are used to decouple */ decrgpulse(pwc90,t2,2.0e-6,0.0); if (fc180[A]=='n') { decpower(d_c180); delay(tau1); decshaped_pulse(spca180,pwca180dec,zero,4.0e-6,0.0); dec2rgpulse(2*pwN,zero,0.0,0.0); delay(tau1); decpower(d_c90); } else decrgpulse(2*pwc90,zero,0.0,0.0); decrgpulse(pwc90,zero,4.0e-6,0.0); decoffset(dof); /* set carrier to Ca */ delay(2.0e-7); zgradpulse(gzlvl9,gt9); delay(100.0e-6); /* Refocusing CayC'z to Cax */ /* Turn on D decoupling using the third decoupler */ dec3phase(one); dec3power(pwDlvl); dec3rgpulse(pwD,one,4.0e-6,0.0); dec3phase(zero); dec3power(dpwr3); dec3unblank(); setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3); /* Turn on D decoupling */ if (cacb_dec[A] == 'n') { decrgpulse(pwc90,zero,0.0e-6,0.0); delay(taud - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY); decpower(d_csed); decshaped_pulse(spcosed,pwcosed,zero,4.0e-6,0.0); decpower(d_creb); initval(1.0,v4); decstepsize(sphase1); dcplrphase(v4); decshaped_pulse(spcareb,pwcareb,zero,4.0e-6,0.0); dcplrphase(zero); delay(taud - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6); decpower(d_c90); decrgpulse(pwc90,one,4.0e-6,0.0); } else { decrgpulse(pwc90,zero,0.0e-6,0.0); /* CaCb dec on */ decpower(d_cacbdec); decprgon(cacbdecseq,pwcacbdec,dres_dec); decon(); /* CaCb dec on */ delay(taud - POWER_DELAY - PRG_START_DELAY - PRG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6 - WFG_START_DELAY); /* CaCb dec off */ decoff(); decprgoff(); /* CaCb dec off */ decpower(d_csed); decshaped_pulse(spcosed,pwcosed,zero,4.0e-6,0.0); decpower(d_creb); initval(1.0,v4); decstepsize(sphase1); dcplrphase(v4); decshaped_pulse(spcareb,pwcareb,zero,4.0e-6,0.0); dcplrphase(zero); /* CaCb dec on */ decpower(d_cacbdec); decprgon(cacbdecseq,pwcacbdec,dres_dec); decon(); /* CaCb dec on */ delay(taud - WFG_STOP_DELAY - POWER_DELAY - PRG_START_DELAY - PRG_STOP_DELAY - POWER_DELAY - 4.0e-6); /* CaCb dec off */ decoff(); decprgoff(); /* CaCb dec off */ decpower(d_c90); decrgpulse(pwc90,one,4.0e-6,0.0); } /* END cacb_dec */ /* Turn off D decoupling */ setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3); dec3blank(); dec3phase(three); dec3power(pwDlvl); dec3rgpulse(pwD,three,4.0e-6,0.0); /* Turn off D decoupling */ decpower(d_c180); txphase(zero); delay(2.0e-7); zgradpulse(gzlvl10,gt10); delay(100.0e-6); /* Constant t2 period */ if (bigTN - tau2 >= 0.2e-6) { dec2rgpulse(pwN,t3,2.0e-6,0.0); dec2phase(t4); delay(bigTN - tau2 + pwca180); dec2rgpulse(2*pwN,t4,0.0,0.0); decrgpulse(pwca180,zero,0.0,0.0); dec2phase(t5); decpower(d_csed); delay(bigTN - gt1 - 502.0e-6 - 2.0*GRADIENT_DELAY - POWER_DELAY - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY); delay(2.0e-6); zgradpulse(gzlvl1,gt1); delay(500.0e-6); decshaped_pulse(spcosed,pwcosed,zero,0.0,0.0); delay(tau2); sim3pulse(pw,0.0e-6,pwN,zero,zero,t5,0.0,0.0); } else { dec2rgpulse(pwN,t3,2.0e-6,0.0); dec2rgpulse(2.0*pwN,t4,2.0e-6,2.0e-6); dec2phase(t5); delay(tau2 - bigTN); decrgpulse(pwca180,zero,0.0,0.0); decpower(d_csed); delay(bigTN - pwca180 - POWER_DELAY - gt1 - 502.0e-6 - 2.0*GRADIENT_DELAY - WFG_START_DELAY - pwcosed - WFG_STOP_DELAY); delay(2.0e-6); zgradpulse(gzlvl1,gt1); delay(500.0e-6); decshaped_pulse(spcosed,pwcosed,zero,0.0,0.0); delay(tau2); sim3pulse(pw,0.0e-6,pwN,zero,zero,t5,0.0,0.0); } if (nietl_flg[A] == 'n') { delay(0.2e-6); zgradpulse(gzlvl6,gt6); delay(2.0e-6); dec2phase(zero); delay(taub - gt6 - 2.2e-6); sim3pulse(2*pw,0.0e-6,2*pwN,zero,zero,zero,0.0,0.0); delay(0.2e-6); zgradpulse(gzlvl6,gt6); delay(200.0e-6); delay(taub - gt6 - 200.2e-6); txphase(one); dec2phase(one); sim3pulse(pw,0.0e-6,pwN,one,zero,one,0.0,0.0); delay(0.2e-6); zgradpulse(gzlvl7,gt7); delay(2.0e-6); txphase(zero); dec2phase(zero); delay(taub - gt7 - 2.2e-6); sim3pulse(2*pw,0.0e-6,2*pwN,zero,zero,zero,0.0,0.0); delay(0.2e-6); zgradpulse(gzlvl7,gt7); delay(200.0e-6); delay(taub - gt7 - 200.2e-6); sim3pulse(pw,0.0e-6,pwN,zero,zero,zero,0.0,0.0); } else { /* shaped pulse */ obspower(tpwrsl); shaped_pulse(shp_sl,pw_sl,zero,4.0e-6,0.0); obspower(tpwr); txphase(zero); delay(4.0e-6); /* shaped pulse */ delay(0.2e-6); zgradpulse(gzlvl6,gt6); delay(2.0e-6); dec2phase(zero); delay(taub - POWER_DELAY - 4.0e-6 - WFG_START_DELAY - pw_sl - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6 - gt6 - 2.2e-6); sim3pulse(2*pw,0.0e-6,2*pwN,zero,zero,zero,0.0,0.0); txphase(one); dec2phase(zero); delay(0.2e-6); zgradpulse(gzlvl6,gt6); delay(200.0e-6); delay(taub - gt6 - 200.2e-6); sim3pulse(pw,0.0e-6,pwN,one,zero,zero,0.0,0.0); delay(0.2e-6); zgradpulse(gzlvl7,gt7); delay(2.0e-6); txphase(zero); dec2phase(zero); delay(taub - gt7 - 2.2e-6); sim3pulse(2*pw,0.0e-6,2*pwN,zero,zero,zero,0.0,0.0); txphase(one); dec2phase(one); delay(0.2e-6); zgradpulse(gzlvl7,gt7); delay(200.0e-6); delay(taub - gt7 - 200.2e-6); sim3pulse(pw,0.0e-6,pwN,one,zero,one,0.0,0.0); txphase(zero); } delay(gt2 +gstab -0.5*(pwN -pw) -2.0*pw/PI); rgpulse(2*pw,zero,0.0,0.0); delay(2.0e-6); zgradpulse(icosel*gzlvl2, gt2); decpower(dpwr); dec2power(dpwr2); delay(gstab -2.0e-6 -2.0*GRADIENT_DELAY -2.0*POWER_DELAY); lk_sample(); status(C); setreceiver(t6); }
void Balancer::_doBalanceRound( DBClientBase& conn, vector<CandidateChunkPtr>* candidateChunks ) { verify( candidateChunks ); // // 1. Check whether there is any sharded collection to be balanced by querying // the ShardsNS::collections collection // auto_ptr<DBClientCursor> cursor = conn.query(ConfigNS::collection, BSONObj()); vector< string > collections; while ( cursor->more() ) { BSONObj col = cursor->nextSafe(); // sharded collections will have a shard "key". if ( ! col[CollectionFields::key()].eoo() && ! col[CollectionFields::noBalance()].trueValue() ){ collections.push_back( col[CollectionFields::name()].String() ); } else if( col[CollectionFields::noBalance()].trueValue() ){ LOG(1) << "not balancing collection " << col[CollectionFields::name()].String() << ", explicitly disabled" << endl; } } cursor.reset(); if ( collections.empty() ) { LOG(1) << "no collections to balance" << endl; return; } // // 2. Get a list of all the shards that are participating in this balance round // along with any maximum allowed quotas and current utilization. We get the // latter by issuing db.serverStatus() (mem.mapped) to all shards. // // TODO: skip unresponsive shards and mark information as stale. // vector<Shard> allShards; Shard::getAllShards( allShards ); if ( allShards.size() < 2) { LOG(1) << "can't balance without more active shards" << endl; return; } ShardInfoMap shardInfo; for ( vector<Shard>::const_iterator it = allShards.begin(); it != allShards.end(); ++it ) { const Shard& s = *it; ShardStatus status = s.getStatus(); shardInfo[ s.getName() ] = ShardInfo( s.getMaxSize(), status.mapped(), s.isDraining(), status.hasOpsQueued(), s.tags() ); } // // 3. For each collection, check if the balancing policy recommends moving anything around. // for (vector<string>::const_iterator it = collections.begin(); it != collections.end(); ++it ) { const string& ns = *it; map< string,vector<BSONObj> > shardToChunksMap; cursor = conn.query(ConfigNS::chunk, QUERY(ChunkFields::ns(ns)).sort(ChunkFields::min())); while ( cursor->more() ) { BSONObj chunk = cursor->nextSafe(); vector<BSONObj>& chunks = shardToChunksMap[chunk[ChunkFields::shard()].String()]; chunks.push_back( chunk.getOwned() ); } cursor.reset(); if (shardToChunksMap.empty()) { LOG(1) << "skipping empty collection (" << ns << ")"; continue; } for ( vector<Shard>::iterator i=allShards.begin(); i!=allShards.end(); ++i ) { // this just makes sure there is an entry in shardToChunksMap for every shard Shard s = *i; shardToChunksMap[s.getName()].size(); } DistributionStatus status( shardInfo, shardToChunksMap ); // load tags conn.ensureIndex(ConfigNS::tag, BSON(TagFields::ns() << 1 << TagFields::min() << 1), true); cursor = conn.query(ConfigNS::tag, QUERY(TagFields::ns(ns)).sort(TagFields::min())); while ( cursor->more() ) { BSONObj tag = cursor->nextSafe(); uassert(16356 , str::stream() << "tag ranges not valid for: " << ns , status.addTagRange(TagRange(tag[TagFields::min()].Obj().getOwned(), tag[TagFields::max()].Obj().getOwned(), tag[TagFields::tag()].String()))); } cursor.reset(); CandidateChunk* p = _policy->balance( ns, status, _balancedLastTime ); if ( p ) candidateChunks->push_back( CandidateChunkPtr( p ) ); } }
pulsesequence() { /* DECLARE AND LOAD VARIABLES */ char f1180[MAXSTR], /* Flag to start t1 @ halfdwell */ f2180[MAXSTR], /* Flag to start t2 @ halfdwell */ mag_flg[MAXSTR], /* magic-angle coherence transfer gradients */ TROSY[MAXSTR]; /* To check for TROSY flag */ int icosel, /* used to get n and p type */ t1_counter, /* used for states tppi in t1 */ t2_counter, /* used for states tppi in t2 */ ni2 = getval("ni2"); double p_d, rfd, ncyc, COmix = getval("COmix"), p_trim, rftrim, tau1, /* t1 delay */ tau2, /* t2 delay */ timeTN = getval("timeTN"), /* constant time for 15N evolution */ kappa = 5.4e-3, lambda = 2.4e-3, pwClvl = getval("pwClvl"), /* coarse power for C13 pulse */ pwC = getval("pwC"), /* C13 90 degree pulse length at pwClvl */ rf0, /* maximum fine power when using pwC pulses */ bw, ofs, ppm, /* bandwidth, offset, ppm - temporary Pbox parameters */ /* the following pulse lengths for SLP pulses are automatically calculated */ /* by the macro "biocal". SLP pulse shapes, "offC3" etc are called */ /* directly from your shapelib. */ pwC3 = getval("pwC3"), /*180 degree pulse at Ca(56ppm) null at CO(174ppm) */ pwC3a, /* pwC3a=pwC3, but not set to zero when pwC3=0 */ phshift3, /* phase shift induced on CO by pwC3 ("offC3") pulse */ pwZ, /* the largest of pwC3 and 2.0*pwN */ pwZ1, /* the largest of pwC3a and 2.0*pwN for 1D experiments */ pwC6, /* 90 degree selective sinc pulse on CO(174ppm) */ pwC8, /* 180 degree selective sinc pulse on CO(174ppm) */ rf3, /* fine power for the pwC3 ("offC3") pulse */ rf6, /* fine power for the pwC6 ("offC6") pulse */ rf8, /* fine power for the pwC8 ("offC8") pulse */ compH = getval("compH"), /* adjustment for C13 amplifier compression */ compC = getval("compC"), /* adjustment for C13 amplifier compression */ pwHs = getval("pwHs"), /* H1 90 degree pulse length at tpwrs */ tpwrsf = getval("tpwrsf"), /* fine power adjustment for flipback */ tpwrs, /* power for the pwHs ("H2Osinc") pulse */ pwHd, /* H1 90 degree pulse length at tpwrd */ tpwrd, /* rf for WALTZ decoupling */ waltzB1 = getval("waltzB1"), /* waltz16 field strength (in Hz) */ pwNlvl = getval("pwNlvl"), /* power for N15 pulses */ pwN = getval("pwN"), /* N15 90 degree pulse length at pwNlvl */ sw1 = getval("sw1"), sw2 = getval("sw2"), gt1 = getval("gt1"), /* coherence pathway gradients */ gzcal = getval("gzcal"), /* g/cm to DAC conversion factor */ gzlvl1 = getval("gzlvl1"), gzlvl2 = getval("gzlvl2"), gt0 = getval("gt0"), /* other gradients */ gt3 = getval("gt3"), gt4 = getval("gt4"), gt5 = getval("gt5"), gstab = getval("gstab"), gzlvl0 = getval("gzlvl0"), gzlvl3 = getval("gzlvl3"), gzlvl4 = getval("gzlvl4"), gzlvl5 = getval("gzlvl5"), gzlvl6 = getval("gzlvl6"); getstr("f1180",f1180); getstr("f2180",f2180); getstr("mag_flg",mag_flg); getstr("TROSY",TROSY); /* LOAD PHASE TABLE */ settable(t3,2,phi3); settable(t4,1,phx); settable(t5,4,phi5); settable(t8,1,phx); settable(t9,8,phi9); settable(t10,1,phx); settable(t11,1,phy); settable(t12,4,rec); /* INITIALIZE VARIABLES */ if( dpwrf < 4095 ) { printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse"); psg_abort(1); } /* maximum fine power for pwC pulses */ rf0 = 4095.0; setautocal(); /* activate auto-calibration */ if (autocal[0] == 'n') { /* offC3 - 180 degree pulse on Ca, null at CO 118ppm away */ pwC3a = getval("pwC3a"); rf3 = (compC*4095.0*pwC*2.0)/pwC3a; rf3 = (int) (rf3 + 0.5); /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */ pwC6 = getval("pwC6"); rf6 = (compC*4095.0*pwC*1.69)/pwC6; /* needs 1.69 times more */ rf6 = (int) (rf6 + 0.5); /* power than a square pulse */ /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */ pwC8 = getval("pwC8"); rf8 = (compC*4095.0*pwC*2.0*1.65)/pwC8; /* needs 1.65 times more */ rf8 = (int) (rf8 + 0.5); /* power than a square pulse */ /* selective H20 one-lobe sinc pulse */ tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69)); /* needs 1.69 times more */ tpwrs = (int) (tpwrs); /* power than a square pulse */ /* power level and pulse time for WALTZ 1H decoupling */ pwHd = 1/(4.0 * waltzB1) ; tpwrd = tpwr - 20.0*log10(pwHd/(compH*pw)); tpwrd = (int) (tpwrd + 0.5); } else /* if autocal = 'y'(yes), 'q'(quiet), 'r'(read) or 's'(semi) */ { if(FIRST_FID) /* make shapes */ { ppm = getval("dfrq"); bw = 118.0*ppm; ofs = -bw; offC3 = pbox_make("offC3", "square180n", bw, ofs, compC*pwC, pwClvl); offC6 = pbox_make("offC6", "sinc90n", bw, 0.0, compC*pwC, pwClvl); offC8 = pbox_make("offC8", "sinc180n", bw, 0.0, compC*pwC, pwClvl); H2Osinc = pbox_Rsh("H2Osinc", "sinc90", pwHs, 0.0, compH*pw, tpwr); wz16 = pbox_Dcal("WALTZ16", 2.8*waltzB1, 0.0, compH*pw, tpwr); ofs_check(H1ofs, C13ofs, N15ofs, H2ofs); } pwC3a = offC3.pw; rf3 = offC3.pwrf; /* set up parameters */ pwC6 = offC6.pw; rf6 = offC6.pwrf; pwC8 = offC8.pw; rf8 = offC8.pwrf; pwHs = H2Osinc.pw; tpwrs = H2Osinc.pwr-1.0; /* 1dB correction applied */ tpwrd = wz16.pwr; pwHd = 1.0/wz16.dmf; } if (tpwrsf < 4095.0) tpwrs = tpwrs + 6.0; /* the pwC3 pulse at the middle of t1 */ if ((ni2 > 0.0) && (ni == 1.0)) ni = 0.0; if (pwC3a > 2.0*pwN) pwZ = pwC3a; else pwZ = 2.0*pwN; if ((pwC3==0.0) && (pwC3a>2.0*pwN)) pwZ1=pwC3a-2.0*pwN; else pwZ1=0.0; if ( ni > 1 ) pwC3 = pwC3a; if ( pwC3 > 0 ) phshift3 = 48.0; else phshift3 = 0.0; /* dipsi-3 decoupling on COCO */ p_trim = 1/(4*5000*(sfrq/600.0)); /* 5 kHz trim pulse at 600MHz as per Bax */ p_d = (5.0)/(9.0*4.0*2800.0*(sfrq/600.0)); /* 2.8 kHz DIPSI-3 at 600MHz as per Bax*/ rftrim = (compC*4095.0*pwC)/p_trim; rftrim = (int)(rftrim+0.5); rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0); rfd = (int) (rfd + 0.5); ncyc = ((COmix - 0.002)/51.8/4/p_d); ncyc = (int) (ncyc + 0.5); initval(ncyc,v9); /* CHECK VALIDITY OF PARAMETER RANGES */ if ( 0.5*ni2*1/(sw2) > timeTN - WFG3_START_DELAY) { printf(" ni2 is too big. Make ni2 equal to %d or less.\n", ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2))); psg_abort(1);} if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' ) { printf("incorrect dec1 decoupler flags! Should be 'nnn' "); psg_abort(1);} if ( dm2[A] == 'y' || dm2[B] == 'y' ) { printf("incorrect dec2 decoupler flags! Should be 'nny' "); psg_abort(1);} if ( dpwr2 > 50 ) { printf("dpwr2 too large! recheck value "); psg_abort(1);} if ( pw > 50.0e-6 ) { printf(" pw too long ! recheck value "); psg_abort(1);} if ( (pwN > 100.0e-6) && (ni>1 || ni2>1)) { printf(" pwN too long! recheck value "); psg_abort(1);} if ( TROSY[A] == 'y') { printf(" TROSY option is not implemented"); psg_abort(1);} /* PHASES AND INCREMENTED TIMES */ /* Phase incrementation for hypercomplex 2D data, States-Haberkorn element */ if (phase1 == 2) tsadd(t3,1,4); if (phase2 == 2) {tsadd(t10,2,4); icosel = +1;} else icosel = -1; /* Set up f1180 */ tau1 = d2; if((f1180[A] == 'y') && (ni > 1.0)) { tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; } /* Set up f2180 */ tau2 = d3; if((f2180[A] == 'y') && (ni2 > 1.0)) { tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; } tau2 = tau2/2.0; /* Calculate modifications to phases for States-TPPI acquisition */ if( ix == 1) d2_init = d2; t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 ); if(t1_counter % 2) { tsadd(t3,2,4); tsadd(t12,2,4); } if( ix == 1) d3_init = d3; t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 ); if(t2_counter % 2) { tsadd(t8,2,4); tsadd(t12,2,4); } /* BEGIN PULSE SEQUENCE */ status(A); delay(d1); rcvroff(); obspower(tpwr); decpower(pwClvl); dec2power(pwNlvl); decpwrf(rf0); obsoffset(tof); txphase(zero); delay(1.0e-5); dec2rgpulse(pwN, zero, 0.0, 0.0); /*destroy N15 and C13 magnetization*/ decrgpulse(pwC, zero, 0.0, 0.0); zgradpulse(gzlvl0, 0.5e-3); delay(1.0e-4); dec2rgpulse(pwN, one, 0.0, 0.0); decrgpulse(pwC, zero, 0.0, 0.0); zgradpulse(0.7*gzlvl0, 0.5e-3); delay(5.0e-4); rgpulse(pw,zero,0.0,0.0); /* 1H pulse excitation */ dec2phase(zero); zgradpulse(gzlvl0, gt0); delay(lambda - gt0); sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0); txphase(one); zgradpulse(gzlvl0, gt0); delay(lambda - gt0); rgpulse(pw, one, 0.0, 0.0); txphase(zero); obspower(tpwrs); if (tpwrsf<4095.0) obspwrf(tpwrsf); shaped_pulse("H2Osinc", pwHs, zero, 5.0e-4, 0.0); obspower(tpwrd); if (tpwrsf<4095.0) obspwrf(4095.0); zgradpulse(gzlvl3, gt3); delay(2.0e-4); dec2rgpulse(pwN, zero, 0.0, 0.0); txphase(one); delay(kappa - pwHd - 2.0e-6 - PRG_START_DELAY); rgpulse(pwHd,one,0.0,0.0); txphase(zero); delay(2.0e-6); obsprgon("waltz16", pwHd, 90.0); /* PRG_START_DELAY */ xmtron(); decphase(zero); dec2phase(zero); decpwrf(rf8); delay(timeTN - kappa - WFG3_START_DELAY); /* WFG3_START_DELAY */ sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, zero, 0.0, 0.0); decphase(t3); decpwrf(rf6); delay(timeTN); dec2rgpulse(pwN, zero, 0.0, 0.0); xmtroff(); obsprgoff(); rgpulse(pwHd,three,2.0e-6,0.0); zgradpulse(gzlvl3, gt3); delay(2.0e-4); /***************************************************************/ /* The sequence is different from here with respect to ghn_co **/ /***************************************************************/ rgpulse(pwHd,one,2.0e-6,0.0); /* H1 decoupler is turned on */ txphase(zero); delay(2.0e-6); obsprgon("waltz16", pwHd, 90.0); xmtron(); decshaped_pulse("offC6", pwC6, t3, 0.0, 0.0); decphase(zero); /* Refocus CO, evolve CO, spinlock CO and defocus CO */ delay(timeTN - tau1/2 - 0.6*pwC6 - WFG3_START_DELAY); decpwrf(rf8); sim3shaped_pulse("", "offC8","",0.0,pwC8, 2.0*pwN, zero,zero,zero,0.0,0.0); decpwrf(rf3); delay(timeTN - WFG3_STOP_DELAY - WFG_START_DELAY - pwC3a/2); decshaped_pulse("offC3",pwC3a,zero,0.0,0.0); if (tau1 > 0) delay(tau1/2 - WFG_STOP_DELAY - pwC3a/2 - 2.0e-6); else delay(tau1/2); /*******DO SPINLOCK ********/ decpwrf(rftrim); decrgpulse(0.002,zero,2.0e-6,0.0); decpwrf(rfd); starthardloop(v9); decrgpulse(6.4*p_d,zero,0.0,0.0); decrgpulse(8.2*p_d,two,0.0,0.0); decrgpulse(5.8*p_d,zero,0.0,0.0); decrgpulse(5.7*p_d,two,0.0,0.0); decrgpulse(0.6*p_d,zero,0.0,0.0); decrgpulse(4.9*p_d,two,0.0,0.0); decrgpulse(7.5*p_d,zero,0.0,0.0); decrgpulse(5.3*p_d,two,0.0,0.0); decrgpulse(7.4*p_d,zero,0.0,0.0); decrgpulse(6.4*p_d,two,0.0,0.0); decrgpulse(8.2*p_d,zero,0.0,0.0); decrgpulse(5.8*p_d,two,0.0,0.0); decrgpulse(5.7*p_d,zero,0.0,0.0); decrgpulse(0.6*p_d,two,0.0,0.0); decrgpulse(4.9*p_d,zero,0.0,0.0); decrgpulse(7.5*p_d,two,0.0,0.0); decrgpulse(5.3*p_d,zero,0.0,0.0); decrgpulse(7.4*p_d,two,0.0,0.0); decrgpulse(6.4*p_d,two,0.0,0.0); decrgpulse(8.2*p_d,zero,0.0,0.0); decrgpulse(5.8*p_d,two,0.0,0.0); decrgpulse(5.7*p_d,zero,0.0,0.0); decrgpulse(0.6*p_d,two,0.0,0.0); decrgpulse(4.9*p_d,zero,0.0,0.0); decrgpulse(7.5*p_d,two,0.0,0.0); decrgpulse(5.3*p_d,zero,0.0,0.0); decrgpulse(7.4*p_d,two,0.0,0.0); decrgpulse(6.4*p_d,zero,0.0,0.0); decrgpulse(8.2*p_d,two,0.0,0.0); decrgpulse(5.8*p_d,zero,0.0,0.0); decrgpulse(5.7*p_d,two,0.0,0.0); decrgpulse(0.6*p_d,zero,0.0,0.0); decrgpulse(4.9*p_d,two,0.0,0.0); decrgpulse(7.5*p_d,zero,0.0,0.0); decrgpulse(5.3*p_d,two,0.0,0.0); decrgpulse(7.4*p_d,zero,0.0,0.0); endhardloop(); decpwrf(4095.0); /* End of spinlock */ delay(timeTN - WFG3_START_DELAY); decpwrf(rf8); sim3shaped_pulse("","offC8","",0.0,pwC8,2*pwN,zero,zero,zero,0.0,0.0); decpwrf(rf6); delay(timeTN - WFG3_STOP_DELAY); /***************************************************************/ /* The sequence is same as ghn_co from this point ********/ /***************************************************************/ decshaped_pulse("offC6", pwC6, t5, 0.0, 0.0); /* xxxxxxxxxxxxxxxxxx OPTIONS FOR N15 EVOLUTION xxxxxxxxxxxxxxxxxxxxx */ dec2phase(t8); zgradpulse(gzlvl4, gt4); txphase(one); dcplrphase(zero); delay(2.0e-4); dec2rgpulse(pwN, t8, 0.0, 0.0); decphase(zero); dec2phase(t9); decpwrf(rf8); delay(timeTN - WFG3_START_DELAY - tau2); /* WFG3_START_DELAY */ sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, t9, 0.0, 0.0); dec2phase(t10); decpwrf(rf3); if (tau2 > kappa) { delay(timeTN - pwC3a - WFG_START_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0); delay(tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ rgpulse(pwHd,three,2.0e-6,0.0); txphase(t4); delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); /* POWER_DELAY */ delay(1.0e-4 - POWER_DELAY); } else if (tau2 > (kappa - pwC3a - WFG_START_DELAY)) { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ rgpulse(pwHd,three,2.0e-6,0.0); txphase(t4); /* WFG_START_DELAY */ decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0); delay(kappa -pwC3a -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); /* POWER_DELAY */ delay(1.0e-4 - POWER_DELAY); } else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4) { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ rgpulse(pwHd,three,2.0e-6,0.0); txphase(t4); delay(kappa - tau2 - pwC3a - WFG_START_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0); delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); /* POWER_DELAY */ delay(1.0e-4 - POWER_DELAY); } else { delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6); xmtroff(); obsprgoff(); /* PRG_STOP_DELAY */ rgpulse(pwHd,three,2.0e-6,0.0); txphase(t4); delay(kappa-tau2-pwC3a-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4); if (mag_flg[A]=='y') magradpulse(gzcal*gzlvl1, gt1); else zgradpulse(gzlvl1, gt1); /* 2.0*GRADIENT_DELAY */ obspower(tpwr); /* POWER_DELAY */ delay(1.0e-4 - POWER_DELAY); /* WFG_START_DELAY */ decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0); delay(tau2); } /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0); txphase(zero); dec2phase(zero); zgradpulse(gzlvl5, gt5); delay(lambda - 1.3*pwN - gt5); sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0); zgradpulse(gzlvl5, gt5); txphase(one); dec2phase(t11); delay(lambda - 1.3*pwN - gt5); sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0); txphase(zero); dec2phase(zero); zgradpulse(gzlvl6, gt5); delay(lambda - 1.3*pwN - gt5); sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0); dec2phase(t10); zgradpulse(gzlvl6, gt5); delay(lambda - 0.65*pwN - gt5); rgpulse(pw, zero, 0.0, 0.0); delay((gt1/10.0) + 1.0e-4 +gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY); rgpulse(2.0*pw, zero, 0.0,0.0); dec2power(dpwr2); /* POWER_DELAY */ if (mag_flg[A] == 'y') magradpulse(icosel*gzcal*gzlvl2, gt1/10.0); else zgradpulse(icosel*gzlvl2, gt1/10.0); /* 2.0*GRADIENT_DELAY */ delay(gstab); rcvron(); statusdelay(C,1.0e-4); setreceiver(t12); }
int main(int argc, char* argv[]) { // initiation the acl library acl::acl_cpp_init(); acl::log::stdout_open(true); int ch; size_t replicas = 0; bool add_slave = false, just_display = false; acl::string addr, cmd, conf, new_addr, node_id, key, passwd; while ((ch = getopt(argc, argv, "hs:a:f:N:SI:r:dk:p:")) > 0) { switch (ch) { case 'h': usage(argv[0]); return 0; case 's': addr = optarg; break; case 'a': cmd = optarg; break; case 'f': conf = optarg; break; case 'N': new_addr = optarg; break; case 'S': add_slave = true; break; case 'I': node_id = optarg; break; case 'r': replicas = (size_t) atoi(optarg); break; case 'd': just_display = true; break; case 'k': key = optarg; break; case 'p': passwd = optarg; break; default: break; } } int conn_timeout = 10, rw_timeout = 120; if (cmd == "hash_slot") { if (key.empty()) printf("usage: %s -a hash_slot -k key\r\n", argv[0]); else { size_t max_slot = 16384; unsigned short n = acl_hash_crc16(key.c_str(), key.length()); unsigned short slot = n % max_slot; printf("key: %s, slot: %d\r\n", key.c_str(), (int) slot); } } else if (cmd == "nodes") { if (addr.empty()) printf("usage: %s -s ip:port -a nodes\r\n", argv[0]); else { acl::redis_client client(addr, conn_timeout, rw_timeout); client.set_password(passwd); acl::redis redis(&client); redis_status status(addr, conn_timeout, rw_timeout, passwd); status.show_nodes(redis); } } else if (cmd == "slots") { if (addr.empty()) printf("usage: %s -a ip:port -a slots\r\n", argv[0]); else { acl::redis_client client(addr, conn_timeout, rw_timeout); client.set_password(passwd); acl::redis redis(&client); redis_status status(addr, conn_timeout, rw_timeout, passwd); status.show_slots(redis); } } else if (cmd == "create") { if (conf.empty()) printf("usage: %s -a create -f cluster.xml\r\n", argv[0]); else { redis_builder builder(passwd); builder.build(conf.c_str(), replicas, just_display); } } else if (cmd == "add_node") { if (addr.empty() || new_addr.empty()) printf("usage: %s -s ip:port -a add_node -N ip:port -S\r\n", argv[0]); else { redis_builder builder(passwd); builder.add_node(addr, new_addr, add_slave); } } else if (cmd == "del_node") { if (addr.empty() || node_id.empty()) printf("usage: %s -s ip:port -a del_node -I nod_id\r\n", argv[0]); else { redis_builder builder(passwd); builder.del_node(addr, node_id); } } else if (cmd == "node_id") { if (addr.empty()) printf("usage: %s -s ip:port -a node_id\r\n", argv[0]); else { node_id.clear(); if (redis_util::get_node_id(addr, node_id, passwd) == false) printf("can't get node id, addr: %s\r\n", addr.c_str()); else printf("addr: %s, node_id: %s\r\n", addr.c_str(), node_id.c_str()); } } else if (cmd == "reshard") { if (addr.empty()) printf("usage: %s -s ip:port -a reshard\r\n", argv[0]); else { redis_reshard reshard(addr, passwd); reshard.run(); } } else printf("unknown cmd: %s\r\n", cmd.c_str()); #ifdef WIN32 printf("enter any key to exit\r\n"); getchar(); #endif return 0; }
int Main(int argc, char const * const argv[], char const * const envp[]) { _aprcall(apr_initialize()); apr_pool_t *pool; apr_pool_create(&pool, NULL); bool tty(isatty(STDIN_FILENO)); bool compile(false); CYOptions options; append_history$ = (int (*)(int, const char *)) (dlsym(RTLD_DEFAULT, "append_history")); #ifdef CY_ATTACH pid_t pid(_not(pid_t)); #endif const char *host(NULL); const char *port(NULL); apr_getopt_t *state; _aprcall(apr_getopt_init(&state, pool, argc, argv)); for (;;) { char opt; const char *arg; apr_status_t status(apr_getopt(state, "cg:n:" #ifdef CY_ATTACH "p:" #endif "r:" "s" , &opt, &arg)); switch (status) { case APR_EOF: goto getopt; case APR_BADCH: case APR_BADARG: fprintf(stderr, "usage: cycript [-c]" #ifdef CY_ATTACH " [-p <pid|name>]" #endif " [-r <host:port>]" " [<script> [<arg>...]]\n" ); return 1; default: _aprcall(status); } switch (opt) { case 'c': compile = true; break; case 'g': if (false); else if (strcmp(arg, "rename") == 0) options.verbose_ = true; #if YYDEBUG else if (strcmp(arg, "bison") == 0) bison_ = true; #endif else { fprintf(stderr, "invalid name for -g\n"); return 1; } break; case 'n': if (false); else if (strcmp(arg, "minify") == 0) pretty_ = true; else { fprintf(stderr, "invalid name for -n\n"); return 1; } break; #ifdef CY_ATTACH case 'p': { size_t size(strlen(arg)); char *end; pid = strtoul(arg, &end, 0); if (arg + size != end) { // XXX: arg needs to be escaped in some horrendous way of doom const char *command(apr_pstrcat(pool, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^", arg, " /{s/^[^ ]* //;q;};};d'", NULL)); if (FILE *pids = popen(command, "r")) { char value[32]; size = 0; for (;;) { size_t read(fread(value + size, 1, sizeof(value) - size, pids)); if (read == 0) break; else { size += read; if (size == sizeof(value)) { pid = _not(pid_t); goto fail; } } } size: if (size == 0) goto fail; if (value[size - 1] == '\n') { --size; goto size; } value[size] = '\0'; size = strlen(value); pid = strtoul(value, &end, 0); if (value + size != end) fail: pid = _not(pid_t); _syscall(pclose(pids)); } if (pid == _not(pid_t)) { fprintf(stderr, "invalid pid for -p\n"); return 1; } } } break; #endif case 'r': { //size_t size(strlen(arg)); char *colon(strrchr(arg, ':')); if (colon == NULL) { fprintf(stderr, "missing colon in hostspec\n"); return 1; } /*char *end; port = strtoul(colon + 1, &end, 10); if (end != arg + size) { fprintf(stderr, "invalid port in hostspec\n"); return 1; }*/ host = arg; *colon = '\0'; port = colon + 1; } break; case 's': strict_ = true; break; } } getopt:; const char *script; int ind(state->ind); #ifdef CY_ATTACH if (pid != _not(pid_t) && ind < argc - 1) { fprintf(stderr, "-p cannot set argv\n"); return 1; } if (pid != _not(pid_t) && compile) { fprintf(stderr, "-p conflicts with -c\n"); return 1; } #endif if (ind == argc) script = NULL; else { #ifdef CY_EXECUTE // XXX: const_cast?! wtf gcc :( CYSetArgs(argc - ind - 1, const_cast<const char **>(argv + ind + 1)); #endif script = argv[ind]; if (strcmp(script, "-") == 0) script = NULL; } #ifdef CY_ATTACH if (pid != _not(pid_t) && script == NULL && !tty) { fprintf(stderr, "non-terminal attaching to remote console\n"); return 1; } #endif #ifdef CY_ATTACH if (pid == _not(pid_t)) client_ = -1; else { int server(_syscall(socket(PF_UNIX, SOCK_STREAM, 0))); try { struct sockaddr_un address; memset(&address, 0, sizeof(address)); address.sun_family = AF_UNIX; sprintf(address.sun_path, "/tmp/.s.cy.%u", getpid()); _syscall(bind(server, reinterpret_cast<sockaddr *>(&address), SUN_LEN(&address))); _syscall(chmod(address.sun_path, 0777)); try { _syscall(listen(server, 1)); InjectLibrary(pid); client_ = _syscall(accept(server, NULL, NULL)); } catch (...) { // XXX: exception? unlink(address.sun_path); throw; } } catch (...) { _syscall(close(server)); throw; } } #else client_ = -1; #endif if (client_ == -1 && host != NULL && port != NULL) { struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; hints.ai_flags = 0; struct addrinfo *infos; _syscall(getaddrinfo(host, port, &hints, &infos)); _assert(infos != NULL); try { for (struct addrinfo *info(infos); info != NULL; info = info->ai_next) { int client(_syscall(socket(info->ai_family, info->ai_socktype, info->ai_protocol))); try { _syscall(connect(client, info->ai_addr, info->ai_addrlen)); client_ = client; break; } catch (...) { _syscall(close(client)); throw; } } } catch (...) { freeaddrinfo(infos); throw; } } if (script == NULL && tty) Console(options); else { CYLocalPool pool; char *start, *end; std::istream *indirect; if (script == NULL) { start = NULL; end = NULL; indirect = &std::cin; } else { size_t size; start = reinterpret_cast<char *>(Map(script, &size)); end = start + size; if (size >= 2 && start[0] == '#' && start[1] == '!') { start += 2; if (void *line = memchr(start, '\n', end - start)) start = reinterpret_cast<char *>(line); else start = end; } indirect = NULL; } CYStream direct(start, end); std::istream &stream(indirect == NULL ? direct : *indirect); CYDriver driver(stream, script ?: "<stdin>"); cy::parser parser(driver); Setup(driver, parser); if (parser.parse() != 0 || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i) std::cerr << i->location_.begin << ": " << i->message_ << std::endl; } else if (driver.program_ != NULL) if (client_ != -1) { // XXX: this code means that you can't pipe to another process std::string code(start, end-start); Run(client_, false, code, &std::cout); } else { std::ostringstream str; CYOutput out(str, options); Setup(out, driver, options); out << *driver.program_; std::string code(str.str()); if (compile) std::cout << code; else Run(client_, false, code, &std::cout); } } apr_pool_destroy(pool); return 0; }
pulsesequence() { char CT_flg[MAXSTR], /* Constant time flag */ f1180[MAXSTR], shname1[MAXSTR], /* First pulse: name or 'vap' for automatic VAP(Variable angle pulse) */ ab_flg[MAXSTR]; /* inversion of 15N for coupling*/ int t1_counter, phase; double d2_init=0.0, pwNa = 0.0, adjust = getval("adjust"), ref_pwr = getval("ref_pwr"), ref_pw90 = getval("ref_pw90"), fla = getval("fla"), /* flip-angle */ gzlvl1 = getval("gzlvl1"), gzlvl2 = getval("gzlvl2"), gt1 = getval("gt1"), gt2 = getval("gt2"), gstab = getval("gstab"), pwNlvl = getval("pwNlvl"), pwN = getval("pwN"), dpwr2 = getval("dpwr2"), d2 = getval("d2"), tau1 = getval("tau1"), taunh = 1/(2.0*getval("JNH")); void compo_pulse(), make_shapes(); getstr("CT_flg", CT_flg); getstr("f1180",f1180); getstr("shname1",shname1); getstr("ab_flg",ab_flg); if(ab_flg[A] == 'a' || ab_flg[A] == 'b') pwNa = pwN; phase = (int) (getval("phase") + 0.5); if(FIRST_FID) make_shapes(shname1, ref_pw90, ref_pwr, fla); tau1 = d2; if((f1180[A] == 'y') && (ni > 1.0)) { tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; } if (f1180[0] == 'y') tau1 = tau1-pwN*4.0/3.0; if(ix == 1) d2_init = d2; dbl(ct,v1); /* v1 = 0202 */ t1_counter = (int) ((d2-d2_init)*sw1 + 0.5); if(t1_counter % 2) add(two,v1,v1); assign(v1,oph); if (phase == 2) incr(v1); status(A); dec2power(pwNlvl); zgradpulse(gzlvl2, gt2); delay(gstab); delay(d1-gt2); pbox_pulse(&sh1,zero,2.0e-4,2.0e-6); zgradpulse(gzlvl1, gt1); delay(gstab); if (ni == 0) { delay(taunh-gt1-gstab-WFG_START_DELAY+pwN*4.0-adjust); pbox_pulse(&sh2,zero,2.0e-6,2.0e-6); dec2rgpulse(pwN,v1,0.0,0.0); dec2rgpulse(pwN*2.0,zero,0.0,0.0); dec2rgpulse(pwN,zero,0.0,0.0); } else { delay(taunh-gt1-gstab-adjust); obspower(sh2dec.pwr); compo_pulse(pwN,v1,tau1); } zgradpulse(gzlvl1, gt1); delay(taunh*0.5-gt1-pwNa); if(ab_flg[A] == 'a' || ab_flg[A] == 'b') { dec2rgpulse(pwNa,zero,0.0,0.0); if (ab_flg[0] == 'b') /*INVERSION OR FLIP BACK*/ dec2rgpulse(pwNa,two,0.0,0.0); else dec2rgpulse(pwNa,zero,0.0,0.0); } delay(taunh*0.5-pwNa-POWER_DELAY); dec2power(dpwr2); /* obsoffset(tof+3.3*sfrq); */ status(C); }
pulsesequence() { double slpwrT = getval("slpwrT"), slpwT = getval("slpwT"), mixT = getval("mixT"), gzlvl1 = getval("gzlvl1"), gt1 = getval("gt1"), gzlvl2 = getval("gzlvl2"), gt2 = getval("gt2"), gstab = getval("gstab"), selpwrA = getval("selpwrA"), selpwA = getval("selpwA"), gzlvlA = getval("gzlvlA"), gtA = getval("gtA"), selpwrB = getval("selpwrB"), selpwB = getval("selpwB"), gzlvlB = getval("gzlvlB"), gtB = getval("gtB"), selfrq = getval("selfrq"), zqfpw1 = getval("zqfpw1"), zqfpwr1 = getval("zqfpwr1"), zqfpw2 = getval("zqfpw2"), zqfpwr2 = getval("zqfpwr2"), gzlvlzq1 = getval("gzlvlzq1"), gzlvlzq2 = getval("gzlvlzq2"), phincr1 = getval("phincr1"); char slpatT[MAXSTR], selshapeA[MAXSTR], selshapeB[MAXSTR], zqfpat1[MAXSTR], zqfpat2[MAXSTR], flipback[MAXSTR], alt_grd[MAXSTR]; //synchronize gradients to srate for probetype='nano' // Preserve gradient "area" gtA = syncGradTime("gtA","gzlvlA",1.0); gzlvlA = syncGradLvl("gtA","gzlvlA",1.0); gtB = syncGradTime("gtB","gzlvlB",1.0); gzlvlB = syncGradLvl("gtB","gzlvlB",1.0); getstr("slpatT",slpatT); getstr("selshapeA",selshapeA); getstr("selshapeB",selshapeB); getstr("zqfpat1",zqfpat1); getstr("zqfpat2",zqfpat2); getstr("flipback", flipback); getstr("alt_grd",alt_grd); /* alternate gradient sign on every 2nd transient */ if (strcmp(slpatT,"mlev17c") && strcmp(slpatT,"dipsi2") && strcmp(slpatT,"dipsi3") && strcmp(slpatT,"mlev17") && strcmp(slpatT,"mlev16")) abort_message("SpinLock pattern %s not supported!.\n", slpatT); /* STEADY-STATE PHASECYCLING */ /* This section determines if the phase calculations trigger off of (SS - SSCTR) or off of CT */ assign(ct,v17); ifzero(ssctr); assign(v17,v13); elsenz(ssctr); /* purge option does not adjust v13 during steady state*/ sub(ssval, ssctr, v13); /* v13 = 0,...,ss-1 */ endif(ssctr); mod4(v13,v1); /* v1 = 0 1 2 3 */ hlv(v13,v13); hlv(v13,v13); mod4(v13,v11); /* v11 = 0000 1111 2222 3333 */ dbl(v1,oph); add(v11,oph,oph); add(v11,oph,oph); /* oph = 2v1 + 2v11 */ /* CYCLOPS */ hlv(v13,v13); hlv(v13,v14); add(v1,v14,v1); add(v11,v14,v11); add(oph,v14,oph); assign(v14,v21); add(one,v21,v21); add(two,v21,v12); if (phincr1 < 0.0) phincr1=360+phincr1; initval(phincr1,v5); mod2(ct,v2); /* 01 01 */ hlv(ct,v4); hlv(v4,v4); mod2(v4,v4); dbl(v4,v4); /* 0000 2222 */ add(v4,v2,v4); mod4(v4,v4); /* 0101 2323 first echo in Excitation Sculpting */ hlv(ct,v7); mod2(v7,v7); /* 0011 */ hlv(ct,v9); hlv(v9,v9); hlv(v9,v9); dbl(v9,v9); add(v9,v7,v9); mod4(v9,v9); /* 0011 0011 2233 2233 second echo in Excitation Sculpting */ dbl(v2,v2); /* 0202 */ dbl(v7,v7); /* 0022 */ add(v2,v7,v7); /* 0220 correct oph for Excitation Sculpting */ add(oph,v7,oph); mod4(oph,oph); if (alt_grd[0] == 'y') mod2(ct,v10); /* alternate gradient sign on every 2nd transient */ /* BEGIN THE ACTUAL PULSE SEQUENCE */ status(A); if (getflag("lkgate_flg")) lk_sample(); /* turn lock sampling on */ obspower(tpwr); delay(5.0e-5); if (getflag("sspul")) steadystate(); delay(d1); if (getflag("lkgate_flg")) lk_hold(); /* turn lock sampling off */ status(B); rgpulse(pw, v14, rof1, rof1); if (selfrq != tof) obsoffset(selfrq); ifzero(v10); zgradpulse(gzlvlA,gtA); elsenz(v10); zgradpulse(-gzlvlA,gtA); endif(v10); delay(gstab); obspower(selpwrA); shaped_pulse(selshapeA,selpwA,v1,rof1,rof1); obspower(tpwr); ifzero(v10); zgradpulse(gzlvlA,gtA); elsenz(v10); zgradpulse(-gzlvlA,gtA); endif(v10); delay(gstab); if (selfrq != tof) delay(2*OFFSET_DELAY); ifzero(v10); zgradpulse(gzlvlB,gtB); elsenz(v10); zgradpulse(-gzlvlB,gtB); endif(v10); delay(gstab); obspower(selpwrB); shaped_pulse(selshapeB,selpwB,v11,rof1,rof1); obspower(tpwr); ifzero(v10); zgradpulse(gzlvlB,gtB); elsenz(v10); zgradpulse(-gzlvlB,gtB); endif(v10); delay(gstab); if (selfrq != tof) obsoffset(tof); rgpulse(pw, v14, rof1, rof1); if (getflag("Gzqfilt")) { obspower(zqfpwr1); ifzero(v10); rgradient('z',gzlvlzq1); elsenz(v10); rgradient('z',-gzlvlzq1); endif(v10); delay(100.0e-6); shaped_pulse(zqfpat1,zqfpw1,v14,rof1,rof1); delay(100.0e-6); rgradient('z',0.0); delay(gstab); } obspower(slpwrT); ifzero(v10); zgradpulse(gzlvl1,gt1); elsenz(v10); zgradpulse(-gzlvl1,gt1); endif(v10); delay(gstab); if (mixT > 0.0) { if (dps_flag) rgpulse(mixT,v21,0.0,0.0); else SpinLock(slpatT,mixT,slpwT,v21); } if (getflag("Gzqfilt")) { obspower(zqfpwr2); ifzero(v10); rgradient('z',gzlvlzq2); elsenz(v10); rgradient('z',-gzlvlzq2); endif(v10); delay(100.0e-6); shaped_pulse(zqfpat2,zqfpw2,v14,rof1,rof1); delay(100.0e-6); rgradient('z',0.0); delay(gstab); } obspower(tpwr); ifzero(v10); zgradpulse(gzlvl2,gt2); elsenz(v10); zgradpulse(-gzlvl2,gt2); endif(v10); delay(gstab); if (flipback[A] == 'y') FlipBack(v14,v5); rgpulse(pw,v14,rof1,2.0e-6); ExcitationSculpting(v4,v9,v10); delay(rof2); status(C); }