void UFuncPar::createResources() { UVarPool * pa; varInitialized = addVar("initialized", 0.0, "b", "(r) is block initialized OK"); varImuSource = addVar("imuSource", "imu.rot", "s", "(r) source variable for calculation (typically imu.rot or ifVar.imu.rot)"); pa = addStruct("state", "Detection state"); if (pa != NULL) { vars.scFlag = pa->addVarA("scFlag", "0 0", "b", "(r) Spectral correlation alarm detected and count"); vars.scFlag->makeTimeSeries(10000, 1.0); vars.wg2Flag = pa->addVarA("w2gFlag", "0 0", "b", "(r) Double Weibull GLRT alarm detection and count"); vars.wg2Flag->makeTimeSeries(10000, 1.0); vars.scIndex = pa->addVar("scIndex", 0.4, "d", "(r) Spectral correlation detection value"); vars.scIndex->makeTimeSeries(10000, 1.0); vars.wg2Index = pa->addVar("w2gIndex", 0.4, "d", "(r) Double Weibull GLRT detection value"); vars.wg2Index->makeTimeSeries(10000, 1.0); vars.alertFlag = pa->addVarA("alertFlag", "0 0", "d", "(r) combined alert index flag and count"); vars.alertFlag->makeTimeSeries(10000, 1.0); vars.alertIndex = pa->addVar("alertIndex", 0.4, "d", "(r) combined alert index"); vars.alertIndex->makeTimeSeries(10000, 1.0); vars.roll6h = pa->addVar("roll6h", 0.0, "d", "(r) max roll value the last 6 hours"); vars.pitch6h = pa->addVar("pitch6h", 0.0, "d", "(r) max pitch value the last '6 hour'"); vars.alarmCnt6h = pa->addVar("alartCnt6h", 0.0, "d", "(r) number of alarms last '6 hour'"); vars.roll1min = pa->addVar("roll1min", 0.0, "d", "(r) max roll value the last minute"); vars.roll1min->makeTimeSeries(3600, 1.0); vars.pitch1min = pa->addVar("pitch1min", 0.0, "d", "(r) max pitch value the last minute"); vars.pitch1min->makeTimeSeries(3600, 1.0); vars.alarmCnt1min = pa->addVar("alartCnt1min", 0.0, "d", "(r) number of alarms last minute"); vars.alarmCnt1min->makeTimeSeries(3600, 1.0); vars.cnt = pa->addVar("cnt", 0.0, "d", "(r) Update count"); vars.time = pa->addVar("time", 0.0, "t", "(r) Time of last update"); vars.timeLong = pa->addVar("time", 0.0, "t", "(r) Time of last update of long term variables"); vars.calcTime = pa->addVar("calcTime", 0.0, "t", "(r) time to make last roll calculation (in ms)"); vars.w2gShape = pa->addVar("w2gShape", 0.75, "d", "(r) Weibull shape parameter in last estimate"); vars.w2gScale = pa->addVar("w2gScale", 1.00, "d", "(r) Weibull scale value in last estimate"); } pa = addStruct("param", "Detection parameters"); if (pa != NULL) { varp.rollT = pa->addVar("rollT", 22.5, "d", "(rw) roll period time (sec)"); varp.rollW = pa->addVar("rollW", 0.279, "d", "(rw) roll natural frequency rad/sec"); //varp.updFrq = pa->addVar("updFrq", 5.0, "d", "(rw) update frequency in Hz"); varp.filterOrder = pa->addVar("filterOrder", 5.0, "d", "(r) filter order"); varp.fileterBW = pa->addVar("fileterBW", 1.2, "d", "(r) filter bandwidth - factor"); varp.filterType = pa->addVar("filterType", 1.0, "d", "(r) filter type 1=butterworth"); varp.scRollPeriods = pa->addVar("scRollPeriods", 3.0, "d", "(rw) number of used roll periods - Spectral analysis"); varp.wg2RollPeriods = pa->addVar("w2gRollPeriods", 3.0, "d", "(rw) number of used roll periods - Weibull method"); varp.initRollPeriods = pa->addVar("initRollPeriods", 30.0, "d", "(rw) initial estimate after this number of periods"); varp.scThreshold = pa->addVar("scThreshold", 0.5, "d", "(rw) spectral corr alarm threshold [0..1]"); varp.wg2Threshold = pa->addVar("w2gThreshold", 0.5, "d", "(rw) Weibull alarm threshold [0..1]"); varp.alarmWindLen = pa->addVar("alertWindLen", 2.0, "d", "(rw) size of detection window in roll periods"); varp.alarmWindOverlap = pa->addVar("alertWindOverlap", 0.0, "d", "(rw) is ???"); varp.rollMinVar = pa->addVar("rollMinVar", 0.1, "d", "(rw) minimum variance for roll (rad^2)"); varp.pitchMinVar = pa->addVar("pitchMinVar", 0.1, "d", "(rw) minimum variance for pitch (rad^2)"); varp.horizon6h = pa->addVar("horizon6h", 360.0, "d", "(rw) number of minutes in '6 hour' period"); varp.shapeUpdTime = pa->addVar("shapeUpdTime", 1.0, "d", "(rw) time between updates of long term variables (e.g. shape0)"); varp.filteredBufferTime = pa->addVar("filteredBufferTime", 300, "d", "(rw) length of buffer (in seconds) for band-pass filtered values."); } }
void AddDevice::getDialog(QJsonObject& newDialog) { clearDialog(); addVar(createConfigStringVar("name", "Device name", m_deviceName)); addVar(createConfigSelectionFromListVar("type", "Device type", g_deviceDatabase->displayType(m_deviceType), g_deviceDatabase->listDeviceTypes())); return dialog(newDialog); }
/* * Make the variables that will be available to other plugins */ void UImagePool::createBaseVar() { setDescription("Image pool information"); varImgCnt = addVarA("imgCnt", "0.0 0.0", "d", "(r) number if images in imagepool (of maksimum)"); varImgCnt->setInt(MAX_IMAGES_IN_POOL, 1, false); varImgList = addVar("imgList", 0.0, "d", "(r) list of constructed images"); varShowDefault = addVar("show", 0.0, "d", "(rw) should images be shown as default"); }
void KafkaConfigure::getDialog(QJsonObject& newDialog) { clearDialog(); addVar(createConfigStringVar("brokerList", "Kafka broker list", m_brokerList)); addVar(createConfigStringVar("videoPath", "Path to video data", m_videoPath)); addVar(createGraphicsLineVar()); addVar(createGraphicsStringVar("Restart app to implement changes")); return dialog(newDialog); }
void handle_coreblas_taskw (struct fxt_ev_64 *ev) { FUNC_NAME; assert( GET_NBPARAMS(ev) == 2 ); INIT_PROCESS_ID(process_id); INIT_SPECIFIC_THREAD_ID(thread_id, CUR_ID, (unsigned int)GET_PARAM(ev, 1)); int value = (int)GET_PARAM(ev, 2); CHANGE() addVar (CURRENT, COREBLAS_TASKR_ALIAS, process_id, (varPrec)value); CHANGE() addVar (CURRENT, COREBLAS_TASKWR_ALIAS, thread_id, (varPrec)value); free(thread_id); free(process_id); }
// 声明 void CodeGenerator::Decla() { while(isNext("type")) { string Type = getToken().value; string var = ""; while(!isNext(";")) { var = getToken().value; addVar(var, Type); if(isNext(";")) break; match(","); } if(var != "") addVar(var, Type); match(";"); } }
int16 GameVars::addSubVar(int16 varIndex, uint32 subNameHash, uint32 value) { int16 nextIndex = _vars[varIndex].firstIndex; int16 subVarIndex; if (nextIndex == -1) { subVarIndex = addVar(subNameHash, value); _vars[varIndex].firstIndex = subVarIndex; } else { while (_vars[nextIndex].nextIndex != -1) nextIndex = _vars[nextIndex].nextIndex; subVarIndex = addVar(subNameHash, value); _vars[nextIndex].nextIndex = subVarIndex; } return subVarIndex; }
bool CodeText::addVar(const std::string& varString) { std::vector<std::string> vec = CStringManager::split(varString, " "); if (vec.size() < 3) { return false; } std::string note = vec[0]; std::string type = vec[1]; bool ptr = false; if (CStringManager::Replace(type, "*", "") != 0) { ptr = true; } std::string name = vec[2]; std::string structText; int32_t index = 2; while (index++ != vec.size() - 1) { structText += (vec[index] + " "); } if (!structText.empty()) { structText.pop_back(); } addVar(note, type, name, ptr); addInitList(name, ptr ? "nullptr" : structText); if (ptr) { addStruct(type, name, structText); addCheck(name); } return ptr; }
void handle_coreblas_task (struct fxt_ev_64 *ev) { FUNC_NAME; INIT_PROCESS_ID(process_id); assert( GET_NBPARAMS(ev) == 1 ); int value = (int)GET_PARAM(ev, 1); CHANGE() addVar (CURRENT, COREBLAS_TASK_ALIAS, process_id, (varPrec)value); free(process_id); }
void check(char ch){ if(isalpha(ch) || isdigit(ch)){ push(ch); append(); addVar(ch); }else{ popThenAdd(ch); } }
extern "C" value C_add_var (value solver_In, value var_id_In) { CAMLparam2 (solver_In, var_id_In); solver_c s = (solver_c) Field(solver_In, 0); int var_id = Int_val(var_id_In); addVar (s,var_id); CAMLreturn(Val_unit); }
void UCamPool::createBaseVar() { varUseGuppy = addVar("useGuppy", 0.0, "d", "Is Guppy firewire camera support enabled (DC1394 ver 2 compiled in)"); varUseIeeeOld = addVar("useIeeeOld", 0.0, "d", "Is firewire using old libs (DC1394 ver 1 compiled in)"); varUseGigE = addVar("useGigE", 0.0, "d", "Is GigE support enabled (compiled in)"); #ifdef USE_GUPPY varUseGuppy->setBool(true, 0); #endif #ifdef USE_IEEE1394 varUseIeeeOld->setBool(true, 0); #endif #ifdef USE_GIGE varUseGigE->setBool(true, 0); #endif // this class uses replay, so create status replay vars createReplayVar(getVarPool()); varCamsCnt = addVar("camsCnt", 0.0, "d", "Number of detected cameras"); varCams = addVar("cams", 0.0, "d", "Device numbers of the detected cameras"); }
void Check_PriorDeclaration_Base::addParamList(const AST_ParameterDecl::vec_shared_ptr &varList) { for( AST_ParameterDecl::vec_shared_ptr::const_iterator it = varList.begin(); it != varList.end(); ++it) { const AST_ParameterDecl::shared_ptr& varIncomingDecl = *it; addVar(varIncomingDecl->paramName(), varIncomingDecl->type()); } }
void addVar_i (varPrec * time, char *type, int *s2, char *cont, int *s1, varPrec * val, int *err) { char *t = (char *) malloc (sizeof (char) * (*s2 + 1)); char *c = (char *) malloc (sizeof (char) * (*s1 + 1)); memcpy (t, type, *s2); t[*s2] = '\0'; memcpy (c, cont, *s1); c[*s1] = '\0'; *err = addVar (*time, t, c, *val); }
void mcshSet() { variable* vPtr; if (commandCount == 0) { printf("Command count should not be 0 in mcshSet.\n"); return; } /****** print all variables ******/ if (commandCount == 1) { if (variableCount > 1) { mcshSort(); } for (vPtr = vHead; vPtr != NULL; vPtr = vPtr->next) { if ((strcmp (vPtr->name, "") != 0) && (vPtr != NULL)) printf ("%s %s\n", vPtr->name, vPtr->value); } return; } /****** print specific variable ******/ if (commandCount == 2) { if (mcshFind("variable", commands[1])) { printf ("%s %s\n", vCur->name, vCur->value); } else { printf ("Variable %s not found.\n", commands[1]); } return; } /****** add or update variable ******/ /* check if commands [1] name already exists, update value accordingly */ if (mcshFind ("variable", commands[1])) { mcshUpdate ("variable", vCur->name, commands [2]); } else { addVar (commands[1], commands[2]); } return; }
AngleSensor::AngleSensor(int pin, const char* id) { this->pin = pin; int idLen = strlen(id); this->id = (char*) malloc(sizeof(char)*idLen); strcpy(this->id, id); this->tempRate = 1; this->varList = NULL; addVar(INT, "angle", &angle); this->angle = 0; this->update(); }
void Check_PriorDeclaration_Base::checkDefinition_Function(const AST_FunctionDeclaration::shared_ptr &decl) { DeclaredVariable::vec_shared_ptr params = translate(decl->params()); m_Current->addPrcedure(decl->name(), params, decl->resultType()); { ASTTypeCheckingHolder holder(this); addVar("result", decl->resultType()); addParamList(decl->params()); addVarList(decl->variables()); // checkInternalDefinition_Function(decl); } }
COMPSL_EXPORT int32_t *vm_addInt(VM *vm, const char *name) { var *tmp; if(vm->vt.cnt < VM_MAX_GVARS) { tmp = addVar(&(vm->vt), INT_VAR, name); return &(tmp->v.i); } else { vm->errorno = COMPSL_VARS_FULL; return NULL; } }
extern "C" value C_create_lit(value v, value solver_In,value sign_In) { CAMLparam3(v, solver_In,sign_In); solver_c s = (solver_c) Field(solver_In, 0); int var_id = Int_val(v); // printf("minisat_ocaml_wrapper: new lit var id: %i\n",var_id); //assume true == True, false == False int sign = Bool_val(sign_In); addVar (s,var_id); lit_c lit = lit_var (var_id, sign); value val = alloc(1, Abstract_tag); Field(val,0) = (value) lit; CAMLreturn(val); }
DLexpression* DLcall::eval(std::unordered_map<std::string, DLexpression*> env){ //std::cerr << "NULL"; cqq++; auto m = _func->eval(env); // if (m==NULL) // std::cerr << ++cqq<< "NULL\n"; //else // std::cerr<< ++cqq << "notNull\n"; //std::cout<<m->getBody(env); auto idq = m->getArg(); addVar(idq, _arg->eval(env), env); return _func->eval(env)->getBody(env); }
COMPSL_EXPORT float *vm_addFloat(VM *vm, const char *name) { var *tmp; if(vm->vt.cnt < VM_MAX_GVARS) { tmp = addVar(&(vm->vt), FLOAT_VAR, name); return &(tmp->v.f); } else { vm->errorno = COMPSL_VARS_FULL; return NULL; } }
void UResPoly::createBaseVar() { varPolyCnt = addVar("polyCnt", 0.0, "d", "(r) number of established poly items"); varCallDispOnNewData = addVar("callDispOnNewData", 1.0, "d", "(rw) make a call to 'disp.newData()' when any polygon has changed (if true)."); varUpdTime = addVar("updateTime", 0.0, "d", "(r) time of last polygon update"); // // methods addMethod("addPoint", "sdd", "Add a polyline point to a poly-item. If the item do not exist it is created. First parameter is the item name, next 2 is x,y (or (E,N)) position"); addMethod("getPoint", "sd", "Get a point from a poly-item. First parameter is the item name, second is the position number (index). " "The point is returned into a 'UVariable' structure"); addMethod("getPointCnt", "s", "Get a point count for a poly-item"); addMethodV("addPoint", "sc", "Add a polyline point to a poly-item. If the item do not exist it is created. First parameter is the item name, next is taken as a 2D position - (x,y) or (E,N)"); addMethodV("del", "s", "Delete a poly item with this name."); addMethodV("delPoint", "sd", "Delete a polyline point from a poly-item. " "First parameter is the item name, next is index [0..cnt-1] to " "the item to delete."); addMethodV("getPoint", "sd", "Get a polyline point from a poly-item. " "First parameter is the item name, next is the item to delete"); addMethodV("isInside", "sc", "Is this pose inside the polygon, " "1st parameter is item name, 2nd is robot pose in item coordinates. " "returns true if pose is inside the (convex) polygon."); addMethodV("isInside", "scc", "Is this position relative to robot inside the polygon. " "1st parameter is item name, 2nd is robot pose in item coordinates, 3rd is a position relative to robot. " "returns true if position is inside the (convex) polygon."); addMethodV("defined", "s", "Is this poly-item defined."); addMethodV("setRefCoord", "sd", "Set the relative coordinate system for " "this poly item (0=odoPose, 1=utmPose, 2=mapPose). " "NB! must be defined with at least one point."); addMethodV("setOpen", "s", "Set as a poly-line. NB! must be defined"); addMethodV("setClosed", "s", "Set as a polygon - i.e. connect first and last point"); addMethodV("setPolygon", "sc", "Set named polygon from this source polygon (any existing pologon of this name is deleted)"); addMethodV("setPolygon", "scd", "Set named polygon and coordinate reference ('d' = 0=odo, 1=utm, 2=map) from this source polygon (any existing pologon of this name is deleted)"); /* else if ((strcasecmp(name, "setRefCoord") == 0) and (strcmp(paramOrder, "sd") == 0)) else if ((strcasecmp(name, "setOpen") == 0) and (strcmp(paramOrder, "s") == 0)) else if ((strcasecmp(name, "setClosed") == 0) and (strcmp(paramOrder, "s") == 0)) */ }
void UResLaserIfObst::createBaseVar() { addVar("version", getResVersion() / 100.0, "d", "Resource version"); varSerial = addVar("serial", -1.0, "d", "(r) latest obstacle group serial number (from laser server)"); varUpdate = addVar("update", -1.0, "d", "(r) Update number - increased when new obstacles arrive"); varTime = addVar("time", -1.0, "t", "(r) time for last update"); varGroups = addVar("groups", -1.0, "d", "(r) Number of obstacle groups"); varOLog = addVar("log", 0.0, "d", "(r/w) Should logfile be open"); // addMethod("obstacles", "ddd", "Get obstacle groups, first 'd' is requested number of dynamic obstacle groups, second d is number of fixed obstacle groups (0 or 1) third 'd' is lock request (1=locked groups) - must be unlocked by caller"); }
void GameLoader::addVar(GameVar *var, GameVar *subvar) { if (var && subvar) { int type = var->_varType; if (type == subvar->_varType && (!type || type == 1)) subvar->_value.intValue = var->_value.intValue; for (GameVar *v = var->_subVars; v; v = v->_nextVarObj) { GameVar *nv = subvar->getSubVarByName(v->_varName.c_str()); if (!nv) { nv = new GameVar; nv->_varName = v->_varName; nv->_varType = v->_varType; subvar->addSubVar(nv); } addVar(v, nv); } } }
void GameLoader::addVar(GameVar *var, GameVar *subvar) { if (var && subvar) { int type = var->_varType; if (type == subvar->_varType && (!type || type == 1)) subvar->_value.intValue = var->_value.intValue; for (GameVar *v = var->_subVars; v; v = v->_nextVarObj) { GameVar *nv = subvar->getSubVarByName(v->_varName); if (!nv) { nv = new GameVar; nv->_varName = (char *)calloc(strlen(v->_varName) + 1, 1); strcpy(nv->_varName, v->_varName); nv->_varType = v->_varType; subvar->addSubVar(nv); } addVar(v, nv); } } }
void QSDLEditor::setRecord(plStateDataRecord* rec, bool own) { fSDLList->clear(); fSDLVersion = -1; if (fIOwnRecord) delete fRecord; fIOwnRecord = own; fRecord = rec; fSDLVersion = rec->getDescriptor()->getVersion(); for (size_t i=0; i<fRecord->getNumVars(); i++) addVar(fRecord->get(i), fSDLList->invisibleRootItem()); fSDLList->expandAll(); fSDLList->resizeColumnToContents(1); fSDLList->resizeColumnToContents(0); if (fRecord->getNumVars() > 0) { fSDLList->topLevelItem(0)->setSelected(true); itemSelected(fSDLList->topLevelItem(0), NULL); } }
int evalexpenv(struct exp *e, struct env *env){ if (!e) return 0; switch (e->tag){ case isconstant: return e->constant; case isopapp :{ return evalexplist2(e->exps, e->op, env); } case islet: { //copy the environment and pass it to the struct env *copy; copy = copyEnv(env); addVarOverride(e->bvar,evalexpenv(e->bexp,copy),copy); addVar(e->bvar,evalexpenv(e->bexp,env),env); return evalexpenv(e->body, copy); } case isvar: return getval(e->var, env); } printf("%s\n", "Type not found."); return -1; }
int main() { puts("Running internal tests"); int ret = 0; { //varTable tests varTable vt; var *vs[6]; varTableCreate(&vt, 6); vs[0] = addVar(&vt,INT_VAR, "foo"); vs[1] = addVar(&vt,IS_GLBL | FLOAT_VAR, "bar"); vs[2] = addVar(&vt, FLOAT_VAR | IS_ARRAY, "foobar"); vs[3] = addVar(&vt, FLOAT_VAR, "baz"); vs[4] = addVar(&vt, FLOAT_VAR, "foo"); vs[5] = addVar(&vt, FLOAT_VAR | IS_ARRAY, "foobar"); assert(vs[2] == vs[5]); for(int i=0;i< 5; i++) for(int j=0; j<5;j++) if(j != i) assert(vs[i] != vs[j]); int16_t ind; //int16_t findVar(const varTable *vt,const char *name) ind = findVar(&vt, "foo"); assert(vs[0] == &(vt.vars[ind])); varTableDestroy(&vt); } { // comparment constant testing //int16_t com_addConst(compart *com, intfloat val); } { //test searchSym // typedef struct // { // int16_t id; // bool isvar;// if this is false then symbol is a native or built in function // bool local; // bool array; // bool isfloat; // }symbolinfo; // used for symbol table search (for compiler) // // /** // * search all symbol tables and return info on a symbol // * // * Post: if symbol doesn't exist returns a symbolinfo with id=-1 // * else returns info on symbol // */ // symbolinfo searchSym(const char *name, compart *com) __attribute__ ((pure)); VM *vm = createVM(); compart *com = createComp(vm); //int16_t com_addConst(compart *com, intfloat val); com_addConst(com,(intfloat)0); destroyComp(com); destroyVM(vm); } return ret; }
string CodeGenerator::newTemp(string Type) { string temp = "#" + itos(VarNum); addVar(temp, Type); return temp; }
string CodeGenerator::newConst(string Type, string value) { string con = "*" + itos(VarNum); addVar(con, Type, value); return con; }