VRUT::Tracking Class Reference

General class - agragation of parser and receiver. More...

#include <tracking.h>

Inheritance diagram for VRUT::Tracking:

VRUT::Module VRUT::Module

List of all members.

Public Member Functions

 Tracking (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink)
 Class constructor - do not alter.
virtual ~Tracking ()
 Class destructor - deinitialize your data.
virtual wxString GetDesc () const
 Always overload method giving description for your module.
 Tracking (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink)
 Class constructor - do not alter.
virtual ~Tracking ()
 Class destructor - deinitialize your data.
virtual wxString GetDesc () const
 Always overload method giving description for your module.

Protected Member Functions

virtual void processEvent (wxCommandEvent &evt)
 processing events and updating parameters
virtual void run ()
 Module running method.
void safeEmptyQueue ()
 method safety empties queue - deleting members
void processQueue ()
void dumpFilterTable ()
virtual void processEvent (wxCommandEvent &evt)
 processing events and updating parameters
virtual void run ()
 Module running method.
void safeEmptyQueue ()
 method safety empties queue - deleting members
void processQueue ()
void dumpFilterTable ()

Protected Attributes

int IDoffset
 Ofset for identificator for tracked devices.
Parameter::ParameterIdentificator IDoffsetParamID
TrackingFilter filter
PacketParser parser
 Dtrack format packet parser.
Receiverlistener
 UDP packet receiver.
std::queue< Body * > bodyQueue
 Received devices front.
wxString remoteAddress
 IP address or Hostname of the peer.
unsigned short remotePort
 Service port of the peer.
unsigned short packetTimeout
 packet and event timeout
Parameter::ParameterIdentificator packetTimeoutParamID
 packetTimeout param identificator to register as module parameter
unsigned short localPort
 local port number
Parameter::ParameterIdentificator localPortParamID
 localPort param identificator to register as parameter
unsigned short bufferSize
 buffer size of packet receiver
Parameter::ParameterIdentificator bufferSizeParamID
 bufferSize param identificator to register parameter
float rotationFilter
 Size of angle to filter out (in radians).
Parameter::ParameterIdentificator rotationFilterParamID
 rotationFilter param identificator
float translationFilter
 Size of shift to filter out (in milimeters).
Parameter::ParameterIdentificator translationFilterParamID
 translationFilter param identificator
int bodyID
 Body number identificator for filter table.
Parameter::ParameterIdentificator bodyIDParamID
int bodyType
 The type of the body for filter table.
Parameter::ParameterIdentificator bodyTypeParamID
short updateTable
 Button for updating Filter.
Parameter::ParameterIdentificator updateTableParamID
short dumpTable
 Buttond to dump table.
Parameter::ParameterIdentificator dumpTableParamID
Receiverlistener
 UDP packet receiver.
std::queue< Body * > bodyQueue
 Received devices front.
wxIPV4address local
wxIPV4address remote
wxDatagramSocket * sendSock
bool forward
 check box for tracking forwarding
Parameter::ParameterIdentificator forwardParamID
wxString forwardMachines
 list of machines for forward in style <port><machine>;<port><machine>...
Parameter::ParameterIdentificator forwardMachinesParamID


Detailed Description

General class - agragation of parser and receiver.

Definition at line 33 of file tracking.h.


Constructor & Destructor Documentation

Tracking::Tracking ( const MODULE_ID _id,
const wxString &  _name,
VRUT::EventHandler msgSink 
)

Class constructor - do not alter.

Definition at line 17 of file tracking.cpp.

