-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created new directories containing stub code for Python and C++. Also moved licenses and copied them into both directories.
- Loading branch information
jzampino
committed
Mar 1, 2017
1 parent
b8c8f07
commit c766581
Showing
11 changed files
with
2,550 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
#include "RTTrP.h" | ||
|
||
using namespace std; | ||
|
||
template<typename vectorType> | ||
void print_vector(vector<vectorType> *toPrint) | ||
{ | ||
typename vector<vectorType>::iterator it; | ||
|
||
for (it = toPrint->begin(); it != toPrint->end(); it++) | ||
(*it)->printModule(); | ||
} | ||
|
||
RTTrP::RTTrP() | ||
{ | ||
} | ||
|
||
RTTrP::RTTrP(vector<unsigned char> data) | ||
{ | ||
std::copy(data.begin(), data.begin() + 2, (unsigned char*)&this->intHeader); | ||
data.erase(data.begin(), data.begin() + 2); | ||
|
||
copy(data.begin(), data.begin() + 2, (unsigned char*)&this->fltHeader); | ||
data.erase(data.begin(), data.begin() + 2); | ||
|
||
// The header values are always in Network (Big Endian) Format | ||
this->intHeader = ntohs(this->intHeader); | ||
this->fltHeader = ntohs(this->fltHeader); | ||
|
||
copy(data.begin(), data.begin() + 2, (unsigned char*)&this->version); | ||
data.erase(data.begin(), data.begin() + 2); | ||
|
||
copy(data.begin(), data.begin() + 4, (unsigned char*)&this->pID); | ||
data.erase(data.begin(), data.begin() + 4); | ||
|
||
copy(data.begin(), data.begin() + 1, (unsigned char*)&this->pForm); | ||
data.erase(data.begin(), data.begin() + 1); | ||
|
||
copy(data.begin(), data.begin() + 2, (unsigned char*)&this->pktSize); | ||
data.erase(data.begin(), data.begin() + 2); | ||
|
||
copy(data.begin(), data.begin() + 4, (unsigned char*)&this->context); | ||
data.erase(data.begin(), data.begin() + 4); | ||
|
||
copy(data.begin(), data.begin() + 1, (unsigned char*)&this->numMods); | ||
data.erase(data.begin(), data.begin() + 1); | ||
|
||
this->data.resize(data.size()); | ||
|
||
if (data.size() > 0) | ||
copy(data.begin(), data.end(), (unsigned char*)&this->data[0]); | ||
|
||
if (this->intHeader == 0x4154) | ||
{ | ||
this->version = ntohs(this->version); | ||
this->pID = ntohl(this->pID); | ||
this->pktSize = ntohs(this->pktSize); | ||
this->context = ntohl(this->context); | ||
} | ||
} | ||
|
||
RTTrP::~RTTrP() | ||
{ | ||
} | ||
|
||
void RTTrP::printHeader(void) | ||
{ | ||
cout << "==================RTTrP Packet Header==================" << endl; | ||
cout << "Integer Header: 0x" << hex << this->intHeader << endl; | ||
cout << "Floating Point Header: 0x" << hex << this->fltHeader << endl; | ||
cout << "Version: 0x" << hex << this->version << endl; | ||
cout << "Packet ID: " << this->pID << endl; | ||
|
||
if (this->pForm == 0) | ||
cout << "Packet Format: 0x00" << endl; | ||
else | ||
cout << "Packet Format: 0x" << hex << this->pForm << endl; | ||
|
||
cout << "Packet Size: " << this->pktSize << endl; | ||
cout << "Context: 0x" << hex << this->context << endl; | ||
cout << "Number of Modules: " << (int) this->numMods << endl; | ||
cout << "==================RTTrP Packet Header==================" << endl; | ||
} | ||
|
||
RTTrPM::RTTrPM() | ||
{ | ||
this->trackable = NULL; | ||
this->centroidMod = NULL; | ||
this->ledMod = NULL; | ||
this->quatMod = NULL; | ||
this->eulerMod = NULL; | ||
this->cavMod = NULL; | ||
this->lavMod = NULL; | ||
} | ||
|
||
RTTrPM::~RTTrPM() | ||
{ | ||
delete(this->trackable); | ||
delete(this->centroidMod); | ||
delete(this->quatMod); | ||
delete(this->eulerMod); | ||
delete(this->cavMod); | ||
|
||
if (this->ledMod != NULL) | ||
{ | ||
if (this->ledMod->size() > 0) | ||
{ | ||
vector<LEDModule*>::iterator led; | ||
|
||
for (led = this->ledMod->begin(); led < this->ledMod->end(); led++) | ||
{ | ||
delete((*led)); | ||
} | ||
|
||
delete(this->ledMod); | ||
} | ||
else | ||
delete(this->ledMod); | ||
} | ||
else | ||
delete(this->ledMod); | ||
|
||
if (this->lavMod != NULL) | ||
{ | ||
if (this->lavMod->size() > 0) | ||
{ | ||
vector<LEDAccVelMod*>::iterator lav; | ||
|
||
for (lav = this->lavMod->begin(); lav < this->lavMod->end(); lav++) | ||
{ | ||
delete((*lav)); | ||
} | ||
|
||
delete(this->lavMod); | ||
} | ||
else | ||
delete(this->lavMod); | ||
} | ||
else | ||
delete(this->lavMod); | ||
} | ||
|
||
void RTTrPM::printPacket(void) | ||
{ | ||
this->header->printHeader(); | ||
this->trackable->printModule(); | ||
|
||
if (this->centroidMod != NULL) | ||
this->centroidMod->printModule(); | ||
|
||
if (this->ledMod != NULL) | ||
print_vector(this->ledMod); | ||
|
||
if (this->quatMod != NULL) | ||
this->quatMod->printModule(); | ||
|
||
if (this->eulerMod != NULL) | ||
this->eulerMod->printModule(); | ||
|
||
if (this->cavMod != NULL) | ||
this->cavMod->printModule(); | ||
|
||
if (this->lavMod != NULL) | ||
print_vector(this->lavMod); | ||
} | ||
|
||
RTTrPL::RTTrPL() | ||
{ | ||
this->header = NULL; | ||
this->lightOut = NULL; | ||
this->sync = NULL; | ||
} | ||
|
||
RTTrPL::~RTTrPL() | ||
{ | ||
delete(this->header); | ||
delete(this->lightOut); | ||
delete(this->sync); | ||
} | ||
|
||
void RTTrPL::printModule() | ||
{ | ||
this->header->printHeader(); | ||
this->lightOut->printModule(); | ||
|
||
vector<Universe*>::iterator univIt; | ||
vector<Spot*>::iterator spotIt; | ||
|
||
for (univIt = this->lightOut->uniList->begin(); univIt != this->lightOut->uniList->end(); univIt++) | ||
{ | ||
(*univIt)->printModule(); | ||
|
||
for (spotIt = (*univIt)->spotList->begin(); spotIt != (*univIt)->spotList->end(); spotIt++) | ||
{ | ||
(*spotIt)->printModule(); | ||
|
||
print_vector((*spotIt)->chanBlocks); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef RTTRP_H | ||
#define RTTRP_H | ||
|
||
#include "protocol_common.h" | ||
#include "thirdParty_motion.h" | ||
#include "lighting.h" | ||
|
||
// Remove if not needed | ||
#ifdef _DEBUG | ||
#define _CRTDBG_MAP_ALLOC | ||
#include <crtdbg.h> | ||
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) | ||
#define new DEBUG_NEW | ||
#endif | ||
|
||
#pragma once | ||
|
||
using namespace std; | ||
|
||
class RTTrP | ||
{ | ||
public: | ||
uint16_t intHeader, fltHeader, version; | ||
uint32_t pID; | ||
uint8_t pForm; | ||
uint16_t pktSize; | ||
uint32_t context; | ||
uint8_t numMods; | ||
vector<unsigned char> data; | ||
|
||
RTTrP(); | ||
RTTrP(vector<unsigned char>); | ||
~RTTrP(); | ||
|
||
void printHeader(void); | ||
}; | ||
|
||
class RTTrPM | ||
{ | ||
public: | ||
RTTrP *header; | ||
Trackable *trackable; | ||
CentroidMod *centroidMod; | ||
vector<LEDModule*> *ledMod; | ||
QuatModule *quatMod; | ||
EulerModule *eulerMod; | ||
CentroidAccVelMod *cavMod; | ||
vector<LEDAccVelMod*> *lavMod; | ||
vector<unsigned char> *data; | ||
vector<uint8_t> pkType; | ||
|
||
RTTrPM(); | ||
~RTTrPM(); | ||
|
||
void printPacket(void); | ||
}; | ||
|
||
class RTTrPL | ||
{ | ||
public: | ||
RTTrP *header; | ||
LightingOutput *lightOut; | ||
LightingSync *sync; | ||
|
||
RTTrPL(); | ||
RTTrPL(RTTrPL* toCopy); | ||
~RTTrPL(); | ||
|
||
void printModule(void); | ||
}; | ||
|
||
#endif // RTTRP_H |
Oops, something went wrong.