GoPxL SDK
GoGdpClient.h
Go to the documentation of this file.
1 
10 #ifndef GO_PXL_SDK_GOGDPCLIENT_H
11 #define GO_PXL_SDK_GOGDPCLIENT_H
12 
13 #include <kApi/Io/kNetwork.h>
14 #include <kApi/Io/kTcpClient.h>
15 
16 #include <kApi/Threads/kThread.h>
17 #include <kApi/Threads/kLock.h>
18 #include <kApi/Threads/kTimer.h>
19 
20 #include <GoApi/GoApi.h>
21 #include <GoApi/Threads/MsgQueue.h>
22 #include <GoApi/Threads/Locker.h>
23 
24 #include <GoPxLSdk/Def.h>
25 #include <GoPxLSdk/GoDataSet.h>
27 
28 class GoGdpClientTests;
29 
30 namespace GoPxLSdk
31 {
33  {
34  public:
42  GoGdpClient();
43  ~GoGdpClient();
44 
45  const int CONNECT_TIMEOUT = 5000000;
46  const int CANCEL_QUERY_INTERVAL = 100000;
47 
57  void Connect(kIpAddress ipAddr, k16u port = GO_PXL_SDK_DEFAULT_GDP_SERVER_PORT);
58 
66  void Close();
67 
75  bool IsConnected();
76 
85  void ReceiveDataSync(k64u receiveTimeoutInMilliseconds);
86 
95  void ReceiveDataAsync(std::function<void(const GoDataSet& receivedDataSet)>& func);
96 
104  const GoDataSet& DataSet() const;
105 
115  void ClearData();
116 
117  private:
126  void GetGdpMsgType(MessageType& type);
127 
135  void InitTcpClient();
136 
144  void InitThreadAndTimer();
145 
155  static kStatus kCall OnDataReceive(void* context);
156 
166  static kStatus kCall DataThreadEntry(void* context);
167 
168  private:
169  void TryClose();
170 
171  std::function<void(const GoDataSet& pDataSet)> func;
172 
173  GoDataSet dataSet;
174 
175  bool isConnected = false;
176  bool async = false;
177  bool isCompleteSet;
178 
179  Go::Object<kTcpClient> socket;
180  Go::Object<kSerializer> serializer;
181  Go::Object<kTimer> timer;
182  Go::Object<kThread> receiveThread;
183  Go::MsgQueue<GoDataSet> dataQueue;
184  Go::Object<kThread> dataThread;
185 
186  kIpAddress ipAddress;
187  k16u port;
188 
189  friend class ::GoGdpClientTests;
190  };
191 }
192 
193 
194 #endif
195 
196 
Definition: GoDataSet.h:18
#define GoPxLSdkClass
Definition: Def.h:35
Declares the GoPxLSdk.GoDataSet class.
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:32
constexpr k16u GO_PXL_SDK_DEFAULT_GDP_SERVER_PORT
Definition: Def.h:40
Definition: Def.h:46