Changeset 11575 for trunk/FACT++/src/fadctrl.cc
- Timestamp:
- 07/24/11 21:00:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fadctrl.cc
r11574 r11575 1974 1974 #include "Main.h" 1975 1975 1976 /*1977 void RunThread(StateMachineImp *io_service)1978 {1979 // This is necessary so that the StateMachien Thread can signal the1980 // Readline to exit1981 io_service->Run();1982 Readline::Stop();1983 }1984 */1985 /*1986 template<class S>1987 int RunDim(Configuration &conf)1988 {1989 WindowLog wout;1990 1991 ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);1992 1993 if (conf.Has("log"))1994 if (!wout.OpenLogFile(conf.Get<string>("log")))1995 wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;1996 1997 // Start io_service.Run to use the StateMachineImp::Run() loop1998 // Start io_service.run to only use the commandHandler command detaching1999 StateMachineFAD<S> io_service(wout);2000 if (!io_service.EvalConfiguration(conf))2001 return -1;2002 2003 io_service.Run();2004 2005 return 0;2006 }2007 */2008 2009 1976 template<class T, class S> 2010 1977 int RunShell(Configuration &conf) 2011 1978 { 2012 return Main<T, StateMachineFAD<S>>(conf); 2013 /* 2014 static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1); 2015 2016 WindowLog &win = shell.GetStreamIn(); 2017 WindowLog &wout = shell.GetStreamOut(); 2018 2019 if (conf.Has("log")) 2020 if (!wout.OpenLogFile(conf.Get<string>("log"))) 2021 win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl; 2022 2023 StateMachineFAD<S> io_service(wout); 2024 if (!io_service.EvalConfiguration(conf)) 2025 return -1; 2026 2027 shell.SetReceiver(io_service); 2028 2029 boost::thread t(bind(RunThread, &io_service)); 2030 //boost::thread t(bind(&StateMachineFAD<S>::Run, &io_service)); 2031 2032 if (conf.Has("cmd")) 2033 { 2034 const vector<string> v = conf.Get<vector<string>>("cmd"); 2035 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 2036 shell.ProcessLine(*it); 2037 } 2038 2039 if (conf.Has("exec")) 2040 { 2041 const vector<string> v = conf.Get<vector<string>>("exec"); 2042 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 2043 shell.Execute(*it); 2044 } 2045 2046 if (conf.Get<bool>("quit")) 2047 shell.Stop(); 2048 2049 shell.Run(); // Run the shell 2050 io_service.Stop(); // Signal Loop-thread to stop 2051 2052 // Wait until the StateMachine has finished its thread 2053 // before returning and destroying the dim objects which might 2054 // still be in use. 2055 t.join(); 2056 2057 return 0; 2058 */ 1979 return Main::execute<T, StateMachineFAD<S>>(conf); 2059 1980 } 2060 1981 2061 1982 void SetupConfiguration(Configuration &conf) 2062 1983 { 2063 const string n = conf.GetName()+".log";2064 2065 po::options_description config("Program options");2066 config.add_options()2067 ("dns", var<string>("localhost"), "Dim nameserver (overwites DIM_DNS_NODE environment variable)")2068 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")2069 ("log,l", var<string>(n), "Write log-file")2070 // ("no-dim,d", po_switch(), "Disable dim services")2071 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")2072 ("cmd", vars<string>(), "Execute one or more commands at startup")2073 ("exec,e", vars<string>(), "Execute one or more scrips at startup")2074 ("quit", po_switch(), "Quit after startup");2075 ;2076 2077 1984 po::options_description control("FAD control options"); 2078 1985 control.add_options() … … 2128 2035 conf.AddEnv("host", "DIM_HOST_NODE"); 2129 2036 2130 conf.AddOptions(config);2131 2037 conf.AddOptions(control); 2132 2038 conf.AddOptions(connect); … … 2160 2066 Configuration conf(argv[0]); 2161 2067 conf.SetPrintUsage(PrintUsage); 2068 Main::SetupConfiguration(conf); 2162 2069 SetupConfiguration(conf); 2163 2070
Note:
See TracChangeset
for help on using the changeset viewer.