From 976678c532a1c3cf2d44ac6af57aef17d69a8ebd Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 12 Feb 2025 15:10:32 +0100 Subject: [PATCH 1/3] Add test to load program from subdirectory --- tests/test_dashboard_client.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_dashboard_client.cpp b/tests/test_dashboard_client.cpp index 50e9e192d..43da19567 100644 --- a/tests/test_dashboard_client.cpp +++ b/tests/test_dashboard_client.cpp @@ -242,6 +242,13 @@ TEST_F(DashboardClientTest, connecting_twice_returns_false) EXPECT_FALSE(dashboard_client_->connect()); } +TEST_F(DashboardClientTest, load_program_in_subdir_works) +{ + ASSERT_TRUE(dashboard_client_->connect()); + + ASSERT_TRUE(dashboard_client_->commandLoadProgram("/ursim/programs/wait_program.urp")); +} + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); From 03b47d53f48716d6ef04843545d0ed69f968eb6c Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 12 Feb 2025 15:14:11 +0100 Subject: [PATCH 2/3] Drop checking programState when loading a program When loading a program from an absolute path or a subdirectory instead of a file being directly in /programs (or /ursim/programs in the case of URSim) the check "programState" will only return the filename without the path while we compare it against the path that was requested to load. However, that second check should not be necessary, as the "load" call will already make sure that the program is loading correctly. --- src/ur/dashboard_client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ur/dashboard_client.cpp b/src/ur/dashboard_client.cpp index 41a43c94a..19803e96a 100644 --- a/src/ur/dashboard_client.cpp +++ b/src/ur/dashboard_client.cpp @@ -246,8 +246,7 @@ bool DashboardClient::commandBrakeRelease() bool DashboardClient::commandLoadProgram(const std::string& program_file_name) { assertVersion("5.0.0", "1.4", "load "); - return sendRequest("load " + program_file_name + "", "(?:Loading program: ).*(?:" + program_file_name + ").*") && - waitForReply("programState", "STOPPED " + program_file_name); + return sendRequest("load " + program_file_name + "", "(?:Loading program: ).*(?:" + program_file_name + ").*"); } bool DashboardClient::commandLoadInstallation(const std::string& installation_file_name) From 3b9b521c017046b0411b9e9d4e2967f6ba04823a Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Thu, 13 Feb 2025 13:49:51 +0100 Subject: [PATCH 3/3] Re-add wait for stopped programState We load the program, which will fail if the program is not found or the requested file does not contain a valid program. Afterwards, we wait until the program state is stopped with a program named the same as the requested program. We cannot check the full file path here, but the important thing is that the program state is stopped. --- src/ur/dashboard_client.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ur/dashboard_client.cpp b/src/ur/dashboard_client.cpp index 19803e96a..ff1d5180e 100644 --- a/src/ur/dashboard_client.cpp +++ b/src/ur/dashboard_client.cpp @@ -26,6 +26,7 @@ */ //---------------------------------------------------------------------- +#include #include #include #include @@ -246,7 +247,12 @@ bool DashboardClient::commandBrakeRelease() bool DashboardClient::commandLoadProgram(const std::string& program_file_name) { assertVersion("5.0.0", "1.4", "load "); - return sendRequest("load " + program_file_name + "", "(?:Loading program: ).*(?:" + program_file_name + ").*"); + // We load the program, which will fail if the program is not found or the requested file does + // not contain a valid program. Afterwards, we wait until the program state is stopped with a + // program named the same as the requested program. We cannot check the full file path here, but + // the important thing is that the program state is stopped. + return sendRequest("load " + program_file_name + "", "(?:Loading program: ).*(?:" + program_file_name + ").*") && + waitForReply("programState", "STOPPED " + std::filesystem::path{ program_file_name }.filename().string()); } bool DashboardClient::commandLoadInstallation(const std::string& installation_file_name)