Visioscan Set SDK Libraries 1.0.14
Visioscan Set SDK Help documentation file for C++ and C++/CLI
 
Loading...
Searching...
No Matches
BaseCommunication.h
1#pragma once
2#include <string>
3#include <thread>
4#include <iostream>
5#include "BaseSettings.h"
6#include "RawData.h"
7#include "BaseDataExtractor.h"
8#include "Callback.h"
9
10#define MONITORING_ENABLED
11
12using namespace std;
13
14#ifdef STARFLEETTOOLBOX_EXPORTS
15#define BASECOMM __declspec(dllexport)
16#else
17#define BASECOMM __declspec(dllimport)
18#endif
19
20#define MONITORING_TIMESLEEP 500 // Sets the loop period of the monitoring system
21
22#define MONITORING_MODE unsigned int
23#define MONITORING_OFF 0 // Indicates that monitoring is OFF
24#define MONITORING_ON 1 // Indicates that monitoring is ON
25#define AUTO_RECONNECT 2 // Indicates that monitoring is ON and auto reconnect mode is on
26
27#define CONNECTION_LOST 3 // The connection has been lost
28#define DISCONNECTING 4 // The system is disconnecting and clearing any ressources linked to physical connection
29#define RECONNECTING 5 // The system is reconnecting and allocating ressources linged to physical connection
30#define RECONNECTED 6 // The host has been reconnected
31#define DISCONNECTED 7 // The host has been disconnected
32#define CONNECTION_BACK 8 // The host connection is back
33#define NO_CONNECTION 9 // There is no connection to the host
34#define CONNECTED 10 // There is a connection to the host
35
39class BASECOMM BaseCommunication abstract
40{
41public:
46
50 BaseCommunication(MONITORING_MODE monitor);
51
56
61 void SetSettings(BaseSettings* settings);
62
67 BaseSettings* GetSettings();
68
69
74 void SetDataExtractor(BaseDataExtractor* pDataExtractor);
75
80 BaseDataExtractor* GetDataExtractor();
81
86 virtual void Connect() = 0;
87
88
92 virtual void Disconnect() = 0;
93
100
106
107
114 virtual string SendCommand(string commandToSend) = 0;
115
123 virtual RawData WaitForRawData(int waitTimeout, unsigned long* semStatus) = 0;
124
131
136 void SetHeartBeatCallback(void (*pCallback)(CONNECTION_CALLBACK*));
137
142
147
148
149protected:
150 bool _connectHasBeenCalled = false;
151 volatile int _connectionState = DISCONNECTED;
152
157 void SetConnectionState(int connectionState);
158
163 virtual int GetCommunicationStatus() = 0;
164
165
166
171 MONITORING_MODE GetMonitoringMode();
172
173
180 virtual void Connect(bool forceMoninoring) = 0;
181
184 volatile int _connStatus = 0;
185 CONNECTION_CALLBACK* _callerCallback = NULL;
186private:
187
188
189 MONITORING_MODE _monitoringMode = MONITORING_OFF;
190 thread _monitoringWorker;
191
195 void MonitoringBusiness(CONNECTION_CALLBACK *connCallback);
196
197 bool _monitoringExit = false;
198 void (*callback)(CONNECTION_CALLBACK*);
199
200 BaseSettings* _settings;
201 BaseDataExtractor* _dataExtractor;
202};
203
void StartMonitoring()
Starts the monitoring process.
int GetConnectionState()
Returns the actual connection state. /!\: monitoring must be turned to ON to get the realtime status....
BaseCommunication()
Base constructor.
virtual void Disconnect()=0
Pure virtual method that will help the caller to proceed to media disconection.
void SetConnectionState(int connectionState)
Indicates the default value for connection state flag.
void SetDataExtractor(BaseDataExtractor *pDataExtractor)
Sets the data extractor.
BaseDataExtractor * GetDataExtractor()
Gets the data extractir.
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 SetHeartBeatCallback(void(*pCallback)(CONNECTION_CALLBACK *))
Sets the caller program static method that will be called by the HEARTBEAT internal process.
bool IsConnected()
Indicates rather or not connect or disconnect method has been called.
void AllocCallbackCaller(CONNECTION_CALLBACK *caller)
Allocate the callback structure for the caller program Allocating the callback structure is mandatori...
BaseSettings * GetSettings()
Gets the communication settings.
virtual void Connect(bool forceMoninoring)=0
Proceed to TCP and UDP connection semaphores and mutex creation and Threads launching force monitorin...
virtual int GetCommunicationStatus()=0
Returns the communication status.
virtual void Connect()=0
Pure virtual method that will help the caller to proceed to the connection to media.
void StopMonitoring()
Stops the monitoring process.
void * _mutexMonitoring
Definition BaseCommunication.h:182
MONITORING_MODE GetMonitoringMode()
Returns the monitoring mode.
virtual string SendCommand(string commandToSend)=0
Pure virtual method that will help the caller to send command on the media.
~BaseCommunication()
Destructor.
BaseCommunication(MONITORING_MODE monitor)
Base constructor.
void * _mutexConnectState
The mutex for the monitoring flag.
Definition BaseCommunication.h:183
void SetSettings(BaseSettings *settings)
Sets the communication settings.
Definition Callback.h:2
The base class encapsulating sensor's RAW data.
Definition RawData.h:14