149 lines
3.2 KiB
C++
Executable File
149 lines
3.2 KiB
C++
Executable File
/**
|
|
* @file SystemInfoUpdateThread.h
|
|
* @author jinchao
|
|
* @brief 系统信息更新线程类头文件
|
|
* @version 1.0
|
|
* @date 2025-03-10
|
|
*
|
|
* @copyright Copyright (c) 2025 COMAC
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QThread>
|
|
#include <QMutex>
|
|
#include <QQueue>
|
|
#include <QMap>
|
|
#include "../TypeDefine.h"
|
|
#include "../../XNCore/XNIDL/XNSimStatusPubSubTypes.hpp"
|
|
|
|
/**
|
|
* @brief 系统信息更新线程类
|
|
*/
|
|
class SystemInfoUpdateThread : public QThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param parent 父对象
|
|
*/
|
|
explicit SystemInfoUpdateThread(QObject *parent = nullptr) : QThread(parent) {}
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~SystemInfoUpdateThread();
|
|
signals:
|
|
/**
|
|
* @brief 更新线程信息信号
|
|
* @param threadData 线程数据
|
|
*/
|
|
void updateThreadInfo(const XNRuntimeData threadData);
|
|
/**
|
|
* @brief 更新引擎名称信号
|
|
* @param engineName 引擎名称
|
|
*/
|
|
void updateEngineName(const QString engineName);
|
|
/**
|
|
* @brief 更新引擎ID信号
|
|
* @param engineID 引擎ID
|
|
*/
|
|
void updateEngineID(const unsigned int engineID);
|
|
/**
|
|
* @brief 更新引擎状态信号
|
|
* @param threadStatus 线程状态
|
|
*/
|
|
void updateEngineStatus(const unsigned int threadStatus);
|
|
/**
|
|
* @brief 更新内核状态信号
|
|
* @param index 索引
|
|
* @param status 状态
|
|
*/
|
|
void updateCoreStatus(int index, const unsigned int &status);
|
|
/**
|
|
* @brief 更新运行值信号
|
|
* @param index 索引
|
|
* @param newValue 新值
|
|
*/
|
|
void updateRuntimeValue(int index, const QString &newValue);
|
|
/**
|
|
* @brief 更新线程数量信号
|
|
* @param count 数量
|
|
*/
|
|
void updateThreadCount(const unsigned int &count);
|
|
/**
|
|
* @brief 更新亲和性信号
|
|
* @param affinity 亲和性
|
|
*/
|
|
void updateAffinity(const QString &affinity);
|
|
public slots:
|
|
/**
|
|
* @brief 更改睡眠时间槽函数
|
|
* @param newSleepTime 新的睡眠时间
|
|
*/
|
|
void onChangeSleepTime(const unsigned int newSleepTime);
|
|
/**
|
|
* @brief 线程控制槽函数
|
|
* @param isRunning 是否运行
|
|
*/
|
|
void onThreadController(const bool &isRunning);
|
|
/**
|
|
* @brief 线程退出信号
|
|
*/
|
|
void onThreadQuit() { m_Quit = true; }
|
|
|
|
public:
|
|
/**
|
|
* @brief 初始化
|
|
*/
|
|
void Initialize();
|
|
|
|
protected:
|
|
/**
|
|
* @brief 运行函数
|
|
*/
|
|
void run() override;
|
|
|
|
private:
|
|
/**
|
|
* @brief 引擎状态监听器
|
|
* @param status 引擎状态
|
|
*/
|
|
void EngineStatusListener(const XNSim::XNSimStatus::XNEngineStatus &status);
|
|
/**
|
|
* @brief 线程状态监听器
|
|
* @param status 线程状态
|
|
*/
|
|
void ThreadStatusListener(const XNSim::XNSimStatus::XNThreadStatus &status);
|
|
|
|
private:
|
|
/**
|
|
* @brief 睡眠时间
|
|
*/
|
|
unsigned int m_SleepTime = 1000;
|
|
/**
|
|
* @brief 是否激活
|
|
*/
|
|
bool m_Active = false;
|
|
/**
|
|
* @brief 是否退出
|
|
*/
|
|
bool m_Quit = false;
|
|
/**
|
|
* @brief 互斥锁
|
|
*/
|
|
QMutex m_Mutex;
|
|
/**
|
|
* @brief 引擎状态
|
|
*/
|
|
XNSim::XNSimStatus::XNEngineStatus engineStatus;
|
|
/**
|
|
* @brief 引擎状态更新
|
|
*/
|
|
bool m_EngineStatusUpdate = false;
|
|
/**
|
|
* @brief 线程状态
|
|
*/
|
|
QMap<quint32, XNSim::XNSimStatus::XNThreadStatus> m_ThreadStatus;
|
|
};
|