Commit 78c7fd7b by Yuhaibo

1

parent b2bf9116
...@@ -1481,12 +1481,17 @@ class MainWindow( ...@@ -1481,12 +1481,17 @@ class MainWindow(
更新任务面板中通道列的颜色 更新任务面板中通道列的颜色
当通道的检测状态改变时调用此方法,更新任务面板中对应通道列的背景色 当通道的检测状态改变时调用此方法,更新任务面板中对应通道列的背景色
调用 MissionPanelHandler 的方法(MainWindow 继承了 MissionPanelHandler)
""" """
print(f"🎯 [app._updateChannelColumnColor] 方法被调用")
try: try:
if hasattr(self, '_updateChannelCellColors'): # MainWindow 继承了 MissionPanelHandler,直接调用父类方法
self._updateChannelCellColors() from handlers.videopage import MissionPanelHandler
MissionPanelHandler._updateChannelColumnColor(self)
except Exception as e: except Exception as e:
print(f"⚠️ [更新通道列颜色] 失败: {e}") print(f"⚠️ [更新通道列颜色] 失败: {e}")
import traceback
traceback.print_exc()
def closeEvent(self, event): def closeEvent(self, event):
"""窗口关闭事件""" """窗口关闭事件"""
......
...@@ -5,14 +5,14 @@ channel1: ...@@ -5,14 +5,14 @@ channel1:
height: 20mm height: 20mm
name: 通道1_区域1 name: 通道1_区域1
boxes: boxes:
- - 484 - - 715
- 710 - 629
- 352 - 416
fixed_bottoms: fixed_bottoms:
- 850 - 795
fixed_tops: fixed_tops:
- 569 - 462
last_updated: '2025-11-29 12:56:00' last_updated: '2025-11-29 13:46:20'
channel2: channel2:
annotation_count: 1 annotation_count: 1
areas: areas:
......
...@@ -17,23 +17,23 @@ channels: ...@@ -17,23 +17,23 @@ channels:
name: '4' name: '4'
channel2: channel2:
general: general:
task_id: '123' task_id: '1'
task_name: '21' task_name: '2'
save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\123_21 save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\1_2
channel3: channel3:
general: general:
task_id: '123' task_id: '1'
task_name: '21' task_name: '222'
save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\123_21 save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\1_222
channel4: channel4:
general: general:
task_id: '1' task_id: '1'
task_name: '1' task_name: '222'
save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\1_1 save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\1_222
channel1: channel1:
general: general:
task_id: '1' task_id: 2 去
task_name: '1' task_name:
area_count: 0 area_count: 0
safe_low: 2.0mm safe_low: 2.0mm
safe_high: 10.0mm safe_high: 10.0mm
...@@ -41,7 +41,8 @@ channel1: ...@@ -41,7 +41,8 @@ channel1:
video_format: AVI video_format: AVI
push_address: '' push_address: ''
video_path: '' video_path: ''
save_liquid_data_path: d:\restructure\liquid_level_line_detection_system\database\mission_result\1_1 save_liquid_data_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\2
去_去
areas: areas:
area_1: 通道1_区域1 area_1: 通道1_区域1
area_2: 通道1_区域2 area_2: 通道1_区域2
......
task_id: 2 去
task_id: 2 去
task_name:
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:30:07'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\2
去_去
task_id: 任务
task_id: 任务
task_name: 若是
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:39:21'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\任务_若是
task_id: 企鹅
task_id: 企鹅
task_name: 1额
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:34:35'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\企鹅_1额
task_id: 去v
task_id: 去v
task_name: 去v
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:34:18'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\去v_去v
2025-11-29-13:52:52.059 16.2
2025-11-29-13:52:52.059 16.2
2025-11-29-13:52:52.093 16.6
2025-11-29-13:52:52.293 0.0
2025-11-29-13:52:52.495 16.6
2025-11-29-13:52:52.688 0.0
2025-11-29-13:52:52.903 16.3
2025-11-29-13:52:53.091 0.0
2025-11-29-13:52:53.302 16.6
2025-11-29-13:52:53.502 0.0
2025-11-29-13:52:53.694 0.0
2025-11-29-13:52:53.905 0.0
2025-11-29-13:52:54.103 0.0
2025-11-29-13:52:54.324 16.3
2025-11-29-13:52:54.511 0.0
2025-11-29-13:52:54.705 0.0
2025-11-29-13:52:54.921 16.0
2025-11-29-13:52:55.117 0.0
2025-11-29-13:52:55.313 0.0
2025-11-29-13:52:55.519 0.0
2025-11-29-13:52:55.716 0.0
2025-11-29-13:52:55.919 0.0
2025-11-29-13:52:56.129 0.0
2025-11-29-13:52:56.326 0.0
2025-11-29-13:52:56.544 0.0
2025-11-29-13:52:56.739 0.0
2025-11-29-13:52:56.939 0.0
2025-11-29-13:52:57.149 0.0
2025-11-29-13:52:57.352 0.0
2025-11-29-13:52:57.557 0.0
2025-11-29-13:52:57.763 0.0
2025-11-29-13:52:57.964 0.0
2025-11-29-13:52:58.173 0.0
2025-11-29-13:52:58.371 0.0
2025-11-29-13:52:58.571 0.0
2025-11-29-13:52:58.782 0.0
2025-11-29-13:52:58.980 0.0
2025-11-29-13:52:59.209 0.0
2025-11-29-13:52:59.425 0.0
2025-11-29-13:52:59.606 0.0
2025-11-29-13:52:59.828 16.2
2025-11-29-13:53:00.022 0.0
2025-11-29-13:53:00.225 0.0
2025-11-29-13:53:00.424 0.0
2025-11-29-13:53:00.628 0.0
2025-11-29-13:53:00.836 0.0
2025-11-29-13:53:01.034 0.0
2025-11-29-13:53:01.246 0.0
2025-11-29-13:53:01.448 0.0
2025-11-29-13:53:01.660 0.0
2025-11-29-13:53:01.923 0.0
2025-11-29-13:53:02.009 0.0
2025-11-29-13:53:02.196 0.0
2025-11-29-13:53:02.392 0.0
2025-11-29-13:53:02.590 0.0
2025-11-29-13:53:02.810 0.0
2025-11-29-13:53:03.002 0.0
2025-11-29-13:53:03.197 0.0
2025-11-29-13:53:03.415 0.0
2025-11-29-13:53:03.604 0.0
2025-11-29-13:53:03.803 0.0
2025-11-29-13:53:04.018 0.0
2025-11-29-13:53:04.209 0.0
2025-11-29-13:53:04.418 0.0
2025-11-29-13:53:04.619 0.0
2025-11-29-13:53:04.813 0.0
2025-11-29-13:53:05.025 0.0
2025-11-29-13:53:05.223 0.0
2025-11-29-13:53:05.422 0.0
2025-11-29-13:53:05.632 0.0
2025-11-29-13:53:05.828 0.0
2025-11-29-13:53:06.038 0.0
2025-11-29-13:53:06.238 0.0
2025-11-29-13:53:06.446 0.0
2025-11-29-13:53:06.655 0.0
2025-11-29-13:53:06.858 0.0
2025-11-29-13:53:07.063 0.0
2025-11-29-13:53:07.263 0.0
2025-11-29-13:53:07.466 0.0
2025-11-29-13:53:07.671 0.0
2025-11-29-13:53:07.872 0.0
2025-11-29-13:53:08.074 0.0
2025-11-29-13:53:08.277 0.0
2025-11-29-13:53:08.481 0.0
2025-11-29-13:53:08.711 0.0
2025-11-29-13:53:08.908 0.0
2025-11-29-13:53:09.121 0.0
2025-11-29-13:53:09.316 16.9
2025-11-29-13:53:09.528 0.0
2025-11-29-13:53:09.726 0.0
2025-11-29-13:53:09.936 0.0
2025-11-29-13:53:10.137 0.0
2025-11-29-13:53:10.366 0.0
2025-11-29-13:53:10.552 0.0
2025-11-29-13:53:10.758 0.0
2025-11-29-13:53:10.962 0.0
2025-11-29-13:53:11.163 0.0
2025-11-29-13:53:11.365 0.0
2025-11-29-13:53:11.572 0.0
2025-11-29-13:53:11.775 16.9
2025-11-29-13:53:11.981 0.0
2025-11-29-13:53:12.173 0.0
2025-11-29-13:53:12.376 0.0
2025-11-29-13:53:12.581 0.0
2025-11-29-13:53:12.777 0.0
2025-11-29-13:53:12.983 0.0
2025-11-29-13:53:13.194 0.0
2025-11-29-13:53:13.387 0.0
2025-11-29-13:53:13.586 0.0
2025-11-29-13:53:13.833 0.0
2025-11-29-13:53:13.937 0.0
2025-11-29-13:53:14.125 0.0
2025-11-29-13:53:14.335 0.0
2025-11-29-13:53:14.536 0.0
2025-11-29-13:53:14.731 0.0
2025-11-29-13:53:14.941 0.0
2025-11-29-13:53:15.135 0.0
2025-11-29-13:53:15.341 0.0
2025-11-29-13:53:15.552 0.0
2025-11-29-13:53:15.746 0.0
2025-11-29-13:53:15.950 0.0
2025-11-29-13:53:16.151 0.0
2025-11-29-13:53:16.354 0.0
2025-11-29-13:53:16.545 0.0
2025-11-29-13:53:16.760 0.0
2025-11-29-13:53:16.970 0.0
2025-11-29-13:53:17.155 0.0
2025-11-29-13:53:17.363 0.0
2025-11-29-13:53:17.578 0.0
2025-11-29-13:53:17.770 0.0
2025-11-29-13:53:17.978 0.0
2025-11-29-13:53:18.184 0.0
2025-11-29-13:53:18.384 0.0
2025-11-29-13:53:18.588 0.0
2025-11-29-13:53:18.787 0.0
2025-11-29-13:53:18.994 0.0
2025-11-29-13:53:19.196 0.0
2025-11-29-13:53:19.405 0.0
2025-11-29-13:53:19.620 0.0
2025-11-29-13:53:19.828 0.0
2025-11-29-13:53:20.044 0.0
2025-11-29-13:53:20.252 0.0
2025-11-29-13:53:20.451 0.0
2025-11-29-13:53:20.661 0.0
2025-11-29-13:53:20.856 0.0
2025-11-29-13:53:21.057 0.0
2025-11-29-13:53:21.260 0.0
2025-11-29-13:53:21.462 0.0
2025-11-29-13:53:21.667 0.0
2025-11-29-13:53:21.921 0.0
2025-11-29-13:53:22.057 0.0
2025-11-29-13:53:22.275 0.0
2025-11-29-13:53:22.476 0.0
2025-11-29-13:53:22.676 0.0
2025-11-29-13:53:22.877 0.0
2025-11-29-13:53:23.078 0.0
2025-11-29-13:53:23.279 0.0
2025-11-29-13:53:23.482 0.0
2025-11-29-13:53:23.687 0.0
2025-11-29-13:53:23.887 0.0
2025-11-29-13:53:24.076 0.0
2025-11-29-13:53:24.221 0.0
2025-11-29-13:53:24.439 0.0
2025-11-29-13:53:24.625 0.0
2025-11-29-13:53:24.822 0.0
2025-11-29-13:53:25.035 0.0
2025-11-29-13:53:25.225 0.0
2025-11-29-13:53:25.435 0.0
2025-11-29-13:53:25.634 0.0
2025-11-29-13:53:25.839 0.0
2025-11-29-13:53:26.049 0.0
2025-11-29-13:53:26.253 0.0
2025-11-29-13:53:26.436 0.0
2025-11-29-13:53:26.644 0.0
2025-11-29-13:53:26.846 0.0
2025-11-29-13:53:27.051 0.0
2025-11-29-13:53:27.258 0.0
2025-11-29-13:53:27.459 0.0
2025-11-29-13:53:27.661 0.0
2025-11-29-13:53:27.868 0.0
2025-11-29-13:53:28.071 0.0
2025-11-29-13:53:28.276 0.0
2025-11-29-13:53:28.474 0.0
2025-11-29-13:53:28.680 0.0
2025-11-29-13:53:28.888 0.0
2025-11-29-13:53:29.086 0.0
2025-11-29-13:53:29.296 0.0
2025-11-29-13:53:29.494 0.0
2025-11-29-13:53:29.716 0.0
2025-11-29-13:53:29.921 0.0
2025-11-29-13:53:30.124 0.0
2025-11-29-13:53:30.326 0.0
2025-11-29-13:53:30.592 0.0
2025-11-29-13:53:30.747 0.0
2025-11-29-13:53:30.935 0.0
2025-11-29-13:53:31.143 0.0
2025-11-29-13:53:31.344 0.0
2025-11-29-13:53:31.553 16.3
2025-11-29-13:53:31.793 16.6
2025-11-29-13:53:31.976 16.3
2025-11-29-13:53:32.155 16.2
2025-11-29-13:53:32.365 0.0
2025-11-29-13:53:32.554 0.0
2025-11-29-13:53:32.766 16.3
2025-11-29-13:53:32.967 16.3
2025-11-29-13:53:33.160 0.0
2025-11-29-13:53:33.383 0.0
2025-11-29-13:53:33.563 0.0
2025-11-29-13:53:33.788 0.0
2025-11-29-13:53:33.988 0.0
2025-11-29-13:53:34.191 0.0
2025-11-29-13:53:34.398 0.0
2025-11-29-13:53:34.593 0.0
2025-11-29-13:53:34.804 0.0
2025-11-29-13:53:35.025 0.0
2025-11-29-13:53:35.199 0.0
2025-11-29-13:53:35.399 0.0
2025-11-29-13:53:35.609 0.0
2025-11-29-13:53:35.802 0.0
2025-11-29-13:53:36.006 0.0
2025-11-29-13:53:36.210 0.0
2025-11-29-13:53:36.409 0.0
2025-11-29-13:53:36.622 0.0
2025-11-29-13:53:36.814 0.0
2025-11-29-13:53:37.018 0.0
2025-11-29-13:53:37.229 0.0
2025-11-29-13:53:37.435 0.0
2025-11-29-13:53:37.663 0.0
2025-11-29-13:53:37.836 0.0
task_id: 2 去
task_id: 2 去
task_name:
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:30:07'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\2
去_去
task_id: 任务
task_id: 任务
task_name: 若是
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:39:21'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\任务_若是
2025-11-29-13:39:40.946 0.0
2025-11-29-13:39:40.946 0.0
2025-11-29-13:39:40.993 0.0
2025-11-29-13:39:41.186 0.0
2025-11-29-13:39:41.387 0.0
2025-11-29-13:39:41.588 0.0
2025-11-29-13:39:41.785 0.0
2025-11-29-13:39:41.977 0.0
2025-11-29-13:39:42.180 0.0
2025-11-29-13:39:42.392 0.0
2025-11-29-13:39:42.588 0.0
2025-11-29-13:39:42.893 16.3
task_id: 企鹅
task_id: 企鹅
task_name: 1额
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:34:35'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\企鹅_1额
task_id: 去v
task_id: 去v
task_name: 去v
status: 未启动
selected_channels:
- 通道1
created_time: '2025-11-29 13:34:18'
mission_result_folder_path: D:\restructure\liquid_level_line_detection_system\database\mission_result\去v_去v
# 通道列绿色状态更新功能
## 问题描述
当通道的 `channel_detect_status``true` 时,对应任务行的对应通道列应该变为绿色,但之前没有实现这个功能。
## 解决方案
### 1. 在 `MissionTextStatus` 类中添加新方法
#### `setChannelColumnGreenOnDetection(task_folder_name, channel_num)`
**功能**:启动检测线程时对应任务的对应通道列置为绿色
**参数**
- `task_folder_name`: 任务文件夹名称(如 "1_1")
- `channel_num`: 通道编号(1-4)
**位置**:第1819-1843行
```python
def setChannelColumnGreenOnDetection(self, task_folder_name, channel_num):
"""
启动检测线程时对应任务的对应通道列置为绿色
Args:
task_folder_name: 任务文件夹名称(如 "1_1")
channel_num: 通道编号(1-4)
"""
try:
# 查找对应的任务行
row_index = self._findTaskRow(task_folder_name)
if row_index >= 0:
# 通道列从第3列开始(0:任务编号, 1:任务名称, 2:状态, 3-6:通道1-4)
col_index = 3 + (channel_num - 1)
channel_item = self.table.item(row_index, col_index)
if channel_item:
channel_item.setForeground(self.COLOR_GREEN)
print(f"✅ [文本状态] 任务 {task_folder_name} 通道{channel_num}列已置为绿色(检测中)")
else:
print(f"⚠️ [文本状态] 未找到任务 {task_folder_name}")
except Exception as e:
print(f"❌ [文本状态] 设置通道列检测状态颜色失败: {e}")
import traceback
traceback.print_exc()
```
#### `resetChannelColumnOnStopDetection(task_folder_name, channel_num)`
**功能**:停止检测线程时恢复通道列颜色
**参数**
- `task_folder_name`: 任务文件夹名称(如 "1_1")
- `channel_num`: 通道编号(1-4)
**位置**:第1845-1868行
```python
def resetChannelColumnOnStopDetection(self, task_folder_name, channel_num):
"""
停止检测线程时恢复通道列颜色
Args:
task_folder_name: 任务文件夹名称(如 "1_1")
channel_num: 通道编号(1-4)
"""
try:
row_index = self._findTaskRow(task_folder_name)
if row_index >= 0:
col_index = 3 + (channel_num - 1)
channel_item = self.table.item(row_index, col_index)
if channel_item:
# 如果是选中行,恢复为黑色;否则恢复为灰色
if row_index == self.selected_row:
channel_item.setForeground(self.COLOR_BLACK)
else:
channel_item.setForeground(self.COLOR_GRAY)
print(f"✅ [文本状态] 任务 {task_folder_name} 通道{channel_num}列已恢复")
except Exception as e:
print(f"❌ [文本状态] 恢复通道列颜色失败: {e}")
import traceback
traceback.print_exc()
```
### 2. 修改 `_updateChannelColumnColor` 方法
**位置**:第1526-1650行
**主要改动**
1. **遍历所有任务行,更新通道列颜色**(第1557-1599行)
- 获取每个任务使用的通道列表
- 检查每个通道的检测状态
- 如果通道正在检测该任务,设置通道列为绿色
- 如果通道未检测或未分配该任务,恢复通道列颜色
2. **简化状态列更新逻辑**(第1601-1626行)
- 删除重复的通道列绿色设置
- 只检查所有通道是否都在检测,用于更新状态列
## 工作流程
### 启动检测时
1. `thread_manager.py``start_detection_thread` 调用 `_updateChannelColumnColor`
2. `_updateChannelColumnColor` 遍历所有任务行
3. 对于每个任务的每个通道:
- 检查通道是否正在执行该任务
- 检查通道的 `channel_detect_status`(通过 `channelXdetect` 变量)
- 如果检测中,调用 `setChannelColumnGreenOnDetection` 设置通道列为绿色
### 停止检测时
1. `thread_manager.py``stop_detection_thread` 调用 `_updateChannelColumnColor`
2. `_updateChannelColumnColor` 遍历所有任务行
3. 对于每个任务的每个通道:
- 检查通道是否未检测或未分配该任务
- 调用 `resetChannelColumnOnStopDetection` 恢复通道列颜色
## 颜色规则
| 状态 | 颜色 | RGB | 适用范围 |
|------|------|-----|----------|
| 默认/未启动 | 灰色 | (128, 128, 128) | 通道列 |
| 已选中 | 黑色 | (0, 0, 0) | 通道列(选中行) |
| 检测中 | 绿色 | (0, 128, 0) | 通道列(检测中) |
## 表格列索引
| 列索引 | 列名 | 说明 |
|--------|------|------|
| 0 | 任务编号 | - |
| 1 | 任务名称 | - |
| 2 | 状态 | "未启动"/"已启动"/"检测中" |
| 3 | 通道1 | 通道列,检测时变绿 |
| 4 | 通道2 | 通道列,检测时变绿 |
| 5 | 通道3 | 通道列,检测时变绿 |
| 6 | 通道4 | 通道列,检测时变绿 |
| 7 | 曲线 | 按钮列 |
## 测试建议
1. **启动单个通道检测**
- 选择一个任务并启动某个通道的检测
- 检查该任务行对应通道列是否变为绿色
- 检查其他通道列是否保持原有颜色
2. **启动多个通道检测**
- 选择一个任务并启动多个通道的检测
- 检查所有检测中的通道列是否都变为绿色
3. **停止检测**
- 停止某个通道的检测
- 检查该通道列是否恢复为灰色(或黑色,如果是选中行)
4. **切换选中行**
- 选中一个有检测中通道的任务行
- 检查非检测中的通道列是否变为黑色
- 检查检测中的通道列是否保持绿色
5. **多任务并行**
- 启动多个任务的不同通道检测
- 检查每个任务的通道列颜色是否正确
## 注意事项
1. **通道列优先级**:检测中的通道列始终为绿色,不受选中行影响
2. **自动恢复**:停止检测时自动恢复通道列颜色
3. **选中状态保持**:恢复颜色时会考虑当前选中行状态
4. **异常处理**:所有方法都包含完整的异常处理
## 完成时间
2025-11-29 13:35
...@@ -198,7 +198,7 @@ class ChannelPanelHandler: ...@@ -198,7 +198,7 @@ class ChannelPanelHandler:
pass pass
# 如果检测线程已在运行,重新启动以使用新引擎 # 如果检测线程已在运行,重新启动以使用新引擎
if channel_id in self._detection_flags and self._detection_flags[channel_id]: if channel_id in self._channel_detect_statuss and self._channel_detect_statuss[channel_id]:
pass pass
return True return True
...@@ -1429,7 +1429,7 @@ class ChannelPanelHandler: ...@@ -1429,7 +1429,7 @@ class ChannelPanelHandler:
else: else:
print(f" {channel_id} 检测引擎未就绪,检测线程将只读取帧不执行检测") print(f" {channel_id} 检测引擎未就绪,检测线程将只读取帧不执行检测")
while self._detection_flags.get(channel_id, False): while self._channel_detect_statuss.get(channel_id, False):
try: try:
loop_start_time = time.time() loop_start_time = time.time()
......
...@@ -799,11 +799,6 @@ class CurvePanelHandler: ...@@ -799,11 +799,6 @@ class CurvePanelHandler:
# 按文件夹名称排序 # 按文件夹名称排序
mission_folders.sort(key=lambda x: x['name']) mission_folders.sort(key=lambda x: x['name'])
print(f"📂 [任务扫描] 扫描目录: {mission_result_dir}")
print(f"📂 [任务扫描] 找到 {len(mission_folders)} 个任务文件夹")
for folder in mission_folders:
print(f" - {folder['name']}")
# 通知UI更新下拉框 # 通知UI更新下拉框
if self.curve_panel: if self.curve_panel:
self.curve_panel.updateMissionFolderList(mission_folders) self.curve_panel.updateMissionFolderList(mission_folders)
......
...@@ -51,7 +51,7 @@ class ChannelThreadContext: ...@@ -51,7 +51,7 @@ class ChannelThreadContext:
# ========== 控制标志 ========== # ========== 控制标志 ==========
self.capture_flag = False # 捕获线程运行标志 self.capture_flag = False # 捕获线程运行标志
self.display_flag = False # 显示线程运行标志 self.display_flag = False # 显示线程运行标志
self.detection_flag = False # 检测线程运行标志 self.channel_detect_status = False # 检测线程运行标志
# 注意:curve_flag已改为全局单例管理,不再存储在context中 # 注意:curve_flag已改为全局单例管理,不再存储在context中
self.storage_flag = False # 存储线程运行标志 self.storage_flag = False # 存储线程运行标志
......
...@@ -245,7 +245,7 @@ class ChannelThreadManager: ...@@ -245,7 +245,7 @@ class ChannelThreadManager:
if not context: if not context:
return False return False
if context.detection_flag: if context.channel_detect_status:
return True return True
try: try:
...@@ -271,17 +271,22 @@ class ChannelThreadManager: ...@@ -271,17 +271,22 @@ class ChannelThreadManager:
global_thread.register_channel(channel_id, context, callback) global_thread.register_channel(channel_id, context, callback)
# 更新通道状态 # 更新通道状态
context.detection_flag = True context.channel_detect_status = True
context.detection_enabled = True context.detection_enabled = True
# 🔥 更新主窗口中的通道检测变量(channel1detect, channel2detect等) # 🔥 更新主窗口中的通道检测变量(channel1detect, channel2detect等)
if self.main_window: if self.main_window:
detect_var_name = f'{channel_id}detect' detect_var_name = f'{channel_id}detect'
setattr(self.main_window, detect_var_name, True) setattr(self.main_window, detect_var_name, True)
print(f"🔥 [线程管理器] 已设置 {detect_var_name} = True")
# 🔥 更新任务面板中状态列的颜色(只更新为绿色,不置黑) # 🔥 更新任务面板中状态列的颜色(只更新为绿色,不置黑)
if hasattr(self.main_window, '_updateChannelColumnColor'): if hasattr(self.main_window, '_updateChannelColumnColor'):
print(f"🔥 [线程管理器] 准备调用 _updateChannelColumnColor")
self.main_window._updateChannelColumnColor() self.main_window._updateChannelColumnColor()
print(f"🔥 [线程管理器] _updateChannelColumnColor 调用完成")
else:
print(f"❌ [线程管理器] main_window 没有 _updateChannelColumnColor 方法!")
# 保持兼容性:设置一个占位符线程对象 # 保持兼容性:设置一个占位符线程对象
context.detection_thread = threading.Thread( context.detection_thread = threading.Thread(
...@@ -510,7 +515,7 @@ class ChannelThreadManager: ...@@ -510,7 +515,7 @@ class ChannelThreadManager:
global_thread.unregister_channel(channel_id) global_thread.unregister_channel(channel_id)
# 更新通道状态 # 更新通道状态
context.detection_flag = False context.channel_detect_status = False
context.detection_enabled = False context.detection_enabled = False
# 🔥 更新主窗口中的通道检测变量(channel1detect, channel2detect等) # 🔥 更新主窗口中的通道检测变量(channel1detect, channel2detect等)
...@@ -996,7 +1001,7 @@ class ChannelThreadManager: ...@@ -996,7 +1001,7 @@ class ChannelThreadManager:
'count': context.display_count 'count': context.display_count
}, },
'detection': { 'detection': {
'running': context.detection_flag, 'running': context.channel_detect_status,
'count': context.detection_count, 'count': context.detection_count,
'enabled': context.detection_enabled 'enabled': context.detection_enabled
}, },
......
...@@ -70,7 +70,7 @@ class DetectionThread: ...@@ -70,7 +70,7 @@ class DetectionThread:
channel_id = context.channel_id channel_id = context.channel_id
frame_interval = 1.0 / frame_rate if frame_rate > 0 else 0.05 frame_interval = 1.0 / frame_rate if frame_rate > 0 else 0.05
while context.detection_flag: while context.channel_detect_status:
try: try:
frame_start_time = time.time() frame_start_time = time.time()
...@@ -150,7 +150,7 @@ class DetectionThread: ...@@ -150,7 +150,7 @@ class DetectionThread:
print(f" - 批大小: {batch_size}") print(f" - 批大小: {batch_size}")
print(f" - 目标FPS: {frame_rate}") print(f" - 目标FPS: {frame_rate}")
while context.detection_flag: while context.channel_detect_status:
try: try:
frame_start_time = time.time() frame_start_time = time.time()
......
...@@ -149,10 +149,10 @@ class ViewHandler: ...@@ -149,10 +149,10 @@ class ViewHandler:
print(f"📊 [检测状态判断] 任务状态: '{mission_status}'") print(f"📊 [检测状态判断] 任务状态: '{mission_status}'")
if mission_status == "未启动": if mission_status == "未启动":
print(f"⚠️ [检测状态判断] 任务状态为'未启动',跳过detection_flag检查,直接使用历史回放模式(索引1)") print(f"⚠️ [检测状态判断] 任务状态为'未启动',跳过channel_detect_status检查,直接使用历史回放模式(索引1)")
return False return False
else: else:
print(f"✅ [检测状态判断] 任务状态为'{mission_status}',继续检查detection_flag") print(f"✅ [检测状态判断] 任务状态为'{mission_status}',继续检查channel_detect_status")
# 获取该任务使用的通道列表 # 获取该任务使用的通道列表
task_channels = self._getTaskChannels(mission_name) task_channels = self._getTaskChannels(mission_name)
...@@ -172,21 +172,21 @@ class ViewHandler: ...@@ -172,21 +172,21 @@ class ViewHandler:
print(f"🔑 [检测状态判断] 转换后的通道ID: {channel_ids}") print(f"🔑 [检测状态判断] 转换后的通道ID: {channel_ids}")
# 检查这些通道的detection_flag状态 # 检查这些通道的channel_detect_status状态
# 只要有任意一个通道的detection_flag为True,就返回True # 只要有任意一个通道的channel_detect_status为True,就返回True
for channel_id in channel_ids: for channel_id in channel_ids:
context = self.thread_manager.get_channel_context(channel_id) context = self.thread_manager.get_channel_context(channel_id)
if context: if context:
detection_flag = context.detection_flag channel_detect_status = context.channel_detect_status
print(f" 🔸 {channel_id}: detection_flag={detection_flag}, type={type(detection_flag)}") print(f" 🔸 {channel_id}: channel_detect_status={channel_detect_status}, type={type(channel_detect_status)}")
# 确保 detection_flag 是布尔值 True # 确保 channel_detect_status 是布尔值 True
if detection_flag is True or detection_flag == True: if channel_detect_status is True or channel_detect_status == True:
print(f"✅ [检测状态判断] 发现运行中的检测线程: {channel_id}") print(f"✅ [检测状态判断] 发现运行中的检测线程: {channel_id}")
return True return True
else: else:
print(f" ⚠️ {channel_id}: 没有context") print(f" ⚠️ {channel_id}: 没有context")
# 所有通道的detection_flag都为False # 所有通道的channel_detect_status都为False
print(f"❌ [检测状态判断] 所有通道的检测线程都已停止") print(f"❌ [检测状态判断] 所有通道的检测线程都已停止")
return False return False
......
1曲线模式索引0布局,只显示根据curvemission筛选使用的通道面板失效了 1曲线模式索引0布局,只显示根据curvemission筛选使用的通道面板失效了
...@@ -8,16 +8,18 @@ ...@@ -8,16 +8,18 @@
├─ 是 → 返回 False → 索引1(历史回放) ├─ 是 → 返回 False → 索引1(历史回放)
└─ 否 → 继续检查 └─ 否 → 继续检查
检查通道 detection_flag 检查通道 channel_detect_status
任意通道 detection_flag = True? 任意通道 channel_detect_status = True?
├─ 是 → 返回 True → 索引0(实时检测) ├─ 是 → 返回 True → 索引0(实时检测)
└─ 否 → 返回 False → 索引1(历史回放) └─ 否 → 返回 False → 索引1(历史回放)
保存标注结果用于持久显示 保存标注结果用于持久显示
self._last_annotation_pixmap self._last_annotation_pixmap
任务面板任务信息文本状态切换逻辑 class missiontexe_status 任务面板任务信息文本状态切换逻辑 class missiontexe_status,channel_detect_status
1任务面板信息文本显示初始默认都为灰色 1任务面板信息文本显示初始默认都为灰色
2单击选中行时文本该行文本置为黑色 2单击选中行时文本该行文本置为黑色
3启动检测线程时对应任务的对应通道列置为绿色 3启动检测线程时对应任务的对应通道列置为绿色
4新建任务信息文本显示初始默认都为灰色 4新建任务信息文本显示初始默认都为灰色
\ No newline at end of file 5单击任务行后该任务mission_status为true时才置黑该任务行
6mission_status判断逻辑,只要任意channelmission值为此任务,则此任务mission_status=true
\ No newline at end of file
...@@ -648,7 +648,24 @@ class MissionPanel(QtWidgets.QWidget): ...@@ -648,7 +648,24 @@ class MissionPanel(QtWidgets.QWidget):
# 更新分页显示(如果需要) # 更新分页显示(如果需要)
if update_display: if update_display:
self._updatePagination() # 🔥 检查新行是否在当前页,如果是则直接添加到表格,否则更新分页
display_data = self._filtered_rows_data if self._search_text else self._all_rows_data
total_rows = len(display_data)
start_index = (self._current_page - 1) * self._page_size
end_index = start_index + self._page_size
# 新行的索引
new_row_index = len(self._all_rows_data) - 1
# 如果新行在当前页范围内,直接添加到表格
if start_index <= new_row_index < end_index and self.table.rowCount() < self._page_size:
self._addRowToTable(row_data, user_data, button_callback)
# 只更新页码标签,不刷新整个表格
total_pages = (total_rows + self._page_size - 1) // self._page_size if total_rows > 0 else 1
self.page_label.setText(f"{self._current_page} / {total_pages}")
else:
# 新行不在当前页,需要完整刷新分页
self._updatePagination()
# 返回在全部数据中的索引 # 返回在全部数据中的索引
return len(self._all_rows_data) - 1 return len(self._all_rows_data) - 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment