This commit is contained in:
flowerstonezl
2026-03-11 11:21:53 +08:00
parent 993581b2a4
commit fef874e0e3
5 changed files with 163 additions and 7 deletions

View File

View File

@@ -0,0 +1,62 @@
/**
* @file Ipc_dbus.h
* @brief D-Bus 服务接口 - 提供核心服务状态和负载查询
*/
#ifndef IPC_DBUS_H
#define IPC_DBUS_H
#include <QObject>
/**
* @brief D-Bus 服务适配器 - 暴露核心服务接口
*/
class IpcDBus : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.softbus.Daemon")
public:
explicit IpcDBus(CoreService* coreService, QObject* parent = nullptr);
~IpcDBus();
public slots:
/**
* @brief 检查核心服务是否运行
* @return true 如果核心服务正在运行
*/
bool isRunning() const;
/**
* @brief 获取核心服务状态信息
* @return JSON 格式的状态信息
*/
QString getStatus() const;
/**
* @brief 获取守护进程的进程ID
* @return 进程ID如果无法获取则返回0
*/
qint64 getPid() const;
/**
* @brief 关闭守护进程
*/
void shutdown();
private slots:
void updateLoadInfo();
private:
};
#endif // IPC_DBUS_H

View File

@@ -7,6 +7,13 @@ class CoreService : public QObject {
public:
static CoreService* instance();
enum Role {
CoreRouter, // 核心路由器,负责设备发现、连接管理和数据转发
Collector, // 数据收集器,负责从设备收集数据
CollectorSerial, // 串口数据收集器
CollectorCan, // CAN总线数据收集器
SqlServer, // SQL服务器负责存储设备数据
};
bool initialize();
void shutdown();

View File

@@ -16,21 +16,21 @@
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
// 构建来源字符串的辅助宏
#define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
// #define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
// 日志宏,格式:[文件名.函数名] 消息
#define LOG_DEBUG() \
qDebug() << "[" << "SYSTEM" << "DEBUG" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
qDebug() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
#define LOG_ERROR() \
qCritical() << "[" << "SYSTEM" << "ERROR" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
qCritical() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
#define LOG_INFO() \
qInfo() << "[" << "SYSTEM" << "INFO" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
qInfo() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
#define LOG_WARNING() \
qWarning() << "[" << "SYSTEM" << "WARNING" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
qWarning() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
#endif // LOGGING_H