Ejemplo n.º 1
0
static void presetVal(varInfo *v, int type)
{
    v->active      = ACT_ON;
    v->subtype     = type;
    v->prot	   = preset[type].Prot;
    v->Dgroup      = preset[type].Dgroup;
    v->Ggroup      = preset[type].Ggroup;
    v->minVal      = preset[type].minVal;
    v->maxVal      = preset[type].maxVal;
    v->step        = preset[type].step;
    v->R           = NULL;
    v->E           = NULL;
    v->T.size      = 0;
    v->ET.size     = 0;
    v->T.basicType = preset[type].type;
    v->ET.basicType= v->T.basicType;
    if(v->T.basicType == T_REAL) /* set inital value to zero */
	assignReal(0.0,v,0);
    if(v->T.basicType == T_STRING) /* set inital value to null */
	assignString("",v,0);
}
Ejemplo n.º 2
0
int P_loadVar(int tree, char *name,  vInfo *v, int *fd) 	
{   char            buf[4097];
    double          dvalue;
    int             i; 
    int             length;
    int             nread;
    symbol        **root;
    varInfo        *newv;
    
/* If the variable was passed as a system global, store it
   in the global variable tree.					*/

/* if lockfreq is passed from the system global and global annouce the fact and
   abort  */
    if (tree==SYSTEMGLOBAL)	/* break if in two for speed,avoid strcmp if possible */
    {
      if (strcmp(name,"lockfreq") == 0) 
      {
         if (!havelockfreq)
	    havelockfreq=1;
         else
         {
	   text_error(
	    "lockfreq in both conpar and global, remove occurrence in global.\n");
           havelockfreq = -1;
         }
      }
    }
    if (tree==GLOBAL)	/* break if in two for speed,avoid strcmp if possible */
    {
      if (strcmp(name,"lockfreq") == 0) 
      {
         if (!havelockfreq)
	    havelockfreq=1;
         else
         {
	   text_error(
	    "lockfreq in both conpar and global, remove occurrence in global.\n");
           havelockfreq = -1;
         }
      }
    }
    if (tree==SYSTEMGLOBAL) tree = GLOBAL;
    if ( (root = getTreeRoot(getRoot(tree))) )
    {	if ( (newv=rfindVar(name,root)) ) /* if variable exists, get rid of it*/
	{   if (newv->T.basicType == T_STRING)  
	    {   disposeStringRvals(newv->R);
		disposeStringRvals(newv->E);
	    }
	    else
	    {   disposeRealRvals(newv->R);
		disposeRealRvals(newv->E);
	    }
	    newv->R = NULL;
	    newv->E = NULL;
	    newv->T.size = newv->ET.size = 0;
	    newv->T.basicType  = v->basicType;
	    newv->ET.basicType = v->basicType;
	}
	else
	    newv = RcreateVar(name,root,v->basicType); /* create the variable */
	newv->active = v->active;
	newv->subtype= v->subtype;
	newv->Dgroup = v->Dgroup;
	newv->Ggroup = v->group;
	newv->prot   = v->prot;
	newv->minVal = v->minVal;
	newv->maxVal = v->maxVal;
	newv->step   = v->step;
	if (v->basicType == T_STRING)
	{    for (i=0 ; i<v->size ; i++)
	    {	nread = read(fd[0],&length,sizeof(int)); 
		nread = read(fd[0],buf,length);
		buf[length] = '\0';
		if (bgflag > 2)
		    fprintf(stderr,"bg: STRING[%d] = \"%s\"\n",i,buf);
		assignString(buf,newv,i+1);
	    }
	    /* copy over enumerals */
/* ---------------------- deleted
	    for (i=0 ; i<v->Esize ; i++)
	    {	nread = read(fd[0],&length,sizeof(int)); 
		nread = read(fd[0],buf,length);
		buf[length] = NULL;
		if (bgflag > 2)
		    fprintf(stderr,"bg: Enum STRING[%d] = \"%s\"\n",i,buf);
		assignEString(buf,newv,i+1); 
	    }
+------------------------- */
	}
	else /* assume T_REAL */
	{   for (i=0 ; i<v->size ; i++)
	    {	nread = read(fd[0],&dvalue,sizeof(double));
		/* convert usec pulse values in to seconds */
                if (v->subtype == ST_PULSE) /* pulse in usec */ 
                { 
                     dvalue *= 1.0e-6; 	/* now in sec. */
                }
		if (bgflag > 2)
		    fprintf(stderr,"bg: REAL[%d] = \"%g\"\n",i,dvalue);
		assignReal(dvalue,newv,i+1);
	    }
	    /*  copy over enumeral values */
/* ---------------------- deleted
	    for (i=0 ; i<v->Esize ; i++)
	    {	nread = read(fd[0],&dvalue,sizeof(double));
		if (bgflag > 2)
		    fprintf(stderr,"bg: Enum REAL[%d] = \"%g\"\n",i,dvalue);
		assignEReal(dvalue,newv,i+1);  
	    }
+------------------------- */
	}
    }
    else
    {
	fprintf(stderr,"P_loadVar: fatal error, cannot find tree %d\n",tree);
        havelockfreq = -1;  /* make PSG abort */
    }
    return(0);
}
Ejemplo n.º 3
0
int assignPair(pair *p, varInfo *v, int i)
{   Rval *r;

    DPRINT3(3,"assignPair: pair 0x%08x to var 0x%08x[%d]...\n",p,v,i);
    DSHOWPAIR(3,"assignPair: ",p);
    DSHOWVAR(3,"assignPair: ",v);
    if (v)
    {	switch (p->T.basicType)
	{ case T_UNDEF:     return(0);
	  case T_REAL:	    r = p->R;
		            if (v->prot & P_ARR)
		            { if ((r = r->next) || (i > 1))
		              {
				 WerrprintfWithPos("cannot array parameter");
				 return(0);
		              }
			      r = p->R;
		            }
			    while (r)
			    {
			    	if (assignReal(r->v.r,v,i))
				{   r  = r->next;
				    if (i == 0)
					i++; /* bump index to 2 */
				    i += 1;
				}
				else
				{
				    return(0);
				}
			    }
			    DPRINT0(3,"assignPair: ...after\n");
			    DSHOWVAR(3,"assignPair: ",v);
			    return(1);
	  case T_STRING:    r = p->R;
		            if (v->prot & P_ARR)
		            { if ((r = r->next) || (i > 1))
		              {
				 WerrprintfWithPos("cannot array parameter");
				 return(0);
		              }
			      r = p->R;
			    }
			    while (r)
			    	if (assignString(r->v.s,v,i))
				{   r  = r->next;
				    if (i == 0)
					i++; /* bump index to 2 */
				    i += 1;
				}
				else
				    return(0);
			    DPRINT0(3,"assignPair: ...after\n");
			    DSHOWVAR(3,"assignPair: ",v);
			    return(1);
	  default:	    WerrprintfWithPos("unknown parameter assignment with basictype %d",p->T.basicType);
			    return(0);

	}
    }
    return(0);
}