13 using namespace sw_update;
19 static std::vector<update_profile_model> updates_copy;
21 std::lock_guard<std::mutex>
lock(_lock);
22 updates_copy = _updates;
28 _icon = std::make_shared<rs2::texture_buffer>();
31 _icon->upload_image(x, y,
data);
37 const auto window_name =
"Updates Window";
40 if (updates_copy.size())
47 positions.
w = window.
width() * 0.6f;
49 positions.
x0 = window.
width() * 0.2f;
50 positions.
y0 = std::max(window.
height() - positions.
h, 0.f) / 2;
88 for (
int i = 0; i < static_cast<int>(updates_copy.size());
i++)
96 if (
i == selected_index)
127 auto&
update = updates_copy[selected_index];
129 bool sw_update_needed(
false), fw_update_needed(
false);
132 if (update.profile.dev_active || _fw_update_state == fw_update_states::started)
137 sw_update_needed = draw_software_section(window_name, update, positions, window, error_message);
142 fw_update_needed = draw_firmware_section(not_model, window_name, update, positions, window, error_message);
151 ImGui::Text(
"%s",
"THE DEVICE HAS BEEN DISCONNECTED,");
153 ImGui::Text(
"%s",
"PLEASE RECONNECT IT OR CLOSE THE UPDATES WINDOW.");
167 auto no_update_needed = (!sw_update_needed && !fw_update_needed);
169 if (!no_update_needed)
172 if (emphasize_dismiss_text)
177 ImGui::Checkbox(
"I understand and would like to proceed anyway without updating", &ignore);
179 if (emphasize_dismiss_text)
187 auto enabled = ignore || no_update_needed;
190 if (_fw_update_state != fw_update_states::started)
195 std::lock_guard<std::mutex>
lock(_lock);
200 emphasize_dismiss_text =
false;
202 _fw_update_state = fw_update_states::ready;
203 _fw_download_progress = 0;
220 emphasize_dismiss_text =
true;
225 "or agree to the warning of closing without it");
239 bool essential_sw_update_needed(
false);
240 bool recommended_sw_update_needed(
false);
244 std::vector<dev_updates_profile::version_info> software_updates;
246 software_updates.push_back(swu.second);
248 return a.
ver <
b.ver;
250 if (static_cast<int>(software_updates.size()) <= selected_software_update_index) selected_software_update_index = 0;
253 if (software_updates.size() != 0)
255 bool essential_found(
false);
256 bool recommended_found(
false);
257 for (
auto sw_update : software_updates)
259 if (!essential_found)
261 essential_found = essential_found || sw_update.name_for_display.find(
"ESSENTIAL") != std::string::npos;
262 essential_sw_update_needed = essential_sw_update_needed || essential_found && (selected_profile.
profile.
software_version < sw_update.ver);
265 if (!recommended_found)
267 recommended_found = recommended_found || sw_update.name_for_display.find(
"RECOMMENDED") != std::string::npos;
268 recommended_sw_update_needed = recommended_sw_update_needed || recommended_found && (selected_profile.
profile.
software_version < sw_update.ver);
273 if (essential_found && !essential_sw_update_needed)
276 return (u.name_for_display.find(
"ESSENTIAL") != std::string::npos);
278 if (
it != software_updates.end())
279 software_updates.erase(
it);
283 if (recommended_found && !recommended_sw_update_needed)
286 return (u.name_for_display.find(
"RECOMMENDED") != std::string::npos);
288 if (
it != software_updates.end())
289 software_updates.erase(
it);
292 if (essential_sw_update_needed || recommended_sw_update_needed)
294 selected_software_update = software_updates[selected_software_update_index];
307 if (!essential_sw_update_needed || software_updates.size() == 0)
309 if (recommended_sw_update_needed)
323 else if (essential_sw_update_needed)
326 ImGui::Text(
"Essential update is available. Please install!");
339 ImGui::Text(
"%s",
"Intel RealSense SDK 2.0, Intel RealSense Viewer and Depth Quality Tool");
346 ImGui::Text(
"%s",
"Enhancements for stream alignment, texture mapping and camera accuracy health algorithms");
357 if (essential_sw_update_needed)
361 ImGui::Text(
"%s",
" (Your version is older than the minimum version required for the proper functioning of your device)");
365 if ( selected_software_update.
ver )
372 "Versions available:" :
373 "Version to download:");
377 if (software_updates.size() >= 2)
379 std::vector<const char*> swu_labels;
380 for (
auto&& swu : software_updates)
382 swu_labels.push_back(swu.name_for_display.c_str());
387 std::string combo_id =
"##Software Update Version";
390 ImGui::Combo(combo_id.c_str(), &selected_software_update_index, swu_labels.data(),
static_cast<int>(swu_labels.size()));
450 auto msg = selected_software_update.
description.c_str();
461 if ( selected_software_update.
ver )
482 std::string tooltip =
"This will redirect you to download the selected software from:\n" + selected_software_update.
download_link;
489 ImGui::Text(
"%s",
"Visit the release page before download to identify the most suitable package.");
494 return essential_sw_update_needed;
498 bool essential_fw_update_needed(
false);
499 bool recommended_fw_update_needed(
false);
503 std::vector<dev_updates_profile::version_info> firmware_updates;
505 firmware_updates.push_back(swu.second);
507 return a.
ver <
b.ver;
509 if (static_cast<int>(firmware_updates.size()) <= selected_firmware_update_index) selected_firmware_update_index = 0;
513 if (firmware_updates.size() != 0)
515 bool essential_found(
false);
516 bool recommended_found(
false);
518 for (
auto fw_update : firmware_updates)
520 if (!essential_found)
522 essential_found = essential_found || fw_update.name_for_display.find(
"ESSENTIAL") != std::string::npos;
523 essential_fw_update_needed = essential_fw_update_needed || essential_found && (selected_profile.
profile.
firmware_version < fw_update.ver);
526 if (!recommended_found)
528 recommended_found = recommended_found || fw_update.name_for_display.find(
"RECOMMENDED") != std::string::npos;
529 recommended_fw_update_needed = recommended_fw_update_needed || recommended_found && (selected_profile.
profile.
firmware_version < fw_update.ver);
534 if (essential_found && !essential_fw_update_needed)
537 return (u.name_for_display.find(
"ESSENTIAL") != std::string::npos);
539 if (
it != firmware_updates.end())
540 firmware_updates.erase(
it);
544 if (recommended_found && !recommended_fw_update_needed)
547 return (u.name_for_display.find(
"RECOMMENDED") != std::string::npos);
549 if (
it != firmware_updates.end())
550 firmware_updates.erase(
it);
552 if (essential_fw_update_needed || recommended_fw_update_needed)
554 selected_firmware_update = firmware_updates[selected_firmware_update_index];
567 if (!essential_fw_update_needed || firmware_updates.size() == 0)
569 if (recommended_fw_update_needed)
583 else if (essential_fw_update_needed)
586 ImGui::Text(
"Essential update is available. Please install!");
599 ImGui::Text(
"%s",
"Signed Firmware Image (.bin file)");
612 if (essential_fw_update_needed)
616 ImGui::Text(
"%s",
" (Your version is older than the minimum version required for the proper functioning of your device)");
620 if ( selected_firmware_update.
ver )
627 "Versions available:" :
628 "Version to download:");
632 if (firmware_updates.size() >= 2)
634 std::vector<const char*> fwu_labels;
635 for (
auto&& fwu : firmware_updates)
637 fwu_labels.push_back(fwu.name_for_display.c_str());
643 std::string combo_id =
"##Firmware Update Version";
646 ImGui::Combo(combo_id.c_str(), &selected_firmware_update_index, fwu_labels.data(),
static_cast<int>(fwu_labels.size()));
705 auto msg = selected_firmware_update.
description.c_str();
717 if( ( _fw_update_state == fw_update_states::ready || _fw_update_state == fw_update_states::completed )
718 && ( essential_fw_update_needed || recommended_fw_update_needed ) )
728 std::thread download_thread([
link,
this]() {
729 std::vector<uint8_t> vec;
734 _fw_download_progress = static_cast<int>((dl_current_bytes * 100) / dl_total_bytes);
735 return callback_result::CONTINUE_DOWNLOAD;
738 _fw_update_state = fw_update_states::failed_downloading;
739 LOG_ERROR(
"Error in download firmware version from: " +
link);
744 _fw_download_progress = 100;
746 download_thread.detach();
748 _fw_update_state = fw_update_states::downloading;
752 ImGui::SetTooltip(
"This will download selected firmware and install it to the device");
757 else if (_fw_update_state == fw_update_states::downloading)
760 _progress.draw(window, static_cast<int>(pos.
w) - 170, _fw_download_progress / 3);
761 if (_fw_download_progress == 100 && !_fw_image.empty())
763 _fw_download_progress = 0;
764 _fw_update_state = fw_update_states::started;
766 _update_manager = std::make_shared<firmware_update_manager>(not_model,
769 auto invoke = [](std::function<void()>
action) {
action(); };
770 _update_manager->start(invoke);
773 else if (_fw_update_state == fw_update_states::started)
776 _progress.draw(window, static_cast<int>(pos.
w) - 170, static_cast<int>(_update_manager->get_progress() * 0.66 + 33));
777 if (_update_manager->done()) {
778 _fw_update_state = fw_update_states::completed;
782 if (_update_manager->failed()) {
783 _fw_update_state = fw_update_states::failed_updating;
785 _fw_download_progress = 0;
788 if (!error_message.empty())
790 LOG_ERROR(
"error caught during update process, details: " + error_message);
791 error_message.clear();
795 else if (_fw_update_state == fw_update_states::failed_downloading ||
796 _fw_update_state == fw_update_states::failed_updating)
800 std::string text = _fw_update_state == fw_update_states::failed_downloading ?
801 "Firmware download failed, check connection and press to retry" :
802 "Firmware update process failed, press to retry";
805 _fw_update_state = fw_update_states::ready;
806 _update_manager.reset();
811 _fw_download_progress = 0;
813 else if (_fw_update_state == fw_update_states::completed)
815 _fw_update_state = fw_update_states::ready;
816 _update_manager.reset();
818 _fw_download_progress = 0;
823 return essential_fw_update_needed;
static const textual_icon lock
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
static const ImVec4 transparent
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
static const ImVec4 white
IMGUI_API float GetCursorPosX()
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F)
GLboolean GLboolean GLboolean b
static const ImVec4 light_red
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
IMGUI_API float GetFontSize()
static const textual_icon check_square_o
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
version_to_info firmware_versions
IMGUI_API void SetCursorPos(const ImVec2 &local_pos)
static const ImVec4 light_grey
IMGUI_API bool IsItemClicked(int mouse_button=0)
IMGUI_API void PopTextWrapPos()
void draw(std::shared_ptr< notifications_model > not_model, ux_window &window, std::string &error_message)
static const ImVec4 light_blue
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
STBIDEF stbi_uc * stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
bool download_to_bytes_vector(const std::string &url, std::vector< uint8_t > &output, user_callback_func_type user_callback_func=user_callback_func_type())
GLsizei const GLchar *const * string
IMGUI_API void PushTextWrapPos(float wrap_pos_x=0.0f)
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
sw_update::version firmware_version
GLboolean GLboolean GLboolean GLboolean a
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
void update(rs2::update_device fwu_dev, std::vector< uint8_t > fw_image)
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API void PopStyleVar(int count=1)
IMGUI_API ImVec2 CalcTextSize(const char *text, const char *text_end=NULL, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
version_to_info software_versions
static const ImVec4 regular_blue
static const textual_icon link
void open_url(const char *url)
static uint32_t camera_icon_l515_png_size
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
static const ImVec4 sensor_bg
unsigned __int64 uint64_t
IMGUI_API void SetCursorPosX(float x)
GLenum GLenum GLsizei const GLuint GLboolean enabled
IMGUI_API float GetContentRegionAvailWidth()
IMGUI_API void PushItemWidth(float item_width)
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
bool draw_software_section(const char *window_name, update_profile_model &selected_profile, position_params &pos_params, ux_window &window, std::string &error_message)
static const ImVec4 dark_grey
IMGUI_API void EndPopup()
static const ImVec4 header_color
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
IMGUI_API bool Combo(const char *label, int *current_item, const char **items, int items_count, int height_in_items=-1, bool show_arrow_down=true)
IMGUI_API void PushFont(ImFont *font)
IMGUI_API ImVec2 GetCursorScreenPos()
IMGUI_API void PopItemWidth()
sw_update::version software_version
static const ImVec4 yellowish
STBIDEF void stbi_image_free(void *retval_from_stbi_load)
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
IMGUI_API bool Checkbox(const char *label, bool *v)
std::string download_link
IMGUI_API void SetCursorScreenPos(const ImVec2 &pos)
sw_update::dev_updates_profile::update_profile profile
IMGUI_API void CloseCurrentPopup()
ImFont * get_large_font() const
IMGUI_API void OpenPopup(const char *str_id)
IMGUI_API void SetCursorPosY(float y)
IMGUI_API void SetWindowFontScale(float scale)
static uint8_t camera_icon_l515_png_data[]
IMGUI_API float GetCursorPosY()
IMGUI_API bool IsItemHovered()
bool draw_firmware_section(std::shared_ptr< notifications_model > not_model, const char *window_name, update_profile_model &selected_profile, position_params &pos_params, ux_window &window, std::string &error_message)
IMGUI_API void PopStyleColor(int count=1)