\doxysection{Base\+Communication.\+h}
\hypertarget{a00314_source}{}\label{a00314_source}\index{BaseCommunication.h@{BaseCommunication.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ <string>}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ <thread>}}
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <future>}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ "{}BaseSettings.h"{}}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ "{}RawData.h"{}}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ "{}BaseDataExtractor.h"{}}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ "{}CommunicationStructures.h"{}}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{comment}{//\#define\ MONITORING\_ENABLED}}
\DoxyCodeLine{00012\ }
\DoxyCodeLine{00013\ \textcolor{keyword}{using\ namespace\ }std;}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#ifdef\ STARFLEETTOOLBOX\_EXPORTS}}
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#define\ BASECOMM\ \_\_declspec(dllexport)}}
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#define\ BASECOMM\ \_\_declspec(dllimport)}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ MONITORING\_TIMESLEEP\ 250\ \ \ \ \ \ \ \ }\textcolor{comment}{//\ Sets\ the\ loop\ period\ of\ the\ monitoring\ system}}
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#define\ RECONNECT\_TIMESLEEP\ 250\ \ \ \ \ \ \ \ \ }\textcolor{comment}{//\ Sets\ the\ reconnect\ timeout\ period\ in\ the\ monitoring\ system}}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#define\ MONITORING\_MODE\ unsigned\ int}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#define\ MONITORING\_OFF\ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{//\ Indicates\ that\ monitoring\ is\ OFF}}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#define\ MONITORING\_ON\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{//\ Indicates\ that\ monitoring\ is\ ON}}
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#define\ AUTO\_RECONNECT\ 2\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{//\ Indicates\ that\ monitoring\ is\ ON\ and\ auto\ reconnect\ mode\ is\ on}}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \textcolor{keyword}{typedef}\ void\ \ (*MarshallingConnectionCheckerCallback)(\mbox{\hyperlink{a00856}{CommunicationStatus}}*);}
\DoxyCodeLine{00031\ \textcolor{keyword}{typedef}\ std::function<void(\mbox{\hyperlink{a00856}{CommunicationStatus}}*)>\ ConnectionCheckerCallback;}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00036\ \textcolor{keyword}{class\ }BASECOMM\ BaseCommunication\ \textcolor{keyword}{abstract}}
\DoxyCodeLine{00037\ \{}
\DoxyCodeLine{00038\ \textcolor{keyword}{public}:\ }
\DoxyCodeLine{00042\ \ \ \ \ \mbox{\hyperlink{a00836_a07f5ac904bd6f3354aadec16d55243f7}{BaseCommunication}}();}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00047\ \ \ \ \ \mbox{\hyperlink{a00836_aef19a00c52069f410a0f8916d5b2c236}{BaseCommunication}}(MONITORING\_MODE\ monitor);}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00052\ \ \ \ \ \mbox{\hyperlink{a00836_ae02c3d34c0bb14f8348455aba656216d}{\string~BaseCommunication}}();}
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_afd346eecd704ce15a1be7a4af2fa2ec2}{SetSettings}}(BaseSettings*\ settings);}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00064\ \ \ \ \ BaseSettings*\ \mbox{\hyperlink{a00836_a4f810efa6eb6e0476612b5bf3b336fb2}{GetSettings}}();}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_a1f7d7847fe8775bac2b8e1be30548f3a}{SetDataExtractor}}(BaseDataExtractor*\ pDataExtractor);}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00077\ \ \ \ \ BaseDataExtractor*\ \mbox{\hyperlink{a00836_a28146f1285657c087407c2431b8d0c60}{GetDataExtractor}}();}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00083\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a00856}{CommunicationStatus}}\ \mbox{\hyperlink{a00836_ab3946b9007a5532974c29ff66531e6e0}{Connect}}()\ =\ 0;}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00088\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_a0851786556bc3f2d48a482d46d811772}{Disconnect}}()\ =\ 0;}
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00094\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a00856}{CommunicationStatus}}\ \mbox{\hyperlink{a00836_aa5d2f9d3491830e2f20b15885a68db42}{GetConnectionStatus}}()\ =\ 0;}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{a00836_a3f41a0cc57c9f1290a117d605f41a51d}{IsConnected}}();}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ }
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{string}\ \mbox{\hyperlink{a00836_ab5819dd22ed975cb2fb0ed11e704d5dd}{SendCommand}}(\textcolor{keywordtype}{string}\ commandToSend)\ =\ 0;}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{string}\ \mbox{\hyperlink{a00836_aba6d9bca10a62932638764ec21973f27}{SendCommand}}(\textcolor{keywordtype}{string}\ commandToSend,\ \textcolor{keywordtype}{int}\ specificTimeout)\ =\ 0;}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00128\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a00928}{RawData}}\ \mbox{\hyperlink{a00836_a35004113eae585ed10bb3694d7f0eab6}{WaitForRawData}}(\textcolor{keywordtype}{int}\ waitTimeout,\ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{long}*\ semStatus)\ =\ 0;\ }
\DoxyCodeLine{00129\ }
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_a005c3939de711e08d09bb30371df3bd2}{StartMonitoring}}();}
\DoxyCodeLine{00134\ \ \ \ \ }
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_aa22491626e2b50a98b7aa8e9f2d5b4ff}{StopMonitoring}}();}
\DoxyCodeLine{00139\ }
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_a3ba6fd416e32aa116ea82655defeb205}{SetCommunicationCallback}}(ConnectionCheckerCallback);}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00836_a73f7ab05a5ed41818c5a0f79cfe0b5e0}{SetCommunicationCallback}}(\textcolor{keywordtype}{void}(*\ ConnectionCheckerCallbackMethod)(\mbox{\hyperlink{a00856}{CommunicationStatus}}*));}
\DoxyCodeLine{00142\ }
\DoxyCodeLine{00143\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00144\ \ \ \ \ std::atomic<bool>\ \mbox{\hyperlink{a00836_a2959180701d69a8061bd6e59edca42c8}{\_connected}};}
\DoxyCodeLine{00145\ \ \ \ \ std::atomic<bool>\ \mbox{\hyperlink{a00836_a57a3cfeacbfabfb17ba6e41caf737fa2}{\_reconnecting}};}
\DoxyCodeLine{00146\ \ \ \ \ std::atomic<bool>\ \mbox{\hyperlink{a00836_a93a00ff8ab2097570bb6fe3080daf2e3}{\_isConnected}};}
\DoxyCodeLine{00147\ }
\DoxyCodeLine{00152\ \ \ \ \ MONITORING\_MODE\ \mbox{\hyperlink{a00836_ab53ea74bb34e96b762909cd6ffa07f9e}{GetMonitoringMode}}();}
\DoxyCodeLine{00153\ \ \ \ \ }
\DoxyCodeLine{00154\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a00856}{CommunicationStatus}}\ \mbox{\hyperlink{a00836_a5ccb13b9db4d02848440204df46d7286}{Reconnect}}()\ =\ 0;}
\DoxyCodeLine{00155\ }
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keywordtype}{void}\ *\mbox{\hyperlink{a00836_ab506370bda5af9ad4410fa8ce0b8e208}{\_mutexMonitoring}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00157\ \ \ \ \ \textcolor{keywordtype}{void}*\ \mbox{\hyperlink{a00836_af346187b19db87c2f15550c1af786ab8}{\_mutexConnectState}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00158\ \ \ \ \ \textcolor{keyword}{volatile}\ \textcolor{keywordtype}{int}\ \_connStatus\ =\ 0;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00159\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00160\ \ \ \ \ std::atomic<bool>\ \_monitoringExit;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00161\ \ \ \ \ thread\ \_monitoringWorker;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00162\ \ \ \ \ MONITORING\_MODE\ \_monitoringMode\ =\ MONITORING\_OFF;\ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00163\ \ \ \ \ ConnectionCheckerCallback\ \_monitorinCallBack\ =\ NULL;\ \ \ \ \ \ \ \ }
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{keywordtype}{void}\ AsyncWrapper(ConnectionCheckerCallback,\ \mbox{\hyperlink{a00856}{CommunicationStatus}}*);\ \textcolor{comment}{//\ async\ wrapper\ for\ callback}}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{keywordtype}{void}\ MonitoringBusiness();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00166\ \ \ \ \ }
\DoxyCodeLine{00167\ \ \ \ \ BaseSettings*\ \_settings;}
\DoxyCodeLine{00168\ \ \ \ \ BaseDataExtractor*\ \_dataExtractor;}
\DoxyCodeLine{00169\ \};}
\DoxyCodeLine{00170\ }

\end{DoxyCode}