00018 : Module(_id, _name, 0, msgSink),
00019   localPortParamID(_name, wxT("localPort"), _id),
00020   packetTimeoutParamID(_name, wxT("packetTimeout"), _id),
00021   bufferSizeParamID(_name, wxT("bufferSize"), _id),
00022   translationFilterParamID(_name, wxT("translationFilter"), _id),
00023   rotationFilterParamID(_name, wxT("rotationFilter"), _id),
00024   bodyIDParamID(_name, wxT("bodyID"), _id),
00025   bodyTypeParamID(_name, wxT("bodyType"), _id),
00026   dumpTableParamID(_name, wxT("dumpTable"), _id),
00027   updateTableParamID(_name, wxT("updateTabe"), _id),
00028   IDoffsetParamID(_name, wxT("IDoffset"), _id)
00029 {
00030        REGISTER_PARAM_GUI_TEXTCONTROL(bodyIDParamID, wxT("0"));
00031        REGISTER_PARAM_GUI_TEXTCONTROL(bodyTypeParamID, wxT("0"));
00032        REGISTER_PARAM_GUI_TEXTCONTROL(rotationFilterParamID, wxT("0.1"));
00033        REGISTER_PARAM_GUI_TEXTCONTROL(translationFilterParamID, wxT("5.0"));
00034        REGISTER_PARAM_GUI_BUTTON(updateTableParamID);
00035        REGISTER_PARAM_GUI_BUTTON(dumpTableParamID);
00036        REGISTER_PARAM_GUI_TEXTCONTROL(IDoffsetParamID,wxT("0"));
00037        REGISTER_PARAM_GUI_TEXTCONTROL(localPortParamID, wxT("2627"));
00038        REGISTER_PARAM_GUI_TEXTCONTROL(bufferSizeParamID, wxT("8192"));
00039        REGISTER_PARAM_GUI_TEXTCONTROL(packetTimeoutParamID, wxT("20"));
00040        IDoffset = 0;
00041        rotationFilter = (float)0.1;
00042        bodyType = bodyID = 0;
00043        translationFilter = 5;
00044        remoteAddress = wxT("localhost");
00045        remotePort = 2627;
00046        localPort = 2627;
00047        eventTimeout= packetTimeout = 20;
00048        listener = new Receiver();
00049        parser.SetQueue(&bodyQueue);
00050 }

Tracking::~Tracking (  )  [virtual]

Class destructor - deinitialize your data.

Definition at line 114 of file tracking.cpp.

00115 {
00116        listener->~Receiver();
00117 }

VRUT::Tracking::Tracking ( const MODULE_ID _id,
const wxString &  _name,
EventHandler msgSink 
)

Class constructor - do not alter.

virtual VRUT::Tracking::~Tracking (  )  [virtual]

Class destructor - deinitialize your data.


Member Function Documentation

void Tracking::processEvent ( wxCommandEvent &  evt  )  [protected, virtual]

processing events and updating parameters

Reimplemented from VRUT::Module.

Definition at line 52 of file tracking.cpp.

00053 {
00054        Module::processEvent(evt);
00055        switch (evt.GetEventType())
00056        {
00057               case Event::EVT_PARAM_SET:
00058                      {
00059                             updateTable = dumpTable = 0;
00060                             UPDATE_PARAM_FROM_EVENT_INT(localPortParamID, localPort, evt);
00061                             UPDATE_PARAM_FROM_EVENT_INT(bufferSizeParamID, bufferSize, evt);
00062                             UPDATE_PARAM_FROM_EVENT_UNSIGNED(packetTimeoutParamID, packetTimeout,evt);
00063                             UPDATE_PARAM_FROM_EVENT_FLOAT(rotationFilterParamID, rotationFilter, evt);
00064                             UPDATE_PARAM_FROM_EVENT_FLOAT(translationFilterParamID, translationFilter, evt);
00065                             UPDATE_PARAM_FROM_EVENT_INT(bodyIDParamID, bodyID, evt);
00066                             UPDATE_PARAM_FROM_EVENT_INT(bodyTypeParamID, bodyType,evt);
00067                             UPDATE_PARAM_FROM_EVENT_INT(updateTableParamID, updateTable, evt);
00068                             UPDATE_PARAM_FROM_EVENT_INT(dumpTableParamID, dumpTable, evt);
00069                             UPDATE_PARAM_FROM_EVENT_INT(IDoffsetParamID, IDoffset, evt);
00070                             listener->UpdateSocket(remoteAddress, remotePort, localPort);
00071                             listener->ResizeBuffer(bufferSize);
00072                             eventTimeout = packetTimeout;
00073                             if (updateTable != 0)
00074                             {
00075                                    if(filter.UpdateFilter((Body::BodyType)bodyType, bodyID, rotationFilter, translationFilter))
00076                                    {
00077                                           LOG(wxT("<Tracking> Filter updated."));
00078                                    }
00079                                    else
00080                                    {
00081                                           LOG(wxT("<Tracking> Selected entry were not found! Entry Pre-created: "));
00082                                           this->dumpFilterTable();
00083                                    }
00084                             }
00085                             if (dumpTable != 0)
00086                             {
00087                                    this->dumpFilterTable();
00088                             }
00089                             break;
00090                      }
00091        }
00092        if (packetTimeout != eventTimeout) packetTimeout = eventTimeout;
00093 }

