27 #include <rtt/rtt-config.h> 30 #define ORO_MEMORY_POOL 43 #ifdef ORO_BUILD_LOGGING 45 # warning "Logging needs rtalloc!" 53 namespace po = boost::program_options;
55 int main(
int argc,
char** argv)
58 std::vector<std::string> scriptFiles;
59 std::string name(
"Deployer");
60 bool requireNameService =
false;
61 bool deploymentOnlyChecked =
false;
64 po::options_description taoOptions(
"Additional options after a '--' are passed through to TAO");
67 po::options_description otherOptions;
69 #ifdef ORO_BUILD_RTALLOC 70 OCL::memorySize rtallocMemorySize = ORO_DEFAULT_RTALLOC_SIZE;
71 po::options_description rtallocOptions = OCL::deployerRtallocOptions(rtallocMemorySize);
72 otherOptions.add(rtallocOptions);
73 OCL::TLSFMemoryPool memoryPool;
76 #if defined(ORO_BUILD_LOGGING) && defined(OROSEM_LOG4CPP_LOGGING) 78 std::string rttLog4cppConfigFile;
79 po::options_description rttLog4cppOptions = OCL::deployerRttLog4cppOptions(rttLog4cppConfigFile);
80 otherOptions.add(rttLog4cppOptions);
84 otherOptions.add(taoOptions);
90 while(!found && optIndex<argc)
92 found = (0 == strcmp(
"--", argv[optIndex]));
93 if(!found) optIndex++;
97 argv[optIndex] = argv[0];
103 siteFile, scriptFiles, name, requireNameService, deploymentOnlyChecked,
118 #if defined(ORO_BUILD_LOGGING) && defined(OROSEM_LOG4CPP_LOGGING) 119 if (!OCL::deployerConfigureRttLog4cppCategory(rttLog4cppConfigFile))
125 #ifdef ORO_BUILD_RTALLOC 126 if (!memoryPool.initialize(rtallocMemorySize.size))
130 #endif // ORO_BUILD_RTALLOC 132 #ifdef ORO_BUILD_LOGGING 143 if (0 ==
__os_init(argc - optIndex, &argv[optIndex]))
145 #ifdef ORO_BUILD_LOGGING 146 log(
Info) <<
"OCL factory set for real-time logging" <<
endlog();
170 for (std::vector<std::string>::const_iterator iter=scriptFiles.begin();
171 iter!=scriptFiles.end() && result;
174 if ( !(*iter).empty() )
176 if ( (*iter).rfind(
".xml", std::string::npos) == (*iter).length() - 4 ||
177 (*iter).rfind(
".cpf", std::string::npos) == (*iter).length() - 4) {
178 if ( deploymentOnlyChecked ) {
180 bool configureOk =
true;
182 if (!dc.
kickStart2( (*iter),
false, loadOk, configureOk, startOk )) {
185 log(
Error) <<
"Failed to load file: '"<< (*iter) <<
"'." <<
endlog();
186 }
else if (!configureOk) {
187 log(
Error) <<
"Failed to configure file: '"<< (*iter) <<
"'." <<
endlog();
193 result = dc.
kickStart( (*iter) ) && result;
198 if ( (*iter).rfind(
".ops", std::string::npos) == (*iter).length() - 4 ||
199 (*iter).rfind(
".osd", std::string::npos) == (*iter).length() - 4 ||
200 (*iter).rfind(
".lua", std::string::npos) == (*iter).length() - 4) {
201 result = dc.
runScript( (*iter) ) && result;
205 log(
Error) <<
"Unknown extension of file: '"<< (*iter) <<
"'. Must be xml, cpf for XML files or, ops, osd or lua for script files."<<
endlog();
208 rc = (result ? 0 : -1);
211 if ( !deploymentOnlyChecked ) {
220 }
catch( CORBA::Exception &e ) {
233 std::cerr <<
"Unable to start Orocos" << std::endl;
237 #ifdef ORO_BUILD_LOGGING 242 #ifdef ORO_BUILD_RTALLOC 243 memoryPool.shutdown();
bool kickStart2(const std::string &configurationfile, const bool doStart, bool &loadOk, bool &configureOk, bool &startOk)
int __os_init(int argc, char **argv)
virtual void deleteAllCategories()
static void set_category_factory(creator_function_t creator_function)
static std::ostream & nl(std::ostream &__os)
#define CORBA_EXCEPTION_INFO(x)
int deployerParseCmdLine(int argc, char **argv, std::string &siteFile, std::vector< std::string > &scriptFiles, std::string &name, bool &requireNameService, bool &deploymentOnlyChecked, int &minNumberCPU, po::variables_map &vm, po::options_description *otherOptions)
static RTT_CORBA_API bool InitOrb(int argc, char *argv[], Seconds orb_timeout=0)
int main(int argc, char **argv)
static TaskContextServer * Create(TaskContext *tc, bool use_naming=true, bool require_name_service=false)
bool kickStart(const std::string &file_name)
static log4cpp::Category * createOCLCategory(const std::string &name, log4cpp::Category *parent, log4cpp::Priority::Value priority)
static HierarchyMaintainer & getDefaultMaintainer()
bool runScript(const std::string &file_name)
static void ShutdownOrb(bool wait_for_completion=true)
int enforceMinNumberCPU(const int minNumberCPU)
static Logger::LogFunction endlog()