Update of /cvsroot/playerstage/code/player/utils/playerv
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29560

Modified Files:
        playerv.c 
Log Message:
Added a 'pull' mode to playerv.  This should help with keeping the data fresh 
on 
slower computers (actually, it works quite well on fast ones too).



Index: playerv.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/playerv.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** playerv.c   30 May 2006 19:51:31 -0000      1.45
--- playerv.c   4 Jul 2006 15:53:52 -0000       1.46
***************
*** 42,46 ****
  in your PATH, then playerv should also be.  Command-line usage is:
  @verbatim
! $ playerv [-h <hostname>] [-p <port>] [--<device>:<index>] 
[--<device>:<index>] ...
  @endverbatim
  For example, to connect to Player on localhost at the default port
--- 42,46 ----
  in your PATH, then playerv should also be.  Command-line usage is:
  @verbatim
! $ playerv [-h <hostname>] [-p <port>] [-pull <0|1>] [--<device>:<index>] 
[--<device>:<index>] ...
  @endverbatim
  For example, to connect to Player on localhost at the default port
***************
*** 55,58 ****
--- 55,62 ----
  @endverbatim
  
+ If pull is set to 1, it will set the server's replace rule to true, and only
+ deliver data when a read is requested.  This is sometimes useful on slow
+ connections or with slow computers that cannot keep up.
+ 
  When playerv starts, a window will pop up.  Click and drag with the left
  mouse button to pan the window.  Click and drag with the right mouse
***************
*** 118,121 ****
--- 122,126 ----
  #include <stdlib.h>
  #include <unistd.h>
+ #include <time.h>
  #include "playerv.h"
  
***************
*** 136,140 ****
    printf("\nPlayerViewer %s, ", VERSION);
    printf("a visualization tool for the Player robot device server.\n");
!   printf("Usage  : playerv [-h <hostname>] [-p <port>]\n");
    printf("                 [--<device>:<index>] [--<device>:<index>] ... \n");
    printf("Example: playerv -p 6665 --position:0 --sonar:0\n");
--- 141,145 ----
    printf("\nPlayerViewer %s, ", VERSION);
    printf("a visualization tool for the Player robot device server.\n");
!   printf("Usage  : playerv [-h <hostname>] [-p <port>] [-pull <0|1>]\n");
    printf("                 [--<device>:<index>] [--<device>:<index>] ... \n");
    printf("Example: playerv -p 6665 --position:0 --sonar:0\n");
***************
*** 155,158 ****
--- 160,164 ----
    int rate;
    int count;
+   int pull;
    char section[256];
    int device_count;
***************
*** 160,163 ****
--- 166,170 ----
    device_t *device;
    void *proxy;
+   struct timeval tv, tc, st = {0, 0};
  
    printf("PlayerViewer %s\n", VERSION);
***************
*** 189,192 ****
--- 196,201 ----
      port = opt_get_int(opt, "", "p", 6665);
  
+   pull = opt_get_int(opt, "", "pull", 0);
+ 
    // Connect to the server
    printf("Connecting to [%s:%d]\n", host, port);
***************
*** 199,210 ****
    }
  
! #if 0
!   // Change the server's data delivery mode.
!   if (playerc_client_datamode(client, PLAYERC_DATAMODE_PUSH_NEW) != 0)
    {
!     PRINT_ERR1("%s", playerc_error_str());
!     return -1;
    }
- #endif
  
    // Get the available devices.
--- 208,231 ----
    }
  
!   if (0 != pull)
    {
!     printf("Setting delivery mode to PLAYER_DATAMODE_PULL\n", host, port);
!     // Change the server's data delivery mode.
!     if (playerc_client_set_replace_rule(client, -1, -1, -1, -1, 1) != 0)
!     {
!       PRINT_ERR1("%s", playerc_error_str());
!       return -1;
!     }
! 
!     // Change the server's data delivery mode.
!     // PLAYERC_DATAMODE_PUSH, PLAYERC_DATAMODE_PULL
!     if (playerc_client_datamode(client, PLAYERC_DATAMODE_PULL) != 0)
!     {
!       PRINT_ERR1("%s", playerc_error_str());
!       return -1;
!     }
! 
!     gettimeofday(&tv, NULL);
    }
  
    // Get the available devices.
***************
*** 298,317 ****
      rtk_app_main_loop(app);
  
!     // see if there's data
!     count = playerc_client_peek(client, 50);
!     if (count < 0)
      {
!       PRINT_ERR1("%s", playerc_error_str());
!       break;
      }
!     if (count > 0)
      {
!       proxy = playerc_client_read(client);
!       // NULL return from playerc_client_read() means an error in the
!       // connection to the server (I think)
!       if(!proxy)
!         break;
      }
  
      // Update the devices
      for (i = 0; i < device_count; i++)
--- 319,364 ----
      rtk_app_main_loop(app);
  
!     if (0 == pull)  // if we're in push mode
      {
!       // see if there's data
!       count = playerc_client_peek(client, 50);
!       if (count < 0)
!       {
!         PRINT_ERR1("%s", playerc_error_str());
!         break;
!       }
!       if (count > 0)
!       {
!         proxy = playerc_client_read(client);
!         // NULL return from playerc_client_read() means an error in the
!         // connection to the server (I think)
!         if(!proxy)
!           break;
!       }
      }
!     else // we're in pull mode
      {
!       // we only want to request new data at roughly 20 Hz
!       gettimeofday(&tc, NULL);
!       if ((tc.tv_sec > tv.tv_sec) || (tc.tv_usec > tv.tv_usec + 50000))
!       {
!         tv = tc;
!         // this requests a round of data from the server to be read
!         proxy = playerc_client_read(client);
!         // NULL return from playerc_client_read() means an error in the
!         // connection to the server (I think)
!         if(!proxy)
!           break;
! 
!        }
!        else
!        {
!         // sleep for the minimum time we can, so we don't use up too much
!         // processor
!         nanosleep(&st, NULL);
!        }
      }
  
+ 
      // Update the devices
      for (i = 0; i < device_count; i++)


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to