From 211c203b737072a02d3a425f3f67884f2a62bebc Mon Sep 17 00:00:00 2001 From: Oliver Glandberger Date: Mon, 4 May 2026 17:59:25 +0200 Subject: [PATCH 1/2] Add tests for new Measurement Time port mode setting. --- SettingsDeserializer.cpp | 2 +- Tests/Data/General.h | 28 +++++++++ Tests/GeneralParametersTests.cpp | 101 +++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) diff --git a/SettingsDeserializer.cpp b/SettingsDeserializer.cpp index c004f4e..f674c5a 100644 --- a/SettingsDeserializer.cpp +++ b/SettingsDeserializer.cpp @@ -824,7 +824,7 @@ bool SettingsDeserializer::DeserializeGeneralSettings(SSettingsGeneral& generalS else // Measurement Time port { std::string syncOutMode; - if (syncOutElem.TryReadElementString("Mode", syncOutMode)) // is optional (back-compatability with QTM <= 1.27 + if (syncOutElem.TryReadElementString("Mode", syncOutMode)) // is optional (back-compatibility with QTM <= 1.27) { syncOutMode = ToLowerXmlString(syncOutMode); if (syncOutMode == "measurement time") diff --git a/Tests/Data/General.h b/Tests/Data/General.h index 9e02044..2a4cfc3 100644 --- a/Tests/Data/General.h +++ b/Tests/Data/General.h @@ -86,6 +86,34 @@ R"XMLDATA( +)XMLDATA"; + + inline const char* SetCameraSyncOutSettingsMTMeasurementTimeTest = +R"XMLDATA( + + + 7 + + Measurement time + Positive + + + + +)XMLDATA"; + + inline const char* SetCameraSyncOutSettingsMTSystemLiveTimeTest = +R"XMLDATA( + + + 7 + + System live time + Negative + + + + )XMLDATA"; inline const char* SetCameraLensControlSettingsTest = diff --git a/Tests/GeneralParametersTests.cpp b/Tests/GeneralParametersTests.cpp index f971d80..4de918e 100644 --- a/Tests/GeneralParametersTests.cpp +++ b/Tests/GeneralParametersTests.cpp @@ -311,6 +311,50 @@ TEST_CASE("SetCameraSyncOutSettingsTest") CHECK(utils::CompareXmlIgnoreWhitespace(qualisys_cpp_sdk::tests::data::SetCameraSyncOutSettingsTest, network->ReadSentData().data())); } +TEST_CASE("SetCameraSyncOutSettingsMTMeasurementTimeTest") +{ + auto [protocol, network] = utils::CreateTestContext(); + + network->PrepareResponse("", "Setting parameters succeeded", CRTPacket::PacketCommand); + + const unsigned int nCameraID = 7u; + const unsigned int portNumber = 3u; + const CRTProtocol::ESyncOutFreqMode peSyncOutMode = CRTProtocol::ESyncOutFreqMode::ModeMeasurementTime; + const bool pbSyncOutNegativePolarity = false; + + if (!protocol->SetCameraSyncOutSettings( + nCameraID, portNumber, &peSyncOutMode, + nullptr, nullptr, + &pbSyncOutNegativePolarity)) + { + FAIL(protocol->GetErrorString()); + } + + CHECK(utils::CompareXmlIgnoreWhitespace(qualisys_cpp_sdk::tests::data::SetCameraSyncOutSettingsMTMeasurementTimeTest, network->ReadSentData().data())); +} + +TEST_CASE("SetCameraSyncOutSettingsMTSystemLiveTimeTest") +{ + auto [protocol, network] = utils::CreateTestContext(); + + network->PrepareResponse("", "Setting parameters succeeded", CRTPacket::PacketCommand); + + const unsigned int nCameraID = 7u; + const unsigned int portNumber = 3u; + const CRTProtocol::ESyncOutFreqMode peSyncOutMode = CRTProtocol::ESyncOutFreqMode::ModeSystemLiveTime; + const bool pbSyncOutNegativePolarity = true; + + if (!protocol->SetCameraSyncOutSettings( + nCameraID, portNumber, &peSyncOutMode, + nullptr, nullptr, + &pbSyncOutNegativePolarity)) + { + FAIL(protocol->GetErrorString()); + } + + CHECK(utils::CompareXmlIgnoreWhitespace(qualisys_cpp_sdk::tests::data::SetCameraSyncOutSettingsMTSystemLiveTimeTest, network->ReadSentData().data())); +} + TEST_CASE("GetCameraSyncOutSettingsTest") { auto [protocol, network] = utils::CreateTestContext(); @@ -339,6 +383,63 @@ TEST_CASE("GetCameraSyncOutSettingsTest") CHECK_EQ(1, nSyncOutValue); CHECK_EQ(50.0f, fSyncOutDutyCycle); CHECK_EQ(true, bSyncOutNegativePolarity); + + // Measurement Time port (port 3) — fixture omits , so the deserializer + // must default to ModeMeasurementTime (back-compat with QTM <= 1.27). + portNumber = 3u; + eSyncOutMode = CRTProtocol::ESyncOutFreqMode::ModeDivisor; + bSyncOutNegativePolarity = false; + + protocol->GetCameraSyncOutSettings( + nCameraIndex, portNumber, eSyncOutMode, + nSyncOutValue, fSyncOutDutyCycle, + bSyncOutNegativePolarity + ); + + CHECK_EQ(CRTProtocol::ESyncOutFreqMode::ModeMeasurementTime, eSyncOutMode); + CHECK_EQ(true, bSyncOutNegativePolarity); +} + +TEST_CASE("GetCameraSyncOutSettingsMTSystemLiveTimeTest") +{ + auto [protocol, network] = utils::CreateTestContext(); + + std::string xml = qualisys_cpp_sdk::tests::data::GetGeneralSettingsTest; + const std::string oldBlock = + "\n" + " Negative\n" + " "; + const std::string newBlock = + "\n" + " System live time\n" + " Positive\n" + " "; + auto pos = xml.find(oldBlock); + REQUIRE(pos != std::string::npos); + xml.replace(pos, oldBlock.length(), newBlock); + + network->PrepareResponse("GetParameters General", xml.c_str(), CRTPacket::PacketXML); + + if (!protocol->ReadGeneralSettings()) + { + FAIL(protocol->GetErrorString()); + } + + unsigned int nCameraIndex = 7u; + unsigned int portNumber = 3u; + CRTProtocol::ESyncOutFreqMode eSyncOutMode = CRTProtocol::ESyncOutFreqMode::ModeDivisor; + unsigned int nSyncOutValue = 99u; + float fSyncOutDutyCycle = 99.0f; + bool bSyncOutNegativePolarity = true; + + protocol->GetCameraSyncOutSettings( + nCameraIndex, portNumber, eSyncOutMode, + nSyncOutValue, fSyncOutDutyCycle, + bSyncOutNegativePolarity + ); + + CHECK_EQ(CRTProtocol::ESyncOutFreqMode::ModeSystemLiveTime, eSyncOutMode); + CHECK_EQ(false, bSyncOutNegativePolarity); } TEST_CASE("SetCameraLensControlSettingsTest") From 71f4da8bf79b84b40b1406edcb8e543706c44456 Mon Sep 17 00:00:00 2001 From: Oliver Glandberger Date: Tue, 5 May 2026 13:44:11 +0200 Subject: [PATCH 2/2] Minor spelling-change. --- Tests/GeneralParametersTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/GeneralParametersTests.cpp b/Tests/GeneralParametersTests.cpp index 4de918e..7e61ad3 100644 --- a/Tests/GeneralParametersTests.cpp +++ b/Tests/GeneralParametersTests.cpp @@ -385,7 +385,7 @@ TEST_CASE("GetCameraSyncOutSettingsTest") CHECK_EQ(true, bSyncOutNegativePolarity); // Measurement Time port (port 3) — fixture omits , so the deserializer - // must default to ModeMeasurementTime (back-compat with QTM <= 1.27). + // must default to ModeMeasurementTime (backwards-compatibility with QTM <= 1.27). portNumber = 3u; eSyncOutMode = CRTProtocol::ESyncOutFreqMode::ModeDivisor; bSyncOutNegativePolarity = false;