\doxysection{WBase\+Communication.\+h}
\hypertarget{a00485_source}{}\label{a00485_source}\index{WBaseCommunication.h@{WBaseCommunication.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#pragma\ make\_public(BaseCommunication)}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ "{}WBaseSettings.h"{}}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}BaseCommunication.h"{}}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ "{}WCommunicationStatus.h"{}}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ \textcolor{keyword}{using\ namespace\ }System::Threading;}
\DoxyCodeLine{00009\ \textcolor{keyword}{using\ namespace\ }System;}
\DoxyCodeLine{00010\ \textcolor{keyword}{using\ namespace\ }System::Runtime::InteropServices;}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{keyword}{public}\ delegate\ \textcolor{keywordtype}{void}\ ManagedDelegate(\mbox{\hyperlink{a00856}{CommunicationStatus}}*);}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ \textcolor{keyword}{public}\ delegate\ \textcolor{keywordtype}{void}\ CommunicationEventHandler(System::Object\string^\ sender,\ \mbox{\hyperlink{a00988}{WUtils::WCommunicationStatus}}\string^\ e);}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \textcolor{keyword}{namespace\ }\mbox{\hyperlink{a00635}{WBase}}\ \{}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \ \ \ \ \textcolor{keyword}{public\ ref\ class}\ WBaseCommunication\ \textcolor{keyword}{abstract}}
\DoxyCodeLine{00019\ \ \ \ \ \{}
\DoxyCodeLine{00020\ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00972_a48ab624d5c6c11938d5fb0776282631e}{WBaseCommunication}}()\ \{\ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00023\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00972_acb82ce6ddbeb34388df50af02c16fccd}{\string~WBaseCommunication}}()\ \{}
\DoxyCodeLine{00026\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00027\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00032\ \ \ \ \ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a00988}{WUtils::WCommunicationStatus}}\string^\ \mbox{\hyperlink{a00972_a9153f0a1bd56e7f20ecaf3d99d2480f4}{Connect}}()\ =\ 0;}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00972_a919a37784f33300eaaff10106e4ae864}{Disconnect}}()\ =\ 0;}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{a00972_a1c5ff9d8187760dccd7d83979b36f595}{IsConnected}}()\ \{}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \_communication-\/>IsConnected();}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Properties}}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ \textcolor{keyword}{property}\ WBaseSettings\string^\ Settings\ \{}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \ \ \ \ WBaseSettings\string^\ get()\ \{}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \_settings;}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ set(WBaseSettings\string^\ pSettings)\ \{}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_settings\ =\ pSettings;}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ \textcolor{keyword}{property}\ BaseCommunication*\ \_\_nativeCommunication\ \{}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \ \ \ \ BaseCommunication*\ get()\ \{}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \_communication;}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ \textcolor{keyword}{event}\ CommunicationEventHandler\string^\ CommunicationEvent\ \{}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ add(CommunicationEventHandler\string^\ handler)\ \{}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!\_callbackAssigned)\ \{}
\DoxyCodeLine{00067\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ IntPtr\ ptr\ =\ this-\/>GetFunctionPointer();}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ MarshallingConnectionCheckerCallback\ nativeFunc\ =\ \textcolor{keyword}{reinterpret\_cast<}MarshallingConnectionCheckerCallback\textcolor{keyword}{>}(ptr.ToPointer());}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_communication-\/>SetCommunicationCallback(nativeFunc);}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_callbackAssigned\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_communicationEvent\ +=\ handler;}
\DoxyCodeLine{00074\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00075\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ remove(CommunicationEventHandler\string^\ handler)\ \{}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_communicationEvent\ -\/=\ handler;}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \ \ \ \ \textcolor{keyword}{protected}:\ \ }
\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ ManagedDelegate\string^\ del\ =\ gcnew\ ManagedDelegate(\textcolor{keyword}{this},\ \&WBaseCommunication::CommunicationCallback);}
\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ IntPtr\ \mbox{\hyperlink{a00972_a88c6eef7c046bddf934b1a0dd30b036e}{GetFunctionPointer}}()\ \{\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ Marshal::GetFunctionPointerForDelegate(del);}
\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a00972_a952b90023fcfc1a71bddd3c91c831b5a}{CommunicationCallback}}(\mbox{\hyperlink{a00856}{CommunicationStatus}}*\ status)\ \{}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00988}{WUtils::WCommunicationStatus}}\string^\ eventDataToFire\ =\ gcnew\ \mbox{\hyperlink{a00988}{WUtils::WCommunicationStatus}}();}
\DoxyCodeLine{00088\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ status-\/>\mbox{\hyperlink{a00856_a87cc1983ca0089337a5f71ad795dcff8}{Channels}}.size();\ i++)\ \{}
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00976}{WUtils::WChannel}}\string^\ toAdd\ =\ gcnew\ \mbox{\hyperlink{a00976}{WUtils::WChannel}}();}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ toAdd-\/>RawDataAvailability\ =\ \textcolor{keyword}{static\_cast<}\mbox{\hyperlink{a00636_a99a96c318c747eed449d5f38ca4bec30}{DataAvailabilityEnum}}\textcolor{keyword}{>}(status-\/>\mbox{\hyperlink{a00856_a87cc1983ca0089337a5f71ad795dcff8}{Channels}}[i].RawDataAvailability);}
\DoxyCodeLine{00091\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ toAdd-\/>\mbox{\hyperlink{a00976_a7cc59dd4b6cab51b0f1155dde4f85a36}{Type}}\ =\ \textcolor{keyword}{static\_cast<}\mbox{\hyperlink{a00636_ae8530ef12e9933875ded9a884118229b}{ChannelTypeEnum}}\textcolor{keyword}{>}(status-\/>\mbox{\hyperlink{a00856_a87cc1983ca0089337a5f71ad795dcff8}{Channels}}[i].Type);}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ eventDataToFire-\/>\mbox{\hyperlink{a00988_a8c45b6f68a51768ba69be0c4fa95c763}{Channels}}-\/>Add(toAdd);}
\DoxyCodeLine{00094\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \ \ \ \ eventDataToFire-\/>ErrorCode\ =\ gcnew\ \mbox{\hyperlink{a00980}{WUtils::WCommunicationErrorCode}}();}
\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ \ \ \ \ eventDataToFire-\/>ErrorCode-\/>ErrorCode\ =\ status-\/>\mbox{\hyperlink{a00856_aa6728b7808f69b23990630e64d37fbc0}{ErrorCode}}.\mbox{\hyperlink{a00848_af710215988a642bb36b0e93f61341e9a}{ErrorCode}};}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ \ \ \ \ eventDataToFire-\/>ErrorCode-\/>ErrorMeaning\ =\ gcnew\ String(status-\/>\mbox{\hyperlink{a00856_aa6728b7808f69b23990630e64d37fbc0}{ErrorCode}}.\mbox{\hyperlink{a00848_a2411f96315b686ae04af6c8ce56432fe}{ErrorMeaning}}.c\_str());}
\DoxyCodeLine{00099\ }
\DoxyCodeLine{00100\ \ \ \ \ \ \ \ \ \ \ \ \ eventDataToFire-\/>Status\ =\ \textcolor{keyword}{static\_cast<}\mbox{\hyperlink{a00636_aea54c0042f80c7dffb49c66a1869f924}{ConnectionStatusEnum}}\textcolor{keyword}{>}(status-\/>\mbox{\hyperlink{a00856_a35b90bc5c1c8a18f59c0118b1181a95a}{Status}});}
\DoxyCodeLine{00101\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \ \ \ \ \_communicationEvent(\textcolor{keyword}{this},\ eventDataToFire);}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00104\ }
\DoxyCodeLine{00105\ \ \ \ \ \ \ \ \ BaseCommunication*\ \mbox{\hyperlink{a00972_ae1fbf603a73d1a3169e5ef519d252def}{\_communication}};}
\DoxyCodeLine{00106\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ \_monitoringExit\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00108\ \ \ \ \ \textcolor{keyword}{private}:}
\DoxyCodeLine{00109\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ \_callbackAssigned\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ \textcolor{keyword}{event}\ CommunicationEventHandler\string^\ \_communicationEvent;}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ WBaseSettings\string^\ \_settings;}
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ Thread\string^\ \_monitoringWorker;}
\DoxyCodeLine{00113\ \ \ \ \ \};}
\DoxyCodeLine{00114\ \}}

\end{DoxyCode}
