47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
app_name: str = "电气量测控平台"
|
|
app_version: str = "0.1.0"
|
|
api_prefix: str = "/api"
|
|
realtime_ws_path: str = "/ws/real-time"
|
|
status_ws_path: str = "/ws/status"
|
|
alarm_ws_path: str = "/ws/alarm"
|
|
time_sync_ws_path: str = "/ws/time-sync"
|
|
poll_interval_seconds: float = 0.5
|
|
time_sync_poll_interval_seconds: float = 1.0
|
|
auth_password: str = "admin123"
|
|
use_mock_device: bool = False
|
|
modbus_transport: str = "rtu"
|
|
modbus_slave_id: int = 1
|
|
modbus_tcp_host: str = "127.0.0.1"
|
|
modbus_tcp_port: int = 502
|
|
modbus_serial_device: str = "/dev/ttyS1"
|
|
modbus_serial_baud: int = 115200
|
|
modbus_serial_parity: str = "N"
|
|
modbus_serial_data_bits: int = 8
|
|
modbus_serial_stop_bits: int = 1
|
|
modbus_timeout_seconds: float = 1.0
|
|
modbus_float_byte_order: str = "big"
|
|
modbus_float_word_order: str = "big"
|
|
config_dir: Path = BASE_DIR / "config"
|
|
data_dir: Path = BASE_DIR / "data"
|
|
alarm_db_path: Path = BASE_DIR / "data" / "alarm.db"
|
|
backup_dir: Path = BASE_DIR / "data" / "backups"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_prefix="EMCP_",
|
|
env_file=BASE_DIR / ".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
settings = Settings()
|