int main(int argc, char** argv) { cfg.path("../../setup"); cfg.args("detector.webcam.provider.", argv); if (argc == 1) cfg.load("config.csv"); bool verbose = cfg.flag("detector.webcam.provider.verbose", true); if (verbose) cfg.show(); int indexR = (int)cfg.num("detector.webcam.provider.indexR"); int indexL = (int)cfg.num("detector.webcam.provider.indexL"); int sleep_time = (int)cfg.num("detector.webcam.provider.sleep_time"); std::string addressf = cfg.str("detector.webcam.provider.f_ip").c_str(); std::string addressc = cfg.str("detector.webcam.provider.c_ip").c_str(); std::string port = cfg.str("detector.webcam.provider.port").c_str(); signal(SIGINT, quitproc); signal(SIGTERM, quitproc); signal(SIGQUIT, quitproc); webcamProvider p(indexR, indexL, sleep_time, verbose, argv[0], addressf.c_str(), addressc.c_str(), port); ghost = &p; if(p.init()) { //p.rotate(); p.provide(); } return 0; }
/// 读取配置数据 void loadConfig() { config.load(); printf("FrontAddress=%s\n",config.FrontAddress); printf("BrokerID=%s\n",config.BrokerID); printf("UserID=%s\n",config.UserID); printf("Password=%s\n",config.Password); printf("RequestPipe=%s\n",config.RequestPipe); printf("PushbackPipe=%s\n",config.PushbackPipe); printf("PublishPipe=%s\n",config.PublishPipe); }
void test03() { config.load(); CThostFtdcInstrumentField pInstrument; CThostFtdcRspInfoField pRspInfo; int nRequestID; bool bIsLast; CTraderHandler traderHandler = CTraderHandler(&config); while(1) { traderHandler.OnRspQryInstrument(&pInstrument,&pRspInfo,nRequestID,bIsLast); //traderHandler.OnRspQryInstrument(0,&pRspInfo,nRequestID,bIsLast); std::cout << "message send ..." << std::endl; getchar(); } }
int main(int argc, char *argv[]) { cfg.path("../../setup"); cfg.args("proxyservos.",argv); if (argc == 1) cfg.load("config.csv"); cfg.servos(); verbose = cfg.flag("proxyservos.verbose",false); if (verbose) cfg.show(); server = ProxyServoListenerSP(new ProxyServoListener()); signal(SIGINT, quit); signal(SIGTERM, quit); signal(SIGQUIT, quit); while (server) { usleep(int(0.25*1e6)); } std::cout << "done" << std::endl; return 0; }
int main(int argc, char** argv) { pid_t leapd_pid; if ((leapd_pid=fork()) == 0) { execl("/usr/bin/leapd","leapd",0); } cfg.path("../../setup"); cfg.args("leap.provider.", argv); if (argc == 1) cfg.load("config.csv"); verbose = cfg.flag("leap.provider.verbose", false); if (verbose) cfg.show(); decay_time = cfg.num("leap.provider.decay_time"); int hwm = 1; int retries = 5; int linger = 25; int rc = 0; bool connected = false; MyListener listener; Controller controller(listener); zmq_context = zmq_ctx_new (); zmq_pub = zmq_socket(zmq_context,ZMQ_PUB); while(!connected && retries--) { if(zmq_setsockopt(zmq_pub, ZMQ_SNDHWM, &hwm, sizeof(hwm)) == 0) { if(zmq_setsockopt(zmq_pub, ZMQ_LINGER, &linger, sizeof(linger)) == 0) { if(zmq_bind(zmq_pub, cfg.str("leap.provider.publish").c_str()) == 0) { connected = true; } } } if (retries <= 0) { int en=zmq_errno(); std::cout << "TCP Error Number " << en << " " << zmq_strerror(en) << std::endl; die = true; } std::this_thread::sleep_for(std::chrono::milliseconds(200)); } signal(SIGINT, quitproc); signal(SIGTERM, quitproc); signal(SIGQUIT, quitproc); while(!die) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); } controller.removeListener(listener); zmq_close(zmq_pub); zmq_ctx_destroy(zmq_context); kill(leapd_pid,SIGINT); waitpid(leapd_pid,0,0); std::cout << "--done!" << std::endl; return 0; }