2026-03-12 14:56:53 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QByteArray>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QMap>
|
|
|
|
|
#include <QList>
|
2026-03-18 16:31:32 +08:00
|
|
|
#include <QHash>
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
#include <memory>
|
2026-03-12 14:56:53 +08:00
|
|
|
|
|
|
|
|
#include "device_bus/tree/DeviceTreeModel.h"
|
2026-03-18 16:31:32 +08:00
|
|
|
#include "device_bus/registry/IDeviceRegistry.h"
|
|
|
|
|
#include "devices/DeviceTypes.h"
|
|
|
|
|
#include "devices/physical/SerialDevice.h"
|
2026-03-12 14:56:53 +08:00
|
|
|
|
|
|
|
|
class DeviceBusManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
2026-03-18 16:31:32 +08:00
|
|
|
void setDeviceTreeModel(std::shared_ptr<DeviceTreeModel> model);
|
2026-03-20 17:19:29 +08:00
|
|
|
void setRegistry(softbus::device_bus::registry::IDeviceRegistry* registry);
|
2026-03-18 16:31:32 +08:00
|
|
|
|
2026-03-12 14:56:53 +08:00
|
|
|
bool initialize(const QJsonObject& rootConfig);
|
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
|
|
private:
|
2026-03-18 16:31:32 +08:00
|
|
|
void initializeSerialDevice(const QString& endpoint, const QJsonObject& params);
|
|
|
|
|
void shutdownSerialDevice(const QString& endpoint);
|
2026-03-12 14:56:53 +08:00
|
|
|
// void initializeCanDriver();
|
|
|
|
|
// void shutdownCanDriver();
|
|
|
|
|
// void initializeTcpDriver();
|
|
|
|
|
// void shutdownTcpDriver();
|
|
|
|
|
// void initializeUdpDriver();
|
|
|
|
|
// void shutdownUdpDriver();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2026-03-18 16:31:32 +08:00
|
|
|
std::shared_ptr<DeviceTreeModel> m_treeModel;
|
2026-03-12 14:56:53 +08:00
|
|
|
// 添加map来记住所有设备的endpoint和type的映射
|
2026-03-18 16:31:32 +08:00
|
|
|
QMap<QString, softbus::devices::DeviceKind> m_deviceEndpointsMap;
|
|
|
|
|
|
|
|
|
|
QHash<QString, QSharedPointer<softbus::devices::physical::SerialDevice>> m_serialDevicesByEndpoint;
|
2026-03-12 14:56:53 +08:00
|
|
|
|
2026-03-18 16:31:32 +08:00
|
|
|
softbus::device_bus::registry::IDeviceRegistry* m_registry = nullptr;
|
2026-03-12 14:56:53 +08:00
|
|
|
|
|
|
|
|
// std::vector<softbus::hardware::drivers::can::CanQtDriver*> m_canDrivers;
|
|
|
|
|
// std::vector<softbus::hardware::drivers::tcp::TcpQtDriver*> m_tcpDrivers;
|
|
|
|
|
// std::vector<softbus::hardware::drivers::udp::UdpQtDriver*> m_udpDrivers;
|
|
|
|
|
};
|
|
|
|
|
|