29 #include "common/fw/D4XX_FW_Image.h" 30 #include "common/fw/SR3XX_FW_Image.h" 31 #include "common/fw/L5XX_FW_Image.h" 33 #define FW_D4XX_FW_IMAGE_VERSION "" 34 #define FW_SR3XX_FW_IMAGE_VERSION "" 35 #define FW_L5XX_FW_IMAGE_VERSION "" 38 #ifdef BUILD_EASYLOGGINGPP 40 #ifdef BUILD_SHARED_LIBS 49 using namespace rs400;
51 #define MIN_IP_SIZE 7 //TODO: Ester - update size when host name is supported 73 bool was_loaded =
false;
79 device_models.emplace_back(
new device_model(
dev, error_message, viewer_model));
87 auto it = std::find_if(device_models.begin(), device_models.end(),
88 [&](
const std::unique_ptr<device_model>& dm) {
93 if (
it != device_models.end())
95 auto subs = (*it)->subdevices;
96 if ((*it)->_playback_repeat)
99 std::thread{ [subs, &viewer_model,
it]()
101 if (!(*it)->dev_syncer)
102 (*it)->dev_syncer = viewer_model.syncer->create_syncer();
104 for (
auto&& sub : subs)
108 auto profiles = sub->get_selected_profiles();
110 sub->play(
profiles, viewer_model, (*it)->dev_syncer);
117 for (
auto&& sub : subs)
135 catch (
const std::exception& e)
137 error_message =
to_string() <<
"Failed to load file " << file <<
". Reason: " << e.what();
140 if (failed && was_loaded)
153 std::vector<device>& current_connected_devices,
154 std::vector<std::pair<std::string, std::string>>& device_names,
165 auto dev_itr =
begin(current_connected_devices);
166 while (dev_itr !=
end(current_connected_devices))
176 auto dev_model_itr = std::find_if(
begin(device_models),
end(device_models),
179 if (dev_model_itr !=
end(device_models))
181 for (
auto&&
s : (*dev_model_itr)->subdevices)
182 s->streaming =
false;
184 dev_model_itr->reset();
185 device_models.erase(dev_model_itr);
187 if (device_models.size() == 0)
196 if (dev_name_itr !=
end(device_names))
197 device_names.erase(dev_name_itr);
199 dev_itr = current_connected_devices.erase(dev_itr);
206 static bool initial_refresh =
true;
209 for (
auto dev :
info.get_new_devices())
212 device_names.push_back(dev_descriptor);
215 if (device_models.size() == 0 &&
218 device_models.emplace_back(
new device_model(
dev, error_message, viewer_model));
223 if (!initial_refresh)
226 viewer_model.
not_model->add_notification({ dev_descriptor.first +
" Connected\n",
227 RS2_LOG_SEVERITY_INFO, RS2_NOTIFICATION_CATEGORY_UNKNOWN_ERROR });
229 viewer_model.
not_model->add_notification({ dev_descriptor.first +
" Connected\n",
230 RS2_LOG_SEVERITY_INFO, RS2_NOTIFICATION_CATEGORY_UNKNOWN_ERROR });
232 viewer_model.
not_model->add_notification({ dev_descriptor.first +
" Connected\n",
234 [&device_models, &viewer_model, &error_message,
dev] {
236 device_models.emplace_back(
241 current_connected_devices.push_back(
dev);
242 for (
auto&&
s :
dev.query_sensors())
244 s.set_notifications_callback([&, dev_descriptor](
const notification&
n)
251 auto dev_model_itr = std::find_if(
begin(device_models),
end(device_models),
252 [&](
const std::unique_ptr<device_model>& other)
255 if (dev_model_itr ==
end(device_models))
258 (*dev_model_itr)->handle_hardware_events(
data);
268 catch (std::exception&
e) {
270 s <<
"Couldn't refresh devices - " << e.what();
273 initial_refresh =
false;
279 catch (
const std::exception& e)
281 error_message = e.what();
285 error_message =
"Unknown error";
291 int main(
int argc,
const char** argv)
try 294 #ifdef BUILD_EASYLOGGINGPP 303 std::vector<std::pair<std::string, std::string>> device_names;
308 std::shared_ptr<device_models_list> device_models = std::make_shared<device_models_list>();
310 bool is_ip_device_connected =
false;
317 std::vector<device> connected_devs;
320 #ifdef BUILD_EASYLOGGINGPP 321 std::weak_ptr<notifications_model> notifications = viewer_model.
not_model;
325 if (
auto not_model = notifications.lock())
335 if (!error_message.empty())
337 viewer_model.
not_model->add_notification({ error_message,
342 for (
int i = 1;
i < argc;
i++)
346 const char*
arg = argv[
i];
347 std::ifstream file(arg);
357 catch (
const std::exception& e)
359 error_message = e.what();
366 device_names, *device_models, viewer_model, error_message);
376 catch (std::runtime_error
e)
378 error_message = e.what();
385 auto device_changed =
refresh_devices(m, ctx, devices_connection_changes, connected_devs,
386 device_names, *device_models, viewer_model, error_message);
417 auto new_devices_count = device_names.size() + 1;
419 for (
auto&& dev_model : *device_models)
421 auto connected_devs_itr = std::find_if(
begin(connected_devs),
end(connected_devs),
424 if (connected_devs_itr !=
end(connected_devs) || dev_model->dev.is<
playback>())
431 int multiline_devices_names = 0;
432 for (
size_t i = 0;
i < device_names.size();
i++)
434 if (device_names[
i].
first.find(
"\n") != std::string::npos)
436 bool show_device_in_list =
true;
437 for (
auto&& dev_model : *device_models)
441 show_device_in_list =
false;
445 if (show_device_in_list)
447 multiline_devices_names++;
457 for (
size_t i = 0;
i < device_names.size();
i++)
460 for (
auto&& dev_model : *device_models)
468 auto dev = connected_devs[
i];
469 device_models->emplace_back(
new device_model(
dev, error_message, viewer_model));
475 catch (
const std::exception& e)
477 error_message = e.what();
511 bool close_ip_popup =
false;
513 if (!is_ip_device_connected)
518 #ifdef NETWORK_DEVICE 522 error_message =
"To enable RealSense device over network, please build the SDK with CMake flag -DBUILD_NETWORK_DEVICE=ON.\nThis binary distribution was built with network features disabled.";
528 float posx = window.
width() * 0.5f - width * 0.5f;
529 float posy = window.
height() * 0.5f - height * 0.5f;
541 ImGui::Text(
"Connect to a Linux system running rs-server");
545 static char ip_input[255];
546 std::copy(ip_address.begin(), ip_address.end(), ip_input);
547 ip_input[ip_address.size()] =
'\0';
563 ip_address = ip_input;
577 refresh_devices(m, ctx, devices_connection_changes, connected_devs, device_names, *device_models, viewer_model, error_message);
578 auto dev = connected_devs[connected_devs.size() - 1];
579 device_models->emplace_back(
new device_model(
dev, error_message, viewer_model));
582 catch (std::runtime_error
e)
584 error_message = e.what();
587 close_ip_popup =
true;
595 close_ip_popup =
true;
611 close_ip_popup =
false;
627 viewer_model.
show_top_bar(window, viewer_rect, *device_models);
633 viewer_model.
not_model->output.draw(window, output_rect, *device_models);
646 if (device_models->size() > 0)
648 std::vector<std::function<void()>> draw_later;
651 for (
auto&& dev_model : *device_models)
654 window, error_message, device_to_remove, viewer_model, windows_width, draw_later);
658 if (!std::any_of(device_models->begin(), device_models->end(),
659 [](
const std::unique_ptr<device_model>& dm)
661 return dm->is_streaming();
680 for (
auto&& lambda : draw_later)
690 catch (
const std::exception& e)
692 error_message = e.what();
696 if (device_to_remove)
698 if (
auto p = device_to_remove->dev.as<
playback>())
702 viewer_model.
syncer->remove_syncer(device_to_remove->dev_syncer);
703 auto it = std::find_if(
begin(*device_models),
end(*device_models),
704 [&](
const std::unique_ptr<device_model>& other)
707 if (
it != device_models->end())
710 device_models->erase(
it);
713 device_to_remove =
nullptr;
730 viewer_model.
handle_ready_frames(viewer_rect, window, static_cast<int>(device_models->size()), error_message);
751 catch (
const std::exception& e)
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
void add_to(context &ctx)
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)
rs2::frame handle_ready_frames(const rect &viewer_rect, ux_window &window, int devices, std::string &error_message)
GLenum GLuint GLenum severity
static bool GetWindowIsFocused()
std::string get_serialized_data() const
void unload_device(const std::string &file)
ImVec4 from_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a, bool consistent_color)
void log_to_callback(rs2_log_severity min_severity, S callback)
std::atomic< bool > depth_stream_active
static const char * last_ip
std::function< bool()> on_load
static const ImVec4 light_grey
static GLFWwindow * window
static config_file & instance()
playback load_device(const std::string &file)
static const ImVec4 light_blue
float get_output_height() const
rs2_log_severity get_severity() const
std::unordered_set< int > _hidden_options
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
void log(rs2_log_severity severity, const char *message)
static const ImVec4 dark_window_background
GLsizei const GLchar *const * string
const char * filename() const
std::string get_description() const
static const textual_icon plus_circle
GLfloat GLfloat GLfloat GLfloat h
void show_no_device_overlay(ImFont *font, int min_x, int min_y)
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
IMGUI_API ImVec2 GetContentRegionMax()
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
std::shared_ptr< notifications_model > not_model
ImFont * get_font() const
T get_or_default(const char *key, T def) const
def info(name, value, persistent=False)
size_t line_number() const
const std::string & get_failed_args() const
IMGUI_API bool BeginPopup(const char *str_id)
bool is_rendering() const
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
std::string error_to_string(const error &e)
IMGUI_API ImVec2 GetContentRegionAvail()
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
IMGUI_API void PopStyleVar(int count=1)
#define INITIALIZE_EASYLOGGINGPP
bool add_remote_device(context &ctx, std::string address)
bool refresh_devices(std::mutex &m, context &ctx, device_changes &devices_connection_changes, std::vector< device > ¤t_connected_devices, std::vector< std::pair< std::string, std::string >> &device_names, device_models_list &device_models, viewer_model &viewer_model, std::string &error_message)
bool try_get_next_changes(event_information &removed_and_connected)
GLint GLsizei GLsizei height
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
static const ImVec4 sensor_bg
IMGUI_API void SetCursorPosX(float x)
void update_viewer_configuration(viewer_model &viewer_model)
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)
IMGUI_API void Separator()
std::function< void(std::string)> on_file_drop
static const ImVec4 dark_grey
IMGUI_API void EndPopup()
IMGUI_API void NextColumn()
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
IMGUI_API float GetWindowHeight()
IMGUI_API bool ButtonEx(const char *label, const ImVec2 &size_arg=ImVec2(0, 0), ImGuiButtonFlags flags=0)
rs2_notification_category get_category() const
IMGUI_API void PushFont(ImFont *font)
post_processing_filters ppf
int main(int argc, const char **argv)
void log_to_console(rs2_log_severity min_severity)
std::pair< std::string, std::string > get_device_name(const device &dev)
IMGUI_API ImVec2 GetCursorScreenPos()
void set(const char *key, const char *value)
IMGUI_API void PopItemWidth()
#define GLFW_KEY_KP_ENTER
GLuint GLsizei const GLchar * label
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
GLuint GLuint64EXT address
void add_playback_device(context &ctx, device_models_list &device_models, std::string &error_message, viewer_model &viewer_model, const std::string &file)
std::vector< std::unique_ptr< device_model > > device_models_list
std::vector< std::shared_ptr< subdevice_model > > subdevices
IMGUI_API void SetContentRegionWidth(float y)
IMGUI_API void CloseCurrentPopup()
IMGUI_API bool IsKeyDown(int key_index)
ImFont * get_large_font() const
void show_top_bar(ux_window &window, const rect &viewer_rect, const device_models_list &devices)
IMGUI_API void OpenPopup(const char *str_id)
IMGUI_API void SetCursorPosY(float y)
std::shared_ptr< syncer_model > syncer
rs2_log_severity
Severity of the librealsense logger.
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
IMGUI_API bool IsAnyItemActive()
IMGUI_API float GetCursorPosY()
IMGUI_API bool IsItemHovered()
IMGUI_API void SetKeyboardFocusHere(int offset=0)
const std::string & get_failed_function() const
void copy(void *dst, void const *src, size_t size)
IMGUI_API void PopStyleColor(int count=1)
std::string to_string(T value)