36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "types/VehicleCommand.h"
|
|
#include "network/HTTPClient.h"
|
|
|
|
struct ControllableVehicleConfig {
|
|
std::string vehicleNo; // 车牌号
|
|
std::string ip; // IP地址
|
|
int port; // 端口号
|
|
};
|
|
|
|
class ControllableVehicles {
|
|
public:
|
|
explicit ControllableVehicles(const std::string& configFile);
|
|
virtual ~ControllableVehicles() = default;
|
|
|
|
// 获取所有可控车辆配置
|
|
const std::vector<ControllableVehicleConfig>& getVehicles() const;
|
|
|
|
// 根据车牌号查找可控车辆配置
|
|
const ControllableVehicleConfig* findVehicle(const std::string& vehicleNo) const;
|
|
|
|
// 检查车辆是否可控
|
|
virtual bool isControllable(const std::string& vehicleNo) const;
|
|
|
|
// 发送控制命令,返回是否发送成功
|
|
virtual bool sendCommand(const std::string& vehicleNo, const VehicleCommand& command);
|
|
|
|
private:
|
|
std::vector<ControllableVehicleConfig> vehicles_;
|
|
std::unique_ptr<HTTPClient> http_client_;
|
|
void loadConfig(const std::string& configFile);
|
|
};
|