corba_mqueue_ipc_server.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:54:57 CEST 2010 corba_mqueue_ipc_server.cpp
3 
4  corba_mqueue_ipc_server.cpp - description
5  -------------------
6  begin : Tue September 07 2010
7  copyright : (C) 2010 The SourceWorks
8  email : peter@thesourceworks.com
9 
10  ***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 
20 // need access to all TLSF functions embedded in RTT
21 // this call must occur before ALL RTT include's!!
22 #define ORO_MEMORY_POOL
23 #include <rtt/os/tlsf/tlsf.h>
24 
27 #include <rtt/Port.hpp>
29 #include <os/main.h>
30 #include <fstream>
31 
32 using namespace std;
33 using namespace RTT;
34 using namespace RTT::detail;
35 
36 class TheServer : public TaskContext
37 {
38 public:
39  // Ports
42 
43  TheServer(string name) : TaskContext(name), mi1("mr"), mo1("mw") {
44  ports()->addEventPort( mi1 );
45  ports()->addPort( mo1 );
46  this->start();
47  ts = corba::TaskContextServer::Create( this, /* use_naming = */ true );
48  }
50  this->stop();
51  }
52 
53  void updateHook(){
54  log(Info) << "Received data on port" <<endlog();
55  double d = 123456.789;
56  FlowStatus fs = NoData;
57  while( (fs = mi1.read(d, false)) == NewData ) {
58  mo1.write(d);
59  }
60  }
61 
63 
64 };
65 
66 int ORO_main(int argc, char** argv)
67 {
68 #ifdef OS_RT_MALLOC
69  void* rtMem=0;
70  size_t freeMem=0;
71 
73  rtMem = malloc(BUILD_TEST_RT_MEM_POOL_SIZE); // don't calloc() as is first thing TLSF does.
74  assert(0 != rtMem);
75  freeMem = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
76  assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
77  (void)freeMem; // avoid compiler warning
78 #endif
79  corba::TaskContextProxy::InitOrb(argc,argv);
80 
81  PluginLoader::Instance()->loadTypekits("../rtt");
82 
83 #ifndef WIN32
84  pid_t pid = getpid();
85  std::ofstream pidfile("corba-mqueue-ipc-server.pid");
86  pidfile << pid << endl;
87  pidfile.close();
88 #endif
89 
90  {
91  TheServer cmt("other");
92  corba::TaskContextServer::RunOrb();
93  }
94  corba::TaskContextServer::ShutdownOrb(true);
95  corba::TaskContextServer::DestroyOrb();
96  return 0;
97 }
98 
99 
FlowStatus
Definition: FlowStatus.hpp:56
Definition: mystd.hpp:163
size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
Definition: tlsf.c:497
FlowStatus read(base::DataSourceBase::shared_ptr source)
Definition: InputPort.hpp:97
TheServer(string name)
WriteStatus write(const T &sample)
Definition: OutputPort.hpp:243
basic_ostreams & endl(basic_ostreams &s)
Definition: rtstreams.cpp:110
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
static Logger & log()
Definition: Logger.hpp:350
static Logger::LogFunction endlog()
Definition: Logger.hpp:362
int ORO_main(int argc, char **argv)


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:23