SmartEDT/README.md

67 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SmartEDT智能电动车数字孪生系统代码框架
本仓库提供一套可扩展的系统骨架代码,用于支撑《系统开发技术方案.md》中定义的后端采集处理与桌面端多屏显示能力。
## 目录结构
```
SmartEDT/
backend/
frontend/
系统开发技术方案.md
```
## 后端Python 3.13.1 + FastAPI + WebSocket + PostgreSQL/TimescaleDB
### 1) 环境准备
- 建议使用 venv
- `python -m venv venv`
- `venv\Scripts\activate`
- `pip install -r backend/requirements.txt`
### 2) 配置
- 复制示例配置:
- `copy backend\\config.ini.example backend\\config.ini`
- 按需修改 `[DATABASE].url`(示例密码为占位符 `CHANGE_ME`)。
也可以通过环境变量覆盖:
- `SMARTEDT_DATABASE_URL`
- `SMARTEDT_FILE_ROOT`
- `SMARTEDT_HOST`
- `SMARTEDT_PORT`
### 3) 数据库
需要 PostgreSQL 并安装 TimescaleDB 扩展(数据库侧操作)。后端启动时会尝试:
- `CREATE EXTENSION IF NOT EXISTS timescaledb`
- `create_hypertable('vehicle_signals', 'ts', if_not_exists => TRUE)`
### 4) 启动
- 开发启动:
- `python backend/main.py --host 127.0.0.1 --port 5000 --debug`
接口:
- `GET /health`
- `POST /api/simulation/start`
- `POST /api/simulation/{simulation_id}/stop`
- `WS /ws`
## 前端Electron + Vue
### 1) 安装依赖
`frontend/` 目录下执行:
- `npm install`
### 2) 开发启动Vite + Electron
- `npm run dev`
Electron 主进程会尝试启动后端:
- 默认使用 `python backend/main.py`
- 可通过 `SMARTEDT_PYTHON` 指定 Python 可执行文件路径