Changeset 11575 for trunk/FACT++/src/fscctrl.cc
- Timestamp:
- 07/24/11 21:00:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fscctrl.cc
r11574 r11575 520 520 #include "Main.h" 521 521 522 /*523 void RunThread(StateMachineImp *io_service)524 {525 // This is necessary so that the StateMachien Thread can signal the526 // Readline to exit527 io_service->Run();528 Readline::Stop();529 }530 */531 /*532 template<class S, class T>533 int RunDim(Configuration &conf)534 {535 WindowLog wout;536 537 ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);538 539 540 if (conf.Has("log"))541 if (!wout.OpenLogFile(conf.Get<string>("log")))542 wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;543 544 // Start io_service.Run to use the StateMachineImp::Run() loop545 // Start io_service.run to only use the commandHandler command detaching546 StateMachineFSC<S, T> io_service(wout);547 if (!io_service.EvalConfiguration(conf))548 return -1;549 550 io_service.Run();551 552 return 0;553 }554 */555 556 522 template<class T, class S, class R> 557 523 int RunShell(Configuration &conf) 558 524 { 559 return Main<T, StateMachineFSC<S, R>>(conf); 560 /* 561 static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1); 562 563 WindowLog &win = shell.GetStreamIn(); 564 WindowLog &wout = shell.GetStreamOut(); 565 566 if (conf.Has("log")) 567 if (!wout.OpenLogFile(conf.Get<string>("log"))) 568 win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl; 569 570 StateMachineFSC<S, R> io_service(wout); 571 if (!io_service.EvalConfiguration(conf)) 572 return -1; 573 574 shell.SetReceiver(io_service); 575 576 boost::thread t(boost::bind(RunThread, &io_service)); 577 // boost::thread t(boost::bind(&StateMachineFSC<S>::Run, &io_service)); 578 579 if (conf.Has("cmd")) 580 { 581 const vector<string> v = conf.Get<vector<string>>("cmd"); 582 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 583 shell.ProcessLine(*it); 584 } 585 586 if (conf.Has("exec")) 587 { 588 const vector<string> v = conf.Get<vector<string>>("exec"); 589 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 590 shell.Execute(*it); 591 } 592 593 if (conf.Get<bool>("quit")) 594 shell.Stop(); 595 596 shell.Run(); // Run the shell 597 io_service.Stop(); // Signal Loop-thread to stop 598 // io_service.Close(); // Obsolete, done by the destructor 599 600 // Wait until the StateMachine has finished its thread 601 // before returning and destroying the dim objects which might 602 // still be in use. 603 t.join(); 604 605 return 0; 606 */ 525 return Main::execute<T, StateMachineFSC<S, R>>(conf); 607 526 } 608 527 609 528 void SetupConfiguration(Configuration &conf) 610 529 { 611 const string n = conf.GetName()+".log";612 613 po::options_description config("Program options");614 config.add_options()615 ("dns", var<string>("localhost"), "Dim nameserver (overwites DIM_DNS_NODE environment variable)")616 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")617 ("log,l", var<string>(n), "Write log-file")618 ("no-dim,d", po_bool(), "Disable dim services")619 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")620 ("cmd", vars<string>(), "Execute one or more commands at startup")621 ("exec,e", vars<string>(), "Execute one or more scrips at startup")622 ("quit,q", po_switch(), "Quit after startup");623 ;624 625 530 po::options_description control("FTM control options"); 626 531 control.add_options() … … 629 534 ; 630 535 631 conf.AddEnv("dns", "DIM_DNS_NODE");632 conf.AddEnv("host", "DIM_HOST_NODE");633 634 conf.AddOptions(config);635 536 conf.AddOptions(control); 636 537 } … … 684 585 Configuration conf(argv[0]); 685 586 conf.SetPrintUsage(PrintUsage); 587 Main::SetupConfiguration(conf); 686 588 SetupConfiguration(conf); 687 589
Note:
See TracChangeset
for help on using the changeset viewer.