GoPxL SDK
GoGdpClient.h
Go to the documentation of this file.
1 
9 #ifndef GO_PXL_SDK_GOGDPCLIENT_H
10 #define GO_PXL_SDK_GOGDPCLIENT_H
11 
12 #include <kApi/Io/kNetwork.h>
13 #include <kApi/Io/kTcpClient.h>
14 
15 #include <kApi/Threads/kThread.h>
16 #include <kApi/Threads/kLock.h>
17 #include <kApi/Threads/kTimer.h>
18 
19 #include <GoApi/GoApi.h>
20 #include <GoApi/Threads/MsgQueue.h>
21 #include <GoApi/Threads/Locker.h>
22 
23 #include <GoPxLSdk/Def.h>
24 #include <GoPxLSdk/GoDataSet.h>
26 
27 namespace GoPxLSdk
28 {
30  {
31  public:
39  GoGdpClient();
40  ~GoGdpClient();
41 
42  const int CONNECT_TIMEOUT = 5000000;
43  const int CANCEL_QUERY_INTERVAL = 100000;
44 
54  void Connect(kIpAddress ipAddr, k16u port = GO_PXL_SDK_DEFAULT_GDP_SERVER_PORT);
55 
63  void Close();
64 
72  bool IsConnected();
73 
82  void ReceiveDataSync(k64u receiveTimeoutInMilliseconds);
83 
92  void ReceiveDataAsync(std::function<void(const GoDataSet& receivedDataSet)>& func);
93 
101  const GoDataSet& DataSet() const;
102 
103  private:
112  void GetGdpMsgType(MessageType& type);
113 
121  void InitTcpClient();
122 
130  void InitThreadAndTimer();
131 
141  static kStatus kCall OnDataReceive(void* context);
142 
152  static kStatus kCall DataThreadEntry(void* context);
153 
154  private:
155  std::function<void(const GoDataSet& pDataSet)> func;
156 
157  GoDataSet dataSet;
158 
159  bool isConnected = false;
160  bool async = false;
161  bool isCompleteSet;
162 
163  Go::Object<kTcpClient> socket;
164  Go::Object<kSerializer> serializer;
165  Go::Object<kTimer> timer;
166  Go::Object<kThread> receiveThread;
167  Go::MsgQueue<GoDataSet> dataQueue;
168  Go::Object<kThread> dataThread;
169  };
170 }
171 
172 
173 #endif
174 
175 
Definition: GoDataSet.h:17
#define GoPxLSdkClass
Definition: Def.h:35
MessageType
List of enums representing types available to be serialized out through GDP This list is essentially ...
Definition: GoGdpMsgDef.h:27
Declares the general SDK definitions.
Definition: GoGdpClient.h:29
constexpr k16u GO_PXL_SDK_DEFAULT_GDP_SERVER_PORT
Definition: Def.h:40
Definition: Def.h:46