100 lines
2.5 KiB
Python
100 lines
2.5 KiB
Python
|
|
"""ODF 光纤配线单元管理系统 - 数据模型定义。
|
|||
|
|
|
|||
|
|
本模块定义了系统中使用的内部数据模型(内存存储结构)。
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
from dataclasses import dataclass, field
|
|||
|
|
from enum import Enum
|
|||
|
|
from typing import Optional
|
|||
|
|
|
|||
|
|
|
|||
|
|
class PortType(str, Enum):
|
|||
|
|
"""光纤端口类型枚举。"""
|
|||
|
|
LC = "LC" # LC 接口
|
|||
|
|
SC = "SC" # SC 接口
|
|||
|
|
FC = "FC" # FC 接口
|
|||
|
|
ST = "ST" # ST 接口
|
|||
|
|
|
|||
|
|
|
|||
|
|
class PortStatus(str, Enum):
|
|||
|
|
"""光纤端口状态枚举。"""
|
|||
|
|
FREE = "FREE" # 空闲
|
|||
|
|
IN_USE = "IN_USE" # 使用中
|
|||
|
|
FAULT = "FAULT" # 故障
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class Port:
|
|||
|
|
"""光纤端口数据模型。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
port_id: 端口唯一标识。
|
|||
|
|
unit_id: 所属配线单元 ID。
|
|||
|
|
port_number: 端口编号(同一单元内唯一)。
|
|||
|
|
port_type: 端口类型。
|
|||
|
|
status: 端口状态。
|
|||
|
|
label: 端口标签/标识说明。
|
|||
|
|
"""
|
|||
|
|
port_id: str
|
|||
|
|
unit_id: str
|
|||
|
|
port_number: int
|
|||
|
|
port_type: PortType = PortType.LC
|
|||
|
|
status: PortStatus = PortStatus.FREE
|
|||
|
|
label: str = ""
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class Unit:
|
|||
|
|
"""配线单元数据模型。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
unit_id: 配线单元唯一标识。
|
|||
|
|
rack_id: 所属机架 ID。
|
|||
|
|
unit_number: 单元编号(同一机架内唯一)。
|
|||
|
|
unit_name: 单元名称。
|
|||
|
|
position: 在机架中的位置描述(如 "上排"、"下排")。
|
|||
|
|
ports: 单元包含的光纤端口列表。
|
|||
|
|
"""
|
|||
|
|
unit_id: str
|
|||
|
|
rack_id: str
|
|||
|
|
unit_number: int
|
|||
|
|
unit_name: str = ""
|
|||
|
|
position: str = ""
|
|||
|
|
ports: list[Port] = field(default_factory=list)
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class Rack:
|
|||
|
|
"""ODF 机架数据模型。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
rack_id: 机架唯一标识。
|
|||
|
|
rack_name: 机架名称/编号。
|
|||
|
|
location: 物理位置描述(如机房、列、排)。
|
|||
|
|
units: 机架中包含的配线单元列表。
|
|||
|
|
"""
|
|||
|
|
rack_id: str
|
|||
|
|
rack_name: str
|
|||
|
|
location: str = ""
|
|||
|
|
units: list[Unit] = field(default_factory=list)
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class Connection:
|
|||
|
|
"""跳接连接数据模型,记录光纤端口之间的跳纤关系。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
connection_id: 连接唯一标识。
|
|||
|
|
port_a_id: 起始端口 ID(A端)。
|
|||
|
|
port_b_id: 终止端口 ID(B端)。
|
|||
|
|
fiber_length: 光纤长度(米)。
|
|||
|
|
create_time: 创建时间。
|
|||
|
|
remark: 备注说明。
|
|||
|
|
"""
|
|||
|
|
connection_id: str
|
|||
|
|
port_a_id: str
|
|||
|
|
port_b_id: str
|
|||
|
|
fiber_length: float = 0.0
|
|||
|
|
create_time: str = ""
|
|||
|
|
remark: str = ""
|