19 std::vector<rs2::device> dev_copy;
25 for (
auto&&
dev : dev_copy)
31 bool has_parser =
false;
33 std::ifstream
f(hwlogger_xml.c_str());
39 std::istreambuf_iterator<char>());
40 fwlogger.init_parser(str);
43 catch (
const std::exception& ex)
46 to_string() <<
"Invalid Hardware Logger XML at '" << hwlogger_xml <<
"': " << ex.what() <<
"\nEither configure valid XML or remove it");
50 auto message = fwlogger.create_message();
51 while (fwlogger.get_firmware_log(message))
53 auto parsed = fwlogger.create_parsed_message();
54 auto parsed_ok =
false;
58 if (fwlogger.parse_log(message, parsed))
63 parsed.file_name(), parsed.line(),
to_string()
64 <<
"FW-LOG [" << parsed.thread_name() <<
"] " << parsed.message());
71 for (
auto& elem : message.data())
72 ss << std::setfill(
'0') << std::setw(2) << std::hex << static_cast<int>(elem) <<
" ";
73 add_log(message.get_severity(), __FILE__, 0, ss.str());
78 catch(
const std::exception& ex)
81 to_string() <<
"Failed to fetch firmware logs: " << ex.what());
86 std::this_thread::sleep_for(std::chrono::milliseconds(100));
109 dashboards.push_back(front->second(front->first));
115 std::stringstream ss;
117 if (count > 0) ss <<
" " << count << suffix;
148 else highlighted =
false;
167 auto x = view_rect.
x;
168 auto y = view_rect.
y;
169 auto w = view_rect.
w;
170 auto h = view_rect.
h;
220 int h_val = (int)((win.
height() - 100) / 2);
260 bool focus_search =
false;
281 std::stringstream ss;
283 if (percent) ss <<
" " << percent <<
"%";
290 auto actual_search_width =
w -
size.
x - 100 - curr_x;
291 if (focus_search)
search_width = (int)(actual_search_width);
367 const auto log_area_width = 0.7f *
w - 4;
369 bool copy_all =
false;
370 bool save_all =
false;
371 std::vector<std::string> output_strings;
381 line = log.filename.substr(log.filename.find_last_of(
"/\\") + 1) +
":";
382 line += std::string(to_string() << log.line_number) +
" - ";
401 ss <<
" - " << log.
line;
431 {
pos.x + log_area_width,
pos.y +
size.y + 2 * margin },
445 static_cast<int>(
line.size() + 1),
454 label =
to_string() <<
"##log_entry" << i <<
"_context_menu";
480 output_strings.push_back(full);
483 std::stringstream ss;
484 for (
auto&&
s : output_strings) ss <<
s <<
"\n";
492 std::ofstream
out(fn);
514 bool force_refresh =
false;
524 force_refresh =
true;
533 std::ifstream
f(commands_xml.c_str());
537 std::istreambuf_iterator<char>());
542 std::string::const_iterator searchStart(str.cbegin());
543 while (regex_search(searchStart, str.cend(),
res, exp))
547 searchStart = res.suffix().first;
561 force_refresh =
true;
606 auto h = dash->get_height();
607 auto r =
rect { 0.f, (float)
top, 0.3
f *
w - 2, (
float)
h };
612 dashboards.erase(std::remove_if(dashboards.begin(), dashboards.end(),
613 [](std::shared_ptr<stream_dashboard>
p){
615 }), dashboards.end());
617 bool can_add =
false;
621 auto it = std::find_if(dashboards.begin(), dashboards.end(),
622 [
name](std::shared_ptr<stream_dashboard>
p){
623 return p->get_name() ==
name;
625 if (
it == dashboards.end()) can_add =
true;
631 const auto new_dashboard_name =
"new_dashaborad";
650 for (
auto&&
kvp : available_dashboards)
653 auto it = std::find_if(dashboards.begin(), dashboards.end(),
654 [
name](std::shared_ptr<stream_dashboard>
p){
655 return p->get_name() ==
name;
657 if (
it == dashboards.end())
660 bool selected =
false;
663 dashboards.push_back(
kvp.second(
kvp.first));
692 for (
auto && dev_model : device_models)
693 this->
devices.push_back(dev_model->dev);
699 std::lock_guard<std::recursive_mutex>
lock(
m);
738 if (!line.size())
return;
741 struct tm * timeinfo;
744 timeinfo = localtime(&rawtime);
745 strftime(buffer,
sizeof(buffer),
"%H:%M:%S",timeinfo);
784 if (std::regex_match(command, e))
788 std::vector<uint8_t> raw_data;
789 std::stringstream ss(command);
793 std::stringstream converter;
795 converter << std::hex << word;
797 raw_data.push_back(temp);
799 if (raw_data.empty())
800 throw std::runtime_error(
"Invalid input!");
808 auto res = dbg.send_and_receive_raw_data(raw_data);
810 std::stringstream ss;
812 for (
auto& elem :
res)
814 ss << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(elem) <<
" ";
836 std::ifstream
f(commands_xml.c_str());
840 std::istreambuf_iterator<char>());
845 std::stringstream ss; ss << command <<
" = ";
847 ss << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(elem) <<
" ";
857 auto res = dbg.send_and_receive_raw_data(buffer);
872 catch(
const std::exception& ex)
880 bool user_defined_command_detected =
false;
881 bool user_defined_command_activated =
false;
887 if(
to_lower( command ) ==
"trigger-camera-accuracy-health" )
889 user_defined_command_detected =
true;
891 for(
auto && dev_model : device_models )
893 if( dev_model->is_cah_model_enabled() && !user_defined_command_activated)
895 dev_model->show_trigger_camera_accuracy_health_popup =
true;
896 user_defined_command_activated =
true;
900 else if(
to_lower( command ) ==
"reset-camera-accuracy-health" )
902 user_defined_command_detected =
true;
904 for(
auto && dev_model : device_models )
906 if( dev_model->is_cah_model_enabled() && !user_defined_command_activated)
908 dev_model->show_reset_camera_accuracy_health_popup =
true;
909 user_defined_command_activated =
true;
913 else if(
to_lower( command ) ==
"get-nest" )
915 user_defined_command_detected =
true;
922 std::vector< uint8_t > special_command
923 = {
'G',
'E',
'T',
'-',
'N',
'E',
'S',
'T' };
924 auto res = dbg.send_and_receive_raw_data( special_command );
925 user_defined_command_activated =
true;
931 if( user_defined_command_detected && ! user_defined_command_activated )
936 to_string() <<
"None of the connected devices supports '" << command <<
"'" );
939 return user_defined_command_detected;
960 min_y = xy[0].second;
961 max_y = xy[0].second;
966 max_x = std::max(max_x,
p.first);
967 max_y = std::max(max_y,
p.second);
971 auto gap_y = max_y - min_y;
972 auto gap_x = max_x - min_x;
976 auto max_y_label_width = 0.f;
977 for (
int i = 0;
i <= ticks_y;
i++)
979 auto y = max_y -
i * (gap_y / ticks_y);
982 max_y_label_width = std::max(max_y_label_width,
1019 for (
int i = 0;
i <= ticks_y;
i++)
1021 auto y = max_y -
i * (gap_y / ticks_y);
1031 auto graph_width = r.
w - max_y_label_width - 25;
1034 bool has_room =
true;
1038 for (
int i = 0;
i <= ticks_x;
i++)
1040 auto x = min_x +
i * (gap_x / ticks_x);
1045 if (total < graph_width) ticks_x++;
1046 else has_room =
false;
1050 for (
int i = 0;
i < ticks_x;
i++)
1052 auto x = min_x +
i * (gap_x / ticks_x);
1061 std::sort(xy.begin(), xy.end(), [](
const std::pair<float, float>&
a,
const std::pair<float, float>&
b) {
return a.first <
b.first; });
1063 for (
int i = 0;
i + 1 < xy.size();
i++)
1065 auto x0 = xy[
i].first;
1066 auto y0 = xy[
i].second;
1068 auto x1 = xy[
i+1].first;
1069 auto y1 = xy[
i+1].second;
1071 x0 = (
x0 - min_x) / (max_x - min_x);
1072 x1 = (
x1 - min_x) / (max_x - min_x);
1074 y0 = (
y0 - min_y) / (max_y - min_y);
1075 y1 = (
y1 - min_y) / (max_y - min_y);
1089 write_shared_data([&](){
1093 if (
it != stream_to_time.end())
1102 if (1000.f * (ts - last) > 1.5f * (1000.f /
fps)) {
1109 if (ts - last_time > 1.f)
1111 if (drops_history.size() > 100) drops_history.pop_front();
1112 drops_history.push_back(drops);
1114 *frame_drop_count = drops;
1126 auto hist = read_shared_data<std::deque<int>>([&](){
return drops_history; });
1127 for (
int i = 0;
i < hist.size();
i++)
1129 add_point(
i, hist[
i]);
1132 draw_dashboard(win, r);
1141 std::vector<const char*> methods;
1142 methods.push_back(
"Viewer Processing Rate");
1143 methods.push_back(
"Camera Timestamp Rate");
1146 if (
ImGui::Combo(
"##fps_method", &method, methods.data(), (int)(methods.size())))
1160 write_shared_data([&](){
1161 stream_to_time.clear();
1164 *frame_drop_count = 0;
1167 drops_history.clear();
1168 for (
int i = 0;
i < 100;
i++)
1169 drops_history.push_back(0);
static const textual_icon lock
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
static const ImVec4 transparent
GLenum GLuint GLenum GLsizei const GLchar * message
animated< int > default_log_h
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)
IMGUI_API bool IsKeyPressed(int key_index, bool repeat=true)
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum severity
IMGUI_API bool BeginPopupContextItem(const char *str_id, int mouse_button=1)
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
std::string to_lower(std::string x)
GLuint const GLchar * name
static const ImVec4 almost_white_bg
ImVec4 saturate(const ImVec4 &a, float f)
GLdouble GLdouble GLdouble top
static const ImVec4 greenish
IMGUI_API void SetCursorPos(const ImVec2 &local_pos)
std::vector< uint8_t > parse_command(const std::string &command)
void clear(bool full) override
static const ImVec4 light_grey
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
std::atomic< int > to_stop
static config_file & instance()
static const char * commands_xml
static const ImVec4 light_blue
stream_profile get_profile() const
ImFont * get_monofont() const
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
void foreach_log(std::function< void(log_entry &line)> action)
std::string parse_response(const std::string &command, const std::vector< uint8_t > &response)
void log(rs2_log_severity severity, const char *message)
void update_dashboards(rs2::frame f)
IMGUI_API bool BeginChild(const char *str_id, const ImVec2 &size=ImVec2(0, 0), bool border=false, ImGuiWindowFlags extra_flags=0)
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
GLfloat GLfloat GLfloat GLfloat h
static const char * hwlogger_xml
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
bool enable_firmware_logs
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
GLboolean GLboolean GLboolean GLboolean a
ImFont * get_font() const
T get_or_default(const char *key, T def) const
std::map< std::string, std::function< std::shared_ptr< stream_dashboard >std::string)> > available_dashboards
IMGUI_API bool BeginPopup(const char *str_id)
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
bool user_defined_command(std::string command, std::vector< std::unique_ptr< device_model >> &device_models)
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
void add_log(rs2_log_severity severity, std::string filename, int line_number, std::string line)
IMGUI_API void PopStyleVar(int count=1)
static void SetScrollPosHere()
IMGUI_API ImVec2 CalcTextSize(const char *text, const char *text_end=NULL, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
static const ImVec4 orange
static const ImVec4 regular_blue
double get_timestamp() const
std::string get(const char *key, const char *def) const
static const ImVec4 scrollbar_bg
std::deque< std::string > commands_histroy
float single_wave(float x)
void open(ux_window &win)
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
std::vector< std::shared_ptr< stream_dashboard > > dashboards
static const ImVec4 sensor_bg
void process_frame(rs2::frame f) override
static const char * output_open
IMGUI_API void SetCursorPosX(float x)
rs2_log_severity severity
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))
const char * file_dialog_open(file_dialog_mode flags, const char *filters, const char *default_path, const char *default_name)
bool warnings_highlighted
std::deque< log_entry > notification_logs
IMGUI_API void EndPopup()
static const ImVec4 header_color
std::deque< std::string > autocomplete
ImVec4 alpha(const ImVec4 &v, float a)
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
static const ImVec4 black
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 void EndChild()
IMGUI_API float GetTextLineHeightWithSpacing()
GLuint GLfloat GLfloat GLfloat x1
bool round_indicator(ux_window &win, std::string icon, int count, ImVec4 color, std::string tooltip, bool &highlighted, std::string suffix="")
IMGUI_API ImVec2 GetCursorScreenPos()
void set(const char *key, const char *value)
IMGUI_API void PopItemWidth()
#define GLFW_KEY_KP_ENTER
static const char * search_term
void draw_dashboard(ux_window &win, rect &r)
GLuint GLsizei const GLchar * label
IMGUI_API float GetTextLineHeight()
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
GLuint GLfloat GLfloat y0
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
std::vector< std::unique_ptr< device_model > > device_models_list
bool starts_with(const std::string &s, const std::string &prefix)
static const ImVec4 redish
std::vector< rs2::device > devices
IMGUI_API bool InputTextEx(const char *label, char *buf, int buf_size, const ImVec2 &size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
std::array< float, 3 > color
void run_command(std::string command, std::vector< std::unique_ptr< device_model >> &device_models)
single_consumer_queue< log_entry > incoming_log_queue
const char * rs2_log_severity_to_string(rs2_log_severity info)
IMGUI_API void OpenPopup(const char *str_id)
IMGUI_API void AddRect(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F, float thickness=1.0f)
IMGUI_API void SetCursorPosY(float y)
rs2_log_severity
Severity of the librealsense logger.
animated< int > search_width
void draw(ux_window &win, rect view_rect, std::vector< std::unique_ptr< device_model >> &device_models)
static const ImVec4 dark_sensor_bg
IMGUI_API float GetCursorPosY()
IMGUI_API bool IsItemHovered()
IMGUI_API void SetKeyboardFocusHere(int offset=0)
void draw(ux_window &win, rect r) override
IMGUI_API void PopStyleColor(int count=1)
std::string to_string(T value)
int get_height() const override