corba_mqueue_ipc_server.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:54:57 CEST 2010  corba_mqueue_ipc_server.cpp
00003 
00004                         corba_mqueue_ipc_server.cpp -  description
00005                            -------------------
00006     begin                : Tue September 07 2010
00007     copyright            : (C) 2010 The SourceWorks
00008     email                : peter@thesourceworks.com
00009 
00010  ***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 
00020 // need access to all TLSF functions embedded in RTT
00021 // this call must occur before ALL RTT include's!!
00022 #define ORO_MEMORY_POOL
00023 #include <rtt/os/tlsf/tlsf.h>
00024 
00025 #include <transports/corba/TaskContextServer.hpp>
00026 #include <transports/corba/TaskContextProxy.hpp>
00027 #include <rtt/Port.hpp>
00028 #include <rtt/plugin/PluginLoader.hpp>
00029 #include <os/main.h>
00030 #include <fstream>
00031 
00032 using namespace std;
00033 using namespace RTT;
00034 using namespace RTT::detail;
00035 
00036 class TheServer : public TaskContext
00037 {
00038 public:
00039     // Ports
00040     InputPort<double>  mi1;
00041     OutputPort<double> mo1;
00042 
00043     TheServer(string name) : TaskContext(name), mi1("mr"), mo1("mw") {
00044         ports()->addEventPort( mi1 );
00045         ports()->addPort( mo1 );
00046         this->start();
00047         ts = corba::TaskContextServer::Create( this, /* use_naming = */ true );
00048     }
00049     ~TheServer() {
00050         this->stop();
00051     }
00052 
00053     void updateHook(){
00054         double d = 123456.789;
00055         mi1.read(d);
00056         mo1.write(d);
00057     }
00058 
00059     corba::TaskContextServer* ts;
00060 
00061 };
00062 
00063 int ORO_main(int argc, char** argv)
00064 {
00065 #ifdef OS_RT_MALLOC
00066         void*   rtMem=0;
00067         size_t  freeMem=0;
00068 
00070         rtMem           = malloc(BUILD_TEST_RT_MEM_POOL_SIZE);  // don't calloc() as is first thing TLSF does.
00071         assert(0 != rtMem);
00072         freeMem         = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
00073         assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
00074 #endif
00075     corba::TaskContextProxy::InitOrb(argc,argv);
00076 
00077     PluginLoader::Instance()->loadTypekits("../rtt");
00078 
00079 #ifndef WIN32
00080     pid_t pid = getpid();
00081     std::ofstream pidfile("corba-mqueue-ipc-server.pid");
00082     pidfile << pid << endl;
00083     pidfile.close();
00084 #endif
00085 
00086     {
00087         TheServer cmt("other");
00088         corba::TaskContextServer::RunOrb();
00089     }
00090     corba::TaskContextServer::ShutdownOrb(true);
00091     corba::TaskContextServer::DestroyOrb();
00092     return 0;
00093 }
00094 
00095 


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:06