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
00028
00029
00030
00031
00032
00033
00034
00035
00042
00043
00069 #ifndef _ULTRATRAKMODULE_H
00070 #define _ULTRATRAKMODULE_H
00071
00072 #include "../OpenTracker.h"
00073 #include "UltraTrakSource.h"
00074
00075 #include <ace/SOCK_Dgram.h>
00076
00077 #include <vector>
00078
00079
00080 #ifndef OT_NO_ULTRATRACK_SUPPORT
00081
00082
00083 namespace ot {
00084
00086 struct Station
00087 {
00088 int number;
00089 Event event;
00090 int modified;
00091 UltraTrakSource * source;
00092
00093 Station( const int number_, UltraTrakSource * source_ ) :
00094 number( number_ ), modified( 0 ), source( source_ )
00095 {};
00096 };
00097
00098
00099 typedef std::vector<Station *> StationVector;
00100
00102 const int ultraTrakMaxUnits = 16;
00103
00105 struct UltraTrakStationData
00106 {
00107 char dummy1;
00108 char boardNumber;
00109 char updateFlag;
00110 char stationNumber;
00111 #ifdef ERRORCODE
00112 char errorCode;
00113 #endif
00114 char dummy2;
00115 char position[3][4];
00116 char orientation[4][4];
00117 };
00118
00120 struct UltraTrakFrameData
00121 {
00122 char header[56];
00123 UltraTrakStationData stationData[ultraTrakMaxUnits];
00124 };
00125
00126
00127
00136 class OPENTRACKER_API UltraTrakModule : public ThreadModule, public NodeFactory
00137 {
00138
00139 protected:
00140
00142 StationVector stations;
00144 UltraTrakFrameData buffer;
00146 int port;
00147 int stop;
00148
00149 int positionMapping[3];
00150 int invertPosition[3];
00151 int orientationMapping[3];
00152 int invertOrientation[3];
00153
00154
00155 protected:
00161 static void convertFloatsNToHl(float* floats, float* result, int num);
00164 void run();
00165 int parseVector(const std::string & line, int * val);
00166 void initMappping(int *mapping);
00167 void initInversion(int *inversion);
00168 void calcInversion(int *inversion);
00169 void correctData(std::vector<float> &d, int *mapping, int *inversion);
00170
00171 public:
00173 UltraTrakModule();
00174
00176 virtual ~UltraTrakModule();
00182 virtual void init(StringTable& attributes, ConfigNode * localTree);
00190 virtual Node * createNode( const std::string& name, StringTable& attributes);
00194 virtual void start();
00198 virtual void close();
00204 virtual void pushEvent();
00205 };
00206 OT_MODULE(UltraTrakModule);
00207
00208 }
00209
00210
00211 #endif // OT_NO_ULTRATRACK_SUPPORT
00212
00213
00214 #endif
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230