void init_config() { // read gw2dps directory from shared memory shared_memory_object shm(boost::interprocess::open_only, "config_path", boost::interprocess::read_only); mapped_region region(shm, boost::interprocess::read_only); wchar_t* cur_path = (wchar_t*) region.get_address(); abs_file_name = wstring(cur_path) + L"\\" + CONFIG_FILE_NAME; in_config_file.open(abs_file_name.c_str(), fstream::in); if (!in_config_file.is_open()) { out_config_file.open(abs_file_name.c_str(), fstream::out); out_config_file << DEFAULT_CONFIG_FILE; out_config_file.flush(); out_config_file.close(); } // TODO: rewind is better than reopen in_config_file.close(); in_config_file.open(abs_file_name.c_str(), fstream::in); read_ini(in_config_file, config_pt); in_config_file.close(); stringstream ss; ss << DEFAULT_CONFIG_FILE; read_ini(ss, def_config_pt); }
void LanguageModelDALM::Load() { ///////////////////// // READING INIFILE // ///////////////////// string model; // Path to the double-array file. string words; // Path to the vocabulary file. read_ini(m_filePath.c_str(), model, words); //////////////// // LOADING LM // //////////////// // Preparing a logger object. m_logger = new DALM::Logger(stderr); m_logger->setLevel(DALM::LOGGER_INFO); // Load the vocabulary file. m_vocab = new DALM::Vocabulary(words, *m_logger); // Load the language model. m_lm = new DALM::LM(model, *m_vocab, *m_logger); wid_start = m_vocab->lookup(BOS_); wid_end = m_vocab->lookup(EOS_); }
void LanguageModelDALM::Load() { ///////////////////// // READING INIFILE // ///////////////////// string model; // Path to the double-array file. string words; // Path to the vocabulary file. string wordstxt; //Path to the vocabulary file in text format. read_ini(m_filePath.c_str(), model, words, wordstxt); UTIL_THROW_IF(model.empty() || words.empty() || wordstxt.empty(), util::FileOpenException, "Failed to read DALM ini file " << m_filePath << ". Probably doesn't exist"); //////////////// // LOADING LM // //////////////// // Preparing a logger object. m_logger = new DALM::Logger(stderr); m_logger->setLevel(DALM::LOGGER_INFO); // Load the vocabulary file. m_vocab = new DALM::Vocabulary(words, *m_logger); // Load the language model. m_lm = new DALM::LM(model, *m_vocab, *m_logger); wid_start = m_vocab->lookup(BOS_); wid_end = m_vocab->lookup(EOS_); // vocab mapping CreateVocabMapping(wordstxt); }
static int set_upd_nvs(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { char *fname = NULL; struct wl12xx_common cmn = { .arch = UNKNOWN_ARCH, .parse_ops = NULL }; argc -= 2; argv += 2; if (argc < 1) return 1; if (read_ini(*argv, &cmn)) { fprintf(stderr, "Fail to read ini file\n"); return 1; } cfg_nvs_ops(&cmn); if (argc == 2) fname = *++argv; if (update_nvs_file(fname, &cmn)) { fprintf(stderr, "Fail to update NVS file\n"); return 1; } #if 0 printf("\n\tThe updated NVS file (%s) is ready\n\tCopy it to %s and " "reboot the system\n\n", NEW_NVS_NAME, CURRENT_NVS_NAME); #endif return 0; }
static int set_ref_nvs(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { struct wl12xx_common cmn = { .arch = UNKNOWN_ARCH, .parse_ops = NULL, .dual_mode = DUAL_MODE_UNSET, .done_fem = NO_FEM_PARSED }; argc -= 2; argv += 2; if (argc != 1) return 1; if (read_ini(*argv, &cmn)) { fprintf(stderr, "Fail to read ini file\n"); return 1; } cfg_nvs_ops(&cmn); if (create_nvs_file(&cmn)) { fprintf(stderr, "Fail to create reference NVS file\n"); return 1; } #if 0 printf("\n\tThe NVS file (%s) is ready\n\tCopy it to %s and " "reboot the system\n\n", NEW_NVS_NAME, CURRENT_NVS_NAME); #endif return 0; }
static int set_ref_nvs(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) { struct wl12xx_common cmn = { .arch = UNKNOWN_ARCH, .parse_ops = NULL }; argc -= 2; argv += 2; if (argc < 1 || argc > 2) return 1; if (read_ini(*argv, &cmn)) { fprintf(stderr, "Fail to read ini file\n"); return 1; } argv++; argc--; cfg_nvs_ops(&cmn); cmn.nvs_name = get_opt_nvsoutfile(argc, argv); if (create_nvs_file(&cmn)) { fprintf(stderr, "Fail to create reference NVS file\n"); return 1; } printf("%04X", cmn.arch); return 0; }
void read(PTree & node) { std::string line, name; while (in.good()) { std::getline(in, line, '\n'); if (line.empty()) { continue; } size_t begin = line.find_first_not_of(" \t["); size_t end = line.find_first_of(";#]\r", begin); if (begin >= end) { continue; } size_t next = line.find("=", begin); if (next >= end) { // New node. next = line.find_last_not_of(" \t\r]", end); name = line.substr(begin, next); read(root.set(name, PTree())); continue; } size_t next2 = line.find_first_not_of(" \t\r", next+1); next = line.find_last_not_of(" \t", next-1); if (next2 >= end) continue; name = line.substr(begin, next+1); if (!fopen || line.at(next2) != '&') { // New property. std::string value = line.substr(next2, end-next2); node.set(name, value); continue; } // Value is a reference. std::string value = line.substr(next2+1, end-next2-1); const PTree * ref_ptr; if (root.get(value, ref_ptr) || cache.get(value, ref_ptr)) { node.set(name, *ref_ptr); continue; } // Load external reference. PTree ref; read_ini(value, *fopen, ref); cache.set(value, ref); node.set(name, ref); } }
OAuthClient::OAuthClient(string eConf, string uConf){ cout << "Construct" << endl; //Read config files read_ini(eConf, pevimedConfig); read_ini(uConf, puserConfig); try { serverUrl = pevimedConfig.get<string>("evimed.server_url"); } catch (exception& e) { string error = "Error on this description: "; error.append(e.what()); cout << error << endl; return; } loadingConfiguration(serverUrl, eConf, uConf); }
int DEFAULT_CC main(int argc, char** argv) { int pid; char text[256]; if (argc != 2) { g_printf("Usage : xrdp-chansrv 'username'\n"); g_exit(1); } username = argv[1]; g_init(); /* os_calls */ read_ini(); read_logging_conf(); chan_init(); log_start(&log_conf); pid = g_getpid(); log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[main]: " "app started pid %d(0x%8.8x)", pid, pid); g_signal_kill(term_signal_handler); /* SIGKILL */ g_signal_terminate(term_signal_handler); /* SIGTERM */ g_signal_user_interrupt(term_signal_handler); /* SIGINT */ g_signal_pipe(nil_signal_handler); /* SIGPIPE */ g_signal_child_stop(stop_signal_handler); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid); g_term_event = g_create_wait_obj(text); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_thread_done", pid); g_thread_done_event = g_create_wait_obj(text); tc_thread_create(channel_thread_loop, 0); while (!g_is_wait_obj_set(g_term_event)) { if (g_obj_wait(&g_term_event, 1, 0, 0, 0) != 0) { log_message(&log_conf, LOG_LEVEL_WARNING, "chansrv[main]: " "main: error, g_obj_wait failed"); break; } } while (!g_is_wait_obj_set(g_thread_done_event)) { /* wait for thread to exit */ if (g_obj_wait(&g_thread_done_event, 1, 0, 0, 0) != 0) { log_message(&log_conf, LOG_LEVEL_WARNING, "chansrv[main]: " "main: error, g_obj_wait failed"); break; } } /* cleanup */ main_cleanup(); log_message(&log_conf, LOG_LEVEL_INFO, "chansrv[main]: " "main: app exiting pid %d(0x%8.8x)", pid, pid); return 0; }
void PERFORMANCE_TESTING::Test( const std::string & carpath, const std::string & carname, const std::string & partspath, std::ostream & info_output, std::ostream & error_output) { info_output << "Beginning car performance test on " << carname << std::endl; const std::string carfile = carpath+"/"+carname+".car"; //load the car dynamics PTree cfg; file_open_basic fopen(carpath, partspath); if (!read_ini(carname+".car", fopen, cfg)) { error_output << "Error loading car configuration file: " << carfile << std::endl; return; } btVector3 size(0, 0, 0), center(0, 0, 0), pos(0, 0, 0); // collision shape from wheel data btQuaternion rot = btQuaternion::getIdentity(); bool damage = false; if (!car.dynamics.Load(cfg, size, center, pos, rot, damage, world, error_output)) { error_output << "Error during car dynamics load: " << carfile << std::endl; return; } info_output << "Car dynamics loaded" << std::endl; info_output << carname << " Summary:\n" << "Mass (kg) including driver and fuel: " << 1/car.GetInvMass() << "\n" << "Center of mass (m): " << car.GetCenterOfMassPosition() << std::endl; std::stringstream statestream; joeserialize::BinaryOutputSerializer serialize_output(statestream); if (!car.Serialize(serialize_output)) { error_output << "Serialization error" << std::endl; } //else info_output << "Car state: " << statestream.str(); carstate = statestream.str(); // fixme info_output << "Car performance test broken - exiting." << std::endl; return; TestMaxSpeed(info_output, error_output); TestStoppingDistance(false, info_output, error_output); TestStoppingDistance(true, info_output, error_output); info_output << "Car performance test complete." << std::endl; }
void HyperReader_init(void) {CloseCur(); ClrScr(); puts("\nWelcome to the HyperReader 2000"); puts("========================================="); read_ini(); alloc_mem(); read_HZK(); graph_init(); image(); CloseCur(); read_file(); read_LabelFile(); }
void robot_config_t::from_file(const std::string& filename) { ini_t ini=read_ini(filename); for(ini_t::const_iterator iter=ini.begin();iter!=ini.end();++iter) { if(keys_m.count(to_lower(iter->first))>0) keys_m[to_lower(iter->first)]=to_lower(iter->second); else throw std::runtime_error("Unrecognized ini argument \""+iter->first+"\".\n"); } validate(); }
void crt0_start(char * window_name,char * icon_file,char * ini_file,int*colors, void (*xw_error)(void)) { char inif[200]; xw_error_stat=xw_error; if(bgi_status==0) { char * f; sprintf(inif,"%.190s",ini_file); f=strtok(inif,";"); do{ if(read_ini(f)) f=NULL;else f=strtok(NULL,";");} while (f); if(bgi_0to2(window_name,icon_file)) { fprintf(stderr,"X Windows not detected.\n"); X_IO_Error_H(NULL);} } bgi_status=1; *colors=bgi_maxcolor; }
int CMisc::loadManager(string loadFileName, string dataName) { namespace propertyTree = boost::property_tree; propertyTree::ptree pt; read_ini(loadFileName, pt); if (boost::optional<int> value = pt.get_optional<int>(dataName)) { return value.get(); } else { cout << "ERROR:Not Data." << endl; } }
MainWidget::MainWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MainWidget) { ui->setupUi(this); init_sideBar(); init_serPort(); read_ini(); slot_serPort_open();//打开串口 init_timeThreadTimer_connect(); setColumnWidth(); init_charging_wave(); init_ripple_wave(); //纹波 init_PE_wave(); init_runTime(); //运行时间 }
int main(int argc, char* argv[]) { if( 3 > argc ) { printf( "ps [suspend|resume|kill] <app_name>\n" ); return 0; } char client_path[BUF_SIZE]={0}; char hostname[BUF_SIZE]={0}; int port=7010; char username[BUF_SIZE]={0}; char password[BUF_SIZE]={0}; read_ini(&client_path, &hostname, &port, &username, &password); char cmd[BUF_SIZE]={0}; sprintf(cmd, "%s\\bin\\aa.exe connect --hostname=%s --port=%d --user=%s --password=%s", client_path, hostname, port, username, password); BOOL bRet; if( ! strcmpi( argv[1], "suspend" )){ bRet = NTPauseResumeProcess(argv[2], FALSE); if(bRet){ KillProcessByName("IntegrityClient.exe"); } }else if( ! strcmpi( argv[1], "resume" )){ printf("Running... \"%s\"\n", cmd); BOOL bRunStatus = runScripts(cmd); if(bRunStatus) bRet = NTPauseResumeProcess(argv[2], TRUE); }else if( ! strcmpi( argv[1], "kill" )){ KillProcessByName(argv[2]); printf("Running... \"%s\"\n", cmd); bRet = runScripts(cmd); } printf("Result By Process:%d\n", bRet); //KillProcessByName("IntegrityClient.exe"); return 0; }
void AsiftKeypoints::inireadSiftParameters(std::string name){ ptree pt; if(this->path.isExist(name)){ read_ini(name, pt); inireadSiftParameters(pt); }else{ std::cout << "not exist " << name << endl; default_sift_parameters(siftparams); iniwriteSiftParameters(name); } }
void load_config() { char *value; char msg[100]; msg[0] = 0; /* ini_r is a structure that holds state to make this reader * reentrant */ struct read_ini *ini_r = NULL; /* "test.ini" will be parsed into "ini" */ char* root = (*SYS_RootDir)(); char filename[100]; filename[0] = 0; strcat(filename, root); strcat(filename, "\\PlugIns\\"); strcat(filename, "saveall.ini"); struct ini *ini = read_ini(&ini_r, filename); /* pretty printing of ini structure */ ini_pp(ini); /* retrieve a value */ value = ini_get_value(ini, "section", "basedir"); if(value != NULL) { strcat(msg, "value is\n"); strcat(msg, value); strcpy(basedir, value); // ShowMessage(msg); } else { // ShowMessage("cannot get key"); } /* free memory */ destroy_ini(ini); cleanup_readini(ini_r); }
bool CarSound::Load( const std::string & carpath, const std::string & carname, Sound & sound, ContentManager & content, std::ostream & error_output) { assert(!psound); // check for sound specification file std::string path_aud = carpath + "/" + carname + ".aud"; std::ifstream file_aud(path_aud.c_str()); if (file_aud.good()) { PTree aud; read_ini(file_aud, aud); enginesounds.reserve(aud.size()); for (const auto & i : aud) { const PTree & audi = i.second; std::string filename; std::shared_ptr<SoundBuffer> soundptr; if (!audi.get("filename", filename, error_output)) return false; enginesounds.push_back(EngineSoundInfo()); EngineSoundInfo & info = enginesounds.back(); if (!audi.get("MinimumRPM", info.minrpm, error_output)) return false; if (!audi.get("MaximumRPM", info.maxrpm, error_output)) return false; if (!audi.get("NaturalRPM", info.naturalrpm, error_output)) return false; bool powersetting; if (!audi.get("power", powersetting, error_output)) return false; if (powersetting) info.power = EngineSoundInfo::POWERON; else if (!powersetting) info.power = EngineSoundInfo::POWEROFF; else info.power = EngineSoundInfo::BOTH; info.sound_source = sound.AddSource(soundptr, 0, true, true); sound.SetSourceGain(info.sound_source, 0); } // set blend start and end locations -- requires multiple passes std::map <EngineSoundInfo *, EngineSoundInfo *> temporary_to_actual_map; std::list <EngineSoundInfo> poweron_sounds, poweroff_sounds; for (auto & info : enginesounds) { if (info.power == EngineSoundInfo::POWERON) { poweron_sounds.push_back(info); temporary_to_actual_map[&poweron_sounds.back()] = &info; } else if (info.power == EngineSoundInfo::POWEROFF) { poweroff_sounds.push_back(info); temporary_to_actual_map[&poweroff_sounds.back()] = &info; } } poweron_sounds.sort(); poweroff_sounds.sort(); // we only support 2 overlapping sounds at once each for poweron and poweroff; this // algorithm fails for other cases (undefined behavior) std::list <EngineSoundInfo> * cursounds = &poweron_sounds; for (int n = 0; n < 2; n++) { if (n == 1) cursounds = &poweroff_sounds; for (auto i = (*cursounds).begin(); i != (*cursounds).end(); ++i) { // set start blend if (i == (*cursounds).begin()) i->fullgainrpmstart = i->minrpm; // set end blend auto inext = i; inext++; if (inext == (*cursounds).end()) i->fullgainrpmend = i->maxrpm; else { i->fullgainrpmend = inext->minrpm; inext->fullgainrpmstart = i->maxrpm; } } // now assign back to the actual infos for (auto & info : *cursounds) { assert(temporary_to_actual_map.find(&info) != temporary_to_actual_map.end()); *temporary_to_actual_map[&info] = info; } } } else { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "engine"); enginesounds.push_back(EngineSoundInfo()); enginesounds.back().sound_source = sound.AddSource(soundptr, 0, true, true); } //set up tire squeal sounds for (int i = 0; i < 4; ++i) { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "tire_squeal"); tiresqueal[i] = sound.AddSource(soundptr, i * 0.25, true, true); } //set up tire gravel sounds for (int i = 0; i < 4; ++i) { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "gravel"); gravelsound[i] = sound.AddSource(soundptr, i * 0.25, true, true); } //set up tire grass sounds for (int i = 0; i < 4; ++i) { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "grass"); grasssound[i] = sound.AddSource(soundptr, i * 0.25, true, true); } //set up bump sounds for (int i = 0; i < 4; ++i) { std::shared_ptr<SoundBuffer> soundptr; if (i >= 2) { content.load(soundptr, carpath, "bump_rear"); } else { content.load(soundptr, carpath, "bump_front"); } tirebump[i] = sound.AddSource(soundptr, 0, true, false); } //set up crash sound { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "crash"); crashsound = sound.AddSource(soundptr, 0, true, false); } //set up gear sound { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "gear"); gearsound = sound.AddSource(soundptr, 0, true, false); } //set up brake sound { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "brake"); brakesound = sound.AddSource(soundptr, 0, true, false); } //set up handbrake sound { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "handbrake"); handbrakesound = sound.AddSource(soundptr, 0, true, false); } { std::shared_ptr<SoundBuffer> soundptr; content.load(soundptr, carpath, "wind"); roadnoise = sound.AddSource(soundptr, 0, true, true); } psound = &sound; return true; }
//by:yhy write ini_file to the file ini_file_t* save_ini(ini_file_t *ini_file, const char *path) { ini_file_t *doc = (ini_file_t *)ini_file; ini_selection_t *sec_tmp = NULL; ini_comment_t *comm_tmp = NULL; ini_item_t *item_tmp = NULL; ini_selection_t *section_tmp = NULL; ini_comment_t *section_comm_tmp = NULL; ini_item_t *section_item_tmp = NULL; ini_comment_t *item_comm_tmp = NULL; char buf[1024] = {0}; if((NULL == ini_file) || (NULL == ini_file->fd) || (NULL == path)) { printf("Ini save file error! The parameter is empty or configure file is wrong!\n"); return NULL; } fclose(ini_file->fd); FILE *fp = fopen(path, "w"); if (NULL == fp) { return NULL; } ini_file->fd = fp; if(doc->selections) { section_tmp = doc->selections; while(NULL != section_tmp) { sec_tmp = section_tmp; section_tmp = section_tmp->next; section_comm_tmp = sec_tmp->comments; while(NULL != section_comm_tmp) { comm_tmp = section_comm_tmp; section_comm_tmp = section_comm_tmp->next; fputs(comm_tmp->desc, ini_file->fd); fputs("\n", ini_file->fd); } fputs(sec_tmp->selection, ini_file->fd); fputs("\n", ini_file->fd); section_item_tmp = sec_tmp->ini_items; while(NULL != section_item_tmp) { item_tmp = section_item_tmp; section_item_tmp = section_item_tmp->next; item_comm_tmp = item_tmp->comments; while(NULL != item_comm_tmp) { comm_tmp = item_comm_tmp; item_comm_tmp = item_comm_tmp->next; fputs(comm_tmp->desc, ini_file->fd); fputs("\n", ini_file->fd); } strcpy(buf,item_tmp->name); strcat(buf,"="); strcat(buf,item_tmp->value); strcat(buf,"\n"); fputs(buf , ini_file->fd); } fputs("\n", ini_file->fd); } } fflush(ini_file->fd); close_ini(&doc); ini_file_t *new_doc = read_ini(path); ini_file = new_doc; return new_doc; }
/* * コンフィグファイルからパラメータを取得する */ void Param::readConfigFile() { boost::property_tree::ptree pt; read_ini(Param::PARAM_FILE_NAME, pt); //データベース接続関連 dbHost = pt.get<std::string>("db.host"); dbPort = pt.get<int> ("db.port"); dbSchema = pt.get<std::string>("db.schema"); dbUser = pt.get<std::string>("db.user"); dbPass = pt.get<std::string>("db.pass"); //SIGService名 generalServiceName = pt.get<std::string>("General.service_name"); //アバター表示更新間隔 sigAvatarDispInterval = pt.get<int> ("sigverse.avatar_disp_interval"); ////アバター移動速度 (1.0で通常速度) //sigAvatarMoveSpeed = pt.get<double> ("sigverse.avatar_move_speed"); imiAccumInterval = pt.get<int> ("imitation.accum_interval"); //動作データファイルパス(動作データをファイル入力する場合のみ指定) imiMotionDataFilePath = pt.get<std::string>("imitation.motion_data_file_path"); std::string imiMode = pt.get<std::string>("imitation.mode"); imiRecId = pt.get<int> ("imitation.rec_id"); imiUserId = pt.get<int> ("imitation.user_id"); imiOriginMaxTime = pt.get<int> ("imitation.origin_max_time"); imiImitationGroupId = pt.get<int> ("imitation.imitation_group_id"); imiImitationRecType = pt.get<int> ("imitation.imitation_rec_type"); imiImitationOriginRecId = pt.get<int> ("imitation.imitation_origin_rec_id"); imiDbPerceptionNeuronMemo = pt.get<std::string>("imitation.db_perception_neuron_memo"); imiDbImitationConditionPulsePower = pt.get<float> ("imitation.db_imitation_condition_pulse_power"); imiDbImitationConditionPulseFrequency = pt.get<float> ("imitation.db_imitation_condition_pulse_frequency"); imiDbImitationConditionPulseDuration = pt.get<int> ("imitation.db_imitation_condition_pulse_duration"); imiDbImitationConditionPulseInterval = pt.get<int> ("imitation.db_imitation_condition_pulse_interval"); imiDbImitationConditionPulseNumber = pt.get<int> ("imitation.db_imitation_condition_pulse_number"); imiDbImitationMemo = pt.get<std::string>("imitation.db_imitation_memo"); //表示 std::cout << "◆ コンフィグ内容 ◆" << std::endl; std::cout << "[db]host = " << dbHost << std::endl; std::cout << "[db]port = " << dbPort << std::endl; std::cout << "[db]schema = " << dbSchema << std::endl; std::cout << "[db]user = "******"[General]service_name = " << generalServiceName << std::endl; std::cout << "[sigverse]avatar_disp_interval = " << sigAvatarDispInterval << std::endl; std::cout << "[imitation]accum_interval = " << imiAccumInterval << std::endl; std::cout << "[imitation]motion_data_file_path = " << imiMotionDataFilePath << std::endl; std::cout << "[imitation]mode = " << imiMode << std::endl; std::cout << "[imitation]rec_id = " << imiRecId << std::endl; std::cout << "[imitation]user_id = " << imiUserId << std::endl; if (imiMode=="RecOrigin") { Param::mode = Mode::RecOrigin; std::cout << "[imitation]origin_max_time = " << imiOriginMaxTime << std::endl; } else if (imiMode == "Experiment") { Param::mode = Mode::Experiment; std::cout << "[imitation]imitation_group_id = " << imiImitationGroupId << std::endl; std::cout << "[imitation]imitation_rec_type = " << imiImitationRecType << std::endl; std::cout << "[imitation]imitation_origin_rec_id = " << imiImitationOriginRecId << std::endl; } else { std::cout << "illegal imitation mode! mode=" << imiMode << std::endl; exit(EXIT_FAILURE); } std::cout << "[imitation]db_perception_neuron_memo = " << imiDbPerceptionNeuronMemo << std::endl; std::cout << "[imitation]db_imitation_condition_pulse_power = " << imiDbImitationConditionPulsePower << std::endl; std::cout << "[imitation]db_imitation_condition_pulse_frequency = " << imiDbImitationConditionPulseFrequency << std::endl; std::cout << "[imitation]db_imitation_condition_pulse_duration = " << imiDbImitationConditionPulseDuration << std::endl; std::cout << "[imitation]db_imitation_condition_pulse_interval = " << imiDbImitationConditionPulseInterval << std::endl; std::cout << "[imitation]db_imitation_condition_pulse_number = " << imiDbImitationConditionPulseNumber << std::endl; std::cout << "[imitation]db_imitation_memo = " << imiDbImitationMemo << std::endl; }
int main(int argc, char **argv) { ROS_INFO_STREAM(argv[0] << " - iRabbit_RFID Copyright (C) 2015 Tarsbot"); ROS_INFO_STREAM("Distributed under the GNU GPL v3, see the included license file."); boost::property_tree::ptree m_pt, tag_setting; read_ini("./src/uhf_rfid_api/config/template_config.txt.in", m_pt); if (!ros::isInitialized()) { ros::init(argc, argv, "uhf_inventory_single_tag"); } ros::NodeHandle n; UhfRfidReader uhf_reader; uhf_reader.uhfReaderConnect(); uhf_rfid_api::UhfRfid msg; msg.header.stamp = ros::Time::now(); msg.header.frame_id = "1";// 1 global msg.header.seq = 0; ros::Publisher rfid_pub = n.advertise<uhf_rfid_api::UhfRfid>("messageepc", 25); ros::Rate rate(100);// sleep 0.1s int i = 0, k = 0, count = 0, flag = 0, f = 0, bagnum = 0; unsigned char *test = NULL; while (n.ok()) { f = uhf_reader.uhfGetVersion();//return 0 means all correct if(!f)//uhf_reader.uhfGetVersion successed { for(count = 0; count < 25; count++)//whether has tag { if(flag == 0)//unequal { if(mystrcmp((const char*)g_testarry[count], (const char*)uhf_reader.epcbuf24)==0) { flag = 1; break; } } }//end of for if(!flag)//new { if(k > 24)//assert the max num is 24 in a moment k = 0; for(i = 0; i < 24; i++) { g_testarry[k][i] = uhf_reader.epcbuf24[i]; } g_testarry[k][25] = uhf_reader.mybuff[5];//RSSI g_testarry[k][26] = 1;//count g_testarry[k][27] = '\0';//end character printf("if RSSI: %d", g_testarry[k][25]-256); printf(" count: %d\n", g_testarry[k][26]); bagnum = k; k++; }//end of !flag else { g_testarry[count][26]++; g_testarry[count][25] = uhf_reader.mybuff[5]; g_testarry[k][27] = '\0'; printf("else RSSI: %d", g_testarry[count][25]-256); printf(" count: %d\n", g_testarry[count][26]); bagnum = count; }//end of else flag = 0; //--------------------try read ini-------------------- std::string tagname = (const char*)uhf_reader.epcbuf24;//char* epc tag_setting = m_pt.get_child(tagname); int x = tag_setting.get<int>("pos_x",20); int y = tag_setting.get<int>("pos_y",20); tag_setting.clear(); //--------------------message-------------------- msg.header.stamp = ros::Time::now(); msg.header.seq++; msg.data = (char*)uhf_reader.epcbuf24; msg.pos_x = x; msg.pos_y = y; msg.RSSI = g_testarry[bagnum][25]-256;//always remember if U want to get the real RSSI,subtract 256 msg.count = g_testarry[bagnum][26]; }//end of !f else { //--------------------message-------------------- msg.header.stamp = ros::Time::now(); msg.header.seq++; msg.data = '\0';//string epc msg.pos_x = 0; msg.pos_y = 0; msg.RSSI = 0; msg.count = 0; } rfid_pub.publish(msg); msg.data.clear(); if(!rfid_pub) { continue; } ros::spinOnce(); }//end of while return 0; } // end main
int DEFAULT_CC main(int argc, char **argv) { tbus waiters[4]; int pid = 0; char text[256]; char *home_text; char *display_text; char log_file[256]; enum logReturns error; struct log_config logconfig; g_init("xrdp-chansrv"); /* os_calls */ home_text = g_getenv("HOME"); if (home_text == 0) { g_writeln("error reading HOME environment variable"); g_deinit(); return 1; } read_ini(); pid = g_getpid(); /* starting logging subsystem */ g_memset(&logconfig, 0, sizeof(struct log_config)); logconfig.program_name = "XRDP-Chansrv"; g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", home_text); g_writeln("chansrv::main: using log file [%s]", log_file); if (g_file_exist(log_file)) { g_file_delete(log_file); } logconfig.log_file = log_file; logconfig.fd = -1; logconfig.log_level = LOG_LEVEL_ERROR; logconfig.enable_syslog = 0; logconfig.syslog_level = 0; error = log_start_from_param(&logconfig); if (error != LOG_STARTUP_OK) { switch (error) { case LOG_ERROR_MALLOC: g_writeln("error on malloc. cannot start logging. quitting."); break; case LOG_ERROR_FILE_OPEN: g_writeln("error opening log file [%s]. quitting.", getLogFile(text, 255)); break; default: g_writeln("log_start error"); break; } g_deinit(); return 1; } LOGM((LOG_LEVEL_ALWAYS, "main: app started pid %d(0x%8.8x)", pid, pid)); /* set up signal handler */ g_signal_kill(term_signal_handler); /* SIGKILL */ g_signal_terminate(term_signal_handler); /* SIGTERM */ g_signal_user_interrupt(term_signal_handler); /* SIGINT */ g_signal_pipe(nil_signal_handler); /* SIGPIPE */ g_signal_child_stop(child_signal_handler); /* SIGCHLD */ display_text = g_getenv("DISPLAY"); LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text)); get_display_num_from_display(display_text); if (g_display_num == 0) { LOGM((LOG_LEVEL_ERROR, "main: error, display is zero")); g_deinit(); return 1; } LOGM((LOG_LEVEL_INFO, "main: using DISPLAY %d", g_display_num)); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid); g_term_event = g_create_wait_obj(text); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_thread_done", pid); g_thread_done_event = g_create_wait_obj(text); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_exec", pid); g_exec_event = g_create_wait_obj(text); g_exec_mutex = tc_mutex_create(); g_exec_sem = tc_sem_create(0); tc_thread_create(channel_thread_loop, 0); while (g_term_event > 0 && !g_is_wait_obj_set(g_term_event)) { waiters[0] = g_term_event; waiters[1] = g_exec_event; if (g_obj_wait(waiters, 2, 0, 0, 0) != 0) { LOGM((LOG_LEVEL_ERROR, "main: error, g_obj_wait failed")); break; } if (g_is_wait_obj_set(g_term_event)) { break; } if (g_is_wait_obj_set(g_exec_event)) { g_reset_wait_obj(g_exec_event); run_exec(); } } while (g_thread_done_event > 0 && !g_is_wait_obj_set(g_thread_done_event)) { /* wait for thread to exit */ if (g_obj_wait(&g_thread_done_event, 1, 0, 0, 0) != 0) { LOGM((LOG_LEVEL_ERROR, "main: error, g_obj_wait failed")); break; } } /* cleanup */ main_cleanup(); LOGM((LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid)); g_deinit(); return 0; }