Exemple #1
0
void GraphScene::reconnectInputs(const rcc::shared_ptr<aq::nodes::Node>& node, std::map<std::string, QtNodes::Node*>& nodemap){
    auto inputs = node->getInputs();
    auto input_node_itr = nodemap.find(node->getTreeName());
    if(input_node_itr != nodemap.end()){
        for (int i = 0; i < inputs.size(); ++i) {
            auto input_param = inputs[i]->getInputParam();
            if (input_param) {
                auto output_name = input_param->getTreeRoot();
                auto itr = nodemap.find(output_name);
                if (itr != nodemap.end()) {
                    int nout = itr->second->nodeDataModel()->nPorts(QtNodes::PortType::Out);
                    for(int j = 0; j < nout; ++j){
                        auto dtype = itr->second->nodeDataModel()->dataType(QtNodes::PortType::Out, j);
                        if(dtype.name.toStdString() == input_param->getName()){
                            createConnection(*input_node_itr->second, i + 1, *itr->second, j);
                            continue;
                        }
                    }
                }
            }
        }
    }
    auto children = node->getChildren();
    for(auto child : children){
        reconnectInputs(child, nodemap);
    }
}
Exemple #2
0
int
A_getreal(int tree, const char *name, double **valaddr, int index)
{
   symbol        **root;

   if ( (root = getTreeRoot(getRoot(tree))) )
   {
      varInfo        *v;

      if ( (v = rfindVar(name, root)) )	/* if variable exists */
      {
	 if (0 < index && index <= v->T.size)	/* within bounds ? */
	 {
	    int             i;
	    Rval           *r;

	    i = 1;
	    r = v->R;
	    while (r && i < index)	/* travel down Rvals  */
	    {
	       r = r->next;
	       i += 1;
	    }
	    if (r)
	    {
	       *valaddr = &r->v.r;	/* pass address back */
	       if (bgflag > 1)
	       {
		  fprintf(stderr,
		     "A_getstring: Address to put address of value: %p , ",
			  (void *) valaddr);
		  fprintf(stderr, "Address of value: %p \n",
			  (void *) *valaddr);
	       }
	       return (0);
	    }
	    else
	    {
	       return (-99);	/* unknown error */
	    }
	 }
	 else
	    return (-9);	/* index out of bounds */
      }
      else
	 return (-2);		/* variable doesn't exist */
   }
   else
      return (-1);		/* tree doesn't exist */
}
Exemple #3
0
int A_getnames(int tree, char **nameptr, int *numvar, int maxptr)
{
   int             i;
   symbol        **root;

   i = 0;
   *numvar = 0;
   if ( (root = getTreeRoot(getRoot(tree))) )
   {
      getNames(*root, nameptr, numvar, maxptr, &i);
   }
   else
      return (-1);		/* tree doesn't exist */
   return (OK);
}
Exemple #4
0
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 */
Exemple #5
0
void OctTree::checkAndUpdateObjectLocation(OctTree::ObjType * obj) {
    if (obj != NULL && obj->positionChanged()) {
        handleObjectPlacement(obj);
        
        /// Sanity Check
        OctTree * root = getTreeRoot(), * expNode;
        OctTree * node = root->whereIs(obj, false);
        
        if (node == NULL) {
            node = root->whereIs(obj, true);
            UTIL_ASSERT(node != NULL);
            //UTIL_LOG("Root: " + *root);
            //UTIL_LOG(*obj + " is at node " + node->getCompleteAddress() + " "
             //+ *node);
            UTIL_ASSERT(root->getChild(node->getCompleteAddress()) == node);
            
            for (int i = 0; i < kNumNodes; i++) {
                if (root->getChild(i) != NULL) {
                    //UTIL_LOG("Child [" + i + "]: " + *root->getChild(i));
                    //UTIL_LOG("Should have bounding box: "
                    // + root->boundingBoxForChild(i).description());
                    //UTIL_LOG(std::string("Expects parent bounding box: ")
                    // + root->getChild(i)->boundingBoxForParent(root->getChild(i)->getAddress()).description());
                }
                //else
                    //UTIL_LOG("Child [" + i + "]: NULL");
            }
            
            
            
            std::vector<int> expAddress = root->getExpectedObjAddress(obj);
            //UTIL_LOG("Instead, expected address " + expAddress);
            expNode = root->getChild(expAddress);
            if (expNode != NULL)
                //UTIL_LOG("Node: " + *expNode);
            
            UTIL_ASSERT(false);
        }
    }
}
Exemple #6
0
std::vector<int> OctTree::getExpectedObjAddress(OctTree::ObjType * obj) {
    std::vector<int> addresses;
    OctTree * root = getTreeRoot(), * node, * oldNode = NULL ;
    int whichChild;
    
    node = root;
    while (node->boundingBox.numCornersContained(obj) == kNumNodes
     && node != oldNode) {
        if (node != root)
            addresses.push_back(node->address);
        whichChild = -1;
        oldNode = node;
        while (++whichChild < kNumNodes && oldNode == node) {
            OctTree * child = node->getChild(whichChild);
            if (child != NULL
             && child->boundingBox.numCornersContained(obj) == kNumNodes)
                node = child;
        }
    }
    
    return addresses;
}
Exemple #7
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);
}