fixed
BIN
assets/error.png
Normal file
After Width: | Height: | Size: 969 B |
BIN
assets/info.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
assets/logo.png
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 361 B After Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 492 B |
BIN
assets/run.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/success.png
Normal file
After Width: | Height: | Size: 939 B |
BIN
assets/warning.png
Normal file
After Width: | Height: | Size: 761 B |
@ -97,7 +97,7 @@ class TaskTable(EdgeComponent):
|
||||
try:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM dat_task WHERE state <= ? order by create_time", (state,))
|
||||
cursor.execute("SELECT * FROM dat_task WHERE state <= ? order by create_time desc", (state,))
|
||||
l = cursor.fetchall()
|
||||
except Exception as e:
|
||||
pass
|
||||
|
@ -1,3 +1,4 @@
|
||||
from PyQt5.QtWidgets import QMainWindow
|
||||
|
||||
|
||||
class AppContext:
|
||||
@ -8,6 +9,8 @@ class AppContext:
|
||||
_display_ratio = 1
|
||||
# EdgeContext
|
||||
_edge_context = None
|
||||
# 主窗口
|
||||
_main_window: QMainWindow = None
|
||||
|
||||
@staticmethod
|
||||
def set_ratio(ratio):
|
||||
@ -23,4 +26,12 @@ class AppContext:
|
||||
|
||||
@staticmethod
|
||||
def get_edge_context():
|
||||
return AppContext._edge_context
|
||||
return AppContext._edge_context
|
||||
|
||||
@staticmethod
|
||||
def set_main_window(win):
|
||||
AppContext._main_window = win
|
||||
|
||||
@staticmethod
|
||||
def get_main_window():
|
||||
return AppContext._main_window
|
||||
|
@ -301,7 +301,7 @@ class EdgeContext(LoggingMixin):
|
||||
self.tcp_clients.add(writer) # 添加客户端连接
|
||||
try:
|
||||
while True:
|
||||
data = await reader.read(4096)
|
||||
data = await reader.read(8192)
|
||||
if not data:
|
||||
break
|
||||
|
||||
|
49
main.py
@ -12,7 +12,7 @@ from core.logging import logger
|
||||
from core.context import AppContext
|
||||
from util import load_stylesheet
|
||||
from widget.device import DeviceWidget
|
||||
from widget.task_list import TaskListWidget
|
||||
from widget.task_list import TaskListFrame
|
||||
|
||||
class DetectWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
@ -20,7 +20,7 @@ class DetectWindow(QMainWindow):
|
||||
|
||||
self.ratio = AppContext.get_ratio()
|
||||
# 电池状态
|
||||
self.battery = 40
|
||||
self.battery = 10
|
||||
self.battery_state = 0
|
||||
|
||||
# 设置主窗口标题
|
||||
@ -50,20 +50,21 @@ class DetectWindow(QMainWindow):
|
||||
# logo
|
||||
logo_label = QLabel()
|
||||
pixmap = QPixmap("assets/logo.png")
|
||||
scaled_pixmap = pixmap.scaled(int(self.ratio * 64) - 4, int(self.ratio * 64) - 4, True)
|
||||
scaled_pixmap = pixmap.scaled(int(self.ratio * 64) - 10, int(self.ratio * 64) - 10, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
logo_label.setPixmap(scaled_pixmap)
|
||||
header_left_layout.addWidget(logo_label)
|
||||
header_left_layout.addSpacing(int(self.ratio * 5))
|
||||
# title
|
||||
self.title_label = QLabel("预埋件检测系统")
|
||||
self.title_label.setStyleSheet(f"color: white;font-size: {int(self.ratio * 24)}px;")
|
||||
self.title_label.setObjectName("titleLabel")
|
||||
header_left_layout.addWidget(self.title_label)
|
||||
header_layout.addWidget(header_left_widget, alignment=Qt.AlignLeft)
|
||||
# 右侧日期和电量
|
||||
header_right_widget = QWidget()
|
||||
header_right_layout = QHBoxLayout(header_right_widget)
|
||||
self.date_label = QLabel(QDate.currentDate().toString('yyyy年MM月dd日'))
|
||||
self.date_label.setStyleSheet(f"color: #898AC5;font-size: {int(self.ratio * 14)}px;")
|
||||
self.date_label.setObjectName("dateLabel")
|
||||
|
||||
header_right_layout.addWidget(self.date_label)
|
||||
header_right_layout.addSpacing(int(self.ratio * 10))
|
||||
|
||||
@ -72,37 +73,32 @@ class DetectWindow(QMainWindow):
|
||||
self.radar.setObjectName("radar-open")
|
||||
self.radar.setIcon(QIcon("assets/radar-fill-red.png"))
|
||||
self.radar.setIconSize(QSize(36, 36))
|
||||
self.radar.setStyleSheet("background-color: rgb(255, 255, 255, 0);")
|
||||
self.radar.setStyleSheet("background-color: transparent;")
|
||||
self.radar.clicked.connect(self.radar_clicked)
|
||||
header_right_layout.addWidget(self.radar)
|
||||
header_left_layout.addSpacing(int(self.ratio * 10))
|
||||
|
||||
# 充电图标
|
||||
self.chargeIcon = QLabel(self)
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charge_finish.png").scaled(36, 36))
|
||||
self.chargeIcon.setVisible(False)
|
||||
# 电量
|
||||
self.batteryBar = QProgressBar(self)
|
||||
self.batteryBar.setMinimum(0)
|
||||
self.batteryBar.setMaximum(100)
|
||||
self.batteryBar.setValue(self.battery)
|
||||
self.batteryBar.setFixedHeight(int(self.ratio * 24))
|
||||
self.batteryBar.setFixedWidth(int(self.ratio * 64))
|
||||
# 充电图标
|
||||
self.chargeIcon = QLabel(self)
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charging.png").scaled(24, 24, Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
||||
self.chargeIcon.setVisible(False)
|
||||
# 设置电池显示样式
|
||||
self.batteryBar.setAlignment(Qt.AlignCenter)
|
||||
self.batteryBar.setFormat("%p%")
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: #1afa29; }")
|
||||
header_right_layout.addWidget(self.chargeIcon)
|
||||
header_right_layout.addWidget(self.batteryBar)
|
||||
header_right_layout.addWidget(self.chargeIcon)
|
||||
header_layout.addWidget(header_right_widget, alignment=Qt.AlignRight)
|
||||
# 添加标题栏
|
||||
main_layout.addWidget(header_widget)
|
||||
|
||||
# 任务列表
|
||||
task_list_content = TaskListWidget()
|
||||
task_list_content.setObjectName("taskListWidget")
|
||||
task_list_content.setStyleSheet("background-color: #161B3B")
|
||||
main_layout.addWidget(task_list_content)
|
||||
task_list = TaskListFrame()
|
||||
main_layout.addWidget(task_list)
|
||||
|
||||
# 信号
|
||||
self.init_signals()
|
||||
@ -110,8 +106,8 @@ class DetectWindow(QMainWindow):
|
||||
|
||||
# 设置窗口默认全屏
|
||||
# self.resize(1024, 768)
|
||||
# self.showFullScreen()
|
||||
self.setWindowState(Qt.WindowMaximized)
|
||||
self.showFullScreen()
|
||||
# self.setWindowState(Qt.WindowMaximized)
|
||||
|
||||
#
|
||||
def init_signals(self):
|
||||
@ -136,20 +132,20 @@ class DetectWindow(QMainWindow):
|
||||
self.battery = battery
|
||||
self.batteryBar.setValue(battery)
|
||||
if self.battery < 20:
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: red; }")
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: red; border-radius: 3px;}")
|
||||
elif self.battery < 50:
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: yellow; }")
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: yellow; border-radius: 3px;}")
|
||||
else:
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: #1afa29; }")
|
||||
self.batteryBar.setStyleSheet("QProgressBar::chunk { background-color: #1afa29; border-radius: 3px;}")
|
||||
|
||||
def battery_state_change(self, battery_state):
|
||||
"""更新充电状态"""
|
||||
self.battery_state = battery_state
|
||||
if self.battery_state & 0x08 == 0x08:
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charging.png").scaled(36, 36))
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charging.png").scaled(24, 24))
|
||||
self.chargeIcon.setVisible(True)
|
||||
elif self.battery_state & 0x04 == 0x04:
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charge_finish.png").scaled(36, 36))
|
||||
self.chargeIcon.setPixmap(QPixmap("assets/icon_charge_finish.png").scaled(24, 24))
|
||||
self.chargeIcon.setVisible(True)
|
||||
else:
|
||||
self.chargeIcon.setVisible(False)
|
||||
@ -198,6 +194,9 @@ if __name__ == '__main__':
|
||||
|
||||
window = DetectWindow()
|
||||
window.setGeometry(0, 0, 1920, 1080)
|
||||
window.setWindowIcon(QIcon("assets/logo.png"))
|
||||
window.show()
|
||||
|
||||
AppContext.set_main_window(window)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
@ -6,83 +6,62 @@ QLabel {
|
||||
color: #D9E1E7;
|
||||
background-color: transparent;
|
||||
border: 0 solid transparent;
|
||||
}
|
||||
|
||||
MenuButton {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QWidget#menuWidget {
|
||||
background-color: #1E244D;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
QWidget#headerWidget {
|
||||
background-color: #2A2F55;
|
||||
background-color: #222644;
|
||||
}
|
||||
|
||||
TaskListWidget QLabel,
|
||||
TaskListWidget QPlainTextEdit {
|
||||
QLabel#titleLabel {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
QLabel#dateLabel {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
TaskListWidget QLabel#THeader {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
TaskListWidget QPushButton {
|
||||
color: #D9E1E7;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
color: #D9E1E7;
|
||||
border-radius: 8px;
|
||||
background-color: #3A36DB;
|
||||
}
|
||||
|
||||
QPushButton::disabled {
|
||||
color: #999999;
|
||||
background-color: rgba(58,54,219,0.4);
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
color: #D9E1E7;
|
||||
border: 1px solid #D9E1E7;
|
||||
border-radius: 8px;
|
||||
padding: 3 10;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QWidget#jsonWidget {
|
||||
border: 1px solid #D9E1E7;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
QPlainTextEdit {
|
||||
color: #D9E1E7;
|
||||
QProgressBar {
|
||||
color: #6a6d88;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
background-color: #ffffff;
|
||||
border: none;
|
||||
border: 1px solid #D9E1E7;
|
||||
background-color: transparent;
|
||||
height: 20px;
|
||||
width: 60px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
QAbstractScrollArea#mapArea {
|
||||
border: none;
|
||||
background: transparent;
|
||||
border: 1px solid #D9E1E7;
|
||||
QProgressBar::chunk {
|
||||
background-color: #05B8CC;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
QAbstractScrollArea QWidget {
|
||||
border: none;
|
||||
background: transparent;
|
||||
QCommandLinkButton {
|
||||
font-family: 'Noto Sans SC';
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
color: #ffffff;
|
||||
max-width: 60px;
|
||||
}
|
||||
|
||||
QScrollArea#taskArea {
|
||||
border: None;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
QScrollArea#paramArea {
|
||||
border: 1px solid #ffffff;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* === QScrollBar:horizontal === */
|
||||
QScrollBar:horizontal {
|
||||
background: rgba(58,54,219,0.45);
|
||||
height: 5px;
|
||||
margin: 0px;
|
||||
border-radius: 2px;
|
||||
height: 8px;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
QScrollBar::handle:horizontal {
|
||||
@ -106,15 +85,15 @@ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
|
||||
/* === QScrollBar:vertical === */
|
||||
QScrollBar:vertical {
|
||||
background: rgba(58,54,219,0.45);
|
||||
width: 5px;
|
||||
margin: 0px;
|
||||
border-radius: 2px;
|
||||
width: 8px;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical {
|
||||
background: rgba(58,54,219,0.9);
|
||||
background: #555977;
|
||||
min-height: 20px;
|
||||
border-radius: 2px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:vertical {
|
||||
@ -127,168 +106,134 @@ QScrollBar::sub-line:vertical {
|
||||
|
||||
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
|
||||
background: none;
|
||||
}
|
||||
|
||||
TaskRunDialog {
|
||||
background-color: #161B3B;
|
||||
}
|
||||
|
||||
QWidget#viewWidget {
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
QPushButton#stopTaskButton {
|
||||
background-color: #FF4444;
|
||||
}
|
||||
|
||||
EmbedItem QLabel {
|
||||
color: #999999;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
EmbedItem QPushButton {
|
||||
border: 1px solid #999999;
|
||||
border-radius: 0;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
EmbedItem QPushButton#STD {
|
||||
border: 1px solid transparent;
|
||||
background-color: #FF4444;
|
||||
}
|
||||
|
||||
QWidget#checkWidget,
|
||||
QWidget#viewCheckWidget {
|
||||
border: 0px dashed #6cff6c;
|
||||
}
|
||||
|
||||
QWidget#legendCheckWidget {
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
max-width: 20px;
|
||||
height: 20px;
|
||||
min-height: 20px;
|
||||
max-height: 20px;
|
||||
border: 1px dashed #6cff6c;
|
||||
}
|
||||
|
||||
QWidget#legendCheckLabel {
|
||||
color: #6cff6c;
|
||||
}
|
||||
|
||||
QWidget#legendStdWidget {
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
max-width: 20px;
|
||||
height: 20px;
|
||||
min-height: 20px;
|
||||
max-height: 20px;
|
||||
background-color: #FF4444;
|
||||
}
|
||||
|
||||
QWidget#legendStdLabel {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
QWidget#legendOkWidget {
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
max-width: 20px;
|
||||
height: 20px;
|
||||
min-height: 20px;
|
||||
max-height: 20px;
|
||||
border: 1px solid #6cff6c;
|
||||
}
|
||||
|
||||
QWidget#legendOkLabel {
|
||||
color: #6cff6c;
|
||||
}
|
||||
|
||||
QWidget#legendNgWidget {
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
max-width: 20px;
|
||||
height: 20px;
|
||||
min-height: 20px;
|
||||
max-height: 20px;
|
||||
border: 1px solid #FF4444;
|
||||
}
|
||||
|
||||
QWidget#legendNgLabel {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
QWidget#legendNormalWidget {
|
||||
width: 20px;
|
||||
min-width: 20px;
|
||||
max-width: 20px;
|
||||
height: 20px;
|
||||
min-height: 20px;
|
||||
max-height: 20px;
|
||||
border: 1px solid #999999;
|
||||
}
|
||||
|
||||
QWidget#legendNormalLabel {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
EmbedDetail {
|
||||
background-color: #161B3B;
|
||||
border: 1px solid #999999;
|
||||
}
|
||||
|
||||
EmbedDetail QPushButton {
|
||||
padding: 5px;
|
||||
font-size: 16px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QMessageBox {
|
||||
background-color: #161B3B; /* QMessageBox背景颜色 */
|
||||
}
|
||||
|
||||
QMessageBox QLabel#qt_msgbox_label { /* textLabel */
|
||||
color: #FFFFFF;
|
||||
font-size: 16px;
|
||||
background-color: transparent;
|
||||
min-width: 240px; /* textLabel设置最小宽度可以相应的改变QMessageBox的最小宽度 */
|
||||
min-height: 40px; /* textLabel和iconLabel高度保持一致 */
|
||||
}
|
||||
|
||||
QMessageBox QLabel#qt_msgboxex_icon_label { /* iconLabel */
|
||||
width: 40px;
|
||||
height: 40px; /* textLabel和iconLabel高度保持一致 */
|
||||
}
|
||||
|
||||
QMessageBox QPushButton { /* QMessageBox中的QPushButton样式 */
|
||||
border: 1px solid #3A36DB;
|
||||
border-radius: 8px;
|
||||
background-color: #3A36DB;
|
||||
color: #FFFFFF;
|
||||
font-size: 16px;
|
||||
min-width: 70px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
QMessageBox QPushButton:hover {
|
||||
background-color: #298DFF;
|
||||
color: #F2F2F2;
|
||||
}
|
||||
|
||||
QMessageBox QPushButton:pressed {
|
||||
background-color: #257FE6;
|
||||
}
|
||||
|
||||
QMessageBox QDialogButtonBox#qt_msgbox_buttonbox { /* buttonBox */
|
||||
button-layout: 0; /* 设置QPushButton布局好像没啥作用 */
|
||||
}
|
||||
|
||||
QPlainTextEdit#logText {
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
MessageBox {
|
||||
background-color: #2a2f55;
|
||||
border: 1px solid rgb(85,89,119);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
MessageBox QPushButton {
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
color: #bbbbbb;
|
||||
background-color: #1d63b3;
|
||||
border: 1px solid #257fe6;
|
||||
border-radius: 7px;
|
||||
padding: 6px 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
MessageBox QPushButton:hover {
|
||||
background-color: #298DFF;
|
||||
}
|
||||
|
||||
TaskResultFrame {
|
||||
background-color: #161B3B;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultEmbedFrame {
|
||||
background-color: #ffffff;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultFrame QWidget#embedButton {
|
||||
color: #555555;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
border: 1px solid #999999;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendCheckWidget {
|
||||
border: 2px solid #a7ffa7;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendCheckLabel {
|
||||
color: #a7ffa7;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendStdWidget {
|
||||
background-color: #FF4444;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendStdLabel {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendOkWidget {
|
||||
border: 2px solid #6cff6c;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendOkLabel {
|
||||
color: #6cff6c;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendNgWidget {
|
||||
border: 2px solid #FF4444;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendNgLabel {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendNormalWidget {
|
||||
border: 2px solid #999999;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
TaskResultLegendFrame QWidget#legendNormalLabel {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPushButton {
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
background-color: #1d63b3;
|
||||
border: 1px solid #257fe6;
|
||||
border-radius: 7px;
|
||||
padding: 6px 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPushButton:disabled {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit {
|
||||
font-size: 14px;
|
||||
border: 1px solid #555977;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar:vertical {
|
||||
background: transparent;
|
||||
width: 8px;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar::handle:vertical {
|
||||
background: #555977;
|
||||
min-height: 20px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar::add-line:vertical {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar::sub-line:vertical {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar::add-page:vertical,
|
||||
TaskResultToolsFrame QPlainTextEdit QScrollBar::sub-page:vertical {
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
69
widget/message_box.py
Normal file
@ -0,0 +1,69 @@
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QColor, QPixmap
|
||||
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QGraphicsDropShadowEffect, QPushButton
|
||||
|
||||
from core.context import AppContext
|
||||
|
||||
|
||||
class MessageBox(QFrame):
|
||||
def __init__(self, title, mode, text, parent=None):
|
||||
super(MessageBox, self).__init__(parent)
|
||||
self.title = title
|
||||
self.mode = mode
|
||||
self.text = text
|
||||
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
self.setWindowTitle("")
|
||||
|
||||
self.effect_shadow = QGraphicsDropShadowEffect(self)
|
||||
self.effect_shadow.setOffset(0, 0) # 偏移
|
||||
self.effect_shadow.setBlurRadius(10) # 阴影半径
|
||||
self.effect_shadow.setColor(QColor(85,89,119)) # 阴影颜色
|
||||
self.setGraphicsEffect(self.effect_shadow)
|
||||
|
||||
self.setGeometry((AppContext.get_main_window().geometry().width() - 420) / 2,
|
||||
(AppContext.get_main_window().geometry().height() - 220) / 2,
|
||||
420, 220)
|
||||
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
layout = QGridLayout()
|
||||
layout.setContentsMargins(30,20,30,20)
|
||||
self.setLayout(layout)
|
||||
|
||||
icon_label = QLabel()
|
||||
icon_label.setFixedWidth(60)
|
||||
if self.mode == "warning":
|
||||
icon_label.setPixmap(self.set_icon("assets/warning.png"))
|
||||
elif self.mode == "error":
|
||||
icon_label.setPixmap(self.set_icon("assets/error.png"))
|
||||
elif self.mode == "info":
|
||||
icon_label.setPixmap(self.set_icon("assets/info.png"))
|
||||
elif self.mode == "success":
|
||||
icon_label.setPixmap(self.set_icon("assets/success.png"))
|
||||
layout.addWidget(icon_label, 0, 0)
|
||||
|
||||
title_label = QLabel()
|
||||
title_label.setText(self.title)
|
||||
title_label.setAlignment(Qt.AlignLeft)
|
||||
title_label.setStyleSheet("font-size: 18px; font-weight: bold;")
|
||||
layout.addWidget(title_label, 0, 1, Qt.AlignVCenter)
|
||||
|
||||
text_label = QLabel()
|
||||
text_label.setText(self.text)
|
||||
text_label.setWordWrap(True)
|
||||
text_label.setAlignment(Qt.AlignLeft)
|
||||
layout.addWidget(text_label, 1, 1, Qt.AlignTop)
|
||||
|
||||
button = QPushButton()
|
||||
button.setText("关闭")
|
||||
button.clicked.connect(lambda: self.close())
|
||||
layout.addWidget(button, 2, 1, Qt.AlignRight)
|
||||
|
||||
@staticmethod
|
||||
def set_icon(path):
|
||||
pixmap = QPixmap(path)
|
||||
scaled_pixmap = pixmap.scaled(40, 40, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
return scaled_pixmap
|
153
widget/task_item.py
Normal file
@ -0,0 +1,153 @@
|
||||
from datetime import datetime
|
||||
from os import replace
|
||||
|
||||
from PyQt5.QtGui import QColor, QIcon
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QFrame, QHBoxLayout, QLabel, QGridLayout, QPlainTextEdit, \
|
||||
QGraphicsDropShadowEffect, QCommandLinkButton, QScrollArea, QMessageBox
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
import json
|
||||
|
||||
from widget.message_box import MessageBox
|
||||
from widget.task_result import TaskResultFrame
|
||||
from widget.task_run import TaskRunDialog
|
||||
from core.context import AppContext
|
||||
|
||||
class TaskItemFrame(QFrame):
|
||||
def __init__(self, task, max_height, parent=None):
|
||||
super(TaskItemFrame, self).__init__(parent)
|
||||
|
||||
self.setFixedSize(int((1920 - 50)/3), int((max_height - 30)/2))
|
||||
self.setStyleSheet("background-color: #2a2f55; border-radius: 10px;")
|
||||
|
||||
self.effect_shadow = QGraphicsDropShadowEffect(self)
|
||||
self.effect_shadow.setOffset(0, 0) # 偏移
|
||||
self.effect_shadow.setBlurRadius(10) # 阴影半径
|
||||
self.effect_shadow.setColor(QColor(85,89,119)) # 阴影颜色
|
||||
self.setGraphicsEffect(self.effect_shadow)
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.setSpacing(0)
|
||||
layout.setContentsMargins(30, 10, 20, 10)
|
||||
|
||||
layout.addWidget(self.add_item("任务名称:", True), 0, 0)
|
||||
layout.addWidget(self.add_item(task[1]), 0, 1)
|
||||
layout.addWidget(self.add_item("设备序列号:", True), 1, 0)
|
||||
layout.addWidget(self.add_item(task[2]), 1, 1, 1, 2)
|
||||
layout.addWidget(self.add_item("开始时间:", True), 3, 0)
|
||||
if task[6] is None:
|
||||
layout.addWidget(self.add_item(""), 3, 1, 1, 2)
|
||||
else:
|
||||
layout.addWidget(self.add_item(task[6][0: -10]), 3, 1, 1, 2)
|
||||
layout.addWidget(self.add_item("结束时间:", True), 4, 0)
|
||||
if task[7] is None:
|
||||
layout.addWidget(self.add_item(""), 4, 1, 1, 2)
|
||||
else:
|
||||
layout.addWidget(self.add_item(task[7][0: -10]), 4, 1, 1, 2)
|
||||
layout.addWidget(self.add_item("创建时间:", True), 5, 0)
|
||||
layout.addWidget(self.add_item(task[9][0: -3]), 5, 1, 1, 2)
|
||||
layout.addWidget(self.add_item("任务参数:", True), 6, 0)
|
||||
layout.addWidget(self.add_param(task[3]), 6, 1, 1, 2, Qt.AlignTop)
|
||||
|
||||
button_start = QCommandLinkButton("", self)
|
||||
button_start.setCheckable(True)
|
||||
icon = QIcon("assets/run.png")
|
||||
button_start.setIcon(icon)
|
||||
button_start.setIconSize(QSize(36, 36))
|
||||
button_start.clicked.connect(lambda: self.start_task(task))
|
||||
layout.addWidget(button_start, 0, 2)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
@staticmethod
|
||||
def add_item(text, is_label = False):
|
||||
label = QLabel()
|
||||
if is_label:
|
||||
label.setFixedWidth(100)
|
||||
label.setText(text)
|
||||
return label
|
||||
|
||||
def add_param(self, json_str):
|
||||
content_widget = QWidget()
|
||||
content_widget.setStyleSheet("border: none;")
|
||||
|
||||
scroll_area = QScrollArea()
|
||||
scroll_area.setObjectName("paramArea")
|
||||
scroll_area.setStyleSheet("border-radius: 0;")
|
||||
scroll_area.setWidgetResizable(True)
|
||||
scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
scroll_area.setFixedSize(QSize(470, 200))
|
||||
|
||||
scroll_area.setWidget(content_widget)
|
||||
|
||||
if json_str is None or len(json_str) == 0:
|
||||
return scroll_area
|
||||
|
||||
params = json.loads(json_str)
|
||||
|
||||
if len(params) == 0:
|
||||
return scroll_area
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.setSpacing(0)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
row = 0
|
||||
layout.addWidget(self.add_param_item("编号", 150, True), row, 0)
|
||||
layout.addWidget(self.add_param_item("类型", 100, True), row, 1)
|
||||
layout.addWidget(self.add_param_item("X", 65, True), row, 2)
|
||||
layout.addWidget(self.add_param_item("Y", 65, True), row, 3)
|
||||
layout.addWidget(self.add_param_item("中心点", -1, True), row, 4)
|
||||
|
||||
row = row + 1
|
||||
for param in params:
|
||||
layout.addWidget(self.add_param_item(param['code'], 150, is_bottom = row == len(params)), row, 0)
|
||||
layout.addWidget(self.add_param_item(param['type'], 100, is_bottom = row == len(params)), row, 1)
|
||||
layout.addWidget(self.add_param_item(param['x'], 65, is_bottom = row == len(params)), row, 2)
|
||||
layout.addWidget(self.add_param_item(param['y'], 65, is_bottom = row == len(params)), row, 3)
|
||||
if len(param['center']) != 0 and '.' not in param['center']:
|
||||
index = len(param['center']) - 3
|
||||
str1 = param['center'][0: index]
|
||||
str2 = param['center'][index: ]
|
||||
layout.addWidget(self.add_param_item(str1 + "." + str2, -1, is_bottom = row == len(params)), row, 4)
|
||||
else:
|
||||
layout.addWidget(self.add_param_item(param['center'], -1, is_bottom = row == len(params)), row, 4)
|
||||
row = row + 1
|
||||
|
||||
content_widget.setLayout(layout)
|
||||
return scroll_area
|
||||
|
||||
@staticmethod
|
||||
def add_param_item(text, width, is_header = False, is_bottom = False):
|
||||
label = QLabel()
|
||||
if width != -1:
|
||||
label.setFixedWidth(width)
|
||||
style_str = "text-align: center; border-right: 1px solid #ffffff;"
|
||||
if is_header:
|
||||
label.setFixedHeight(32)
|
||||
style_str += "background-color: #454962;"
|
||||
if not is_bottom:
|
||||
style_str += "border-bottom: 1px solid #ffffff;"
|
||||
label.setStyleSheet(style_str)
|
||||
label.setAlignment(Qt.AlignCenter)
|
||||
label.setText(text)
|
||||
return label
|
||||
|
||||
@staticmethod
|
||||
def start_task(task):
|
||||
params = json.loads(task[3])
|
||||
if len(task[3]) == 0 or len(params) == 0:
|
||||
MessageBox("任务名称: " + task[1],"warning", "任务未设置参数!", AppContext.get_main_window()).show()
|
||||
return
|
||||
task_table = AppContext.get_edge_context().get_component("dat_task")
|
||||
task_table.update_task({ "id": task[0], "state": 1, "start_time": datetime.now() })
|
||||
|
||||
TaskResultFrame(task, AppContext.get_main_window()).show()
|
||||
|
||||
# self.run_dialog = TaskRunDialog(task[3])
|
||||
# self.run_dialog.setGeometry(0,0,1920,1080)
|
||||
# dialog_result = self.run_dialog.exec_()
|
||||
# if dialog_result == 0:
|
||||
# c = 0
|
||||
# # self.name_text.setText(None)
|
||||
# # self.file_content.setPlainText(None)
|
@ -1,148 +1,61 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
import pandas as pd
|
||||
from PyQt5.QtCore import Qt, QRect
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QGridLayout, QLineEdit, QLabel, QHBoxLayout, QPushButton, QFileDialog, \
|
||||
QScrollArea, QPlainTextEdit, QMessageBox
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QGridLayout, QLabel, QScrollArea, QFrame
|
||||
|
||||
from core.context import AppContext
|
||||
from widget.task_run import TaskRunDialog
|
||||
from widget.task_item import TaskItemFrame
|
||||
|
||||
|
||||
class TaskListWidget(QWidget):
|
||||
class TaskListFrame(QFrame):
|
||||
def __init__(self, parent=None):
|
||||
super(TaskListWidget, self).__init__(parent)
|
||||
self.ratio = AppContext.get_ratio()
|
||||
self.run_dialog = None
|
||||
super(TaskListFrame, self).__init__(parent)
|
||||
|
||||
scroll_area = QScrollArea()
|
||||
scroll_area.setStyleSheet("border: none;")
|
||||
scroll_area.setWidgetResizable(True)
|
||||
scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
self.content_widget = QWidget()
|
||||
|
||||
scroll_area.setWidget(self.content_widget)
|
||||
|
||||
widget = QWidget()
|
||||
widget_layout = QVBoxLayout(widget)
|
||||
widget_layout.setContentsMargins(10, 10, 10, 10)
|
||||
widget_layout.setSpacing(0)
|
||||
widget_layout.addWidget(scroll_area)
|
||||
self.setStyleSheet("background-color: #15182b")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(widget)
|
||||
|
||||
self.init_ui()
|
||||
self.content_widget = QWidget()
|
||||
self.content_widget_layout = QGridLayout(self.content_widget)
|
||||
self.content_widget_layout.setContentsMargins(10, 10, 20, 10)
|
||||
self.content_widget_layout.setSpacing(10)
|
||||
|
||||
scroll_area = QScrollArea()
|
||||
scroll_area.setObjectName("taskArea")
|
||||
scroll_area.setWidgetResizable(True)
|
||||
scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
scroll_area.setWidget(self.content_widget)
|
||||
layout.addWidget(scroll_area)
|
||||
|
||||
AppContext.get_edge_context().get_component('dat_task').signals.on_receive_task.connect(self.init_ui)
|
||||
|
||||
def showEvent(self, e):
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
task_table = AppContext.get_edge_context().get_component("dat_task")
|
||||
tasks = task_table.list_task(1)
|
||||
if len(tasks) == 0:
|
||||
return
|
||||
self.content_widget.children().clear()
|
||||
# 添加 TITLE
|
||||
x = 0
|
||||
y = 0
|
||||
offset = 10
|
||||
x = x + offset
|
||||
y = y + offset
|
||||
label_name = QLabel(self.content_widget)
|
||||
label_name.setObjectName("THeader")
|
||||
label_name.setText("任务名称")
|
||||
label_name.setGeometry(QRect(x, y, 200, 30))
|
||||
x = x + 200 + offset
|
||||
label_sn = QLabel(self.content_widget)
|
||||
label_sn.setObjectName("THeader")
|
||||
label_sn.setText("设备序列号")
|
||||
label_sn.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_param = QLabel(self.content_widget)
|
||||
label_param.setObjectName("THeader")
|
||||
label_param.setText("参数")
|
||||
label_param.setGeometry(QRect(x, y, 400, 30))
|
||||
x = x + 400 + offset
|
||||
label_start = QLabel(self.content_widget)
|
||||
label_start.setObjectName("THeader")
|
||||
label_start.setText("开始时间")
|
||||
label_start.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_end = QLabel(self.content_widget)
|
||||
label_end.setObjectName("THeader")
|
||||
label_end.setText("结束时间")
|
||||
label_end.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_create = QLabel(self.content_widget)
|
||||
label_create.setObjectName("THeader")
|
||||
label_create.setText("创建时间")
|
||||
label_create.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_action = QLabel(self.content_widget)
|
||||
label_action.setObjectName("THeader")
|
||||
label_action.setText("操作")
|
||||
label_action.setGeometry(QRect(x, y, 200, 30))
|
||||
|
||||
y = y + 30 + offset
|
||||
while self.content_widget_layout.count():
|
||||
item = self.content_widget_layout.takeAt(0)
|
||||
widget = item.widget()
|
||||
if widget is not None:
|
||||
widget.deleteLater()
|
||||
|
||||
row = 0
|
||||
column = 0
|
||||
for task in tasks:
|
||||
x = offset
|
||||
label_name = QLabel(self.content_widget)
|
||||
label_name.setText(task[1])
|
||||
label_name.setGeometry(QRect(x, y, 200, 30))
|
||||
x = x + 200 + offset
|
||||
label_sn = QLabel(self.content_widget)
|
||||
label_sn.setText(task[2])
|
||||
label_sn.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
param = QPlainTextEdit(self.content_widget)
|
||||
param.setPlainText(task[3])
|
||||
param.setReadOnly(True)
|
||||
param.setStyleSheet("border: 1px solid rgba(58,54,219,0.45); border-radius: 6px;")
|
||||
param.setGeometry(QRect(x, y, 400, 120))
|
||||
x = x + 400 + offset
|
||||
label_start = QLabel(self.content_widget)
|
||||
label_start.setText(task[6])
|
||||
label_start.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_end = QLabel(self.content_widget)
|
||||
label_end.setText(task[7])
|
||||
label_end.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
label_create = QLabel(self.content_widget)
|
||||
label_create.setText(task[8])
|
||||
label_create.setGeometry(QRect(x, y, 150, 30))
|
||||
x = x + 150 + offset
|
||||
run_task = QPushButton(self.content_widget)
|
||||
run_task.setStyleSheet("background-color: #3A36DB;")
|
||||
run_task.setObjectName("run_task")
|
||||
run_task.setText("开始任务")
|
||||
run_task.setGeometry(QRect(x, y, 120, 30))
|
||||
run_task.clicked.connect(lambda: self.start_task(task))
|
||||
task_item = TaskItemFrame(task, self.content_widget.geometry().height())
|
||||
self.content_widget_layout.addWidget(task_item, row, column, Qt.AlignTop)
|
||||
column += 1
|
||||
if column == 3:
|
||||
row += 1
|
||||
column = 0
|
||||
|
||||
y = y + 120 + offset
|
||||
|
||||
self.content_widget.setFixedHeight(y + offset)
|
||||
|
||||
for ctl in self.content_widget.children():
|
||||
if isinstance(ctl, QWidget):
|
||||
ctl.setVisible(True)
|
||||
|
||||
def start_task(self, task):
|
||||
task_table = AppContext.get_edge_context().get_component("dat_task")
|
||||
task_table.update_task({ "id": task[0], "state": 1, "start_time": datetime.now() })
|
||||
try:
|
||||
param_json = json.loads(task[3])
|
||||
self.run_dialog = TaskRunDialog(param_json)
|
||||
self.run_dialog.setGeometry(0,0,1920,1080)
|
||||
dialog_result = self.run_dialog.exec_()
|
||||
if dialog_result == 0:
|
||||
c = 0
|
||||
# self.name_text.setText(None)
|
||||
# self.file_content.setPlainText(None)
|
||||
except Exception as e:
|
||||
QMessageBox.warning(self, 'JSON Error', f'Invalid JSON: {e}')
|
||||
if column == 1 and row == 0:
|
||||
self.content_widget_layout.addWidget(QWidget(), 0, 1)
|
||||
self.content_widget_layout.addWidget(QWidget(), 0, 2)
|
||||
if column == 2 and row == 0:
|
||||
self.content_widget_layout.addWidget(QWidget(), 0, 2)
|
||||
|
170
widget/task_result.py
Normal file
@ -0,0 +1,170 @@
|
||||
from PyQt5.QtWidgets import QFrame, QGraphicsDropShadowEffect, QWidget, QGridLayout, QLabel
|
||||
from PyQt5.QtCore import Qt, QSize, QRect
|
||||
from PyQt5.QtGui import QColor, QPixmap, QImage
|
||||
|
||||
from components.image_framework import MSG_LOCATION_RECORD, MSG_DETECTION_RECORD, get_msg_info
|
||||
from core.context import AppContext
|
||||
from widget.message_box import MessageBox
|
||||
from widget.task_result_embed import TaskResultEmbedFrame
|
||||
from widget.task_result_legend import TaskResultLegendFrame
|
||||
from widget.task_result_tools import TaskResultToolsFrame
|
||||
import json
|
||||
import math
|
||||
import cv2
|
||||
|
||||
class TaskResultFrame(QFrame):
|
||||
def __init__(self, task, parent=None):
|
||||
super(TaskResultFrame, self).__init__(parent)
|
||||
self.task = task
|
||||
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
self.setWindowTitle("")
|
||||
|
||||
self.effect_shadow = QGraphicsDropShadowEffect(self)
|
||||
self.effect_shadow.setOffset(0, 0) # 偏移
|
||||
self.effect_shadow.setBlurRadius(10) # 阴影半径
|
||||
self.effect_shadow.setColor(QColor(85,89,119)) # 阴影颜色
|
||||
self.setGraphicsEffect(self.effect_shadow)
|
||||
|
||||
self.result_embed_frame = None
|
||||
self.result_big_widget = None
|
||||
self.result_big_label = None
|
||||
self.result_small_widget = None
|
||||
self.result_small_label = None
|
||||
self.result_tools_frame = None
|
||||
|
||||
self.init_ui()
|
||||
|
||||
self.setGeometry(5, 5, AppContext.get_main_window().geometry().width() - 10, AppContext.get_main_window().geometry().height() - 10)
|
||||
|
||||
AppContext.get_edge_context().get_component('image-framework').signals.on_image_detect_result.connect(
|
||||
lambda data: self.image_result(data))
|
||||
|
||||
def showEvent(self, e):
|
||||
big_width = self.result_big_widget.geometry().width()
|
||||
big_height = self.result_big_widget.geometry().height()
|
||||
self.result_big_label.setFixedWidth(1920 * (big_height - 20) / 1080)
|
||||
self.result_big_label.setFixedHeight(big_height - 20)
|
||||
self.result_big_label.move((big_width - 1920 * (big_height - 20) / 1080) / 2, 10)
|
||||
|
||||
small_width = self.result_small_widget.geometry().width()
|
||||
small_height = self.result_small_widget.geometry().height()
|
||||
self.result_small_label.setFixedWidth(930 * (small_height - 20) / 700)
|
||||
self.result_small_label.setFixedHeight(small_height - 20)
|
||||
self.result_small_label.move((small_width - 930 * (small_height - 20) / 700) / 2, 10)
|
||||
|
||||
AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
|
||||
def image_result(self, msg):
|
||||
qt_image = None
|
||||
if msg.im2D is not None:
|
||||
rgb_frame = cv2.cvtColor(msg.im2D, cv2.COLOR_BGR2RGB)
|
||||
height, width, channels = rgb_frame.shape
|
||||
bytes_per_line = channels * width
|
||||
qt_image = QImage(rgb_frame.data, width, height, bytes_per_line, QImage.Format_RGB888)
|
||||
|
||||
if msg.msg_type == MSG_LOCATION_RECORD:
|
||||
if qt_image is None:
|
||||
return
|
||||
try:
|
||||
big_pixmap = QPixmap.fromImage(qt_image)
|
||||
# sc = big_pixmap.height() / self.result_big_label.geometry().height()
|
||||
# self.view_label.setFixedWidth(view_pixmap.width() / sc)
|
||||
self.result_big_label.setPixmap(big_pixmap)
|
||||
# self.view_label.setGeometry((self.view_widget.width() - self.view_label.width()) / 2, 0, self.view_label.width(), self.view_label.height())
|
||||
except Exception as e:
|
||||
dd = 0
|
||||
elif msg.msg_type == MSG_DETECTION_RECORD:
|
||||
# 显示日志
|
||||
# self.log_text.appendPlainText(get_msg_info(msg.record.code).decode('utf-8'))
|
||||
if msg.record.code < 0:
|
||||
self.result_tools_frame.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("red"))
|
||||
self.result_tools_frame.set_default()
|
||||
MessageBox("错误信息", "error", get_msg_info(msg.record.code).decode('utf-8'), AppContext.get_main_window()).show()
|
||||
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("red"))
|
||||
# QMessageBox.warning(self, '错误信息', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
# self.set_button_default()
|
||||
AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
elif msg.record.code == 1008:
|
||||
self.result_tools_frame.start_adjust_button.setEnabled(False)
|
||||
self.result_tools_frame.start_check_button.setEnabled(True)
|
||||
self.result_tools_frame.stop_check_button.setEnabled(True)
|
||||
self.result_tools_frame.stop_task_button.setEnabled(False)
|
||||
elif msg.record.code == 1012:
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("green"))
|
||||
# QMessageBox.warning(self, '成功信息', "检测结束")
|
||||
# self.set_button_default()
|
||||
|
||||
self.result_tools_frame.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("green"))
|
||||
self.result_tools_frame.set_default()
|
||||
MessageBox("成功信息", "success", "检测结束", AppContext.get_main_window()).show()
|
||||
AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
else:
|
||||
self.result_tools_frame.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("white"))
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("white"))
|
||||
if qt_image is None:
|
||||
return
|
||||
try:
|
||||
small_pixmap = QPixmap.fromImage(qt_image)
|
||||
self.result_small_label.setPixmap(small_pixmap)
|
||||
# view_pixmap = QPixmap.fromImage(qt_image)
|
||||
# self.picture_label.setPixmap(view_pixmap)
|
||||
except Exception as e:
|
||||
dd = 0
|
||||
else:
|
||||
ddd = 0
|
||||
|
||||
def init_ui(self):
|
||||
layout = QGridLayout()
|
||||
layout.setRowStretch(0,15)
|
||||
layout.setRowStretch(1,1)
|
||||
layout.setRowStretch(2,15)
|
||||
self.setLayout(layout)
|
||||
|
||||
# bim
|
||||
self.result_embed_frame = TaskResultEmbedFrame(self.task)
|
||||
layout.addWidget(self.result_embed_frame, 0, 0)
|
||||
|
||||
# legend
|
||||
layout.addWidget(TaskResultLegendFrame(), 1, 0)
|
||||
|
||||
# result
|
||||
result_widget = QWidget()
|
||||
result_widget_layout = QGridLayout()
|
||||
result_widget_layout.setContentsMargins(0,0,0,0)
|
||||
result_widget_layout.setColumnStretch(0, 5)
|
||||
result_widget_layout.setColumnStretch(1, 4)
|
||||
result_widget_layout.setColumnStretch(2, 1)
|
||||
result_widget.setLayout(result_widget_layout)
|
||||
layout.addWidget(result_widget, 2, 0)
|
||||
|
||||
# result
|
||||
# 摄像头1
|
||||
self.result_big_widget = QWidget()
|
||||
self.result_big_widget.setStyleSheet("background-color: rgba(255, 255, 255, 0.1);")
|
||||
self.result_big_label = QLabel(self.result_big_widget)
|
||||
self.result_big_label.setText("广角摄像头")
|
||||
self.result_big_label.setAlignment(Qt.AlignCenter)
|
||||
self.result_big_label.setStyleSheet("background: #222222;")
|
||||
self.result_big_label.setVisible(True)
|
||||
|
||||
# 摄像头2
|
||||
self.result_small_widget = QWidget()
|
||||
self.result_small_widget.setStyleSheet("background-color: rgba(255, 255, 255, 0.1);")
|
||||
self.result_small_label = QLabel(self.result_small_widget)
|
||||
self.result_small_label.setText("高清摄像头")
|
||||
self.result_small_label.setAlignment(Qt.AlignCenter)
|
||||
self.result_small_label.setStyleSheet("background: #222222;")
|
||||
self.result_small_label.setVisible(True)
|
||||
|
||||
# 按钮
|
||||
self.result_tools_frame = TaskResultToolsFrame(self)
|
||||
self.result_tools_frame.set_default()
|
||||
|
||||
# 布局
|
||||
result_widget_layout.addWidget(self.result_big_widget, 0, 0)
|
||||
result_widget_layout.addWidget(self.result_small_widget, 0, 1)
|
||||
result_widget_layout.addWidget(self.result_tools_frame, 0, 2)
|
||||
|
42
widget/task_result_embed.py
Normal file
@ -0,0 +1,42 @@
|
||||
import math
|
||||
|
||||
from PyQt5.QtWidgets import QFrame, QWidget, QPushButton
|
||||
import json
|
||||
|
||||
from exceptiongroup import catch
|
||||
|
||||
class TaskResultEmbedFrame(QFrame):
|
||||
def __init__(self, task, parent=None):
|
||||
super(TaskResultEmbedFrame, self).__init__(parent)
|
||||
self.task = task
|
||||
self.embed_buttons = []
|
||||
|
||||
def showEvent(self, e):
|
||||
params = json.loads(self.task[3])
|
||||
try:
|
||||
max_x = math.ceil(float(max(params, key=lambda p: float(p["x"]))["x"]) / 1000) * 1000
|
||||
max_y = math.ceil(float(max(params, key=lambda p: float(p["center"]))["center"])) * 1000
|
||||
w = self.geometry().width()
|
||||
h = self.geometry().height()
|
||||
scale = min(max_x / w, max_y / h)
|
||||
for param in params:
|
||||
embed_button = QPushButton(param["code"], self)
|
||||
embed_button.setObjectName("embedButton")
|
||||
embed_button.setFixedSize(math.ceil(float(param["w"]) / scale), math.ceil(float(param["h"]) / scale))
|
||||
left = math.ceil((float(param["x"]) - float(param["w"]) / 2) / scale)
|
||||
top = h - math.ceil(float(param["center"]) * 1000 / scale)
|
||||
embed_button.move(left, top)
|
||||
embed_button.setVisible(True)
|
||||
|
||||
except ValueError:
|
||||
print("任务参数有错误!")
|
||||
|
||||
def setChecked(self, text):
|
||||
for btn in self.embed_buttons:
|
||||
if btn.text() == text:
|
||||
btn.setStyleSheet("border: 1px solid #6cff6c;")
|
||||
|
||||
def setError(self, text):
|
||||
for btn in self.embed_buttons:
|
||||
if btn.text() == text:
|
||||
btn.setStyleSheet("border: 1px solid #FF4444;")
|
63
widget/task_result_legend.py
Normal file
@ -0,0 +1,63 @@
|
||||
from PyQt5.QtCore import QSize
|
||||
from PyQt5.QtWidgets import QFrame, QWidget, QGridLayout, QLabel
|
||||
|
||||
|
||||
class TaskResultLegendFrame(QFrame):
|
||||
def __init__(self, parent=None):
|
||||
super(TaskResultLegendFrame, self).__init__(parent)
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.setContentsMargins(0,0,0,0)
|
||||
self.setLayout(layout)
|
||||
|
||||
legend_check_widget = QWidget()
|
||||
legend_check_widget.setObjectName("legendCheckWidget")
|
||||
legend_check_widget.setFixedSize(QSize(20, 20))
|
||||
# legend_std_widget = QWidget()
|
||||
# legend_std_widget.setObjectName("legendStdWidget")
|
||||
legend_ok_widget = QWidget()
|
||||
legend_ok_widget.setObjectName("legendOkWidget")
|
||||
legend_ok_widget.setFixedSize(QSize(20, 20))
|
||||
legend_ng_widget = QWidget()
|
||||
legend_ng_widget.setObjectName("legendNgWidget")
|
||||
legend_ng_widget.setFixedSize(QSize(20, 20))
|
||||
legend_normal_widget = QWidget()
|
||||
legend_normal_widget.setObjectName("legendNormalWidget")
|
||||
legend_normal_widget.setFixedSize(QSize(20, 20))
|
||||
|
||||
legend_check_label = QLabel()
|
||||
legend_check_label.setObjectName("legendCheckLabel")
|
||||
legend_check_label.setText("检测区域")
|
||||
# legend_std_label = QLabel()
|
||||
# legend_std_label.setObjectName("legendStdLabel")
|
||||
# legend_std_label.setText("基准件")
|
||||
legend_ok_label = QLabel()
|
||||
legend_ok_label.setObjectName("legendOkLabel")
|
||||
legend_ok_label.setText("合格件")
|
||||
legend_ng_label = QLabel()
|
||||
legend_ng_label.setObjectName("legendNgLabel")
|
||||
legend_ng_label.setText("不合格件")
|
||||
legend_normal_label = QLabel()
|
||||
legend_normal_label.setObjectName("legendNormalLabel")
|
||||
legend_normal_label.setText("待检测件")
|
||||
|
||||
layout.setColumnStretch(0,6)
|
||||
layout.setColumnStretch(1,1)
|
||||
layout.setColumnStretch(2,1)
|
||||
layout.setColumnStretch(3,1)
|
||||
layout.setColumnStretch(4,1)
|
||||
layout.setColumnStretch(5,1)
|
||||
layout.setColumnStretch(6,1)
|
||||
layout.setColumnStretch(7,1)
|
||||
layout.setColumnStretch(8,1)
|
||||
layout.setColumnStretch(9,6)
|
||||
|
||||
layout.addWidget(legend_check_widget, 0, 1)
|
||||
layout.addWidget(legend_check_label, 0, 2)
|
||||
layout.addWidget(legend_ok_widget, 0, 3)
|
||||
layout.addWidget(legend_ok_label, 0, 4)
|
||||
layout.addWidget(legend_ng_widget, 0, 5)
|
||||
layout.addWidget(legend_ng_label, 0, 6)
|
||||
layout.addWidget(legend_normal_widget, 0, 7)
|
||||
layout.addWidget(legend_normal_label, 0, 8)
|
||||
layout.addWidget(QWidget(), 0, 9)
|
117
widget/task_result_tools.py
Normal file
@ -0,0 +1,117 @@
|
||||
from PyQt5.QtGui import QTextCharFormat, QColor, QBrush, QPixmap
|
||||
from PyQt5.QtWidgets import QFrame, QPushButton, QSizePolicy, QGridLayout, QPlainTextEdit
|
||||
from rich.layout import Layout
|
||||
from components.image_framework import MSG_LOCATION_RECORD, MSG_DETECTION_RECORD, get_msg_info
|
||||
from core.context import AppContext
|
||||
|
||||
|
||||
class TaskResultToolsFrame(QFrame):
|
||||
def __init__(self, parent=None):
|
||||
super(TaskResultToolsFrame, self).__init__(parent)
|
||||
|
||||
self.task_result = parent
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.setContentsMargins(10, 0, 10, 10)
|
||||
|
||||
self.log_text = QPlainTextEdit()
|
||||
self.log_text.setObjectName("logText")
|
||||
self.log_text.setReadOnly(True)
|
||||
|
||||
self.start_adjust_button = QPushButton()
|
||||
self.start_adjust_button.setObjectName("startAdjustButton")
|
||||
self.start_adjust_button.setText("开始校准")
|
||||
self.start_adjust_button.setFixedHeight(42)
|
||||
self.start_adjust_button.clicked.connect(self.start_adjust)
|
||||
|
||||
self.start_check_button = QPushButton()
|
||||
self.start_check_button.setObjectName("startCheckButton")
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.start_check_button.setText("开始检测")
|
||||
self.start_check_button.setFixedHeight(42)
|
||||
self.start_check_button.clicked.connect(self.start_check)
|
||||
|
||||
self.stop_check_button = QPushButton()
|
||||
self.stop_check_button.setObjectName("stopCheckButton")
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_check_button.setText("停止检测")
|
||||
self.stop_check_button.setFixedHeight(42)
|
||||
self.stop_check_button.clicked.connect(self.stop_check)
|
||||
|
||||
self.stop_task_button = QPushButton()
|
||||
self.stop_task_button.setObjectName("stopTaskButton")
|
||||
self.stop_task_button.setText("结束任务")
|
||||
self.stop_task_button.setFixedHeight(42)
|
||||
self.stop_task_button.clicked.connect(self.stop_task)
|
||||
|
||||
layout.setRowStretch(0,6)
|
||||
layout.setRowStretch(1,1)
|
||||
layout.setRowStretch(2,1)
|
||||
layout.setRowStretch(3,1)
|
||||
layout.setRowStretch(4,1)
|
||||
layout.addWidget(self.log_text, 0, 0)
|
||||
layout.addWidget(self.start_adjust_button, 1, 0)
|
||||
layout.addWidget(self.start_check_button, 2, 0)
|
||||
layout.addWidget(self.stop_check_button, 3, 0)
|
||||
layout.addWidget(self.stop_task_button, 4, 0)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
def insert_text(self, text, font_color):
|
||||
char_format = QTextCharFormat()
|
||||
char_format.setForeground(QBrush(font_color))
|
||||
self.log_text.mergeCurrentCharFormat(char_format)
|
||||
self.log_text.appendPlainText(text)
|
||||
|
||||
# 开始校准
|
||||
def start_adjust(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
|
||||
self.log_text.setPlainText("")
|
||||
self.task_result.result_big_label.setPixmap(QPixmap(""))
|
||||
self.task_result.result_big_label.setText("广角摄像头")
|
||||
self.task_result.result_small_label.setPixmap(QPixmap(""))
|
||||
self.task_result.result_small_label.setText("高清摄像头")
|
||||
|
||||
result = AppContext.get_edge_context().get_component('image-framework').start_adjust()
|
||||
if result.code < 0:
|
||||
self.set_default()
|
||||
MessageBox("校准启动失败", "error", get_msg_info(msg.record.code).decode('utf-8'), AppContext.get_main_window()).show()
|
||||
# QMessageBox.warning(self, '校准启动失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
|
||||
# 开始检测
|
||||
def start_check(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
result = AppContext.get_edge_context().get_component('image-framework').start_check()
|
||||
if result.code < 0:
|
||||
self.set_default()
|
||||
MessageBox("检测启动失败", "error", get_msg_info(msg.record.code).decode('utf-8'), AppContext.get_main_window()).show()
|
||||
|
||||
# 停止检测
|
||||
def stop_check(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
result = AppContext.get_edge_context().get_component('image-framework').stop_check()
|
||||
if result.code < 0:
|
||||
MessageBox("检测停止失败", "error", get_msg_info(msg.record.code).decode('utf-8'), AppContext.get_main_window()).show()
|
||||
# QMessageBox.warning(self, '检测停止失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
self.set_default()
|
||||
|
||||
# 结束任务
|
||||
def stop_task(self):
|
||||
AppContext.get_edge_context().get_component('image-framework').stop_all()
|
||||
self.task_result.close()
|
||||
|
||||
def set_default(self):
|
||||
self.start_adjust_button.setEnabled(True)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(True)
|
@ -44,55 +44,55 @@ class TaskRunDialog(QDialog):
|
||||
AppContext.get_edge_context().get_component('image-framework').signals.on_image_detect_result.connect(
|
||||
lambda data: self.image_result(data))
|
||||
|
||||
def image_result(self, msg):
|
||||
qt_image = None
|
||||
if msg.im2D is not None:
|
||||
rgb_frame = cv2.cvtColor(msg.im2D, cv2.COLOR_BGR2RGB)
|
||||
height, width, channels = rgb_frame.shape
|
||||
bytes_per_line = channels * width
|
||||
qt_image = QImage(rgb_frame.data, width, height, bytes_per_line, QImage.Format_RGB888)
|
||||
|
||||
if msg.msg_type == MSG_LOCATION_RECORD:
|
||||
if qt_image is None:
|
||||
return
|
||||
try:
|
||||
view_pixmap = QPixmap.fromImage(qt_image)
|
||||
sc = view_pixmap.height() / 450
|
||||
self.view_label.setFixedWidth(view_pixmap.width() / sc)
|
||||
self.view_label.setPixmap(view_pixmap)
|
||||
self.view_label.setGeometry((self.view_widget.width() - self.view_label.width()) / 2, 0, self.view_label.width(), self.view_label.height())
|
||||
except Exception as e:
|
||||
dd = 0
|
||||
elif msg.msg_type == MSG_DETECTION_RECORD:
|
||||
# 显示日志
|
||||
# self.log_text.appendPlainText(get_msg_info(msg.record.code).decode('utf-8'))
|
||||
if msg.record.code < 0:
|
||||
self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("red"))
|
||||
QMessageBox.warning(self, '错误信息', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
self.set_button_default()
|
||||
AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
elif msg.record.code == 1008:
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(True)
|
||||
self.stop_check_button.setEnabled(True)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
elif msg.record.code == 1012:
|
||||
self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("green"))
|
||||
QMessageBox.warning(self, '成功信息', "检测结束")
|
||||
self.set_button_default()
|
||||
AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
else:
|
||||
self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("white"))
|
||||
|
||||
if qt_image is None:
|
||||
return
|
||||
try:
|
||||
view_pixmap = QPixmap.fromImage(qt_image)
|
||||
self.picture_label.setPixmap(view_pixmap)
|
||||
except Exception as e:
|
||||
dd = 0
|
||||
else:
|
||||
ddd = 0
|
||||
# def image_result(self, msg):
|
||||
# qt_image = None
|
||||
# if msg.im2D is not None:
|
||||
# rgb_frame = cv2.cvtColor(msg.im2D, cv2.COLOR_BGR2RGB)
|
||||
# height, width, channels = rgb_frame.shape
|
||||
# bytes_per_line = channels * width
|
||||
# qt_image = QImage(rgb_frame.data, width, height, bytes_per_line, QImage.Format_RGB888)
|
||||
#
|
||||
# if msg.msg_type == MSG_LOCATION_RECORD:
|
||||
# if qt_image is None:
|
||||
# return
|
||||
# try:
|
||||
# view_pixmap = QPixmap.fromImage(qt_image)
|
||||
# sc = view_pixmap.height() / 450
|
||||
# self.view_label.setFixedWidth(view_pixmap.width() / sc)
|
||||
# self.view_label.setPixmap(view_pixmap)
|
||||
# self.view_label.setGeometry((self.view_widget.width() - self.view_label.width()) / 2, 0, self.view_label.width(), self.view_label.height())
|
||||
# except Exception as e:
|
||||
# dd = 0
|
||||
# elif msg.msg_type == MSG_DETECTION_RECORD:
|
||||
# # 显示日志
|
||||
# # self.log_text.appendPlainText(get_msg_info(msg.record.code).decode('utf-8'))
|
||||
# if msg.record.code < 0:
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("red"))
|
||||
# QMessageBox.warning(self, '错误信息', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
# self.set_button_default()
|
||||
# AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
# elif msg.record.code == 1008:
|
||||
# self.start_adjust_button.setEnabled(False)
|
||||
# self.start_check_button.setEnabled(True)
|
||||
# self.stop_check_button.setEnabled(True)
|
||||
# self.stop_task_button.setEnabled(False)
|
||||
# elif msg.record.code == 1012:
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("green"))
|
||||
# QMessageBox.warning(self, '成功信息', "检测结束")
|
||||
# self.set_button_default()
|
||||
# AppContext.get_edge_context().get_component('image-framework').start_location()
|
||||
# else:
|
||||
# self.insert_text(get_msg_info(msg.record.code).decode('utf-8'), QColor("white"))
|
||||
#
|
||||
# if qt_image is None:
|
||||
# return
|
||||
# try:
|
||||
# view_pixmap = QPixmap.fromImage(qt_image)
|
||||
# self.picture_label.setPixmap(view_pixmap)
|
||||
# except Exception as e:
|
||||
# dd = 0
|
||||
# else:
|
||||
# ddd = 0
|
||||
|
||||
def insert_text(self, text, font_color):
|
||||
fmt = QTextCharFormat()
|
||||
@ -115,13 +115,13 @@ class TaskRunDialog(QDialog):
|
||||
self.check_widget.setFixedSize(160, 160)
|
||||
self.check_widget.move(90, 230)
|
||||
|
||||
# 预埋件
|
||||
self.embed_widgets = []
|
||||
for item in self.param:
|
||||
embed_item = EmbedItem(self.bim_widget)
|
||||
embed_item.setObjectName(item["code"])
|
||||
embed_item.setItemParam(item)
|
||||
self.embed_widgets.append(embed_item)
|
||||
# # 预埋件
|
||||
# self.embed_widgets = []
|
||||
# for item in self.param:
|
||||
# embed_item = EmbedItem(self.bim_widget)
|
||||
# embed_item.setObjectName(item["code"])
|
||||
# embed_item.setItemParam(item)
|
||||
# self.embed_widgets.append(embed_item)
|
||||
|
||||
map_widget = QWidget()
|
||||
legend_widget = QWidget()
|
||||
@ -293,59 +293,59 @@ class TaskRunDialog(QDialog):
|
||||
|
||||
self.set_button_default()
|
||||
|
||||
index = 0
|
||||
for item in self.embed_widgets:
|
||||
if item.objectName() == 'STD': continue
|
||||
if self.check_widget.geometry().contains(item.rect):
|
||||
item.setIndex(str(self.checkIndex))
|
||||
if index % 2 == 0:
|
||||
item.setChecked()
|
||||
else:
|
||||
item.setError()
|
||||
index += 1
|
||||
# index = 0
|
||||
# for item in self.embed_widgets:
|
||||
# if item.objectName() == 'STD': continue
|
||||
# if self.check_widget.geometry().contains(item.rect):
|
||||
# item.setIndex(str(self.checkIndex))
|
||||
# if index % 2 == 0:
|
||||
# item.setChecked()
|
||||
# else:
|
||||
# item.setError()
|
||||
# index += 1
|
||||
|
||||
# 校准
|
||||
def start_adjust(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
|
||||
self.log_text.setPlainText("")
|
||||
self.picture_label.setPixmap(QPixmap(""))
|
||||
|
||||
result = AppContext.get_edge_context().get_component('image-framework').start_adjust()
|
||||
if result.code < 0:
|
||||
self.set_button_default()
|
||||
QMessageBox.warning(self, '校准启动失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
|
||||
def start_check(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
|
||||
result = AppContext.get_edge_context().get_component('image-framework').start_check()
|
||||
if result.code < 0:
|
||||
self.set_button_default()
|
||||
QMessageBox.warning(self, '检测启动失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
|
||||
def stop_check(self):
|
||||
self.start_adjust_button.setEnabled(False)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(False)
|
||||
result = AppContext.get_edge_context().get_component('image-framework').stop_check()
|
||||
if result.code < 0:
|
||||
QMessageBox.warning(self, '检测停止失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
self.set_button_default()
|
||||
|
||||
def stop_task(self):
|
||||
AppContext.get_edge_context().get_component('image-framework').stop_all()
|
||||
self.reject()
|
||||
|
||||
def set_button_default(self):
|
||||
self.start_adjust_button.setEnabled(True)
|
||||
self.start_check_button.setEnabled(False)
|
||||
self.stop_check_button.setEnabled(False)
|
||||
self.stop_task_button.setEnabled(True)
|
||||
# def start_adjust(self):
|
||||
# self.start_adjust_button.setEnabled(False)
|
||||
# self.start_check_button.setEnabled(False)
|
||||
# self.stop_check_button.setEnabled(False)
|
||||
# self.stop_task_button.setEnabled(False)
|
||||
#
|
||||
# self.log_text.setPlainText("")
|
||||
# self.picture_label.setPixmap(QPixmap(""))
|
||||
#
|
||||
# result = AppContext.get_edge_context().get_component('image-framework').start_adjust()
|
||||
# if result.code < 0:
|
||||
# self.set_button_default()
|
||||
# QMessageBox.warning(self, '校准启动失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
#
|
||||
# def start_check(self):
|
||||
# self.start_adjust_button.setEnabled(False)
|
||||
# self.start_check_button.setEnabled(False)
|
||||
# self.stop_check_button.setEnabled(False)
|
||||
# self.stop_task_button.setEnabled(False)
|
||||
#
|
||||
# result = AppContext.get_edge_context().get_component('image-framework').start_check()
|
||||
# if result.code < 0:
|
||||
# self.set_button_default()
|
||||
# QMessageBox.warning(self, '检测启动失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
#
|
||||
# def stop_check(self):
|
||||
# self.start_adjust_button.setEnabled(False)
|
||||
# self.start_check_button.setEnabled(False)
|
||||
# self.stop_check_button.setEnabled(False)
|
||||
# self.stop_task_button.setEnabled(False)
|
||||
# result = AppContext.get_edge_context().get_component('image-framework').stop_check()
|
||||
# if result.code < 0:
|
||||
# QMessageBox.warning(self, '检测停止失败', get_msg_info(msg.record.code).decode('utf-8'))
|
||||
# self.set_button_default()
|
||||
#
|
||||
# def stop_task(self):
|
||||
# AppContext.get_edge_context().get_component('image-framework').stop_all()
|
||||
# self.reject()
|
||||
#
|
||||
# def set_button_default(self):
|
||||
# self.start_adjust_button.setEnabled(True)
|
||||
# self.start_check_button.setEnabled(False)
|
||||
# self.stop_check_button.setEnabled(False)
|
||||
# self.stop_task_button.setEnabled(True)
|