void CMetab::initObjects() { // We need to have mpIValueRefernce point to a CParticleReference object. pdelete(mpIValueReference); mpIValueReference = new CParticleReference("InitialParticleNumber", this, mIValue); // We need to have mpValueRefernce point to a CParticleReference object. pdelete(mpValueReference); mpValueReference = new CParticleReference("ParticleNumber", this, mValue); mpRateReference->setObjectName("ParticleNumberRate"); mpIConcReference = new CConcentrationReference("InitialConcentration", this, mIConc); mpConcReference = new CConcentrationReference("Concentration", this, mConc); mpConcRateReference = static_cast<CCopasiObjectReference<C_FLOAT64> *>(addObjectReference("Rate", mConcRate, CCopasiObject::ValueDbl)); mpIntensiveNoiseReference = static_cast<CCopasiObjectReference<C_FLOAT64> *>(addObjectReference("IntensiveNoise", mIntensiveNoise, CCopasiObject::ValueDbl)); mpTTReference = static_cast<CCopasiObjectReference<C_FLOAT64> *>(addObjectReference("TransitionTime", mTT, CCopasiObject::ValueDbl)); }
void CCrossSectionTask::initObjects() { addObjectReference("Period", mPeriod, CCopasiObject::ValueDbl); addObjectReference("Average Period", mAveragePeriod, CCopasiObject::ValueDbl); addObjectReference("Last Period", mLastPeriod, CCopasiObject::ValueDbl); addObjectReference("Periodicity", mPeriodicity, CCopasiObject::ValueInt); addObjectReference("Last Frequency", mLastFreq, CCopasiObject::ValueDbl); addObjectReference("Frequency", mFreq, CCopasiObject::ValueDbl); addObjectReference("Average Frequency", mAverageFreq, CCopasiObject::ValueDbl); }
void CILDMMethod::initializeParameter() { addObjectReference("Number of slow variables", mSlow, CCopasiObject::ValueInt); addMatrixReference("Contribution of Species to Slow Space", mVslow, CCopasiObject::ValueDbl); initializeIntegrationsParameter(); assertParameter("Deuflhard Tolerance", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-6); createAnnotationsM(); emptyVectors(); }
void CMoiety::initObjects() { mpINumberReference = new CTotalNumberReference("InitialValue", this, mINumber); mpNumberReference = new CTotalNumberReference("Value", this, mNumber); mpDNumberReference = new CDependentNumberReference("DependentValue", this, mNumber); mpDNumberReference->addDirectDependency(this); CCopasiObject * pObject = addObjectReference("Amount", mIAmount, CCopasiObject::ValueDbl); pObject->addDirectDependency(mpNumberReference); return; }
void CCopasiTask::initObjects() { addObjectReference("Output counter", mOutputCounter, CCopasiObject::ValueInt); new CCopasiTimer(CCopasiTimer::WALL, this); new CCopasiTimer(CCopasiTimer::PROCESS, this); CCopasiDataModel *pDataModel = getObjectDataModel(); if (pDataModel != NULL) { if (pDataModel->getModel() != NULL) { setMathContainer(&pDataModel->getModel()->getMathContainer()); } } }
/** Begin Code emulation ********************************************************************/ void startFunction(FILE * logf, struct SCRIPT * script, struct TYPING * types, int funcindex, struct LINE * line){ char * tokens = (char *) calloc(TOKENMAXNB*TOKENSIZE,sizeof(char)); int parameters[10]; char arguments[10][TOKENSIZE]; int i, j, retobj, nbtokens, nbarg, nextparam, pos = 0; //Jump to function printf("[+] Jump inside function %s\n", script->functionslist[funcindex].name); //Merge parameters with local aliases from the signature nbarg = script->functionslist[funcindex].nbarg; nbtokens = decomposeLine(line->line,(char*)tokens,TOKENMAXNB,TOKENSIZE); for(i=0;i<nbtokens;i++){ if(!strcasecmp(ACCESS(tokens,i),script->functionslist[funcindex].name)) break; } nextparam = i+1; for(j=1;j<=nbarg;j++){ processExpression(logf,script,types,FUNCLEVEL|funcindex, line,nextparam,0,arguments[j-1],&nextparam); parameters[j-1] = updateTypesBeforeLocCall(types, arguments[j-1], script->functionslist[funcindex].arguments[j-1]); } //Following the execution path while(pos<script->functionslist[funcindex].nblines){ //Analyze code pos = processLines(logf,script,types,FUNCLEVEL|funcindex,pos); }//while //Return from function printf("[+] Return from function %s\n",script->functionslist[funcindex].name); //Unmerge parameters with local aliases from the signature for(j=1;j<=nbarg;j++){ removeObjectReference(types, parameters[j-1], script->functionslist[funcindex].arguments[j-1]); } retobj = isKnownObject(types,script->functionslist[funcindex].name); if(retobj>-1){ removeObjectReference(types,retobj,script->functionslist[funcindex].name); //If the return value is affected if(i>1 && ((char*)ACCESS(tokens,i-1))[0]== '='){ addObjectReference(types,retobj,ACCESS(tokens,i-2)); }//if affectation } free(tokens); }
void CLyapTask::initObjects() { unsigned C_INT32 i; mExponents.resize(LYAP_NUM_REF); for (i = 0; i < LYAP_NUM_REF; ++i) mExponents[i] = 0.0; mvExpRef.resize(LYAP_NUM_REF); mLocalExponents.resize(LYAP_NUM_REF); for (i = 0; i < LYAP_NUM_REF; ++i) mLocalExponents[i] = 0.0; mvLocExpRef.resize(LYAP_NUM_REF); addVectorReference("Exponents", mExponents, CCopasiObject::ValueDbl); addVectorReference("Local exponents", mLocalExponents, CCopasiObject::ValueDbl); for (i = 0; i < LYAP_NUM_REF; ++i) { std::ostringstream sss; sss << "Exponent " << i + 1; mvExpRef[i] = dynamic_cast<CCopasiObjectReference<C_FLOAT64> *> (addObjectReference(sss.str(), mExponents.array()[i], CCopasiObject::ValueDbl)); assert(mvExpRef[i]); std::ostringstream sss2; sss2 << "Local exponent " << i + 1; mvLocExpRef[i] = dynamic_cast<CCopasiObjectReference<C_FLOAT64> *> (addObjectReference(sss2.str(), mLocalExponents.array()[i], CCopasiObject::ValueDbl)); assert(mvLocExpRef[i]); } addObjectReference("Sum of exponents", mSumOfExponents, CCopasiObject::ValueDbl); addObjectReference("Sum of local exponents", mSumOfLocalExponents, CCopasiObject::ValueDbl); //addObjectReference("Local divergence", mDivergence, CCopasiObject::ValueDbl); addObjectReference("Interval divergence", mIntervalDivergence, CCopasiObject::ValueDbl); addObjectReference("Average divergence", mAverageDivergence, CCopasiObject::ValueDbl); }
void COptPopulationMethod::initObjects() { if (getSubType() != CTaskEnum::Method::ParticleSwarm && getSubType() != CTaskEnum::Method::ScatterSearch) addObjectReference("Current Generation", mCurrentGeneration, CDataObject::ValueInt); }
void CEFMAlgorithm::initObjects() { addObjectReference("Current Step", mStep, CCopasiObject::ValueInt); }
void COptMethodNelderMead::initObjects() { addObjectReference("Current Iteration", mIteration, CCopasiObject::ValueInt); }
void CFunctionDB::initObjects() { addObjectReference("File", mFilename); }
int monitorFileControl(FILE * logf, struct SCRIPT * script, struct TYPING * types, unsigned long location, struct LINE * line){ char tokens[TOKENMAXNB][TOKENSIZE]; char exp[TOKENSIZE]; int next = 1; static char driveobj[TOKENSIZE]; static int drives = 0; static int driveset; int i, obj1, nbtokens, unknown = -1; struct LINE combined; static int combinnb = 45; char combinid[TOKENSIZE]; char * combinline; struct MANAG_ENTRY * localmanagers = accessManagers(script,location); nbtokens = decomposeLine(line->line,(char*)tokens,TOKENMAXNB,TOKENSIZE); for(i=0;i<nbtokens;i++){ unknown = isUnknownManager(&script->managers,tokens[i]); //File system manager if((isFileManager(&script->managers,tokens[i])>-1) || (isFileManager(localmanagers,tokens[i])>-1) || (unknown>-1)){ //Open command if(!strcasecmp(tokens[i+1],OPENF1)//file || !strcasecmp(tokens[i+1],OPENF2) || !strcasecmp(tokens[i+1],OPENF3)){ line->type = SYSCALL; processExpression(logf,script,types,location, line,i+2,OBJ_FILE,exp,&next); obj1 = updateTypesAfterSysCall(types,exp, NULL,OBJ_FILE,OBJ_EXIST); printLogEntry(logf, types, OP_OPEN, obj1, 0); //Checks combined call combinline = strstr(line->line,tokens[next]); if((nbtokens-2>=next)&&combinline){ char * found; combinline--; found = strchr(combinline,'.'); if(!found){ if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; } sprintf_s(combinid,TOKENSIZE,"INT%08X",combinnb); combinnb++; addObjectReference(types,obj1,combinid); if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))){ sprintf_s(combined.line,LINE_LENGTH,"%s = %s.%s", tokens[i-2],combinid,found); }else{ sprintf_s(combined.line,LINE_LENGTH,"%s.%s",combinid,found); } if(!monitorFileIO(logf,script,types,location,&combined)){ removeObjectReference(types,obj1,combinid); if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); } }else{ if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); } if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; //File existence command }else if(!strcasecmp(tokens[i+1],OPENFT)){ line->type = SYSCALL; processExpression(logf,script,types,location, line,i+2,OBJ_FILE,exp,NULL); obj1 = updateTypesAfterSysCall(types,exp, NULL,OBJ_FILE,OBJ_CREATED); printLogEntry(logf, types, OP_OPEN, obj1, 0); if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; //Drive commands }else if(!strcasecmp(tokens[i+1],OPEND1)){ line->type = SYSCALL; obj1 = updateTypesAfterSysCall(types,COM_DRIVE, tokens[i-2],OBJ_DRIVE,OBJ_EXIST); sprintf_s(types->objects[obj1].ObjectName, NAME_MAX_LENGTH, "Drive(ref:%s)",tokens[i-2]); printLogEntry(logf, types, OP_OPEN, obj1, 0); if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; }else if(!strcasecmp(tokens[i+1],OPEND2)){ if((i+2<nbtokens&&!strcasecmp(tokens[i+2],"Item")) ||(i-2>=0&&!strcasecmp(tokens[i-1],"In"))){ line->type = SYSCALL; obj1 = updateTypesAfterSysCall(types,COM_DRIVE, tokens[i-2],OBJ_DRIVE,OBJ_EXIST); sprintf_s(types->objects[obj1].ObjectName, NAME_MAX_LENGTH, "Drive(ref:%s)",tokens[i-2]); printLogEntry(logf, types, OP_OPEN, obj1, 0); }else if(i-2>=0&&tokens[i-1][0]=='='){ drives = 1; strcpy_s(driveobj,TOKENSIZE,tokens[i-2]); line->type = SYSCALL; }else{ line->type = SYSCALL; } if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; }//if open //Creation command if(!strcasecmp(tokens[i+1],CREATEF2) || !strcasecmp(tokens[i+1],CREATEF3)){ line->type = SYSCALL; processExpression(logf,script,types,location, line,i+2,OBJ_FILE,exp,&next); obj1 = updateTypesAfterSysCall(types,exp, NULL,OBJ_FILE,OBJ_CREATED); printLogEntry(logf, types, OP_CREA, obj1, 0); //Checks combined call combinline = strstr(line->line,tokens[next]); if((nbtokens-2>=next)&&combinline){ char * found = strchr(combinline,'.'); if(!found){ if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; } sprintf_s(combinid,TOKENSIZE,"INT%08X",combinnb); combinnb++; addObjectReference(types,obj1,combinid); if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))){ sprintf_s(combined.line,LINE_LENGTH,"%s = %s.%s",tokens[i-2],combinid,found); }else{ sprintf_s(combined.line,LINE_LENGTH,"%s.%s",combinid,found); } if(!monitorFileIO(logf,script,types,location,&combined)){ removeObjectReference(types,obj1,combinid); if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); } }else{ if(i>=2&&(tokens[i-1][0]=='='||!strcasecmp(tokens[i-1],"in"))) addObjectReference(types,obj1,tokens[i-2]); } if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; }//if creation //Delete command if(!strcasecmp(tokens[i+1],DELETEF1) || !strcasecmp(tokens[i+1],DELETEF2)){ line->type = SYSCALL; processExpression(logf,script,types,location, line,i+2,OBJ_FILE,exp,NULL); obj1 = updateTypesAfterSysCall(types,exp, tokens[i-2],OBJ_FILE,OBJ_EXIST); printLogEntry(logf, types, OP_DEL, obj1, 0); if(unknown>1) //learn manager class addManagerObject(&script->managers,TFSO,tokens[i]); return 1; }//if delete }//if file system manager //Drive set object if(drives && !strcasecmp(driveobj,tokens[i])){ if((i+1<nbtokens && (!strcasecmp(tokens[i+1],"Item")|| !strcasecmp(tokens[i+1],"Files")))|| !strcasecmp(tokens[i-1],"in")){ line->type = SYSCALL; obj1 = updateTypesAfterSysCall(types,COM_DRIVE, tokens[i-2],OBJ_DRIVE,OBJ_EXIST); sprintf_s(types->objects[obj1].ObjectName, NAME_MAX_LENGTH, "Drive(ref:%s)",tokens[i-2]); printLogEntry(logf, types, OP_OPEN, obj1, 0); return 1; } }//if drive set //Document object if((nbtokens-i>2) && !strcasecmp(tokens[i],"Document")){ if(!strcasecmp(tokens[i+1],"Body")&&!strcasecmp(tokens[i+2],OPENDOC)){ line->type = SYSCALL; obj1 = updateTypesAfterSysCall(types,HTM_DOC, NULL,OBJ_FILE,OBJ_EXIST); if(i>=2) addObjectReference(types,obj1,tokens[i-2]); setObjectStatus(types,obj1,OBJ_EXIST); printLogEntry(logf, types, OP_OPEN, obj1, 0); return 1; } } //Shell manager if((isShellManager(&script->managers,tokens[i])>-1) || (isShellManager(localmanagers,tokens[i])>-1)){ //Open command if(!strcasecmp(tokens[i+1],OPENRUN)){ line->type = SYSCALL; processExpression(logf,script,types,location, line,i+2,OBJ_FILE,exp,&next); obj1 = updateTypesAfterSysCall(types,exp, NULL,OBJ_FILE,OBJ_EXIST); printLogEntry(logf, types, OP_OPEN, obj1, 0); if(unknown>1) //learn manager class addManagerObject(&script->managers,TSHELL,tokens[i]); return 1; } } }//for return 0; }
void processLine(FILE * logf, struct SCRIPT * script, struct TYPING * types, unsigned long location, struct LINE * line){ char * tokens = (char *) calloc(TOKENMAXNB*TOKENSIZE,sizeof(char)); int nbtokens, i, j, index, storobj=-1, valobj=-1; int calldetected; //Detect system calls calldetected = monitorSytemCalls(logf,script,types,location,line); //Parse line nbtokens = decomposeLine(line->line,tokens,TOKENMAXNB,TOKENSIZE); for(i=0;i<nbtokens;i++){ //Monitor string and processing and treat dependency if(!strcasecmp(ACCESS(tokens,i),"Mid") ||!strcasecmp(ACCESS(tokens,i),"Left") ||!strcasecmp(ACCESS(tokens,i),"Ucase") ||!strcasecmp(ACCESS(tokens,i),"Lcase") ||!strcasecmp(ACCESS(tokens,i),"LTrim") ||!strcasecmp(ACCESS(tokens,i),"RTrim") ||!strcasecmp(ACCESS(tokens,i),"Replace")){ int newstor = 0; int obj = isKnownObject(types,ACCESS(tokens,i+1)); if(obj>-1 && i>=2 && ((char *)ACCESS(tokens,i-1))[0]=='='){ int storobj = isKnownObject(types,ACCESS(tokens,i-2)); if(storobj==-1){ newstor = 1, storobj = addNewObject(types,NULL,getObjectNature(types,obj)); addObjectReference(types,storobj,ACCESS(tokens,i-2)); setObjectType(types,storobj,getObjectType(types,obj)); }else{ setObjectNature(types,storobj,getObjectNature(types,obj)); setObjectType(types,storobj,getObjectType(types,obj)); } if(newstor){strcpy_s(types->objects[storobj].ObjectName, NAME_MAX_LENGTH,types->objects[obj].ObjectName);} printLogEntry(logf, types, OP_AFF, storobj, obj); } } //Detect string proceclocal procedure and function calls index = isLocalProcedure(script,ACCESS(tokens,i)); if(index>-1){ //Avoid recursive calls //if((location&0xF0000000)==PROCLEVEL // && index==(location&0x0FFFFFFF)){ if(script->procedureslist[index].beingexecuted){ printf("[+] Block recursive call to procedure %s\n", script->procedureslist[index].name); }else{ script->procedureslist[index].beingexecuted = 1; //No return value, so can not be an affectation startProcedure(logf,script,types,index,line); script->procedureslist[index].beingexecuted = 0; } free(tokens); return; }else{ index = isLocalFunction(script,ACCESS(tokens,i)); if(index>-1){ if(strcmp(ACCESS(tokens,i+1),"=")){//Avoid return values //Avoid recursive calls if(script->functionslist[index].beingexecuted){ printf("[+] Block recursive call to function %s\n", script->functionslist[index].name); }else{ script->functionslist[index].beingexecuted = 1; startFunction(logf,script,types,index,line); script->functionslist[index].beingexecuted = 0; } free(tokens); return; }else{ line->type = AFFECTATION; updateReturnStorage(types, script->functionslist[index].name, ACCESS(tokens,i+2)); free(tokens); return; }//if call or return } } } if(calldetected) return; //Detect affectation of known object for(i=0;i<nbtokens;i++){ if(((char *)ACCESS(tokens,i))[0]=='='||!strcasecmp(ACCESS(tokens,i),"in")){ int maxobj = -1; int maxtype; int nullnat = 0; int newstor = 0; int nbconselem; //Number of consecutive elements must int isarray = 0;//be < 2 except using & and array to concatenate //Either creation or retrieving of store object storobj = isKnownObject(types,ACCESS(tokens,i-1)); if(storobj==-1){ newstor = 1; storobj = addNewObject(types,NULL,0); addObjectReference(types,storobj,ACCESS(tokens,i-1)); }//if unknown maxtype = getObjectType(types,storobj); nbconselem = 0; //Look for significant passing value for(j=i+1;j<nbtokens;j++){ if(!strcasecmp(ACCESS(tokens,j),"Array")){ isarray = 1; j++; }//if if(((char *)ACCESS(tokens,j))[0]=='&'){ nbconselem = 0; }else{ //Checks if access to a static attribute char stataccess[TOKENSIZE+5]; strcpy_s(stataccess,5+TOKENSIZE,ACCESS(tokens,j)); strcat_s(stataccess,5+TOKENSIZE,"."); if(strcasestr(line->line,stataccess)){ nbconselem = 0; }else{ nbconselem++; } }//if if(!isarray && nbconselem>1) break; valobj = isKnownObject(types,ACCESS(tokens,j)); if(valobj>-1){//known objects //Update store type when significant if(getObjectType(types,valobj)>maxtype){ maxtype = getObjectType(types,valobj); maxobj = valobj; } }else if(ClassifyObject(ACCESS(tokens,j),&nullnat)>maxtype){//typed object maxobj = addNewObject(types,ACCESS(tokens,j),nullnat); maxtype = getObjectType(types,maxobj); }//if }//for if(maxobj>-1){ line->type = AFFECTATION; setObjectType(types,storobj,getObjectType(types,maxobj)); setObjectNature(types,storobj,getObjectNature(types,maxobj)); if(newstor){strcpy_s(types->objects[storobj].ObjectName, NAME_MAX_LENGTH,types->objects[maxobj].ObjectName);} printLogEntry(logf, types, OP_AFF, storobj, maxobj); } }//if '=' found }//for free(tokens); }
void COptMethodSteepestDescent::initObjects() { addObjectReference("Current Iteration", mCurrentIteration, CCopasiObject::ValueInt); }
void CBitPatternTreeMethod::initObjects() { addObjectReference("Current Step", mProgressCounter, CCopasiObject::ValueInt); }
void COptMethodPraxis::initObjects() { addObjectReference("Current Iteration", mIteration, CDataObject::ValueInt); }
void CCopasiTask::initObjects() { addObjectReference("Output counter", mOutputCounter, CCopasiObject::ValueInt); new CCopasiTimer(CCopasiTimer::WALL, this); new CCopasiTimer(CCopasiTimer::PROCESS, this); }
void COptMethodEP::initObjects() { addObjectReference("Current Generation", mGeneration, CCopasiObject::ValueInt); }
void CChemEqElement::initObjects() { addObjectReference("Multiplicity", mMultiplicity, CCopasiObject::ValueDbl); addObjectReference("Metab Key", mMetaboliteKey); }