Changeset 11575 for trunk/FACT++/src/ftmctrl.cc
- Timestamp:
- 07/24/11 21:00:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r11574 r11575 2331 2331 #include "Main.h" 2332 2332 2333 /*2334 void RunThread(StateMachineImp *io_service)2335 {2336 // This is necessary so that the StateMachien Thread can signal the2337 // Readline to exit2338 io_service->Run();2339 Readline::Stop();2340 }2341 */2342 /*2343 template<class S, class T>2344 int RunDim(Configuration &conf)2345 {2346 WindowLog wout;2347 2348 ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);2349 2350 if (conf.Has("log"))2351 if (!wout.OpenLogFile(conf.Get<string>("log")))2352 wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;2353 2354 // Start io_service.Run to use the StateMachineImp::Run() loop2355 // Start io_service.run to only use the commandHandler command detaching2356 StateMachineFTM<S, T> io_service(wout);2357 if (!io_service.EvalConfiguration(conf))2358 return -1;2359 2360 io_service.Run();2361 2362 return 0;2363 }2364 */2365 2366 2333 template<class T, class S, class R> 2367 2334 int RunShell(Configuration &conf) 2368 2335 { 2369 return Main<T, StateMachineFTM<S, R>>(conf); 2370 /* 2371 static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1); 2372 2373 WindowLog &win = shell.GetStreamIn(); 2374 WindowLog &wout = shell.GetStreamOut(); 2375 2376 if (conf.Has("log")) 2377 if (!wout.OpenLogFile(conf.Get<string>("log"))) 2378 win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl; 2379 2380 StateMachineFTM<S, R> io_service(wout); 2381 if (!io_service.EvalConfiguration(conf)) 2382 return -1; 2383 2384 shell.SetReceiver(io_service); 2385 2386 boost::thread t(bind(RunThread, &io_service)); 2387 // boost::thread t(bind(&StateMachineFTM<S>::Run, &io_service)); 2388 2389 if (conf.Has("cmd")) 2390 { 2391 const vector<string> v = conf.Get<vector<string>>("cmd"); 2392 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 2393 shell.ProcessLine(*it); 2394 } 2395 2396 if (conf.Has("exec")) 2397 { 2398 const vector<string> v = conf.Get<vector<string>>("exec"); 2399 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 2400 shell.Execute(*it); 2401 } 2402 2403 if (conf.Get<bool>("quit")) 2404 shell.Stop(); 2405 2406 shell.Run(); // Run the shell 2407 io_service.Stop(); // Signal Loop-thread to stop 2408 // io_service.Close(); // Obsolete, done by the destructor 2409 2410 // Wait until the StateMachine has finished its thread 2411 // before returning and destroying the dim objects which might 2412 // still be in use. 2413 t.join(); 2414 2415 return 0; 2416 */ 2336 return Main::execute<T, StateMachineFTM<S, R>>(conf); 2417 2337 } 2418 2338 2419 2339 void SetupConfiguration(Configuration &conf) 2420 2340 { 2421 const string n = conf.GetName()+".log";2422 2423 po::options_description config("Program options");2424 config.add_options()2425 ("dns", var<string>("localhost"), "Dim nameserver (overwites DIM_DNS_NODE environment variable)")2426 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")2427 ("no-dim,d", po_bool(), "Disable dim services")2428 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")2429 ("cmd", vars<string>(), "Execute one or more commands at startup")2430 ("exec,e", vars<string>(), "Execute one or more scrips at startup")2431 ("quit", po_switch(), "Quit after startup");2432 ;2433 2434 2341 po::options_description control("Control options"); 2435 2342 control.add_options() 2343 ("no-dim", po_bool(), "Disable dim services") 2436 2344 ("addr,a", var<string>("localhost:5000"), "Network address of FTM") 2437 2345 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") … … 2481 2389 ; 2482 2390 2483 conf.AddEnv("dns", "DIM_DNS_NODE");2484 conf.AddEnv("host", "DIM_HOST_NODE");2485 2486 conf.AddOptions(config);2487 2391 conf.AddOptions(control); 2488 2392 conf.AddOptions(runtype); … … 2537 2441 Configuration conf(argv[0]); 2538 2442 conf.SetPrintUsage(PrintUsage); 2443 Main::SetupConfiguration(conf); 2539 2444 SetupConfiguration(conf); 2540 2445
Note:
See TracChangeset
for help on using the changeset viewer.