#include <tracking.h>
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. | |
Receiver * | listener |
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 |
Receiver * | listener |
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 |
Definition at line 33 of file tracking.h.
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] |
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.
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] |
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.
virtual void VRUT::Tracking::processEvent | ( | wxCommandEvent & | evt | ) | [protected, virtual] |
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] |
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.
TrackingFilter VRUT::Tracking::filter [protected] |
Definition at line 47 of file tracking.h.
PacketParser VRUT::Tracking::parser [protected] |
Receiver* VRUT::Tracking::listener [protected] |
std::queue<Body *> VRUT::Tracking::bodyQueue [protected] |
wxString VRUT::Tracking::remoteAddress [protected] |
unsigned short VRUT::Tracking::remotePort [protected] |
unsigned short VRUT::Tracking::packetTimeout [protected] |
packetTimeout
param identificator to register as module parameter
Definition at line 69 of file tracking.h.
unsigned short VRUT::Tracking::localPort [protected] |
unsigned short VRUT::Tracking::bufferSize [protected] |
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.
float VRUT::Tracking::translationFilter [protected] |
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.
int VRUT::Tracking::bodyID [protected] |
Definition at line 99 of file tracking.h.
int VRUT::Tracking::bodyType [protected] |
Definition at line 102 of file tracking.h.
short VRUT::Tracking::updateTable [protected] |
Definition at line 105 of file tracking.h.
short VRUT::Tracking::dumpTable [protected] |
Definition at line 108 of file tracking.h.
Receiver* VRUT::Tracking::listener [protected] |
std::queue<Body *> VRUT::Tracking::bodyQueue [protected] |
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] |
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.