| Visioscan Set SDK Libraries 1.3.5 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
111
119 virtual string SendCommand(string commandToSend, int specificTimeout) = 0;
120
128 virtual RawData WaitForRawData(int waitTimeout, unsigned long* semStatus) = 0;
129
133 void StartMonitoring();
134
138 void StopMonitoring();
139
140 void SetCommunicationCallback(ConnectionCheckerCallback);
141 void SetCommunicationCallback(void(* ConnectionCheckerCallbackMethod)(CommunicationStatus*));
142
143 protected:
144 std::atomic<bool> _connected;
145 std::atomic<bool> _reconnecting;
146 std::atomic<bool> _isConnected;
147
152 MONITORING_MODE GetMonitoringMode();
153
154 virtual CommunicationStatus Reconnect() = 0;
155
156 void *_mutexMonitoring;
157 void* _mutexConnectState;
158 volatile int _connStatus = 0;
159 private:
160 std::atomic<bool> _monitoringExit;
161 thread _monitoringWorker;
162 MONITORING_MODE _monitoringMode = MONITORING_OFF;
163 ConnectionCheckerCallback _monitorinCallBack = NULL;
164 void AsyncWrapper(ConnectionCheckerCallback, CommunicationStatus*); // async wrapper for callback
165 void MonitoringBusiness();
166
167 BaseSettings* _settings;
168 BaseDataExtractor* _dataExtractor;
169};
170
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:144
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:145
abstract::Reconnect
virtual CommunicationStatus Reconnect()=0
abstract::SetCommunicationCallback
void SetCommunicationCallback(void(*ConnectionCheckerCallbackMethod)(CommunicationStatus *))
abstract::_isConnected
std::atomic< bool > _isConnected
Definition BaseCommunication.h:146
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:156
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::SendCommand
virtual string SendCommand(string commandToSend, int specificTimeout)=0
Pure virtual method that will help the caller to send command on the media with a specific timeout.
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:157
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