| Visioscan Set SDK Libraries 1.0.28 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 <future>
6#include "BaseSettings.h"
7#include "RawData.h"
8#include "BaseDataExtractor.h"
9#include "CommunicationStructures.h"
10
11//#define MONITORING_ENABLED
12
13 using namespace std;
14
15#ifdef STARFLEETTOOLBOX_EXPORTS
16#define BASECOMM __declspec(dllexport)
17#else
18#define BASECOMM __declspec(dllimport)
19#endif
20
21#define MONITORING_TIMESLEEP 250 // Sets the loop period of the monitoring system
22#define RECONNECT_TIMESLEEP 250 // Sets the reconnect timeout period in the monitoring system
23
24
25#define MONITORING_MODE unsigned int
26#define MONITORING_OFF 0 // Indicates that monitoring is OFF
27#define MONITORING_ON 1 // Indicates that monitoring is ON
28#define AUTO_RECONNECT 2 // Indicates that monitoring is ON and auto reconnect mode is on
29
30 typedef void (*MarshallingConnectionCheckerCallback)(CommunicationStatus*);
31 typedef std::function<void(CommunicationStatus*)> ConnectionCheckerCallback;
32
36 class BASECOMM BaseCommunication abstract
37{
38 public:
42 BaseCommunication();
43
47 BaseCommunication(MONITORING_MODE monitor);
48
52 ~BaseCommunication();
53
58 void SetSettings(BaseSettings* settings);
59
64 BaseSettings* GetSettings();
65
66
71 void SetDataExtractor(BaseDataExtractor* pDataExtractor);
72
77 BaseDataExtractor* GetDataExtractor();
78
83 virtual CommunicationStatus Connect() = 0;
84
88 virtual void Disconnect() = 0;
89
94 virtual CommunicationStatus GetConnectionStatus() = 0;
95
100 bool IsConnected();
101
102
109 virtual string SendCommand(string commandToSend) = 0;
110
118 virtual RawData WaitForRawData(int waitTimeout, unsigned long* semStatus) = 0;
119
123 void StartMonitoring();
124
128 void StopMonitoring();
129
130 void SetCommunicationCallback(ConnectionCheckerCallback);
131 void SetCommunicationCallback(void(* ConnectionCheckerCallbackMethod)(CommunicationStatus*));
132
133 protected:
134 std::atomic<bool> _connected;
135 std::atomic<bool> _reconnecting;
136 bool _connectHasBeenCalled = false;
137
142 MONITORING_MODE GetMonitoringMode();
143
144 virtual CommunicationStatus Reconnect() = 0;
145
146 void *_mutexMonitoring;
147 void* _mutexConnectState;
148 volatile int _connStatus = 0;
149 private:
150 std::atomic<bool> _monitoringExit;
151 thread _monitoringWorker;
152 MONITORING_MODE _monitoringMode = MONITORING_OFF;
153 ConnectionCheckerCallback _monitorinCallBack = NULL;
154 void AsyncWrapper(ConnectionCheckerCallback, CommunicationStatus*); // async wrapper for callback
155 void MonitoringBusiness();
156
157 BaseSettings* _settings;
158 BaseDataExtractor* _dataExtractor;
159};
160
abstract::StartMonitoring
void StartMonitoring()
Starts the monitoring process.
abstract::BaseCommunication
BaseCommunication()
Base constructor.
abstract::Disconnect
virtual void Disconnect()=0
Pure virtual method that will help the caller to proceed to media disconection.
abstract::SetDataExtractor
void SetDataExtractor(BaseDataExtractor *pDataExtractor)
Sets the data extractor.
abstract::GetDataExtractor
BaseDataExtractor * GetDataExtractor()
Gets the data extractir.
abstract::_connected
std::atomic< bool > _connected
Definition BaseCommunication.h:134
abstract::WaitForRawData
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.
abstract::SetCommunicationCallback
void SetCommunicationCallback(ConnectionCheckerCallback)
abstract::IsConnected
bool IsConnected()
Indicates rather or not connect or disconnect method has been called.
abstract::GetSettings
BaseSettings * GetSettings()
Gets the communication settings.
abstract::_reconnecting
std::atomic< bool > _reconnecting
Definition BaseCommunication.h:135
abstract::Reconnect
virtual CommunicationStatus Reconnect()=0
abstract::SetCommunicationCallback
void SetCommunicationCallback(void(*ConnectionCheckerCallbackMethod)(CommunicationStatus *))
abstract::StopMonitoring
void StopMonitoring()
Stops the monitoring process.
abstract::GetConnectionStatus
virtual CommunicationStatus GetConnectionStatus()=0
Returns the actual connection state.
abstract::Connect
virtual CommunicationStatus Connect()=0
Pure virtual method that will help the caller to proceed to the connection to media.
abstract::_mutexMonitoring
void * _mutexMonitoring
Definition BaseCommunication.h:146
abstract::GetMonitoringMode
MONITORING_MODE GetMonitoringMode()
Returns the monitoring mode.
abstract::SendCommand
virtual string SendCommand(string commandToSend)=0
Pure virtual method that will help the caller to send command on the media.
abstract::~BaseCommunication
~BaseCommunication()
Destructor.
abstract::BaseCommunication
BaseCommunication(MONITORING_MODE monitor)
Base constructor.
abstract::_mutexConnectState
void * _mutexConnectState
The mutex for the monitoring flag.
Definition BaseCommunication.h:147
abstract::SetSettings
void SetSettings(BaseSettings *settings)
Sets the communication settings.
CommunicationStatus
Definition CommunicationStructures.h:24
RawData
The base class encapsulating sensor's RAW data.
Definition RawData.h:14