From e16278b9561fb91b6c9ca59b5a7a6357566e61c8 Mon Sep 17 00:00:00 2001 From: suyu <1643689728@qq.com> Date: Thu, 13 Aug 2026 15:50:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=B7=E6=96=B0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0=E6=A8=A1=E5=9E=8B=E6=8A=95=E5=BD=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/ui/runtime_monitor_widget.cpp | 4 ++++ app/tests/main_window_tests.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/ui/runtime_monitor_widget.cpp b/app/src/ui/runtime_monitor_widget.cpp index af1629e..6aad488 100644 --- a/app/src/ui/runtime_monitor_widget.cpp +++ b/app/src/ui/runtime_monitor_widget.cpp @@ -43,7 +43,11 @@ void RuntimeMonitorWidget::setProjectObjects( const std::string &page_id, const std::string &logic_id) { hmi_view_->setPageId(page_id); + // 运行视图是独立投影,同一页面的控件也可能已在编辑视图中发生变化 + hmi_view_->reloadPage(); logic_view_->setLogicId(logic_id); + // 同一逻辑 ID 下的网络结构变化同样需要在首次扫描前立即可见 + logic_view_->reloadLogic(); } void RuntimeMonitorWidget::setMode( diff --git a/app/tests/main_window_tests.cpp b/app/tests/main_window_tests.cpp index 17abd76..abeec82 100644 --- a/app/tests/main_window_tests.cpp +++ b/app/tests/main_window_tests.cpp @@ -212,6 +212,7 @@ void testModeActionsControlEditingAvailability() QAction *offline_action = requiredChild(window, "offlineModeAction"); QAction *online_action = requiredChild(window, "onlineModeAction"); QAction *add_button_action = requiredChild(window, "addButtonAction"); + QAction *add_indicator_action = requiredChild(window, "addIndicatorAction"); QAction *delete_control_action = requiredChild(window, "deleteControlAction"); QAction *add_normally_open_action = requiredChild( window, "addNormallyOpenAction"); @@ -269,6 +270,14 @@ void testModeActionsControlEditingAvailability() require(editor_service.findPage(page_id)->controls.empty(), "deleting a selected control must update the HMI page model"); + add_indicator_action->trigger(); + HmiControl runtime_indicator = *editor_service.findControl(page_id, "indicator-1"); + runtime_indicator.binding = RegisterAddress{RegisterArea::M, 3}; + require(editor_service.updateControl( + page_id, runtime_indicator.id, runtime_indicator).succeeded, + "a configured HMI control must be available for the runtime projection"); + hmi_editor->reloadPage(); + add_normally_open_action->trigger(); parallel_insert_action->trigger(); add_normal_coil_action->trigger(); @@ -326,6 +335,10 @@ void testModeActionsControlEditingAvailability() require(runtime_tab->isVisible() && runtime_hmi->isVisible() && runtime_logic->isVisible() && free_monitor->isVisible(), "offline running must show HMI, ladder trace and free monitor together"); + auto *runtime_hmi_view = qobject_cast(runtime_hmi); + require(runtime_hmi_view != nullptr + && runtime_hmi_view->scene()->items().size() == 2, + "offline runtime HMI must project the configured page control"); QLineEdit *monitor_address = requiredChild(window, "addressEdit"); QPushButton *monitor_add = requiredChild(window, "addButton"); QTableWidget *monitor_table = requiredChild(window, "monitorTable");