27/include/app.hpp

206 lines
7.3 KiB
C++
Raw Normal View History

2026-05-25 03:12:55 +00:00
#ifndef ODF_MANAGER_APP_HPP
#define ODF_MANAGER_APP_HPP
#include <string>
#include <vector>
#include <map>
#include <cstdint>
#include <sstream>
#include <iomanip>
#include <ctime>
#include <algorithm>
// =========================================================================
// ODF 光纤配线单元管理系统 —— 核心数据类型与接口
// =========================================================================
/// @brief 连接器端面类型UPC / APC
enum class PolishType : uint8_t {
UPC, ///< 超物理接触端面,回波损耗 ≥ 50dB
APC ///< 斜角度物理接触端面,回波损耗 ≥ 60dB
};
/// @brief 连接器等级(按标准光纤分类)
enum class FiberGrade : uint8_t {
OM1, ///< 多模 OM1 (62.5/125μm)
OM2, ///< 多模 OM2 (50/125μm)
OM3, ///< 多模 OM3 (50/125μm, 激光优化)
OM4, ///< 多模 OM4 (50/125μm, 高带宽)
OM5, ///< 多模 OM5 (50/125μm, 宽带)
OS2 ///< 单模 OS2 (9/125μm)
};
/// @brief 光接口类型(连接器形式)
enum class ConnectorType : uint8_t {
LC, ///< LC 连接器1.25mm 插芯)
SC, ///< SC 连接器2.5mm 插芯)
MPO ///< MPO 多芯连接器
};
/// @brief 适配器安装方向
enum class MountDirection : uint8_t {
Front, ///< 前面板接入
Rear, ///< 后面板接入
Both ///< 前后均可接入
};
// =========================================================================
// 数据结构定义
// =========================================================================
/**
* @brief
*
*
*/
struct AdapterSpec {
ConnectorType interface_type; ///< 接口类型LC/SC/MPO
FiberGrade connector_grade; ///< 连接器等级OM1-OS2
PolishType polish_type; ///< 端面类型UPC/APC
double max_insertion_loss_dB; ///< 最大插入损耗 (dB)
double min_return_loss_dB; ///< 最小回波损耗 (dB)
int port_count; ///< 该面板上安装的适配器数量
MountDirection mount_direction; ///< 安装方向
};
/**
* @brief ODF
*
* ODF /
*/
struct ODFUnitInfo {
std::string unit_id; ///< 单元全局唯一标识
std::string model_name; ///< 产品型号
std::string location; ///< 安装位置,格式 "机房-机柜-高度U数"
std::string manufacturer; ///< 制造商
std::string production_date; ///< 生产日期 (YYYY-MM-DD)
int max_capacity_cores; ///< 最大支持光纤芯数(≤ 288
std::vector<AdapterSpec> adapters; ///< 已安装的适配器列表
};
/**
* @brief
*
*
*/
struct TypicalConfig {
std::string scene_name; ///< 场景名称,如 "数据中心LC单模预端接"
std::string environment; ///< 应用环境:数据中心 / 园区网 / 接入网
std::string fiber_type; ///< 光纤类型:单模/多模
std::string connector_type; ///< 连接器类型描述
int preterminated_len_m; ///< 预端接长度 (米)
int port_density_per_u; ///< 每 U 端口密度
double redundancy_ratio; ///< 冗余比例 (如 0.25 表示 25%)
std::vector<std::string> accessories; ///< 配套附件列表
};
/**
* @brief
*/
struct Milestone {
std::string phase_name; ///< 阶段名称
std::string start_date; ///< 开始日期 (YYYY-MM-DD)
std::string end_date; ///< 结束日期 (YYYY-MM-DD)
std::string owner; ///< 负责人
std::string deliverable; ///< 交付物描述
bool is_completed; ///< 完成状态
};
// =========================================================================
// ODF 管理器 —— 核心业务接口
// =========================================================================
/**
* @brief ODF 线
*
* ODF
*/
class ODFManager {
public:
ODFManager() = default;
// ---- 单元管理 ----
/// @brief 注册一个新的 ODF 单元到管理器
void register_unit(const ODFUnitInfo& unit);
/// @brief 按 unit_id 查询已注册的 ODF 单元
/// @return 指向 ODFUnitInfo 的指针,若不存在返回 nullptr
const ODFUnitInfo* find_unit(const std::string& unit_id) const;
/// @brief 返回所有已注册的 ODF 单元列表
const std::vector<ODFUnitInfo>& all_units() const;
// ---- 编码生成 ----
/**
* @brief --
*
* `[site]-[cabinet]-[slot]` 64
*
* @param site DC01
* @param cabinet RF02
* @param slot SL05
* @return
*/
std::string generate_naming_code(const std::string& site,
const std::string& cabinet,
const std::string& slot) const;
// ---- 典型配置 ----
/**
* @brief
* @param scene_type
* @return TypicalConfig
*/
TypicalConfig get_typical_config(const std::string& scene_type) const;
/// @brief 注册一个典型配置方案
void register_typical_config(const TypicalConfig& cfg);
// ---- 兼容性校验 ----
/**
* @brief
*
*
* - LC LCSC SCMPO MPO
* - UPC APC
*
* @param a A
* @param b B
* @return true false
*/
bool validate_adapter_compatibility(const AdapterSpec& a,
const AdapterSpec& b) const;
// ---- 报告与标签 ----
/**
* @brief
* @return
*/
std::string export_milestone_schedule() const;
/// @brief 添加一个里程碑
void add_milestone(const Milestone& ms);
/// @brief 返回所有里程碑
const std::vector<Milestone>& milestones() const;
/**
* @brief
* @param unit_id ODF ID
* @return [QR]
*/
std::string print_label(const std::string& unit_id) const;
private:
std::vector<ODFUnitInfo> units_;
std::vector<TypicalConfig> configs_;
std::vector<Milestone> milestones_;
/// @brief 内部辅助:将 ConnectorType 转为字符串
static std::string connector_type_str(ConnectorType t);
/// @brief 内部辅助:将 PolishType 转为字符串
static std::string polish_type_str(PolishType p);
};
#endif // ODF_MANAGER_APP_HPP