Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

dev_vicon.H

Go to the documentation of this file.
00001 // dev_vicon.H
00002 
00003 #ifndef _DEV_VICON_H_
00004 #define _DEV_VICON_H_
00005 
00006 #include <ctype.h>
00007 #include "dev/emitter.H"
00008 #include "net/net_stream.H"
00009 #include "mlib/points.H"
00010 
00011 class ViconObject : public EVENTsource
00012 {
00013  protected:
00014   int      _index;  // index of first data item in array
00015                     // of doubles Tarsus will send
00016 
00017  public:
00018   ViconObject( Cstr_ptr &name,
00019            int index ) : EVENTsource(name), _index(index) {}
00020 
00021   virtual void update_data_and_distrib_event( double *data ) = 0;
00022 };
00023 
00024 class DEVice_Vicon : public DEVice, public NetStream {
00025  protected:
00026   Network              *_n;
00027   Wtransf               _device_to_room;
00028   ARRAY<ViconObject *>  _vicon_obj_list;
00029 
00030  public:
00031             DEVice_Vicon(Cstr_ptr &dev_name);
00032    virtual ~DEVice_Vicon() {}
00033 
00034    virtual void sample();
00035 };
00036 
00038 
00039 // some inlined utility functions
00040 
00041 inline char *vicon_getint( char *buf, int *val )
00042 {
00043   int v;
00044   for(int i=0;i<sizeof(v);i++)
00045     ((char *)&v)[i] = buf[i];
00046   buf += sizeof(v);
00047 
00048   *val = v;
00049 
00050   return buf;
00051 }
00052 
00053 inline char *vicon_getdouble( char *buf, double *val )
00054 {
00055   double v;
00056   for(int i=0;i<sizeof(v);i++)
00057     ((char *)&v)[i] = buf[i];
00058   buf += sizeof(v);
00059 
00060   *val = v;
00061 
00062   return buf;
00063 }
00064 
00065 inline char *vicon_getstring( char *buf, str_ptr *val )
00066 {
00067   int num;
00068   buf = vicon_getint(buf, &num);
00069 
00070   char tmpbuf[1024];
00071   for(int j=0;j<num;j++)
00072     tmpbuf[j] = buf[j];
00073 
00074   tmpbuf[num] = '\0';
00075   buf += num;
00076 
00077   *val = tmpbuf;
00078 
00079   return buf;
00080 }
00081 
00082 inline str_ptr str_left(Cstr_ptr &s, int num)
00083 {
00084   char buf[1024];
00085 
00086   for(int i=0;i<num;i++)
00087     buf[i] = s[i];
00088   buf[num] = '\0';
00089 
00090   return str_ptr(buf);
00091 }
00092 
00093 inline void print_bytes( char *buf, int num )
00094 {
00095   for(int i=0;i<num;i++) {
00096     cerr << "  " << i << "  "
00097      << int(buf[i]) << "  "
00098      << (isprint(buf[i]) ? buf[i] : ' ') << endl;
00099   }
00100 }
00101 
00102 #endif

Generated on Mon Sep 15 16:25:56 2003 for gluebase by doxygen1.2.18