// Read arguments ========================================================== void ProgNmaAlignment::readParams() { XmippMetadataProgram::readParams(); fnPDB = getParam("--pdb"); fnOutDir = getParam("--odir"); fnModeList = getParam("--modes"); resume = checkParam("--resume"); trustradius_scale = abs(getDoubleParam("--trustradius_scale")); sampling_rate = getDoubleParam("--sampling_rate"); fnmask = getParam("--mask"); gaussian_DFT_sigma = getDoubleParam("--gaussian_Fourier"); gaussian_Real_sigma = getDoubleParam("--gaussian_Real"); weight_zero_freq = getDoubleParam("--zerofreq_weight"); do_centerPDB = checkParam("--centerPDB"); do_FilterPDBVol = checkParam("--filterVol"); if (do_FilterPDBVol) cutoff_LPfilter = getDoubleParam("--filterVol"); useFixedGaussian = checkParam("--fixed_Gaussian"); if (useFixedGaussian) sigmaGaussian = getDoubleParam("--fixed_Gaussian"); projMatch = checkParam("--projMatch"); discrAngStep = getDoubleParam("--discrAngStep"); }
virtual State validate(QString &input, int &pos) const { static const char* p[] = {"o", "frames", "seek", "raw", "hfyu", "slave", NULL}; bool invalid = checkPrefix(input); for(size_t i = 0; p[i] && (!invalid); i++) { invalid = invalid || checkParam(input, QString::fromLatin1(p[i]), false); } return setStatus(invalid, "Avs2YUV") ? QValidator::Intermediate : QValidator::Acceptable; }
int LocalLog::HandleProcess( MSS &in, MSS &out ) { checkParam( in ); string sContent; int ret = getLogContent(sContent); if (ret != 0) { return ret; } out[ "content" ] = JU::SrvEncode( sContent ); return 0; }
// AmB2BSession methods bool DSMCall::onOtherBye(const AmSipRequest& req) { DBG("* Got BYE from other leg\n"); DSMSipRequest sip_req(&req); avar[DSM_AVAR_REQUEST] = AmArg((AmObject*)&sip_req); map<string, string> params; params["hdrs"] = req.hdrs; // todo: optimization - make this configurable engine.runEvent(this, this, DSMCondition::B2BOtherBye, ¶ms); avar.erase(DSM_AVAR_REQUEST); return checkParam(DSM_PROCESSED, DSM_TRUE, ¶ms); }
virtual State validate(QString &input, int &pos) const { static const char* p[] = {"B", "o", "h", "p", "q", /*"fps", "frames",*/ "preset", "tune", "profile", "stdin", "crf", "bitrate", "qp", "pass", "stats", "output", "help","quiet", NULL}; bool invalid = checkPrefix(input); for(size_t i = 0; p[i] && (!invalid); i++) { invalid = invalid || checkParam(input, QString::fromLatin1(p[i]), true); } return setStatus(invalid, "encoder") ? QValidator::Intermediate : QValidator::Acceptable; }
void readParams() { XmippMetadataProgram::readParams(); min_val = getDoubleParam("--range", 0); max_val = getDoubleParam("--range", 1); sigma = getDoubleParam("--noise"); randomize_random_generator(); if (checkParam("--mask")) { mask_prm.allowed_data_types = INT_MASK; mask_prm.readParams(this); } }
int main(int argc, char* argv[]) { FILE* file = NULL; STRING** table = NULL; int max = 0; checkParam(argc); file = fopen(argv[1], "r"); checkFile(file, argv[1]); table = readFile(file); max = findMax(table); printMax(file, table, max); destroyTable(table); return 0; }
void DSMCall::onSipReply(const AmSipRequest& req, const AmSipReply& reply, AmBasicSipDialog::Status old_dlg_status) { if (checkVar(DSM_ENABLE_REPLY_EVENTS, DSM_TRUE)) { map<string, string> params; params["code"] = int2str(reply.code); params["reason"] = reply.reason; params["hdrs"] = reply.hdrs; params["cseq"] = int2str(reply.cseq); params["dlg_status"] = dlg->getStatusStr(); params["old_dlg_status"] = AmBasicSipDialog::getStatusStr(old_dlg_status); // pass AmSipReply for use by mod_dlg (? sending ACK?) DSMSipReply* dsm_reply = new DSMSipReply(&reply); avar[DSM_AVAR_REPLY] = AmArg(dsm_reply); engine.runEvent(this, this, DSMCondition::SipReply, ¶ms); delete dsm_reply; avar.erase(DSM_AVAR_REPLY); if (checkParam(DSM_PROCESSED, DSM_TRUE, ¶ms)) { DBG("DSM script processed SIP reply '%u %s', returning\n", reply.code, reply.reason.c_str()); return; } } AmB2BCallerSession::onSipReply(req, reply, old_dlg_status); if ((old_dlg_status < AmSipDialog::Connected) && (dlg->getStatus() == AmSipDialog::Disconnected)) { DBG("Outbound call failed with reply %d %s.\n", reply.code, reply.reason.c_str()); map<string, string> params; params["code"] = int2str(reply.code); params["reason"] = reply.reason; engine.runEvent(this, this, DSMCondition::FailedCall, ¶ms); setStopped(); } }
/* Read parameters --------------------------------------------------------- */ void ProgAngularProjectLibrary::readParams() { input_volume = getParam("-i"); output_file = getParam("-o"); output_file_root = output_file.withoutExtension(); fn_sym = getParam("--sym"); fn_sym_neigh=checkParam("--sym_neigh")?getParam("--sym_neigh"):fn_sym; sampling = getDoubleParam("--sampling_rate"); psi_sampling = getDoubleParam("--psi_sampling"); max_tilt_angle = getDoubleParam("--max_tilt_angle"); min_tilt_angle = getDoubleParam("--min_tilt_angle"); angular_distance_bool = checkParam("--angular_distance"); angular_distance=0.; if(angular_distance_bool) { FnexperimentalImages = getParam("--experimental_images"); angular_distance = getDoubleParam("--angular_distance"); } compute_closer_sampling_point_bool= checkParam("--closer_sampling_points"); if(compute_closer_sampling_point_bool) FnexperimentalImages = getParam("--experimental_images"); if (STR_EQUAL(getParam("--method"), "real_space")) projType = REALSPACE; if (STR_EQUAL(getParam("--method"), "shears")) projType = SHEARS; if (STR_EQUAL(getParam("--method"), "fourier")) { projType = FOURIER; paddFactor = getDoubleParam("--method", 1); maxFrequency = getDoubleParam("--method", 2); String degree = getParam("--method", 3); if (degree == "nearest") BSplineDeg = NEAREST; else if (degree == "linear") BSplineDeg = LINEAR; else if (degree == "bspline") BSplineDeg = BSPLINE3; else REPORT_ERROR(ERR_ARG_BADCMDLINE, "The interpolation kernel can be : nearest, linear, bspline"); } //NOTE perturb in computed after the even sampling is computes // and max tilt min tilt applied perturb_projection_vector=getDoubleParam("--perturb"); compute_neighbors_bool=checkParam("--compute_neighbors"); remove_points_far_away_from_experimental_data_bool=checkParam("--near_exp_data"); if(remove_points_far_away_from_experimental_data_bool) FnexperimentalImages = getParam("--experimental_images"); fn_groups = getParam("--groups"); only_winner = checkParam("--only_winner"); }
void n_comphep(void) { clr_scr(FGmain,BGmain); while(checkParam()) if(mess_y_n(15,15, "Quit the session?")) {w_sess__(NULL); return;} else change_parameter(54,7,0); do { int err=monte_carlo_menu(); switch(err) { case 1:printf("Energy is too small!\n"); sortie(123); case 2:printf("Can not evaluate cuts limlts\n"); sortie(124); case 3:printf("Can not evaluate regularization paremeters"); sortie(125); } } while(!mess_y_n(15,15,"Quit session?")); w_sess__(NULL); }
/*--------------------------------------------------------*/ void AzOptOnTree::synchronize() { checkParam(); int f_num = tree_feat->featNum(); int old_f_num = v_w.rowNum(); v_w.resize(f_num); bool isThereChange = false; int fx; for (fx = 0; fx < old_f_num; ++fx) { if (tree_feat->featInfo(fx)->isRemoved && v_w.get(fx) != 0) { isThereChange = true; v_w.set(fx, 0); } } if (isThereChange || doRefreshP) { refreshPred(); } }
void ParamMap::add(const string &str) { int hash = checkHash(str); if (hash != 1) { Param p(str.substr(0, hash)); // cut the string until a hash appears, otherwise use the whole string (hash = str.length()) if (!checkParam(p.getParamName())) // if name not present -> create list with first Param entry { vector<Param> paramVec; paramVec.push_back(p); paraMap[p.getParamName()] = paramVec; } else // if name already exits push_back Param to STL vector in map { vector<Param> *paramVec = getParamVector(p.getParamName()); paramVec->push_back(p); } } }
IOperatingMode* BasicMode::handleRequest(WebRequest* webHandler, String request) { int argc = -1; String* split = webHandler->splitRequest(request, &argc); if(checkParam(split, 0, BASIC)) { if(checkParam(split, 1, TEST)) { webHandler->completeResponse("Hello there"); return NULL; } else if(checkParam(split, 1, SET) && checkParam(split, 2, MODE)) { if(checkParam(split, 3, GPIO)) { webHandler->sendResponse(webHandler->createJSONResponse("SET_MODE", "GPIO_MODE", "OK", "")); StaticJsonBuffer<200> jsonBuffer; JsonObject& root = jsonBuffer.createObject(); //TODO get JSON from request root["gpio"] = 2; LEDMode* newmode = new LEDMode(); newmode->init(this->owner, root); return newmode; } else if(checkParam(split, 3, COMPOSITE)) { webHandler->sendResponse(webHandler->createJSONResponse("SET_MODE", "COMPOSITE_MODE", "OK", "")); StaticJsonBuffer<0> jsonBuffer; JsonObject& root = jsonBuffer.createObject(); //TODO create empty JSON in a simpler way CompositeMode* newmode = new CompositeMode(); //Need to create a new one, because the old one will be deleted automatically newmode->addMode(new BasicMode()); newmode->init(this->owner, root); return newmode; } } } return NULL; }
void readParams() { fnIn = getParam("-i"); fnOut = getParam("-o"); type = getParam("-o",1); if (type=="chimera") { R=getDoubleParam("-o",2); rmax=getDoubleParam("-o",3); shift_center=getIntParam("-o",4); } else if (type=="ps") { R=getDoubleParam("-o",2); rmax=getDoubleParam("-o",3); rot_view=getDoubleParam("-o",4); tilt_view=getDoubleParam("-o",5); solid_sphere=getIntParam("-o",6); } else if (type=="histogram") steps = getIntParam("-o",2); up_down_correction = checkParam("--up_down_correction"); }
void show() { if (verbose == 0) return; String msg; switch (operation) { case HEADER_PRINT: msg = "Printing headers..."; break; case HEADER_EXTRACT: msg = "Extracting image(s) geometrical transformations from header to metadata..."; break; case HEADER_ASSIGN: msg = "Assigning image(s) geometrical transformations from metadata to header..."; break; case HEADER_RESET: msg = "Reseting geometrical transformations from headers..."; break; case HEADER_SAMPLINGRATE: if (sampling > 0) msg = "Setting sampling rate into headers..."; else msg = "Showing sampling rate from headers..."; break; case HEADER_TREE: msg = "Printing tree structure..."; break; } std::cout << msg << std::endl << "Input: " << fn_in << std::endl; if (checkParam("-o")) std::cout << "Output: " << fn_out << std::endl; }
/* perform I/O requests */ LOCAL INT rwfn(INT mode, INT start, INT size, void *buf) { INT er; W dsz; BOOL set = (mode == Write); switch (start) { case DN_SCRSPEC: dsz = sizeof(DEV_SPEC); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRSPEC((DEV_SPEC*)buf); break; case DN_SCRLIST: dsz = getSCRLIST(NULL); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRLIST((TC*)buf); break; case DN_SCRNO: dsz = sizeof(W); if ((er = checkParam(mode, size, dsz, RW_OK)) > E_OK) er = getsetSCRNO((W*)buf, suspended, set); break; case DN_SCRCOLOR: dsz = getsetSCRCOLOR(NULL, FALSE); if ((er = checkParam(mode, size, dsz, RW_OK)) > E_OK) er = getsetSCRCOLOR((COLOR*)buf, set); break; case DN_SCRBMP: dsz = sizeof(BMP); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRBMP((BMP*)buf); break; case DN_SCRBRIGHT: dsz = sizeof(W); if ((er = checkParam(mode, size, dsz, RW_OK)) > E_OK) er = getsetSCRBRIGHT((W*)buf, set); break; case DN_SCRUPDFN: dsz = sizeof(FP); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRUPDFN((FP*)buf); break; case DN_SCRVFREQ: dsz = sizeof(W); if ((er = checkParam(mode, size, dsz, RW_OK)) > E_OK) er = getsetSCRVFREQ((W*)buf, set); break; case DN_SCRADJUST: dsz = sizeof(ScrAdjust); if ((er = checkParam(mode, size, dsz, RW_OK)) > E_OK) er = getsetSCRADJUST((ScrAdjust*)buf, set); break; case DN_SCRDEVINFO: dsz = sizeof(ScrDevInfo); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRDEVINFO((ScrDevInfo*)buf); break; case DN_SCRMEMCLK: dsz = 0; er = E_NOSPT; break; case DN_SCRUPDRECT: dsz = sizeof(RECT); if ((er = checkParam(mode, size, dsz, W_OK)) > E_OK) er = setSCRUPDRECT((RECT*)buf); break; case DN_SCRWRITE: dsz = size; if ((er = checkParam(mode, size, dsz, W_OK)) > E_OK) er = setSCRWRITE(0, buf, dsz); break; default: if (start <= DN_SCRXSPEC(1) && start >= DN_SCRXSPEC(255)) { dsz = sizeof(DEV_SPEC); if ((er = checkParam(mode, size, dsz, R_OK)) > E_OK) er = getSCRXSPEC((DEV_SPEC*)buf, DN_SCRXSPEC(1) - start); } else { dsz = 0; er = E_PAR; } break; } return (er < E_OK) ? er : dsz; }
void paramdependence(r_func ff, char* procname, char* resultname) { double minprm, maxprm; int npoints; double memprm, stepprm; unsigned count; double f[201]; int Esc=0,mPos=1; double prmval; char txt[100]; char name[20]; double *vPos; if(!selectParam(54,11,"Choose parameter",NULL,nin_int==2,1,0,&vPos,name,&mPos)) return; memprm=*vPos; minprm = memprm; maxprm = minprm; label1: sprintf(txt,"'%s' min=",name); if (!correctDouble(55,14,txt,&minprm,0)) return; label2: sprintf(txt,"'%s' max=",name); if (!correctDouble(55,15,txt,&maxprm,0)) { goto_xy(55,14); clr_eol(); goto label1; } if (maxprm <= minprm) { messanykey(55,17,"Range check error"); goto_xy(55,15); clr_eol(); goto label2; } label4: npoints = 101; if (correctInt(55,16,"Number of points= ",&npoints,0)) { if (npoints < 3) { messanykey(55,17,"Too few points!"); goto label4; } if (npoints > 201) { messanykey(55,17,"Too many points!"); goto label4; } } else { goto_xy(55,15); clr_eol(); goto label2; } goto_xy(55,14); clr_eol(); goto_xy(55,15); clr_eol(); goto_xy(55,16); clr_eol(); stepprm = (maxprm - minprm)/(npoints - 1); informline(0,npoints); stepprm = (maxprm - minprm) / (npoints - 1); prmval=minprm; err_code = 0; for(count = 1; count <= npoints; count++) { *vPos=prmval; err_code=checkParam(); if(err_code>1) break; f[count-1] = ff(); if(err_code>1) break; Esc=informline(count,npoints); if(Esc) break; prmval += stepprm; } if(err_code) errormessage(); strcpy(txt,name); if (err_code <=1 && Esc==0) plot_1(minprm,maxprm ,npoints,f,NULL,procname,txt,resultname); *vPos=memprm; calcFunc_int(); }
void readParams() { // Get parameters ======================================================= fn1 = getParam("--i1"); fn2 = getParam("--i2"); rot0 = getDoubleParam("--rot",0); rotF = getDoubleParam("--rot",1); step_rot = getDoubleParam("--rot",2); tilt0 = getDoubleParam("--tilt",0); tiltF = getDoubleParam("--tilt",1); step_tilt = getDoubleParam("--tilt",2); psi0 = getDoubleParam("--psi",0); psiF = getDoubleParam("--psi",1); step_psi = getDoubleParam("--psi",2); scale0 = getDoubleParam("--scale",0); scaleF = getDoubleParam("--scale",1); step_scale = getDoubleParam("--scale",2); grey_scale0 = getDoubleParam("--grey_scale",0); grey_scaleF = getDoubleParam("--grey_scale",1); step_grey = getDoubleParam("--grey_scale",2); grey_shift0 = getDoubleParam("--grey_shift",0); grey_shiftF = getDoubleParam("--grey_shift",1); step_grey_shift = getDoubleParam("--grey_shift",2); z0 = getDoubleParam("-z",0); zF = getDoubleParam("-z",1); step_z = getDoubleParam("-z",2); y0 = getDoubleParam("-y",0); yF = getDoubleParam("-y",1); step_y = getDoubleParam("-y",2); x0 = getDoubleParam("-x",0); xF = getDoubleParam("-x",1); step_x = getDoubleParam("-x",2); mask_enabled = checkParam("--mask"); if (mask_enabled) mask.read(argc, argv); usePowell = checkParam("--local"); useFRM = checkParam("--frm"); if (useFRM) { maxFreq=getDoubleParam("--frm",0); maxShift=getIntParam("--frm",1); } onlyShift = checkParam("--onlyShift"); if (step_rot == 0) step_rot = 1; if (step_tilt == 0) step_tilt = 1; if (step_psi == 0) step_psi = 1; if (step_scale == 0) step_scale = 1; if (step_grey == 0) step_grey = 1; if (step_grey_shift == 0) step_grey_shift = 1; if (step_z == 0) step_z = 1; if (step_y == 0) step_y = 1; if (step_x == 0) step_x = 1; tell = checkParam("--show_fit"); apply = checkParam("--apply"); fnOut = getParam("--apply"); if (checkParam("--covariance")) { params.alignment_method = COVARIANCE; } else if (checkParam("--least_squares")) { params.alignment_method = LEAST_SQUARES; } else { params.alignment_method = COVARIANCE; } }