diff --git a/include/ur_client_library/ur/dashboard_client.h b/include/ur_client_library/ur/dashboard_client.h index 342610ff..8362ec9f 100644 --- a/include/ur_client_library/ur/dashboard_client.h +++ b/include/ur_client_library/ur/dashboard_client.h @@ -758,12 +758,12 @@ class DashboardClient /*! * \brief Download a program from the robot * - * \param filename The name of the program file on the robot. This is the name as returned by + * \param program_name The name of the program file on the robot. This is the name as returned by * commandGetProgramListWithResponse. \param save_path The path where the program file should be saved on the machine * where the dashboard client is running. * */ - DashboardResponse commandDownloadProgramWithResponse(const std::string& filename, const std::string& save_path); + DashboardResponse commandDownloadProgramWithResponse(const std::string& program_name, const std::string& save_path); /*! * \brief Makes sure that the dashboard_server's version is above the required version diff --git a/include/ur_client_library/ur/dashboard_client_implementation.h b/include/ur_client_library/ur/dashboard_client_implementation.h index 9c7d1029..433ffd72 100644 --- a/include/ur_client_library/ur/dashboard_client_implementation.h +++ b/include/ur_client_library/ur/dashboard_client_implementation.h @@ -440,7 +440,7 @@ class DashboardClientImpl virtual DashboardResponse commandUpdateProgram(const std::string& file_path) = 0; - virtual DashboardResponse commandDownloadProgram(const std::string& filename, const std::string& save_path) = 0; + virtual DashboardResponse commandDownloadProgram(const std::string& program_name, const std::string& save_path) = 0; const VersionInformation& getPolyscopeVersion() const { diff --git a/include/ur_client_library/ur/dashboard_client_implementation_g5.h b/include/ur_client_library/ur/dashboard_client_implementation_g5.h index 063cce83..d62b89bf 100644 --- a/include/ur_client_library/ur/dashboard_client_implementation_g5.h +++ b/include/ur_client_library/ur/dashboard_client_implementation_g5.h @@ -163,7 +163,7 @@ class DashboardClientImplG5 : public DashboardClientImpl, comm::TCPSocket DashboardResponse commandGetProgramList() override; DashboardResponse commandUploadProgram(const std::string& file_path) override; DashboardResponse commandUpdateProgram(const std::string& file_path) override; - DashboardResponse commandDownloadProgram(const std::string& filename, const std::string& save_path) override; + DashboardResponse commandDownloadProgram(const std::string& program_name, const std::string& save_path) override; void setReceiveTimeout(const timeval& timeout) override { diff --git a/include/ur_client_library/ur/dashboard_client_implementation_x.h b/include/ur_client_library/ur/dashboard_client_implementation_x.h index fd325c8a..2db0afd8 100644 --- a/include/ur_client_library/ur/dashboard_client_implementation_x.h +++ b/include/ur_client_library/ur/dashboard_client_implementation_x.h @@ -160,7 +160,7 @@ class DashboardClientImplX : public DashboardClientImpl DashboardResponse commandGetProgramList() override; DashboardResponse commandUploadProgram(const std::string& file_path) override; DashboardResponse commandUpdateProgram(const std::string& file_path) override; - DashboardResponse commandDownloadProgram(const std::string& filename, const std::string& save_path) override; + DashboardResponse commandDownloadProgram(const std::string& program_name, const std::string& save_path) override; void setReceiveTimeout(const timeval& timeout) override { diff --git a/src/ur/dashboard_client.cpp b/src/ur/dashboard_client.cpp index 381ddd07..a748b6c7 100644 --- a/src/ur/dashboard_client.cpp +++ b/src/ur/dashboard_client.cpp @@ -562,10 +562,10 @@ DashboardResponse DashboardClient::commandUpdateProgramWithResponse(const std::s return impl_->commandUpdateProgram(file_path); } -DashboardResponse DashboardClient::commandDownloadProgramWithResponse(const std::string& filename, +DashboardResponse DashboardClient::commandDownloadProgramWithResponse(const std::string& program_name, const std::string& save_path) { - return impl_->commandDownloadProgram(filename, save_path); + return impl_->commandDownloadProgram(program_name, save_path); } void DashboardClient::assertVersion(const std::string& e_series_min_ver, const std::string& cb3_min_ver, diff --git a/src/ur/dashboard_client_implementation_g5.cpp b/src/ur/dashboard_client_implementation_g5.cpp index e462ac28..51d68ba0 100644 --- a/src/ur/dashboard_client_implementation_g5.cpp +++ b/src/ur/dashboard_client_implementation_g5.cpp @@ -1204,7 +1204,7 @@ DashboardResponse DashboardClientImplG5::commandUpdateProgram(const std::string& ". It is supported from PolyScope 10.12.0 onwards."); } -DashboardResponse DashboardClientImplG5::commandDownloadProgram(const std::string& program_file_name, +DashboardResponse DashboardClientImplG5::commandDownloadProgram(const std::string& program_name, const std::string& destination_path) { throw NotImplementedException("commandDownloadProgram is not available for PolyScope " + diff --git a/src/ur/dashboard_client_implementation_x.cpp b/src/ur/dashboard_client_implementation_x.cpp index c5c9a8cc..b61e433a 100644 --- a/src/ur/dashboard_client_implementation_x.cpp +++ b/src/ur/dashboard_client_implementation_x.cpp @@ -480,7 +480,7 @@ DashboardResponse DashboardClientImplX::commandUpdateProgram(const std::string& file_path, [this](const std::string& e, const httplib::UploadFormDataItems& f) { return put(e, f); }); } -DashboardResponse DashboardClientImplX::commandDownloadProgram(const std::string& filename, +DashboardResponse DashboardClientImplX::commandDownloadProgram(const std::string& program_name, const std::string& save_path) { if (robot_api_version_ < VersionInformation::fromString("3.1.4")) @@ -488,7 +488,18 @@ DashboardResponse DashboardClientImplX::commandDownloadProgram(const std::string throw NotImplementedException("commandDownloadProgram is not implemented for Robot API version < 3.1.4. Please " "upgrade the robot to PolyScope 10.12.0 or higher to use this command."); } - auto response = get("/programs/v1/" + filename, false); // The json response is pretty long. Don't print it. + if (program_name.size() == 0 || save_path.size() == 0) + { + std::string error = "Both program_name and save_path parameters should be populated."; + error += program_name.size() == 0 ? " Program name is empty." : ""; + error += save_path.size() == 0 ? " Save path is empty." : ""; + URCL_LOG_ERROR(error.c_str()); + DashboardResponse response; + response.ok = false; + response.message = error; + return response; + } + auto response = get("/programs/v1/" + program_name, false); // The json response is pretty long. Don't print it. if (response.ok) { std::ofstream save_file(save_path, std::ios_base::out);