瀏覽代碼

fix: 刷新运行工作台模型投影

main
suyu 1 月之前
父節點
當前提交
e16278b956
共有 2 個檔案被更改,包括 17 行新增0 行删除
  1. +4
    -0
      app/src/ui/runtime_monitor_widget.cpp
  2. +13
    -0
      app/tests/main_window_tests.cpp

+ 4
- 0
app/src/ui/runtime_monitor_widget.cpp 查看文件

@@ -43,7 +43,11 @@ void RuntimeMonitorWidget::setProjectObjects(
const std::string &page_id, const std::string &logic_id) const std::string &page_id, const std::string &logic_id)
{ {
hmi_view_->setPageId(page_id); hmi_view_->setPageId(page_id);
// 运行视图是独立投影,同一页面的控件也可能已在编辑视图中发生变化
hmi_view_->reloadPage();
logic_view_->setLogicId(logic_id); logic_view_->setLogicId(logic_id);
// 同一逻辑 ID 下的网络结构变化同样需要在首次扫描前立即可见
logic_view_->reloadLogic();
} }


void RuntimeMonitorWidget::setMode( void RuntimeMonitorWidget::setMode(


+ 13
- 0
app/tests/main_window_tests.cpp 查看文件

@@ -212,6 +212,7 @@ void testModeActionsControlEditingAvailability()
QAction *offline_action = requiredChild<QAction>(window, "offlineModeAction"); QAction *offline_action = requiredChild<QAction>(window, "offlineModeAction");
QAction *online_action = requiredChild<QAction>(window, "onlineModeAction"); QAction *online_action = requiredChild<QAction>(window, "onlineModeAction");
QAction *add_button_action = requiredChild<QAction>(window, "addButtonAction"); QAction *add_button_action = requiredChild<QAction>(window, "addButtonAction");
QAction *add_indicator_action = requiredChild<QAction>(window, "addIndicatorAction");
QAction *delete_control_action = requiredChild<QAction>(window, "deleteControlAction"); QAction *delete_control_action = requiredChild<QAction>(window, "deleteControlAction");
QAction *add_normally_open_action = requiredChild<QAction>( QAction *add_normally_open_action = requiredChild<QAction>(
window, "addNormallyOpenAction"); window, "addNormallyOpenAction");
@@ -269,6 +270,14 @@ void testModeActionsControlEditingAvailability()
require(editor_service.findPage(page_id)->controls.empty(), require(editor_service.findPage(page_id)->controls.empty(),
"deleting a selected control must update the HMI page model"); "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(); add_normally_open_action->trigger();
parallel_insert_action->trigger(); parallel_insert_action->trigger();
add_normal_coil_action->trigger(); add_normal_coil_action->trigger();
@@ -326,6 +335,10 @@ void testModeActionsControlEditingAvailability()
require(runtime_tab->isVisible() && runtime_hmi->isVisible() require(runtime_tab->isVisible() && runtime_hmi->isVisible()
&& runtime_logic->isVisible() && free_monitor->isVisible(), && runtime_logic->isVisible() && free_monitor->isVisible(),
"offline running must show HMI, ladder trace and free monitor together"); "offline running must show HMI, ladder trace and free monitor together");
auto *runtime_hmi_view = qobject_cast<HmiEditorWidget *>(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<QLineEdit>(window, "addressEdit"); QLineEdit *monitor_address = requiredChild<QLineEdit>(window, "addressEdit");
QPushButton *monitor_add = requiredChild<QPushButton>(window, "addButton"); QPushButton *monitor_add = requiredChild<QPushButton>(window, "addButton");
QTableWidget *monitor_table = requiredChild<QTableWidget>(window, "monitorTable"); QTableWidget *monitor_table = requiredChild<QTableWidget>(window, "monitorTable");


Loading…
取消
儲存