void Tracking::run (  )  [protected, virtual]

Module running method.

In this method's body Receiver c\ listener is called and if data are available also parser is called

Reimplemented from VRUT::Module.

Definition at line 94 of file tracking.cpp.

00095 {
00096        while (listener->Receive())
00097        {
00098               parser.SetPacket(listener->GetPacket());
00099               if (parser.Parse())
00100               {
00101                      processQueue();
00102               }
00103               else
00104               {
00105                      LOGWARNING(wxT("<Tracking> Parsing Failed"));
00106                      safeEmptyQueue();
00107               }
00108        }
00109 }

void Tracking::safeEmptyQueue (  )  [protected]

method safety empties queue - deleting members

Definition at line 118 of file tracking.cpp.

00119 {
00120        while (!bodyQueue.empty())
00121        {
00122               Body * tempB = bodyQueue.front();
00123               bodyQueue.pop();
00124               delete tempB;
00125        }
00126 }

void Tracking::processQueue (  )  [protected]

Definition at line 127 of file tracking.cpp.

00128 {
00129        while (!bodyQueue.empty())
00130        {
00131               Body * tempA = bodyQueue.front();
00132               bodyQueue.pop();
00133               if (filter.Filter(tempA))
00134               {
00135               //     LOG(wxT("<Tracking> Filtered packet"));
00136               }
00137               else
00138               {
00139               //     LOG(wxT("<Tracking> NOT filtered packet"));
00140                      DeviceData * data = new DeviceData;
00141                      data->id       = tempA->GetID() + IDoffset;
00142                      data->type     = tempA->GetType();
00143                      data->matrix   = tempA->Matrix();
00144                      data->buttons  = tempA->ButtonsMask32();
00145                      data->control1 = tempA->Control(0);
00146                      data->control1 = tempA->Control(1);
00147                      if (data->control1  < -1 || data->control1 > 1) data->control1 = 0;
00148                      if (data->control2  < -1 || data->control2 > 1) data->control2 = 0;
00149 
00150                      wxCommandEvent evt = Event::GET_EVT_INPUT_TRACKING(data);
00151                      PostToKernel(evt);
00152               }
00153               delete tempA;
00154        }
00155 }

void Tracking::dumpFilterTable (  )  [protected]

Definition at line 156 of file tracking.cpp.

00157 {
00158 
00159        wxString dump = wxT("<Tracking> FilterTable:\nType\tID\tAngleFilter\tDistFilter\n");
00160        dump += filter.GetAsString("\n","\t");
00161        LOG(dump);
00162 }

wxString Tracking::GetDesc (  )  const [virtual]

Always overload method giving description for your module.

Implements VRUT::Module.

Definition at line 110 of file tracking.cpp.

00111 {
00112        return wxT("DTrack datagram receiver and parser");
00113 }

virtual void VRUT::Tracking::processEvent ( wxCommandEvent &  evt  )  [protected, virtual]

processing events and updating parameters

Reimplemented from VRUT::Module.

virtual void VRUT::Tracking::run (  )  [protected, virtual]

Module running method.

In this method's body Receiver c\ listener is called and if data are available also parser is called

Reimplemented from VRUT::Module.

void VRUT::Tracking::safeEmptyQueue (  )  [protected]

method safety empties queue - deleting members

void VRUT::Tracking::processQueue (  )  [protected]

void VRUT::Tracking::dumpFilterTable (  )  [protected]

virtual wxString VRUT::Tracking::GetDesc (  )  const [virtual]

