Exemplo n.º 1
0
int get2Dflag() { 
  int d2flag;
  double proc, ni_val;

   d2flag = -1;
   if ( !P_getreal(CURRENT, "procdim", &proc, 1) ) 
   {
      if (proc > 1.5)
         d2flag = 1;
      else if (proc > 0.5)
         d2flag=0;
   }
   if (d2flag == -1)
   {
      if ( !P_getreal(PROCESSED, "nD", &ni_val, 1) ) 
         d2flag = (ni_val > 1.0);
   }

   if (d2flag == -1)
   {
      if ( !P_getreal(PROCESSED, "ni", &ni_val, 1) ) 
	 d2flag = (ni_val > 0.5);
   }

   if (d2flag == -1)
   {
      if ( !P_getreal(PROCESSED, "ni2", &ni_val, 1) ) 
         d2flag = (ni_val > 1.0);
   }
   if (d2flag == -1)
      d2flag = 0;

   return d2flag;
}
Exemplo n.º 2
0
static int setspecmaxmin()
/********************/
{
    vInfo  info;
    double cutoff;

    specmax = mnumypnts - 3;
    specmin = mnumypnts - 3;
    if (P_getVarInfo(CURRENT,"cutoff",&info))
        return(COMPLETE);
    if (info.active == ACT_OFF)
        return(COMPLETE);
    P_getreal(CURRENT,"cutoff",&cutoff,1);
    if (cutoff < 2.0)
        cutoff = 2.0;
    if (info.size == 2)
    {
        specmax = (int) (dispcalib * cutoff);
        P_getreal(CURRENT,"cutoff",&cutoff,2);
        if (cutoff < 0.0)
            cutoff = 0.0;
        specmin = (int) (dispcalib * cutoff);
    }
    else if (info.size == 1)
    {
        specmax = (int) (dispcalib * cutoff);
        specmin = (int) (dispcalib * cutoff);
    }
    if (specmax > mnumypnts - 3)
        specmax = mnumypnts - 3;
    if (specmin < 0)
        specmin = 0;
    return(COMPLETE);
}
Exemplo n.º 3
0
double AspCell::getCali(int dim) {
   double d=1.0;
   if(dim == VERT) {
	P_getreal(CURRENT, "wc2", &d, 1);
   	if(d<1.0) d=100.0;
   	return pht/d; 
   } else {
	P_getreal(CURRENT, "wc", &d, 1);
   	if(d<1.0) d=100.0;
   	return pwd/d; 
   }
}
Exemplo n.º 4
0
void RshowVar(FILE *f, varInfo *v)
{   
    double maxv, minv, stepv;
    int i,pindex;
    unsigned int p;

    (void) f;
    if (v)
    {	
	RshowRvals(v->T.basicType,v->R);
	RshowTval(&(v->T));
	if(v->ET.size) /* if there are enums */
	{   Wscrprintf("Enumerals\n");
	    RshowRvals(v->T.basicType,v->E);
	}
	Wscrprintf("subtype = %s   ",whatType(v->subtype));
	Wscrprintf("active = %s  ",whatActive(v->active));
	Wscrprintf("group = %s   ",whatGroup(v->Ggroup));
	Wscrprintf("Dgroup = %d\n",v->Dgroup);
	Wscrprintf("protection = ");
	p = v->prot;
	for (i=15; i >= 0; i--)
	  Wscrprintf("%1d%c",(p >> i) & 1,(i != 0) ? ' ' : '\n');

/*  If P_MMS bit set, use maxVal, minVal, etc. fields as indicies
    into system global paramters "parmax", "parmin", etc. extracting
    the desired value from the appropriate array.                       */

        if (v->prot & P_MMS)
        {
           pindex = (int) (v->minVal+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parmin", &minv, pindex ))
            minv = -1.0e+30;
           pindex = (int) (v->maxVal+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parmax", &maxv, pindex ))
            maxv = 1.0e+30;
           pindex = (int) (v->step+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parstep", &stepv, pindex ))
            stepv = 0.0;
	   Wscrprintf("maxVal[%d] = %1.12g   ",(int)(v->maxVal+0.1),maxv);
	   Wscrprintf("minVal[%d] = %1.12g   ",(int)(v->minVal+0.1),minv);
	   Wscrprintf("step[%d] = %1.12g\n\n",
		(int)(v->step+0.1),stepv);
	}
	else
	{
	   Wscrprintf("maxVal = %1.12g   ",v->maxVal);
	   Wscrprintf("minVal = %1.12g   ",v->minVal);
	   Wscrprintf("step = %1.12g\n\n",v->step);
	}
    }
    else
Exemplo n.º 5
0
double AspUtil::getReal(string varname, double defaultVal)
{
    const char *cname = varname.c_str();
    double value;
    if (P_getreal(CURRENT, cname, &value, 1)) { // Try CURRENT
        if (P_getreal(GLOBAL, cname, &value, 1)) { // Try GLOBAL
            // Doesnt exist; create it with default value
            setReal(varname, defaultVal, false);
            return defaultVal;
        }
    }
    return value;
}
Exemplo n.º 6
0
void get_transverseShimSums(int fromPars, int *pos, int *neg)
{
   *pos = *neg = 0;
   if (shimset > 0 && shimset <= MAX_SHIMSET)
   {
      register int index;
      double dbltmp;
      int hwShimVal;

      for (index=Z0 + 1; index <= MAX_SHIMS; index++)
      {
         if (ISACTIVE(index) && ISTRANSVERSE(index) )
         {
            if (fromPars)
            {
               P_getreal( CURRENT, sh_names[index], &dbltmp, 1);
            }
            else
            {
               getExpStatusShim(index, &hwShimVal);
               dbltmp = (double) hwShimVal;
            }
            if (dbltmp >= 0.0)
               *pos += dbltmp;
            else
               *neg -= dbltmp;
         }
      }
   }
   return;
}
Exemplo n.º 7
0
double AspUtil::getReal(string varname, int index, double defaultVal)
{
    const char *cname = varname.c_str();
    double value;

    if (index <= 0) {
        index = 1;
    }
    if (P_getreal(CURRENT, cname, &value, index)) { // Try CURRENT
        if (P_getreal(GLOBAL, cname, &value, index)) { // Try GLOBAL
            // Doesnt exist
            return defaultVal;
        }
    }
    return value;
}
Exemplo n.º 8
0
int jcurwin_jexp(int expnum, int oldexpnum )
{
    int index, get1, get2, retval=1;
    double dval;
    vInfo info; /* int VnmrJViewId */
    char path[MAXSTR];
    struct stat     stat_blk;

    (void) oldexpnum;
    if (mode_of_vnmr==AUTOMATION) /* || (mode_of_vnmr==BACKGROUND) */ 
      return(retval);

    if (expnum > 0)
    {
      sprintf(path, "%s/lock_%d.primary", userdir, expnum);
      if (stat( path, &stat_blk ) != 0) return(retval);

      get1 = P_getVarInfo(GLOBAL, "jcurwin", &info);
      get2 = P_getreal(GLOBAL, "jviewports", &dval, 1);
/* read number of viewports from jviewports[1] */
      if (get1==0 && get2==0)
      {
	get2 = (int) (dval + 0.5);
	if ((get2 > 0) && (get2 <= info.size))
	{
	  for (index=0; index<get2; index++)
	  {
	    P_getreal(GLOBAL, "jcurwin", &dval, index+1);
	    if (expnum == (int)dval)
	    {
	      char mstr[MAXPATH];
/*	      sprintf(mstr, "viewport %d", index+1);
	      writelineToVnmrJ("vnmrjcmd",mstr);
	      sprintf(mstr, "vplayout use %d", index+1);
	      writelineToVnmrJ("vnmrjcmd",mstr);
*/
	      P_getstring(GLOBAL, "jviewportlabel", mstr, index+1, MAXPATH);
	      Winfoprintf("Cannot join workspace exp%d - in use by %s viewport.\n",expnum,mstr);
	      retval = 0;
	      break;
	    }
	  }
	}
      }
    }
    return(retval);
}
Exemplo n.º 9
0
static int get_flashc_parms (double *parraydim, double *pnf, double *pni )
/* 
Purpose:
-------
     Routine get_flashc_parms shall obtain some Vnmr process parameters for 
flashc.

Arguments:
---------
parraydim     :  (  O)  Pointer to value of Vnmr process parameter arraydim.
pnf	      :  (  O)  Pointer to value of Vnmr process parameter nf.
pni	      :  (  O)  Pointer to value of Vnmr process parameter ni.
*/
{ /* Begin function get_flashc_parms */
   /*
   Local Variables:
   ---------------
   r	 :  Return value of a function.
   */
   int r;
   /*
   Begin Executable Code:
   ---------------------
   */
   /* Get existing values */
   if ( ( r = P_getreal ( PROCESSED, "arraydim", parraydim, 1 ) ) != 0 )
   {  P_err ( r, "arraydim", ":" );
      ABORT;
   }
   if ( ( r = P_getreal ( PROCESSED, "nf", pnf, 1 ) ) != 0 )
   {  P_err ( r, "nf", ":" );
      ABORT;
   }
   /* "ni" is allowed to not exist */
   /* Value "-1" codes for "not set" */
   if ( P_getreal ( PROCESSED, "ni", pni, 1 ) != 0 )
      *pni = -1;
   if ( *pni == 0 )
      *pni = -1;

   /* Normal successful return */
   RETURN;

} /* End function get_flashc_parms */
Exemplo n.º 10
0
// fwc,fsc,fwc2,fsc2 are always set to wc,sc,wc2,sc2 by Vnmrbg
// they differ only if user explicitly set wc,sc,wc2,sc2 in macro or command line.
// In this case, resize window will not call setFullChart.
int adjustFull() {
  int r;
  double t_sc,t_wc,t_sc2,t_wc2;
  if ( (r=P_getreal(CURRENT,"sc" ,&t_sc, 1)) )
    { P_err(r,"current ","sc:"); return 1; }
  if ( (r=P_getreal(CURRENT,"wc" ,&t_wc, 1)) )
    { P_err(r,"current ","wc:"); return 1; }
  if ( (r=P_getreal(CURRENT,"sc2" ,&t_sc2, 1)) )
    { P_err(r,"current ","sc2:"); return 1; }
  if ( (r=P_getreal(CURRENT,"wc2" ,&t_wc2, 1)) )
    { P_err(r,"current ","wc2:"); return 1; }

  if ( ((int)t_sc==fsc) &&
       ((int)t_wc==fwc) &&
       ((int)t_sc2==fsc2) &&
       ((int)t_wc2==fwc2) )
    return 1;
  else
    return 0;
}
Exemplo n.º 11
0
int getparm(char *varname, char *vartype, int tree,
            void *varaddr, int size)
{
    int ret;
    char mess[MAXSTR];

    if ( (strcmp(vartype,"REAL") == 0) || (strcmp(vartype,"real") == 0) )
    {
        if ((ret = P_getreal(tree,varname,(double *)varaddr,1)) < 0)
        {
           if (dowarn)
           {
             sprintf(mess,"Cannot get parameter: %s\n",varname);
             text_error(mess);
	     if (bgflag)
	         P_err(ret,varname,": ");
           }
           else
           {
              dowarn = 1;
           }
	   return(1);
        }
    }
    else 
    {
	if ( (strcmp(vartype,"STRING") == 0) || 
	     (strcmp(vartype,"string") == 0) )
        {
            if ((ret = P_getstring(tree,varname,(char *)varaddr,1,size)) < 0)
            {
              if (dowarn)
              {
                sprintf(mess,"Cannot get parameter: %s\n",varname);
                text_error(mess);
		if (bgflag)
	     	    P_err(ret,varname,": ");
              }
              else
              {
                 dowarn=1;
              }
              return(1);
            }
	}
	else
	{   sprintf(mess,"Variable '%s' is neither a 'real' or 'string'.\n",
			vartype);
            text_error(mess);
	    return(1);
	}
      }
    return(0);
}
Exemplo n.º 12
0
static void jviewport_init()
{
    int e;
    double dcurwin;
    e=P_getreal(GLOBAL,"jviewport",&dcurwin,1);
    if (e < 0)
    {	P_creatvar(GLOBAL,"jviewport",ST_REAL);
	P_setlimits(GLOBAL,"jviewport", (double)(VNMRJ_NUM_VIEWPORTS * VNMRJ_NUM_VIEWPORTS), 0.0, 1.0);
	P_setprot(GLOBAL,"jviewport",33045);
    }
    P_setreal(GLOBAL,"jviewport",(double)(VnmrJViewId),1);
}
Exemplo n.º 13
0
void AspFrame::deleteRoi()
{
    double c1,c2;
    double reffrq = getDefaultDataInfo()->haxis.scale;
    if(getCursorMode() == 2) {
      P_getreal(CURRENT, "cr", &c1, 1);
      P_getreal(CURRENT, "delta", &c2, 1);
      c2 = c1 -c2;
      if (reffrq>0) {
	c1 /= reffrq;
	c2 /= reffrq;
      }
      roiList->deleteRoi(c1,c2);
    } else {
      P_getreal(CURRENT, "cr", &c1, 1);
      if (reffrq>0) {
	c1 /= reffrq;
      }
      roiList->deleteRoi(c1);
    }
    displayTop();
}
Exemplo n.º 14
0
/*------------------------------------------------------------------------------
|
|	maxminlimit(tree,name)
|
|	This function returns the max & min limit of the real variable based
|				Author: Greg Brissey  8-18-95
+----------------------------------------------------------------------------*/
int par_maxminstep(int tree, const char *name, double *maxv, double *minv, double *stepv)
{
   int             ret,pindex;
   vInfo           varinfo;	/* variable information structure */
   char            mess[MAXSTR];

   if ( (ret = P_getVarInfo(tree, name, &varinfo)) )
   {
      sprintf(mess, "Cannot find the variable: %s", name);
      text_error(mess);
      if (bgflag)
	 P_err(ret, name, ": ");
      return (-1);
   }
   if (varinfo.basicType != ST_REAL)
   {
      sprintf(mess, "The variable '%s' is not a type 'REAL'", name);
      text_error(mess);
   }
   if (varinfo.prot & P_MMS)
   {
      pindex = (int) (varinfo.minVal+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parmin", minv, pindex ))
         *minv = -1.0e+30;
      pindex = (int) (varinfo.maxVal+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parmax", maxv, pindex ))
         *maxv = 1.0e+30;
      pindex = (int) (varinfo.step+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parstep", stepv, pindex ))
            *stepv = 0.0;
   }
   else
   {
       *maxv = varinfo.maxVal;
       *minv = varinfo.minVal;
       *stepv = varinfo.step;
   }
   return (0);
}
Exemplo n.º 15
0
int getplaneno()
{
   double tmp;

   if ( P_getreal(PROCESSED, "index2", &tmp, 1) < 0 )
   {
      return(-1);
   }
   else
   {
      return( (int) tmp);
   }
}
Exemplo n.º 16
0
static void compare_shims()
{
	const char	*cur_shim;
	char	 tbuf1[ 12 ], tbuf2[ 12 ];
	int	 iter, one_undef, two_undef, sh_val1, sh_val2;
	double	 rval1, rval2;

	for (iter = 0; iter < MAX_SHIMS; iter++) {
		cur_shim = get_shimname( iter );

                sh_val1 = sh_val2 = 0;
		one_undef = P_getreal( CURRENT, cur_shim, &rval1, 1 );
		two_undef = P_getreal( PROCESSED, cur_shim, &rval2, 1 );

	/*  If shim not defined in either set, move to the next.  */

		if (one_undef && two_undef)
		  continue;

		if ( !one_undef ) {
			sh_val1 = (int)(rval1 >= 0 ? rval1+0.1 : rval1-0.1);
			sprintf( &tbuf1[ 0 ], "%d", sh_val1 );
		}
		else
		  strcpy( &tbuf1[ 0 ], "undefined" );
		if ( !two_undef ) {
			sh_val2 = (int)(rval2 >= 0 ? rval2+0.1 : rval2-0.1);
			sprintf( &tbuf2[ 0 ], "%d", sh_val2 );
		}
		else
		  strcpy( &tbuf2[ 0 ], "undefined" );

		if (one_undef || two_undef || sh_val1 != sh_val2) {
			print_line( cur_shim, &tbuf1[ 0 ], &tbuf2[ 0 ] );
		}
	}
}
Exemplo n.º 17
0
void jcurwin_setexp(char *estring, int oldexpnum )
{
    int expnum;

    expnum = atoi(estring);
    if ((expnum < 0) || (expnum > MAXEXPS))
    {
      Werrprintf("jexp: value of jcurwin=%s out-of-range",estring);
      return;
    }
    if (P_setreal(GLOBAL,"jcurwin",(double)(expnum),VnmrJViewId) != 0)
    {
      Werrprintf("WARNING: jexp could not set parameter jcurwin");
    }
    else
    {
/* see jAutoSendIfGlobal( "jcurwin" ); */
      char mstr[MAXSTR];
      double dval;
      int i;
      vInfo info;
      sprintf(mstr,"jcurwin[%d]=%d",VnmrJViewId,expnum);
      writelineToVnmrJ("pglo",mstr);
/* check all other jcurwin values */
      if (oldexpnum > -1)
      {
        if (P_getVarInfo(GLOBAL, "jcurwin", &info)==0)
        {
	  if (info.size > VnmrJViewId)
	  {
	    for (i=VnmrJViewId; i<info.size; i++)
	    {
	      P_getreal(GLOBAL, "jcurwin", &dval, i+1);
/* if match, set to oldexpnum - see unlockAllExp() in locksys.c */
	      if ((int)(dval+0.1) == expnum)
	      {
		P_setreal(GLOBAL, "jcurwin", (double)(oldexpnum), i+1);
	        sprintf(mstr,"jcurwin[%d]=%d", i+1, oldexpnum);
	        writelineToVnmrJ("pglo",mstr);
	      }
	    }
	  }
        }
      }
    }
}
Exemplo n.º 18
0
void getRealSetDefault(int tree, const char *name, double *buf, double def)
{
	int index;
	if (tree != CURRENT)
	{
		if (P_getreal(tree, name,buf,1) < 0)
		*buf = def;
	}
	else
	{
		index = find(name);   /* hash table find */
	    if (index == NOTFOUND)
	       *buf = def;
	    else
	       *buf = *( (double *) cvals[index]);
	}
}
Exemplo n.º 19
0
int setFullChart(int d2flag) {
   int r;
  double sc,wc,sc2,wc2,wcmax,wc2max;
  if ( (r=P_getreal(GLOBAL,"wcmax"  ,&wcmax,  1)) )
    { P_err(r,"global ","wcmax:");  wcmax = 500.0; }
  if ( (r=P_getreal(GLOBAL,"wc2max" ,&wc2max, 1)) )
    { P_err(r,"global ","wc2max:"); wc2max = 240.0; }
  if ( (r=P_getreal(CURRENT,"sc" ,&sc, 1)) )
    { P_err(r,"current ","sc:"); return 1; }
  if ( (r=P_getreal(CURRENT,"wc" ,&wc, 1)) )
    { P_err(r,"current ","wc:"); return 1; }
  if ( (r=P_getreal(CURRENT,"sc2" ,&sc2, 1)) )
    { P_err(r,"current ","sc2:"); return 1; }
  if ( (r=P_getreal(CURRENT,"wc2" ,&wc2, 1)) )
    { P_err(r,"current ","wc2:"); return 1; }

      if ( d2flag ) { 
  	  double xband = 9*xcharpixels/((double)(mnumxpnts-right_edge) / wcmax);
	  double yband = 3*ycharpixels/((double)(mnumypnts-ymin) / wc2max); 
	  wc  = wcmax - xband;
	  sc  = 0;
          wc2 = wc2max - yband;
          sc2 = yband/2;
      } else {
	  if(get_drawVscale() > 0) set_vscaleMode(0);
	  double margin = getPlotMargin();
          wc  = wcmax-2*margin;
	  sc  = margin;
          wc2 = wc2max-2*margin;
          sc2 = margin;
      }
      dss_sc = 0;
      dss_wc = wc;
      dss_sc2 = 0;
      dss_wc2 = wc2;
      P_setreal(CURRENT,"dss_sc",dss_sc,0);
      P_setreal(CURRENT,"dss_wc",dss_wc,0);
      P_setreal(CURRENT,"dss_sc2",dss_sc2,0);
      P_setreal(CURRENT,"dss_wc2",dss_wc2,0);

  P_setreal(CURRENT,"sc",sc,0);
  P_setreal(CURRENT,"wc",wc,0);
  P_setreal(CURRENT,"sc2",sc2,0);
  P_setreal(CURRENT,"wc2",wc2,0);
  fwc=(int)wc;
  fsc=(int)sc;
  fwc2=(int)wc2;
  fsc2=(int)sc2;
  RETURN;
}
Exemplo n.º 20
0
static void jcurwin_init(char *curexp )
{
    int e, i;
    double dcurwin;
    char expnum[8];

    e=P_getreal(GLOBAL,"jcurwin",&dcurwin,VnmrJViewId);
    if (e==-2)
    {	P_creatvar(GLOBAL,"jcurwin",ST_REAL);
	P_setlimits(GLOBAL,"jcurwin", (double)(MAXEXPS), 0.0, 1.0);
	P_setprot(GLOBAL,"jcurwin",272);
	for (i=1; i<=VNMRJ_NUM_VIEWPORTS; i++)
	  P_setreal(GLOBAL,"jcurwin",(double)(i),i);
	dcurwin = ((double)VnmrJViewId);
    }
    sprintf( expnum, "%d", ((int)(dcurwin + 0.5)) );
    strcpy( curexp, userdir );
    strcat( curexp, "/exp" );
    strcat( curexp, expnum );
}
Exemplo n.º 21
0
int getArrayparval(const char *parname, double *parval[])
{
  int nn, j, k;
  double am=0.0;

  if (P_getsize(CURRENT,parname,&nn) <= 0)
  {
      abort_message("parameter %s does not exist\n", parname);
  }

  (*parval = (double *) calloc(nn, sizeof(double)));
  for (j=0; j<nn; j++)
  {
	if ((k = P_getreal(CURRENT, parname, &am, j+1)) < 0)
	{
           abort_message("parameter %s does not exist\n", parname);
	}
	(*parval)[j] = am;
  }
  return nn;
}
Exemplo n.º 22
0
int
init_shimnames(int tree)
{
   double dbltmp;
   int    res;

   sh_names = sh_names_std;
   if ( (tree == SYSTEMGLOBAL) || (tree == GLOBAL) )
   {
      res = P_getreal( tree, "shimset", &dbltmp, 1);
      if (res >= 0)
      {
         shimset = (int) (dbltmp + 0.5);
         if (shimset < 1){
	    fprintf(stderr,"Illegal shimset number: %d\n", shimset);
            shimset = 1;
	 }
         else if (shimset > MAX_SHIMSET)
	 {
	    fprintf(stderr,"shimset number > MAX_SHIMSET (%d>%d)\n",
		    shimset, MAX_SHIMSET);
            shimset = MAX_SHIMSET;
	 }
         if (shimset == 12)
            sh_names = sh_names_12;
      }
      else
      {
         shimset = 1;		/* if recognized tree, default to Varian */
      }
   }
   else
   {
     shimset = -1;			/* if unrecognized tree, set all to active */
   }
   return( shimset );
}
Exemplo n.º 23
0
void settmpgradtype(char *tmpgradname)
{
   double pfgBoard;
   char tmpGradtype[MAXSTR];

   if (P_getstring(CURRENT, tmpgradname, tmpGradtype, 1, MAXSTR) == 0)
   {
      if (strlen(tmpGradtype) >= 3)
      {
         P_setstring(GLOBAL,"gradtype",tmpGradtype,1);

//       see checkGradtype() in psgmain.cpp
         specialGradtype = 0;
         if ( P_getreal(GLOBAL,"pfg1board",&pfgBoard,1) == 0)
         {
            if (pfgBoard > 0.5)
            {
               strcpy(tmpGradtype,"   ");
               P_getstring(GLOBAL,"gradtype",tmpGradtype,1,MAXSTR-1);
               if (tmpGradtype[2] == 'a')
               {
                  specialGradtype = 'a';
               }
               else if (tmpGradtype[2] == 'h')
               {
                  specialGradtype = 'h';
               }
               if (specialGradtype)
               {
                  tmpGradtype[2] = 'p';
                  P_setstring(GLOBAL,"gradtype",tmpGradtype,1);
               }
            }
         }
      }
   }
}
Exemplo n.º 24
0
int wrspec_find_epscale(float *epscale, int proctype, int elem1_num, int elem2_num )
{
	float		*epsdelay, deps1, deps2;
	double		 eps_tmp;
	vInfo		 info;
	int		 i;

        (void) proctype;
/*	if (proctype == 6) { *epscale = 0.0; else do below; } */
/*	calc scale from eps */
/*	note only valid for proctype == 2 || proctype == 4 || proctype == 5 */
	*epscale = 0.0;	/* *epscale=0 translates to no scaling - see wrspec_output */
	if ( P_getVarInfo(CURRENT, "d3", &info) ) {
		*epscale = 0.0; 
	}
        else {  
		epsdelay=(float *)malloc((info.size) * sizeof(float));
		for( i=0; i< (int) info.size; i++ ) {
                        P_getreal(CURRENT, "d3", &eps_tmp, i+1);
                        epsdelay[i] = (float) eps_tmp; 
			}
		*epscale = 1.0;
		deps1 = epsdelay[(elem1_num - 1) % info.size]; 
		deps2 = epsdelay[(elem2_num - 1) % info.size]; 
		deps1 = deps2 - deps1;
		deps2 = deps1;
		if ( deps2 < 0 ) { deps2 = -deps2; }
		if ( deps2 < NEW_AMP_TOL ) { *epscale = 0.0; }
		else { *epscale = 1.0/(360.0 * deps1); }		/* true value */
		free((char *) epsdelay);
		}
	EPRINT1(1, "  wrspec: *epscale %f\n", *epscale ); 
/*	if (*epscale < 0.0) { *epscale = -1.0 * *epscale; } */

	return(0);
}
Exemplo n.º 25
0
Arquivo: cps.c Projeto: timburrow/ovj3
/*-----------------------------------------------------------------
|       getmaxval()/1
|       Gets the maximum value of an arrayed or list real parameter.
+------------------------------------------------------------------*/
int getmaxval(const char *parname )
{
    int      size,r,i,tmpval,maxval;
    double   dval;
    vInfo    varinfo;

    if ( (r = P_getVarInfo(CURRENT, parname, &varinfo)) ) {
        abort_message("getmaxval: could not find the parameter \"%s\"\n",parname);
    }
    if ((int)varinfo.basicType != 1) {
        abort_message("getmaxval: \"%s\" is not an array of reals.\n",parname);
    }

    size = (int)varinfo.size;
    maxval = 0;
    for (i=0; i<size; i++) {
        if ( P_getreal(CURRENT,parname,&dval,i+1) ) {
	    abort_message("getmaxval: problem getting array element %d.\n",i+1);
	}
	tmpval = (int)(dval+0.5);
	if (tmpval > maxval)	maxval = tmpval;
    }
    return(maxval);
}
Exemplo n.º 26
0
void AspFrame::addRoiFromCursors() {
  if(getCursorMode() != 2) {
	Winfoprintf("Try again after selecting second cursor with right mouse button.");
	return;
  }
  spAspDataInfo_t dataInfo = getDefaultDataInfo();
  if(dataInfo->vaxis.rev) { // 1D band
    double c1,c2;
    P_getreal(CURRENT, "cr", &c1, 1);
    P_getreal(CURRENT, "delta", &c2, 1);
    c2 = c1 - c2;
    double reffrq = dataInfo->haxis.scale;
    if (reffrq>0) {
	c1 /= reffrq;
	c2 /= reffrq;
    }
    addRoiFromCursors(c1,c2);
  } else { // 2D box
    double c11,c12,c21,c22;
    P_getreal(CURRENT, "cr", &c11, 1);
    P_getreal(CURRENT, "delta", &c12, 1);
    c12 = c11 - c12;
    double reffrq = dataInfo->haxis.scale;
    if (reffrq>0) {
	c11 /= reffrq;
	c12 /= reffrq;
    }
    P_getreal(CURRENT, "cr1", &c21, 1);
    P_getreal(CURRENT, "delta1", &c22, 1);
    c22 = c21 - c22;
    double reffrq1 = dataInfo->vaxis.scale;
    if (reffrq1>0) {
	c21 /= reffrq1;
	c22 /= reffrq1;
    }
    addRoiFromCursors(c11,c12,c21,c22);
  }
}
Exemplo n.º 27
0
void pulsesequence()
{

/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            mag_flg[MAXSTR],                            /*magic angle gradient*/
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
	    stCdec[MAXSTR],	       /* calls STUD+ waveforms from shapelib */
	    STUD[MAXSTR];   /* apply automatically calculated STUD decoupling */
 
int         icosel1,          			  /* used to get n and p type */
	    icosel2,
            t1_counter,  		        /* used for states tppi in t1 */
            t2_counter,  	 	        /* used for states tppi in t2 */
	    ni2 = getval("ni2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
	    del = getval("del"),     /* time delays for CH coupling evolution */
         BPdpwrspinlock,        /*  user-defined upper limit for spinlock(Hz) */
         BPpwrlimits,           /*  =0 for no limit, =1 for limit             */

	    del1 = getval("del1"),
	    del2 = getval("del2"),
/* STUD+ waveforms automatically calculated by macro "biocal"  	      */
/* and string parameter stCdec calls them from your shapelib. 	              */
   stdmf,                                /* dmf for STUD decoupling           */
   studlvl,	                         /* coarse power for STUD+ decoupling */
   rf80 = getval("rf80"), 			  /* rf in Hz for 80ppm STUD+ */
   bw, ofs, ppm,                            /* temporary Pbox parameters */
	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 */

/* p_d is used to calculate the isotropic mixing on the Cab region            */
        spinlock = getval("spinlock"), /* DIPSI-3 spinlock field strength in Hz */
        p_d,                  	       /* 50 degree pulse for DIPSI-2 at rfd  */
        rfd,                    /* fine power for 7 kHz rf for 500MHz magnet  */
	ncyc = getval("ncyc"), 			  /* no. of cycles of DIPSI-3 */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "ghcch_tocsy" .  SLP pulse shapes, "offC10" etc are called   */
/* directly from your shapelib.                    			      */
   pwC10,                       /* 180 degree selective sinc pulse on CO(174ppm) */
   pwZ,					  /* the largest of pwC10 and 2.0*pwN */
   rf10,	                 /* fine power for the pwC10 ("offC10") pulse */

   compC = getval("compC"),         /* adjustment for C13 amplifier compression */

	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 coversion factor*/
        gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

	gt3 = getval("gt3"),				   /* other gradients */
	gt5 = getval("gt5"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6");

    getstr("STUD",STUD);
    getstr("mag_flg",mag_flg);
    getstr("f1180",f1180);
    getstr("f2180",f2180);
   strcpy(stCdec, "stCdec80");
   stdmf = getval("dmf80");
   studlvl = pwClvl + 20.0*log10(compC*pwC*4.0*rf80);
   studlvl = (int) (studlvl + 0.5);
  P_getreal(GLOBAL,"BPpwrlimits",&BPpwrlimits,1);
  P_getreal(GLOBAL,"BPdpwrspinlock",&BPdpwrspinlock,1);


/*   LOAD PHASE TABLE    */

	settable(t3,2,phi3);
	settable(t6,1,phi6);
	settable(t5,4,phi5);
	settable(t10,1,phi10);
	settable(t11,4,rec);

        

/*   INITIALIZE VARIABLES   */


  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); }

    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

      setautocal();                        /* activate auto-calibration flags */ 
        
      if (autocal[0] == 'n') 
      {
        /* "offC10": 180 degree one-lobe sinc pulse on CO, null at Ca 139ppm away */
        pwC10 = getval("pwC10");
	  rf10 = (compC*4095.0*pwC*2.0*1.65)/pwC10;     /* needs 1.65 times more     */
	  rf10 = (int) (rf10 + 0.5);		           /* power than a square pulse */

        if( pwC > (24.0e-6*600.0/sfrq) )
	  { printf("Increase pwClvl so that pwC < 24*600/sfrq");
	    psg_abort(1); 
        }
      }
      else        /* if autocal = 'y'(yes), 'q'(quiet), r(read), or 's'(semi) */
      {
        if(FIRST_FID)                                            /* call Pbox */
        {
          ppm = getval("dfrq"); 
          bw = 118.0*ppm; ofs = 139.0*ppm;
          offC10 = pbox_make("offC10", "sinc180n", bw, ofs, compC*pwC, pwClvl);
          if(dm3[B] == 'y') H2ofs = 3.2;    
          ofs_check(H1ofs, C13ofs, N15ofs, H2ofs);
        }
        rf10 = offC10.pwrf;  pwC10 = offC10.pw;
      }
				
   /* dipsi-3 decoupling on CbCa */	
 	p_d = (5.0)/(9.0*4.0*spinlock);      /*  DIPSI-3 Field Strength */
 	rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0);
	rfd = (int) (rfd + 0.5);
  	ncyc = (int) (ncyc + 0.5);


/* CHECK VALIDITY OF PARAMETER RANGES */

    if( gt1 > 0.5*del - 1.0e-4)
    {
        printf(" gt1 is too big. Make gt1 less than %f.\n", (0.5*del - 1.0e-4));
        psg_abort(1);
    }

    if( dm[A] == 'y' )
    {
        printf("incorrect dec1 decoupler flag! Should be 'nny' or 'nnn' ");
        psg_abort(1);
    }

    if((dm2[A] == 'y' || dm2[C] == 'y'))
    {
        printf("incorrect dec2 decoupler flags! Should be 'nnn' ");
        psg_abort(1);
    }
    if((dm3[A] == 'y' || dm3[C] == 'y'))
    {
        printf("incorrect dec3 decoupler flags! Should be 'nnn' or 'nyn' ");
        psg_abort(1);
    }

    if( dpwr > 52 )
    {
        printf("don't fry the probe, DPWR too large!  ");
        psg_abort(1);
    }

    if( pw > 50.0e-6 )
    {
        printf("dont fry the probe, pw too high ! ");
        psg_abort(1);
    } 
  
    if( pwN > 100.0e-6 )
    {
        printf("dont fry the probe, pwN too high ! ");
        psg_abort(1);
    } 
 

/* PHASES AND INCREMENTED TIMES */

/*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    icosel1 = -1;  icosel2 = -1;
    if (phase1 == 2) 
	{ tsadd(t6,2,4); icosel1 = -1*icosel1; }
    if (phase2 == 2) 
	{ tsadd(t10,2,4); icosel2 = -1*icosel2; tsadd(t6,2,4); }


/*  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;


/*  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(t11,2,4); }

   if( ix == 1) d3_init = d3;
   t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
   if(t2_counter % 2) 
	{ tsadd(t5,2,4); tsadd(t11,2,4); }



/*   BEGIN PULSE SEQUENCE   */

status(A);
        if ( dm3[B] == 'y' )
          lk_sample();  
        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*/
   	delay(d1);
        if ( dm3[B] == 'y' )
          { lk_hold(); lk_sampling_off();}  /*freezes z0 correction, stops lock pulsing*/

	rcvroff();
	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
	decpwrf(rf0);
	obsoffset(tof);
	txphase(t3);
	delay(1.0e-5);

	decrgpulse(pwC, zero, 0.0, 0.0);	   /*destroy C13 magnetization*/
	zgradpulse(gzlvl1, 0.5e-3);
	delay(1.0e-4);
	decrgpulse(pwC, one, 0.0, 0.0);
	zgradpulse(0.7*gzlvl1, 0.5e-3);
	delay(5.0e-4);

      if ( dm3[B] == 'y' )     /* begins optional 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);
        }
	rgpulse(pw, t3, 0.0, 0.0);                    /* 1H pulse excitation */

        decphase(zero);
	delay(0.5*del + tau1 - 2.0*pwC);

        decrgpulse(2.0*pwC, zero, 0.0, 0.0);

        txphase(zero);
	delay(tau1);

	rgpulse(2.0*pw, zero, 0.0, 0.0);

                if (mag_flg[A] == 'y')
                {
                   magradpulse(icosel1*gzcal*gzlvl1,0.1*gt1);
                }
                else
                {
                   zgradpulse(icosel1*gzlvl1, 0.1*gt1);
                }
        decphase(t5);
	delay(0.5*del - 0.1*gt1);

	simpulse(pw, pwC, zero, t5, 0.0, 0.0);

	zgradpulse(gzlvl3, gt3);
        decphase(zero);
	delay(0.5*del2 - gt3);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl3, gt3);
        txphase(t6);
        decphase(one);
	delay(0.5*del2 - gt3);

	simpulse(pw, pwC, t6, one, 0.0, 0.0);

	zgradpulse(gzlvl4, gt3);
        txphase(zero);
        decphase(zero);
	delay(0.5*del1 - gt3);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl4, gt3);
	delay(0.5*del1 - gt3);

	decrgpulse(pwC, zero, 0.0, 0.0);
	decpwrf(rfd);
	delay(2.0e-6);
	initval(ncyc, v2);
	starthardloop(v2);
     decrgpulse(4.9*p_d,zero,0.0,0.0);
     decrgpulse(7.9*p_d,two,0.0,0.0);
     decrgpulse(5.0*p_d,zero,0.0,0.0);
     decrgpulse(5.5*p_d,two,0.0,0.0);
     decrgpulse(0.6*p_d,zero,0.0,0.0);
     decrgpulse(4.6*p_d,two,0.0,0.0);
     decrgpulse(7.2*p_d,zero,0.0,0.0);
     decrgpulse(4.9*p_d,two,0.0,0.0);
     decrgpulse(7.4*p_d,zero,0.0,0.0);
     decrgpulse(6.8*p_d,two,0.0,0.0);
     decrgpulse(7.0*p_d,zero,0.0,0.0);
     decrgpulse(5.2*p_d,two,0.0,0.0);
     decrgpulse(5.4*p_d,zero,0.0,0.0);
     decrgpulse(0.6*p_d,two,0.0,0.0);
     decrgpulse(4.5*p_d,zero,0.0,0.0);
     decrgpulse(7.3*p_d,two,0.0,0.0);
     decrgpulse(5.1*p_d,zero,0.0,0.0);
     decrgpulse(7.9*p_d,two,0.0,0.0);

     decrgpulse(4.9*p_d,two,0.0,0.0);
     decrgpulse(7.9*p_d,zero,0.0,0.0);
     decrgpulse(5.0*p_d,two,0.0,0.0);
     decrgpulse(5.5*p_d,zero,0.0,0.0);
     decrgpulse(0.6*p_d,two,0.0,0.0);
     decrgpulse(4.6*p_d,zero,0.0,0.0);
     decrgpulse(7.2*p_d,two,0.0,0.0);
     decrgpulse(4.9*p_d,zero,0.0,0.0);
     decrgpulse(7.4*p_d,two,0.0,0.0);
     decrgpulse(6.8*p_d,zero,0.0,0.0);
     decrgpulse(7.0*p_d,two,0.0,0.0);
     decrgpulse(5.2*p_d,zero,0.0,0.0);
     decrgpulse(5.4*p_d,two,0.0,0.0);
     decrgpulse(0.6*p_d,zero,0.0,0.0);
     decrgpulse(4.5*p_d,two,0.0,0.0);
     decrgpulse(7.3*p_d,zero,0.0,0.0);
     decrgpulse(5.1*p_d,two,0.0,0.0);
     decrgpulse(7.9*p_d,zero,0.0,0.0);

     decrgpulse(4.9*p_d,two,0.0,0.0);
     decrgpulse(7.9*p_d,zero,0.0,0.0);
     decrgpulse(5.0*p_d,two,0.0,0.0);
     decrgpulse(5.5*p_d,zero,0.0,0.0);
     decrgpulse(0.6*p_d,two,0.0,0.0);
     decrgpulse(4.6*p_d,zero,0.0,0.0);
     decrgpulse(7.2*p_d,two,0.0,0.0);
     decrgpulse(4.9*p_d,zero,0.0,0.0);
     decrgpulse(7.4*p_d,two,0.0,0.0);
     decrgpulse(6.8*p_d,zero,0.0,0.0);
     decrgpulse(7.0*p_d,two,0.0,0.0);
     decrgpulse(5.2*p_d,zero,0.0,0.0);
     decrgpulse(5.4*p_d,two,0.0,0.0);
     decrgpulse(0.6*p_d,zero,0.0,0.0);
     decrgpulse(4.5*p_d,two,0.0,0.0);
     decrgpulse(7.3*p_d,zero,0.0,0.0);
     decrgpulse(5.1*p_d,two,0.0,0.0);
     decrgpulse(7.9*p_d,zero,0.0,0.0);

     decrgpulse(4.9*p_d,zero,0.0,0.0);
     decrgpulse(7.9*p_d,two,0.0,0.0);
     decrgpulse(5.0*p_d,zero,0.0,0.0);
     decrgpulse(5.5*p_d,two,0.0,0.0);
     decrgpulse(0.6*p_d,zero,0.0,0.0);
     decrgpulse(4.6*p_d,two,0.0,0.0);
     decrgpulse(7.2*p_d,zero,0.0,0.0);
     decrgpulse(4.9*p_d,two,0.0,0.0);
     decrgpulse(7.4*p_d,zero,0.0,0.0);
     decrgpulse(6.8*p_d,two,0.0,0.0);
     decrgpulse(7.0*p_d,zero,0.0,0.0);
     decrgpulse(5.2*p_d,two,0.0,0.0);
     decrgpulse(5.4*p_d,zero,0.0,0.0);
     decrgpulse(0.6*p_d,two,0.0,0.0);
     decrgpulse(4.5*p_d,zero,0.0,0.0);
     decrgpulse(7.3*p_d,two,0.0,0.0);
     decrgpulse(5.1*p_d,zero,0.0,0.0);
     decrgpulse(7.9*p_d,two,0.0,0.0);
	endhardloop();

        dec2phase(zero);
        decphase(zero);
        txphase(zero);
	decpwrf(rf10);
	delay(tau2);
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC10", "", 2.0*pw, pwC10, 2.0*pwN, zero, zero, zero, 0.0, 0.0);
        if(pwC10>2.0*pwN) pwZ=0.0; else pwZ=2.0*pwN - pwC10;

	delay(tau2);
	decpwrf(rf0);
                if (mag_flg[A] == 'y')
                {
                   magradpulse(-icosel2*gzcal*gzlvl2, 1.8*gt1);
                }
                else
                {
                   zgradpulse(-icosel2*gzlvl2, 1.8*gt1);
                }
	delay(2.02e-4);

	decrgpulse(2.0*pwC, zero, 0.0, 0.0);

	decpwrf(rf10);
                if (mag_flg[A] == 'y')
                {
                   magradpulse(icosel2*gzcal*gzlvl2, 1.8*gt1);
                }
                else
                {
                   zgradpulse(icosel2*gzlvl2, 1.8*gt1);
                }
	delay(2.0e-4 + WFG3_START_DELAY + pwZ);

	decshaped_pulse("offC10", pwC10, zero, 0.0, 0.0);
	decpwrf(rf0);
	decrgpulse(pwC, zero, 2.0e-6, 0.0);

	zgradpulse(gzlvl5, gt5);
	delay(0.5*del1 - gt5);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	txphase(one);
	decphase(t10);
	delay(0.5*del1 - gt5);

	simpulse(pw, pwC, one, t10, 0.0, 0.0);

	zgradpulse(gzlvl6, gt5);
	txphase(zero);
	decphase(zero);
	delay(0.5*del2 - gt5);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl6, gt5);
	delay(0.5*del2 - gt5);

	simpulse(pw, pwC, zero, zero, 0.0, 0.0);

	delay(0.5*del - 0.5*pwC);

	simpulse(2.0*pw,2.0*pwC, zero, zero, 0.0, 0.0);
        if (mag_flg[A] == 'y')
            magradpulse(gzcal*gzlvl1, gt1);
        else
            zgradpulse(gzlvl1, gt1);
        rcvron();
   if ((STUD[A]=='n') && (dm[C] == 'y'))
        decpower(dpwr);
        if ( dm3[B] == 'y' )   /* turns off 2H decoupling  */
        {
           delay(0.5*del-40.0e-6 -gt1 -1/dmf3);
           setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3);
           dec3rgpulse(1/dmf3,three,2.0e-6,2.0e-6);
           dec3blank();
           lk_autotrig();   /* resumes lock pulsing */
           lk_sample();
           if (mag_flg[A] == 'y')
            statusdelay(C,40.0e-6  - 2.0*VAGRADIENT_DELAY - POWER_DELAY);
           else
            statusdelay(C,40.0e-6  - 2.0*GRADIENT_DELAY - POWER_DELAY);
        }
      else
        {
         delay(0.5*del-40.0e-6 -gt1);
        if (mag_flg[A] == 'y')
         statusdelay(C,40.0e-6  - 2.0*VAGRADIENT_DELAY - POWER_DELAY);
        else
         statusdelay(C,40.0e-6  - 2.0*GRADIENT_DELAY - POWER_DELAY);
        }
  if ((STUD[A]=='y') && (dm[C] == 'y'))
        {decpower(studlvl);
         decunblank();
         decon();
         decprgon(stCdec,1/stdmf, 1.0);
         startacq(alfa);
         acquire(np, 1.0/sw);
         decprgoff();
         decoff();
         decblank();
        }
 setreceiver(t11);
}		 
Exemplo n.º 28
0
int decc_compare(int argc, char *argv[], int retc, char *retv[])
{
int i, same;
char oe[MAXSTR],e[MAXSTR];
double otaus, taus, oampls, ampls, olimits, limits, oscales, scales;

   (void)argv;
   if (argc>1) debug=1;
   else        debug=0;
   if (debug)
      Winfoprintf("decc_compare started");

   same=1;
   for (i=1; i<53; i++)
   {
      if (P_getstring(GLOBAL, "enabled", e, i, MAXSTR) < 0)
      {
         Werrprintf("decc_compare: cannot find 'enabled'");
         same=0; break;
      }
      if (P_getstring(GLOBAL, "o_enabled", oe, i, MAXSTR) < 0)
      {
         Werrprintf("decc_compare: cannot find 'o_enabled'");
         same=0; break;
      }
      if (e[0] != oe[0])
      {
         same=0; break;
      }

      if (P_getreal(GLOBAL, "taus", &taus, i) < 0)
      {
         Werrprintf("decc_compare: cannot find 'taus'");
         same=0; break;
      }
      if (P_getreal(GLOBAL, "o_taus", &otaus, i) < 0)
      {
         Werrprintf("decc_compare: cannot find 'o_taus'");
         same=0; break;
      }
      if (fabs(taus-otaus) > 1e-6)
      {
         same=0; break;
      }
         
      if (P_getreal(GLOBAL, "ampls", &ampls, i) < 0)
      {
         Werrprintf("decc_compare: cannot find 'ampls'");
         same=0; break;
      }
      if (P_getreal(GLOBAL, "o_ampls", &oampls, i) < 0)
      {
         Werrprintf("decc_compare: cannot find 'o_ampls'");
         same=0; break;
      }
      if (fabs(ampls-oampls) > 1e-6)
      {
         same=0; break;
      }
   }

   if (same != 0) 
   {
      for (i=1; i<8; i++)
      {
         if (P_getreal(GLOBAL, "limits", &limits, i) < 0)
         {
            Werrprintf("decc_compare: cannot find 'limits'");
            same=0; break;
         }
         if (P_getreal(GLOBAL, "o_limits", &olimits, i) < 0)
         {
            Werrprintf("decc_compare: cannot find 'o_limits'");
            same=0; break;
         }
         if (fabs(limits-olimits) > 5e-9)
         {
            same=0; break;
         }
      }
   }
	
   if (same != 0) 
   {
      for (i=1; i<11; i++)
      {
         if (P_getreal(GLOBAL, "scales", &scales, i) < 0)
         {
            Werrprintf("decc_compare: cannot find 'scales'");
            same=0; break;
         }
         if (P_getreal(GLOBAL, "o_scales", &oscales, i) < 0)
         {
            Werrprintf("decc_compare: cannot find 'o_scales'");
            same=0; break;
         }
         if (fabs(scales-oscales) > 5e-9)
         {
            same=0; break;
         }
      }
   }

   if (same != 0)
   {
      if (P_getstring(GLOBAL, "decctool_fln", e, 1, MAXSTR) < 0)
      {
         Werrprintf("decc_compare: cannot find 'decctool_fln'");
         same=0;
      }
      if (P_getstring(GLOBAL, "deccorig_fln", oe, 1, MAXSTR) < 0)
      {
         Werrprintf("decc_compare: cannot find 'deccorig_fln'");
         same=0;
      }
      if ( strcmp(e,oe) )
      {
Winfoprintf("decc_compare: '%s' '%s'\n",e,oe);
         same=0;
      }
   }
	
       
   if (P_setreal(GLOBAL, "deccflag", (double)same, 7) < 0)
   {
      Werrprintf("decc_compare: cannot set deccflag[7]");
   }
   appendvarlist("deccflag");
   if (retc > 0) 
      retv[0] = realString((double) same);
   RETURN; 
}
Exemplo n.º 29
0
int decc_save(int argc, char *argv[], int retc, char *retv[])
{
char    sysgcoil[MAXSTR];
char    filename[MAXSTR];
char    decclibpath[MAXSTR];
char    fullpath[MAXSTR];
char    cmd[MAXSTR];
char   *tmpPtr, *tmpPtr2;
char    enabled[MAXSTR];
double  taus,ampls,scales,limits;
int     done, biggest;
int     i, j,k;
FILE   *fd,*fd2;

   (void) retc;
   (void) retv;
   if (argc>2) debug=1;
   else        debug=0;
   if (argc < 2)
   {
      Werrprintf("Usage -- decc_save(filename)");
      RETURN;
   }
   if (P_getstring(SYSTEMGLOBAL,"sysgcoil", sysgcoil, 1, MAXSTR) < 0)
   {
      Werrprintf("decc_save: cannot find 'sysgcoil'");
      RETURN;
   }

   strcpy(filename,argv[1]);
   if (debug) Winfoprintf("decc_save: inputfile='%s'\n",filename);
   if (filename[0] == '.')
   {  Werrprintf("decc_save: filename cannot start with a '.'");
      ABORT;
   }

   // strip version if any
   getVersion(filename);
   if (debug) Winfoprintf("decc_save: minus version='%s'\n",filename);

   // check decclib for highest version 
   strcpy(decclibpath,systemdir);
   strcat(decclibpath,"/imaging/decclib/");
   strcpy(fullpath,decclibpath);
   strcat(fullpath,filename);

   biggest = getBiggestVersion(fullpath);

   tmpPtr = tmpPtr2 = filename;
   sprintf(fullpath,"%s%s.%d",decclibpath,tmpPtr,biggest+1);

   done=0;
   while ( ! done)
   {
      Winfoprintf("decc_save: saving to '%s'",fullpath);
      // save to file
      fd = fopen(fullpath,"w");
      if (fd==0)
      {
         Werrprintf("decc_save: problem opening %s",fullpath);
         RETURN;
      }
      fprintf(fd,"filename\t%s.%d\n",tmpPtr2,biggest+1);
      fd2 = popen("date","r");
      fgets(cmd,MAXSTR,fd2);
      pclose(fd2);
      fprintf(fd,"date\t%s\n",cmd);
      
      i=1; j=0; k=0;
      while (j<13)
      {
         fprintf(fd,"%s",terms[j]);		// "xx" etc.
         k += nterms[j];
         while (i<=k)
         {
            fputc((int)'\t',fd);
            if (P_getstring(GLOBAL,"enabled",enabled,i,MAXSTR) < 0)
            {
               Werrprintf("decc_save: cannot find 'enabled'");
            }
            if (enabled[0]=='n') fputc((int)'*',fd);
            if (P_getreal(GLOBAL,"taus",&taus,i) < 0)
            {
               Werrprintf("decc_save: cannot find 'taus'");
            }
            if (P_getreal(GLOBAL,"ampls",&ampls,i) < 0)
            {
               Werrprintf("decc_save: cannot find 'ampls'");
            }
            fprintf(fd,"%g %g",taus/1000.0,ampls/100.0);
            i++;
         }
         fputc((int)'\n',fd);
         j++;
      }

      fprintf(fd,"eccscale");
      for (i=1; i<5; i++)
      {
         if (P_getreal(GLOBAL,"scales",&scales,i) < 0)
         {
            Werrprintf("decc_save: cannot find 'scales'");
         }
         fprintf(fd,"\t%g",scales);
      }
      fputc((int)'\n',fd);

      fprintf(fd,"shimscale");
      for (i=5; i<8; i++)
      {
         if (P_getreal(GLOBAL,"scales",&scales,i) < 0)
         {
            Werrprintf("decc_save: cannot find 'scales'");
         }
         fprintf(fd,"\t%g",scales);
      }
      fputc((int)'\n',fd);

      fprintf(fd,"totalscale");
      for (i=8; i<11; i++)
      {
         if (P_getreal(GLOBAL,"scales",&scales,i) < 0)
         {
            Werrprintf("decc_save: cannot find 'scales'");
         }
         fprintf(fd,"\t%g",scales);
      }
      fputc((int)'\n',fd);

      fprintf(fd,"slewlimit");
      for (i=1; i<5; i++)
      {
         if (P_getreal(GLOBAL,"limits",&limits,i) < 0)
         {
            Werrprintf("decc_save: cannot find 'limits'");
         }
         fprintf(fd,"\t%g",limits);
      }
      fputc((int)'\n',fd);

      fprintf(fd,"dutylimit");
      for (i=5; i<9; i++)
      {
         if (P_getreal(GLOBAL,"limits",&limits,i) < 0)
         {
            Werrprintf("decc_save: cannot find 'limits'");
         }
         fprintf(fd,"\t%g",limits);
      }
      fputc((int)'\n',fd);
      fclose(fd);

      // check if we need to save to .sysgcoil
      if (tmpPtr==sysgcoil) done=1;
      else
      {  
         tmpPtr=sysgcoil;
         sprintf(fullpath,"%s.%s",decclibpath,tmpPtr);
      }
   }
   // Now all is saved,
   // deccflag[8]=biggest+1 (version)
   // set o_enabled=enabled, o_taus=taus, o_ampls=ampls
   //     o_limits=limits,   o_scales=scales
   // and deccflag[7]=1 (Unmodified).
   if (P_setreal(GLOBAL,"deccflag", (double)(biggest+1),8) < 0)
   {
      Werrprintf("decc_save: cannot set 'deccflag[8]'i to version");
   }

   for (i=1; i< 53; i++)
   {   
      if (P_getstring(GLOBAL,"enabled",enabled,i,MAXSTR) < 0)
      {
         Werrprintf("decc_save: cannot find 'enabled'");
         break;
      }
      if (P_getreal(GLOBAL,"taus",&taus,i) < 0)
      {
         Werrprintf("decc_save: cannot find 'taus'");
         break;
      }
      if (P_getreal(GLOBAL,"ampls",&ampls,i) < 0)
      {
         Werrprintf("decc_save: cannot find 'ampls'");
         break;
      }

      if (P_setstring(GLOBAL,"o_enabled", enabled, i) < 0)
      {
         Werrprintf("decc_save: cannot find 'o_enabled'");
         break;
      }
      if (P_setreal(GLOBAL,"o_taus", taus, i) < 0)
      {
         Werrprintf("decc_save: cannot find 'o_taus'");
         break;
      }
      if (P_setreal(GLOBAL,"o_ampls", ampls, i) < 0)
      {
         Werrprintf("decc_save: cannot find 'o_ampls'");
         break;
      }
   }

   for (i=1; i<11; i++)
   {
      if (P_getreal(GLOBAL,"scales",&scales,i) < 0)
      {
         Werrprintf("decc_save: cannot find 'scales'");
         break;
      }
      if (P_setreal(GLOBAL,"o_scales", scales, i) < 0)
      {
         Werrprintf("decc_save: cannot find 'o_scales'");
         break;
      }
   }

   for (i=1; i<8; i++)
   {
      if (P_getreal(GLOBAL,"limits",&limits,i) < 0)
      {
         Werrprintf("decc_save: cannot find 'limits'");
         break;
      }
      if (P_setreal(GLOBAL,"o_limits", limits, i) < 0)
      {
         Werrprintf("decc_save: cannot find 'o_limits'");
         break;
      }
   } 

   if (P_setreal(GLOBAL, "deccflag", 1.0, 7) < 0) // Unmodified
   {
      Werrprintf("decc_save: cannot set deccflag[7]");
   }
   if (debug) Winfoprintf("decc_save: saved fln='%s',version=%d\n",
				filename,biggest+1);

   sprintf(fullpath,"%s.%d",filename,biggest+1);
   if (P_setstring(GLOBAL,"deccorig_fln", fullpath, 1) < 0)
   {
      Werrprintf("decc_load: cannot set 'deccorig_fln'");
   }
   if (P_setstring(GLOBAL,"decctool_fln", fullpath, 1) < 0)
   {
      Werrprintf("decc_load: cannot set 'decctool_fln'");
   }

   appendvarlist("deccflag deccorig_fln decctool_fln");
   RETURN;
}
Exemplo n.º 30
0
// cursor1 is lower left, cursor2 is upper right
bool AspRoi::getRoiBox(spAspCell_t cell,double &px, double &py, double &pw, double &ph) {

    if(cell == nullAspCell) return false;

  double vx,vw,vy,vh;
  double pstx, psty, pwd, pht;
  double vstx, vsty, vwd, vht;
  cell->getPixCell(pstx, psty, pwd, pht);
  cell->getValCell(vstx, vsty, vwd, vht);

  // before asign vx,vw,vy,vh, make the following swapping if needed.
  Dpoint_t c1,c2;
  int rank = getRank();
  if(rank==2) {
    
    string xname = cell->getXname();
    string yname = cell->getYname();

    // swap resonances[0] and resonances[1] to match xname, yname if needed
    if(cursor1->resonances[0].name != xname) { // resonances[0] has to be yname
	if(cursor1->resonances[0].name == yname && cursor1->resonances[1].name == xname) { 
	     // swap resonances[0] resonances[1]
	   double tmp=cursor1->resonances[0].freq;
	   string tmpstr=cursor1->resonances[0].name;
	   cursor1->resonances[0].freq=cursor1->resonances[1].freq;
	   cursor1->resonances[0].name=cursor1->resonances[1].name; 
	   cursor1->resonances[1].freq=tmp;
	   cursor1->resonances[1].name=tmpstr;
	   cursor2->resonances[0].freq=cursor1->resonances[0].freq;
	   cursor2->resonances[0].name=cursor1->resonances[0].name; 
	   cursor2->resonances[1].freq=cursor1->resonances[1].freq;
	   cursor2->resonances[1].name=cursor1->resonances[1].name; 
	}
    } 

    if(cursor1->resonances[0].name != xname || cursor1->resonances[1].name != yname) {
/*
	Winfoprintf("Mismatched nucleus names: %s to %s %s to %s.",
		cursor1->resonances[0].name.c_str(), xname.c_str(),
		cursor1->resonances[1].name.c_str(), yname.c_str());
*/
	return false; 
    }

    // swap cursor1 cursor1 so cursor1 is lower left, and cursor2 is upper right
    c1.x = cell->val2pix(HORIZ, cursor1->resonances[0].freq);
    c1.y = cell->val2pix(VERT, cursor1->resonances[1].freq);
    c2.x = cell->val2pix(HORIZ, cursor2->resonances[0].freq);
    c2.y = cell->val2pix(VERT, cursor2->resonances[1].freq);
    if(c1.x>c2.x) {
        double tmp=cursor1->resonances[0].freq;
        cursor1->resonances[0].freq=cursor2->resonances[0].freq;
        cursor2->resonances[0].freq=tmp;
    }
    if(c2.y>c1.y) {
        double tmp=cursor1->resonances[1].freq;
        cursor1->resonances[1].freq=cursor2->resonances[1].freq;
        cursor2->resonances[1].freq=tmp;
    }
    vx=cursor1->resonances[0].freq;
    vw=cursor1->resonances[0].freq-cursor2->resonances[0].freq;
    vy=cursor2->resonances[1].freq;
    vh=cursor1->resonances[1].freq-cursor2->resonances[1].freq;
  } else if(rank == 1) {

    string xname = cell->getXname();
    if(cursor1->resonances[0].name != xname) {
/*
	Winfoprintf("Mismatched nucleus names: %s %s.",
		cursor1->resonances[0].name.c_str(),xname.c_str());
*/
	return false; 
    }

    c1.x = cell->val2pix(HORIZ, cursor1->resonances[0].freq);
    c2.x = cell->val2pix(HORIZ, cursor2->resonances[0].freq);
    if(c1.x>c2.x) {
        // swap cursor1 cursor1 so cursor1 is left, and cursor2 is right
        double tmp=cursor1->resonances[0].freq;
        cursor1->resonances[0].freq=cursor2->resonances[0].freq;
        cursor2->resonances[0].freq=tmp;
    }
    vx=cursor1->resonances[0].freq;
    vw=cursor1->resonances[0].freq-cursor2->resonances[0].freq;
    double percentH;
    if(height>0) percentH = (double)height/100.0;
    else {
	percentH = getReal("aspPref",3,70);
	if(percentH>0) percentH/=100.0;
	else percentH=0.7;
    }
    if(vht<0)
    vy=vsty-percentH*vht;
    else
    vy=vsty-(1.0-percentH)*vht;
    vh=percentH*vht;

  } else return false;

// note, vy is lower left, py is upper left 
  double vp;
  px = cell->val2pix(HORIZ, vx);
  py = cell->val2pix(VERT, vy);
  if(rank==1) {
     P_getreal(CURRENT,"vp",&vp,1);
     py -= cell->getCali(VERT)*vp;
  }
  pw = fabs(vw*pwd/vwd);
  ph = fabs(vh*pht/vht);
//Winfoprintf("roi vx,vy,vw,vh,px,py,pw,ph %f %f %f %f %f %f %f %f",vx,vy,vw,vh,px,py,pw,ph); 

  return true;

}