00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <blackboard/remote.h>
00028 #include <blackboard/local.h>
00029 #include <blackboard/exceptions.h>
00030 #include <blackboard/bbconfig.h>
00031 #include <netcomm/fawkes/server_thread.h>
00032
00033 #include <interfaces/ObjectPositionInterface.h>
00034
00035 #include <core/exceptions/system.h>
00036 #include <utils/logging/liblogger.h>
00037 #include <utils/time/tracker.h>
00038
00039 #include <signal.h>
00040 #include <cstdlib>
00041
00042 #include <iostream>
00043 #include <vector>
00044
00045 using namespace std;
00046 using namespace fawkes;
00047
00048 bool quit = false;
00049
00050 void handle_signal(int signum)
00051 {
00052 quit = true;
00053 }
00054
00055 int
00056 main(int argc, char **argv)
00057 {
00058 signal(SIGINT, handle_signal);
00059
00060 LibLogger::init();
00061
00062 LocalBlackBoard *lbb = new LocalBlackBoard(BLACKBOARD_MEMSIZE);
00063 BlackBoard *bb = lbb;
00064 FawkesNetworkServerThread *netthread = new FawkesNetworkServerThread(1910);
00065 netthread->start();
00066 lbb->start_nethandler(netthread);
00067
00068 std::list<ObjectPositionInterface *> interfaces;
00069
00070 cout << "Opening interfaces" << endl;
00071 for (int i = 1; i <= 15; ++i) {
00072 char tmp[100];
00073 sprintf(tmp, "legtracker Leg %i", i);
00074 printf(" %s\n", tmp);
00075 ObjectPositionInterface *iface = bb->open_for_writing<ObjectPositionInterface>(tmp);
00076 interfaces.push_back(iface);
00077 }
00078
00079 srand(time(NULL));
00080
00081 TimeTracker tt;
00082 unsigned int ttc_write = tt.add_class("Write");
00083
00084 int u = 0;
00085 while ( ! quit) {
00086 for (std::list<ObjectPositionInterface *>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) {
00087 int r = rand() % 1000000;
00088 (*i)->set_world_x((float)r);
00089 (*i)->set_world_y((float)r+1);
00090 (*i)->set_world_z((float)r+2);
00091 tt.ping_start(ttc_write);
00092 (*i)->write();
00093 tt.ping_end(ttc_write);
00094 }
00095 if ( ++u > 20000 ) {
00096 tt.print_to_stdout();
00097 tt.reset();
00098 u = 0;
00099 }
00100
00101 }
00102
00103 for (std::list<ObjectPositionInterface *>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) {
00104 bb->close(*i);
00105 }
00106
00107 delete bb;
00108 LibLogger::finalize();
00109 }
00110
00111
00112