00001 #include "urbi/uclient.hh"
00002 #include <sys/types.h>
00003 #include "libport/sys/stat.h"
00004 #include <signal.h>
00005 #include <assert.h>
00006 #include "libport/windows.hh"
00007
00008 bool over=false;
00009 static int totalsize=0;
00010 static int starttime=0;
00011
00012 urbi::UCallbackAction
00013 bw(const urbi::UMessage &msg)
00014 {
00015 assert (msg.type == urbi::MESSAGE_DATA);
00016 assert (msg.value->type == urbi::DATA_BINARY);
00017 assert (msg.value->binary->type == urbi::BINARY_IMAGE);
00018
00019
00020 totalsize += (msg.value->binary->image.size
00021 + msg.tag.size ()
00022 + 20);
00023
00024 if (msg.tag != "be")
00025 {
00026 msg.client.printf("received %d bytes in %d miliseconds: bandwidth is %d bytes per second.\n",
00027 totalsize,
00028 msg.client.getCurrentTime()-starttime,
00029 totalsize*1000/(msg.client.getCurrentTime()-starttime));
00030
00031 over=true;
00032 }
00033
00034 return urbi::URBI_CONTINUE;
00035 }
00036
00037 int main(int argc, char * argv[])
00038 {
00039 if (argc != 2)
00040 {
00041 printf("usage: %s robot\n", argv[0]);
00042 urbi::exit(1);
00043 }
00044
00045 urbi::UClient c (argv[1]);
00046
00047 if (c.error())
00048 urbi::exit(1);
00049
00050 c.printf("requesting raw images from server to test bandwidth...\n");
00051
00052 c.setCallback(bw,"bw");
00053 c.setCallback(bw,"be");
00054
00055 c << "camera.format = 0;camera.resolution = 0;noop;noop;";
00056
00057 starttime=c.getCurrentTime();
00058 c << " for (i=0;i<9; ++i) bw:camera.val|";
00059 c << "be:camera.val;";
00060 urbi::execute();
00061 }