diff --git a/qml.qrc b/qml.qrc index 8eb72d0b..c3b06d16 100644 --- a/qml.qrc +++ b/qml.qrc @@ -76,6 +76,7 @@ resources/images/graphs.svg resources/images/domain_graph.svg resources/images/topic_graph.svg + resources/images/loading_graph.gif resources/images/icons/clearissues/clearissues_black.svg @@ -163,6 +164,7 @@ resources/images/icons/issues/issues_eProsimaLightBlue.svg resources/images/icons/issues/issues_grey.svg resources/images/icons/issues/issues_white.svg + resources/images/icons/issues/issues_yellow.svg resources/images/icons/lessthan/lessthan_black.svg resources/images/icons/lessthan/lessthan_eProsimaLightBlue.svg resources/images/icons/lessthan/lessthan_grey.svg diff --git a/qml/DomainGraphLayout.qml b/qml/DomainGraphLayout.qml index 0797f116..7756e77a 100644 --- a/qml/DomainGraphLayout.qml +++ b/qml/DomainGraphLayout.qml @@ -26,25 +26,31 @@ Item id: domainGraphLayout // Public properties - property var model: {} // domain view graph JSON model - property int domain_entity_id // entity id associated to the domain id - property int domain_id // domain id - required property string component_id // mandatory to be included when object created + property var model: {} // domain view graph JSON model + property int domain_entity_id // entity id associated to the domain id + property int domain_id // domain id + required property string component_id // mandatory to be included when object created // Public signals signal update_tab_name(string new_name, string stack_id) // Update tab name based on selected domain id signal openEntitiesMenu(string domainEntityId, string entityId, string currentAlias, string entityKind) signal openTopicMenu(string domainEntityId, string domainId, string entityId, string currentAlias, string entityKind) + signal openLoadingGraphDialog() //l et tab layout know that graph is about to be generated + signal initialized() // let tab layout know that graph has been generated // Private properties - property var topic_locations_: {} // topic information needed for connection representation - property var endpoint_topic_connections_: {} // endpoint information needed for connection representation - property var topic_painted_: [] // already painted topic connection references - property var endpoint_painted_: [] // already painted endpoint connection references - property var pending_endpoints_: [] // pending endpoints references that have not been resized yet - property var pending_connections_: [] // pending connections references that have not been generated yet - property var filtered_topics_: [] // flitered topic entity id in the graph - property int entity_box_width_: 0 // entity box width management + property var topic_locations_: {} // topic information needed for connection representation + property var endpoint_topic_connections_: {} // endpoint information needed for connection representation + property var topic_painted_: [] // already painted topic connection references + property var endpoint_painted_: [] // already painted endpoint connection references + property var pending_endpoints_: [] // pending endpoints references that have not been resized yet + property var pending_connections_: [] // pending connections references that have not been generated yet + property var filtered_topics_: [] // flitered topic entity id in the graph + property var endpoints_per_topic: {} // list of endpoint ids associated to each topic + property int entity_box_width_: 0 // entity box width management + property bool topic_connections_generated: false // topic side connections generated + property bool endpoint_connections_generated: false // endpoint side connections generated + // Private (resize) signals The signal resize_elements_ will trigger all entities resize methods in // HOST TOPIC ─┐ the order displayed in the left figure. All entities width value are @@ -54,6 +60,7 @@ Item signal topics_updated_() signal endpoints_updated_() signal record_connections_() + signal topic_visibility_changed_(string endpoint_id, bool new_status) // Read only design properties (sizes and colors) readonly property int radius_: 10 @@ -79,6 +86,7 @@ Item readonly property string reader_color_: Theme.eProsimaYellow readonly property string writer_color_: Theme.eProsimaGreen + // Horizontal scroll view for topics section. This will contain also a Flickable that replicates entities height // and will move accordingly to display the connections Flickable { @@ -256,6 +264,15 @@ Item width: topic_thickness_ color: topic_color_ } + + Connections { + target: topicView + function onContentXChanged() + { + domainGraphLayout.topic_visibility_changed( + topic_id, ((x + width/2 + topic_thickness_/2 + elements_spacing_) < topicView.contentX)) + } + } } } @@ -345,15 +362,28 @@ Item ,"y": endpoint_topic_connections_[key]["y"] - (connection_thickness_ / 2) ,"width": topic_locations_[topic_id]["width"] ,"height":connection_thickness_, "z":200, "left_margin": 2*elements_spacing_ - ,"arrow_color": topic_color_, "background_color": background_color.color } + ,"arrow_color": topic_color_, "background_color": background_color.color + ,"endpoint_id": key } var connection_bar = arrow_component.createObject(topic_connections, input) topic_painted_[topic_painted_.length] = key; } } } + + topic_connections_generated = true + domainGraphLayout.connections_generated() } } + // Left section background (over right section) + Rectangle { + anchors.top: parent.top + anchors.left: parent.left + height: parent.height + width: entity_box_width_ + 2*elements_spacing_ + color: "white" + } + // Entities vertical flickable (left section) Flickable { id: mainView @@ -426,7 +456,16 @@ Item Component { id: arrow_component GraphConnection{ + id: conn + + Connections{ + target: domainGraphLayout + function onTopic_visibility_changed_(endpoint_id, new_status) + { + conn.topid_hidden(endpoint_id, new_status) + } + } } } @@ -552,7 +591,7 @@ Item IconSVG { anchors.centerIn: parent name: modelData["status"] == "WARNING" ? "issues" : "error" - color: modelData["status"] == "WARNING" ? "black" : "red" + color: modelData["status"] == "WARNING" ? "yellow" : "red" size: modelData["status"] != "OK"? icon_size_ : 0 } } @@ -696,7 +735,7 @@ Item IconSVG { anchors.centerIn: parent name: modelData["status"] == "WARNING" ? "issues" : "error" - color: modelData["status"] == "WARNING" ? "black" : "red" + color: modelData["status"] == "WARNING" ? "yellow" : "red" size: modelData["status"] != "OK"? icon_size_ : 0 } } @@ -839,7 +878,7 @@ Item IconSVG { anchors.centerIn: parent name: modelData["status"] == "WARNING" ? "issues" : "error" - color: modelData["status"] == "WARNING" ? "black" : "red" + color: modelData["status"] == "WARNING" ? "yellow" : "red" size: modelData["status"] != "OK"? icon_size_ : 0 } } @@ -982,7 +1021,7 @@ Item IconSVG { anchors.centerIn: parent name: modelData["status"] == "WARNING" ? "issues" : "error" - color: modelData["status"] == "WARNING" ? "black" : "red" + color: modelData["status"] == "WARNING" ? "yellow" : "red" size: modelData["status"] != "OK"? icon_size_ : 0 } } @@ -1175,10 +1214,17 @@ Item width: modelData["status"] != "OK"? icon_size_ + spacing_icon_: 0 height: modelData["status"] != "OK"? icon_size_ + spacing_icon_: 0 radius: modelData["status"] != "OK"? icon_size_ + spacing_icon_: 0 + IconSVG { + visible: modelData["status"] == "WARNING" + anchors.centerIn: parent + name: "issues" + color: "white" + size: icon_size_ * (3/2) + } IconSVG { anchors.centerIn: parent name: modelData["status"] == "WARNING" ? "issues" : "error" - color: modelData["status"] == "WARNING" ? "black" : "red" + color: modelData["status"] == "WARNING" ? "yellow" : "red" size: modelData["status"] != "OK"? icon_size_ : 0 } } @@ -1243,17 +1289,21 @@ Item ,"left_direction": endpoint_topic_connections_[key]["left_direction"] ,"width": 5*elements_spacing_ ,"height":connection_thickness_, "z":200 - ,"arrow_color": topic_color_, "background_color": background_color.color } + ,"arrow_color": topic_color_, "background_color": background_color.color + ,"endpoint_id": key } var connection_bar = arrow_component.createObject(mainSpace, input) endpoint_painted_[endpoint_painted_.length] = key } } } + + endpoint_connections_generated = true + domainGraphLayout.connections_generated() } } } - // top section to cut entities layout and display the REFRESH butotn + // top section to cut entities layout and display the REFRESH button Rectangle { anchors.top: parent.top anchors.left: parent.left @@ -1273,6 +1323,7 @@ Item text: "Refresh" onClicked:{ + domainGraphLayout.openLoadingGraphDialog() load_model() } } @@ -1379,6 +1430,7 @@ Item "kind":"Topic", "alias":new_model["topics"][topic]["alias"] } + endpoints_per_topic[topic] = [] } } } @@ -1389,6 +1441,7 @@ Item "kind":"Topic", "alias":new_model["topics"][topic]["alias"] } + endpoints_per_topic[topic] = [] } } } @@ -1443,14 +1496,16 @@ Item { kind = "DataReader" } + var endpoint_topic = new_model["hosts"][host]["users"][user]["processes"][process]["participants"][participant]["endpoints"][endpoint]["topic"] new_endpoints[new_endpoints.length] = { "id":endpoint, "kind":kind, "alias":new_model["hosts"][host]["users"][user]["processes"][process]["participants"][participant]["endpoints"][endpoint]["alias"], "status":new_model["hosts"][host]["users"][user]["processes"][process]["participants"][participant]["endpoints"][endpoint]["status"], - "topic":new_model["hosts"][host]["users"][user]["processes"][process]["participants"][participant]["endpoints"][endpoint]["topic"], + "topic": endpoint_topic, "accum_y":accum_y } + endpoints_per_topic[endpoint_topic][endpoints_per_topic[endpoint_topic].length] = endpoint accum_y += endpoint_height_ + elements_spacing_ pending_endpoints_[pending_endpoints_.length] = endpoint } @@ -1565,6 +1620,9 @@ Item // display empty screen label emptyScreenLabel.visible = true + + // stop animation + domainGraphLayout.initialized() } // Update tab name with selected domain id @@ -1604,6 +1662,7 @@ Item topic_painted_ = [] pending_endpoints_ = [] pending_connections_ = [] + endpoints_per_topic = {} vertical_bar.position = 0 horizontal_bar.position = 0 entity_box_width_ = 0; @@ -1705,4 +1764,27 @@ Item // not found yet return false } + + // report to the graph connections that the endpoint associated topic is not currently in view + function topic_visibility_changed(topic_id, inView) + { + if (topic_id in endpoints_per_topic) + { + for (var i = 0; i < endpoints_per_topic[topic_id].length; i++) + { + domainGraphLayout.topic_visibility_changed_(endpoints_per_topic[topic_id][i], inView) + } + } + } + + // set the graph as initialized + function connections_generated() + { + if (domainGraphLayout.topic_connections_generated && domainGraphLayout.endpoint_connections_generated) + { + domainGraphLayout.topic_connections_generated = false + domainGraphLayout.endpoint_connections_generated = false + domainGraphLayout.initialized() + } + } } diff --git a/qml/GraphConnection.qml b/qml/GraphConnection.qml index b52b4fe6..aa984d02 100644 --- a/qml/GraphConnection.qml +++ b/qml/GraphConnection.qml @@ -1,12 +1,15 @@ import QtQuick 2.0 Item { + id: graphConnection // public property property bool left_direction: false // defines if the represented connection must draw a left arrow property bool right_direction: false // defines if the represented connection must draw a right arrow property int left_margin: 0 // left margin to be applied property string arrow_color: Theme.grey // connection color property string background_color: "white" // background color + property string endpoint_id: "" // graph refferred entity id + property bool hidden_arrow: false // associated topic is not visible // readonly private design properties readonly property int arrow_margin_: -3 // margins for background @@ -18,6 +21,7 @@ Item { readonly property int left_arrow_background_margin_: -4 readonly property int left_arrow_margin_: -5 // left arrow margin readonly property int right_arrow_margin_: -2 // right arrow margin + readonly property int hidden_arrow_margin_: 2 // hidden arrow margin // background to make connection overlap nicely with previous topics (looks like connection goes OVER the topic) Rectangle { @@ -41,8 +45,6 @@ Item { color: "white" } - - // left arrow if visible Item { id: left_arrow_background @@ -70,7 +72,6 @@ Item { } } - Item { id: left_arrow visible: left_direction @@ -96,6 +97,57 @@ Item { color: arrow_color } + // hidden topic icon + Rectangle { + visible: graphConnection.hidden_arrow + anchors.verticalCenter: base_arrow.verticalCenter + anchors.left: base_arrow.right + height: graphConnection.height - 2* arrow_margin_; width: 3*graphConnection.height + hidden_arrow_margin_*4 + color: "white" + + Rectangle { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.right; anchors.leftMargin: -parent.height/2 + height: parent.height; width: parent.height + radius: parent.height + color: "white" + } + + Rectangle { + id: spot_1 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left; anchors.leftMargin: hidden_arrow_margin_*2 + height: graphConnection.height; width: graphConnection.height + radius: graphConnection.height + color: arrow_color + } + Rectangle { + id: spot_2 + anchors.verticalCenter: parent.verticalCenter + anchors.left: spot_1.right; anchors.leftMargin: hidden_arrow_margin_ + height: graphConnection.height; width: graphConnection.height + radius: graphConnection.height + color: arrow_color + } + Rectangle { + id: spot_3 + anchors.verticalCenter: parent.verticalCenter + anchors.left: spot_2.right; anchors.leftMargin: hidden_arrow_margin_ + height: graphConnection.height; width: graphConnection.height + radius: graphConnection.height + color: arrow_color + } + + Rectangle { + id: spot_0 + anchors.verticalCenter: parent.verticalCenter + anchors.right: spot_1.left; anchors.rightMargin: hidden_arrow_margin_*2-graphConnection.height/2 +1 + height: graphConnection.height; width: graphConnection.height + radius: graphConnection.height + color: arrow_color + } + } + // right arrow if visible Item { id: right_arrow @@ -111,4 +163,12 @@ Item { size: arrow_size_ + right_arrow_margin_ } } + + function topid_hidden(entityId, is_hidden) + { + if (endpoint_id == entityId && graphConnection.hidden_arrow != is_hidden) + { + graphConnection.hidden_arrow = is_hidden + } + } } diff --git a/qml/StatusTreeViewItem.qml b/qml/StatusTreeViewItem.qml index 244c06fb..b9b6c683 100644 --- a/qml/StatusTreeViewItem.qml +++ b/qml/StatusTreeViewItem.qml @@ -120,7 +120,7 @@ Item { anchors.verticalCenter: parent.verticalCenter name: currentRow.currentStatus == "ERROR" ? "error" : currentRow.currentStatus == "WARNING" ? "issues" : "" - color: currentRow.currentAlive ? currentRow.currentStatus == "ERROR" ? "red" :"black" : "grey" + color: currentRow.currentAlive ? currentRow.currentStatus == "ERROR" ? "red" :"yellow" : "grey" size: 15 } diff --git a/qml/TabLayout.qml b/qml/TabLayout.qml index be26a7d6..4d83c8da 100644 --- a/qml/TabLayout.qml +++ b/qml/TabLayout.qml @@ -36,6 +36,8 @@ Item { property int last_index_: 1 // force unique idx on QML components property var tab_model_: [{"idx":0, "title":"New Tab", "stack_id": 0}] // tab model for tab bad and tab management property bool disable_chart_selection_: false // flag to disable multiple chart view tabs + readonly property var allowed_stack_components_: // list of allowed component names to be + ["view_selector", "chartsLayout", "domainGraphLayout_component"]// loaded in the tabs stack view // private signals signal open_domain_view_(int stack_id, int entity_id, int domain_id) @@ -50,6 +52,9 @@ Item { readonly property int tabs_margins_: 15 readonly property int tab_icons_size_: 16 readonly property int add_tab_width_: 50 + readonly property int timer_ms_interval_: 500 + readonly property int dialog_width_: 300 + readonly property int dialog_height_: 152 readonly property string selected_tab_color_: "#ffffff" readonly property string selected_shadow_tab_color_: "#c0c0c0" readonly property string not_selected_tab_color_: "#f0f0f0" @@ -84,7 +89,9 @@ Item { StackView { id: stack property int stack_id: 0 - initialItem: view_selector + property string customInitialItem: "view_selector" + initialItem: customInitialItem == "chartsLayout" ? chartsLayout : + customInitialItem == "domainGraphLayout_component" ? domainGraphLayout_component : view_selector // override push transition to none pushEnter: Transition {} @@ -241,6 +248,14 @@ Item { tabLayout.openTopicMenu(domainEntityId, domainId, entityId, currentAlias, entityKind) } + onOpenLoadingGraphDialog: { + loading_graph_dialog.open() + } + + onInitialized: { + loading_graph_dialog.soft_close() + } + Connections { target: tabLayout @@ -261,7 +276,6 @@ Item { } } } - } } @@ -271,6 +285,7 @@ Item { function onOpen_domain_view_(stack_id, entity_id, domain_id, topic_id) { if (stack.stack_id == stack_id) { + loading_graph_dialog.open() if (stack.deep > 1) { stack.pop() @@ -426,7 +441,7 @@ Item { x: (parent.width - width) / 2 y: (parent.height - height) / 2 - width: 300 + width: dialog_width_ modal: true title: "Select DDS Domain" @@ -478,11 +493,73 @@ Item { } } + Dialog { + id: loading_graph_dialog + + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + + width: dialog_width_ + height: dialog_height_ + + modal: true + + AnimatedImage { + source: "/resources/images/loading_graph.gif" + anchors.centerIn: parent + width: dialog_width_ + height: dialog_height_ + } + + onAboutToShow: + { + timer.start() + } + + function soft_close() + { + if (timer.running) + { + timer.should_close = true + } + else + { + loading_graph_dialog.close() + } + } + + Timer + { + id: timer + property bool should_close: false + interval: timer_ms_interval_; running: false + onTriggered: + { + if (timer.should_close) + { + loading_graph_dialog.close() + timer.should_close = false + } + } + } + } + function create_new_tab() { + create_new_custom_tab_("") + } + + function create_new_custom_tab_(component_identifier) + { + var initial_component = component_identifier + if (!allowed_stack_components_.includes(component_identifier)) + { + initial_component = "view_selector"; + } var idx = tabLayout.tab_model_.length tabLayout.tab_model_[idx] = {"idx" : idx, "title": "New Tab", "stack_id":last_index_} - var new_stack = stack_component.createObject(null, {"stack_id": tabLayout.tab_model_[idx]["stack_id"]}) + var new_stack = stack_component.createObject(null, { + "stack_id": tabLayout.tab_model_[idx]["stack_id"], "customInitialItem": initial_component }) last_index_++ stack_layout.children.push(new_stack) refresh_layout(idx) @@ -626,7 +703,7 @@ Item { } function open_topic_view(domainEntityId, domainId, entityId) { - create_new_tab() + create_new_custom_tab_("domainGraphLayout_component") open_domain_view_(tabLayout.tab_model_[current_]["stack_id"], domainEntityId, domainId) filter_domain_view_by_topic_(tabLayout.tab_model_[current_]["stack_id"], domainEntityId, entityId) } diff --git a/resources/images/icons/issues/issues_yellow.svg b/resources/images/icons/issues/issues_yellow.svg new file mode 100644 index 00000000..5e099d44 --- /dev/null +++ b/resources/images/icons/issues/issues_yellow.svg @@ -0,0 +1,14 @@ + + + + + + + +Layer 1 + + + + + + \ No newline at end of file diff --git a/resources/images/loading_graph.gif b/resources/images/loading_graph.gif new file mode 100644 index 00000000..da702cd0 Binary files /dev/null and b/resources/images/loading_graph.gif differ diff --git a/src/Engine.cpp b/src/Engine.cpp index 22de100d..ead4e246 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -982,12 +982,6 @@ bool Engine::read_callback_( + backend::status_kind_to_string(status_callback.status_kind), utils::now()); - // Update status in info model - if (last_entities_clicked_.dds.id == status_callback.entity_id) - { - info_model_->update(backend_connection_.get_info(status_callback.entity_id)); - } - // Remove entities from status layout if needed remove_inactive_entities_from_status_model(status_callback.entity_id); @@ -1003,12 +997,12 @@ bool Engine::update_entity_status( if (id == backend::ID_ALL) { auto empty_item = new models::StatusTreeItem(backend::ID_ALL, - std::string("No issues found"), backend::StatusLevel::OK, std::string("")); + std::string("No issues found"), backend::StatusLevel::OK_STATUS, std::string("")); entity_status_model_->addTopLevelItem(empty_item); } else { - backend::StatusLevel new_status = backend::StatusLevel::OK; + backend::StatusLevel new_status = backend::StatusLevel::OK_STATUS; std::string description = backend::entity_status_description(kind); switch (kind) @@ -1018,23 +1012,25 @@ bool Engine::update_entity_status( backend::DeadlineMissedSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; std::string handle_string; auto deadline_missed_item = new models::StatusTreeItem(id, kind, std::string("Deadline missed"), - sample.status, std::string(""), description); + sample.status, std::string(""), description); auto total_count_item = new models::StatusTreeItem(id, kind, std::string("Total count:"), - sample.status, std::to_string(sample.deadline_missed_status.total_count()), std::string("")); + sample.status, std::to_string( + sample.deadline_missed_status.total_count()), std::string("")); for (uint8_t handler : sample.deadline_missed_status.last_instance_handle()) { handle_string = handle_string + std::to_string(handler); } auto last_instance_handle_item = new models::StatusTreeItem(id, kind, - std::string("Last instance handle:"), sample.status, handle_string, std::string("")); + std::string("Last instance handle:"), sample.status, handle_string, + std::string("")); entity_status_model_->addItem(deadline_missed_item, total_count_item); entity_status_model_->addItem(deadline_missed_item, last_instance_handle_item); entity_status_model_->addItem(entity_item, deadline_missed_item); @@ -1048,27 +1044,31 @@ bool Engine::update_entity_status( backend::IncompatibleQosSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { std::string fastdds_version = "v2.12.0"; backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; - auto incompatible_qos_item = new models::StatusTreeItem(id, kind, std::string("Incompatible QoS"), - sample.status, std::string(""), description); - for (eprosima::fastdds::statistics::QosPolicyCount_s policy : sample.incompatible_qos_status.policies()) + auto incompatible_qos_item = new models::StatusTreeItem(id, kind, std::string( + "Incompatible QoS"), + sample.status, std::string(""), description); + for (eprosima::fastdds::statistics::QosPolicyCount_s policy : + sample.incompatible_qos_status.policies()) { if (policy.count() > 0) { auto policy_item = new models::StatusTreeItem(id, kind, - std::string(backend::policy_id_to_string(policy.policy_id()) + ":"), - sample.status, std::to_string(policy.count()), - std::string("Check for compatible rules ") + - std::string("here")); + std::string(backend::policy_id_to_string(policy.policy_id()) + ":"), + sample.status, std::to_string(policy.count()), + std::string( + "Check for compatible rules ") + + std::string( + "here")); entity_status_model_->addItem(incompatible_qos_item, policy_item); } } @@ -1083,14 +1083,16 @@ bool Engine::update_entity_status( backend::InconsistentTopicSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; - auto inconsistent_topic_item = new models::StatusTreeItem(id, kind, std::string("Inconsistent topics:"), - sample.status, std::to_string(sample.inconsistent_topic_status.total_count()), description); + auto inconsistent_topic_item = + new models::StatusTreeItem(id, kind, std::string("Inconsistent topics:"), + sample.status, std::to_string( + sample.inconsistent_topic_status.total_count()), description); entity_status_model_->addItem(entity_item, inconsistent_topic_item); counter = entity_item->recalculate_entity_counter(); } @@ -1102,25 +1104,30 @@ bool Engine::update_entity_status( backend::LivelinessChangedSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; - auto liveliness_changed_item = new models::StatusTreeItem(id, kind, std::string("Liveliness changed"), - sample.status, std::string(""), description); + auto liveliness_changed_item = + new models::StatusTreeItem(id, kind, std::string("Liveliness changed"), + sample.status, std::string(""), description); std::string handle_string; auto alive_count_item = new models::StatusTreeItem(id, kind, std::string("Alive count:"), - sample.status, std::to_string(sample.liveliness_changed_status.alive_count()), std::string("")); - auto not_alive_count_item = new models::StatusTreeItem(id, kind, std::string("Not alive count:"), - sample.status, std::to_string(sample.liveliness_changed_status.not_alive_count()), std::string("")); + sample.status, std::to_string( + sample.liveliness_changed_status.alive_count()), std::string("")); + auto not_alive_count_item = new models::StatusTreeItem(id, kind, std::string( + "Not alive count:"), + sample.status, std::to_string( + sample.liveliness_changed_status.not_alive_count()), std::string("")); for (uint8_t handler : sample.liveliness_changed_status.last_publication_handle()) { handle_string = handle_string + std::to_string(handler); } auto last_publication_handle_item = new models::StatusTreeItem(id, kind, - std::string("Last publication handle:"), sample.status, handle_string, std::string("")); + std::string( + "Last publication handle:"), sample.status, handle_string, std::string("")); entity_status_model_->addItem(liveliness_changed_item, alive_count_item); entity_status_model_->addItem(liveliness_changed_item, not_alive_count_item); @@ -1136,14 +1143,16 @@ bool Engine::update_entity_status( backend::LivelinessLostSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; - auto liveliness_lost_item = new models::StatusTreeItem(id, kind, std::string("Liveliness lost:"), - sample.status, std::to_string(sample.liveliness_lost_status.total_count()), description); + auto liveliness_lost_item = new models::StatusTreeItem(id, kind, std::string( + "Liveliness lost:"), + sample.status, std::to_string( + sample.liveliness_lost_status.total_count()), description); entity_status_model_->addItem(entity_item, liveliness_lost_item); counter = entity_item->recalculate_entity_counter(); } @@ -1155,14 +1164,15 @@ bool Engine::update_entity_status( backend::SampleLostSample sample; if (backend_connection_.get_status_data(id, sample)) { - if (sample.status != backend::StatusLevel::OK) + if (sample.status != backend::StatusLevel::OK_STATUS) { backend::StatusLevel entity_status = backend_connection_.get_status(id); auto entity_item = entity_status_model_->getTopLevelItem( - id, backend_connection_.get_name(id), entity_status, description); + id, backend_connection_.get_name(id), entity_status, description); new_status = sample.status; auto samples_lost_item = new models::StatusTreeItem(id, kind, std::string("Samples lost:"), - sample.status, std::to_string(sample.sample_lost_status.total_count()), description); + sample.status, std::to_string( + sample.sample_lost_status.total_count()), description); entity_status_model_->addItem(entity_item, samples_lost_item); counter = entity_item->recalculate_entity_counter(); } @@ -1179,22 +1189,22 @@ bool Engine::update_entity_status( break; } } - if (new_status != backend::StatusLevel::OK) + if (new_status != backend::StatusLevel::OK_STATUS) { - if (new_status == backend::StatusLevel::ERROR) + if (new_status == backend::StatusLevel::ERROR_STATUS) { - std::map::iterator it = controller_->status_counters.errors.find(id); - if(it != controller_->status_counters.errors.end()) + std::map::iterator it = controller_->status_counters.errors.find(id); + if (it != controller_->status_counters.errors.end()) { controller_->status_counters.total_errors -= controller_->status_counters.errors[id]; } controller_->status_counters.errors[id] = counter; controller_->status_counters.total_errors += controller_->status_counters.errors[id]; } - else if (new_status == backend::StatusLevel::WARNING) + else if (new_status == backend::StatusLevel::WARNING_STATUS) { - std::map::iterator it = controller_->status_counters.warnings.find(id); - if(it != controller_->status_counters.warnings.end()) + std::map::iterator it = controller_->status_counters.warnings.find(id); + if (it != controller_->status_counters.warnings.end()) { controller_->status_counters.total_warnings -= controller_->status_counters.warnings[id]; } @@ -1205,8 +1215,8 @@ bool Engine::update_entity_status( emit entity_status_proxy_model_->layoutAboutToBeChanged(); emit controller_->update_status_counters( - QString::number(controller_->status_counters.total_errors), - QString::number(controller_->status_counters.total_warnings)); + QString::number(controller_->status_counters.total_errors), + QString::number(controller_->status_counters.total_warnings)); // remove empty message if exists if (entity_status_model_->is_empty()) @@ -1237,18 +1247,20 @@ bool Engine::remove_inactive_entities_from_status_model( if (!entity_info["alive"]) { // remove item from tree - entity_status_model_->removeItem(entity_status_model_->getTopLevelItem(id, "", backend::StatusLevel::OK, "")); + entity_status_model_->removeItem(entity_status_model_->getTopLevelItem(id, "", backend::StatusLevel::OK_STATUS, + "")); // add empty item if removed last item if (entity_status_model_->rowCount(entity_status_model_->rootIndex()) == 0) { entity_status_model_->addTopLevelItem(new models::StatusTreeItem( - backend::ID_ALL, std::string("No issues found"), backend::StatusLevel::OK, std::string(""))); + backend::ID_ALL, std::string("No issues found"), backend::StatusLevel::OK_STATUS, + std::string(""))); } // update error counter - std::map::iterator err_it = controller_->status_counters.errors.find(id); - if(err_it != controller_->status_counters.errors.end()) + std::map::iterator err_it = controller_->status_counters.errors.find(id); + if (err_it != controller_->status_counters.errors.end()) { //element found; controller_->status_counters.total_errors -= err_it->second; @@ -1260,8 +1272,8 @@ bool Engine::remove_inactive_entities_from_status_model( controller_->status_counters.errors.erase(id); // update warning counter - std::map::iterator warn_it = controller_->status_counters.warnings.find(id); - if(warn_it != controller_->status_counters.warnings.end()) + std::map::iterator warn_it = controller_->status_counters.warnings.find(id); + if (warn_it != controller_->status_counters.warnings.end()) { //element found; controller_->status_counters.total_warnings -= warn_it->second; @@ -1276,8 +1288,8 @@ bool Engine::remove_inactive_entities_from_status_model( emit entity_status_proxy_model_->layoutAboutToBeChanged(); emit controller_->update_status_counters( - QString::number(controller_->status_counters.total_errors), - QString::number(controller_->status_counters.total_warnings)); + QString::number(controller_->status_counters.total_errors), + QString::number(controller_->status_counters.total_warnings)); // update view entity_status_proxy_model_->set_source_model(entity_status_model_); diff --git a/src/model/tree/StatusTreeItem.cpp b/src/model/tree/StatusTreeItem.cpp index 95ab319f..e4adb760 100644 --- a/src/model/tree/StatusTreeItem.cpp +++ b/src/model/tree/StatusTreeItem.cpp @@ -53,7 +53,7 @@ StatusTreeItem::StatusTreeItem() , id_(backend::ID_ALL) , kind_(backend::StatusKind::INVALID) , name_() - , status_level_(backend::StatusLevel::OK) + , status_level_(backend::StatusLevel::OK_STATUS) , value_() , description_() , is_active_(true) @@ -73,7 +73,7 @@ StatusTreeItem::StatusTreeItem( , id_(backend::ID_ALL) , kind_(backend::StatusKind::INVALID) , name_(data.toString().toStdString()) - , status_level_(backend::StatusLevel::OK) + , status_level_(backend::StatusLevel::OK_STATUS) , value_() , description_() , is_active_(true)