You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

211 lines
4.9 KiB

#ifndef __PROTOCOLTGZ_H_INCL__
#define __PROTOCOLTGZ_H_INCL__
#include "../../components/base/basicTransport.h"
#include "../../components/base/basicLogCollection.h"
#include "protocol.h"
#define MASTER_TAG 0x80
#define SENSOR_TAG 0x00
#define SEND_TAG MASTER_TAG
#define ACCEPT_TAG SENSOR_TAG
/**
* TODO: Add class description
*
* @author gagua
*/
class protocolTGZ : public protocolParser {
private:
basicLogCollection *m_pLog;
protected:
//U8 m_bDeviceID;
//U8 m_bHostID;
unsigned int preparing;
unsigned int lastSent;
unsigned int lastReceived;
bool m_bRun;
bool m_bErrorReset;
bool m_bVersion2;
U8 m_bPRF;
U8 m_bRatio;
U8 m_bDivider;
uint16_t m_nQFreq;
uint16_t m_nBFreq;
int packetChecker( U8 *Buffer, size_t BufferSize );
protocolPackage *packetExtractor(U8 *Buffer, size_t BufferSize );
basicTransport *m_oDataTransport;
void update( void );
public:
// Constructor
protocolTGZ();
protocolTGZ( basicTransport *canBus );//, U8 MyID = 0, U8 PeerID = 0 );
// Destructor
virtual ~protocolTGZ();
// Copy constructor
// TODO: Uncomment the copy constructor when you need it.
//protocolTGZ(const protocolTGZ& src);
// Assignment operator
// TODO: Uncomment the assignment operator when you need it.
//protocolTGZ& operator=(const protocolTGZ& src);
bool startDeviceStateInquiry( void );
void setRunMode( bool mode ){
m_bRun = mode;
update();
};
void setPrfMode( uint8_t kHz ){
m_bPRF = kHz;
update();
};
void setRatio( uint8_t ratio ){
m_bRatio = ratio;
update();
};
void setDivider( uint8_t divider ){
m_bDivider = divider;
update();
};
void setErrorMode( bool reset ){
m_bErrorReset = reset;
update();
};
uint32_t getLastSend( void ){ return lastSent;};
uint32_t getPreparing( void ){ return preparing;};
uint32_t getLastReceived( void ){ return lastReceived; };
uint8_t getRatio( void ){ return m_bRatio; };
uint8_t getDivider( void ){ return m_bDivider; };
uint8_t getPRF( void ){ return m_bPRF; };
bool getRunFlag( void ){ return m_bRun; };
bool getResetFlag( void ){ return m_bErrorReset; };
uint16_t getQSpeed( void ){ return m_nQFreq; };
uint16_t getBSpeed( void ){ return m_nBFreq; };
void toggleRun( void ){m_bRun=(m_bRun)?false:true; update();};
void toggleErrorReset( void ){m_bErrorReset=(m_bErrorReset)?false:true; update();};
void toggleQSpeed( void ){
m_bVersion2 = true;
if(m_nQFreq==0) {
m_nQFreq = 12000;
}else if(m_nQFreq== 12000) {
m_nQFreq = 26000;
}else if(m_nQFreq==26000) {
m_nQFreq = 40000;
}else if(m_nQFreq==40000) {
m_nQFreq = 12000;
};
update();
};
void toggleBSpeed( void ){
m_bVersion2 = true;
if(m_nBFreq==0) {
m_nBFreq = 2944;
}else if(m_nBFreq== 2944) {
m_nBFreq = 5888;
}else if(m_nBFreq==5888) {
m_nBFreq = 8832;
}else if(m_nQFreq==8832) {
m_nBFreq = 2944;
};
update();
};
void togglePRF( void ){
if(m_bPRF==0) {
m_bPRF = 35;
}else if(m_bPRF== 35) {
m_bPRF = 45;
}else if(m_bPRF==45) {
m_bPRF = 50;
}else if(m_bPRF==50) {
m_bPRF = 35;
};
update();
};
void togleRatio( void ){
if(m_bRatio==0) {
m_bRatio = 64;
} else if(m_bRatio==64) {
m_bRatio = 72;
} else if(m_bRatio==72) {
m_bRatio = 98;
} else if(m_bRatio==98) {
m_bRatio = 128;
} else if(m_bRatio==128) {
m_bRatio = 64;
};
update();
};
void toggleDivider( void ){
if(m_bDivider==0) {
m_bDivider = 1;
} else if(m_bDivider==1) {
m_bDivider = 2;
} else if(m_bDivider==2) {
m_bDivider = 4;
} else if(m_bDivider==4) {
m_bDivider = 1;
};
update();
};
void stopPRF( void ){
m_bPRF = 0;
update();
};
void stopAzimuth( void ){
m_bRatio = 0;
update();
};
void setSpeeds( uint16_t QSpeed, uint16_t BSpeed ){
m_bVersion2 = true;
m_nBFreq = BSpeed;
m_nQFreq = QSpeed;
update();
};
char *generateFileNameForStat( void ){
char *Buffer;
Buffer = (char*)malloc(120);
if(Buffer!=NULL) {
sprintf( Buffer, "stat_%02dkHz_1-%02d_div_%02d.csv", m_bPRF, m_bRatio, m_bDivider );
};
return Buffer;
};
};
// Constructor implementation
inline protocolTGZ::protocolTGZ() : protocolParser(){
m_pLog = basicLogCollection::getInstance();
}
// Destructor implementation
inline protocolTGZ::~protocolTGZ()
{
}
// TODO: Uncomment the copy constructor when you need it.
//inline protocolTGZ::protocolTGZ(const protocolTGZ& src)
//{
// // TODO: copy
//}
// TODO: Uncomment the assignment operator when you need it.
//inline protocolTGZ& protocolTGZ::operator=(const protocolTGZ& rhs)
//{
// if (this == &rhs) {
// return *this;
// }
//
// // TODO: assignment
//
// return *this;
//}
#endif // __PROTOCOLTGZ_H_INCL__