sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
RTProtocol.cpp
Go to the documentation of this file.
1 #define _CRT_SECURE_NO_WARNINGS
2 #define NOMINMAX
3 
5 
6 #include <float.h>
7 #include <string.h>
8 
9 #include <algorithm>
10 #include <cctype>
11 #include <cmath>
12 #include <locale>
13 #include <thread>
14 
17 
18 #ifdef _WIN32
19 #include <iphlpapi.h>
20 // import the internet protocol helper library.
21 #pragma comment(lib, "IPHLPAPI.lib")
22 #else
23 #include <arpa/inet.h>
24 
25 #endif
26 
27 namespace {
28 inline void ToLower(std::string& str) {
29  std::transform(str.begin(), str.end(), str.begin(),
30  [](int c) { return std::tolower(c); });
31 }
32 
33 inline void RemoveInvalidChars(std::string& str) {
34  auto isInvalidChar = [](int c) -> int {
35  // iscntrl: control codes(NUL, etc.), '\t', '\n', '\v', '\f', '\r',
36  // backspace (DEL) isspace: some common checks but also 0x20 (SPACE) return
37  // != 0 --> invalid char
38  return std::iscntrl(c) + std::isspace(c);
39  };
40  str.erase(std::remove_if(str.begin(), str.end(), isInvalidChar), str.end());
41 }
42 
43 } // namespace
44 
46  mpoNetwork = new CNetwork();
47  mpoRTPacket = nullptr;
48  meLastEvent = CRTPacket::EventCaptureStopped;
50  mnMajorVersion = 1;
51  mnMinorVersion = 0;
52  mbBigEndian = false;
53  maErrorStr[0] = 0;
54  mnBroadcastPort = 0;
55  mpFileBuffer = nullptr;
56  mDataBuffSize = 65535;
57  maDataBuff = new char[mDataBuffSize];
58  mbIsMaster = false;
59 } // CRTProtocol
60 
62  if (mpoNetwork) {
63  delete mpoNetwork;
64  mpoNetwork = nullptr;
65  }
66  if (mpoRTPacket) {
67  delete mpoRTPacket;
68  mpoRTPacket = nullptr;
69  }
70 } // ~CRTProtocol
71 
72 bool CRTProtocol::Connect(const char* pServerAddr, unsigned short nPort,
73  unsigned short* pnUDPServerPort, int nMajorVersion,
74  int nMinorVersion, bool bBigEndian) {
76  char tTemp[100];
77  char pResponseStr[256];
78 
79  mbBigEndian = bBigEndian;
80  mbIsMaster = false;
81 
82  mnMajorVersion = 1;
83  if ((nMajorVersion == 1) && (nMinorVersion == 0)) {
84  mnMinorVersion = 0;
85  } else {
86  mnMinorVersion = 1;
87  if (mbBigEndian) {
88  nPort += 2;
89  } else {
90  nPort += 1;
91  }
92  }
93 
94  if (mpoRTPacket) {
95  delete mpoRTPacket;
96  }
97  mpoRTPacket = new CRTPacket(nMajorVersion, nMinorVersion, bBigEndian);
98 
99  if (mpoRTPacket == nullptr) {
100  strcpy(maErrorStr, "Could not allocate data packet.");
101  return false;
102  }
103 
104  if (mpoNetwork->Connect(pServerAddr, nPort)) {
105  if (pnUDPServerPort != nullptr) {
106  if (mpoNetwork->CreateUDPSocket(*pnUDPServerPort) == false) {
107  sprintf(maErrorStr, "CreateUDPSocket failed. %s",
108  mpoNetwork->GetErrorString());
109  Disconnect();
110  return false;
111  }
112  }
113 
114  // Welcome message
115  auto received = ReceiveRTPacket(eType, true);
116  if (received > 0) {
117  if (eType == CRTPacket::PacketError) {
118  strcpy(maErrorStr, mpoRTPacket->GetErrorString());
119  Disconnect();
120  return false;
121  } else if (eType == CRTPacket::PacketCommand) {
122  const std::string welcomeMessage("QTM RT Interface connected");
123  if (strncmp(welcomeMessage.c_str(), mpoRTPacket->GetCommandString(),
124  welcomeMessage.size()) == 0) {
125  // Set protocol version
126  if (SetVersion(nMajorVersion, nMinorVersion)) {
127  // Set byte order.
128  // Unless we use protocol version 1.0, we have set the byte order by
129  // selecting the correct port.
130 
131  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
132  if (mbBigEndian) {
133  strcpy(tTemp, "ByteOrder BigEndian");
134  } else {
135  strcpy(tTemp, "ByteOrder LittleEndian");
136  }
137 
138  if (SendCommand(tTemp, pResponseStr)) {
139  return true;
140  } else {
141  strcpy(maErrorStr, "Set byte order failed.");
142  }
143  } else {
144  GetState(meState, true);
145  return true;
146  }
147  }
148  Disconnect();
149  return false;
150  }
151  }
152  }
153  } else {
154  if (mpoNetwork->GetError() == 10061) {
155  strcpy(maErrorStr, "Check if QTM is running on target machine.");
156  } else {
157  strcpy(maErrorStr, mpoNetwork->GetErrorString());
158  }
159  }
160  Disconnect();
161  return false;
162 } // Connect
163 
165  if (mpoNetwork) {
166  return mpoNetwork->GetUdpServerPort();
167  }
168  return 0;
169 }
170 
172  mpoNetwork->Disconnect();
173  mnBroadcastPort = 0;
174  if (mpoRTPacket) {
175  delete mpoRTPacket;
176  mpoRTPacket = nullptr;
177  }
178  mbIsMaster = false;
179 } // Disconnect
180 
181 bool CRTProtocol::Connected() const { return mpoNetwork->Connected(); }
182 
183 bool CRTProtocol::SetVersion(int nMajorVersion, int nMinorVersion) {
184  char tTemp[256];
185  char pResponseStr[256];
186 
187  sprintf(tTemp, "Version %u.%u", nMajorVersion, nMinorVersion);
188 
189  if (SendCommand(tTemp, pResponseStr)) {
190  sprintf(tTemp, "Version set to %u.%u", nMajorVersion, nMinorVersion);
191 
192  if (strcmp(pResponseStr, tTemp) == 0) {
193  mnMajorVersion = nMajorVersion;
194  mnMinorVersion = nMinorVersion;
195  mpoRTPacket->SetVersion(mnMajorVersion, mnMinorVersion);
196  return true;
197  }
198 
199  if (pResponseStr) {
200  sprintf(maErrorStr, "%s.", pResponseStr);
201  } else {
202  strcpy(maErrorStr, "Set Version failed.");
203  }
204  } else {
205  strcpy(tTemp, maErrorStr);
206  sprintf(maErrorStr, "Send Version failed. %s.", tTemp);
207  }
208  return false;
209 }
210 
211 bool CRTProtocol::GetVersion(unsigned int& nMajorVersion,
212  unsigned int& nMinorVersion) {
213  if (!Connected()) {
214  return false;
215  }
216 
217  nMajorVersion = mnMajorVersion;
218  nMinorVersion = mnMinorVersion;
219 
220  return true;
221 }
222 
223 bool CRTProtocol::GetQTMVersion(char* pVersion, unsigned int nVersionLen) {
224  if (SendCommand("QTMVersion", pVersion, nVersionLen)) {
225  return true;
226  }
227  strcpy(maErrorStr, "Get QTM Version failed.");
228  return false;
229 }
230 
231 bool CRTProtocol::GetByteOrder(bool& bBigEndian) {
232  char pResponseStr[256];
233 
234  if (SendCommand("ByteOrder", pResponseStr)) {
235  bBigEndian = (strcmp(pResponseStr, "Byte order is big endian") == 0);
236  return true;
237  }
238  strcpy(maErrorStr, "Get Byte order failed.");
239  return false;
240 }
241 
242 bool CRTProtocol::CheckLicense(const char* pLicenseCode) {
243  char tTemp[100];
244  char pResponseStr[256];
245 
246  if (strlen(pLicenseCode) <= 85) {
247  sprintf(tTemp, "CheckLicense %s", pLicenseCode);
248 
249  if (SendCommand(tTemp, pResponseStr)) {
250  if (strcmp(pResponseStr, "License pass") == 0) {
251  return true;
252  }
253  strcpy(maErrorStr, "Wrong license code.");
254  } else {
255  strcpy(maErrorStr, "CheckLicense failed.");
256  }
257  } else {
258  strcpy(maErrorStr, "License code too long.");
259  }
260  return false;
261 }
262 
263 bool CRTProtocol::DiscoverRTServer(unsigned short nServerPort,
264  bool bNoLocalResponses,
265  unsigned short nDiscoverPort) {
266  char pData[10];
267  SDiscoverResponse sResponse;
268 
269  if (mnBroadcastPort == 0) {
270  if (!mpoNetwork->CreateUDPSocket(nServerPort, true)) {
271  strcpy(maErrorStr, mpoNetwork->GetErrorString());
272  return false;
273  }
274  mnBroadcastPort = nServerPort;
275  } else {
276  nServerPort = mnBroadcastPort;
277  }
278 
279  *((unsigned int*)pData) = (unsigned int)10;
280  *((unsigned int*)(pData + 4)) = (unsigned int)CRTPacket::PacketDiscover;
281  *((unsigned short*)(pData + 8)) = htons(nServerPort);
282 
283  if (mpoNetwork->SendUDPBroadcast(pData, 10, nDiscoverPort)) {
284  mvsDiscoverResponseList.clear();
285 
286  int nReceived;
287  do {
288  unsigned int nAddr = 0;
289  nReceived =
290  mpoNetwork->Receive(maDataBuff, mDataBuffSize, false, 100000, &nAddr);
291 
292  if (nReceived != -1 && nReceived > 8) {
293  if (CRTPacket::GetType(maDataBuff) == CRTPacket::PacketCommand) {
294  char* response = CRTPacket::GetCommandString(maDataBuff);
295  sResponse.nAddr = nAddr;
296  sResponse.nBasePort =
298 
299  if (response &&
300  (!bNoLocalResponses || !mpoNetwork->IsLocalAddress(nAddr))) {
301  strcpy(sResponse.message, response);
302  mvsDiscoverResponseList.push_back(sResponse);
303  }
304  }
305  }
306  } while (nReceived != -1 &&
307  nReceived > 8); // Keep reading until no more responses.
308 
309  return true;
310  }
311  return false;
312 }
313 
315  return (int)mvsDiscoverResponseList.size();
316 }
317 
318 bool CRTProtocol::GetDiscoverResponse(unsigned int nIndex, unsigned int& nAddr,
319  unsigned short& nBasePort,
320  std::string& message) {
321  if (nIndex < mvsDiscoverResponseList.size()) {
322  nAddr = mvsDiscoverResponseList[nIndex].nAddr;
323  nBasePort = mvsDiscoverResponseList[nIndex].nBasePort;
324  message = mvsDiscoverResponseList[nIndex].message;
325  return true;
326  }
327  return false;
328 }
329 
330 bool CRTProtocol::GetCurrentFrame(unsigned int nComponentType,
331  const SComponentOptions& componentOptions) {
332  char pCommandStr[256];
333  strcpy(pCommandStr, "GetCurrentFrame ");
334 
335  std::string::size_type nCommandStrSize = strlen(pCommandStr);
336  if (GetComponentString(pCommandStr + (int)nCommandStrSize, nComponentType,
337  componentOptions)) {
338  if (SendCommand(pCommandStr)) {
339  return true;
340  }
341  strcpy(maErrorStr, "GetCurrentFrame failed.");
342  } else {
343  strcpy(maErrorStr, "DataComponent missing.");
344  }
345  return false;
346 }
347 
348 bool CRTProtocol::StreamFrames(EStreamRate eRate, unsigned int nRateArg,
349  unsigned short nUDPPort, const char* pUDPAddr,
350  unsigned int nComponentType,
351  const SComponentOptions& componentOptions) {
352  char pCommandStr[256];
353 
354  if (eRate == RateFrequencyDivisor) {
355  sprintf(pCommandStr, "StreamFrames FrequencyDivisor:%d ", nRateArg);
356  } else if (eRate == RateFrequency) {
357  sprintf(pCommandStr, "StreamFrames Frequency:%d ", nRateArg);
358  } else if (eRate == RateAllFrames) {
359  sprintf(pCommandStr, "StreamFrames AllFrames ");
360  } else {
361  strcpy(maErrorStr, "No valid rate.");
362  return false;
363  }
364 
365  if (nUDPPort > 0) {
366  if (pUDPAddr != nullptr && strlen(pUDPAddr) > 64) {
367  strcpy(maErrorStr, "UDP address string too long.");
368  return false;
369  }
370  sprintf(pCommandStr, "%s UDP%s%s:%d ", pCommandStr,
371  pUDPAddr != nullptr ? ":" : "", pUDPAddr != nullptr ? pUDPAddr : "",
372  nUDPPort);
373  }
374 
375  std::string::size_type nCommandStrSize = strlen(pCommandStr);
376  if (GetComponentString(pCommandStr + (int)nCommandStrSize, nComponentType,
377  componentOptions)) {
378  if (SendCommand(pCommandStr)) {
379  return true;
380  }
381  strcpy(maErrorStr, "StreamFrames failed.");
382  } else {
383  strcpy(maErrorStr, "DataComponent missing.");
384  }
385 
386  return false;
387 }
388 
390  if (SendCommand("StreamFrames Stop")) {
391  return true;
392  }
393  strcpy(maErrorStr, "StreamFrames Stop failed.");
394  return false;
395 }
396 
397 bool CRTProtocol::GetState(CRTPacket::EEvent& eEvent, bool bUpdate,
398  int nTimeout) {
400 
401  if (bUpdate) {
402  bool result;
403  if (mnMajorVersion > 1 || mnMinorVersion > 9) {
404  result = SendCommand("GetState");
405  } else {
406  result = SendCommand("GetLastEvent");
407  }
408  if (result) {
409  int nReceived;
410  do {
411  nReceived = ReceiveRTPacket(eType, false, nTimeout);
412  if (nReceived > 0) {
413  if (mpoRTPacket->GetEvent(eEvent)) {
414  return true;
415  }
416  }
417  } while (nReceived > 0);
418  }
419  strcpy(maErrorStr, "GetLastEvent failed.");
420  } else {
421  eEvent = meState;
422  return true;
423  }
424  return false;
425 }
426 
427 bool CRTProtocol::GetCapture(const char* pFileName, bool bC3D) {
429  char pResponseStr[256];
430 
431  mpFileBuffer = fopen(pFileName, "wb");
432  if (mpFileBuffer != nullptr) {
433  if (bC3D) {
434  // C3D file
435  if (SendCommand((mnMajorVersion > 1 || mnMinorVersion > 7)
436  ? "GetCaptureC3D"
437  : "GetCapture",
438  pResponseStr)) {
439  if (strcmp(pResponseStr, "Sending capture") == 0) {
440  if (ReceiveRTPacket(eType, true, 5000000) >
441  0) // Wait for C3D file in 5 seconds.
442  {
443  if (eType == CRTPacket::PacketC3DFile) {
444  if (mpFileBuffer != nullptr) {
445  fclose(mpFileBuffer);
446  return true;
447  }
448  strcpy(maErrorStr, "Writing C3D file failed.");
449  } else {
450  strcpy(maErrorStr, "Wrong packet type received.");
451  }
452  } else {
453  strcpy(maErrorStr, "No packet received.");
454  }
455  } else {
456  sprintf(maErrorStr, "%s failed.",
457  (mnMajorVersion > 1 || mnMinorVersion > 7) ? "GetCaptureC3D"
458  : "GetCapture");
459  }
460  } else {
461  sprintf(maErrorStr, "%s failed.",
462  (mnMajorVersion > 1 || mnMinorVersion > 7) ? "GetCaptureC3D"
463  : "GetCapture");
464  }
465  } else {
466  // QTM file
467  if (SendCommand("GetCaptureQTM", pResponseStr)) {
468  if (strcmp(pResponseStr, "Sending capture") == 0) {
469  if (ReceiveRTPacket(eType, true, 5000000) >
470  0) // Wait for QTM file in 5 seconds.
471  {
472  if (eType == CRTPacket::PacketQTMFile) {
473  if (mpFileBuffer != nullptr) {
474  fclose(mpFileBuffer);
475  return true;
476  }
477  strcpy(maErrorStr, "Writing QTM file failed.");
478  } else {
479  strcpy(maErrorStr, "Wrong packet type received.");
480  }
481  } else {
482  sprintf(maErrorStr, "No packet received. %s.", maErrorStr);
483  }
484  } else {
485  strcpy(maErrorStr, "GetCaptureQTM failed.");
486  }
487  } else {
488  strcpy(maErrorStr, "GetCaptureQTM failed.");
489  }
490  }
491  }
492  if (mpFileBuffer) {
493  fclose(mpFileBuffer);
494  }
495 
496  return false;
497 }
498 
500  char pResponseStr[256];
501 
502  if (SendCommand("Trig", pResponseStr)) {
503  if (strcmp(pResponseStr, "Trig ok") == 0) {
504  return true;
505  }
506  }
507  if (pResponseStr) {
508  sprintf(maErrorStr, "%s.", pResponseStr);
509  } else {
510  strcpy(maErrorStr, "Trig failed.");
511  }
512  return false;
513 }
514 
515 bool CRTProtocol::SetQTMEvent(const char* pLabel) {
516  char tTemp[100];
517  char pResponseStr[256];
518 
519  if (strlen(pLabel) <= 92) {
520  sprintf(
521  tTemp, "%s %s",
522  (mnMajorVersion > 1 || mnMinorVersion > 7) ? "SetQTMEvent" : "Event",
523  pLabel);
524 
525  if (SendCommand(tTemp, pResponseStr)) {
526  if (strcmp(pResponseStr, "Event set") == 0) {
527  return true;
528  }
529  }
530  if (pResponseStr) {
531  sprintf(maErrorStr, "%s.", pResponseStr);
532  } else {
533  sprintf(
534  maErrorStr, "%s failed.",
535  (mnMajorVersion > 1 || mnMinorVersion > 7) ? "SetQTMEvent" : "Event");
536  }
537  } else {
538  strcpy(maErrorStr, "Event label too long.");
539  }
540  return false;
541 }
542 
543 bool CRTProtocol::TakeControl(const char* pPassword) {
544  char pResponseStr[256];
545  char pCmd[64];
546 
547  strcpy(pCmd, "TakeControl");
548  if (pPassword != nullptr) {
549  // Add password
550  if (pPassword[0] != 0) {
551  strcat(pCmd, " ");
552  strcat(pCmd, pPassword);
553  }
554  }
555  if (SendCommand(pCmd, pResponseStr)) {
556  if (strcmp("You are now master", pResponseStr) == 0 ||
557  strcmp("You are already master", pResponseStr) == 0) {
558  mbIsMaster = true;
559  return true;
560  }
561  }
562  if (pResponseStr) {
563  sprintf(maErrorStr, "%s.", pResponseStr);
564  } else {
565  strcpy(maErrorStr, "TakeControl failed.");
566  }
567  mbIsMaster = false;
568  return false;
569 } // TakeControl
570 
572  char pResponseStr[256];
573 
574  if (SendCommand("ReleaseControl", pResponseStr)) {
575  if (strcmp("You are now a regular client", pResponseStr) == 0 ||
576  strcmp("You are already a regular client", pResponseStr) == 0) {
577  mbIsMaster = false;
578  return true;
579  }
580  }
581  if (pResponseStr) {
582  sprintf(maErrorStr, "%s.", pResponseStr);
583  } else {
584  strcpy(maErrorStr, "ReleaseControl failed.");
585  }
586  return false;
587 } // ReleaseControl
588 
589 bool CRTProtocol::IsControlling() { return mbIsMaster; }
590 
592  char pResponseStr[256];
593 
594  if (SendCommand("New", pResponseStr)) {
595  if (strcmp(pResponseStr, "Creating new connection") == 0 ||
596  strcmp(pResponseStr, "Already connected") == 0) {
597  return true;
598  }
599  }
600  if (pResponseStr) {
601  sprintf(maErrorStr, "%s.", pResponseStr);
602  } else {
603  strcpy(maErrorStr, "New failed.");
604  }
605  return false;
606 }
607 
609  char pResponseStr[256];
610 
611  if (SendCommand("Close", pResponseStr)) {
612  if (strcmp(pResponseStr, "Closing connection") == 0 ||
613  strcmp(pResponseStr, "File closed") == 0 ||
614  strcmp(pResponseStr, "Closing file") == 0 ||
615  strcmp(pResponseStr, "No connection to close") == 0) {
616  return true;
617  }
618  }
619  if (pResponseStr) {
620  sprintf(maErrorStr, "%s.", pResponseStr);
621  } else {
622  strcpy(maErrorStr, "Close failed.");
623  }
624  return false;
625 }
626 
628  char pResponseStr[256];
629 
630  if (SendCommand("Start", pResponseStr)) {
631  if (strcmp(pResponseStr, "Starting measurement") == 0) {
632  return true;
633  }
634  }
635  if (pResponseStr) {
636  sprintf(maErrorStr, "%s.", pResponseStr);
637  } else {
638  strcpy(maErrorStr, "Start failed.");
639  }
640  return false;
641 }
642 
644  char pResponseStr[256];
645 
646  if (SendCommand("Start rtfromfile", pResponseStr)) {
647  if (strcmp(pResponseStr, "Starting RT from file") == 0) {
648  return true;
649  }
650  }
651  if (pResponseStr) {
652  if (strcmp(pResponseStr, "RT from file already running") == 0) {
653  return true;
654  }
655  sprintf(maErrorStr, "%s.", pResponseStr);
656  } else {
657  strcpy(maErrorStr, "Starting RT from file failed.");
658  }
659  return false;
660 }
661 
663  char pResponseStr[256];
664 
665  if (SendCommand("Stop", pResponseStr)) {
666  if (strcmp(pResponseStr, "Stopping measurement") == 0) {
667  return true;
668  }
669  }
670  if (pResponseStr) {
671  sprintf(maErrorStr, "%s.", pResponseStr);
672  } else {
673  strcpy(maErrorStr, "Stop failed.");
674  }
675  return false;
676 }
677 
678 bool CRTProtocol::LoadCapture(const char* pFileName) {
679  char tTemp[100];
680  char pResponseStr[256];
681 
682  if (strlen(pFileName) <= 94) {
683  sprintf(tTemp, "Load %s", pFileName);
684 
685  if (SendCommand(tTemp, pResponseStr,
686  20000000)) // Set timeout to 20 s for Load command.
687  {
688  if (strcmp(pResponseStr, "Measurement loaded") == 0) {
689  return true;
690  }
691  }
692  if (strlen(pResponseStr) > 0) {
693  sprintf(maErrorStr, "%s.", pResponseStr);
694  } else {
695  strcpy(maErrorStr, "Load failed.");
696  }
697  } else {
698  strcpy(maErrorStr, "File name too long.");
699  }
700  return false;
701 }
702 
703 bool CRTProtocol::SaveCapture(const char* pFileName, bool bOverwrite,
704  char* pNewFileName, int nSizeOfNewFileName) {
705  char tTemp[100];
706  char pResponseStr[256];
707  char tNewFileNameTmp[300];
708 
709  tNewFileNameTmp[0] = 0;
710 
711  if (strlen(pFileName) <= 94) {
712  sprintf(tTemp, "Save %s%s", pFileName, bOverwrite ? " Overwrite" : "");
713 
714  if (SendCommand(tTemp, pResponseStr)) {
715  if (strcmp(pResponseStr, "Measurement saved") == 0) {
716  if (pNewFileName && nSizeOfNewFileName > 0) {
717  pNewFileName[0] = 0;
718  }
719  return true;
720  }
721  if (sscanf(pResponseStr, "Measurement saved as '%[^']'",
722  tNewFileNameTmp) == 1) {
723  if (pNewFileName) {
724  strcpy(pNewFileName, tNewFileNameTmp);
725  }
726  return true;
727  }
728  }
729  if (pResponseStr) {
730  sprintf(maErrorStr, "%s.", pResponseStr);
731  } else {
732  strcpy(maErrorStr, "Save failed.");
733  }
734  } else {
735  strcpy(maErrorStr, "File name too long.");
736  }
737  return false;
738 }
739 
740 bool CRTProtocol::LoadProject(const char* pFileName) {
741  char tTemp[100];
742  char pResponseStr[256];
743 
744  if (strlen(pFileName) <= 94) {
745  sprintf(tTemp, "LoadProject %s", pFileName);
746 
747  if (SendCommand(tTemp, pResponseStr)) {
748  if (strcmp(pResponseStr, "Project loaded") == 0) {
749  return true;
750  }
751  }
752  if (pResponseStr) {
753  sprintf(maErrorStr, "%s.", pResponseStr);
754  } else {
755  strcpy(maErrorStr, "Load project failed.");
756  }
757  } else {
758  strcpy(maErrorStr, "File name too long.");
759  }
760  return false;
761 }
762 
764  char pResponseStr[256];
765 
766  if (SendCommand("Reprocess", pResponseStr)) {
767  if (strcmp(pResponseStr, "Reprocessing file") == 0) {
768  return true;
769  }
770  }
771  if (pResponseStr) {
772  sprintf(maErrorStr, "%s.", pResponseStr);
773  } else {
774  strcpy(maErrorStr, "Reprocess failed.");
775  }
776  return false;
777 }
778 
780  switch (eEvent) {
782  strcpy(pStr, "Connected");
783  break;
785  strcpy(pStr, "Connection Closed");
786  break;
788  strcpy(pStr, "Capture Started");
789  break;
791  strcpy(pStr, "Capture Stopped");
792  break;
794  strcpy(pStr, "Fetching Finished");
795  break;
797  strcpy(pStr, "Calibration Started");
798  break;
800  strcpy(pStr, "Calibration Finished");
801  break;
803  strcpy(pStr, "RT From File Started");
804  break;
806  strcpy(pStr, "RT From File Stopped");
807  break;
809  strcpy(pStr, "Waiting For Trigger");
810  break;
812  strcpy(pStr, "Camera Settings Changed");
813  break;
815  strcpy(pStr, "QTM Shutting Down");
816  break;
818  strcpy(pStr, "Capture Saved");
819  break;
821  strcpy(pStr, "Reprocessing Started");
822  break;
824  strcpy(pStr, "Reprocessing Stopped");
825  break;
827  strcpy(pStr, "Trigger");
828  break;
829  default:
830  return false;
831  }
832  return true;
833 }
834 
835 bool CRTProtocol::ConvertRateString(const char* pRate, EStreamRate& eRate,
836  unsigned int& nRateArg) {
837  std::string rateString;
838 
839  rateString.assign(pRate);
840  std::transform(rateString.begin(), rateString.end(), rateString.begin(),
841  ::tolower);
842 
843  eRate = RateNone;
844 
845  if (rateString.compare(0, 9, "allframes", 9) == 0) {
846  eRate = RateAllFrames;
847  } else if (rateString.compare(0, 10, "frequency:") == 0) {
848  nRateArg = atoi(rateString.substr(10).c_str());
849  if (nRateArg > 0) {
850  eRate = RateFrequency;
851  }
852  } else if (rateString.compare(0, 17, "frequencydivisor:") == 0) {
853  nRateArg = atoi(rateString.substr(17).c_str());
854  if (nRateArg > 0) {
855  eRate = RateFrequencyDivisor;
856  }
857  }
858 
859  return eRate != RateNone;
860 }
861 
862 unsigned int CRTProtocol::ConvertComponentString(const char* pComponentType) {
863  std::string componentString;
864  unsigned int componentTypes = 0;
865 
866  componentString.assign(pComponentType);
867  // Make string lower case.
868  std::transform(componentString.begin(), componentString.end(),
869  componentString.begin(), ::tolower);
870 
871  if (componentString.find("2d") != std::string::npos) {
872  componentTypes += CRTProtocol::cComponent2d;
873  }
874  if (componentString.find("2dlin") != std::string::npos) {
875  componentTypes += CRTProtocol::cComponent2dLin;
876  }
877  if (componentString.find("3d") != std::string::npos) {
878  componentTypes += CRTProtocol::cComponent3d;
879  }
880  if (componentString.find("3dres") != std::string::npos) {
881  componentTypes += CRTProtocol::cComponent3dRes;
882  }
883  if (componentString.find("3dnolabels") != std::string::npos) {
884  componentTypes += CRTProtocol::cComponent3dNoLabels;
885  }
886  if (componentString.find("3dnolabelsres") != std::string::npos) {
887  componentTypes += CRTProtocol::cComponent3dNoLabelsRes;
888  }
889  if (componentString.find("analog") != std::string::npos) {
890  componentTypes += CRTProtocol::cComponentAnalog;
891  }
892  if (componentString.find("analogsingle") != std::string::npos) {
893  componentTypes += CRTProtocol::cComponentAnalogSingle;
894  }
895  if (componentString.find("force") != std::string::npos) {
896  componentTypes += CRTProtocol::cComponentForce;
897  }
898  if (componentString.find("forcesingle") != std::string::npos) {
899  componentTypes += CRTProtocol::cComponentForceSingle;
900  }
901  if (componentString.find("6d") != std::string::npos) {
902  componentTypes += CRTProtocol::cComponent6d;
903  }
904  if (componentString.find("6dres") != std::string::npos) {
905  componentTypes += CRTProtocol::cComponent6dRes;
906  }
907  if (componentString.find("6deuler") != std::string::npos) {
908  componentTypes += CRTProtocol::cComponent6dEuler;
909  }
910  if (componentString.find("6deulerres") != std::string::npos) {
911  componentTypes += CRTProtocol::cComponent6dEulerRes;
912  }
913  if (componentString.find("image") != std::string::npos) {
914  componentTypes += CRTProtocol::cComponentImage;
915  }
916  if (componentString.find("gazevector") != std::string::npos) {
917  componentTypes += CRTProtocol::cComponentGazeVector;
918  }
919  if (componentString.find("timecode") != std::string::npos) {
920  componentTypes += CRTProtocol::cComponentTimecode;
921  }
922  if (componentString.find("skeleton") != std::string::npos) {
923  componentTypes += CRTProtocol::cComponentSkeleton;
924  }
925  return componentTypes;
926 }
927 
928 bool CRTProtocol::GetComponentString(char* pComponentStr,
929  unsigned int nComponentType,
930  const SComponentOptions& options) {
931  pComponentStr[0] = 0;
932 
933  if (nComponentType & cComponent2d) {
934  strcat(pComponentStr, "2D ");
935  }
936  if (nComponentType & cComponent2dLin) {
937  strcat(pComponentStr, "2DLin ");
938  }
939  if (nComponentType & cComponent3d) {
940  strcat(pComponentStr, "3D ");
941  }
942  if (nComponentType & cComponent3dRes) {
943  strcat(pComponentStr, "3DRes ");
944  }
945  if (nComponentType & cComponent3dNoLabels) {
946  strcat(pComponentStr, "3DNoLabels ");
947  }
948  if (nComponentType & cComponent3dNoLabelsRes) {
949  strcat(pComponentStr, "3DNoLabelsRes ");
950  }
951  if (nComponentType & cComponent6d) {
952  strcat(pComponentStr, "6D ");
953  }
954  if (nComponentType & cComponent6dRes) {
955  strcat(pComponentStr, "6DRes ");
956  }
957  if (nComponentType & cComponent6dEuler) {
958  strcat(pComponentStr, "6DEuler ");
959  }
960  if (nComponentType & cComponent6dEulerRes) {
961  strcat(pComponentStr, "6DEulerRes ");
962  }
963  if (nComponentType & cComponentAnalog) {
964  strcat(pComponentStr, "Analog");
965 
966  if (options.mAnalogChannels != nullptr) {
967  strcat(pComponentStr, ":");
968  strcat(pComponentStr, options.mAnalogChannels);
969  }
970 
971  strcat(pComponentStr, " ");
972  }
973  if (nComponentType & cComponentAnalogSingle) {
974  strcat(pComponentStr, "AnalogSingle");
975 
976  if (options.mAnalogChannels != nullptr) {
977  strcat(pComponentStr, ":");
978  strcat(pComponentStr, options.mAnalogChannels);
979  }
980 
981  strcat(pComponentStr, " ");
982  }
983  if (nComponentType & cComponentForce) {
984  strcat(pComponentStr, "Force ");
985  }
986  if (nComponentType & cComponentForceSingle) {
987  strcat(pComponentStr, "ForceSingle ");
988  }
989  if (nComponentType & cComponentGazeVector) {
990  strcat(pComponentStr, "GazeVector ");
991  }
992  if (nComponentType & cComponentImage) {
993  strcat(pComponentStr, "Image ");
994  }
995  if (nComponentType & cComponentTimecode) {
996  strcat(pComponentStr, "Timecode ");
997  }
998  if (nComponentType & cComponentSkeleton) {
999  strcat(pComponentStr, "Skeleton");
1000 
1001  if (options.mSkeletonGlobalData) {
1002  strcat(pComponentStr, ":global");
1003  }
1004 
1005  strcat(pComponentStr, " ");
1006  }
1007 
1008  return (pComponentStr[0] != 0);
1009 }
1010 
1012  bool bSkipEvents, int nTimeout) {
1013  int nRecved = 0;
1014  unsigned int nRecvedTotal = 0;
1015  unsigned int nFrameSize;
1016 
1017  eType = CRTPacket::PacketNone;
1018 
1019  do {
1020  nRecved = 0;
1021  nRecvedTotal = 0;
1022 
1023  nRecved = mpoNetwork->Receive(maDataBuff, mDataBuffSize, true, nTimeout);
1024  if (nRecved == 0) {
1025  // Receive timeout.
1026  strcpy(maErrorStr, "Data receive timeout.");
1027  return 0;
1028  }
1029  if (nRecved < (int)(sizeof(int) * 2)) {
1030  // QTM header not received.
1031  strcpy(maErrorStr, "Couldn't read header bytes.");
1032  return -1;
1033  }
1034  if (nRecved <= -1) {
1035  strcpy(maErrorStr, "Socket Error.");
1036  return -1;
1037  }
1038  nRecvedTotal += nRecved;
1039 
1040  bool bBigEndian =
1041  (mbBigEndian || (mnMajorVersion == 1 && mnMinorVersion == 0));
1042  nFrameSize = mpoRTPacket->GetSize(maDataBuff, bBigEndian);
1043  eType = mpoRTPacket->GetType(maDataBuff, bBigEndian);
1044 
1045  unsigned int nReadSize;
1046 
1047  if (eType == CRTPacket::PacketC3DFile ||
1048  eType == CRTPacket::PacketQTMFile) {
1049  if (mpFileBuffer != nullptr) {
1050  rewind(mpFileBuffer); // Start from the beginning
1051  if (fwrite(maDataBuff + sizeof(int) * 2, 1,
1052  nRecvedTotal - sizeof(int) * 2,
1053  mpFileBuffer) != nRecvedTotal - sizeof(int) * 2) {
1054  strcpy(maErrorStr, "Failed to write file to disk.");
1055  fclose(mpFileBuffer);
1056  mpFileBuffer = nullptr;
1057  return -1;
1058  }
1059  // Receive more data until we have read the whole packet
1060  while (nRecvedTotal < nFrameSize) {
1061  nReadSize = nFrameSize - nRecvedTotal;
1062  if (nFrameSize > mDataBuffSize) {
1063  nReadSize = mDataBuffSize;
1064  }
1065  // As long as we haven't received enough data, wait for more
1066  nRecved = mpoNetwork->Receive(&(maDataBuff[sizeof(int) * 2]),
1067  nReadSize, false, nTimeout);
1068  if (nRecved <= 0) {
1069  strcpy(maErrorStr, "Socket Error.");
1070  fclose(mpFileBuffer);
1071  mpFileBuffer = nullptr;
1072  return -1;
1073  }
1074  if (fwrite(maDataBuff + sizeof(int) * 2, 1, nRecved, mpFileBuffer) !=
1075  (size_t)nRecved) {
1076  strcpy(maErrorStr, "Failed to write file to disk.");
1077  fclose(mpFileBuffer);
1078  mpFileBuffer = nullptr;
1079  return -1;
1080  }
1081  nRecvedTotal += nRecved;
1082  }
1083  } else {
1084  strcpy(maErrorStr, "Receive file buffer not opened.");
1085  if (mpFileBuffer) {
1086  fclose(mpFileBuffer);
1087  }
1088  mpFileBuffer = nullptr;
1089  return -1;
1090  }
1091  } else {
1092  if (nFrameSize > mDataBuffSize) {
1093  char* buf = new char[nFrameSize];
1094  memcpy(buf, maDataBuff, mDataBuffSize);
1095  delete maDataBuff;
1096  maDataBuff = buf;
1097  mDataBuffSize = nFrameSize;
1098  }
1099 
1100  // Receive more data until we have read the whole packet
1101  while (nRecvedTotal < nFrameSize) {
1102  // As long as we haven't received enough data, wait for more
1103  nRecved =
1104  mpoNetwork->Receive(&(maDataBuff[nRecvedTotal]),
1105  nFrameSize - nRecvedTotal, false, nTimeout);
1106  if (nRecved <= 0) {
1107  strcpy(maErrorStr, "Socket Error.");
1108  return -1;
1109  }
1110  nRecvedTotal += nRecved;
1111  }
1112  }
1113 
1114  mpoRTPacket->SetData(maDataBuff);
1115  if (mpoRTPacket->GetEvent(
1116  meLastEvent)) // Update last event if there is an event
1117  {
1118  if (meLastEvent != CRTPacket::EventCameraSettingsChanged) {
1119  meState = meLastEvent;
1120  }
1121  }
1122  } while (bSkipEvents && eType == CRTPacket::PacketEvent);
1123 
1124  if (nRecvedTotal == nFrameSize) {
1125  return nRecvedTotal;
1126  }
1127  strcpy(maErrorStr, "Packet truncated.");
1128 
1129  return -1;
1130 } // ReceiveRTPacket
1131 
1132 CRTPacket* CRTProtocol::GetRTPacket() { return mpoRTPacket; }
1133 
1134 bool CRTProtocol::ReadXmlBool(CMarkup* xml, const std::string& element,
1135  bool& value) const {
1136  if (!xml->FindChildElem(element.c_str())) {
1137  return false;
1138  }
1139 
1140  auto str = xml->GetChildData();
1141  RemoveInvalidChars(str);
1142  ToLower(str);
1143 
1144  if (str == "true") {
1145  value = true;
1146  } else if (str == "false") {
1147  value = false;
1148  } else {
1149  // Don't change value, just report error.
1150  return false;
1151  }
1152 
1153  return true;
1154 }
1155 
1157  CRTPacket::EPacketType eType;
1158  CMarkup oXML;
1159  std::string tStr;
1160 
1161  msGeneralSettings.vsCameras.clear();
1162 
1163  if (!SendCommand("GetParameters General")) {
1164  strcpy(maErrorStr, "GetParameters General failed");
1165  return false;
1166  }
1167 
1168  auto received = ReceiveRTPacket(eType, true);
1169  if (received <= 0) {
1170  if (received == 0) {
1171  // Receive timeout.
1172  strcat(maErrorStr, " Expected XML packet.");
1173  }
1174  return false;
1175  }
1176 
1177  if (eType != CRTPacket::PacketXML) {
1178  if (eType == CRTPacket::PacketError) {
1179  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
1180  } else {
1181  sprintf(maErrorStr,
1182  "GetParameters General returned wrong packet type. Got type %d "
1183  "expected type 2.",
1184  eType);
1185  }
1186  return false;
1187  }
1188 
1189  oXML.SetDoc(mpoRTPacket->GetXMLString());
1190 
1191  // ==================== General ====================
1192  if (!oXML.FindChildElem("General")) {
1193  return false;
1194  }
1195  oXML.IntoElem();
1196 
1197  if (!oXML.FindChildElem("Frequency")) {
1198  return false;
1199  }
1200  msGeneralSettings.nCaptureFrequency = atoi(oXML.GetChildData().c_str());
1201 
1202  if (!oXML.FindChildElem("Capture_Time")) {
1203  return false;
1204  }
1205  msGeneralSettings.fCaptureTime = (float)atof(oXML.GetChildData().c_str());
1206 
1207  // Refactored variant of all this copy/paste code. TODO: Refactor everything
1208  // else.
1209  if (!ReadXmlBool(&oXML, "Start_On_External_Trigger",
1210  msGeneralSettings.bStartOnExternalTrigger)) {
1211  return false;
1212  }
1213  if (mnMajorVersion > 1 || mnMinorVersion > 14) {
1214  if (!ReadXmlBool(&oXML, "Start_On_Trigger_NO",
1215  msGeneralSettings.bStartOnTrigNO)) {
1216  return false;
1217  }
1218  if (!ReadXmlBool(&oXML, "Start_On_Trigger_NC",
1219  msGeneralSettings.bStartOnTrigNC)) {
1220  return false;
1221  }
1222  if (!ReadXmlBool(&oXML, "Start_On_Trigger_Software",
1223  msGeneralSettings.bStartOnTrigSoftware)) {
1224  return false;
1225  }
1226  }
1227 
1228  // ==================== External time base ====================
1229  if (!oXML.FindChildElem("External_Time_Base")) {
1230  return false;
1231  }
1232  oXML.IntoElem();
1233 
1234  if (!oXML.FindChildElem("Enabled")) {
1235  return false;
1236  }
1237  tStr = oXML.GetChildData();
1238  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1239  msGeneralSettings.sExternalTimebase.bEnabled = (tStr == "true");
1240 
1241  if (!oXML.FindChildElem("Signal_Source")) {
1242  return false;
1243  }
1244  tStr = oXML.GetChildData();
1245  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1246  if (tStr == "control port") {
1247  msGeneralSettings.sExternalTimebase.eSignalSource = SourceControlPort;
1248  } else if (tStr == "ir receiver") {
1249  msGeneralSettings.sExternalTimebase.eSignalSource = SourceIRReceiver;
1250  } else if (tStr == "smpte") {
1251  msGeneralSettings.sExternalTimebase.eSignalSource = SourceSMPTE;
1252  } else if (tStr == "irig") {
1253  msGeneralSettings.sExternalTimebase.eSignalSource = SourceIRIG;
1254  } else if (tStr == "video sync") {
1255  msGeneralSettings.sExternalTimebase.eSignalSource = SourceVideoSync;
1256  } else {
1257  return false;
1258  }
1259 
1260  if (!oXML.FindChildElem("Signal_Mode")) {
1261  return false;
1262  }
1263  tStr = oXML.GetChildData();
1264  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1265  if (tStr == "periodic") {
1266  msGeneralSettings.sExternalTimebase.bSignalModePeriodic = true;
1267  } else if (tStr == "non-periodic") {
1268  msGeneralSettings.sExternalTimebase.bSignalModePeriodic = false;
1269  } else {
1270  return false;
1271  }
1272 
1273  if (!oXML.FindChildElem("Frequency_Multiplier")) {
1274  return false;
1275  }
1276  unsigned int nMultiplier;
1277  tStr = oXML.GetChildData();
1278  if (sscanf(tStr.c_str(), "%u", &nMultiplier) == 1) {
1279  msGeneralSettings.sExternalTimebase.nFreqMultiplier = nMultiplier;
1280  } else {
1281  return false;
1282  }
1283 
1284  if (!oXML.FindChildElem("Frequency_Divisor")) {
1285  return false;
1286  }
1287  unsigned int nDivisor;
1288  tStr = oXML.GetChildData();
1289  if (sscanf(tStr.c_str(), "%u", &nDivisor) == 1) {
1290  msGeneralSettings.sExternalTimebase.nFreqDivisor = nDivisor;
1291  } else {
1292  return false;
1293  }
1294 
1295  if (!oXML.FindChildElem("Frequency_Tolerance")) {
1296  return false;
1297  }
1298  unsigned int nTolerance;
1299  tStr = oXML.GetChildData();
1300  if (sscanf(tStr.c_str(), "%u", &nTolerance) == 1) {
1301  msGeneralSettings.sExternalTimebase.nFreqTolerance = nTolerance;
1302  } else {
1303  return false;
1304  }
1305 
1306  if (!oXML.FindChildElem("Nominal_Frequency")) {
1307  return false;
1308  }
1309  tStr = oXML.GetChildData();
1310  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1311 
1312  if (tStr == "none") {
1313  msGeneralSettings.sExternalTimebase.fNominalFrequency =
1314  -1; // -1 = disabled
1315  } else {
1316  float fFrequency;
1317  if (sscanf(tStr.c_str(), "%f", &fFrequency) == 1) {
1318  msGeneralSettings.sExternalTimebase.fNominalFrequency = fFrequency;
1319  } else {
1320  return false;
1321  }
1322  }
1323 
1324  if (!oXML.FindChildElem("Signal_Edge")) {
1325  return false;
1326  }
1327  tStr = oXML.GetChildData();
1328  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1329  if (tStr == "negative") {
1330  msGeneralSettings.sExternalTimebase.bNegativeEdge = true;
1331  } else if (tStr == "positive") {
1332  msGeneralSettings.sExternalTimebase.bNegativeEdge = false;
1333  } else {
1334  return false;
1335  }
1336 
1337  if (!oXML.FindChildElem("Signal_Shutter_Delay")) {
1338  return false;
1339  }
1340  unsigned int nDelay;
1341  tStr = oXML.GetChildData();
1342  if (sscanf(tStr.c_str(), "%u", &nDelay) == 1) {
1343  msGeneralSettings.sExternalTimebase.nSignalShutterDelay = nDelay;
1344  } else {
1345  return false;
1346  }
1347 
1348  if (!oXML.FindChildElem("Non_Periodic_Timeout")) {
1349  return false;
1350  }
1351  float fTimeout;
1352  tStr = oXML.GetChildData();
1353  if (sscanf(tStr.c_str(), "%f", &fTimeout) == 1) {
1354  msGeneralSettings.sExternalTimebase.fNonPeriodicTimeout = fTimeout;
1355  } else {
1356  return false;
1357  }
1358 
1359  oXML.OutOfElem(); // External_Time_Base
1360 
1361  const char* processings[3] = {"Processing_Actions",
1362  "RealTime_Processing_Actions",
1363  "Reprocessing_Actions"};
1364  EProcessingActions* processingActions[3] = {
1365  &msGeneralSettings.eProcessingActions,
1366  &msGeneralSettings.eRtProcessingActions,
1367  &msGeneralSettings.eReprocessingActions};
1368  auto actionsCount = (mnMajorVersion > 1 || mnMinorVersion > 13) ? 3 : 1;
1369  for (auto i = 0; i < actionsCount; i++) {
1370  // ==================== Processing actions ====================
1371  if (!oXML.FindChildElem(processings[i])) {
1372  return false;
1373  }
1374  oXML.IntoElem();
1375 
1376  *processingActions[i] = ProcessingNone;
1377 
1378  if (mnMajorVersion > 1 || mnMinorVersion > 13) {
1379  if (!oXML.FindChildElem("PreProcessing2D")) {
1380  return false;
1381  }
1382  if (CompareNoCase(oXML.GetChildData(), "true")) {
1383  *processingActions[i] = (EProcessingActions)(*processingActions[i] +
1385  }
1386  }
1387 
1388  if (!oXML.FindChildElem("Tracking")) {
1389  return false;
1390  }
1391  tStr = oXML.GetChildData();
1392  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1393  if (tStr == "3d") {
1394  *processingActions[i] =
1395  (EProcessingActions)(*processingActions[i] + ProcessingTracking3D);
1396  } else if (tStr == "2d" && i != 1) // i != 1 => Not RtProcessingSettings
1397  {
1398  *processingActions[i] =
1399  (EProcessingActions)(*processingActions[i] + ProcessingTracking2D);
1400  }
1401 
1402  if (i != 1) // Not RtProcessingSettings
1403  {
1404  if (!oXML.FindChildElem("TwinSystemMerge")) {
1405  return false;
1406  }
1407  if (CompareNoCase(oXML.GetChildData(), "true")) {
1408  *processingActions[i] = (EProcessingActions)(*processingActions[i] +
1410  }
1411 
1412  if (!oXML.FindChildElem("SplineFill")) {
1413  return false;
1414  }
1415  if (CompareNoCase(oXML.GetChildData(), "true")) {
1416  *processingActions[i] =
1417  (EProcessingActions)(*processingActions[i] + ProcessingSplineFill);
1418  }
1419  }
1420 
1421  if (!oXML.FindChildElem("AIM")) {
1422  return false;
1423  }
1424  if (CompareNoCase(oXML.GetChildData(), "true")) {
1425  *processingActions[i] =
1426  (EProcessingActions)(*processingActions[i] + ProcessingAIM);
1427  }
1428 
1429  if (!oXML.FindChildElem("Track6DOF")) {
1430  return false;
1431  }
1432  if (CompareNoCase(oXML.GetChildData(), "true")) {
1433  *processingActions[i] =
1434  (EProcessingActions)(*processingActions[i] + Processing6DOFTracking);
1435  }
1436 
1437  if (!oXML.FindChildElem("ForceData")) {
1438  return false;
1439  }
1440  if (CompareNoCase(oXML.GetChildData(), "true")) {
1441  *processingActions[i] =
1442  (EProcessingActions)(*processingActions[i] + ProcessingForceData);
1443  }
1444 
1445  if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1446  if (!oXML.FindChildElem("GazeVector")) {
1447  return false;
1448  }
1449  if (CompareNoCase(oXML.GetChildData(), "true")) {
1450  *processingActions[i] =
1451  (EProcessingActions)(*processingActions[i] + ProcessingGazeVector);
1452  }
1453  }
1454 
1455  if (i != 1) // Not RtProcessingSettings
1456  {
1457  if (!oXML.FindChildElem("ExportTSV")) {
1458  return false;
1459  }
1460  if (CompareNoCase(oXML.GetChildData(), "true")) {
1461  *processingActions[i] =
1462  (EProcessingActions)(*processingActions[i] + ProcessingExportTSV);
1463  }
1464 
1465  if (!oXML.FindChildElem("ExportC3D")) {
1466  return false;
1467  }
1468  if (CompareNoCase(oXML.GetChildData(), "true")) {
1469  *processingActions[i] =
1470  (EProcessingActions)(*processingActions[i] + ProcessingExportC3D);
1471  }
1472 
1473  if (!oXML.FindChildElem("ExportMatlabFile")) {
1474  return false;
1475  }
1476  if (CompareNoCase(oXML.GetChildData(), "true")) {
1477  *processingActions[i] =
1478  (EProcessingActions)(*processingActions[i] +
1480  }
1481 
1482  if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1483  if (!oXML.FindChildElem("ExportAviFile")) {
1484  return false;
1485  }
1486  if (CompareNoCase(oXML.GetChildData(), "true")) {
1487  *processingActions[i] = (EProcessingActions)(*processingActions[i] +
1489  }
1490  }
1491  }
1492  oXML.OutOfElem(); // Processing_Actions
1493  }
1494 
1495  // ==================== Camera ====================
1496  msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Unknown;
1497  if (oXML.FindChildElem("Camera_System") && oXML.IntoElem()) {
1498  if (oXML.FindChildElem("Type")) {
1499  tStr = oXML.GetChildData();
1500  if (CompareNoCase(tStr, "oqus")) {
1501  msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Oqus;
1502  } else if (CompareNoCase(tStr, "miqus")) {
1503  msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Miqus;
1504  }
1505  }
1506  oXML.OutOfElem();
1507  }
1508 
1509  SSettingsGeneralCamera sCameraSettings;
1510 
1511  while (oXML.FindChildElem("Camera")) {
1512  oXML.IntoElem();
1513 
1514  if (!oXML.FindChildElem("ID")) {
1515  return false;
1516  }
1517  sCameraSettings.nID = atoi(oXML.GetChildData().c_str());
1518 
1519  if (!oXML.FindChildElem("Model")) {
1520  return false;
1521  }
1522  tStr = oXML.GetChildData();
1523  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1524 
1525  if (tStr == "macreflex") {
1526  sCameraSettings.eModel = ModelMacReflex;
1527  } else if (tStr == "proreflex 120") {
1528  sCameraSettings.eModel = ModelProReflex120;
1529  } else if (tStr == "proreflex 240") {
1530  sCameraSettings.eModel = ModelProReflex240;
1531  } else if (tStr == "proreflex 500") {
1532  sCameraSettings.eModel = ModelProReflex500;
1533  } else if (tStr == "proreflex 1000") {
1534  sCameraSettings.eModel = ModelProReflex1000;
1535  } else if (tStr == "oqus 100") {
1536  sCameraSettings.eModel = ModelOqus100;
1537  } else if (tStr == "oqus 200" || tStr == "oqus 200 c") {
1538  sCameraSettings.eModel = ModelOqus200C;
1539  } else if (tStr == "oqus 300") {
1540  sCameraSettings.eModel = ModelOqus300;
1541  } else if (tStr == "oqus 300 plus") {
1542  sCameraSettings.eModel = ModelOqus300Plus;
1543  } else if (tStr == "oqus 400") {
1544  sCameraSettings.eModel = ModelOqus400;
1545  } else if (tStr == "oqus 500") {
1546  sCameraSettings.eModel = ModelOqus500;
1547  } else if (tStr == "oqus 500 plus") {
1548  sCameraSettings.eModel = ModelOqus500Plus;
1549  } else if (tStr == "oqus 700") {
1550  sCameraSettings.eModel = ModelOqus700;
1551  } else if (tStr == "oqus 700 plus") {
1552  sCameraSettings.eModel = ModelOqus700Plus;
1553  } else if (tStr == "oqus 600 plus") {
1554  sCameraSettings.eModel = ModelOqus600Plus;
1555  } else if (tStr == "miqus m1") {
1556  sCameraSettings.eModel = ModelMiqusM1;
1557  } else if (tStr == "miqus m3") {
1558  sCameraSettings.eModel = ModelMiqusM3;
1559  } else if (tStr == "miqus m5") {
1560  sCameraSettings.eModel = ModelMiqusM5;
1561  } else if (tStr == "miqus sync unit") {
1562  sCameraSettings.eModel = ModelMiqusSyncUnit;
1563  } else if (tStr == "miqus video") {
1564  sCameraSettings.eModel = ModelMiqusVideo;
1565  } else if (tStr == "miqus video color") {
1566  sCameraSettings.eModel = ModelMiqusVideoColor;
1567  } else {
1568  return false;
1569  }
1570 
1571  // Only available from protocol version 1.10 and later.
1572  if (oXML.FindChildElem("Underwater")) {
1573  tStr = oXML.GetChildData();
1574  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1575  sCameraSettings.bUnderwater = (tStr == "true");
1576  }
1577 
1578  if (oXML.FindChildElem("Supports_HW_Sync")) {
1579  tStr = oXML.GetChildData();
1580  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1581  sCameraSettings.bSupportsHwSync = (tStr == "true");
1582  }
1583 
1584  if (!oXML.FindChildElem("Serial")) {
1585  return false;
1586  }
1587  sCameraSettings.nSerial = atoi(oXML.GetChildData().c_str());
1588 
1589  // ==================== Camera Mode ====================
1590  if (!oXML.FindChildElem("Mode")) {
1591  return false;
1592  }
1593  tStr = oXML.GetChildData();
1594  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1595  if (tStr == "marker") {
1596  sCameraSettings.eMode = ModeMarker;
1597  } else if (tStr == "marker intensity") {
1598  sCameraSettings.eMode = ModeMarkerIntensity;
1599  } else if (tStr == "video") {
1600  sCameraSettings.eMode = ModeVideo;
1601  } else {
1602  return false;
1603  }
1604 
1605  if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1606  // ==================== Video frequency ====================
1607  if (!oXML.FindChildElem("Video_Frequency")) {
1608  return false;
1609  }
1610  sCameraSettings.nVideoFrequency = atoi(oXML.GetChildData().c_str());
1611  }
1612 
1613  // ==================== Video Resolution ====================
1614  if (oXML.FindChildElem("Video_Resolution")) {
1615  tStr = oXML.GetChildData();
1616  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1617  if (tStr == "1080p") {
1618  sCameraSettings.eVideoResolution = VideoResolution1080p;
1619  } else if (tStr == "720p") {
1620  sCameraSettings.eVideoResolution = VideoResolution720p;
1621  } else if (tStr == "540p") {
1622  sCameraSettings.eVideoResolution = VideoResolution540p;
1623  } else if (tStr == "480p") {
1624  sCameraSettings.eVideoResolution = VideoResolution480p;
1625  }
1626  } else {
1627  sCameraSettings.eVideoResolution = VideoResolutionNone;
1628  }
1629 
1630  // ==================== Video AspectRatio ====================
1631  if (oXML.FindChildElem("Video_Aspect_Ratio")) {
1632  tStr = oXML.GetChildData();
1633  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1634  if (tStr == "16x9") {
1635  sCameraSettings.eVideoAspectRatio = VideoAspectRatio16x9;
1636  } else if (tStr == "4x3") {
1637  sCameraSettings.eVideoAspectRatio = VideoAspectRatio4x3;
1638  } else if (tStr == "1x1") {
1639  sCameraSettings.eVideoAspectRatio = VideoAspectRatio1x1;
1640  }
1641  } else {
1642  sCameraSettings.eVideoAspectRatio = VideoAspectRatioNone;
1643  }
1644 
1645  // ==================== Video exposure ====================
1646  if (!oXML.FindChildElem("Video_Exposure")) {
1647  return false;
1648  }
1649  oXML.IntoElem();
1650 
1651  if (!oXML.FindChildElem("Current")) {
1652  return false;
1653  }
1654  sCameraSettings.nVideoExposure = atoi(oXML.GetChildData().c_str());
1655 
1656  if (!oXML.FindChildElem("Min")) {
1657  return false;
1658  }
1659  sCameraSettings.nVideoExposureMin = atoi(oXML.GetChildData().c_str());
1660 
1661  if (!oXML.FindChildElem("Max")) {
1662  return false;
1663  }
1664  sCameraSettings.nVideoExposureMax = atoi(oXML.GetChildData().c_str());
1665  oXML.OutOfElem(); // Video_Exposure
1666 
1667  // ==================== Video flash time ====================
1668  if (!oXML.FindChildElem("Video_Flash_Time")) {
1669  return false;
1670  }
1671  oXML.IntoElem();
1672 
1673  if (!oXML.FindChildElem("Current")) {
1674  return false;
1675  }
1676  sCameraSettings.nVideoFlashTime = atoi(oXML.GetChildData().c_str());
1677 
1678  if (!oXML.FindChildElem("Min")) {
1679  return false;
1680  }
1681  sCameraSettings.nVideoFlashTimeMin = atoi(oXML.GetChildData().c_str());
1682 
1683  if (!oXML.FindChildElem("Max")) {
1684  return false;
1685  }
1686  sCameraSettings.nVideoFlashTimeMax = atoi(oXML.GetChildData().c_str());
1687  oXML.OutOfElem(); // Video_Flash_Time
1688 
1689  // ==================== Marker exposure ====================
1690  if (!oXML.FindChildElem("Marker_Exposure")) {
1691  return false;
1692  }
1693  oXML.IntoElem();
1694 
1695  if (!oXML.FindChildElem("Current")) {
1696  return false;
1697  }
1698  sCameraSettings.nMarkerExposure = atoi(oXML.GetChildData().c_str());
1699 
1700  if (!oXML.FindChildElem("Min")) {
1701  return false;
1702  }
1703  sCameraSettings.nMarkerExposureMin = atoi(oXML.GetChildData().c_str());
1704 
1705  if (!oXML.FindChildElem("Max")) {
1706  return false;
1707  }
1708  sCameraSettings.nMarkerExposureMax = atoi(oXML.GetChildData().c_str());
1709 
1710  oXML.OutOfElem(); // Marker_Exposure
1711 
1712  // ==================== Marker threshold ====================
1713  if (!oXML.FindChildElem("Marker_Threshold")) {
1714  return false;
1715  }
1716  oXML.IntoElem();
1717 
1718  if (!oXML.FindChildElem("Current")) {
1719  return false;
1720  }
1721  sCameraSettings.nMarkerThreshold = atoi(oXML.GetChildData().c_str());
1722 
1723  if (!oXML.FindChildElem("Min")) {
1724  return false;
1725  }
1726  sCameraSettings.nMarkerThresholdMin = atoi(oXML.GetChildData().c_str());
1727 
1728  if (!oXML.FindChildElem("Max")) {
1729  return false;
1730  }
1731  sCameraSettings.nMarkerThresholdMax = atoi(oXML.GetChildData().c_str());
1732 
1733  oXML.OutOfElem(); // Marker_Threshold
1734 
1735  // ==================== Position ====================
1736  if (!oXML.FindChildElem("Position")) {
1737  return false;
1738  }
1739  oXML.IntoElem();
1740 
1741  if (!oXML.FindChildElem("X")) {
1742  return false;
1743  }
1744  sCameraSettings.fPositionX = (float)atoi(oXML.GetChildData().c_str());
1745 
1746  if (!oXML.FindChildElem("Y")) {
1747  return false;
1748  }
1749  sCameraSettings.fPositionY = (float)atoi(oXML.GetChildData().c_str());
1750 
1751  if (!oXML.FindChildElem("Z")) {
1752  return false;
1753  }
1754  sCameraSettings.fPositionZ = (float)atoi(oXML.GetChildData().c_str());
1755 
1756  if (!oXML.FindChildElem("Rot_1_1")) {
1757  return false;
1758  }
1759  sCameraSettings.fPositionRotMatrix[0][0] =
1760  (float)atof(oXML.GetChildData().c_str());
1761 
1762  if (!oXML.FindChildElem("Rot_2_1")) {
1763  return false;
1764  }
1765  sCameraSettings.fPositionRotMatrix[1][0] =
1766  (float)atof(oXML.GetChildData().c_str());
1767 
1768  if (!oXML.FindChildElem("Rot_3_1")) {
1769  return false;
1770  }
1771  sCameraSettings.fPositionRotMatrix[2][0] =
1772  (float)atof(oXML.GetChildData().c_str());
1773 
1774  if (!oXML.FindChildElem("Rot_1_2")) {
1775  return false;
1776  }
1777  sCameraSettings.fPositionRotMatrix[0][1] =
1778  (float)atof(oXML.GetChildData().c_str());
1779 
1780  if (!oXML.FindChildElem("Rot_2_2")) {
1781  return false;
1782  }
1783  sCameraSettings.fPositionRotMatrix[1][1] =
1784  (float)atof(oXML.GetChildData().c_str());
1785 
1786  if (!oXML.FindChildElem("Rot_3_2")) {
1787  return false;
1788  }
1789  sCameraSettings.fPositionRotMatrix[2][1] =
1790  (float)atof(oXML.GetChildData().c_str());
1791 
1792  if (!oXML.FindChildElem("Rot_1_3")) {
1793  return false;
1794  }
1795  sCameraSettings.fPositionRotMatrix[0][2] =
1796  (float)atof(oXML.GetChildData().c_str());
1797 
1798  if (!oXML.FindChildElem("Rot_2_3")) {
1799  return false;
1800  }
1801  sCameraSettings.fPositionRotMatrix[1][2] =
1802  (float)atof(oXML.GetChildData().c_str());
1803 
1804  if (!oXML.FindChildElem("Rot_3_3")) {
1805  return false;
1806  }
1807  sCameraSettings.fPositionRotMatrix[2][2] =
1808  (float)atof(oXML.GetChildData().c_str());
1809 
1810  oXML.OutOfElem(); // Position
1811 
1812  if (!oXML.FindChildElem("Orientation")) {
1813  return false;
1814  }
1815  sCameraSettings.nOrientation = atoi(oXML.GetChildData().c_str());
1816 
1817  // ==================== Marker exposure ====================
1818  if (!oXML.FindChildElem("Marker_Res")) {
1819  return false;
1820  }
1821  oXML.IntoElem();
1822 
1823  if (!oXML.FindChildElem("Width")) {
1824  return false;
1825  }
1826  sCameraSettings.nMarkerResolutionWidth = atoi(oXML.GetChildData().c_str());
1827 
1828  if (!oXML.FindChildElem("Height")) {
1829  return false;
1830  }
1831  sCameraSettings.nMarkerResolutionHeight = atoi(oXML.GetChildData().c_str());
1832 
1833  oXML.OutOfElem(); // Marker_Res
1834 
1835  // ==================== Marker resolution ====================
1836  if (!oXML.FindChildElem("Video_Res")) {
1837  return false;
1838  }
1839  oXML.IntoElem();
1840 
1841  if (!oXML.FindChildElem("Width")) {
1842  return false;
1843  }
1844  sCameraSettings.nVideoResolutionWidth = atoi(oXML.GetChildData().c_str());
1845 
1846  if (!oXML.FindChildElem("Height")) {
1847  return false;
1848  }
1849  sCameraSettings.nVideoResolutionHeight = atoi(oXML.GetChildData().c_str());
1850 
1851  oXML.OutOfElem(); // Video_Res
1852 
1853  // ==================== Marker FOV ====================
1854  if (!oXML.FindChildElem("Marker_FOV")) {
1855  return false;
1856  }
1857  oXML.IntoElem();
1858 
1859  if (!oXML.FindChildElem("Left")) {
1860  return false;
1861  }
1862  sCameraSettings.nMarkerFOVLeft = atoi(oXML.GetChildData().c_str());
1863 
1864  if (!oXML.FindChildElem("Top")) {
1865  return false;
1866  }
1867  sCameraSettings.nMarkerFOVTop = atoi(oXML.GetChildData().c_str());
1868 
1869  if (!oXML.FindChildElem("Right")) {
1870  return false;
1871  }
1872  sCameraSettings.nMarkerFOVRight = atoi(oXML.GetChildData().c_str());
1873 
1874  if (!oXML.FindChildElem("Bottom")) {
1875  return false;
1876  }
1877  sCameraSettings.nMarkerFOVBottom = atoi(oXML.GetChildData().c_str());
1878 
1879  oXML.OutOfElem(); // Marker_FOV
1880 
1881  // ==================== Video FOV ====================
1882  if (!oXML.FindChildElem("Video_FOV")) {
1883  return false;
1884  }
1885  oXML.IntoElem();
1886 
1887  if (!oXML.FindChildElem("Left")) {
1888  return false;
1889  }
1890  sCameraSettings.nVideoFOVLeft = atoi(oXML.GetChildData().c_str());
1891 
1892  if (!oXML.FindChildElem("Top")) {
1893  return false;
1894  }
1895  sCameraSettings.nVideoFOVTop = atoi(oXML.GetChildData().c_str());
1896 
1897  if (!oXML.FindChildElem("Right")) {
1898  return false;
1899  }
1900  sCameraSettings.nVideoFOVRight = atoi(oXML.GetChildData().c_str());
1901 
1902  if (!oXML.FindChildElem("Bottom")) {
1903  return false;
1904  }
1905  sCameraSettings.nVideoFOVBottom = atoi(oXML.GetChildData().c_str());
1906 
1907  oXML.OutOfElem(); // Video_FOV
1908 
1909  // ==================== Sync out ====================
1910  // Only available from protocol version 1.10 and later.
1911  for (int port = 0; port < 3; port++) {
1912  char syncOutStr[16];
1913  sprintf(syncOutStr, "Sync_Out%s",
1914  port == 0 ? "" : (port == 1 ? "2" : "_MT"));
1915  if (oXML.FindChildElem(syncOutStr)) {
1916  oXML.IntoElem();
1917 
1918  if (port < 2) {
1919  if (!oXML.FindChildElem("Mode")) {
1920  return false;
1921  }
1922  tStr = oXML.GetChildData();
1923  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1924  if (tStr == "shutter out") {
1925  sCameraSettings.eSyncOutMode[port] = ModeShutterOut;
1926  } else if (tStr == "multiplier") {
1927  sCameraSettings.eSyncOutMode[port] = ModeMultiplier;
1928  } else if (tStr == "divisor") {
1929  sCameraSettings.eSyncOutMode[port] = ModeDivisor;
1930  } else if (tStr == "camera independent") {
1931  sCameraSettings.eSyncOutMode[port] = ModeActualFreq;
1932  } else if (tStr == "measurement time") {
1933  sCameraSettings.eSyncOutMode[port] = ModeMeasurementTime;
1934  } else if (tStr == "continuous 100hz") {
1935  sCameraSettings.eSyncOutMode[port] = ModeFixed100Hz;
1936  } else {
1937  return false;
1938  }
1939 
1940  if (sCameraSettings.eSyncOutMode[port] == ModeMultiplier ||
1941  sCameraSettings.eSyncOutMode[port] == ModeDivisor ||
1942  sCameraSettings.eSyncOutMode[port] == ModeActualFreq) {
1943  if (!oXML.FindChildElem("Value")) {
1944  return false;
1945  }
1946  sCameraSettings.nSyncOutValue[port] =
1947  atoi(oXML.GetChildData().c_str());
1948 
1949  if (!oXML.FindChildElem("Duty_Cycle")) {
1950  return false;
1951  }
1952  sCameraSettings.fSyncOutDutyCycle[port] =
1953  (float)atof(oXML.GetChildData().c_str());
1954  }
1955  }
1956  if (port == 2 ||
1957  (sCameraSettings.eSyncOutMode[port] != ModeFixed100Hz)) {
1958  if (!oXML.FindChildElem("Signal_Polarity")) {
1959  return false;
1960  }
1961  if (CompareNoCase(oXML.GetChildData(), "negative")) {
1962  sCameraSettings.bSyncOutNegativePolarity[port] = true;
1963  } else {
1964  sCameraSettings.bSyncOutNegativePolarity[port] = false;
1965  }
1966  }
1967  oXML.OutOfElem(); // Sync_Out
1968  } else {
1969  sCameraSettings.eSyncOutMode[port] = ModeActualFreq;
1970  sCameraSettings.nSyncOutValue[port] = 0;
1971  sCameraSettings.fSyncOutDutyCycle[port] = 0;
1972  sCameraSettings.bSyncOutNegativePolarity[port] = false;
1973  }
1974  }
1975 
1976  if (oXML.FindChildElem("LensControl")) {
1977  oXML.IntoElem();
1978  if (oXML.FindChildElem("Focus")) {
1979  oXML.IntoElem();
1980  float focus;
1981  if (sscanf(oXML.GetAttrib("Value").c_str(), "%f", &focus) == 1) {
1982  sCameraSettings.fFocus = focus;
1983  }
1984  oXML.OutOfElem();
1985  }
1986  if (oXML.FindChildElem("Aperture")) {
1987  oXML.IntoElem();
1988  float aperture;
1989  if (sscanf(oXML.GetAttrib("Value").c_str(), "%f", &aperture) == 1) {
1990  sCameraSettings.fAperture = aperture;
1991  }
1992  oXML.OutOfElem();
1993  }
1994  oXML.OutOfElem();
1995  } else {
1996  sCameraSettings.fFocus = std::numeric_limits<float>::quiet_NaN();
1997  sCameraSettings.fAperture = std::numeric_limits<float>::quiet_NaN();
1998  }
1999 
2000  if (oXML.FindChildElem("AutoExposure")) {
2001  oXML.IntoElem();
2002  if (CompareNoCase(oXML.GetAttrib("Enabled"), "true")) {
2003  sCameraSettings.autoExposureEnabled = true;
2004  }
2005  float autoExposureCompensation;
2006  if (sscanf(oXML.GetAttrib("Compensation").c_str(), "%f",
2007  &autoExposureCompensation) == 1) {
2008  sCameraSettings.autoExposureCompensation = autoExposureCompensation;
2009  }
2010  oXML.OutOfElem();
2011  } else {
2012  sCameraSettings.autoExposureEnabled = false;
2013  sCameraSettings.autoExposureCompensation =
2014  std::numeric_limits<float>::quiet_NaN();
2015  }
2016 
2017  if (oXML.FindChildElem("AutoWhiteBalance")) {
2018  sCameraSettings.autoWhiteBalance =
2019  CompareNoCase(oXML.GetChildData().c_str(), "true") ? 1 : 0;
2020  } else {
2021  sCameraSettings.autoWhiteBalance = -1;
2022  }
2023 
2024  oXML.OutOfElem(); // Camera
2025 
2026  msGeneralSettings.vsCameras.push_back(sCameraSettings);
2027  }
2028 
2029  return true;
2030 } // ReadGeneralSettings
2031 
2032 bool CRTProtocol::Read3DSettings(bool& bDataAvailable) {
2033  CRTPacket::EPacketType eType;
2034  CMarkup oXML;
2035  std::string tStr;
2036 
2037  bDataAvailable = false;
2038 
2039  ms3DSettings.s3DLabels.clear();
2040  ms3DSettings.pCalibrationTime[0] = 0;
2041 
2042  if (!SendCommand("GetParameters 3D")) {
2043  strcpy(maErrorStr, "GetParameters 3D failed");
2044  return false;
2045  }
2046 
2047  auto received = ReceiveRTPacket(eType, true);
2048  if (received <= 0) {
2049  if (received == 0) {
2050  // Receive timeout.
2051  strcat(maErrorStr, " Expected XML packet.");
2052  }
2053  return false;
2054  }
2055 
2056  if (eType != CRTPacket::PacketXML) {
2057  if (eType == CRTPacket::PacketError) {
2058  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2059  } else {
2060  sprintf(maErrorStr,
2061  "GetParameters 3D returned wrong packet type. Got type %d "
2062  "expected type 2.",
2063  eType);
2064  }
2065  return false;
2066  }
2067 
2068  oXML.SetDoc(mpoRTPacket->GetXMLString());
2069 
2070  if (!oXML.FindChildElem("The_3D")) {
2071  // No 3D data available.
2072  return true;
2073  }
2074  oXML.IntoElem();
2075 
2076  if (!oXML.FindChildElem("AxisUpwards")) {
2077  return false;
2078  }
2079  tStr = oXML.GetChildData();
2080  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2081 
2082  if (tStr == "+x") {
2083  ms3DSettings.eAxisUpwards = XPos;
2084  } else if (tStr == "-x") {
2085  ms3DSettings.eAxisUpwards = XNeg;
2086  } else if (tStr == "+y") {
2087  ms3DSettings.eAxisUpwards = YPos;
2088  } else if (tStr == "-y") {
2089  ms3DSettings.eAxisUpwards = YNeg;
2090  } else if (tStr == "+z") {
2091  ms3DSettings.eAxisUpwards = ZPos;
2092  } else if (tStr == "-z") {
2093  ms3DSettings.eAxisUpwards = ZNeg;
2094  } else {
2095  return false;
2096  }
2097 
2098  if (!oXML.FindChildElem("CalibrationTime")) {
2099  return false;
2100  }
2101  tStr = oXML.GetChildData();
2102  strcpy(ms3DSettings.pCalibrationTime, tStr.c_str());
2103 
2104  if (!oXML.FindChildElem("Labels")) {
2105  return false;
2106  }
2107  unsigned int nNumberOfLabels = atoi(oXML.GetChildData().c_str());
2108 
2109  ms3DSettings.s3DLabels.resize(nNumberOfLabels);
2110  SSettings3DLabel sLabel;
2111 
2112  for (unsigned int iLabel = 0; iLabel < nNumberOfLabels; iLabel++) {
2113  if (oXML.FindChildElem("Label")) {
2114  oXML.IntoElem();
2115  if (oXML.FindChildElem("Name")) {
2116  sLabel.oName = oXML.GetChildData();
2117  if (oXML.FindChildElem("RGBColor")) {
2118  sLabel.nRGBColor = atoi(oXML.GetChildData().c_str());
2119  }
2120  ms3DSettings.s3DLabels[iLabel] = sLabel;
2121  }
2122  oXML.OutOfElem();
2123  } else {
2124  return false;
2125  }
2126  }
2127 
2128  ms3DSettings.sBones.clear();
2129  if (oXML.FindChildElem("Bones")) {
2130  oXML.IntoElem();
2131  while (oXML.FindChildElem("Bone")) {
2132  oXML.IntoElem();
2133  SSettingsBone bone = {};
2134  bone.fromName = oXML.GetAttrib("From").c_str();
2135  bone.toName = oXML.GetAttrib("To").c_str();
2136 
2137  auto colorString = oXML.GetAttrib("Color");
2138  if (!colorString.empty()) {
2139  bone.color = atoi(colorString.c_str());
2140  }
2141  ms3DSettings.sBones.push_back(bone);
2142  oXML.OutOfElem();
2143  }
2144  oXML.OutOfElem();
2145  }
2146 
2147  bDataAvailable = true;
2148  return true;
2149 } // Read3DSettings
2150 
2151 bool CRTProtocol::Read6DOFSettings(bool& bDataAvailable) {
2152  CRTPacket::EPacketType eType;
2153  CMarkup oXML;
2154 
2155  bDataAvailable = false;
2156 
2157  mvs6DOFSettings.bodySettings.clear();
2158 
2159  if (!SendCommand("GetParameters 6D")) {
2160  strcpy(maErrorStr, "GetParameters 6D failed");
2161  return false;
2162  }
2163 
2164  auto received = ReceiveRTPacket(eType, true);
2165  if (received <= 0) {
2166  if (received == 0) {
2167  // Receive timeout.
2168  strcat(maErrorStr, " Expected XML packet.");
2169  }
2170  return false;
2171  }
2172 
2173  if (eType != CRTPacket::PacketXML) {
2174  if (eType == CRTPacket::PacketError) {
2175  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2176  } else {
2177  sprintf(maErrorStr,
2178  "GetParameters 6D returned wrong packet type. Got type %d "
2179  "expected type 2.",
2180  eType);
2181  }
2182  return false;
2183  }
2184 
2185  oXML.SetDoc(mpoRTPacket->GetXMLString());
2186 
2187  //
2188  // Read 6DOF bodies
2189  //
2190  if (!oXML.FindChildElem("The_6D")) {
2191  return true; // NO 6DOF data available.
2192  }
2193  oXML.IntoElem();
2194 
2195  if (!oXML.FindChildElem("Bodies")) {
2196  return false;
2197  }
2198  int nBodies = atoi(oXML.GetChildData().c_str());
2199  SSettings6DOFBody s6DOFBodySettings;
2200  SPoint sPoint;
2201 
2202  for (int iBody = 0; iBody < nBodies; iBody++) {
2203  if (!oXML.FindChildElem("Body")) {
2204  return false;
2205  }
2206  oXML.IntoElem();
2207 
2208  if (!oXML.FindChildElem("Name")) {
2209  return false;
2210  }
2211  s6DOFBodySettings.oName = oXML.GetChildData();
2212 
2213  if (!oXML.FindChildElem("RGBColor")) {
2214  return false;
2215  }
2216  s6DOFBodySettings.vsPoints.clear();
2217  s6DOFBodySettings.nRGBColor = atoi(oXML.GetChildData().c_str());
2218 
2219  while (oXML.FindChildElem("Point")) {
2220  oXML.IntoElem();
2221  if (!oXML.FindChildElem("X")) {
2222  return false;
2223  }
2224  sPoint.fX = (float)atof(oXML.GetChildData().c_str());
2225 
2226  if (!oXML.FindChildElem("Y")) {
2227  return false;
2228  }
2229  sPoint.fY = (float)atof(oXML.GetChildData().c_str());
2230 
2231  if (!oXML.FindChildElem("Z")) {
2232  return false;
2233  }
2234  sPoint.fZ = (float)atof(oXML.GetChildData().c_str());
2235 
2236  oXML.OutOfElem(); // Point
2237  s6DOFBodySettings.vsPoints.push_back(sPoint);
2238  }
2239  mvs6DOFSettings.bodySettings.push_back(s6DOFBodySettings);
2240  oXML.OutOfElem(); // Body
2241  }
2242 
2243  if (mnMajorVersion > 1 || mnMinorVersion > 15) {
2244  if (oXML.FindChildElem("Euler")) {
2245  oXML.IntoElem();
2246  if (!oXML.FindChildElem("First")) {
2247  return false;
2248  }
2249  mvs6DOFSettings.eulerFirst = oXML.GetChildData();
2250  if (!oXML.FindChildElem("Second")) {
2251  return false;
2252  }
2253  mvs6DOFSettings.eulerSecond = oXML.GetChildData();
2254  if (!oXML.FindChildElem("Third")) {
2255  return false;
2256  }
2257  mvs6DOFSettings.eulerThird = oXML.GetChildData();
2258  oXML.OutOfElem(); // Euler
2259  }
2260  }
2261 
2262  bDataAvailable = true;
2263  return true;
2264 } // Read6DOFSettings
2265 
2266 bool CRTProtocol::ReadGazeVectorSettings(bool& bDataAvailable) {
2267  CRTPacket::EPacketType eType;
2268  CMarkup oXML;
2269 
2270  bDataAvailable = false;
2271 
2272  mvsGazeVectorSettings.clear();
2273 
2274  if (!SendCommand("GetParameters GazeVector")) {
2275  strcpy(maErrorStr, "GetParameters GazeVector failed");
2276  return false;
2277  }
2278 
2279  auto received = ReceiveRTPacket(eType, true);
2280  if (received <= 0) {
2281  if (received == 0) {
2282  // Receive timeout.
2283  strcat(maErrorStr, " Expected XML packet.");
2284  }
2285  return false;
2286  }
2287 
2288  if (eType != CRTPacket::PacketXML) {
2289  if (eType == CRTPacket::PacketError) {
2290  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2291  } else {
2292  sprintf(maErrorStr,
2293  "GetParameters GazeVector returned wrong packet type. Got type "
2294  "%d expected type 2.",
2295  eType);
2296  }
2297  return false;
2298  }
2299 
2300  oXML.SetDoc(mpoRTPacket->GetXMLString());
2301 
2302  //
2303  // Read gaze vectors
2304  //
2305  if (!oXML.FindChildElem("Gaze_Vector")) {
2306  return true; // NO gaze vector data available.
2307  }
2308  oXML.IntoElem();
2309 
2310  std::string tGazeVectorName;
2311 
2312  int nGazeVectorCount = 0;
2313 
2314  while (oXML.FindChildElem("Vector")) {
2315  oXML.IntoElem();
2316 
2317  if (!oXML.FindChildElem("Name")) {
2318  return false;
2319  }
2320  tGazeVectorName = oXML.GetChildData();
2321 
2322  float frequency = 0;
2323  if (oXML.FindChildElem("Frequency")) {
2324  frequency = (float)atof(oXML.GetChildData().c_str());
2325  }
2326 
2327  mvsGazeVectorSettings.push_back({tGazeVectorName, frequency});
2328  nGazeVectorCount++;
2329  oXML.OutOfElem(); // Vector
2330  }
2331 
2332  bDataAvailable = true;
2333  return true;
2334 } // ReadGazeVectorSettings
2335 
2336 bool CRTProtocol::ReadAnalogSettings(bool& bDataAvailable) {
2337  CRTPacket::EPacketType eType;
2338  CMarkup oXML;
2339 
2340  bDataAvailable = false;
2341  mvsAnalogDeviceSettings.clear();
2342 
2343  if (!SendCommand("GetParameters Analog")) {
2344  strcpy(maErrorStr, "GetParameters Analog failed");
2345  return false;
2346  }
2347 
2348  auto received = ReceiveRTPacket(eType, true);
2349  if (received <= 0) {
2350  if (received == 0) {
2351  // Receive timeout.
2352  strcat(maErrorStr, " Expected XML packet.");
2353  }
2354  return false;
2355  }
2356 
2357  if (eType != CRTPacket::PacketXML) {
2358  if (eType == CRTPacket::PacketError) {
2359  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2360  } else {
2361  sprintf(maErrorStr,
2362  "GetParameters Analog returned wrong packet type. Got type %d "
2363  "expected type 2.",
2364  eType);
2365  }
2366  return false;
2367  }
2368 
2369  oXML.SetDoc(mpoRTPacket->GetXMLString());
2370 
2371  if (!oXML.FindChildElem("Analog")) {
2372  // No analog data available.
2373  return true;
2374  }
2375 
2376  SAnalogDevice sAnalogDevice;
2377 
2378  oXML.IntoElem();
2379 
2380  if (mnMajorVersion == 1 && mnMinorVersion == 0) {
2381  sAnalogDevice.nDeviceID = 1; // Always channel 1
2382  sAnalogDevice.oName = "AnalogDevice";
2383  if (!oXML.FindChildElem("Channels")) {
2384  return false;
2385  }
2386  sAnalogDevice.nChannels = atoi(oXML.GetChildData().c_str());
2387  if (!oXML.FindChildElem("Frequency")) {
2388  return false;
2389  }
2390  sAnalogDevice.nFrequency = atoi(oXML.GetChildData().c_str());
2391  if (!oXML.FindChildElem("Unit")) {
2392  return false;
2393  }
2394  sAnalogDevice.oUnit = oXML.GetChildData();
2395  if (!oXML.FindChildElem("Range")) {
2396  return false;
2397  }
2398  oXML.IntoElem();
2399  if (!oXML.FindChildElem("Min")) {
2400  return false;
2401  }
2402  sAnalogDevice.fMinRange = (float)atof(oXML.GetChildData().c_str());
2403  if (!oXML.FindChildElem("Max")) {
2404  return false;
2405  }
2406  sAnalogDevice.fMaxRange = (float)atof(oXML.GetChildData().c_str());
2407  mvsAnalogDeviceSettings.push_back(sAnalogDevice);
2408  bDataAvailable = true;
2409  return true;
2410  } else {
2411  while (oXML.FindChildElem("Device")) {
2412  sAnalogDevice.voLabels.clear();
2413  sAnalogDevice.voUnits.clear();
2414  oXML.IntoElem();
2415  if (!oXML.FindChildElem("Device_ID")) {
2416  oXML.OutOfElem(); // Device
2417  continue;
2418  }
2419  sAnalogDevice.nDeviceID = atoi(oXML.GetChildData().c_str());
2420 
2421  if (!oXML.FindChildElem("Device_Name")) {
2422  oXML.OutOfElem(); // Device
2423  continue;
2424  }
2425  sAnalogDevice.oName = oXML.GetChildData();
2426 
2427  if (!oXML.FindChildElem("Channels")) {
2428  oXML.OutOfElem(); // Device
2429  continue;
2430  }
2431  sAnalogDevice.nChannels = atoi(oXML.GetChildData().c_str());
2432 
2433  if (!oXML.FindChildElem("Frequency")) {
2434  oXML.OutOfElem(); // Device
2435  continue;
2436  }
2437  sAnalogDevice.nFrequency = atoi(oXML.GetChildData().c_str());
2438 
2439  if (mnMajorVersion == 1 && mnMinorVersion < 11) {
2440  if (!oXML.FindChildElem("Unit")) {
2441  oXML.OutOfElem(); // Device
2442  continue;
2443  }
2444  sAnalogDevice.oUnit = oXML.GetChildData();
2445  }
2446  if (!oXML.FindChildElem("Range")) {
2447  oXML.OutOfElem(); // Device
2448  continue;
2449  }
2450  oXML.IntoElem();
2451 
2452  if (!oXML.FindChildElem("Min")) {
2453  oXML.OutOfElem(); // Device
2454  oXML.OutOfElem(); // Range
2455  continue;
2456  }
2457  sAnalogDevice.fMinRange = (float)atof(oXML.GetChildData().c_str());
2458 
2459  if (!oXML.FindChildElem("Max")) {
2460  oXML.OutOfElem(); // Device
2461  oXML.OutOfElem(); // Range
2462  continue;
2463  }
2464  sAnalogDevice.fMaxRange = (float)atof(oXML.GetChildData().c_str());
2465  oXML.OutOfElem(); // Range
2466 
2467  if (mnMajorVersion == 1 && mnMinorVersion < 11) {
2468  for (unsigned int i = 0; i < sAnalogDevice.nChannels; i++) {
2469  if (oXML.FindChildElem("Label")) {
2470  sAnalogDevice.voLabels.push_back(oXML.GetChildData());
2471  }
2472  }
2473  if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels) {
2474  oXML.OutOfElem(); // Device
2475  continue;
2476  }
2477  } else {
2478  while (oXML.FindChildElem("Channel")) {
2479  oXML.IntoElem();
2480  if (oXML.FindChildElem("Label")) {
2481  sAnalogDevice.voLabels.push_back(oXML.GetChildData());
2482  }
2483  if (oXML.FindChildElem("Unit")) {
2484  sAnalogDevice.voUnits.push_back(oXML.GetChildData());
2485  }
2486  oXML.OutOfElem(); // Channel
2487  }
2488  if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels ||
2489  sAnalogDevice.voUnits.size() != sAnalogDevice.nChannels) {
2490  oXML.OutOfElem(); // Device
2491  continue;
2492  }
2493  }
2494  oXML.OutOfElem(); // Device
2495  mvsAnalogDeviceSettings.push_back(sAnalogDevice);
2496  bDataAvailable = true;
2497  }
2498  }
2499 
2500  return true;
2501 } // ReadAnalogSettings
2502 
2503 bool CRTProtocol::ReadForceSettings(bool& bDataAvailable) {
2504  CRTPacket::EPacketType eType;
2505  CMarkup oXML;
2506 
2507  bDataAvailable = false;
2508 
2509  msForceSettings.vsForcePlates.clear();
2510 
2511  if (!SendCommand("GetParameters Force")) {
2512  strcpy(maErrorStr, "GetParameters Force failed");
2513  return false;
2514  }
2515 
2516  auto received = ReceiveRTPacket(eType, true);
2517  if (received <= 0) {
2518  if (received == 0) {
2519  // Receive timeout.
2520  strcat(maErrorStr, " Expected XML packet.");
2521  }
2522  return false;
2523  }
2524 
2525  if (eType != CRTPacket::PacketXML) {
2526  if (eType == CRTPacket::PacketError) {
2527  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2528  } else {
2529  sprintf(maErrorStr,
2530  "GetParameters Force returned wrong packet type. Got type %d "
2531  "expected type 2.",
2532  eType);
2533  }
2534  return false;
2535  }
2536 
2537  oXML.SetDoc(mpoRTPacket->GetXMLString());
2538  //
2539  // Read some force plate parameters
2540  //
2541  if (!oXML.FindChildElem("Force")) {
2542  return true;
2543  }
2544 
2545  oXML.IntoElem();
2546 
2547  SForcePlate sForcePlate;
2548  sForcePlate.bValidCalibrationMatrix = false;
2549  sForcePlate.nCalibrationMatrixRows = 6;
2550  sForcePlate.nCalibrationMatrixColumns = 6;
2551 
2552  if (!oXML.FindChildElem("Unit_Length")) {
2553  return false;
2554  }
2555  msForceSettings.oUnitLength = oXML.GetChildData();
2556 
2557  if (!oXML.FindChildElem("Unit_Force")) {
2558  return false;
2559  }
2560  msForceSettings.oUnitForce = oXML.GetChildData();
2561 
2562  int iPlate = 1;
2563  while (oXML.FindChildElem("Plate")) {
2564  //
2565  // Get name and type of the plates
2566  //
2567  oXML.IntoElem(); // "Plate"
2568  if (oXML.FindChildElem("Force_Plate_Index")) // Version 1.7 and earlier.
2569  {
2570  sForcePlate.nID = atoi(oXML.GetChildData().c_str());
2571  } else if (oXML.FindChildElem("Plate_ID")) // Version 1.8 and later.
2572  {
2573  sForcePlate.nID = atoi(oXML.GetChildData().c_str());
2574  } else {
2575  return false;
2576  }
2577 
2578  if (oXML.FindChildElem("Analog_Device_ID")) {
2579  sForcePlate.nAnalogDeviceID = atoi(oXML.GetChildData().c_str());
2580  } else {
2581  sForcePlate.nAnalogDeviceID = 0;
2582  }
2583 
2584  if (!oXML.FindChildElem("Frequency")) {
2585  return false;
2586  }
2587  sForcePlate.nFrequency = atoi(oXML.GetChildData().c_str());
2588 
2589  if (oXML.FindChildElem("Type")) {
2590  sForcePlate.oType = oXML.GetChildData();
2591  } else {
2592  sForcePlate.oType = "unknown";
2593  }
2594 
2595  if (oXML.FindChildElem("Name")) {
2596  sForcePlate.oName = oXML.GetChildData();
2597  } else {
2598  sForcePlate.oName = CMarkup::Format("#%d", iPlate);
2599  }
2600 
2601  if (oXML.FindChildElem("Length")) {
2602  sForcePlate.fLength = (float)atof(oXML.GetChildData().c_str());
2603  }
2604  if (oXML.FindChildElem("Width")) {
2605  sForcePlate.fWidth = (float)atof(oXML.GetChildData().c_str());
2606  }
2607 
2608  if (oXML.FindChildElem("Location")) {
2609  oXML.IntoElem();
2610  if (oXML.FindChildElem("Corner1")) {
2611  oXML.IntoElem();
2612  if (oXML.FindChildElem("X")) {
2613  sForcePlate.asCorner[0].fX = (float)atof(oXML.GetChildData().c_str());
2614  }
2615  if (oXML.FindChildElem("Y")) {
2616  sForcePlate.asCorner[0].fY = (float)atof(oXML.GetChildData().c_str());
2617  }
2618  if (oXML.FindChildElem("Z")) {
2619  sForcePlate.asCorner[0].fZ = (float)atof(oXML.GetChildData().c_str());
2620  }
2621  oXML.OutOfElem();
2622  }
2623  if (oXML.FindChildElem("Corner2")) {
2624  oXML.IntoElem();
2625  if (oXML.FindChildElem("X")) {
2626  sForcePlate.asCorner[1].fX = (float)atof(oXML.GetChildData().c_str());
2627  }
2628  if (oXML.FindChildElem("Y")) {
2629  sForcePlate.asCorner[1].fY = (float)atof(oXML.GetChildData().c_str());
2630  }
2631  if (oXML.FindChildElem("Z")) {
2632  sForcePlate.asCorner[1].fZ = (float)atof(oXML.GetChildData().c_str());
2633  }
2634  oXML.OutOfElem();
2635  }
2636  if (oXML.FindChildElem("Corner3")) {
2637  oXML.IntoElem();
2638  if (oXML.FindChildElem("X")) {
2639  sForcePlate.asCorner[2].fX = (float)atof(oXML.GetChildData().c_str());
2640  }
2641  if (oXML.FindChildElem("Y")) {
2642  sForcePlate.asCorner[2].fY = (float)atof(oXML.GetChildData().c_str());
2643  }
2644  if (oXML.FindChildElem("Z")) {
2645  sForcePlate.asCorner[2].fZ = (float)atof(oXML.GetChildData().c_str());
2646  }
2647  oXML.OutOfElem();
2648  }
2649  if (oXML.FindChildElem("Corner4")) {
2650  oXML.IntoElem();
2651  if (oXML.FindChildElem("X")) {
2652  sForcePlate.asCorner[3].fX = (float)atof(oXML.GetChildData().c_str());
2653  }
2654  if (oXML.FindChildElem("Y")) {
2655  sForcePlate.asCorner[3].fY = (float)atof(oXML.GetChildData().c_str());
2656  }
2657  if (oXML.FindChildElem("Z")) {
2658  sForcePlate.asCorner[3].fZ = (float)atof(oXML.GetChildData().c_str());
2659  }
2660  oXML.OutOfElem();
2661  }
2662  oXML.OutOfElem();
2663  }
2664 
2665  if (oXML.FindChildElem("Origin")) {
2666  oXML.IntoElem();
2667  if (oXML.FindChildElem("X")) {
2668  sForcePlate.sOrigin.fX = (float)atof(oXML.GetChildData().c_str());
2669  }
2670  if (oXML.FindChildElem("Y")) {
2671  sForcePlate.sOrigin.fY = (float)atof(oXML.GetChildData().c_str());
2672  }
2673  if (oXML.FindChildElem("Z")) {
2674  sForcePlate.sOrigin.fZ = (float)atof(oXML.GetChildData().c_str());
2675  }
2676  oXML.OutOfElem();
2677  }
2678 
2679  sForcePlate.vChannels.clear();
2680  if (oXML.FindChildElem("Channels")) {
2681  oXML.IntoElem();
2682  SForceChannel sForceChannel;
2683  while (oXML.FindChildElem("Channel")) {
2684  oXML.IntoElem();
2685  if (oXML.FindChildElem("Channel_No")) {
2686  sForceChannel.nChannelNumber = atoi(oXML.GetChildData().c_str());
2687  }
2688  if (oXML.FindChildElem("ConversionFactor")) {
2689  sForceChannel.fConversionFactor =
2690  (float)atof(oXML.GetChildData().c_str());
2691  }
2692  sForcePlate.vChannels.push_back(sForceChannel);
2693  oXML.OutOfElem();
2694  }
2695  oXML.OutOfElem();
2696  }
2697 
2698  if (oXML.FindChildElem("Calibration_Matrix")) {
2699  oXML.IntoElem();
2700  int nRow = 0;
2701 
2702  if (mnMajorVersion == 1 && mnMinorVersion < 12) {
2703  char strRow[16];
2704  char strCol[16];
2705  sprintf(strRow, "Row%d", nRow + 1);
2706  while (oXML.FindChildElem(strRow)) {
2707  oXML.IntoElem();
2708  int nCol = 0;
2709  sprintf(strCol, "Col%d", nCol + 1);
2710  while (oXML.FindChildElem(strCol)) {
2711  sForcePlate.afCalibrationMatrix[nRow][nCol] =
2712  (float)atof(oXML.GetChildData().c_str());
2713  nCol++;
2714  sprintf(strCol, "Col%d", nCol + 1);
2715  }
2716  sForcePlate.nCalibrationMatrixColumns = nCol;
2717 
2718  nRow++;
2719  sprintf(strRow, "Row%d", nRow + 1);
2720  oXML.OutOfElem(); // RowX
2721  }
2722  } else {
2723  //<Rows>
2724  if (oXML.FindChildElem("Rows")) {
2725  oXML.IntoElem();
2726 
2727  while (oXML.FindChildElem("Row")) {
2728  oXML.IntoElem();
2729 
2730  //<Columns>
2731  if (oXML.FindChildElem("Columns")) {
2732  oXML.IntoElem();
2733 
2734  int nCol = 0;
2735  while (oXML.FindChildElem("Column")) {
2736  sForcePlate.afCalibrationMatrix[nRow][nCol] =
2737  (float)atof(oXML.GetChildData().c_str());
2738  nCol++;
2739  }
2740  sForcePlate.nCalibrationMatrixColumns = nCol;
2741 
2742  nRow++;
2743  oXML.OutOfElem(); // Columns
2744  }
2745  oXML.OutOfElem(); // Row
2746  }
2747  oXML.OutOfElem(); // Rows
2748  }
2749  }
2750  sForcePlate.nCalibrationMatrixRows = nRow;
2751  sForcePlate.bValidCalibrationMatrix = true;
2752 
2753  oXML.OutOfElem(); // "Calibration_Matrix"
2754  }
2755  oXML.OutOfElem(); // "Plate"
2756 
2757  bDataAvailable = true;
2758  msForceSettings.vsForcePlates.push_back(sForcePlate);
2759  }
2760 
2761  return true;
2762 } // Read force settings
2763 
2764 bool CRTProtocol::ReadImageSettings(bool& bDataAvailable) {
2765  CRTPacket::EPacketType eType;
2766  CMarkup oXML;
2767 
2768  bDataAvailable = false;
2769 
2770  mvsImageSettings.clear();
2771 
2772  if (!SendCommand("GetParameters Image")) {
2773  strcpy(maErrorStr, "GetParameters Image failed");
2774  return false;
2775  }
2776 
2777  auto received = ReceiveRTPacket(eType, true);
2778  if (received <= 0) {
2779  if (received == 0) {
2780  // Receive timeout.
2781  strcat(maErrorStr, " Expected XML packet.");
2782  }
2783  return false;
2784  }
2785 
2786  if (eType != CRTPacket::PacketXML) {
2787  if (eType == CRTPacket::PacketError) {
2788  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2789  } else {
2790  sprintf(maErrorStr,
2791  "GetParameters Image returned wrong packet type. Got type %d "
2792  "expected type 2.",
2793  eType);
2794  }
2795  return false;
2796  }
2797 
2798  oXML.SetDoc(mpoRTPacket->GetXMLString());
2799  //
2800  // Read some Image parameters
2801  //
2802  if (!oXML.FindChildElem("Image")) {
2803  return true;
2804  }
2805  oXML.IntoElem();
2806 
2807  while (oXML.FindChildElem("Camera")) {
2808  oXML.IntoElem();
2809 
2810  SImageCamera sImageCamera;
2811 
2812  if (!oXML.FindChildElem("ID")) {
2813  return false;
2814  }
2815  sImageCamera.nID = atoi(oXML.GetChildData().c_str());
2816 
2817  if (!oXML.FindChildElem("Enabled")) {
2818  return false;
2819  }
2820  std::string tStr;
2821  tStr = oXML.GetChildData();
2822  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2823 
2824  if (tStr == "true") {
2825  sImageCamera.bEnabled = true;
2826  } else {
2827  sImageCamera.bEnabled = false;
2828  }
2829 
2830  if (!oXML.FindChildElem("Format")) {
2831  return false;
2832  }
2833  tStr = oXML.GetChildData();
2834  std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2835 
2836  if (tStr == "rawgrayscale") {
2837  sImageCamera.eFormat = CRTPacket::FormatRawGrayscale;
2838  } else if (tStr == "rawbgr") {
2839  sImageCamera.eFormat = CRTPacket::FormatRawBGR;
2840  } else if (tStr == "jpg") {
2841  sImageCamera.eFormat = CRTPacket::FormatJPG;
2842  } else if (tStr == "png") {
2843  sImageCamera.eFormat = CRTPacket::FormatPNG;
2844  } else {
2845  return false;
2846  }
2847 
2848  if (!oXML.FindChildElem("Width")) {
2849  return false;
2850  }
2851  sImageCamera.nWidth = atoi(oXML.GetChildData().c_str());
2852 
2853  if (!oXML.FindChildElem("Height")) {
2854  return false;
2855  }
2856  sImageCamera.nHeight = atoi(oXML.GetChildData().c_str());
2857 
2858  if (!oXML.FindChildElem("Left_Crop")) {
2859  return false;
2860  }
2861  sImageCamera.fCropLeft = (float)atof(oXML.GetChildData().c_str());
2862 
2863  if (!oXML.FindChildElem("Top_Crop")) {
2864  return false;
2865  }
2866  sImageCamera.fCropTop = (float)atof(oXML.GetChildData().c_str());
2867 
2868  if (!oXML.FindChildElem("Right_Crop")) {
2869  return false;
2870  }
2871  sImageCamera.fCropRight = (float)atof(oXML.GetChildData().c_str());
2872 
2873  if (!oXML.FindChildElem("Bottom_Crop")) {
2874  return false;
2875  }
2876  sImageCamera.fCropBottom = (float)atof(oXML.GetChildData().c_str());
2877 
2878  oXML.OutOfElem(); // "Camera"
2879 
2880  mvsImageSettings.push_back(sImageCamera);
2881  bDataAvailable = true;
2882  }
2883 
2884  return true;
2885 } // ReadImageSettings
2886 
2887 bool CRTProtocol::ReadSkeletonSettings(bool& bDataAvailable,
2888  bool skeletonGlobalData) {
2889  CRTPacket::EPacketType eType;
2890  CMarkup oXML;
2891 
2892  bDataAvailable = false;
2893 
2894  mSkeletonSettings.clear();
2895 
2896  std::string cmd("GetParameters Skeleton");
2897  if (skeletonGlobalData) {
2898  cmd += ":global";
2899  }
2900  if (!SendCommand(cmd.c_str())) {
2901  strcpy(maErrorStr, "GetParameters Skeleton failed");
2902  return false;
2903  }
2904 
2905  auto received = ReceiveRTPacket(eType, true);
2906  if (received <= 0) {
2907  if (received == 0) {
2908  // Receive timeout.
2909  strcat(maErrorStr, " Expected XML packet.");
2910  }
2911  return false;
2912  }
2913 
2914  if (eType != CRTPacket::PacketXML) {
2915  if (eType == CRTPacket::PacketError) {
2916  sprintf(maErrorStr, "%s.", mpoRTPacket->GetErrorString());
2917  } else {
2918  sprintf(maErrorStr,
2919  "GetParameters Skeleton returned wrong packet type. Got type %d "
2920  "expected type 2.",
2921  eType);
2922  }
2923  return false;
2924  }
2925 
2926  oXML.SetDoc(mpoRTPacket->GetXMLString());
2927 
2928  if (!oXML.FindChildElem("Skeletons")) {
2929  return true;
2930  }
2931  oXML.IntoElem();
2932 
2933  std::string skeletonName;
2934  int segmentIndex;
2935  std::map<int, int> segmentIdIndexMap;
2936 
2937  while (oXML.FindChildElem("Skeleton")) {
2938  SSettingsSkeleton skeleton;
2939  segmentIndex = 0;
2940 
2941  oXML.IntoElem();
2942 
2943  skeleton.name = oXML.GetAttrib("Name");
2944  while (oXML.FindChildElem("Segment")) {
2945  oXML.IntoElem();
2946 
2947  SSettingsSkeletonSegment segment;
2948 
2949  segment.name = oXML.GetAttrib("Name");
2950  if (segment.name.size() == 0 ||
2951  sscanf(oXML.GetAttrib("ID").c_str(), "%u", &segment.id) != 1) {
2952  return false;
2953  }
2954 
2955  segmentIdIndexMap[segment.id] = segmentIndex++;
2956 
2957  int parentId;
2958  if (sscanf(oXML.GetAttrib("Parent_ID").c_str(), "%d", &parentId) != 1) {
2959  segment.parentId = -1;
2960  segment.parentIndex = -1;
2961  } else if (segmentIdIndexMap.count(parentId) > 0) {
2962  segment.parentId = parentId;
2963  segment.parentIndex = segmentIdIndexMap[parentId];
2964  }
2965 
2966  if (oXML.FindChildElem("Position")) {
2967  oXML.IntoElem();
2968  float x, y, z;
2969  if (sscanf(oXML.GetAttrib("X").c_str(), "%f", &x) == 1) {
2970  segment.positionX = x;
2971  }
2972  if (sscanf(oXML.GetAttrib("Y").c_str(), "%f", &y) == 1) {
2973  segment.positionY = y;
2974  }
2975  if (sscanf(oXML.GetAttrib("Z").c_str(), "%f", &z) == 1) {
2976  segment.positionZ = z;
2977  }
2978  oXML.OutOfElem();
2979  }
2980 
2981  if (oXML.FindChildElem("Rotation")) {
2982  oXML.IntoElem();
2983  float x, y, z, w;
2984  if (sscanf(oXML.GetAttrib("X").c_str(), "%f", &x) == 1) {
2985  segment.rotationX = x;
2986  }
2987  if (sscanf(oXML.GetAttrib("Y").c_str(), "%f", &y) == 1) {
2988  segment.rotationY = y;
2989  }
2990  if (sscanf(oXML.GetAttrib("Z").c_str(), "%f", &z) == 1) {
2991  segment.rotationZ = z;
2992  }
2993  if (sscanf(oXML.GetAttrib("W").c_str(), "%f", &w) == 1) {
2994  segment.rotationW = w;
2995  }
2996  oXML.OutOfElem();
2997  }
2998 
2999  skeleton.segments.push_back(segment);
3000 
3001  oXML.OutOfElem(); // Segment
3002  }
3003 
3004  mSkeletonSettings.push_back(skeleton);
3005 
3006  oXML.OutOfElem(); // Skeleton
3007  }
3008 
3009  oXML.OutOfElem(); // Skeletons
3010 
3011  bDataAvailable = true;
3012  return true;
3013 } // ReadSkeletonSettings
3014 
3016  unsigned int& nCaptureFrequency, float& fCaptureTime, bool& bStartOnExtTrig,
3017  bool& startOnTrigNO, bool& startOnTrigNC, bool& startOnTrigSoftware,
3018  EProcessingActions& eProcessingActions,
3019  EProcessingActions& eRtProcessingActions,
3020  EProcessingActions& eReprocessingActions) const {
3021  nCaptureFrequency = msGeneralSettings.nCaptureFrequency;
3022  fCaptureTime = msGeneralSettings.fCaptureTime;
3023  bStartOnExtTrig = msGeneralSettings.bStartOnExternalTrigger;
3024  startOnTrigNO = msGeneralSettings.bStartOnTrigNO;
3025  startOnTrigNC = msGeneralSettings.bStartOnTrigNC;
3026  startOnTrigSoftware = msGeneralSettings.bStartOnTrigSoftware;
3027  eProcessingActions = msGeneralSettings.eProcessingActions;
3028  eRtProcessingActions = msGeneralSettings.eRtProcessingActions;
3029  eReprocessingActions = msGeneralSettings.eReprocessingActions;
3030 }
3031 
3032 // External time base settings only available in version 1.10 of the rt protocol
3033 // and later
3035  bool& bEnabled, ESignalSource& eSignalSource, bool& bSignalModePeriodic,
3036  unsigned int& nFreqMultiplier, unsigned int& nFreqDivisor,
3037  unsigned int& nFreqTolerance, float& fNominalFrequency, bool& bNegativeEdge,
3038  unsigned int& nSignalShutterDelay, float& fNonPeriodicTimeout) const {
3039  bEnabled = msGeneralSettings.sExternalTimebase.bEnabled;
3040  eSignalSource = msGeneralSettings.sExternalTimebase.eSignalSource;
3041  bSignalModePeriodic = msGeneralSettings.sExternalTimebase.bSignalModePeriodic;
3042  nFreqMultiplier = msGeneralSettings.sExternalTimebase.nFreqMultiplier;
3043  nFreqDivisor = msGeneralSettings.sExternalTimebase.nFreqDivisor;
3044  nFreqTolerance = msGeneralSettings.sExternalTimebase.nFreqTolerance;
3045  fNominalFrequency = msGeneralSettings.sExternalTimebase.fNominalFrequency;
3046  bNegativeEdge = msGeneralSettings.sExternalTimebase.bNegativeEdge;
3047  nSignalShutterDelay = msGeneralSettings.sExternalTimebase.nSignalShutterDelay;
3048  fNonPeriodicTimeout = msGeneralSettings.sExternalTimebase.fNonPeriodicTimeout;
3049 }
3050 
3051 unsigned int CRTProtocol::GetCameraCount() const {
3052  return (unsigned int)msGeneralSettings.vsCameras.size();
3053 }
3054 
3055 bool CRTProtocol::GetCameraSettings(unsigned int nCameraIndex,
3056  unsigned int& nID, ECameraModel& eModel,
3057  bool& bUnderwater, bool& bSupportsHwSync,
3058  unsigned int& nSerial,
3059  ECameraMode& eMode) const {
3060  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3061  nID = msGeneralSettings.vsCameras[nCameraIndex].nID;
3062  eModel = msGeneralSettings.vsCameras[nCameraIndex].eModel;
3063  bUnderwater = msGeneralSettings.vsCameras[nCameraIndex].bUnderwater;
3064  bSupportsHwSync = msGeneralSettings.vsCameras[nCameraIndex].bSupportsHwSync;
3065  nSerial = msGeneralSettings.vsCameras[nCameraIndex].nSerial;
3066  eMode = msGeneralSettings.vsCameras[nCameraIndex].eMode;
3067  return true;
3068  }
3069  return false;
3070 }
3071 
3072 bool CRTProtocol::GetCameraMarkerSettings(unsigned int nCameraIndex,
3073  unsigned int& nCurrentExposure,
3074  unsigned int& nMinExposure,
3075  unsigned int& nMaxExposure,
3076  unsigned int& nCurrentThreshold,
3077  unsigned int& nMinThreshold,
3078  unsigned int& nMaxThreshold) const {
3079  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3080  nCurrentExposure =
3081  msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposure;
3082  nMinExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMin;
3083  nMaxExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMax;
3084  nCurrentThreshold =
3085  msGeneralSettings.vsCameras[nCameraIndex].nMarkerThreshold;
3086  nMinThreshold =
3087  msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMin;
3088  nMaxThreshold =
3089  msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMax;
3090  return true;
3091  }
3092  return false;
3093 }
3094 
3096  unsigned int nCameraIndex, EVideoResolution& eVideoResolution,
3097  EVideoAspectRatio& eVideoAspectRatio, unsigned int& nVideoFrequency,
3098  unsigned int& nCurrentExposure, unsigned int& nMinExposure,
3099  unsigned int& nMaxExposure, unsigned int& nCurrentFlashTime,
3100  unsigned int& nMinFlashTime, unsigned int& nMaxFlashTime) const {
3101  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3102  eVideoResolution =
3103  msGeneralSettings.vsCameras[nCameraIndex].eVideoResolution;
3104  eVideoAspectRatio =
3105  msGeneralSettings.vsCameras[nCameraIndex].eVideoAspectRatio;
3106  nVideoFrequency = msGeneralSettings.vsCameras[nCameraIndex].nVideoFrequency;
3107  nCurrentExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposure;
3108  nMinExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposureMin;
3109  nMaxExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposureMax;
3110  nCurrentFlashTime =
3111  msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTime;
3112  nMinFlashTime =
3113  msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMin;
3114  nMaxFlashTime =
3115  msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMax;
3116  return true;
3117  }
3118  return false;
3119 }
3120 
3122  unsigned int nCameraIndex, unsigned int portNumber,
3123  ESyncOutFreqMode& eSyncOutMode, unsigned int& nSyncOutValue,
3124  float& fSyncOutDutyCycle, bool& bSyncOutNegativePolarity) const {
3125  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3126  if (portNumber == 1 || portNumber == 2) {
3127  eSyncOutMode = msGeneralSettings.vsCameras[nCameraIndex]
3128  .eSyncOutMode[portNumber - 1];
3129  nSyncOutValue = msGeneralSettings.vsCameras[nCameraIndex]
3130  .nSyncOutValue[portNumber - 1];
3131  fSyncOutDutyCycle = msGeneralSettings.vsCameras[nCameraIndex]
3132  .fSyncOutDutyCycle[portNumber - 1];
3133  }
3134  if (portNumber > 0 && portNumber < 4) {
3135  bSyncOutNegativePolarity = msGeneralSettings.vsCameras[nCameraIndex]
3136  .bSyncOutNegativePolarity[portNumber - 1];
3137  } else {
3138  return false;
3139  }
3140  return true;
3141  }
3142  return false;
3143 }
3144 
3145 bool CRTProtocol::GetCameraPosition(unsigned int nCameraIndex, SPoint& sPoint,
3146  float fvRotationMatrix[3][3]) const {
3147  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3148  sPoint.fX = msGeneralSettings.vsCameras[nCameraIndex].fPositionX;
3149  sPoint.fY = msGeneralSettings.vsCameras[nCameraIndex].fPositionY;
3150  sPoint.fZ = msGeneralSettings.vsCameras[nCameraIndex].fPositionZ;
3151  memcpy(fvRotationMatrix,
3152  msGeneralSettings.vsCameras[nCameraIndex].fPositionRotMatrix,
3153  9 * sizeof(float));
3154  return true;
3155  }
3156  return false;
3157 }
3158 
3159 bool CRTProtocol::GetCameraOrientation(unsigned int nCameraIndex,
3160  int& nOrientation) const {
3161  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3162  nOrientation = msGeneralSettings.vsCameras[nCameraIndex].nOrientation;
3163  return true;
3164  }
3165  return false;
3166 }
3167 
3168 bool CRTProtocol::GetCameraResolution(unsigned int nCameraIndex,
3169  unsigned int& nMarkerWidth,
3170  unsigned int& nMarkerHeight,
3171  unsigned int& nVideoWidth,
3172  unsigned int& nVideoHeight) const {
3173  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3174  nMarkerWidth =
3175  msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionWidth;
3176  nMarkerHeight =
3177  msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionHeight;
3178  nVideoWidth =
3179  msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionWidth;
3180  nVideoHeight =
3181  msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionHeight;
3182  return true;
3183  }
3184  return false;
3185 }
3186 
3188  unsigned int nCameraIndex, unsigned int& nMarkerLeft,
3189  unsigned int& nMarkerTop, unsigned int& nMarkerRight,
3190  unsigned int& nMarkerBottom, unsigned int& nVideoLeft,
3191  unsigned int& nVideoTop, unsigned int& nVideoRight,
3192  unsigned int& nVideoBottom) const {
3193  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3194  nMarkerLeft = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVLeft;
3195  nMarkerTop = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVTop;
3196  nMarkerRight = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVRight;
3197  nMarkerBottom = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVBottom;
3198  nVideoLeft = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVLeft;
3199  nVideoTop = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVTop;
3200  nVideoRight = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVRight;
3201  nVideoBottom = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVBottom;
3202  return true;
3203  }
3204  return false;
3205 }
3206 
3207 bool CRTProtocol::GetCameraLensControlSettings(const unsigned int nCameraIndex,
3208  float* focus,
3209  float* aperture) const {
3210  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3211  *focus = msGeneralSettings.vsCameras[nCameraIndex].fFocus;
3212  if (std::isnan(*focus)) return false;
3213  *aperture = msGeneralSettings.vsCameras[nCameraIndex].fAperture;
3214  return true;
3215  }
3216  return false;
3217 }
3218 
3220  const unsigned int nCameraIndex, bool* autoExposureEnabled,
3221  float* autoExposureCompensation) const {
3222  if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3223  *autoExposureCompensation =
3224  msGeneralSettings.vsCameras[nCameraIndex].autoExposureCompensation;
3225  if (std::isnan(*autoExposureCompensation)) return false;
3226  *autoExposureEnabled =
3227  msGeneralSettings.vsCameras[nCameraIndex].autoExposureEnabled;
3228  return true;
3229  }
3230  return false;
3231 }
3232 
3234  const unsigned int nCameraIndex, bool* autoWhiteBalanceEnabled) const {
3235  if (nCameraIndex < msGeneralSettings.vsCameras.size() &&
3236  msGeneralSettings.vsCameras[nCameraIndex].autoWhiteBalance >= 0) {
3237  *autoWhiteBalanceEnabled =
3238  msGeneralSettings.vsCameras[nCameraIndex].autoWhiteBalance == 1;
3239  return true;
3240  }
3241  return false;
3242 }
3243 
3245  return ms3DSettings.eAxisUpwards;
3246 }
3247 
3248 const char* CRTProtocol::Get3DCalibrated() const {
3249  return ms3DSettings.pCalibrationTime;
3250 }
3251 
3253  return (unsigned int)ms3DSettings.s3DLabels.size();
3254 }
3255 
3256 const char* CRTProtocol::Get3DLabelName(unsigned int nMarkerIndex) const {
3257  if (nMarkerIndex < ms3DSettings.s3DLabels.size()) {
3258  return ms3DSettings.s3DLabels[nMarkerIndex].oName.c_str();
3259  }
3260  return nullptr;
3261 }
3262 
3263 unsigned int CRTProtocol::Get3DLabelColor(unsigned int nMarkerIndex) const {
3264  if (nMarkerIndex < ms3DSettings.s3DLabels.size()) {
3265  return ms3DSettings.s3DLabels[nMarkerIndex].nRGBColor;
3266  }
3267  return 0;
3268 }
3269 
3270 unsigned int CRTProtocol::Get3DBoneCount() const {
3271  return (unsigned int)ms3DSettings.sBones.size();
3272 }
3273 
3274 const char* CRTProtocol::Get3DBoneFromName(unsigned int boneIndex) const {
3275  if (boneIndex < ms3DSettings.sBones.size()) {
3276  return ms3DSettings.sBones[boneIndex].fromName.c_str();
3277  }
3278  return nullptr;
3279 }
3280 
3281 const char* CRTProtocol::Get3DBoneToName(unsigned int boneIndex) const {
3282  if (boneIndex < ms3DSettings.sBones.size()) {
3283  return ms3DSettings.sBones[boneIndex].toName.c_str();
3284  }
3285  return nullptr;
3286 }
3287 
3288 void CRTProtocol::Get6DOFEulerNames(std::string& first, std::string& second,
3289  std::string& third) const {
3290  first = mvs6DOFSettings.eulerFirst;
3291  second = mvs6DOFSettings.eulerSecond;
3292  third = mvs6DOFSettings.eulerThird;
3293 }
3294 
3295 unsigned int CRTProtocol::Get6DOFBodyCount() const {
3296  return (unsigned int)mvs6DOFSettings.bodySettings.size();
3297 }
3298 
3299 const char* CRTProtocol::Get6DOFBodyName(unsigned int nBodyIndex) const {
3300  if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3301  return mvs6DOFSettings.bodySettings[nBodyIndex].oName.c_str();
3302  }
3303  return nullptr;
3304 }
3305 
3306 unsigned int CRTProtocol::Get6DOFBodyColor(unsigned int nBodyIndex) const {
3307  if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3308  return mvs6DOFSettings.bodySettings[nBodyIndex].nRGBColor;
3309  }
3310  return 0;
3311 }
3312 
3313 unsigned int CRTProtocol::Get6DOFBodyPointCount(unsigned int nBodyIndex) const {
3314  if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3315  return (unsigned int)mvs6DOFSettings.bodySettings.at(nBodyIndex)
3316  .vsPoints.size();
3317  }
3318  return false;
3319 }
3320 
3321 bool CRTProtocol::Get6DOFBodyPoint(unsigned int nBodyIndex,
3322  unsigned int nMarkerIndex,
3323  SPoint& sPoint) const {
3324  if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3325  if (nMarkerIndex <
3326  mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints.size()) {
3327  sPoint.fX =
3328  mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fX;
3329  sPoint.fY =
3330  mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fY;
3331  sPoint.fZ =
3332  mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fZ;
3333  return true;
3334  }
3335  }
3336  return false;
3337 }
3338 
3339 unsigned int CRTProtocol::GetGazeVectorCount() const {
3340  return (unsigned int)mvsGazeVectorSettings.size();
3341 }
3342 
3344  unsigned int nGazeVectorIndex) const {
3345  if (nGazeVectorIndex < mvsGazeVectorSettings.size()) {
3346  return mvsGazeVectorSettings[nGazeVectorIndex].name.c_str();
3347  }
3348  return nullptr;
3349 }
3350 
3351 float CRTProtocol::GetGazeVectorFrequency(unsigned int nGazeVectorIndex) const {
3352  if (nGazeVectorIndex < mvsGazeVectorSettings.size()) {
3353  return mvsGazeVectorSettings[nGazeVectorIndex].frequency;
3354  }
3355  return 0;
3356 }
3357 
3359  return (unsigned int)mvsAnalogDeviceSettings.size();
3360 }
3361 
3362 bool CRTProtocol::GetAnalogDevice(unsigned int nDeviceIndex,
3363  unsigned int& nDeviceID,
3364  unsigned int& nChannels, char*& pName,
3365  unsigned int& nFrequency, char*& pUnit,
3366  float& fMinRange, float& fMaxRange) const {
3367  if (nDeviceIndex < mvsAnalogDeviceSettings.size()) {
3368  nDeviceID = mvsAnalogDeviceSettings.at(nDeviceIndex).nDeviceID;
3369  pName = (char*)mvsAnalogDeviceSettings.at(nDeviceIndex).oName.c_str();
3370  nChannels = mvsAnalogDeviceSettings.at(nDeviceIndex).nChannels;
3371  nFrequency = mvsAnalogDeviceSettings.at(nDeviceIndex).nFrequency;
3372  pUnit = (char*)mvsAnalogDeviceSettings.at(nDeviceIndex).oUnit.c_str();
3373  fMinRange = mvsAnalogDeviceSettings.at(nDeviceIndex).fMinRange;
3374  fMaxRange = mvsAnalogDeviceSettings.at(nDeviceIndex).fMaxRange;
3375 
3376  return true;
3377  }
3378  return false;
3379 }
3380 
3381 const char* CRTProtocol::GetAnalogLabel(unsigned int nDeviceIndex,
3382  unsigned int nChannelIndex) const {
3383  if (nDeviceIndex < mvsAnalogDeviceSettings.size()) {
3384  if (nChannelIndex <
3385  mvsAnalogDeviceSettings.at(nDeviceIndex).voLabels.size()) {
3386  return mvsAnalogDeviceSettings.at(nDeviceIndex)
3387  .voLabels.at(nChannelIndex)
3388  .c_str();
3389  }
3390  }
3391  return nullptr;
3392 }
3393 
3394 const char* CRTProtocol::GetAnalogUnit(unsigned int nDeviceIndex,
3395  unsigned int nChannelIndex) const {
3396  if (nDeviceIndex < mvsAnalogDeviceSettings.size()) {
3397  if (nChannelIndex <
3398  mvsAnalogDeviceSettings.at(nDeviceIndex).voUnits.size()) {
3399  return mvsAnalogDeviceSettings.at(nDeviceIndex)
3400  .voUnits.at(nChannelIndex)
3401  .c_str();
3402  }
3403  }
3404  return nullptr;
3405 }
3406 
3407 void CRTProtocol::GetForceUnits(char*& pLength, char*& pForce) const {
3408  pLength = (char*)msForceSettings.oUnitLength.c_str();
3409  pForce = (char*)msForceSettings.oUnitForce.c_str();
3410 }
3411 
3412 unsigned int CRTProtocol::GetForcePlateCount() const {
3413  return (unsigned int)msForceSettings.vsForcePlates.size();
3414 }
3415 
3416 bool CRTProtocol::GetForcePlate(unsigned int nPlateIndex, unsigned int& nID,
3417  unsigned int& nAnalogDeviceID,
3418  unsigned int& nFrequency, char*& pType,
3419  char*& pName, float& fLength,
3420  float& fWidth) const {
3421  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3422  nID = msForceSettings.vsForcePlates[nPlateIndex].nID;
3423  nAnalogDeviceID =
3424  msForceSettings.vsForcePlates[nPlateIndex].nAnalogDeviceID;
3425  nFrequency = msForceSettings.vsForcePlates[nPlateIndex].nFrequency;
3426  pType = (char*)msForceSettings.vsForcePlates[nPlateIndex].oType.c_str();
3427  pName = (char*)msForceSettings.vsForcePlates[nPlateIndex].oName.c_str();
3428  fLength = msForceSettings.vsForcePlates[nPlateIndex].fLength;
3429  fWidth = msForceSettings.vsForcePlates[nPlateIndex].fWidth;
3430  return true;
3431  }
3432  return false;
3433 }
3434 
3435 bool CRTProtocol::GetForcePlateLocation(unsigned int nPlateIndex,
3436  SPoint sCorner[4]) const {
3437  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3438  memcpy(sCorner, msForceSettings.vsForcePlates[nPlateIndex].asCorner,
3439  3 * 4 * sizeof(float));
3440  return true;
3441  }
3442  return false;
3443 }
3444 
3445 bool CRTProtocol::GetForcePlateOrigin(unsigned int nPlateIndex,
3446  SPoint& sOrigin) const {
3447  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3448  sOrigin = msForceSettings.vsForcePlates[nPlateIndex].sOrigin;
3449  return true;
3450  }
3451  return false;
3452 }
3453 
3455  unsigned int nPlateIndex) const {
3456  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3457  return (unsigned int)msForceSettings.vsForcePlates[nPlateIndex]
3458  .vChannels.size();
3459  }
3460  return 0;
3461 }
3462 
3463 bool CRTProtocol::GetForcePlateChannel(unsigned int nPlateIndex,
3464  unsigned int nChannelIndex,
3465  unsigned int& nChannelNumber,
3466  float& fConversionFactor) const {
3467  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3468  if (nChannelIndex <
3469  msForceSettings.vsForcePlates[nPlateIndex].vChannels.size()) {
3470  nChannelNumber = msForceSettings.vsForcePlates[nPlateIndex]
3471  .vChannels[nChannelIndex]
3472  .nChannelNumber;
3473  fConversionFactor = msForceSettings.vsForcePlates[nPlateIndex]
3474  .vChannels[nChannelIndex]
3475  .fConversionFactor;
3476  return true;
3477  }
3478  }
3479  return false;
3480 }
3481 
3482 bool CRTProtocol::GetForcePlateCalibrationMatrix(unsigned int nPlateIndex,
3483  float fvCalMatrix[12][12],
3484  unsigned int* rows,
3485  unsigned int* columns) const {
3486  if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3487  if (msForceSettings.vsForcePlates[nPlateIndex].bValidCalibrationMatrix) {
3488  *rows = msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows;
3489  *columns =
3490  msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixColumns;
3491  memcpy(fvCalMatrix,
3492  msForceSettings.vsForcePlates[nPlateIndex].afCalibrationMatrix,
3493  msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows *
3494  msForceSettings.vsForcePlates[nPlateIndex]
3495  .nCalibrationMatrixColumns *
3496  sizeof(float));
3497  return true;
3498  }
3499  }
3500  return false;
3501 }
3502 
3503 unsigned int CRTProtocol::GetImageCameraCount() const {
3504  return (unsigned int)mvsImageSettings.size();
3505 }
3506 
3507 bool CRTProtocol::GetImageCamera(unsigned int nCameraIndex,
3508  unsigned int& nCameraID, bool& bEnabled,
3509  CRTPacket::EImageFormat& eFormat,
3510  unsigned int& nWidth, unsigned int& nHeight,
3511  float& fCropLeft, float& fCropTop,
3512  float& fCropRight, float& fCropBottom) const {
3513  if (nCameraIndex < mvsImageSettings.size()) {
3514  nCameraID = mvsImageSettings[nCameraIndex].nID;
3515  bEnabled = mvsImageSettings[nCameraIndex].bEnabled;
3516  eFormat = mvsImageSettings[nCameraIndex].eFormat;
3517  nWidth = mvsImageSettings[nCameraIndex].nWidth;
3518  nHeight = mvsImageSettings[nCameraIndex].nHeight;
3519  fCropLeft = mvsImageSettings[nCameraIndex].fCropLeft;
3520  fCropTop = mvsImageSettings[nCameraIndex].fCropTop;
3521  fCropRight = mvsImageSettings[nCameraIndex].fCropRight;
3522  fCropBottom = mvsImageSettings[nCameraIndex].fCropBottom;
3523  return true;
3524  }
3525  return false;
3526 }
3527 
3528 unsigned int CRTProtocol::GetSkeletonCount() const {
3529  return (unsigned int)mSkeletonSettings.size();
3530 }
3531 
3532 const char* CRTProtocol::GetSkeletonName(unsigned int skeletonIndex) {
3533  if (skeletonIndex < mSkeletonSettings.size()) {
3534  return (char*)mSkeletonSettings[skeletonIndex].name.c_str();
3535  }
3536  return nullptr;
3537 }
3538 
3539 unsigned int CRTProtocol::GetSkeletonSegmentCount(unsigned int skeletonIndex) {
3540  if (skeletonIndex < mSkeletonSettings.size()) {
3541  return static_cast<long unsigned>(
3542  mSkeletonSettings[skeletonIndex].segments.size());
3543  }
3544  return 0;
3545 }
3546 
3547 bool CRTProtocol::GetSkeleton(unsigned int skeletonIndex,
3548  SSettingsSkeleton* skeleton) {
3549  if (skeleton == nullptr) return false;
3550 
3551  if (skeletonIndex < mSkeletonSettings.size()) {
3552  *skeleton = mSkeletonSettings[skeletonIndex];
3553  return true;
3554  }
3555  return false;
3556 }
3557 
3558 bool CRTProtocol::GetSkeletonSegment(unsigned int skeletonIndex,
3559  unsigned int segmentIndex,
3560  SSettingsSkeletonSegment* segment) {
3561  if (segment == nullptr) return false;
3562 
3563  if (skeletonIndex < mSkeletonSettings.size()) {
3564  if (segmentIndex < mSkeletonSettings[skeletonIndex].segments.size()) {
3565  *segment = mSkeletonSettings[skeletonIndex].segments[segmentIndex];
3566  return true;
3567  }
3568  }
3569  return false;
3570 }
3571 
3573  return msGeneralSettings.sCameraSystem.eType;
3574 }
3575 
3577  const unsigned int* pnCaptureFrequency, const float* pfCaptureTime,
3578  const bool* pbStartOnExtTrig, const bool* startOnTrigNO,
3579  const bool* startOnTrigNC, const bool* startOnTrigSoftware,
3580  const EProcessingActions* peProcessingActions,
3581  const EProcessingActions* peRtProcessingActions,
3582  const EProcessingActions* peReprocessingActions) {
3583  CMarkup oXML;
3584 
3585  oXML.AddElem("QTM_Settings");
3586  oXML.IntoElem();
3587  oXML.AddElem("General");
3588  oXML.IntoElem();
3589 
3590  if (pnCaptureFrequency) {
3591  AddXMLElementUnsignedInt(&oXML, "Frequency", pnCaptureFrequency);
3592  }
3593  if (pfCaptureTime) {
3594  AddXMLElementFloat(&oXML, "Capture_Time", pfCaptureTime, 3);
3595  }
3596  if (pbStartOnExtTrig) {
3597  AddXMLElementBool(&oXML, "Start_On_External_Trigger", pbStartOnExtTrig);
3598  if (mnMajorVersion > 1 || mnMinorVersion > 14) {
3599  AddXMLElementBool(&oXML, "Start_On_Trigger_NO", startOnTrigNO);
3600  AddXMLElementBool(&oXML, "Start_On_Trigger_NC", startOnTrigNC);
3601  AddXMLElementBool(&oXML, "Start_On_Trigger_Software",
3602  startOnTrigSoftware);
3603  }
3604  }
3605 
3606  const char* processings[3] = {"Processing_Actions",
3607  "RealTime_Processing_Actions",
3608  "Reprocessing_Actions"};
3609  const EProcessingActions* processingActions[3] = {
3610  peProcessingActions, peRtProcessingActions, peReprocessingActions};
3611 
3612  auto actionsCount = (mnMajorVersion > 1 || mnMinorVersion > 13) ? 3 : 1;
3613 
3614  for (auto i = 0; i < actionsCount; i++) {
3615  if (processingActions[i]) {
3616  oXML.AddElem(processings[i]);
3617  oXML.IntoElem();
3618 
3619  if (mnMajorVersion > 1 || mnMinorVersion > 13) {
3620  AddXMLElementBool(
3621  &oXML, "PreProcessing2D",
3622  (*processingActions[i] & ProcessingPreProcess2D) != 0);
3623  }
3624  if (*processingActions[i] & ProcessingTracking2D &&
3625  i != 1) // i != 1 => Not RtProcessingSettings
3626  {
3627  oXML.AddElem("Tracking", "2D");
3628  } else if (*processingActions[i] & ProcessingTracking3D) {
3629  oXML.AddElem("Tracking", "3D");
3630  } else {
3631  oXML.AddElem("Tracking", "False");
3632  }
3633  if (i != 1) // Not RtProcessingSettings
3634  {
3635  AddXMLElementBool(
3636  &oXML, "TwinSystemMerge",
3637  (*processingActions[i] & ProcessingTwinSystemMerge) != 0);
3638  AddXMLElementBool(&oXML, "SplineFill",
3639  (*processingActions[i] & ProcessingSplineFill) != 0);
3640  }
3641  AddXMLElementBool(&oXML, "AIM",
3642  (*processingActions[i] & ProcessingAIM) != 0);
3643  AddXMLElementBool(&oXML, "Track6DOF",
3644  (*processingActions[i] & Processing6DOFTracking) != 0);
3645  AddXMLElementBool(&oXML, "ForceData",
3646  (*processingActions[i] & ProcessingForceData) != 0);
3647  AddXMLElementBool(&oXML, "GazeVector",
3648  (*processingActions[i] & ProcessingGazeVector) != 0);
3649  if (i != 1) // Not RtProcessingSettings
3650  {
3651  AddXMLElementBool(&oXML, "ExportTSV",
3652  (*processingActions[i] & ProcessingExportTSV) != 0);
3653  AddXMLElementBool(&oXML, "ExportC3D",
3654  (*processingActions[i] & ProcessingExportC3D) != 0);
3655  AddXMLElementBool(
3656  &oXML, "ExportMatlabFile",
3657  (*processingActions[i] & ProcessingExportMatlabFile) != 0);
3658  AddXMLElementBool(
3659  &oXML, "ExportAviFile",
3660  (*processingActions[i] & ProcessingExportAviFile) != 0);
3661  }
3662  oXML.OutOfElem(); // Processing_Actions
3663  }
3664  }
3665  oXML.OutOfElem(); // General
3666  oXML.OutOfElem(); // QTM_Settings
3667 
3668  if (SendXML(oXML.GetDoc().c_str())) {
3669  return true;
3670  }
3671 
3672  return false;
3673 } // SetGeneral
3674 
3676  const bool* pbEnabled, const ESignalSource* peSignalSource,
3677  const bool* pbSignalModePeriodic, const unsigned int* pnFreqMultiplier,
3678  const unsigned int* pnFreqDivisor, const unsigned int* pnFreqTolerance,
3679  const float* pfNominalFrequency, const bool* pbNegativeEdge,
3680  const unsigned int* pnSignalShutterDelay,
3681  const float* pfNonPeriodicTimeout) {
3682  CMarkup oXML;
3683 
3684  oXML.AddElem("QTM_Settings");
3685  oXML.IntoElem();
3686  oXML.AddElem("General");
3687  oXML.IntoElem();
3688  oXML.AddElem("External_Time_Base");
3689  oXML.IntoElem();
3690 
3691  AddXMLElementBool(&oXML, "Enabled", pbEnabled);
3692 
3693  if (peSignalSource) {
3694  switch (*peSignalSource) {
3695  case SourceControlPort:
3696  oXML.AddElem("Signal_Source", "Control port");
3697  break;
3698  case SourceIRReceiver:
3699  oXML.AddElem("Signal_Source", "IR receiver");
3700  break;
3701  case SourceSMPTE:
3702  oXML.AddElem("Signal_Source", "SMPTE");
3703  break;
3704  case SourceVideoSync:
3705  oXML.AddElem("Signal_Source", "Video sync");
3706  break;
3707  case SourceIRIG:
3708  oXML.AddElem("Signal_Source", "IRIG");
3709  break;
3710  }
3711  }
3712 
3713  AddXMLElementBool(&oXML, "Signal_Mode", pbSignalModePeriodic, "Periodic",
3714  "Non-periodic");
3715  AddXMLElementUnsignedInt(&oXML, "Frequency_Multiplier", pnFreqMultiplier);
3716  AddXMLElementUnsignedInt(&oXML, "Frequency_Divisor", pnFreqDivisor);
3717  AddXMLElementUnsignedInt(&oXML, "Frequency_Tolerance", pnFreqTolerance);
3718 
3719  if (pfNominalFrequency) {
3720  if (*pfNominalFrequency < 0) {
3721  oXML.AddElem("Nominal_Frequency", "None");
3722  } else {
3723  AddXMLElementFloat(&oXML, "Nominal_Frequency", pfNominalFrequency, 3);
3724  }
3725  }
3726 
3727  AddXMLElementBool(&oXML, "Signal_Edge", pbNegativeEdge, "Negative",
3728  "Positive");
3729  AddXMLElementUnsignedInt(&oXML, "Signal_Shutter_Delay", pnSignalShutterDelay);
3730  AddXMLElementFloat(&oXML, "Non_Periodic_Timeout", pfNonPeriodicTimeout, 3);
3731 
3732  oXML.OutOfElem(); // External_Time_Base
3733  oXML.OutOfElem(); // General
3734  oXML.OutOfElem(); // QTM_Settings
3735 
3736  if (SendXML(oXML.GetDoc().c_str())) {
3737  return true;
3738  }
3739 
3740  return false;
3741 } // SetGeneralExtTimeBase
3742 
3743 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
3744 // cameras.
3745 bool CRTProtocol::SetCameraSettings(const unsigned int nCameraID,
3746  const ECameraMode* peMode,
3747  const float* pfMarkerExposure,
3748  const float* pfMarkerThreshold,
3749  const int* pnOrientation) {
3750  CMarkup oXML;
3751 
3752  oXML.AddElem("QTM_Settings");
3753  oXML.IntoElem();
3754  oXML.AddElem("General");
3755  oXML.IntoElem();
3756 
3757  oXML.AddElem("Camera");
3758  oXML.IntoElem();
3759 
3760  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
3761 
3762  if (peMode) {
3763  switch (*peMode) {
3764  case ModeMarker:
3765  oXML.AddElem("Mode", "Marker");
3766  break;
3767  case ModeMarkerIntensity:
3768  oXML.AddElem("Mode", "Marker Intensity");
3769  break;
3770  case ModeVideo:
3771  oXML.AddElem("Mode", "Video");
3772  break;
3773  }
3774  }
3775  AddXMLElementFloat(&oXML, "Marker_Exposure", pfMarkerExposure);
3776  AddXMLElementFloat(&oXML, "Marker_Threshold", pfMarkerThreshold);
3777  AddXMLElementInt(&oXML, "Orientation", pnOrientation);
3778 
3779  oXML.OutOfElem(); // Camera
3780  oXML.OutOfElem(); // General
3781  oXML.OutOfElem(); // QTM_Settings
3782 
3783  if (SendXML(oXML.GetDoc().c_str())) {
3784  return true;
3785  }
3786 
3787  return false;
3788 } // SetGeneralCamera
3789 
3790 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
3791 // cameras.
3793  const unsigned int nCameraID, const EVideoResolution* eVideoResolution,
3794  const EVideoAspectRatio* eVideoAspectRatio,
3795  const unsigned int* pnVideoFrequency, const float* pfVideoExposure,
3796  const float* pfVideoFlashTime) {
3797  CMarkup oXML;
3798 
3799  oXML.AddElem("QTM_Settings");
3800  oXML.IntoElem();
3801  oXML.AddElem("General");
3802  oXML.IntoElem();
3803 
3804  oXML.AddElem("Camera");
3805  oXML.IntoElem();
3806 
3807  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
3808  if (eVideoResolution) {
3809  switch (*eVideoResolution) {
3810  case VideoResolution1080p:
3811  oXML.AddElem("Video_Resolution", "1080p");
3812  break;
3813  case VideoResolution720p:
3814  oXML.AddElem("Video_Resolution", "720p");
3815  break;
3816  case VideoResolution540p:
3817  oXML.AddElem("Video_Resolution", "540p");
3818  break;
3819  case VideoResolution480p:
3820  oXML.AddElem("Video_Resolution", "480p");
3821  break;
3822  case VideoResolutionNone:
3823  break;
3824  }
3825  }
3826  if (eVideoAspectRatio) {
3827  switch (*eVideoAspectRatio) {
3828  case VideoAspectRatio16x9:
3829  oXML.AddElem("Video_Aspect_Ratio", "16x9");
3830  break;
3831  case VideoAspectRatio4x3:
3832  oXML.AddElem("Video_Aspect_Ratio", "4x3");
3833  break;
3834  case VideoAspectRatio1x1:
3835  oXML.AddElem("Video_Aspect_Ratio", "1x1");
3836  break;
3837  case VideoAspectRatioNone:
3838  break;
3839  }
3840  }
3841  AddXMLElementUnsignedInt(&oXML, "Video_Frequency", pnVideoFrequency);
3842  AddXMLElementFloat(&oXML, "Video_Exposure", pfVideoExposure);
3843  AddXMLElementFloat(&oXML, "Video_Flash_Time", pfVideoFlashTime);
3844 
3845  oXML.OutOfElem(); // Camera
3846  oXML.OutOfElem(); // General
3847  oXML.OutOfElem(); // QTM_Settings
3848 
3849  if (SendXML(oXML.GetDoc().c_str())) {
3850  return true;
3851  }
3852 
3853  return false;
3854 } // SetGeneralCameraVideo
3855 
3856 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
3857 // cameras.
3859  const unsigned int nCameraID, const unsigned int portNumber,
3860  const ESyncOutFreqMode* peSyncOutMode, const unsigned int* pnSyncOutValue,
3861  const float* pfSyncOutDutyCycle, const bool* pbSyncOutNegativePolarity) {
3862  CMarkup oXML;
3863 
3864  oXML.AddElem("QTM_Settings");
3865  oXML.IntoElem();
3866  oXML.AddElem("General");
3867  oXML.IntoElem();
3868 
3869  oXML.AddElem("Camera");
3870  oXML.IntoElem();
3871 
3872  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
3873 
3874  int port = portNumber - 1;
3875  if (((port == 0 || port == 1) && peSyncOutMode) || (port == 2)) {
3876  oXML.AddElem(port == 0 ? "Sync_Out"
3877  : (port == 1 ? "Sync_Out2" : "Sync_Out_MT"));
3878  oXML.IntoElem();
3879 
3880  if (port == 0 || port == 1) {
3881  switch (*peSyncOutMode) {
3882  case ModeShutterOut:
3883  oXML.AddElem("Mode", "Shutter out");
3884  break;
3885  case ModeMultiplier:
3886  oXML.AddElem("Mode", "Multiplier");
3887  break;
3888  case ModeDivisor:
3889  oXML.AddElem("Mode", "Divisor");
3890  break;
3891  case ModeActualFreq:
3892  oXML.AddElem("Mode", "Camera independent");
3893  break;
3894  case ModeMeasurementTime:
3895  oXML.AddElem("Mode", "Measurement time");
3896  break;
3897  case ModeFixed100Hz:
3898  oXML.AddElem("Mode", "Continuous 100Hz");
3899  break;
3900  default:
3901  return false; // Should never happen
3902  }
3903 
3904  if (*peSyncOutMode == ModeMultiplier || *peSyncOutMode == ModeDivisor ||
3905  *peSyncOutMode == ModeActualFreq) {
3906  if (pnSyncOutValue) {
3907  AddXMLElementUnsignedInt(&oXML, "Value", pnSyncOutValue);
3908  }
3909  if (pfSyncOutDutyCycle) {
3910  AddXMLElementFloat(&oXML, "Duty_Cycle", pfSyncOutDutyCycle, 3);
3911  }
3912  }
3913  }
3914  if (pbSyncOutNegativePolarity &&
3915  (port == 2 || (peSyncOutMode && *peSyncOutMode != ModeFixed100Hz))) {
3916  AddXMLElementBool(&oXML, "Signal_Polarity", pbSyncOutNegativePolarity,
3917  "Negative", "Positive");
3918  }
3919  oXML.OutOfElem(); // Sync_Out
3920  }
3921  oXML.OutOfElem(); // Camera
3922  oXML.OutOfElem(); // General
3923  oXML.OutOfElem(); // QTM_Settings
3924 
3925  if (SendXML(oXML.GetDoc().c_str())) {
3926  return true;
3927  }
3928 
3929  return false;
3930 } // SetGeneralCameraSyncOut
3931 
3932 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
3933 // cameras.
3934 bool CRTProtocol::SetCameraLensControlSettings(const unsigned int nCameraID,
3935  const float focus,
3936  const float aperture) {
3937  CMarkup oXML;
3938 
3939  oXML.AddElem("QTM_Settings");
3940  oXML.IntoElem();
3941  oXML.AddElem("General");
3942  oXML.IntoElem();
3943 
3944  oXML.AddElem("Camera");
3945  oXML.IntoElem();
3946 
3947  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
3948 
3949  oXML.AddElem("LensControl");
3950  oXML.IntoElem();
3951 
3952  oXML.AddElem("Focus");
3953  oXML.AddAttrib("Value", CMarkup::Format("%f", focus).c_str());
3954  oXML.AddElem("Aperture");
3955  oXML.AddAttrib("Value", CMarkup::Format("%f", aperture).c_str());
3956 
3957  oXML.OutOfElem(); // LensControl
3958  oXML.OutOfElem(); // Camera
3959  oXML.OutOfElem(); // General
3960  oXML.OutOfElem(); // QTM_Settings
3961 
3962  if (SendXML(oXML.GetDoc().c_str())) {
3963  return true;
3964  }
3965 
3966  return false;
3967 }
3968 
3969 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
3970 // cameras.
3971 bool CRTProtocol::SetCameraAutoExposureSettings(const unsigned int nCameraID,
3972  const bool autoExposure,
3973  const float compensation) {
3974  CMarkup oXML;
3975 
3976  oXML.AddElem("QTM_Settings");
3977  oXML.IntoElem();
3978  oXML.AddElem("General");
3979  oXML.IntoElem();
3980 
3981  oXML.AddElem("Camera");
3982  oXML.IntoElem();
3983 
3984  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
3985 
3986  oXML.AddElem("LensControl");
3987  oXML.IntoElem();
3988 
3989  oXML.AddElem("AutoExposure");
3990  oXML.AddAttrib("Enabled", autoExposure ? "true" : "false");
3991  oXML.AddAttrib("Compensation", CMarkup::Format("%f", compensation).c_str());
3992 
3993  oXML.OutOfElem(); // AutoExposure
3994  oXML.OutOfElem(); // Camera
3995  oXML.OutOfElem(); // General
3996  oXML.OutOfElem(); // QTM_Settings
3997 
3998  if (SendXML(oXML.GetDoc().c_str())) {
3999  return true;
4000  }
4001 
4002  return false;
4003 }
4004 
4005 // nCameraID starts on 1. If nCameraID < 0 then settings are applied to all
4006 // cameras.
4007 bool CRTProtocol::SetCameraAutoWhiteBalance(const unsigned int nCameraID,
4008  const bool enable) {
4009  CMarkup oXML;
4010 
4011  oXML.AddElem("QTM_Settings");
4012  oXML.IntoElem();
4013  oXML.AddElem("General");
4014  oXML.IntoElem();
4015 
4016  oXML.AddElem("Camera");
4017  oXML.IntoElem();
4018 
4019  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
4020 
4021  oXML.AddElem("AutoWhiteBalance", enable ? "true" : "false");
4022 
4023  oXML.OutOfElem(); // Camera
4024  oXML.OutOfElem(); // General
4025  oXML.OutOfElem(); // QTM_Settings
4026 
4027  if (SendXML(oXML.GetDoc().c_str())) {
4028  return true;
4029  }
4030 
4031  return false;
4032 }
4033 
4035  const unsigned int nCameraID, const bool* pbEnable,
4036  const CRTPacket::EImageFormat* peFormat, const unsigned int* pnWidth,
4037  const unsigned int* pnHeight, const float* pfLeftCrop,
4038  const float* pfTopCrop, const float* pfRightCrop,
4039  const float* pfBottomCrop) {
4040  CMarkup oXML;
4041 
4042  oXML.AddElem("QTM_Settings");
4043  oXML.IntoElem();
4044  oXML.AddElem("Image");
4045  oXML.IntoElem();
4046 
4047  oXML.AddElem("Camera");
4048  oXML.IntoElem();
4049 
4050  AddXMLElementUnsignedInt(&oXML, "ID", &nCameraID);
4051 
4052  AddXMLElementBool(&oXML, "Enabled", pbEnable);
4053 
4054  if (peFormat) {
4055  switch (*peFormat) {
4057  oXML.AddElem("Format", "RAWGrayscale");
4058  break;
4060  oXML.AddElem("Format", "RAWBGR");
4061  break;
4062  case CRTPacket::FormatJPG:
4063  oXML.AddElem("Format", "JPG");
4064  break;
4065  case CRTPacket::FormatPNG:
4066  oXML.AddElem("Format", "PNG");
4067  break;
4068  }
4069  }
4070  AddXMLElementUnsignedInt(&oXML, "Width", pnWidth);
4071  AddXMLElementUnsignedInt(&oXML, "Height", pnHeight);
4072  AddXMLElementFloat(&oXML, "Left_Crop", pfLeftCrop);
4073  AddXMLElementFloat(&oXML, "Top_Crop", pfTopCrop);
4074  AddXMLElementFloat(&oXML, "Right_Crop", pfRightCrop);
4075  AddXMLElementFloat(&oXML, "Bottom_Crop", pfBottomCrop);
4076 
4077  oXML.OutOfElem(); // Camera
4078  oXML.OutOfElem(); // Image
4079  oXML.OutOfElem(); // QTM_Settings
4080 
4081  if (SendXML(oXML.GetDoc().c_str())) {
4082  return true;
4083  }
4084 
4085  return false;
4086 } // SetImageSettings
4087 
4088 bool CRTProtocol::SetForceSettings(const unsigned int nPlateID,
4089  const SPoint* psCorner1,
4090  const SPoint* psCorner2,
4091  const SPoint* psCorner3,
4092  const SPoint* psCorner4) {
4093  CMarkup oXML;
4094 
4095  if (nPlateID > 0) {
4096  oXML.AddElem("QTM_Settings");
4097  oXML.IntoElem();
4098  oXML.AddElem("Force");
4099  oXML.IntoElem();
4100 
4101  oXML.AddElem("Plate");
4102  oXML.IntoElem();
4103 
4104  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
4105  AddXMLElementUnsignedInt(&oXML, "Plate_ID", &nPlateID);
4106  } else {
4107  AddXMLElementUnsignedInt(&oXML, "Force_Plate_Index", &nPlateID);
4108  }
4109  if (psCorner1) {
4110  oXML.AddElem("Corner1");
4111  oXML.IntoElem();
4112  AddXMLElementFloat(&oXML, "X", &(psCorner1->fX));
4113  AddXMLElementFloat(&oXML, "Y", &(psCorner1->fY));
4114  AddXMLElementFloat(&oXML, "Z", &(psCorner1->fZ));
4115  oXML.OutOfElem(); // Corner1
4116  }
4117  if (psCorner2) {
4118  oXML.AddElem("Corner2");
4119  oXML.IntoElem();
4120  AddXMLElementFloat(&oXML, "X", &(psCorner2->fX));
4121  AddXMLElementFloat(&oXML, "Y", &(psCorner2->fY));
4122  AddXMLElementFloat(&oXML, "Z", &(psCorner2->fZ));
4123  oXML.OutOfElem(); // Corner2
4124  }
4125  if (psCorner3) {
4126  oXML.AddElem("Corner3");
4127  oXML.IntoElem();
4128  AddXMLElementFloat(&oXML, "X", &(psCorner3->fX));
4129  AddXMLElementFloat(&oXML, "Y", &(psCorner3->fY));
4130  AddXMLElementFloat(&oXML, "Z", &(psCorner3->fZ));
4131  oXML.OutOfElem(); // Corner3
4132  }
4133  if (psCorner4) {
4134  oXML.AddElem("Corner4");
4135  oXML.IntoElem();
4136  AddXMLElementFloat(&oXML, "X", &(psCorner4->fX));
4137  AddXMLElementFloat(&oXML, "Y", &(psCorner4->fY));
4138  AddXMLElementFloat(&oXML, "Z", &(psCorner4->fZ));
4139  oXML.OutOfElem(); // Corner4
4140  }
4141  oXML.OutOfElem(); // Plate
4142 
4143  oXML.OutOfElem(); // Force
4144  oXML.OutOfElem(); // QTM_Settings
4145 
4146  if (SendXML(oXML.GetDoc().c_str())) {
4147  return true;
4148  }
4149  } else {
4150  sprintf(maErrorStr, "Illegal force plate id: %d.", nPlateID);
4151  }
4152  return false;
4153 } // SetForceSettings
4154 
4155 char* CRTProtocol::GetErrorString() { return maErrorStr; }
4156 
4157 bool CRTProtocol::SendString(const char* pCmdStr, int nType) {
4158  auto nCmdStrLen = strlen(pCmdStr);
4159  static char aSendBuffer[5000];
4160 
4161  if (nCmdStrLen > sizeof(aSendBuffer)) {
4162  strcpy(maErrorStr, "String is larger than send buffer.");
4163  return false;
4164  }
4165 
4166  //
4167  // Header size + length of the string + terminating null char
4168  //
4169  unsigned int nSize = 8 + (unsigned int)nCmdStrLen + 1;
4170 
4171  memcpy(aSendBuffer + 8, pCmdStr, nCmdStrLen + 1);
4172 
4173  if ((mnMajorVersion == 1 && mnMinorVersion == 0) || mbBigEndian) {
4174  *((unsigned int*)aSendBuffer) = htonl(nSize);
4175  *((unsigned int*)(aSendBuffer + 4)) = htonl(nType);
4176  } else {
4177  *((unsigned int*)aSendBuffer) = nSize;
4178  *((unsigned int*)(aSendBuffer + 4)) = nType;
4179  }
4180 
4181  if (mpoNetwork->Send(aSendBuffer, nSize) == false) {
4182  strcpy(maErrorStr, mpoNetwork->GetErrorString());
4183  return false;
4184  }
4185 
4186  return true;
4187 } // SendString
4188 
4189 bool CRTProtocol::SendCommand(const char* pCmdStr) {
4190  return SendString(pCmdStr, CRTPacket::PacketCommand);
4191 } // SendCommand
4192 
4193 bool CRTProtocol::SendCommand(const char* pCmdStr, char* pCommandResponseStr,
4194  unsigned int timeout) {
4195  CRTPacket::EPacketType eType;
4196 
4197  if (SendString(pCmdStr, CRTPacket::PacketCommand)) {
4198  while (ReceiveRTPacket(eType, true, timeout) > 0) {
4199  if (eType == CRTPacket::PacketCommand) {
4200  strcpy(pCommandResponseStr, mpoRTPacket->GetCommandString());
4201  return true;
4202  }
4203  if (eType == CRTPacket::PacketError) {
4204  strcpy(pCommandResponseStr, mpoRTPacket->GetErrorString());
4205  return false;
4206  }
4207  }
4208  } else {
4209  char pTmpStr[256];
4210  strcpy(pTmpStr, maErrorStr);
4211  sprintf(maErrorStr, "\'%s\' command failed. %s", pCmdStr, pTmpStr);
4212  }
4213  pCommandResponseStr[0] = 0;
4214  return false;
4215 } // SendCommand
4216 
4217 bool CRTProtocol::SendXML(const char* pCmdStr) {
4218  CRTPacket::EPacketType eType;
4219 
4220  if (SendString(pCmdStr, CRTPacket::PacketXML)) {
4221  if (ReceiveRTPacket(eType, true) > 0) {
4222  if (eType == CRTPacket::PacketCommand) {
4223  if (strcmp(mpoRTPacket->GetCommandString(),
4224  "Setting parameters succeeded") == 0) {
4225  return true;
4226  } else {
4227  sprintf(maErrorStr,
4228  "Expected command response \"Setting parameters succeeded\". "
4229  "Got \"%s\".",
4230  mpoRTPacket->GetCommandString());
4231  }
4232  } else {
4233  sprintf(maErrorStr,
4234  "Expected command response packet. Got packet type %d.",
4235  (int)eType);
4236  }
4237  } else {
4238  strcpy(maErrorStr, "Missing command response packet.");
4239  }
4240  } else {
4241  char pTmpStr[256];
4242  strcpy(pTmpStr, maErrorStr);
4243  sprintf(maErrorStr, "Failed to send XML string. %s", pTmpStr);
4244  }
4245  return false;
4246 } // SendXML
4247 
4248 void CRTProtocol::AddXMLElementBool(CMarkup* oXML, const char* tTag,
4249  const bool* pbValue, const char* tTrue,
4250  const char* tFalse) {
4251  if (pbValue) {
4252  oXML->AddElem(tTag, *pbValue ? tTrue : tFalse);
4253  }
4254 }
4255 
4256 void CRTProtocol::AddXMLElementBool(CMarkup* oXML, const char* tTag,
4257  const bool pbValue, const char* tTrue,
4258  const char* tFalse) {
4259  oXML->AddElem(tTag, pbValue ? tTrue : tFalse);
4260 }
4261 
4262 void CRTProtocol::AddXMLElementInt(CMarkup* oXML, const char* tTag,
4263  const int* pnValue) {
4264  if (pnValue) {
4265  std::string tVal;
4266 
4267  tVal = CMarkup::Format("%d", *pnValue);
4268  oXML->AddElem(tTag, tVal.c_str());
4269  }
4270 }
4271 
4272 void CRTProtocol::AddXMLElementUnsignedInt(CMarkup* oXML, const char* tTag,
4273  const unsigned int* pnValue) {
4274  if (pnValue) {
4275  std::string tVal;
4276 
4277  tVal = CMarkup::Format("%u", *pnValue);
4278  oXML->AddElem(tTag, tVal.c_str());
4279  }
4280 }
4281 
4282 void CRTProtocol::AddXMLElementFloat(CMarkup* oXML, const char* tTag,
4283  const float* pfValue,
4284  unsigned int pnDecimals) {
4285  if (pfValue) {
4286  std::string tVal;
4287  char fFormat[10];
4288 
4289  sprintf(fFormat, "%%.%df", pnDecimals);
4290  tVal = CMarkup::Format(fFormat, *pfValue);
4291  oXML->AddElem(tTag, tVal.c_str());
4292  }
4293 }
4294 
4295 bool CRTProtocol::CompareNoCase(std::string tStr1, const char* tStr2) const {
4296  std::transform(tStr1.begin(), tStr1.end(), tStr1.begin(), ::tolower);
4297  return tStr1.compare(tStr2) == 0;
4298 }
CRTProtocol::ZNeg
@ ZNeg
Definition: RTProtocol.h:121
CRTProtocol::ModelProReflex120
@ ModelProReflex120
Definition: RTProtocol.h:63
CMarkup
Definition: Markup.h:25
CRTProtocol::ModelOqus300Plus
@ ModelOqus300Plus
Definition: RTProtocol.h:69
CRTProtocol::CloseMeasurement
bool CloseMeasurement()
Definition: RTProtocol.cpp:608
CRTPacket::EventTrigger
@ EventTrigger
Definition: RTPacket.h:83
CRTProtocol::GetSkeletonName
const char * GetSkeletonName(unsigned int skeletonIndex)
Definition: RTProtocol.cpp:3532
CRTProtocol::GetForceUnits
void GetForceUnits(char *&pLength, char *&pForce) const
Definition: RTProtocol.cpp:3407
CNetwork::GetError
int GetError() const
Definition: Network.cpp:434
CRTProtocol::ProcessingExportTSV
@ ProcessingExportTSV
Definition: RTProtocol.h:133
CRTProtocol::SPoint
Definition: RTProtocol.h:140
CRTProtocol::cComponentForce
static const unsigned int cComponentForce
Definition: RTProtocol.h:31
CRTPacket::EventCalibrationStopped
@ EventCalibrationStopped
Definition: RTPacket.h:74
CRTProtocol::SSettingsSkeletonSegment::parentId
int parentId
Definition: RTProtocol.h:352
CRTPacket::EImageFormat
EImageFormat
Definition: RTPacket.h:60
Network.h
CRTProtocol::ESignalSource
ESignalSource
Definition: RTProtocol.h:113
CRTPacket::GetType
EPacketType GetType()
Definition: RTPacket.cpp:271
CRTProtocol::RateFrequencyDivisor
@ RateFrequencyDivisor
Definition: RTProtocol.h:58
CRTPacket::SSkeletonSegment::positionY
float positionY
Definition: RTPacket.h:118
CRTProtocol::LoadCapture
bool LoadCapture(const char *pFileName)
Definition: RTProtocol.cpp:678
CRTPacket::PacketError
@ PacketError
Definition: RTPacket.h:26
CRTPacket::EventCalibrationStarted
@ EventCalibrationStarted
Definition: RTPacket.h:73
CRTProtocol::GetCurrentFrame
bool GetCurrentFrame(unsigned int nComponentType, const SComponentOptions &componentOptions={})
Definition: RTProtocol.cpp:330
CRTProtocol::cComponent6dRes
static const unsigned int cComponent6dRes
Definition: RTProtocol.h:38
CRTProtocol::RateFrequency
@ RateFrequency
Definition: RTProtocol.h:57
CRTPacket::EventReprocessingStopped
@ EventReprocessingStopped
Definition: RTPacket.h:82
CRTPacket::SSkeletonSegment::positionZ
float positionZ
Definition: RTPacket.h:119
CRTProtocol::ProcessingPreProcess2D
@ ProcessingPreProcess2D
Definition: RTProtocol.h:137
CRTProtocol::GetCameraSettings
bool GetCameraSettings(unsigned int nCameraIndex, unsigned int &nID, ECameraModel &eModel, bool &bUnderwater, bool &bSupportsHwSync, unsigned int &nSerial, ECameraMode &eMode) const
Definition: RTProtocol.cpp:3055
CRTProtocol::StreamFrames
bool StreamFrames(EStreamRate eRate, unsigned int nRateArg, unsigned short nUDPPort, const char *pUDPAddr, unsigned int nComponentType, const SComponentOptions &componentOptions={})
Definition: RTProtocol.cpp:348
CRTProtocol::VideoResolution1080p
@ VideoResolution1080p
Definition: RTProtocol.h:90
CRTProtocol::NewMeasurement
bool NewMeasurement()
Definition: RTProtocol.cpp:591
CRTProtocol::ProcessingTwinSystemMerge
@ ProcessingTwinSystemMerge
Definition: RTProtocol.h:127
CRTPacket::PacketEvent
@ PacketEvent
Definition: RTPacket.h:32
CRTPacket::EventCaptureSaved
@ EventCaptureSaved
Definition: RTPacket.h:80
CRTPacket::EventCaptureStarted
@ EventCaptureStarted
Definition: RTPacket.h:70
CRTProtocol::cComponentImage
static const unsigned int cComponentImage
Definition: RTProtocol.h:41
CRTProtocol::EProcessingActions
EProcessingActions
Definition: RTProtocol.h:123
CRTProtocol::GetSkeletonCount
unsigned int GetSkeletonCount() const
Definition: RTProtocol.cpp:3528
CNetwork::CreateUDPSocket
bool CreateUDPSocket(unsigned short &nUDPPort, bool bBroadcast=false)
Definition: Network.cpp:155
CRTPacket::GetDiscoverResponseBasePort
short GetDiscoverResponseBasePort()
Definition: RTPacket.cpp:374
CRTProtocol::GetUdpServerPort
unsigned short GetUdpServerPort()
Definition: RTProtocol.cpp:164
CRTProtocol::Get3DBoneToName
const char * Get3DBoneToName(unsigned int boneIndex) const
Definition: RTProtocol.cpp:3281
CRTProtocol::SSettingsSkeleton::segments
std::vector< SSettingsSkeletonSegment > segments
Definition: RTProtocol.h:358
CRTProtocol::ReadSkeletonSettings
bool ReadSkeletonSettings(bool &bDataAvailable, bool skeletonGlobalData=false)
Definition: RTProtocol.cpp:2887
CMarkup::FindChildElem
bool FindChildElem(const char *szName=NULL)
Definition: Markup.cpp:101
CRTProtocol::ModelOqus500Plus
@ ModelOqus500Plus
Definition: RTProtocol.h:73
CRTProtocol::GetCameraFOV
bool GetCameraFOV(unsigned int nCameraIndex, unsigned int &nMarkerLeft, unsigned int &nMarkerTop, unsigned int &nMarkerRight, unsigned int &nMarkerBottom, unsigned int &nVideoLeft, unsigned int &nVideoTop, unsigned int &nVideoRight, unsigned int &nVideoBottom) const
Definition: RTProtocol.cpp:3187
CRTProtocol::ModelProReflex240
@ ModelProReflex240
Definition: RTProtocol.h:64
CRTProtocol::VideoAspectRatio1x1
@ VideoAspectRatio1x1
Definition: RTProtocol.h:100
CRTProtocol::VideoResolution720p
@ VideoResolution720p
Definition: RTProtocol.h:91
CRTProtocol::ESyncOutFreqMode
ESyncOutFreqMode
Definition: RTProtocol.h:104
CRTProtocol::Get3DLabelName
const char * Get3DLabelName(unsigned int nMarkerIndex) const
Definition: RTProtocol.cpp:3256
CRTProtocol::ModeVideo
@ ModeVideo
Definition: RTProtocol.h:87
CRTProtocol::ProcessingForceData
@ ProcessingForceData
Definition: RTProtocol.h:131
CRTPacket::EPacketType
EPacketType
Definition: RTPacket.h:25
CRTPacket::PacketQTMFile
@ PacketQTMFile
Definition: RTPacket.h:34
CRTProtocol::GetDiscoverResponse
bool GetDiscoverResponse(unsigned int nIndex, unsigned int &nAddr, unsigned short &nBasePort, std::string &message)
Definition: RTProtocol.cpp:318
CRTProtocol::SSettingsSkeletonSegment::name
std::string name
Definition: RTProtocol.h:351
CRTProtocol::SourceControlPort
@ SourceControlPort
Definition: RTProtocol.h:114
CRTProtocol::cComponent3dRes
static const unsigned int cComponent3dRes
Definition: RTProtocol.h:36
CRTProtocol::cComponentForceSingle
static const unsigned int cComponentForceSingle
Definition: RTProtocol.h:42
CRTPacket::FormatPNG
@ FormatPNG
Definition: RTPacket.h:64
CRTProtocol::GetGazeVectorFrequency
float GetGazeVectorFrequency(unsigned int nGazeVectorIndex) const
Definition: RTProtocol.cpp:3351
CRTProtocol::GetAnalogUnit
const char * GetAnalogUnit(unsigned int nDeviceIndex, unsigned int nChannelIndex) const
Definition: RTProtocol.cpp:3394
CRTProtocol::ProcessingGazeVector
@ ProcessingGazeVector
Definition: RTProtocol.h:132
CRTProtocol::cComponent6dEulerRes
static const unsigned int cComponent6dEulerRes
Definition: RTProtocol.h:39
CRTProtocol::SendTrig
bool SendTrig()
Definition: RTProtocol.cpp:499
CRTProtocol::GetSystemSettings
void GetSystemSettings(unsigned int &nCaptureFrequency, float &fCaptureTime, bool &bStartOnExtTrig, bool &trigNO, bool &trigNC, bool &trigSoftware, EProcessingActions &eProcessingActions, EProcessingActions &eRtProcessingActions, EProcessingActions &eReprocessingActions) const
Definition: RTProtocol.cpp:3015
CRTPacket::PacketDiscover
@ PacketDiscover
Definition: RTPacket.h:33
CRTProtocol::Get6DOFBodyName
const char * Get6DOFBodyName(unsigned int nBodyIndex) const
Definition: RTProtocol.cpp:3299
CRTProtocol::EVideoResolution
EVideoResolution
Definition: RTProtocol.h:89
CRTProtocol::SComponentOptions::mSkeletonGlobalData
bool mSkeletonGlobalData
Definition: RTProtocol.h:51
CRTProtocol::SetCameraVideoSettings
bool SetCameraVideoSettings(const unsigned int nCameraID, const EVideoResolution *eVideoResolution, const EVideoAspectRatio *eVideoAspectRatio, const unsigned int *pnVideoFrequency, const float *pfVideoExposure, const float *pfVideoFlashTime)
Definition: RTProtocol.cpp:3792
CRTProtocol::ModelMiqusVideoColor
@ ModelMiqusVideoColor
Definition: RTProtocol.h:82
CRTProtocol::GetCameraCount
unsigned int GetCameraCount() const
Definition: RTProtocol.cpp:3051
CRTProtocol::Get6DOFBodyCount
unsigned int Get6DOFBodyCount() const
Definition: RTProtocol.cpp:3295
CRTPacket::EventQTMShuttingDown
@ EventQTMShuttingDown
Definition: RTPacket.h:79
CRTProtocol::GetForcePlateCount
unsigned int GetForcePlateCount() const
Definition: RTProtocol.cpp:3412
CRTProtocol::ModeMeasurementTime
@ ModeMeasurementTime
Definition: RTProtocol.h:109
sot_talos_balance.test.script_test_end_effector.z
z
Definition: script_test_end_effector.py:12
CRTProtocol::Get3DLabelColor
unsigned int Get3DLabelColor(unsigned int nMarkerIndex) const
Definition: RTProtocol.cpp:3263
CRTProtocol::GetCameraLensControlSettings
bool GetCameraLensControlSettings(const unsigned int nCameraIndex, float *focus, float *aperture) const
Definition: RTProtocol.cpp:3207
CRTProtocol::cComponent6d
static const unsigned int cComponent6d
Definition: RTProtocol.h:32
CNetwork
Definition: Network.h:12
CRTProtocol::GetCameraAutoExposureSettings
bool GetCameraAutoExposureSettings(const unsigned int nCameraIndex, bool *autoExposureEnabled, float *autoExposureCompensation) const
Definition: RTProtocol.cpp:3219
CRTProtocol::Get6DOFBodyPointCount
unsigned int Get6DOFBodyPointCount(unsigned int nBodyIndex) const
Definition: RTProtocol.cpp:3313
CRTPacket::SSkeletonSegment::rotationX
float rotationX
Definition: RTPacket.h:120
CRTProtocol::SetVersion
bool SetVersion(int nMajorVersion, int nMinorVersion)
Definition: RTProtocol.cpp:183
CRTPacket::EventCaptureStopped
@ EventCaptureStopped
Definition: RTPacket.h:71
CRTProtocol::ReadXmlBool
bool ReadXmlBool(CMarkup *xml, const std::string &element, bool &value) const
Definition: RTProtocol.cpp:1134
CRTProtocol::SetForceSettings
bool SetForceSettings(const unsigned int nPlateID, const SPoint *psCorner1, const SPoint *psCorner2, const SPoint *psCorner3, const SPoint *psCorner4)
Definition: RTProtocol.cpp:4088
CRTProtocol::GetForcePlate
bool GetForcePlate(unsigned int nPlateIndex, unsigned int &nID, unsigned int &nAnalogDeviceID, unsigned int &nFrequency, char *&pType, char *&pName, float &fLength, float &fWidth) const
Definition: RTProtocol.cpp:3416
CRTProtocol::Processing6DOFTracking
@ Processing6DOFTracking
Definition: RTProtocol.h:130
CRTProtocol::SDiscoverResponse::nAddr
unsigned int nAddr
Definition: RTProtocol.h:148
CMarkup::OutOfElem
bool OutOfElem()
Definition: Markup.cpp:143
CRTProtocol::cComponent2dLin
static const unsigned int cComponent2dLin
Definition: RTProtocol.h:35
CRTPacket::SSkeletonSegment::rotationW
float rotationW
Definition: RTPacket.h:123
CRTProtocol::CheckLicense
bool CheckLicense(const char *pLicenseCode)
Definition: RTProtocol.cpp:242
CRTProtocol::GetRTPacket
CRTPacket * GetRTPacket()
Definition: RTProtocol.cpp:1132
CRTProtocol::ModeShutterOut
@ ModeShutterOut
Definition: RTProtocol.h:105
CRTProtocol::GetGazeVectorName
const char * GetGazeVectorName(unsigned int nGazeVectorIndex) const
Definition: RTProtocol.cpp:3343
CRTProtocol::StopCapture
bool StopCapture()
Definition: RTProtocol.cpp:662
CRTPacket::FormatRawGrayscale
@ FormatRawGrayscale
Definition: RTPacket.h:61
CRTProtocol::Get3DLabeledMarkerCount
unsigned int Get3DLabeledMarkerCount() const
Definition: RTProtocol.cpp:3252
CRTProtocol::SourceIRReceiver
@ SourceIRReceiver
Definition: RTProtocol.h:115
CRTProtocol::SetQTMEvent
bool SetQTMEvent(const char *pLabel)
Definition: RTProtocol.cpp:515
CRTProtocol::Get3DUpwardAxis
EAxis Get3DUpwardAxis() const
Definition: RTProtocol.cpp:3244
CRTProtocol::Get6DOFBodyPoint
bool Get6DOFBodyPoint(unsigned int nBodyIndex, unsigned int nMarkerIndex, SPoint &sPoint) const
Definition: RTProtocol.cpp:3321
CRTProtocol::GetExtTimeBaseSettings
void GetExtTimeBaseSettings(bool &bEnabled, ESignalSource &eSignalSource, bool &bSignalModePeriodic, unsigned int &nFreqMultiplier, unsigned int &nFreqDivisor, unsigned int &nFreqTolerance, float &fNominalFrequency, bool &bNegativeEdge, unsigned int &nSignalShutterDelay, float &fNonPeriodicTimeout) const
Definition: RTProtocol.cpp:3034
CRTProtocol::GetComponentString
static bool GetComponentString(char *pComponentStr, unsigned int nComponentType, const SComponentOptions &options=SComponentOptions())
Definition: RTProtocol.cpp:928
CRTProtocol::ProcessingTracking2D
@ ProcessingTracking2D
Definition: RTProtocol.h:125
CRTProtocol::Get3DCalibrated
const char * Get3DCalibrated() const
Definition: RTProtocol.cpp:3248
CNetwork::Disconnect
void Disconnect()
Definition: Network.cpp:141
CRTPacket::SSkeletonSegment::rotationY
float rotationY
Definition: RTPacket.h:121
CRTPacket::FormatJPG
@ FormatJPG
Definition: RTPacket.h:63
CRTProtocol::ModeMarker
@ ModeMarker
Definition: RTProtocol.h:87
CRTPacket::EventConnected
@ EventConnected
Definition: RTPacket.h:68
CRTProtocol::ModeMultiplier
@ ModeMultiplier
Definition: RTProtocol.h:106
CRTProtocol::EStreamRate
EStreamRate
Definition: RTProtocol.h:54
CRTProtocol::SetCameraLensControlSettings
bool SetCameraLensControlSettings(const unsigned int nCameraID, const float focus, const float aperture)
Definition: RTProtocol.cpp:3934
CRTPacket::PacketCommand
@ PacketCommand
Definition: RTPacket.h:27
CRTProtocol::ProcessingAIM
@ ProcessingAIM
Definition: RTProtocol.h:129
CRTProtocol::GetCapture
bool GetCapture(const char *pFileName, bool bC3D)
Definition: RTProtocol.cpp:427
CRTProtocol::GetSkeletonSegment
bool GetSkeletonSegment(unsigned int skeletonIndex, unsigned int segmentIndex, SSettingsSkeletonSegment *segment)
Definition: RTProtocol.cpp:3558
RTProtocol.h
CRTProtocol::ProcessingExportC3D
@ ProcessingExportC3D
Definition: RTProtocol.h:134
CRTPacket::PacketXML
@ PacketXML
Definition: RTPacket.h:28
CRTProtocol::SetCameraSettings
bool SetCameraSettings(const unsigned int nCameraID, const ECameraMode *peMode, const float *pfMarkerExposure, const float *pfMarkerThreshold, const int *pnOrientation)
Definition: RTProtocol.cpp:3745
CRTProtocol::ModelMiqusM3
@ ModelMiqusM3
Definition: RTProtocol.h:78
CRTPacket::EventRTfromFileStopped
@ EventRTfromFileStopped
Definition: RTPacket.h:76
CRTProtocol::VideoAspectRatio16x9
@ VideoAspectRatio16x9
Definition: RTProtocol.h:98
CRTProtocol::ProcessingNone
@ ProcessingNone
Definition: RTProtocol.h:124
CRTProtocol::GetCameraAutoWhiteBalance
bool GetCameraAutoWhiteBalance(const unsigned int nCameraIndex, bool *autoWhiteBalanceEnabled) const
Definition: RTProtocol.cpp:3233
CRTPacket::GetEvent
bool GetEvent(EEvent &eEvent)
Definition: RTPacket.cpp:392
CRTProtocol::ReleaseControl
bool ReleaseControl()
Definition: RTProtocol.cpp:571
CRTPacket::SSkeletonSegment::id
unsigned int id
Definition: RTPacket.h:116
CRTProtocol::StartCapture
bool StartCapture()
Definition: RTProtocol.cpp:627
CMarkup::GetChildData
std::string GetChildData() const
Definition: Markup.h:73
CRTProtocol::SetCameraAutoWhiteBalance
bool SetCameraAutoWhiteBalance(const unsigned int nCameraID, const bool enable)
Definition: RTProtocol.cpp:4007
CRTPacket::FormatRawBGR
@ FormatRawBGR
Definition: RTPacket.h:62
CRTProtocol::RateAllFrames
@ RateAllFrames
Definition: RTProtocol.h:56
CRTProtocol::ModelOqus600Plus
@ ModelOqus600Plus
Definition: RTProtocol.h:76
CRTPacket::GetErrorString
char * GetErrorString()
Definition: RTPacket.cpp:346
sot_talos_balance.test.script_test_end_effector.y
y
Definition: script_test_end_effector.py:11
CRTProtocol::SSettingsSkeleton::name
std::string name
Definition: RTProtocol.h:357
CRTProtocol::ModelMacReflex
@ ModelMacReflex
Definition: RTProtocol.h:62
CRTProtocol::cComponentAnalogSingle
static const unsigned int cComponentAnalogSingle
Definition: RTProtocol.h:40
CRTProtocol::GetAnalogDeviceCount
unsigned int GetAnalogDeviceCount() const
Definition: RTProtocol.cpp:3358
CMarkup::GetAttrib
std::string GetAttrib(const char *szAttrib) const
Definition: Markup.h:74
CRTProtocol::ReadAnalogSettings
bool ReadAnalogSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2336
CRTProtocol::GetForcePlateChannel
bool GetForcePlateChannel(unsigned int nPlateIndex, unsigned int nChannelIndex, unsigned int &nChannelNumber, float &fConversionFactor) const
Definition: RTProtocol.cpp:3463
CRTProtocol::ModelMiqusM1
@ ModelMiqusM1
Definition: RTProtocol.h:77
Markup.h
CRTProtocol::ReadCameraSystemSettings
bool ReadCameraSystemSettings()
Definition: RTProtocol.cpp:1156
CRTProtocol::SourceIRIG
@ SourceIRIG
Definition: RTProtocol.h:118
CRTPacket::SetVersion
void SetVersion(unsigned int nMajorVersion, unsigned int nMinorVersion)
Definition: RTPacket.cpp:31
CRTProtocol::GetImageCameraCount
unsigned int GetImageCameraCount() const
Definition: RTProtocol.cpp:3503
CRTProtocol::VideoAspectRatioNone
@ VideoAspectRatioNone
Definition: RTProtocol.h:101
CRTProtocol::GetCameraOrientation
bool GetCameraOrientation(unsigned int nCameraIndex, int &nOrientation) const
Definition: RTProtocol.cpp:3159
CRTProtocol::GetSkeleton
bool GetSkeleton(unsigned int skeletonIndex, SSettingsSkeleton *skeleton)
Definition: RTProtocol.cpp:3547
CRTProtocol::Read3DSettings
bool Read3DSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2032
CRTProtocol::StartRTOnFile
bool StartRTOnFile()
Definition: RTProtocol.cpp:643
CRTPacket::EventWaitingForTrigger
@ EventWaitingForTrigger
Definition: RTPacket.h:77
CRTProtocol::ModelProReflex1000
@ ModelProReflex1000
Definition: RTProtocol.h:66
CRTProtocol::~CRTProtocol
~CRTProtocol()
Definition: RTProtocol.cpp:61
CRTProtocol::SDiscoverResponse::message
char message[128]
Definition: RTProtocol.h:147
sot_talos_balance.test.script_test_end_effector.x
x
Definition: script_test_end_effector.py:10
CRTProtocol::Get6DOFBodyColor
unsigned int Get6DOFBodyColor(unsigned int nBodyIndex) const
Definition: RTProtocol.cpp:3306
CRTProtocol::cComponentTimecode
static const unsigned int cComponentTimecode
Definition: RTProtocol.h:44
CRTProtocol::EAxis
EAxis
Definition: RTProtocol.h:121
CRTProtocol::SPoint::fZ
float fZ
Definition: RTProtocol.h:143
CNetwork::SendUDPBroadcast
bool SendUDPBroadcast(const char *pSendBuf, int nSize, short nPort, unsigned int nFilterAddr=0)
Definition: Network.cpp:328
CRTPacket::GetSize
unsigned int GetSize()
Definition: RTPacket.cpp:261
CNetwork::IsLocalAddress
bool IsLocalAddress(unsigned int nAddr) const
Definition: Network.cpp:436
CRTProtocol::VideoResolution540p
@ VideoResolution540p
Definition: RTProtocol.h:92
CRTProtocol::SComponentOptions
Definition: RTProtocol.h:47
CRTPacket::EEvent
EEvent
Definition: RTPacket.h:67
CNetwork::Send
bool Send(const char *pSendBuf, int nSize)
Definition: Network.cpp:313
CNetwork::Receive
int Receive(char *rtDataBuff, int nDataBufSize, bool bHeader, int nTimeout, unsigned int *ipAddr=nullptr)
Definition: Network.cpp:226
CRTProtocol::ReadImageSettings
bool ReadImageSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2764
CRTProtocol::ModeFixed100Hz
@ ModeFixed100Hz
Definition: RTProtocol.h:110
CRTProtocol::GetForcePlateChannelCount
unsigned int GetForcePlateChannelCount(unsigned int nPlateIndex) const
Definition: RTProtocol.cpp:3454
CRTProtocol::ProcessingExportMatlabFile
@ ProcessingExportMatlabFile
Definition: RTProtocol.h:135
CRTProtocol::SSettingsSkeleton
Definition: RTProtocol.h:356
CRTPacket::SSkeletonSegment::rotationZ
float rotationZ
Definition: RTPacket.h:122
CRTProtocol::ConvertRateString
static bool ConvertRateString(const char *pRate, EStreamRate &eRate, unsigned int &nRateArg)
Definition: RTProtocol.cpp:835
CRTProtocol::SetSystemSettings
bool SetSystemSettings(const unsigned int *pnCaptureFrequency, const float *pfCaptureTime, const bool *pbStartOnExtTrig, const bool *trigNO, const bool *trigNC, const bool *trigSoftware, const EProcessingActions *peProcessingActions, const EProcessingActions *peRtProcessingActions, const EProcessingActions *peReprocessingActions)
Definition: RTProtocol.cpp:3576
CRTProtocol::GetCameraSystemType
ECameraSystemType GetCameraSystemType() const
Definition: RTProtocol.cpp:3572
CRTProtocol::SPoint::fX
float fX
Definition: RTProtocol.h:141
CRTProtocol::ReadGazeVectorSettings
bool ReadGazeVectorSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2266
CNetwork::Connect
bool Connect(const char *pServerAddr, unsigned short nPort)
Definition: Network.cpp:79
CMarkup::AddAttrib
bool AddAttrib(const char *szAttrib, const char *szValue)
Definition: Markup.h:47
CRTProtocol::cComponentSkeleton
static const unsigned int cComponentSkeleton
Definition: RTProtocol.h:45
CRTProtocol::ModeDivisor
@ ModeDivisor
Definition: RTProtocol.h:107
CRTProtocol::IsControlling
bool IsControlling()
Definition: RTProtocol.cpp:589
CRTProtocol::GetByteOrder
bool GetByteOrder(bool &bBigEndian)
Definition: RTProtocol.cpp:231
CRTProtocol::ModelMiqusM5
@ ModelMiqusM5
Definition: RTProtocol.h:79
CRTPacket::EventReprocessingStarted
@ EventReprocessingStarted
Definition: RTPacket.h:81
CRTProtocol::Read6DOFSettings
bool Read6DOFSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2151
CRTProtocol::ReadForceSettings
bool ReadForceSettings(bool &bDataAvailable)
Definition: RTProtocol.cpp:2503
CRTProtocol::GetForcePlateCalibrationMatrix
bool GetForcePlateCalibrationMatrix(unsigned int nPlateIndex, float fvCalMatrix[12][12], unsigned int *rows, unsigned int *columns) const
Definition: RTProtocol.cpp:3482
CRTProtocol::EVideoAspectRatio
EVideoAspectRatio
Definition: RTProtocol.h:97
CRTProtocol::ModelOqus200C
@ ModelOqus200C
Definition: RTProtocol.h:72
CRTProtocol::YNeg
@ YNeg
Definition: RTProtocol.h:121
CRTProtocol::SetExtTimeBaseSettings
bool SetExtTimeBaseSettings(const bool *pbEnabled, const ESignalSource *peSignalSource, const bool *pbSignalModePeriodic, const unsigned int *pnFreqMultiplier, const unsigned int *pnFreqDivisor, const unsigned int *pnFreqTolerance, const float *pfNominalFrequency, const bool *pbNegativeEdge, const unsigned int *pnSignalShutterDelay, const float *pfNonPeriodicTimeout)
Definition: RTProtocol.cpp:3675
CRTProtocol::YPos
@ YPos
Definition: RTProtocol.h:121
CRTPacket::EventCameraSettingsChanged
@ EventCameraSettingsChanged
Definition: RTPacket.h:78
CRTProtocol::GetCameraSyncOutSettings
bool GetCameraSyncOutSettings(unsigned int nCameraIndex, unsigned int portNumber, ESyncOutFreqMode &eSyncOutMode, unsigned int &nSyncOutValue, float &fSyncOutDutyCycle, bool &bSyncOutNegativePolarity) const
Definition: RTProtocol.cpp:3121
CRTProtocol::GetEventString
static bool GetEventString(CRTPacket::EEvent eEvent, char *pStr)
Definition: RTProtocol.cpp:779
CRTProtocol::TakeControl
bool TakeControl(const char *pPassword=nullptr)
Definition: RTProtocol.cpp:543
CRTProtocol::SetImageSettings
bool SetImageSettings(const unsigned int nCameraID, const bool *pbEnable, const CRTPacket::EImageFormat *peFormat, const unsigned int *pnWidth, const unsigned int *pnHeight, const float *pfLeftCrop, const float *pfTopCrop, const float *pfRightCrop, const float *pfBottomCrop)
Definition: RTProtocol.cpp:4034
CRTProtocol::SaveCapture
bool SaveCapture(const char *pFileName, bool bOverwrite, char *pNewFileName=nullptr, int nSizeOfNewFileName=0)
Definition: RTProtocol.cpp:703
CRTProtocol::GetQTMVersion
bool GetQTMVersion(char *pVersion, unsigned int nVersionLen)
Definition: RTProtocol.cpp:223
CRTProtocol::ModelOqus700
@ ModelOqus700
Definition: RTProtocol.h:74
CNetwork::GetUdpServerPort
unsigned short GetUdpServerPort()
Definition: Network.cpp:215
CRTProtocol::GetGazeVectorCount
unsigned int GetGazeVectorCount() const
Definition: RTProtocol.cpp:3339
CRTProtocol::Get3DBoneFromName
const char * Get3DBoneFromName(unsigned int boneIndex) const
Definition: RTProtocol.cpp:3274
CRTProtocol::cComponent3dNoLabelsRes
static const unsigned int cComponent3dNoLabelsRes
Definition: RTProtocol.h:37
CRTProtocol::VideoResolutionNone
@ VideoResolutionNone
Definition: RTProtocol.h:94
CRTProtocol::RateNone
@ RateNone
Definition: RTProtocol.h:55
CRTProtocol::GetAnalogLabel
const char * GetAnalogLabel(unsigned int nDeviceIndex, unsigned int nChannelIndex) const
Definition: RTProtocol.cpp:3381
CRTPacket::SetData
void SetData(char *ptr)
Definition: RTPacket.cpp:66
CRTProtocol::GetNumberOfDiscoverResponses
int GetNumberOfDiscoverResponses()
Definition: RTProtocol.cpp:314
CRTProtocol::ECameraSystemType
ECameraSystemType
Definition: RTProtocol.h:85
CRTProtocol::cComponent6dEuler
static const unsigned int cComponent6dEuler
Definition: RTProtocol.h:33
CRTProtocol::GetCameraResolution
bool GetCameraResolution(unsigned int nCameraIndex, unsigned int &nMarkerWidth, unsigned int &nMarkerHeight, unsigned int &nVideoWidth, unsigned int &nVideoHeight) const
Definition: RTProtocol.cpp:3168
CRTProtocol::GetCameraPosition
bool GetCameraPosition(unsigned int nCameraIndex, SPoint &sPoint, float fvRotationMatrix[3][3]) const
Definition: RTProtocol.cpp:3145
CRTProtocol::ReceiveRTPacket
int ReceiveRTPacket(CRTPacket::EPacketType &eType, bool bSkipEvents=true, int nTimeout=WAIT_FOR_DATA_TIMEOUT)
Definition: RTProtocol.cpp:1011
CRTProtocol::GetAnalogDevice
bool GetAnalogDevice(unsigned int nDeviceIndex, unsigned int &nDeviceID, unsigned int &nChannels, char *&pName, unsigned int &nFrequency, char *&pUnit, float &fMinRange, float &fMaxRange) const
Definition: RTProtocol.cpp:3362
CRTProtocol::XNeg
@ XNeg
Definition: RTProtocol.h:121
CRTProtocol::DiscoverRTServer
bool DiscoverRTServer(unsigned short nServerPort, bool bNoLocalResponses, unsigned short nDiscoverPort=DEFAULT_AUTO_DESCOVER_PORT)
Definition: RTProtocol.cpp:263
CRTPacket::EventRTfromFileStarted
@ EventRTfromFileStarted
Definition: RTPacket.h:75
sot_talos_balance.test.appli_admittance_end_effector.value
value
Definition: appli_admittance_end_effector.py:70
CRTProtocol::Get3DBoneCount
unsigned int Get3DBoneCount() const
Definition: RTProtocol.cpp:3270
CRTPacket::PacketNone
@ PacketNone
Definition: RTPacket.h:35
CRTProtocol::SSettingsSkeletonSegment
Definition: RTProtocol.h:350
CRTProtocol::ModelOqus500
@ ModelOqus500
Definition: RTProtocol.h:71
CRTProtocol::ModelMiqusVideo
@ ModelMiqusVideo
Definition: RTProtocol.h:81
CRTProtocol::ProcessingExportAviFile
@ ProcessingExportAviFile
Definition: RTProtocol.h:136
sot_talos_balance.test.test_base_estimator.c
c
Definition: test_base_estimator.py:23
CRTProtocol::Connect
bool Connect(const char *pServerAddr, unsigned short nPort, unsigned short *pnUDPServerPort=nullptr, int nMajorVersion=MAJOR_VERSION, int nMinorVersion=MINOR_VERSION, bool bBigEndian=false)
Definition: RTProtocol.cpp:72
CRTProtocol::ModelOqus300
@ ModelOqus300
Definition: RTProtocol.h:68
CRTPacket::EventConnectionClosed
@ EventConnectionClosed
Definition: RTPacket.h:69
CRTProtocol::SourceSMPTE
@ SourceSMPTE
Definition: RTProtocol.h:116
CMarkup::SetDoc
bool SetDoc(const char *szDoc)
Definition: Markup.cpp:41
CRTProtocol::SPoint::fY
float fY
Definition: RTProtocol.h:142
CRTProtocol::ECameraMode
ECameraMode
Definition: RTProtocol.h:87
CRTProtocol::ModeMarkerIntensity
@ ModeMarkerIntensity
Definition: RTProtocol.h:87
CMarkup::IntoElem
bool IntoElem()
Definition: Markup.cpp:127
CRTProtocol::GetErrorString
char * GetErrorString()
Definition: RTProtocol.cpp:4155
CRTProtocol::SetCameraSyncOutSettings
bool SetCameraSyncOutSettings(const unsigned int nCameraID, const unsigned int portNumber, const ESyncOutFreqMode *peSyncOutMode, const unsigned int *pnSyncOutValue, const float *pfSyncOutDutyCycle, const bool *pbSyncOutNegativePolarity)
Definition: RTProtocol.cpp:3858
CRTProtocol::GetCameraVideoSettings
bool GetCameraVideoSettings(unsigned int nCameraIndex, EVideoResolution &eVideoResolution, EVideoAspectRatio &eVideoAspectRatio, unsigned int &nVideoFrequency, unsigned int &nCurrentExposure, unsigned int &nMinExposure, unsigned int &nMaxExposure, unsigned int &nCurrentFlashTime, unsigned int &nMinFlashTime, unsigned int &nMaxFlashTime) const
Definition: RTProtocol.cpp:3095
CRTProtocol::SDiscoverResponse::nBasePort
unsigned short nBasePort
Definition: RTProtocol.h:149
CMarkup::AddElem
bool AddElem(const char *szName, const char *szData=NULL)
Definition: Markup.h:41
CRTProtocol::StreamFramesStop
bool StreamFramesStop()
Definition: RTProtocol.cpp:389
CRTProtocol::ECameraModel
ECameraModel
Definition: RTProtocol.h:61
CRTProtocol::Get6DOFEulerNames
void Get6DOFEulerNames(std::string &first, std::string &second, std::string &third) const
Definition: RTProtocol.cpp:3288
CRTProtocol::SourceVideoSync
@ SourceVideoSync
Definition: RTProtocol.h:117
CRTProtocol::ProcessingTracking3D
@ ProcessingTracking3D
Definition: RTProtocol.h:126
CRTPacket::PacketC3DFile
@ PacketC3DFile
Definition: RTPacket.h:31
CMarkup::GetDoc
std::string GetDoc() const
Definition: Markup.h:40
CRTProtocol::SetCameraAutoExposureSettings
bool SetCameraAutoExposureSettings(const unsigned int nCameraID, const bool autoExposure, const float compensation)
Definition: RTProtocol.cpp:3971
CRTProtocol::SSettingsSkeletonSegment::parentIndex
int parentIndex
Definition: RTProtocol.h:353
CMarkup::Format
static std::string Format(const char *fmt,...)
Definition: Markup.cpp:984
CRTProtocol::ModelOqus700Plus
@ ModelOqus700Plus
Definition: RTProtocol.h:75
CNetwork::Connected
bool Connected() const
Definition: Network.cpp:153
CRTProtocol::ModeActualFreq
@ ModeActualFreq
Definition: RTProtocol.h:108
CRTPacket
Definition: RTPacket.h:23
CRTProtocol::cComponentGazeVector
static const unsigned int cComponentGazeVector
Definition: RTProtocol.h:43
CRTProtocol::GetImageCamera
bool GetImageCamera(unsigned int nCameraIndex, unsigned int &nCameraID, bool &bEnabled, CRTPacket::EImageFormat &eFormat, unsigned int &nWidth, unsigned int &nHeight, float &fCropLeft, float &fCropTop, float &fCropRight, float &fCropBottom) const
Definition: RTProtocol.cpp:3507
CRTProtocol::VideoResolution480p
@ VideoResolution480p
Definition: RTProtocol.h:93
CRTProtocol::GetSkeletonSegmentCount
unsigned int GetSkeletonSegmentCount(unsigned int skeletonIndex)
Definition: RTProtocol.cpp:3539
CRTProtocol::GetCameraMarkerSettings
bool GetCameraMarkerSettings(unsigned int nCameraIndex, unsigned int &nCurrentExposure, unsigned int &nMinExposure, unsigned int &nMaxExposure, unsigned int &nCurrentThreshold, unsigned int &nMinThreshold, unsigned int &nMaxThreshold) const
Definition: RTProtocol.cpp:3072
CRTProtocol::ModelOqus100
@ ModelOqus100
Definition: RTProtocol.h:67
CRTProtocol::ModelMiqusSyncUnit
@ ModelMiqusSyncUnit
Definition: RTProtocol.h:80
CRTProtocol::GetForcePlateLocation
bool GetForcePlateLocation(unsigned int nPlateIndex, SPoint sCorner[4]) const
Definition: RTProtocol.cpp:3435
CRTProtocol::ConvertComponentString
static unsigned int ConvertComponentString(const char *pComponentType)
Definition: RTProtocol.cpp:862
CRTProtocol::CRTProtocol
CRTProtocol()
Definition: RTProtocol.cpp:45
CRTProtocol::XPos
@ XPos
Definition: RTProtocol.h:121
CRTProtocol::ZPos
@ ZPos
Definition: RTProtocol.h:121
CRTProtocol::VideoAspectRatio4x3
@ VideoAspectRatio4x3
Definition: RTProtocol.h:99
CRTProtocol::GetState
bool GetState(CRTPacket::EEvent &eEvent, bool bUpdate=true, int nTimeout=WAIT_FOR_DATA_TIMEOUT)
Definition: RTProtocol.cpp:397
CRTProtocol::Connected
bool Connected() const
Definition: RTProtocol.cpp:181
CRTProtocol::ModelOqus400
@ ModelOqus400
Definition: RTProtocol.h:70
CRTPacket::GetCommandString
char * GetCommandString()
Definition: RTPacket.cpp:353
CRTProtocol::Reprocess
bool Reprocess()
Definition: RTProtocol.cpp:763
CRTPacket::EventCaptureFetchingFinished
@ EventCaptureFetchingFinished
Definition: RTPacket.h:72
CRTProtocol::LoadProject
bool LoadProject(const char *pFileName)
Definition: RTProtocol.cpp:740
CRTProtocol::Disconnect
void Disconnect()
Definition: RTProtocol.cpp:171
CRTProtocol::cComponent3d
static const unsigned int cComponent3d
Definition: RTProtocol.h:28
CRTProtocol::cComponent3dNoLabels
static const unsigned int cComponent3dNoLabels
Definition: RTProtocol.h:29
CRTProtocol::GetForcePlateOrigin
bool GetForcePlateOrigin(unsigned int nPlateIndex, SPoint &sOrigin) const
Definition: RTProtocol.cpp:3445
CRTPacket::GetXMLString
char * GetXMLString()
Definition: RTPacket.cpp:367
CRTProtocol::cComponent2d
static const unsigned int cComponent2d
Definition: RTProtocol.h:34
CRTProtocol::SDiscoverResponse
Definition: RTProtocol.h:146
CRTProtocol::ProcessingSplineFill
@ ProcessingSplineFill
Definition: RTProtocol.h:128
CRTProtocol::ModelProReflex500
@ ModelProReflex500
Definition: RTProtocol.h:65
CRTProtocol::SComponentOptions::mAnalogChannels
char * mAnalogChannels
Definition: RTProtocol.h:50
CRTPacket::SSkeletonSegment::positionX
float positionX
Definition: RTPacket.h:117
CNetwork::GetErrorString
char * GetErrorString()
Definition: Network.cpp:432
CRTProtocol::GetVersion
bool GetVersion(unsigned int &nMajorVersion, unsigned int &nMinorVersion)
Definition: RTProtocol.cpp:211
CRTProtocol::cComponentAnalog
static const unsigned int cComponentAnalog
Definition: RTProtocol.h:30