varInfo *createVar(char *n) { symbol **pp; DPRINT1(3,"createVar: creating \"%s\"...\n",n); if ( (pp=selectVarTree(n)) ) return(RcreateVar(n,pp,ST_UNDEF)); else { DPRINT0(3,"createVar: could not select tree \n"); return(NULL); } }
static int flash_interlock() /* Purpose: ------- Routine flash_interlock is used to insure that the "flashc" command is called only once for a given experiment. In particular, this routine checks for the existence of a parameter called flash_converted. If this parameter exists, an error condition is returned. If this parameter does not exist, it is created. To complete this interlock on flashc, the flash_converted parameter should be deleted (if it exists) whenever an acquisition takes place. Arguments: (none) --------- flash_interlock : ( O) Returns 0 for success, 1 to indicate an error. */ { /* Begin function flash_interlock */ /* Local Variables: --------------- root : The root node of the "processed" variable tree. */ symbol **root; /* Begin Executable Code: --------------------- */ /* Obtain the root of the processed tree */ if ( ( root = getTreeRoot ( "processed" ) ) == NULL ) { Werrprintf ( "flashc: getTreeRoot: programming error" ); ABORT; } /* Try to create the interlock variable. This call serves */ /* to indicate whether or not it existed already. */ if ( RcreateVar ( "flash_converted", root, T_REAL ) == NULL ) { /* The interlock already existed, this is an error */ ABORT; } /* Normal successful return */ RETURN; } /* End function flash_interlock */
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); }