1 #define _CRT_SECURE_NO_WARNINGS
21 #pragma comment(lib, "IPHLPAPI.lib")
23 #include <arpa/inet.h>
28 inline void ToLower(std::string& str) {
29 std::transform(str.begin(), str.end(), str.begin(),
30 [](
int c) { return std::tolower(c); });
33 inline void RemoveInvalidChars(std::string& str) {
34 auto isInvalidChar = [](
int c) ->
int {
38 return std::iscntrl(
c) + std::isspace(
c);
40 str.erase(std::remove_if(str.begin(), str.end(), isInvalidChar), str.end());
47 mpoRTPacket =
nullptr;
55 mpFileBuffer =
nullptr;
56 mDataBuffSize = 65535;
57 maDataBuff =
new char[mDataBuffSize];
68 mpoRTPacket =
nullptr;
73 unsigned short* pnUDPServerPort,
int nMajorVersion,
74 int nMinorVersion,
bool bBigEndian) {
77 char pResponseStr[256];
79 mbBigEndian = bBigEndian;
83 if ((nMajorVersion == 1) && (nMinorVersion == 0)) {
97 mpoRTPacket =
new CRTPacket(nMajorVersion, nMinorVersion, bBigEndian);
99 if (mpoRTPacket ==
nullptr) {
100 strcpy(maErrorStr,
"Could not allocate data packet.");
104 if (mpoNetwork->
Connect(pServerAddr, nPort)) {
105 if (pnUDPServerPort !=
nullptr) {
107 sprintf(maErrorStr,
"CreateUDPSocket failed. %s",
122 const std::string welcomeMessage(
"QTM RT Interface connected");
124 welcomeMessage.size()) == 0) {
126 if (
SetVersion(nMajorVersion, nMinorVersion)) {
131 if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
133 strcpy(tTemp,
"ByteOrder BigEndian");
135 strcpy(tTemp,
"ByteOrder LittleEndian");
138 if (SendCommand(tTemp, pResponseStr)) {
141 strcpy(maErrorStr,
"Set byte order failed.");
154 if (mpoNetwork->
GetError() == 10061) {
155 strcpy(maErrorStr,
"Check if QTM is running on target machine.");
176 mpoRTPacket =
nullptr;
185 char pResponseStr[256];
187 sprintf(tTemp,
"Version %u.%u", nMajorVersion, nMinorVersion);
189 if (SendCommand(tTemp, pResponseStr)) {
190 sprintf(tTemp,
"Version set to %u.%u", nMajorVersion, nMinorVersion);
192 if (strcmp(pResponseStr, tTemp) == 0) {
193 mnMajorVersion = nMajorVersion;
194 mnMinorVersion = nMinorVersion;
195 mpoRTPacket->
SetVersion(mnMajorVersion, mnMinorVersion);
200 sprintf(maErrorStr,
"%s.", pResponseStr);
202 strcpy(maErrorStr,
"Set Version failed.");
205 strcpy(tTemp, maErrorStr);
206 sprintf(maErrorStr,
"Send Version failed. %s.", tTemp);
212 unsigned int& nMinorVersion) {
217 nMajorVersion = mnMajorVersion;
218 nMinorVersion = mnMinorVersion;
224 if (SendCommand(
"QTMVersion", pVersion, nVersionLen)) {
227 strcpy(maErrorStr,
"Get QTM Version failed.");
232 char pResponseStr[256];
234 if (SendCommand(
"ByteOrder", pResponseStr)) {
235 bBigEndian = (strcmp(pResponseStr,
"Byte order is big endian") == 0);
238 strcpy(maErrorStr,
"Get Byte order failed.");
244 char pResponseStr[256];
246 if (strlen(pLicenseCode) <= 85) {
247 sprintf(tTemp,
"CheckLicense %s", pLicenseCode);
249 if (SendCommand(tTemp, pResponseStr)) {
250 if (strcmp(pResponseStr,
"License pass") == 0) {
253 strcpy(maErrorStr,
"Wrong license code.");
255 strcpy(maErrorStr,
"CheckLicense failed.");
258 strcpy(maErrorStr,
"License code too long.");
264 bool bNoLocalResponses,
265 unsigned short nDiscoverPort) {
269 if (mnBroadcastPort == 0) {
274 mnBroadcastPort = nServerPort;
276 nServerPort = mnBroadcastPort;
279 *((
unsigned int*)pData) = (
unsigned int)10;
281 *((
unsigned short*)(pData + 8)) = htons(nServerPort);
284 mvsDiscoverResponseList.clear();
288 unsigned int nAddr = 0;
290 mpoNetwork->
Receive(maDataBuff, mDataBuffSize,
false, 100000, &nAddr);
292 if (nReceived != -1 && nReceived > 8) {
295 sResponse.
nAddr = nAddr;
301 strcpy(sResponse.
message, response);
302 mvsDiscoverResponseList.push_back(sResponse);
306 }
while (nReceived != -1 &&
315 return (
int)mvsDiscoverResponseList.size();
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;
332 char pCommandStr[256];
333 strcpy(pCommandStr,
"GetCurrentFrame ");
335 std::string::size_type nCommandStrSize = strlen(pCommandStr);
338 if (SendCommand(pCommandStr)) {
341 strcpy(maErrorStr,
"GetCurrentFrame failed.");
343 strcpy(maErrorStr,
"DataComponent missing.");
349 unsigned short nUDPPort,
const char* pUDPAddr,
350 unsigned int nComponentType,
352 char pCommandStr[256];
355 sprintf(pCommandStr,
"StreamFrames FrequencyDivisor:%d ", nRateArg);
357 sprintf(pCommandStr,
"StreamFrames Frequency:%d ", nRateArg);
359 sprintf(pCommandStr,
"StreamFrames AllFrames ");
361 strcpy(maErrorStr,
"No valid rate.");
366 if (pUDPAddr !=
nullptr && strlen(pUDPAddr) > 64) {
367 strcpy(maErrorStr,
"UDP address string too long.");
370 sprintf(pCommandStr,
"%s UDP%s%s:%d ", pCommandStr,
371 pUDPAddr !=
nullptr ?
":" :
"", pUDPAddr !=
nullptr ? pUDPAddr :
"",
375 std::string::size_type nCommandStrSize = strlen(pCommandStr);
378 if (SendCommand(pCommandStr)) {
381 strcpy(maErrorStr,
"StreamFrames failed.");
383 strcpy(maErrorStr,
"DataComponent missing.");
390 if (SendCommand(
"StreamFrames Stop")) {
393 strcpy(maErrorStr,
"StreamFrames Stop failed.");
403 if (mnMajorVersion > 1 || mnMinorVersion > 9) {
404 result = SendCommand(
"GetState");
406 result = SendCommand(
"GetLastEvent");
413 if (mpoRTPacket->
GetEvent(eEvent)) {
417 }
while (nReceived > 0);
419 strcpy(maErrorStr,
"GetLastEvent failed.");
429 char pResponseStr[256];
431 mpFileBuffer = fopen(pFileName,
"wb");
432 if (mpFileBuffer !=
nullptr) {
435 if (SendCommand((mnMajorVersion > 1 || mnMinorVersion > 7)
439 if (strcmp(pResponseStr,
"Sending capture") == 0) {
444 if (mpFileBuffer !=
nullptr) {
445 fclose(mpFileBuffer);
448 strcpy(maErrorStr,
"Writing C3D file failed.");
450 strcpy(maErrorStr,
"Wrong packet type received.");
453 strcpy(maErrorStr,
"No packet received.");
456 sprintf(maErrorStr,
"%s failed.",
457 (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"GetCaptureC3D"
461 sprintf(maErrorStr,
"%s failed.",
462 (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"GetCaptureC3D"
467 if (SendCommand(
"GetCaptureQTM", pResponseStr)) {
468 if (strcmp(pResponseStr,
"Sending capture") == 0) {
473 if (mpFileBuffer !=
nullptr) {
474 fclose(mpFileBuffer);
477 strcpy(maErrorStr,
"Writing QTM file failed.");
479 strcpy(maErrorStr,
"Wrong packet type received.");
482 sprintf(maErrorStr,
"No packet received. %s.", maErrorStr);
485 strcpy(maErrorStr,
"GetCaptureQTM failed.");
488 strcpy(maErrorStr,
"GetCaptureQTM failed.");
493 fclose(mpFileBuffer);
500 char pResponseStr[256];
502 if (SendCommand(
"Trig", pResponseStr)) {
503 if (strcmp(pResponseStr,
"Trig ok") == 0) {
508 sprintf(maErrorStr,
"%s.", pResponseStr);
510 strcpy(maErrorStr,
"Trig failed.");
517 char pResponseStr[256];
519 if (strlen(pLabel) <= 92) {
522 (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"SetQTMEvent" :
"Event",
525 if (SendCommand(tTemp, pResponseStr)) {
526 if (strcmp(pResponseStr,
"Event set") == 0) {
531 sprintf(maErrorStr,
"%s.", pResponseStr);
534 maErrorStr,
"%s failed.",
535 (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"SetQTMEvent" :
"Event");
538 strcpy(maErrorStr,
"Event label too long.");
544 char pResponseStr[256];
547 strcpy(pCmd,
"TakeControl");
548 if (pPassword !=
nullptr) {
550 if (pPassword[0] != 0) {
552 strcat(pCmd, pPassword);
555 if (SendCommand(pCmd, pResponseStr)) {
556 if (strcmp(
"You are now master", pResponseStr) == 0 ||
557 strcmp(
"You are already master", pResponseStr) == 0) {
563 sprintf(maErrorStr,
"%s.", pResponseStr);
565 strcpy(maErrorStr,
"TakeControl failed.");
572 char pResponseStr[256];
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) {
582 sprintf(maErrorStr,
"%s.", pResponseStr);
584 strcpy(maErrorStr,
"ReleaseControl failed.");
592 char pResponseStr[256];
594 if (SendCommand(
"New", pResponseStr)) {
595 if (strcmp(pResponseStr,
"Creating new connection") == 0 ||
596 strcmp(pResponseStr,
"Already connected") == 0) {
601 sprintf(maErrorStr,
"%s.", pResponseStr);
603 strcpy(maErrorStr,
"New failed.");
609 char pResponseStr[256];
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) {
620 sprintf(maErrorStr,
"%s.", pResponseStr);
622 strcpy(maErrorStr,
"Close failed.");
628 char pResponseStr[256];
630 if (SendCommand(
"Start", pResponseStr)) {
631 if (strcmp(pResponseStr,
"Starting measurement") == 0) {
636 sprintf(maErrorStr,
"%s.", pResponseStr);
638 strcpy(maErrorStr,
"Start failed.");
644 char pResponseStr[256];
646 if (SendCommand(
"Start rtfromfile", pResponseStr)) {
647 if (strcmp(pResponseStr,
"Starting RT from file") == 0) {
652 if (strcmp(pResponseStr,
"RT from file already running") == 0) {
655 sprintf(maErrorStr,
"%s.", pResponseStr);
657 strcpy(maErrorStr,
"Starting RT from file failed.");
663 char pResponseStr[256];
665 if (SendCommand(
"Stop", pResponseStr)) {
666 if (strcmp(pResponseStr,
"Stopping measurement") == 0) {
671 sprintf(maErrorStr,
"%s.", pResponseStr);
673 strcpy(maErrorStr,
"Stop failed.");
680 char pResponseStr[256];
682 if (strlen(pFileName) <= 94) {
683 sprintf(tTemp,
"Load %s", pFileName);
685 if (SendCommand(tTemp, pResponseStr,
688 if (strcmp(pResponseStr,
"Measurement loaded") == 0) {
692 if (strlen(pResponseStr) > 0) {
693 sprintf(maErrorStr,
"%s.", pResponseStr);
695 strcpy(maErrorStr,
"Load failed.");
698 strcpy(maErrorStr,
"File name too long.");
704 char* pNewFileName,
int nSizeOfNewFileName) {
706 char pResponseStr[256];
707 char tNewFileNameTmp[300];
709 tNewFileNameTmp[0] = 0;
711 if (strlen(pFileName) <= 94) {
712 sprintf(tTemp,
"Save %s%s", pFileName, bOverwrite ?
" Overwrite" :
"");
714 if (SendCommand(tTemp, pResponseStr)) {
715 if (strcmp(pResponseStr,
"Measurement saved") == 0) {
716 if (pNewFileName && nSizeOfNewFileName > 0) {
721 if (sscanf(pResponseStr,
"Measurement saved as '%[^']'",
722 tNewFileNameTmp) == 1) {
724 strcpy(pNewFileName, tNewFileNameTmp);
730 sprintf(maErrorStr,
"%s.", pResponseStr);
732 strcpy(maErrorStr,
"Save failed.");
735 strcpy(maErrorStr,
"File name too long.");
742 char pResponseStr[256];
744 if (strlen(pFileName) <= 94) {
745 sprintf(tTemp,
"LoadProject %s", pFileName);
747 if (SendCommand(tTemp, pResponseStr)) {
748 if (strcmp(pResponseStr,
"Project loaded") == 0) {
753 sprintf(maErrorStr,
"%s.", pResponseStr);
755 strcpy(maErrorStr,
"Load project failed.");
758 strcpy(maErrorStr,
"File name too long.");
764 char pResponseStr[256];
766 if (SendCommand(
"Reprocess", pResponseStr)) {
767 if (strcmp(pResponseStr,
"Reprocessing file") == 0) {
772 sprintf(maErrorStr,
"%s.", pResponseStr);
774 strcpy(maErrorStr,
"Reprocess failed.");
782 strcpy(pStr,
"Connected");
785 strcpy(pStr,
"Connection Closed");
788 strcpy(pStr,
"Capture Started");
791 strcpy(pStr,
"Capture Stopped");
794 strcpy(pStr,
"Fetching Finished");
797 strcpy(pStr,
"Calibration Started");
800 strcpy(pStr,
"Calibration Finished");
803 strcpy(pStr,
"RT From File Started");
806 strcpy(pStr,
"RT From File Stopped");
809 strcpy(pStr,
"Waiting For Trigger");
812 strcpy(pStr,
"Camera Settings Changed");
815 strcpy(pStr,
"QTM Shutting Down");
818 strcpy(pStr,
"Capture Saved");
821 strcpy(pStr,
"Reprocessing Started");
824 strcpy(pStr,
"Reprocessing Stopped");
827 strcpy(pStr,
"Trigger");
836 unsigned int& nRateArg) {
837 std::string rateString;
839 rateString.assign(pRate);
840 std::transform(rateString.begin(), rateString.end(), rateString.begin(),
845 if (rateString.compare(0, 9,
"allframes", 9) == 0) {
847 }
else if (rateString.compare(0, 10,
"frequency:") == 0) {
848 nRateArg = atoi(rateString.substr(10).c_str());
852 }
else if (rateString.compare(0, 17,
"frequencydivisor:") == 0) {
853 nRateArg = atoi(rateString.substr(17).c_str());
863 std::string componentString;
864 unsigned int componentTypes = 0;
866 componentString.assign(pComponentType);
868 std::transform(componentString.begin(), componentString.end(),
869 componentString.begin(), ::tolower);
871 if (componentString.find(
"2d") != std::string::npos) {
874 if (componentString.find(
"2dlin") != std::string::npos) {
877 if (componentString.find(
"3d") != std::string::npos) {
880 if (componentString.find(
"3dres") != std::string::npos) {
883 if (componentString.find(
"3dnolabels") != std::string::npos) {
886 if (componentString.find(
"3dnolabelsres") != std::string::npos) {
889 if (componentString.find(
"analog") != std::string::npos) {
892 if (componentString.find(
"analogsingle") != std::string::npos) {
895 if (componentString.find(
"force") != std::string::npos) {
898 if (componentString.find(
"forcesingle") != std::string::npos) {
901 if (componentString.find(
"6d") != std::string::npos) {
904 if (componentString.find(
"6dres") != std::string::npos) {
907 if (componentString.find(
"6deuler") != std::string::npos) {
910 if (componentString.find(
"6deulerres") != std::string::npos) {
913 if (componentString.find(
"image") != std::string::npos) {
916 if (componentString.find(
"gazevector") != std::string::npos) {
919 if (componentString.find(
"timecode") != std::string::npos) {
922 if (componentString.find(
"skeleton") != std::string::npos) {
925 return componentTypes;
929 unsigned int nComponentType,
931 pComponentStr[0] = 0;
934 strcat(pComponentStr,
"2D ");
937 strcat(pComponentStr,
"2DLin ");
940 strcat(pComponentStr,
"3D ");
943 strcat(pComponentStr,
"3DRes ");
946 strcat(pComponentStr,
"3DNoLabels ");
949 strcat(pComponentStr,
"3DNoLabelsRes ");
952 strcat(pComponentStr,
"6D ");
955 strcat(pComponentStr,
"6DRes ");
958 strcat(pComponentStr,
"6DEuler ");
961 strcat(pComponentStr,
"6DEulerRes ");
964 strcat(pComponentStr,
"Analog");
967 strcat(pComponentStr,
":");
971 strcat(pComponentStr,
" ");
974 strcat(pComponentStr,
"AnalogSingle");
977 strcat(pComponentStr,
":");
981 strcat(pComponentStr,
" ");
984 strcat(pComponentStr,
"Force ");
987 strcat(pComponentStr,
"ForceSingle ");
990 strcat(pComponentStr,
"GazeVector ");
993 strcat(pComponentStr,
"Image ");
996 strcat(pComponentStr,
"Timecode ");
999 strcat(pComponentStr,
"Skeleton");
1002 strcat(pComponentStr,
":global");
1005 strcat(pComponentStr,
" ");
1008 return (pComponentStr[0] != 0);
1012 bool bSkipEvents,
int nTimeout) {
1014 unsigned int nRecvedTotal = 0;
1015 unsigned int nFrameSize;
1023 nRecved = mpoNetwork->
Receive(maDataBuff, mDataBuffSize,
true, nTimeout);
1026 strcpy(maErrorStr,
"Data receive timeout.");
1029 if (nRecved < (
int)(
sizeof(
int) * 2)) {
1031 strcpy(maErrorStr,
"Couldn't read header bytes.");
1034 if (nRecved <= -1) {
1035 strcpy(maErrorStr,
"Socket Error.");
1038 nRecvedTotal += nRecved;
1041 (mbBigEndian || (mnMajorVersion == 1 && mnMinorVersion == 0));
1042 nFrameSize = mpoRTPacket->
GetSize(maDataBuff, bBigEndian);
1043 eType = mpoRTPacket->
GetType(maDataBuff, bBigEndian);
1045 unsigned int nReadSize;
1049 if (mpFileBuffer !=
nullptr) {
1050 rewind(mpFileBuffer);
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;
1060 while (nRecvedTotal < nFrameSize) {
1061 nReadSize = nFrameSize - nRecvedTotal;
1062 if (nFrameSize > mDataBuffSize) {
1063 nReadSize = mDataBuffSize;
1066 nRecved = mpoNetwork->
Receive(&(maDataBuff[
sizeof(
int) * 2]),
1067 nReadSize,
false, nTimeout);
1069 strcpy(maErrorStr,
"Socket Error.");
1070 fclose(mpFileBuffer);
1071 mpFileBuffer =
nullptr;
1074 if (fwrite(maDataBuff +
sizeof(
int) * 2, 1, nRecved, mpFileBuffer) !=
1076 strcpy(maErrorStr,
"Failed to write file to disk.");
1077 fclose(mpFileBuffer);
1078 mpFileBuffer =
nullptr;
1081 nRecvedTotal += nRecved;
1084 strcpy(maErrorStr,
"Receive file buffer not opened.");
1086 fclose(mpFileBuffer);
1088 mpFileBuffer =
nullptr;
1092 if (nFrameSize > mDataBuffSize) {
1093 char* buf =
new char[nFrameSize];
1094 memcpy(buf, maDataBuff, mDataBuffSize);
1097 mDataBuffSize = nFrameSize;
1101 while (nRecvedTotal < nFrameSize) {
1104 mpoNetwork->
Receive(&(maDataBuff[nRecvedTotal]),
1105 nFrameSize - nRecvedTotal,
false, nTimeout);
1107 strcpy(maErrorStr,
"Socket Error.");
1110 nRecvedTotal += nRecved;
1114 mpoRTPacket->
SetData(maDataBuff);
1119 meState = meLastEvent;
1124 if (nRecvedTotal == nFrameSize) {
1125 return nRecvedTotal;
1127 strcpy(maErrorStr,
"Packet truncated.");
1135 bool&
value)
const {
1141 RemoveInvalidChars(str);
1144 if (str ==
"true") {
1146 }
else if (str ==
"false") {
1161 msGeneralSettings.vsCameras.clear();
1163 if (!SendCommand(
"GetParameters General")) {
1164 strcpy(maErrorStr,
"GetParameters General failed");
1169 if (received <= 0) {
1170 if (received == 0) {
1172 strcat(maErrorStr,
" Expected XML packet.");
1182 "GetParameters General returned wrong packet type. Got type %d "
1200 msGeneralSettings.nCaptureFrequency = atoi(oXML.
GetChildData().c_str());
1205 msGeneralSettings.fCaptureTime = (float)atof(oXML.
GetChildData().c_str());
1209 if (!
ReadXmlBool(&oXML,
"Start_On_External_Trigger",
1210 msGeneralSettings.bStartOnExternalTrigger)) {
1213 if (mnMajorVersion > 1 || mnMinorVersion > 14) {
1215 msGeneralSettings.bStartOnTrigNO)) {
1219 msGeneralSettings.bStartOnTrigNC)) {
1222 if (!
ReadXmlBool(&oXML,
"Start_On_Trigger_Software",
1223 msGeneralSettings.bStartOnTrigSoftware)) {
1238 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1239 msGeneralSettings.sExternalTimebase.bEnabled = (tStr ==
"true");
1245 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1246 if (tStr ==
"control port") {
1248 }
else if (tStr ==
"ir receiver") {
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") {
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;
1276 unsigned int nMultiplier;
1278 if (sscanf(tStr.c_str(),
"%u", &nMultiplier) == 1) {
1279 msGeneralSettings.sExternalTimebase.nFreqMultiplier = nMultiplier;
1287 unsigned int nDivisor;
1289 if (sscanf(tStr.c_str(),
"%u", &nDivisor) == 1) {
1290 msGeneralSettings.sExternalTimebase.nFreqDivisor = nDivisor;
1298 unsigned int nTolerance;
1300 if (sscanf(tStr.c_str(),
"%u", &nTolerance) == 1) {
1301 msGeneralSettings.sExternalTimebase.nFreqTolerance = nTolerance;
1310 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1312 if (tStr ==
"none") {
1313 msGeneralSettings.sExternalTimebase.fNominalFrequency =
1317 if (sscanf(tStr.c_str(),
"%f", &fFrequency) == 1) {
1318 msGeneralSettings.sExternalTimebase.fNominalFrequency = fFrequency;
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;
1340 unsigned int nDelay;
1342 if (sscanf(tStr.c_str(),
"%u", &nDelay) == 1) {
1343 msGeneralSettings.sExternalTimebase.nSignalShutterDelay = nDelay;
1353 if (sscanf(tStr.c_str(),
"%f", &fTimeout) == 1) {
1354 msGeneralSettings.sExternalTimebase.fNonPeriodicTimeout = fTimeout;
1361 const char* processings[3] = {
"Processing_Actions",
1362 "RealTime_Processing_Actions",
1363 "Reprocessing_Actions"};
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++) {
1378 if (mnMajorVersion > 1 || mnMinorVersion > 13) {
1392 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1394 *processingActions[i] =
1396 }
else if (tStr ==
"2d" && i != 1)
1398 *processingActions[i] =
1416 *processingActions[i] =
1425 *processingActions[i] =
1433 *processingActions[i] =
1441 *processingActions[i] =
1445 if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1450 *processingActions[i] =
1461 *processingActions[i] =
1469 *processingActions[i] =
1477 *processingActions[i] =
1482 if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1496 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Unknown;
1500 if (CompareNoCase(tStr,
"oqus")) {
1501 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Oqus;
1502 }
else if (CompareNoCase(tStr,
"miqus")) {
1503 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Miqus;
1509 SSettingsGeneralCamera sCameraSettings;
1517 sCameraSettings.nID = atoi(oXML.
GetChildData().c_str());
1523 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1525 if (tStr ==
"macreflex") {
1527 }
else if (tStr ==
"proreflex 120") {
1529 }
else if (tStr ==
"proreflex 240") {
1531 }
else if (tStr ==
"proreflex 500") {
1533 }
else if (tStr ==
"proreflex 1000") {
1535 }
else if (tStr ==
"oqus 100") {
1537 }
else if (tStr ==
"oqus 200" || tStr ==
"oqus 200 c") {
1539 }
else if (tStr ==
"oqus 300") {
1541 }
else if (tStr ==
"oqus 300 plus") {
1543 }
else if (tStr ==
"oqus 400") {
1545 }
else if (tStr ==
"oqus 500") {
1547 }
else if (tStr ==
"oqus 500 plus") {
1549 }
else if (tStr ==
"oqus 700") {
1551 }
else if (tStr ==
"oqus 700 plus") {
1553 }
else if (tStr ==
"oqus 600 plus") {
1555 }
else if (tStr ==
"miqus m1") {
1557 }
else if (tStr ==
"miqus m3") {
1559 }
else if (tStr ==
"miqus m5") {
1561 }
else if (tStr ==
"miqus sync unit") {
1563 }
else if (tStr ==
"miqus video") {
1565 }
else if (tStr ==
"miqus video color") {
1574 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1575 sCameraSettings.bUnderwater = (tStr ==
"true");
1580 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1581 sCameraSettings.bSupportsHwSync = (tStr ==
"true");
1587 sCameraSettings.nSerial = atoi(oXML.
GetChildData().c_str());
1594 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1595 if (tStr ==
"marker") {
1597 }
else if (tStr ==
"marker intensity") {
1599 }
else if (tStr ==
"video") {
1605 if (mnMajorVersion > 1 || mnMinorVersion > 11) {
1610 sCameraSettings.nVideoFrequency = atoi(oXML.
GetChildData().c_str());
1616 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1617 if (tStr ==
"1080p") {
1619 }
else if (tStr ==
"720p") {
1621 }
else if (tStr ==
"540p") {
1623 }
else if (tStr ==
"480p") {
1633 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1634 if (tStr ==
"16x9") {
1636 }
else if (tStr ==
"4x3") {
1638 }
else if (tStr ==
"1x1") {
1654 sCameraSettings.nVideoExposure = atoi(oXML.
GetChildData().c_str());
1659 sCameraSettings.nVideoExposureMin = atoi(oXML.
GetChildData().c_str());
1664 sCameraSettings.nVideoExposureMax = atoi(oXML.
GetChildData().c_str());
1676 sCameraSettings.nVideoFlashTime = atoi(oXML.
GetChildData().c_str());
1681 sCameraSettings.nVideoFlashTimeMin = atoi(oXML.
GetChildData().c_str());
1686 sCameraSettings.nVideoFlashTimeMax = atoi(oXML.
GetChildData().c_str());
1698 sCameraSettings.nMarkerExposure = atoi(oXML.
GetChildData().c_str());
1703 sCameraSettings.nMarkerExposureMin = atoi(oXML.
GetChildData().c_str());
1708 sCameraSettings.nMarkerExposureMax = atoi(oXML.
GetChildData().c_str());
1721 sCameraSettings.nMarkerThreshold = atoi(oXML.
GetChildData().c_str());
1726 sCameraSettings.nMarkerThresholdMin = atoi(oXML.
GetChildData().c_str());
1731 sCameraSettings.nMarkerThresholdMax = atoi(oXML.
GetChildData().c_str());
1744 sCameraSettings.fPositionX = (float)atoi(oXML.
GetChildData().c_str());
1749 sCameraSettings.fPositionY = (float)atoi(oXML.
GetChildData().c_str());
1754 sCameraSettings.fPositionZ = (float)atoi(oXML.
GetChildData().c_str());
1759 sCameraSettings.fPositionRotMatrix[0][0] =
1765 sCameraSettings.fPositionRotMatrix[1][0] =
1771 sCameraSettings.fPositionRotMatrix[2][0] =
1777 sCameraSettings.fPositionRotMatrix[0][1] =
1783 sCameraSettings.fPositionRotMatrix[1][1] =
1789 sCameraSettings.fPositionRotMatrix[2][1] =
1795 sCameraSettings.fPositionRotMatrix[0][2] =
1801 sCameraSettings.fPositionRotMatrix[1][2] =
1807 sCameraSettings.fPositionRotMatrix[2][2] =
1815 sCameraSettings.nOrientation = atoi(oXML.
GetChildData().c_str());
1826 sCameraSettings.nMarkerResolutionWidth = atoi(oXML.
GetChildData().c_str());
1831 sCameraSettings.nMarkerResolutionHeight = atoi(oXML.
GetChildData().c_str());
1844 sCameraSettings.nVideoResolutionWidth = atoi(oXML.
GetChildData().c_str());
1849 sCameraSettings.nVideoResolutionHeight = atoi(oXML.
GetChildData().c_str());
1862 sCameraSettings.nMarkerFOVLeft = atoi(oXML.
GetChildData().c_str());
1867 sCameraSettings.nMarkerFOVTop = atoi(oXML.
GetChildData().c_str());
1872 sCameraSettings.nMarkerFOVRight = atoi(oXML.
GetChildData().c_str());
1877 sCameraSettings.nMarkerFOVBottom = atoi(oXML.
GetChildData().c_str());
1890 sCameraSettings.nVideoFOVLeft = atoi(oXML.
GetChildData().c_str());
1895 sCameraSettings.nVideoFOVTop = atoi(oXML.
GetChildData().c_str());
1900 sCameraSettings.nVideoFOVRight = atoi(oXML.
GetChildData().c_str());
1905 sCameraSettings.nVideoFOVBottom = atoi(oXML.
GetChildData().c_str());
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"));
1923 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1924 if (tStr ==
"shutter out") {
1926 }
else if (tStr ==
"multiplier") {
1928 }
else if (tStr ==
"divisor") {
1930 }
else if (tStr ==
"camera independent") {
1932 }
else if (tStr ==
"measurement time") {
1934 }
else if (tStr ==
"continuous 100hz") {
1941 sCameraSettings.eSyncOutMode[port] ==
ModeDivisor ||
1946 sCameraSettings.nSyncOutValue[port] =
1952 sCameraSettings.fSyncOutDutyCycle[port] =
1962 sCameraSettings.bSyncOutNegativePolarity[port] =
true;
1964 sCameraSettings.bSyncOutNegativePolarity[port] =
false;
1970 sCameraSettings.nSyncOutValue[port] = 0;
1971 sCameraSettings.fSyncOutDutyCycle[port] = 0;
1972 sCameraSettings.bSyncOutNegativePolarity[port] =
false;
1981 if (sscanf(oXML.
GetAttrib(
"Value").c_str(),
"%f", &focus) == 1) {
1982 sCameraSettings.fFocus = focus;
1989 if (sscanf(oXML.
GetAttrib(
"Value").c_str(),
"%f", &aperture) == 1) {
1990 sCameraSettings.fAperture = aperture;
1996 sCameraSettings.fFocus = std::numeric_limits<float>::quiet_NaN();
1997 sCameraSettings.fAperture = std::numeric_limits<float>::quiet_NaN();
2002 if (CompareNoCase(oXML.
GetAttrib(
"Enabled"),
"true")) {
2003 sCameraSettings.autoExposureEnabled =
true;
2005 float autoExposureCompensation;
2006 if (sscanf(oXML.
GetAttrib(
"Compensation").c_str(),
"%f",
2007 &autoExposureCompensation) == 1) {
2008 sCameraSettings.autoExposureCompensation = autoExposureCompensation;
2012 sCameraSettings.autoExposureEnabled =
false;
2013 sCameraSettings.autoExposureCompensation =
2014 std::numeric_limits<float>::quiet_NaN();
2018 sCameraSettings.autoWhiteBalance =
2019 CompareNoCase(oXML.
GetChildData().c_str(),
"true") ? 1 : 0;
2021 sCameraSettings.autoWhiteBalance = -1;
2026 msGeneralSettings.vsCameras.push_back(sCameraSettings);
2037 bDataAvailable =
false;
2039 ms3DSettings.s3DLabels.clear();
2040 ms3DSettings.pCalibrationTime[0] = 0;
2042 if (!SendCommand(
"GetParameters 3D")) {
2043 strcpy(maErrorStr,
"GetParameters 3D failed");
2048 if (received <= 0) {
2049 if (received == 0) {
2051 strcat(maErrorStr,
" Expected XML packet.");
2061 "GetParameters 3D returned wrong packet type. Got type %d "
2080 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
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;
2102 strcpy(ms3DSettings.pCalibrationTime, tStr.c_str());
2107 unsigned int nNumberOfLabels = atoi(oXML.
GetChildData().c_str());
2109 ms3DSettings.s3DLabels.resize(nNumberOfLabels);
2110 SSettings3DLabel sLabel;
2112 for (
unsigned int iLabel = 0; iLabel < nNumberOfLabels; iLabel++) {
2120 ms3DSettings.s3DLabels[iLabel] = sLabel;
2128 ms3DSettings.sBones.clear();
2133 SSettingsBone bone = {};
2134 bone.fromName = oXML.
GetAttrib(
"From").c_str();
2135 bone.toName = oXML.
GetAttrib(
"To").c_str();
2137 auto colorString = oXML.
GetAttrib(
"Color");
2138 if (!colorString.empty()) {
2139 bone.color = atoi(colorString.c_str());
2141 ms3DSettings.sBones.push_back(bone);
2147 bDataAvailable =
true;
2155 bDataAvailable =
false;
2157 mvs6DOFSettings.bodySettings.clear();
2159 if (!SendCommand(
"GetParameters 6D")) {
2160 strcpy(maErrorStr,
"GetParameters 6D failed");
2165 if (received <= 0) {
2166 if (received == 0) {
2168 strcat(maErrorStr,
" Expected XML packet.");
2178 "GetParameters 6D returned wrong packet type. Got type %d "
2199 SSettings6DOFBody s6DOFBodySettings;
2202 for (
int iBody = 0; iBody < nBodies; iBody++) {
2216 s6DOFBodySettings.vsPoints.clear();
2217 s6DOFBodySettings.nRGBColor = atoi(oXML.
GetChildData().c_str());
2237 s6DOFBodySettings.vsPoints.push_back(sPoint);
2239 mvs6DOFSettings.bodySettings.push_back(s6DOFBodySettings);
2243 if (mnMajorVersion > 1 || mnMinorVersion > 15) {
2262 bDataAvailable =
true;
2270 bDataAvailable =
false;
2272 mvsGazeVectorSettings.clear();
2274 if (!SendCommand(
"GetParameters GazeVector")) {
2275 strcpy(maErrorStr,
"GetParameters GazeVector failed");
2280 if (received <= 0) {
2281 if (received == 0) {
2283 strcat(maErrorStr,
" Expected XML packet.");
2293 "GetParameters GazeVector returned wrong packet type. Got type "
2294 "%d expected type 2.",
2310 std::string tGazeVectorName;
2312 int nGazeVectorCount = 0;
2322 float frequency = 0;
2327 mvsGazeVectorSettings.push_back({tGazeVectorName, frequency});
2332 bDataAvailable =
true;
2340 bDataAvailable =
false;
2341 mvsAnalogDeviceSettings.clear();
2343 if (!SendCommand(
"GetParameters Analog")) {
2344 strcpy(maErrorStr,
"GetParameters Analog failed");
2349 if (received <= 0) {
2350 if (received == 0) {
2352 strcat(maErrorStr,
" Expected XML packet.");
2362 "GetParameters Analog returned wrong packet type. Got type %d "
2376 SAnalogDevice sAnalogDevice;
2380 if (mnMajorVersion == 1 && mnMinorVersion == 0) {
2381 sAnalogDevice.nDeviceID = 1;
2382 sAnalogDevice.oName =
"AnalogDevice";
2386 sAnalogDevice.nChannels = atoi(oXML.
GetChildData().c_str());
2390 sAnalogDevice.nFrequency = atoi(oXML.
GetChildData().c_str());
2402 sAnalogDevice.fMinRange = (float)atof(oXML.
GetChildData().c_str());
2406 sAnalogDevice.fMaxRange = (float)atof(oXML.
GetChildData().c_str());
2407 mvsAnalogDeviceSettings.push_back(sAnalogDevice);
2408 bDataAvailable =
true;
2412 sAnalogDevice.voLabels.clear();
2413 sAnalogDevice.voUnits.clear();
2419 sAnalogDevice.nDeviceID = atoi(oXML.
GetChildData().c_str());
2431 sAnalogDevice.nChannels = atoi(oXML.
GetChildData().c_str());
2437 sAnalogDevice.nFrequency = atoi(oXML.
GetChildData().c_str());
2439 if (mnMajorVersion == 1 && mnMinorVersion < 11) {
2457 sAnalogDevice.fMinRange = (float)atof(oXML.
GetChildData().c_str());
2464 sAnalogDevice.fMaxRange = (float)atof(oXML.
GetChildData().c_str());
2467 if (mnMajorVersion == 1 && mnMinorVersion < 11) {
2468 for (
unsigned int i = 0; i < sAnalogDevice.nChannels; i++) {
2473 if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels) {
2488 if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels ||
2489 sAnalogDevice.voUnits.size() != sAnalogDevice.nChannels) {
2495 mvsAnalogDeviceSettings.push_back(sAnalogDevice);
2496 bDataAvailable =
true;
2507 bDataAvailable =
false;
2509 msForceSettings.vsForcePlates.clear();
2511 if (!SendCommand(
"GetParameters Force")) {
2512 strcpy(maErrorStr,
"GetParameters Force failed");
2517 if (received <= 0) {
2518 if (received == 0) {
2520 strcat(maErrorStr,
" Expected XML packet.");
2530 "GetParameters Force returned wrong packet type. Got type %d "
2547 SForcePlate sForcePlate;
2548 sForcePlate.bValidCalibrationMatrix =
false;
2549 sForcePlate.nCalibrationMatrixRows = 6;
2550 sForcePlate.nCalibrationMatrixColumns = 6;
2579 sForcePlate.nAnalogDeviceID = atoi(oXML.
GetChildData().c_str());
2581 sForcePlate.nAnalogDeviceID = 0;
2587 sForcePlate.nFrequency = atoi(oXML.
GetChildData().c_str());
2592 sForcePlate.oType =
"unknown";
2602 sForcePlate.fLength = (float)atof(oXML.
GetChildData().c_str());
2605 sForcePlate.fWidth = (float)atof(oXML.
GetChildData().c_str());
2613 sForcePlate.asCorner[0].fX = (float)atof(oXML.
GetChildData().c_str());
2616 sForcePlate.asCorner[0].fY = (float)atof(oXML.
GetChildData().c_str());
2619 sForcePlate.asCorner[0].fZ = (float)atof(oXML.
GetChildData().c_str());
2626 sForcePlate.asCorner[1].fX = (float)atof(oXML.
GetChildData().c_str());
2629 sForcePlate.asCorner[1].fY = (float)atof(oXML.
GetChildData().c_str());
2632 sForcePlate.asCorner[1].fZ = (float)atof(oXML.
GetChildData().c_str());
2639 sForcePlate.asCorner[2].fX = (float)atof(oXML.
GetChildData().c_str());
2642 sForcePlate.asCorner[2].fY = (float)atof(oXML.
GetChildData().c_str());
2645 sForcePlate.asCorner[2].fZ = (float)atof(oXML.
GetChildData().c_str());
2652 sForcePlate.asCorner[3].fX = (float)atof(oXML.
GetChildData().c_str());
2655 sForcePlate.asCorner[3].fY = (float)atof(oXML.
GetChildData().c_str());
2658 sForcePlate.asCorner[3].fZ = (float)atof(oXML.
GetChildData().c_str());
2668 sForcePlate.sOrigin.fX = (float)atof(oXML.
GetChildData().c_str());
2671 sForcePlate.sOrigin.fY = (float)atof(oXML.
GetChildData().c_str());
2674 sForcePlate.sOrigin.fZ = (float)atof(oXML.
GetChildData().c_str());
2679 sForcePlate.vChannels.clear();
2682 SForceChannel sForceChannel;
2686 sForceChannel.nChannelNumber = atoi(oXML.
GetChildData().c_str());
2689 sForceChannel.fConversionFactor =
2692 sForcePlate.vChannels.push_back(sForceChannel);
2702 if (mnMajorVersion == 1 && mnMinorVersion < 12) {
2705 sprintf(strRow,
"Row%d", nRow + 1);
2709 sprintf(strCol,
"Col%d", nCol + 1);
2711 sForcePlate.afCalibrationMatrix[nRow][nCol] =
2714 sprintf(strCol,
"Col%d", nCol + 1);
2716 sForcePlate.nCalibrationMatrixColumns = nCol;
2719 sprintf(strRow,
"Row%d", nRow + 1);
2736 sForcePlate.afCalibrationMatrix[nRow][nCol] =
2740 sForcePlate.nCalibrationMatrixColumns = nCol;
2750 sForcePlate.nCalibrationMatrixRows = nRow;
2751 sForcePlate.bValidCalibrationMatrix =
true;
2757 bDataAvailable =
true;
2758 msForceSettings.vsForcePlates.push_back(sForcePlate);
2768 bDataAvailable =
false;
2770 mvsImageSettings.clear();
2772 if (!SendCommand(
"GetParameters Image")) {
2773 strcpy(maErrorStr,
"GetParameters Image failed");
2778 if (received <= 0) {
2779 if (received == 0) {
2781 strcat(maErrorStr,
" Expected XML packet.");
2791 "GetParameters Image returned wrong packet type. Got type %d "
2810 SImageCamera sImageCamera;
2822 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2824 if (tStr ==
"true") {
2825 sImageCamera.bEnabled =
true;
2827 sImageCamera.bEnabled =
false;
2834 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2836 if (tStr ==
"rawgrayscale") {
2838 }
else if (tStr ==
"rawbgr") {
2840 }
else if (tStr ==
"jpg") {
2842 }
else if (tStr ==
"png") {
2851 sImageCamera.nWidth = atoi(oXML.
GetChildData().c_str());
2856 sImageCamera.nHeight = atoi(oXML.
GetChildData().c_str());
2861 sImageCamera.fCropLeft = (float)atof(oXML.
GetChildData().c_str());
2866 sImageCamera.fCropTop = (float)atof(oXML.
GetChildData().c_str());
2871 sImageCamera.fCropRight = (float)atof(oXML.
GetChildData().c_str());
2876 sImageCamera.fCropBottom = (float)atof(oXML.
GetChildData().c_str());
2880 mvsImageSettings.push_back(sImageCamera);
2881 bDataAvailable =
true;
2888 bool skeletonGlobalData) {
2892 bDataAvailable =
false;
2894 mSkeletonSettings.clear();
2896 std::string cmd(
"GetParameters Skeleton");
2897 if (skeletonGlobalData) {
2900 if (!SendCommand(cmd.c_str())) {
2901 strcpy(maErrorStr,
"GetParameters Skeleton failed");
2906 if (received <= 0) {
2907 if (received == 0) {
2909 strcat(maErrorStr,
" Expected XML packet.");
2919 "GetParameters Skeleton returned wrong packet type. Got type %d "
2933 std::string skeletonName;
2935 std::map<int, int> segmentIdIndexMap;
2950 if (segment.
name.size() == 0 ||
2951 sscanf(oXML.
GetAttrib(
"ID").c_str(),
"%u", &segment.
id) != 1) {
2955 segmentIdIndexMap[segment.
id] = segmentIndex++;
2958 if (sscanf(oXML.
GetAttrib(
"Parent_ID").c_str(),
"%d", &parentId) != 1) {
2961 }
else if (segmentIdIndexMap.count(parentId) > 0) {
2963 segment.
parentIndex = segmentIdIndexMap[parentId];
2969 if (sscanf(oXML.
GetAttrib(
"X").c_str(),
"%f", &
x) == 1) {
2972 if (sscanf(oXML.
GetAttrib(
"Y").c_str(),
"%f", &
y) == 1) {
2975 if (sscanf(oXML.
GetAttrib(
"Z").c_str(),
"%f", &
z) == 1) {
2984 if (sscanf(oXML.
GetAttrib(
"X").c_str(),
"%f", &
x) == 1) {
2987 if (sscanf(oXML.
GetAttrib(
"Y").c_str(),
"%f", &
y) == 1) {
2990 if (sscanf(oXML.
GetAttrib(
"Z").c_str(),
"%f", &
z) == 1) {
2993 if (sscanf(oXML.
GetAttrib(
"W").c_str(),
"%f", &w) == 1) {
2999 skeleton.
segments.push_back(segment);
3004 mSkeletonSettings.push_back(skeleton);
3011 bDataAvailable =
true;
3016 unsigned int& nCaptureFrequency,
float& fCaptureTime,
bool& bStartOnExtTrig,
3017 bool& startOnTrigNO,
bool& startOnTrigNC,
bool& startOnTrigSoftware,
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;
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;
3052 return (
unsigned int)msGeneralSettings.vsCameras.size();
3057 bool& bUnderwater,
bool& bSupportsHwSync,
3058 unsigned int& nSerial,
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;
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()) {
3081 msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposure;
3082 nMinExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMin;
3083 nMaxExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMax;
3085 msGeneralSettings.vsCameras[nCameraIndex].nMarkerThreshold;
3087 msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMin;
3089 msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMax;
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()) {
3103 msGeneralSettings.vsCameras[nCameraIndex].eVideoResolution;
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;
3111 msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTime;
3113 msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMin;
3115 msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMax;
3122 unsigned int nCameraIndex,
unsigned int portNumber,
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];
3134 if (portNumber > 0 && portNumber < 4) {
3135 bSyncOutNegativePolarity = msGeneralSettings.vsCameras[nCameraIndex]
3136 .bSyncOutNegativePolarity[portNumber - 1];
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,
3160 int& nOrientation)
const {
3161 if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3162 nOrientation = msGeneralSettings.vsCameras[nCameraIndex].nOrientation;
3169 unsigned int& nMarkerWidth,
3170 unsigned int& nMarkerHeight,
3171 unsigned int& nVideoWidth,
3172 unsigned int& nVideoHeight)
const {
3173 if (nCameraIndex < msGeneralSettings.vsCameras.size()) {
3175 msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionWidth;
3177 msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionHeight;
3179 msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionWidth;
3181 msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionHeight;
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;
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;
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;
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;
3245 return ms3DSettings.eAxisUpwards;
3249 return ms3DSettings.pCalibrationTime;
3253 return (
unsigned int)ms3DSettings.s3DLabels.size();
3257 if (nMarkerIndex < ms3DSettings.s3DLabels.size()) {
3258 return ms3DSettings.s3DLabels[nMarkerIndex].oName.c_str();
3264 if (nMarkerIndex < ms3DSettings.s3DLabels.size()) {
3265 return ms3DSettings.s3DLabels[nMarkerIndex].nRGBColor;
3271 return (
unsigned int)ms3DSettings.sBones.size();
3275 if (boneIndex < ms3DSettings.sBones.size()) {
3276 return ms3DSettings.sBones[boneIndex].fromName.c_str();
3282 if (boneIndex < ms3DSettings.sBones.size()) {
3283 return ms3DSettings.sBones[boneIndex].toName.c_str();
3289 std::string& third)
const {
3290 first = mvs6DOFSettings.eulerFirst;
3291 second = mvs6DOFSettings.eulerSecond;
3292 third = mvs6DOFSettings.eulerThird;
3296 return (
unsigned int)mvs6DOFSettings.bodySettings.size();
3300 if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3301 return mvs6DOFSettings.bodySettings[nBodyIndex].oName.c_str();
3307 if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3308 return mvs6DOFSettings.bodySettings[nBodyIndex].nRGBColor;
3314 if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3315 return (
unsigned int)mvs6DOFSettings.bodySettings.at(nBodyIndex)
3322 unsigned int nMarkerIndex,
3324 if (nBodyIndex < mvs6DOFSettings.bodySettings.size()) {
3326 mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints.size()) {
3328 mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fX;
3330 mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fY;
3332 mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fZ;
3340 return (
unsigned int)mvsGazeVectorSettings.size();
3344 unsigned int nGazeVectorIndex)
const {
3345 if (nGazeVectorIndex < mvsGazeVectorSettings.size()) {
3346 return mvsGazeVectorSettings[nGazeVectorIndex].name.c_str();
3352 if (nGazeVectorIndex < mvsGazeVectorSettings.size()) {
3353 return mvsGazeVectorSettings[nGazeVectorIndex].frequency;
3359 return (
unsigned int)mvsAnalogDeviceSettings.size();
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;
3382 unsigned int nChannelIndex)
const {
3383 if (nDeviceIndex < mvsAnalogDeviceSettings.size()) {
3385 mvsAnalogDeviceSettings.at(nDeviceIndex).voLabels.size()) {
3386 return mvsAnalogDeviceSettings.at(nDeviceIndex)
3387 .voLabels.at(nChannelIndex)
3395 unsigned int nChannelIndex)
const {
3396 if (nDeviceIndex < mvsAnalogDeviceSettings.size()) {
3398 mvsAnalogDeviceSettings.at(nDeviceIndex).voUnits.size()) {
3399 return mvsAnalogDeviceSettings.at(nDeviceIndex)
3400 .voUnits.at(nChannelIndex)
3408 pLength = (
char*)msForceSettings.oUnitLength.c_str();
3409 pForce = (
char*)msForceSettings.oUnitForce.c_str();
3413 return (
unsigned int)msForceSettings.vsForcePlates.size();
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;
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;
3436 SPoint sCorner[4])
const {
3437 if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3438 memcpy(sCorner, msForceSettings.vsForcePlates[nPlateIndex].asCorner,
3439 3 * 4 *
sizeof(
float));
3447 if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3448 sOrigin = msForceSettings.vsForcePlates[nPlateIndex].sOrigin;
3455 unsigned int nPlateIndex)
const {
3456 if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3457 return (
unsigned int)msForceSettings.vsForcePlates[nPlateIndex]
3464 unsigned int nChannelIndex,
3465 unsigned int& nChannelNumber,
3466 float& fConversionFactor)
const {
3467 if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3469 msForceSettings.vsForcePlates[nPlateIndex].vChannels.size()) {
3470 nChannelNumber = msForceSettings.vsForcePlates[nPlateIndex]
3471 .vChannels[nChannelIndex]
3473 fConversionFactor = msForceSettings.vsForcePlates[nPlateIndex]
3474 .vChannels[nChannelIndex]
3483 float fvCalMatrix[12][12],
3485 unsigned int* columns)
const {
3486 if (nPlateIndex < msForceSettings.vsForcePlates.size()) {
3487 if (msForceSettings.vsForcePlates[nPlateIndex].bValidCalibrationMatrix) {
3488 *rows = msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows;
3490 msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixColumns;
3492 msForceSettings.vsForcePlates[nPlateIndex].afCalibrationMatrix,
3493 msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows *
3494 msForceSettings.vsForcePlates[nPlateIndex]
3495 .nCalibrationMatrixColumns *
3504 return (
unsigned int)mvsImageSettings.size();
3508 unsigned int& nCameraID,
bool& bEnabled,
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;
3529 return (
unsigned int)mSkeletonSettings.size();
3533 if (skeletonIndex < mSkeletonSettings.size()) {
3534 return (
char*)mSkeletonSettings[skeletonIndex].name.c_str();
3540 if (skeletonIndex < mSkeletonSettings.size()) {
3541 return static_cast<long unsigned>(
3542 mSkeletonSettings[skeletonIndex].segments.size());
3549 if (skeleton ==
nullptr)
return false;
3551 if (skeletonIndex < mSkeletonSettings.size()) {
3552 *skeleton = mSkeletonSettings[skeletonIndex];
3559 unsigned int segmentIndex,
3561 if (segment ==
nullptr)
return false;
3563 if (skeletonIndex < mSkeletonSettings.size()) {
3564 if (segmentIndex < mSkeletonSettings[skeletonIndex].segments.size()) {
3565 *segment = mSkeletonSettings[skeletonIndex].segments[segmentIndex];
3573 return msGeneralSettings.sCameraSystem.eType;
3577 const unsigned int* pnCaptureFrequency,
const float* pfCaptureTime,
3578 const bool* pbStartOnExtTrig,
const bool* startOnTrigNO,
3579 const bool* startOnTrigNC,
const bool* startOnTrigSoftware,
3590 if (pnCaptureFrequency) {
3591 AddXMLElementUnsignedInt(&oXML,
"Frequency", pnCaptureFrequency);
3593 if (pfCaptureTime) {
3594 AddXMLElementFloat(&oXML,
"Capture_Time", pfCaptureTime, 3);
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);
3606 const char* processings[3] = {
"Processing_Actions",
3607 "RealTime_Processing_Actions",
3608 "Reprocessing_Actions"};
3610 peProcessingActions, peRtProcessingActions, peReprocessingActions};
3612 auto actionsCount = (mnMajorVersion > 1 || mnMinorVersion > 13) ? 3 : 1;
3614 for (
auto i = 0; i < actionsCount; i++) {
3615 if (processingActions[i]) {
3619 if (mnMajorVersion > 1 || mnMinorVersion > 13) {
3621 &oXML,
"PreProcessing2D",
3627 oXML.
AddElem(
"Tracking",
"2D");
3629 oXML.
AddElem(
"Tracking",
"3D");
3631 oXML.
AddElem(
"Tracking",
"False");
3636 &oXML,
"TwinSystemMerge",
3638 AddXMLElementBool(&oXML,
"SplineFill",
3641 AddXMLElementBool(&oXML,
"AIM",
3643 AddXMLElementBool(&oXML,
"Track6DOF",
3645 AddXMLElementBool(&oXML,
"ForceData",
3647 AddXMLElementBool(&oXML,
"GazeVector",
3651 AddXMLElementBool(&oXML,
"ExportTSV",
3653 AddXMLElementBool(&oXML,
"ExportC3D",
3656 &oXML,
"ExportMatlabFile",
3659 &oXML,
"ExportAviFile",
3668 if (SendXML(oXML.
GetDoc().c_str())) {
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) {
3688 oXML.
AddElem(
"External_Time_Base");
3691 AddXMLElementBool(&oXML,
"Enabled", pbEnabled);
3693 if (peSignalSource) {
3694 switch (*peSignalSource) {
3696 oXML.
AddElem(
"Signal_Source",
"Control port");
3699 oXML.
AddElem(
"Signal_Source",
"IR receiver");
3702 oXML.
AddElem(
"Signal_Source",
"SMPTE");
3705 oXML.
AddElem(
"Signal_Source",
"Video sync");
3708 oXML.
AddElem(
"Signal_Source",
"IRIG");
3713 AddXMLElementBool(&oXML,
"Signal_Mode", pbSignalModePeriodic,
"Periodic",
3715 AddXMLElementUnsignedInt(&oXML,
"Frequency_Multiplier", pnFreqMultiplier);
3716 AddXMLElementUnsignedInt(&oXML,
"Frequency_Divisor", pnFreqDivisor);
3717 AddXMLElementUnsignedInt(&oXML,
"Frequency_Tolerance", pnFreqTolerance);
3719 if (pfNominalFrequency) {
3720 if (*pfNominalFrequency < 0) {
3721 oXML.
AddElem(
"Nominal_Frequency",
"None");
3723 AddXMLElementFloat(&oXML,
"Nominal_Frequency", pfNominalFrequency, 3);
3727 AddXMLElementBool(&oXML,
"Signal_Edge", pbNegativeEdge,
"Negative",
3729 AddXMLElementUnsignedInt(&oXML,
"Signal_Shutter_Delay", pnSignalShutterDelay);
3730 AddXMLElementFloat(&oXML,
"Non_Periodic_Timeout", pfNonPeriodicTimeout, 3);
3736 if (SendXML(oXML.
GetDoc().c_str())) {
3747 const float* pfMarkerExposure,
3748 const float* pfMarkerThreshold,
3749 const int* pnOrientation) {
3760 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
3765 oXML.
AddElem(
"Mode",
"Marker");
3768 oXML.
AddElem(
"Mode",
"Marker Intensity");
3771 oXML.
AddElem(
"Mode",
"Video");
3775 AddXMLElementFloat(&oXML,
"Marker_Exposure", pfMarkerExposure);
3776 AddXMLElementFloat(&oXML,
"Marker_Threshold", pfMarkerThreshold);
3777 AddXMLElementInt(&oXML,
"Orientation", pnOrientation);
3783 if (SendXML(oXML.
GetDoc().c_str())) {
3795 const unsigned int* pnVideoFrequency,
const float* pfVideoExposure,
3796 const float* pfVideoFlashTime) {
3807 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
3808 if (eVideoResolution) {
3809 switch (*eVideoResolution) {
3811 oXML.
AddElem(
"Video_Resolution",
"1080p");
3814 oXML.
AddElem(
"Video_Resolution",
"720p");
3817 oXML.
AddElem(
"Video_Resolution",
"540p");
3820 oXML.
AddElem(
"Video_Resolution",
"480p");
3826 if (eVideoAspectRatio) {
3827 switch (*eVideoAspectRatio) {
3829 oXML.
AddElem(
"Video_Aspect_Ratio",
"16x9");
3832 oXML.
AddElem(
"Video_Aspect_Ratio",
"4x3");
3835 oXML.
AddElem(
"Video_Aspect_Ratio",
"1x1");
3841 AddXMLElementUnsignedInt(&oXML,
"Video_Frequency", pnVideoFrequency);
3842 AddXMLElementFloat(&oXML,
"Video_Exposure", pfVideoExposure);
3843 AddXMLElementFloat(&oXML,
"Video_Flash_Time", pfVideoFlashTime);
3849 if (SendXML(oXML.
GetDoc().c_str())) {
3859 const unsigned int nCameraID,
const unsigned int portNumber,
3861 const float* pfSyncOutDutyCycle,
const bool* pbSyncOutNegativePolarity) {
3872 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
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"));
3880 if (port == 0 || port == 1) {
3881 switch (*peSyncOutMode) {
3883 oXML.
AddElem(
"Mode",
"Shutter out");
3886 oXML.
AddElem(
"Mode",
"Multiplier");
3889 oXML.
AddElem(
"Mode",
"Divisor");
3892 oXML.
AddElem(
"Mode",
"Camera independent");
3895 oXML.
AddElem(
"Mode",
"Measurement time");
3898 oXML.
AddElem(
"Mode",
"Continuous 100Hz");
3906 if (pnSyncOutValue) {
3907 AddXMLElementUnsignedInt(&oXML,
"Value", pnSyncOutValue);
3909 if (pfSyncOutDutyCycle) {
3910 AddXMLElementFloat(&oXML,
"Duty_Cycle", pfSyncOutDutyCycle, 3);
3914 if (pbSyncOutNegativePolarity &&
3915 (port == 2 || (peSyncOutMode && *peSyncOutMode !=
ModeFixed100Hz))) {
3916 AddXMLElementBool(&oXML,
"Signal_Polarity", pbSyncOutNegativePolarity,
3917 "Negative",
"Positive");
3925 if (SendXML(oXML.
GetDoc().c_str())) {
3936 const float aperture) {
3947 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
3962 if (SendXML(oXML.
GetDoc().c_str())) {
3972 const bool autoExposure,
3973 const float compensation) {
3984 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
3990 oXML.
AddAttrib(
"Enabled", autoExposure ?
"true" :
"false");
3998 if (SendXML(oXML.
GetDoc().c_str())) {
4008 const bool enable) {
4019 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4021 oXML.
AddElem(
"AutoWhiteBalance", enable ?
"true" :
"false");
4027 if (SendXML(oXML.
GetDoc().c_str())) {
4035 const unsigned int nCameraID,
const bool* pbEnable,
4037 const unsigned int* pnHeight,
const float* pfLeftCrop,
4038 const float* pfTopCrop,
const float* pfRightCrop,
4039 const float* pfBottomCrop) {
4050 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4052 AddXMLElementBool(&oXML,
"Enabled", pbEnable);
4055 switch (*peFormat) {
4057 oXML.
AddElem(
"Format",
"RAWGrayscale");
4060 oXML.
AddElem(
"Format",
"RAWBGR");
4063 oXML.
AddElem(
"Format",
"JPG");
4066 oXML.
AddElem(
"Format",
"PNG");
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);
4081 if (SendXML(oXML.
GetDoc().c_str())) {
4092 const SPoint* psCorner4) {
4104 if (mnMajorVersion > 1 || mnMinorVersion > 7) {
4105 AddXMLElementUnsignedInt(&oXML,
"Plate_ID", &nPlateID);
4107 AddXMLElementUnsignedInt(&oXML,
"Force_Plate_Index", &nPlateID);
4112 AddXMLElementFloat(&oXML,
"X", &(psCorner1->
fX));
4113 AddXMLElementFloat(&oXML,
"Y", &(psCorner1->
fY));
4114 AddXMLElementFloat(&oXML,
"Z", &(psCorner1->
fZ));
4120 AddXMLElementFloat(&oXML,
"X", &(psCorner2->
fX));
4121 AddXMLElementFloat(&oXML,
"Y", &(psCorner2->
fY));
4122 AddXMLElementFloat(&oXML,
"Z", &(psCorner2->
fZ));
4128 AddXMLElementFloat(&oXML,
"X", &(psCorner3->
fX));
4129 AddXMLElementFloat(&oXML,
"Y", &(psCorner3->
fY));
4130 AddXMLElementFloat(&oXML,
"Z", &(psCorner3->
fZ));
4136 AddXMLElementFloat(&oXML,
"X", &(psCorner4->
fX));
4137 AddXMLElementFloat(&oXML,
"Y", &(psCorner4->
fY));
4138 AddXMLElementFloat(&oXML,
"Z", &(psCorner4->
fZ));
4146 if (SendXML(oXML.
GetDoc().c_str())) {
4150 sprintf(maErrorStr,
"Illegal force plate id: %d.", nPlateID);
4157 bool CRTProtocol::SendString(
const char* pCmdStr,
int nType) {
4158 auto nCmdStrLen = strlen(pCmdStr);
4159 static char aSendBuffer[5000];
4161 if (nCmdStrLen >
sizeof(aSendBuffer)) {
4162 strcpy(maErrorStr,
"String is larger than send buffer.");
4169 unsigned int nSize = 8 + (
unsigned int)nCmdStrLen + 1;
4171 memcpy(aSendBuffer + 8, pCmdStr, nCmdStrLen + 1);
4173 if ((mnMajorVersion == 1 && mnMinorVersion == 0) || mbBigEndian) {
4174 *((
unsigned int*)aSendBuffer) = htonl(nSize);
4175 *((
unsigned int*)(aSendBuffer + 4)) = htonl(nType);
4177 *((
unsigned int*)aSendBuffer) = nSize;
4178 *((
unsigned int*)(aSendBuffer + 4)) = nType;
4181 if (mpoNetwork->
Send(aSendBuffer, nSize) ==
false) {
4189 bool CRTProtocol::SendCommand(
const char* pCmdStr) {
4193 bool CRTProtocol::SendCommand(
const char* pCmdStr,
char* pCommandResponseStr,
4194 unsigned int timeout) {
4210 strcpy(pTmpStr, maErrorStr);
4211 sprintf(maErrorStr,
"\'%s\' command failed. %s", pCmdStr, pTmpStr);
4213 pCommandResponseStr[0] = 0;
4217 bool CRTProtocol::SendXML(
const char* pCmdStr) {
4224 "Setting parameters succeeded") == 0) {
4228 "Expected command response \"Setting parameters succeeded\". "
4234 "Expected command response packet. Got packet type %d.",
4238 strcpy(maErrorStr,
"Missing command response packet.");
4242 strcpy(pTmpStr, maErrorStr);
4243 sprintf(maErrorStr,
"Failed to send XML string. %s", pTmpStr);
4248 void CRTProtocol::AddXMLElementBool(
CMarkup* oXML,
const char* tTag,
4249 const bool* pbValue,
const char* tTrue,
4250 const char* tFalse) {
4252 oXML->
AddElem(tTag, *pbValue ? tTrue : tFalse);
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);
4262 void CRTProtocol::AddXMLElementInt(
CMarkup* oXML,
const char* tTag,
4263 const int* pnValue) {
4268 oXML->
AddElem(tTag, tVal.c_str());
4272 void CRTProtocol::AddXMLElementUnsignedInt(
CMarkup* oXML,
const char* tTag,
4273 const unsigned int* pnValue) {
4278 oXML->
AddElem(tTag, tVal.c_str());
4282 void CRTProtocol::AddXMLElementFloat(
CMarkup* oXML,
const char* tTag,
4283 const float* pfValue,
4284 unsigned int pnDecimals) {
4289 sprintf(fFormat,
"%%.%df", pnDecimals);
4291 oXML->
AddElem(tTag, tVal.c_str());
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;