feat(wits): 添加WITS TCP发送功能和配置重构
- 新增WitsConfig数据类用于WITS配置管理 - 在AppConfig中集成wits配置选项 - 重命名dependencies.py为config.py并重构配置加载逻辑 - 移除db/config.py文件中的TDengine配置相关代码 - 创建新的model.py文件定义MqttConfig、TmsConfig和TdengineConfig模型 - 更新MQTT模块导入路径从config.dependencies到config.config - 添加WITS发送器脚本wits_sender.py实现TCP数据包发送 - 在README.md中添加WITS发送器使用说明和配置选项 - 添加WITS样本数据文件data/wits_sample.txt - 添加requirements.md文档说明项目需求
This commit is contained in:
@@ -28,10 +28,19 @@ class TmsConfig:
|
||||
server_port: int | None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WitsConfig:
|
||||
host: str
|
||||
port: int
|
||||
timeout: int
|
||||
source_file: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AppConfig:
|
||||
mqtt: MqttConfig
|
||||
tms: TmsConfig
|
||||
wits: WitsConfig
|
||||
raw: dict
|
||||
|
||||
|
||||
@@ -96,6 +105,12 @@ def load_app_config(path):
|
||||
server_ip=get_value(raw, ("tms", "server-ip"), ("server-ip",)),
|
||||
server_port=get_value(raw, ("tms", "server-port"), ("server-port",)),
|
||||
),
|
||||
wits=WitsConfig(
|
||||
host=get_value(raw, ("wits", "host"), ("tms", "server-ip"), ("server-ip",), default=""),
|
||||
port=int(get_value(raw, ("wits", "port"), ("tms", "server-port"), ("server-port",), default=0)),
|
||||
timeout=int(get_value(raw, ("wits", "timeout"), ("tms", "timeout"), ("timeout",), default=10)),
|
||||
source_file=get_value(raw, ("wits", "source-file"), default=""),
|
||||
),
|
||||
raw=raw,
|
||||
)
|
||||
|
||||
@@ -106,6 +121,7 @@ __all__ = [
|
||||
"AppConfig",
|
||||
"MqttConfig",
|
||||
"TmsConfig",
|
||||
"WitsConfig",
|
||||
"get_value",
|
||||
"load_app_config",
|
||||
"load_config",
|
||||
|
||||
Reference in New Issue
Block a user