Basic abstract communication class. Must be implemented by subclasses in charge of communication. More...
#include <BaseCommunication.h>
Public Member Functions | |
BaseCommunication () | |
Base constructor. | |
BaseCommunication (MONITORING_MODE monitor) | |
Base constructor. | |
~BaseCommunication () | |
Destructor. | |
void | SetSettings (BaseSettings *settings) |
Sets the communication settings. | |
BaseSettings * | GetSettings () |
Gets the communication settings. | |
void | SetDataExtractor (BaseDataExtractor *pDataExtractor) |
Sets the data extractor. | |
BaseDataExtractor * | GetDataExtractor () |
Gets the data extractir. | |
virtual void | Connect ()=0 |
Pure virtual method that will help the caller to proceed to the connection to media. | |
virtual void | Disconnect ()=0 |
Pure virtual method that will help the caller to proceed to media disconection. | |
int | GetConnectionState () |
Returns the actual connection state. /!\: monitoring must be turned to ON to get the realtime status. The default will be DISCONNECTED. | |
bool | IsConnected () |
Indicates rather or not connect or disconnect method has been called. | |
virtual string | SendCommand (string commandToSend)=0 |
Pure virtual method that will help the caller to send command on the media. | |
virtual RawData | WaitForRawData (int waitTimeout, unsigned long *semStatus)=0 |
Pure virtual method that will help the caller to wait for RAW data comming from the media. | |
void | AllocCallbackCaller (CONNECTION_CALLBACK *caller) |
Allocate the callback structure for the caller program Allocating the callback structure is mandatoring prior using the monitoring. | |
void | SetHeartBeatCallback (void(*pCallback)(CONNECTION_CALLBACK *)) |
Sets the caller program static method that will be called by the HEARTBEAT internal process. | |
void | StartMonitoring () |
Starts the monitoring process. | |
void | StopMonitoring () |
Stops the monitoring process. | |
virtual RawData | ExtractData (vector< string >pDataToExtract)=0 |
Pure virtual method that will help the caller to extract the rawdata from a stream. | |
virtual bool | IsCommandAcknowledgment (string pDataToVerify)=0 |
Pure virtual method that will help the caller to discriminate rawdata header from acknowledgment command data. | |
virtual bool | IsHeader (string pDataToVerify)=0 |
Pure virtual method that will thel the caller to check if the packet is a BEA Header. | |
virtual bool | IsEndOfPacket (string pDataToVerify)=0 |
Pure virtual method that will help the caller to check if stream packet is the end of stream. | |
virtual bool | IsFirstPacket (string pDataToVerify)=0 |
virtual int | GetPacketHeaderSizeToRead ()=0 |
Returns a pointer on an array with a determined size. | |
virtual int | CountToReadForLength (char *pHeaderBuffer)=0 |
Indicates how much byte must be read in order to obtain packet len. | |
virtual int | GetPacketLengthToRead (char *pLenHeaderBuffer, int pPacketType)=0 |
Retrieve, in the pLenHeaderBuffer, the amount of data to read. | |
BaseDataRecorder () | |
Base constructor. | |
~BaseDataRecorder () | |
Destructor. | |
virtual int | GetStatus ()=0 |
Returns the recorder's status (STOPPED, PLAYING, RECORDING) | |
virtual void | Play ()=0 |
Plays a record from the file. | |
virtual void | Pause ()=0 |
Pause the playback. | |
virtual void | Stop ()=0 |
Stops either playing or recording. | |
virtual void | Record ()=0 |
Start recording data. | |
virtual void | ExportToCsv (string pPathToExport, MEASURMENT_UNIT pMeasurmentSystem)=0 |
Exports record file to CSV only if recorder is in STOP mode. | |
virtual void | FetchRecord (RawData data)=0 |
Records RawData in the file (internal usage only) | |
virtual RawData | WaitForRawData ()=0 |
Wait for a data comming from the player. | |
void | SetFrameRate (int pFrameRate) |
Sets the framerate (thread safe) | |
int | GetFrameRate () |
Gets the current framerate (thread safe) | |
long | GetTotalFrame () |
Returns the total frames contained in the record. | |
long | GetCurrentFramePosition () |
Returns the actual frame position in the record whilm being played. | |
BaseSensor () | |
Base constructor. | |
BaseSensor (BaseCommunication *comm) | |
Copy constructor (sets the communication layer) | |
~BaseSensor () | |
Destructor. | |
BaseCommunication * | GetCommunication () |
Returns the communication layer. | |
void | SetCommunication (BaseCommunication *pCom) |
Sets the communication layer. | |
BaseDataRecorder * | GetDataRecorder () |
Returns the data recorder. | |
void | SetDataRecorder (BaseDataRecorder *pDataRecorder) |
Sets the data recorder. | |
virtual void | Initialize ()=0 |
Pure virtual definition of a function that will initialise the extend class (connection, threads creation etc.) | |
virtual RawData | RetrieveRawData ()=0 |
Pure virtual definition of a function that will help the caller to retrieve the data. | |
BaseSettings () | |
Base constructor. | |
~BaseSettings () | |
Destructor. | |
Static Public Attributes | |
static const int | STOPPED = 0 |
static const int | PLAYING = 1 |
static const int | RECORDING = 2 |
static const int | FAILED_START_RECORDING = 3 |
static const int | FAILED_INITIALIZE = 4 |
static const int | PAUSED = 5 |
Protected Member Functions | |
void | SetConnectionState (int connectionState) |
Indicates the default value for connection state flag. | |
virtual int | GetCommunicationStatus ()=0 |
Returns the communication status. | |
MONITORING_MODE | GetMonitoringMode () |
Returns the monitoring mode. | |
virtual void | Connect (bool forceMoninoring)=0 |
Proceed to TCP and UDP connection semaphores and mutex creation and Threads launching force monitoring or not. | |
void | SetTotalFrame (long pTotalFrame) |
Sets the total frame of the record. | |
void | SetCurrentFramePosition (long pCurrentFramePosition) |
Sets the current frame being read. | |
char | ComputeChecksum (string pTocompute) |
string | ComputeBinaryCommand (string pToCompute) |
Protected Attributes | |
bool | _connectHasBeenCalled = false |
volatile int | _connectionState = DISCONNECTED |
void * | _mutexMonitoring |
void * | _mutexConnectState |
The mutex for the monitoring flag. | |
volatile int | _connStatus = 0 |
The mutex for the connection state value. | |
CONNECTION_CALLBACK * | _callerCallback = NULL |
The real connection status given bythe monitoring process. | |
string | RAWDATA_HEADER = { (char)0xBE,(char)0xA0, 0x12, 0x34 } |
string | HEADER = { 0x02 , 0x02, (char)0xBE,(char)0xA0, 0x12, 0x34 } |
string | CHECKSUM = { 0x03 } |
string | cRN = { 0x63, 0x52, 0x4E } |
string | cWN = { 0x63, 0x57, 0x4E } |
string | cRA = { 0x63, 0x52, 0x41 } |
string | cWA = { 0x63, 0x57, 0x41 } |
string | SPC = { 0x20 } |
string | SendMDI = { 0x53 ,0x65 ,0x6E ,0x64 ,0x4D ,0x44 ,0x49 } |
string | StopMDI = { 0x53 ,0x74 ,0x6F ,0x70 ,0x4D ,0x44 ,0x49 } |
string | GetIP = { 0x47, 0x65, 0x74, 0x49, 0x50 } |
string | GetGW = { 0x47 ,0x65 ,0x74 ,0x47 ,0x57 } |
string | GetMask = { 0x47 ,0x65 ,0x74 ,0x4D ,0x61 ,0x73 ,0x6B } |
string | GetDHCP = { 0x47 ,0x65 ,0x74 ,0x44 ,0x48 ,0x43 ,0x50 } |
string | GetProto = { 0x47 ,0x65 ,0x74 ,0x50 ,0x72 ,0x6F ,0x74 ,0x6F } |
string | GetPort = { 0x47 ,0x65 ,0x74 ,0x50 ,0x6F ,0x72 ,0x74 } |
string | GetPType = { 0x47 ,0x65 ,0x74 ,0x50 ,0x54 ,0x79 ,0x70, 0x65 } |
string | GetResol = { 0x47 ,0x65 ,0x74 ,0x52 ,0x65 ,0x73 ,0x6F, 0x6C } |
string | GetDir = { 0x47 ,0x65 ,0x74 ,0x44 ,0x69 ,0x72 } |
string | GetRange = { 0x47 ,0x65 ,0x74 ,0x52, 0x61, 0x6E, 0x67, 0x65 } |
string | GetSkip = { 0x47 ,0x65 ,0x74 ,0x53, 0x6B, 0x69, 0x70 } |
string | GetCont = { 0x47 ,0x65 ,0x74 ,0x43, 0x6F, 0x6E, 0x74 } |
string | GetStat = { 0x47 ,0x65 ,0x74 ,0x53, 0x74, 0x61, 0x74 } |
string | GetVer = { 0x47 ,0x65 ,0x74 ,0x56, 0x65, 0x72 } |
string | GetTem = { 0x47 ,0x65 ,0x74 ,0x54, 0x65, 0x6D } |
string | GetELog = { 0x47 ,0x65 ,0x74 ,0x45, 0x4C, 0x6F, 0x67 } |
string | GetLED = { 0x47 ,0x65 ,0x74 ,0x4C, 0x45, 0x44 } |
string | GetLamp = { 0x47 ,0x65 ,0x74 ,0x4C, 0x61, 0x6D, 0x70 } |
string | GetEthCfg = { 0x47 ,0x65 ,0x74 ,0x45 ,0x74 ,0x68, 0x43, 0x66, 0x67 } |
string | GetHours = { 0x47 ,0x65 ,0x74 ,0x48 ,0x6F ,0x75, 0x72, 0x73 } |
string | GetName = { 0x47 ,0x65 ,0x74 ,0x4E ,0x61 ,0x6D, 0x65 } |
string | GetFilter = { 0x47 ,0x65 ,0x74 ,0x46 ,0x69 ,0x6C, 0x74, 0x65 , 0x72 } |
string | GetWCalib = { 0x47 ,0x65 ,0x74, 0x57, 0x43, 0x61, 0x6C, 0x69, 0x62 } |
string | GetECode = { 0x47 ,0x65 ,0x74 ,0x45 ,0x43 ,0x6F, 0x64, 0x65 } |
string | SetIP = { 0x53, 0x65, 0x74, 0x49, 0x50 } |
string | SetGW = { 0x53, 0x65, 0x74, 0x47, 0x57 } |
string | SetMask = { 0x53, 0x65, 0x74, 0x4D, 0x61, 0x73, 0x6B } |
string | SetDHCP = { 0x53, 0x65, 0x74, 0x44, 0x48, 0x43, 0x50 } |
string | SetProto = { 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x74,0x6F } |
string | SetPort = { 0x53, 0x65, 0x74, 0x50, 0x6F, 0x72, 0x74 } |
string | SetPType = { 0x53, 0x65, 0x74, 0x50, 0x54, 0x79, 0x70, 0x65 } |
string | SetResol = { 0x53, 0x65, 0x74, 0x52,0x65, 0x73, 0x6F, 0x6C } |
string | SetDir = { 0x53, 0x65, 0x74, 0x44, 0x69, 0x72 } |
string | SetRange = { 0x53, 0x65, 0x74, 0x52, 0x61, 0x6E, 0x67, 0x65 } |
string | SetSkip = { 0x53, 0x65, 0x74, 0x53, 0x6B, 0x69, 0x70 } |
string | SetCont = { 0x53, 0x65, 0x74, 0x43, 0x6F, 0x6E, 0x74 } |
string | SetLED = { 0x53, 0x65, 0x74, 0x4C, 0x45, 0x44 } |
string | SetEthCfg = { 0x53 ,0x65 ,0x74 ,0x45 ,0x74 ,0x68, 0x43, 0x66, 0x67 } |
string | SetName = { 0x53 ,0x65 ,0x74 ,0x4E ,0x61 ,0x6D, 0x65 } |
string | SetFilter = { 0x53 ,0x65 ,0x74 ,0x46 ,0x69 ,0x6C, 0x74, 0x65 , 0x72 } |
string | SetWCalib = { 0x53 ,0x65 ,0x74, 0x57, 0x43, 0x61, 0x6C, 0x69, 0x62 } |
string | Reset = { 0x52, 0x65, 0x73, 0x65, 0x74 } |
string | Reboot = { 0x52, 0x65, 0x62, 0x6F, 0x6F, 0x74 } |
Basic abstract communication class. Must be implemented by subclasses in charge of communication.
Basic abstract communication settings class. Must be implemented by subclasses in charge of communication settings.
Basic representation of a sensor. Must be inherited by subclasses in charge of sensor implementation This base class encapsulate the communication mechanism.
A basic data extractor used by the communication classes to know HOW to extract RAW data from a stream.
abstract::~BaseCommunication | ( | ) |
Destructor.
abstract::~BaseDataRecorder | ( | ) |
Destructor.
abstract::~BaseSensor | ( | ) |
Destructor.
abstract::~BaseSettings | ( | ) |
Destructor.
void abstract::AllocCallbackCaller | ( | CONNECTION_CALLBACK * | caller | ) |
Allocate the callback structure for the caller program Allocating the callback structure is mandatoring prior using the monitoring.
caller | A pointer to the caller structure |
abstract::BaseCommunication | ( | ) |
Base constructor.
abstract::BaseCommunication | ( | MONITORING_MODE | monitor | ) |
Base constructor.
abstract::BaseDataRecorder | ( | ) |
Base constructor.
abstract::BaseSensor | ( | ) |
Base constructor.
abstract::BaseSensor | ( | BaseCommunication * | comm | ) |
Copy constructor (sets the communication layer)
comm | The communication layer to be used |
abstract::BaseSettings | ( | ) |
Base constructor.
|
protected |
|
protected |
|
pure virtual |
Pure virtual method that will help the caller to proceed to the connection to media.
|
protectedpure virtual |
Proceed to TCP and UDP connection semaphores and mutex creation and Threads launching force monitoring or not.
forceMoninoring | true: forces the monitoring check |
|
pure virtual |
Indicates how much byte must be read in order to obtain packet len.
|
pure virtual |
Pure virtual method that will help the caller to proceed to media disconection.
|
pure virtual |
Exports record file to CSV only if recorder is in STOP mode.
pPathToExport | The fulle filepath name to export the data |
|
pure virtual |
Pure virtual method that will help the caller to extract the rawdata from a stream.
pDataToExtract | A vector representing the data frames |
|
pure virtual |
Records RawData in the file (internal usage only)
data | The rawdata to be recorded |
BaseCommunication * abstract::GetCommunication | ( | ) |
Returns the communication layer.
|
protectedpure virtual |
Returns the communication status.
int abstract::GetConnectionState | ( | ) |
Returns the actual connection state. /!\: monitoring must be turned to ON to get the realtime status. The default will be DISCONNECTED.
long abstract::GetCurrentFramePosition | ( | ) |
Returns the actual frame position in the record whilm being played.
BaseDataExtractor * abstract::GetDataExtractor | ( | ) |
Gets the data extractir.
BaseDataRecorder * abstract::GetDataRecorder | ( | ) |
Returns the data recorder.
int abstract::GetFrameRate | ( | ) |
Gets the current framerate (thread safe)
|
protected |
Returns the monitoring mode.
|
pure virtual |
Returns a pointer on an array with a determined size.
|
pure virtual |
Retrieve, in the pLenHeaderBuffer, the amount of data to read.
pLenHeaderBuffer | |
pPacketType |
BaseSettings * abstract::GetSettings | ( | ) |
Gets the communication settings.
|
pure virtual |
Returns the recorder's status (STOPPED, PLAYING, RECORDING)
long abstract::GetTotalFrame | ( | ) |
Returns the total frames contained in the record.
|
pure virtual |
Pure virtual definition of a function that will initialise the extend class (connection, threads creation etc.)
|
pure virtual |
Pure virtual method that will help the caller to discriminate rawdata header from acknowledgment command data.
pDataToVerify | A string representing the stream result |
bool abstract::IsConnected | ( | ) |
Indicates rather or not connect or disconnect method has been called.
|
pure virtual |
Pure virtual method that will help the caller to check if stream packet is the end of stream.
pDataToVerify | A string representing the setream packet |
|
pure virtual |
Pure virtual method that will help the caller to check if stream packet is the first packet of stream
pDataToVerify | A string representing the setream packet |
|
pure virtual |
Pure virtual method that will thel the caller to check if the packet is a BEA Header.
pDataToVerify | A string representing the stream packet |
|
pure virtual |
Pause the playback.
|
pure virtual |
Plays a record from the file.
|
pure virtual |
Start recording data.
|
pure virtual |
Pure virtual definition of a function that will help the caller to retrieve the data.
|
pure virtual |
Pure virtual method that will help the caller to send command on the media.
commandToSend | A string representing the command to be sent |
void abstract::SetCommunication | ( | BaseCommunication * | pCom | ) |
Sets the communication layer.
pCom | The communication layer to be set |
|
protected |
Indicates the default value for connection state flag.
Sets the connection state
connectionState | The connection state new value |
|
protected |
Sets the current frame being read.
pCurrentFramePosition | The current frame position |
void abstract::SetDataExtractor | ( | BaseDataExtractor * | pDataExtractor | ) |
Sets the data extractor.
pDataExtractor | The data extractor to be set |
void abstract::SetDataRecorder | ( | BaseDataRecorder * | pDataRecorder | ) |
Sets the data recorder.
pDataRecorder | The data recorder layer to be set |
void abstract::SetFrameRate | ( | int | pFrameRate | ) |
Sets the framerate (thread safe)
pFrameRate | an integer representing the framerate |
void abstract::SetHeartBeatCallback | ( | void(*)(CONNECTION_CALLBACK *) | pCallback | ) |
Sets the caller program static method that will be called by the HEARTBEAT internal process.
pCallback | A pointer to a static method |
void abstract::SetSettings | ( | BaseSettings * | settings | ) |
Sets the communication settings.
settings | The communication settings to be set |
|
protected |
Sets the total frame of the record.
pTotalFrame | The total frame |
void abstract::StartMonitoring | ( | ) |
Starts the monitoring process.
|
pure virtual |
Stops either playing or recording.
void abstract::StopMonitoring | ( | ) |
Stops the monitoring process.
|
pure virtual |
Wait for a data comming from the player.
|
pure virtual |
Pure virtual method that will help the caller to wait for RAW data comming from the media.
waitTimeout | The amount of miliseconds the process has to wait befor being released |
semStatus | The status of the semaphore (updated by reference) |
|
protected |
The real connection status given bythe monitoring process.
|
protected |
|
protected |
|
protected |
The mutex for the connection state value.
|
protected |
The mutex for the monitoring flag.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
static |
|
protected |
|
protected |
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |