35 #include <rtt/rtt-config.h> 38 #define ORO_MEMORY_POOL 39 #include <rtt/os/tlsf/tlsf.h> 41 #include <rtt/os/main.h> 42 #include <rtt/RTT.hpp> 43 #include <rtt/Logger.hpp> 44 #ifdef ORO_BUILD_LOGGING 46 # warning "Logging needs rtalloc!" 48 #include <log4cpp/HierarchyMaintainer.hh> 49 #include "logging/Category.hpp" 54 void dotty (lua_State *L);
55 void l_message (
const char *pname,
const char *msg);
56 int dofile (lua_State *L,
const char *name);
57 int dostring (lua_State *L,
const char *s,
const char *name);
58 int main_args(lua_State *L,
int argc,
char **argv);
60 #include <sys/types.h> 66 #include "LuaComponent.hpp" 67 #include <rtt/os/main.h> 72 #if defined(LUA_RTT_CORBA) 73 #include <rtt/transports/corba/TaskContextServer.hpp> 74 #include <deployment/CorbaDeploymentComponent.hpp> 76 #include <deployment/DeploymentComponent.hpp> 80 #define LuaComponent LuaTLSFComponent 82 #define LuaComponent LuaComponent 85 #define INIT_FILE "~/.rttlua" 90 #if defined(LUA_RTT_CORBA) 91 using namespace RTT::corba;
94 int ORO_main(
int argc,
char** argv)
99 #ifdef ORO_BUILD_RTALLOC 100 size_t memSize = ORO_DEFAULT_RTALLOC_SIZE;
106 rtMem = malloc(memSize);
108 freeMem = init_memory_pool(memSize, rtMem);
109 if ((
size_t)-1 == freeMem)
111 cerr <<
"Invalid memory pool size of " << memSize
112 <<
" bytes (TLSF has a several kilobyte overhead)." << endl;
116 cout <<
"Real-time memory: " << freeMem <<
" bytes free of " 117 << memSize <<
" allocated." << endl;
119 #endif // ORO_BUILD_RTALLOC 121 #ifdef ORO_BUILD_LOGGING 122 log4cpp::HierarchyMaintainer::set_category_factory(
129 #if defined(LUA_RTT_CORBA) 136 if(0 == strcmp(
"--", argv[argc - orb_argc])) {
137 orb_sep = argv[argc - orb_argc];
138 argv[argc - orb_argc] = argv[0];
139 orb_argv = &argv[argc - orb_argc];
149 TaskContextServer::InitOrb(orb_argc, orb_argv);
153 TaskContextServer::Create( dc,
true,
true );
156 TaskContextServer::ThreadOrb();
158 catch( CORBA::Exception &e ) {
159 log(Error) << argv[0] <<
" ORO_main : CORBA exception raised!" << Logger::nl;
160 log() << CORBA_EXCEPTION_INFO(e) << endlog();
167 log(Error) <<
"Uncaught exception." << endlog();
175 argv[argc] = dc?NULL:orb_sep;
183 lua.connectPeers(dc);
186 wordexp(INIT_FILE, &init_exp, 0);
187 if(stat(init_exp.we_wordv[0], &stb) != -1) {
188 if((stb.st_mode & S_IFMT) != S_IFREG)
189 cout <<
"rttlua: warning: init file " << init_exp.we_wordv[0] <<
" is not a regular file" << endl;
191 lua.exec_file(init_exp.we_wordv[0]);
195 main_args(lua.getLuaState().get(), argc, argv);
197 #if defined(LUA_RTT_CORBA) 199 TaskContextServer::ShutdownOrb();
200 TaskContextServer::DestroyOrb();
206 #ifdef ORO_BUILD_LOGGING 207 log4cpp::HierarchyMaintainer::getDefaultMaintainer().shutdown();
208 log4cpp::HierarchyMaintainer::getDefaultMaintainer().deleteAllCategories();
211 #ifdef ORO_BUILD_RTALLOC 214 std::cout <<
"TLSF bytes allocated=" << memSize
215 <<
" overhead=" << (memSize - freeMem)
216 <<
" max-used=" << get_max_size(rtMem)
217 <<
" currently-used=" << get_used_size(rtMem)
218 <<
" still-allocated=" << (get_used_size(rtMem) - (memSize - freeMem))
221 destroy_memory_pool(rtMem);
static log4cpp::Category * createOCLCategory(const std::string &name, log4cpp::Category *parent, log4cpp::Priority::Value priority)
Factory function for log4cpp::HierarchyMaintainer Creates an OCL logging category.
The Orocos Component Library.
A Component for deploying (configuring) other components in an application.