242 lines
5.0 KiB
C++
Executable File
242 lines
5.0 KiB
C++
Executable File
/**
|
|
* @file SystemStatusWidget.h
|
|
* @author jinchao
|
|
* @brief 系统运行状态窗口类
|
|
* @version 1.0
|
|
* @date 2025-03-10
|
|
*
|
|
* @copyright Copyright (c) 2025 COMAC
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QSplitter>
|
|
#include <QTableWidget>
|
|
#include <QMutex>
|
|
#include "../TypeDefine.h"
|
|
#include "SystemInfoUpdateThread.h"
|
|
#include "../XNCustomPlot.h"
|
|
|
|
/**
|
|
* @brief 系统运行状态窗口类
|
|
*/
|
|
class SystemStatusWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param parent 父窗口
|
|
*/
|
|
explicit SystemStatusWidget(QWidget *parent = nullptr);
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
~SystemStatusWidget();
|
|
/**
|
|
* @brief 获取线程名称
|
|
* @param threadID 线程ID
|
|
* @return 线程名称
|
|
*/
|
|
QString getThreadName(const quint32 threadID);
|
|
|
|
public slots:
|
|
/**
|
|
* @brief 设置当前选中的标签页索引
|
|
* @param index 标签页索引
|
|
*/
|
|
void onSetCurrentTabIndex(int index);
|
|
/**
|
|
* @brief 展示/隐藏引擎信息槽函数
|
|
*/
|
|
void toggleEngineInfo();
|
|
/**
|
|
* @brief 展示/隐藏内核信息槽函数
|
|
*/
|
|
void toggleCoreInfo();
|
|
/**
|
|
* @brief 更新引擎状态槽函数
|
|
* @param status 引擎状态
|
|
*/
|
|
void updateEngineStatus(const unsigned int &status);
|
|
/**
|
|
* @brief 更新进程名称槽函数
|
|
* @param name 进程名称
|
|
*/
|
|
void updateProcessName(const QString &name);
|
|
/**
|
|
* @brief 更新进程ID槽函数
|
|
* @param id 进程ID
|
|
*/
|
|
void updateProcessID(const unsigned int &id);
|
|
/**
|
|
* @brief 更新内核状态槽函数
|
|
* @param index 内核索引
|
|
* @param status 内核状态
|
|
*/
|
|
void updateCoreStatus(int index, const unsigned int &status);
|
|
/**
|
|
* @brief 更新线程数据槽函数
|
|
* @param data 线程数据
|
|
*/
|
|
void updateThreadData(const XNRuntimeData &data);
|
|
/**
|
|
* @brief 更新线程数槽函数
|
|
* @param count 线程数
|
|
*/
|
|
void updateThreadCount(const unsigned int &count);
|
|
/**
|
|
* @brief 更新CPU亲和性槽函数
|
|
* @param affinity CPU亲和性
|
|
*/
|
|
void updateAffinity(const QString &affinity);
|
|
/**
|
|
* @brief 显示图表右键菜单槽函数
|
|
* @param pos 鼠标位置
|
|
*/
|
|
void showChartContextMenu(const QPoint &pos);
|
|
/**
|
|
* @brief 显示频率槽函数
|
|
*/
|
|
void onShowFrequency();
|
|
/**
|
|
* @brief 显示周期槽函数
|
|
*/
|
|
void onShowPeriod();
|
|
/**
|
|
* @brief 更新图表数据槽函数
|
|
* @param newXData 新的X轴数据
|
|
* @param newYData 新的Y轴数据
|
|
*/
|
|
void updatePlotData(const QVector<double> &newXData, const QVector<double> &newYData);
|
|
/**
|
|
* @brief 线程状态表格选择改变槽函数
|
|
*/
|
|
void onThreadStatusTableSelectionChanged();
|
|
|
|
signals:
|
|
/**
|
|
* @brief 更新绘图数据信号
|
|
*/
|
|
void updateThreadCutomPlotData();
|
|
/**
|
|
* @brief 控制线程信号
|
|
* @param bActive 是否激活
|
|
*/
|
|
void controlThreadInfoThread(bool bActive);
|
|
/**
|
|
* @brief 更新线程信息信号
|
|
* @param threadID 线程ID
|
|
* @param data 线程数据
|
|
*/
|
|
void updateThreadInfo(unsigned int threadID, const XNRuntimeData &data);
|
|
|
|
private:
|
|
/**
|
|
* @brief 初始化系统状态标签页
|
|
*/
|
|
void setupTabSystemStatus();
|
|
/**
|
|
* @brief 初始化系统状态左面板
|
|
* @param splitter 分割器
|
|
*/
|
|
void setupTabSystemStatusLeftPanel(QSplitter *splitter);
|
|
/**
|
|
* @brief 初始化系统状态右面板
|
|
* @param splitter 分割器
|
|
*/
|
|
void setupTabSystemStatusRightPanel(QSplitter *splitter);
|
|
/**
|
|
* @brief 初始化系统状态图表
|
|
*/
|
|
void setupSystemStatusChartWidget();
|
|
/**
|
|
* @brief 初始化系统状态表格
|
|
*/
|
|
void setupSystemStatusTableWidget();
|
|
/**
|
|
* @brief 更新线程表格数据
|
|
* @param data 线程数据
|
|
* @param rowIndex 行索引
|
|
*/
|
|
void updateThreadTableData(const XNRuntimeData &data, int rowIndex);
|
|
/**
|
|
* @brief 创建引擎信息页面
|
|
* @return 引擎信息页面
|
|
*/
|
|
QWidget *createEngineInfoPage();
|
|
/**
|
|
* @brief 创建内核信息页面
|
|
* @return 内核信息页面
|
|
*/
|
|
QWidget *createCoreInfoPage();
|
|
/**
|
|
* @brief 初始化线程信息更新线程
|
|
*/
|
|
void InitializeThreadInfoThread();
|
|
|
|
private:
|
|
/**
|
|
* @brief 当前选中的标签页索引
|
|
*/
|
|
int currentTabIndex = 0;
|
|
/**
|
|
* @brief 显示频率或周期的索引
|
|
*/
|
|
int freqOrPeriodIndex = 0;
|
|
/**
|
|
* @brief 引擎信息页面
|
|
*/
|
|
QWidget *engineInfoPage;
|
|
/**
|
|
* @brief 内核信息页面
|
|
*/
|
|
QWidget *coreInfoPage;
|
|
/**
|
|
* @brief 线程运行状态表格
|
|
*/
|
|
QTableWidget *threadStatusTableWidget;
|
|
/**
|
|
* @brief 线程状态图表显示界面
|
|
*/
|
|
QWidget *systemStatusChartWidget;
|
|
/**
|
|
* @brief 线程状态图表绘图对象
|
|
*/
|
|
XNCustomPlot *customPlot;
|
|
/**
|
|
* @brief 线程数据向量
|
|
*/
|
|
QVector<XNRuntimeData> threadDataVec;
|
|
/**
|
|
* @brief XNEngine标签
|
|
*/
|
|
QLabel *labelXNEngine;
|
|
/**
|
|
* @brief 进程ID标签
|
|
*/
|
|
QLabel *labelProcessIDValue;
|
|
/**
|
|
* @brief 运行状态标签
|
|
*/
|
|
QLabel *labelStatusValue;
|
|
/**
|
|
* @brief 亲和性标签
|
|
*/
|
|
QLabel *labelAffinityValue;
|
|
/**
|
|
* @brief 线程数标签
|
|
*/
|
|
QLabel *labelThreadCountValue;
|
|
/**
|
|
* @brief 线程信息更新线程
|
|
*/
|
|
SystemInfoUpdateThread *threadInfoThread;
|
|
/**
|
|
* @brief 互斥锁
|
|
*/
|
|
QMutex mutex;
|
|
};
|