Always overload method giving description for your module.

Implements VRUT::Module.


Member Data Documentation

int VRUT::Tracking::IDoffset [protected]

Ofset for identificator for tracked devices.

This parameter enables to use more then one Tracking module with different Ports and offset IDoffset will be added to Number identificator of the device so with different offsets there will be no conflict. It is better to use bigger diferences between ofsets then small! (To TrackingManipulator you have to put the IDs increased by offset)
NOte that this number is not propagated to the filter! TO control filter use IDs without offset! Offset effects only Output events!

Definition at line 44 of file tracking.h.

Definition at line 45 of file tracking.h.

Definition at line 47 of file tracking.h.

Dtrack format packet parser.

Definition at line 52 of file tracking.h.

UDP packet receiver.

Definition at line 55 of file tracking.h.

std::queue<Body *> VRUT::Tracking::bodyQueue [protected]

Received devices front.

Definition at line 58 of file tracking.h.

wxString VRUT::Tracking::remoteAddress [protected]

IP address or Hostname of the peer.

Definition at line 61 of file tracking.h.

unsigned short VRUT::Tracking::remotePort [protected]

Service port of the peer.

Definition at line 64 of file tracking.h.

unsigned short VRUT::Tracking::packetTimeout [protected]

packet and event timeout

Definition at line 67 of file tracking.h.

packetTimeout param identificator to register as module parameter

Definition at line 69 of file tracking.h.

unsigned short VRUT::Tracking::localPort [protected]

local port number

Definition at line 72 of file tracking.h.

localPort param identificator to register as parameter

Definition at line 74 of file tracking.h.

unsigned short VRUT::Tracking::bufferSize [protected]

buffer size of packet receiver

Definition at line 77 of file tracking.h.

bufferSize param identificator to register parameter

Definition at line 79 of file tracking.h.

float VRUT::Tracking::rotationFilter [protected]

Size of angle to filter out (in radians).

If any of Euler's angle is smaller then treshold rotation will be ignored set the angles from 0 rad to 1,5705 rad (it corresponds to 0° ; 90°)

Definition at line 85 of file tracking.h.

rotationFilter param identificator

Definition at line 87 of file tracking.h.

Size of shift to filter out (in milimeters).

if any difference (in x, y or z axis) is smaller then treshold translation will be ignored

Definition at line 93 of file tracking.h.

translationFilter param identificator

Definition at line 95 of file tracking.h.

int VRUT::Tracking::bodyID [protected]

Body number identificator for filter table.

Definition at line 98 of file tracking.h.

Definition at line 99 of file tracking.h.

int VRUT::Tracking::bodyType [protected]

The type of the body for filter table.

Definition at line 101 of file tracking.h.

Definition at line 102 of file tracking.h.

short VRUT::Tracking::updateTable [protected]

Button for updating Filter.

Definition at line 104 of file tracking.h.

Definition at line 105 of file tracking.h.

short VRUT::Tracking::dumpTable [protected]

Buttond to dump table.

Definition at line 107 of file tracking.h.

Definition at line 108 of file tracking.h.

UDP packet receiver.

Definition at line 55 of file tracking.h.

std::queue<Body *> VRUT::Tracking::bodyQueue [protected]

Received devices front.

Definition at line 58 of file tracking.h.

wxIPV4address VRUT::Tracking::local [protected]

Definition at line 111 of file tracking.h.

wxIPV4address VRUT::Tracking::remote [protected]

Definition at line 111 of file tracking.h.

wxDatagramSocket* VRUT::Tracking::sendSock [protected]

Definition at line 112 of file tracking.h.

bool VRUT::Tracking::forward [protected]

check box for tracking forwarding

Definition at line 115 of file tracking.h.

Definition at line 116 of file tracking.h.

wxString VRUT::Tracking::forwardMachines [protected]

list of machines for forward in style <port><machine>;<port><machine>...

Definition at line 119 of file tracking.h.

Definition at line 120 of file tracking.h.


The documentation for this class was generated from the following files:

Generated on Tue Mar 10 14:41:50 2009 for VRUT by  doxygen 1.5.5