现场调试版同步:S331 点表修正(CDAB/scale 60/int32) + SafeRTUFramer 多点485 + 哨兵过滤
- config.yaml: 恢复现场 IP(10.50.253.165/.181/.182)、s331_2 端口 502 - config.yaml: S331 全部 32 位量 word_order 改 CDAB,瞬时流量 scale=60 (m3/min -> m3/h) - config.yaml: 11# 电表功率/电能类型改 int32;第二路 RTU 从站 slave_id 改 10 - poller.py: 过滤 S331 无数据哨兵 -9999 与非有限值,避免污染周期基准 - rtu.py: 新增 SafeRTUFramer 支持多点半总线,忽略其它从站请求 - 新增 config.debug.yaml、README.md、wheelhouse 离线依赖 - tests: 适配新配置(ttyS7/address_offset);新增 pytest.ini 限定 testpaths
This commit is contained in:
commit
9eaf87ab7d
43 files changed
+4514
No files matched your search
@@ -0,0 +1,20 @@
|
||||
[Unit]
|
||||
Description=Air Compressor Gas-Electric Ratio Edge Gateway (EG828-CEW)
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/hx-gateway
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
ExecStart=/opt/hx-gateway/.venv/bin/python -m gateway.app --config /opt/hx-gateway/config/config.yaml
|
||||
# 串口异常/程序异常自动重启;正常退出码 0 不重启
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
KillSignal=SIGTERM
|
||||
TimeoutStopSec=20
|
||||
# 串口权限(若改用非 root 用户,请将该用户加入 dialout 组)
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# EG828-CEW 边缘网关部署脚本(Debian)
|
||||
# 用法:sudo bash deploy/install.sh
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR=/opt/hx-gateway
|
||||
DATA_DIR=/var/lib/hx-gateway
|
||||
SRC_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "请使用 root 运行:sudo bash deploy/install.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> 检查 Python 3.11 运行环境"
|
||||
# 运行环境固定使用独立 Python 3.11,不影响系统自带 python3.8。
|
||||
# 若 PATH 中已有 python3.11(例如已部署 python-build-standalone 并做了软链),则跳过 apt 安装。
|
||||
if ! command -v python3.11 >/dev/null 2>&1; then
|
||||
echo " 未检测到 python3.11,尝试通过 apt(deadsnakes) 安装..."
|
||||
apt-get update
|
||||
apt-get install -y python3.11 python3.11-venv
|
||||
else
|
||||
echo " 已检测到 python3.11: $(command -v python3.11)"
|
||||
fi
|
||||
|
||||
echo "==> 部署程序到 ${APP_DIR}"
|
||||
mkdir -p "${APP_DIR}" "${DATA_DIR}"
|
||||
rm -rf "${APP_DIR}/gateway"
|
||||
cp -r "${SRC_DIR}/gateway" "${APP_DIR}/gateway"
|
||||
cp "${SRC_DIR}/requirements.txt" "${APP_DIR}/requirements.txt"
|
||||
mkdir -p "${APP_DIR}/config"
|
||||
# 现场已存在的配置不覆盖,避免升级时丢失点表
|
||||
if [ ! -f "${APP_DIR}/config/config.yaml" ]; then
|
||||
cp "${SRC_DIR}/config/config.yaml" "${APP_DIR}/config/config.yaml"
|
||||
echo " 已写入默认配置,请按现场点表核对 ${APP_DIR}/config/config.yaml"
|
||||
fi
|
||||
|
||||
echo "==> 创建虚拟环境并安装依赖"
|
||||
python3.11 -m venv "${APP_DIR}/.venv"
|
||||
if compgen -G "${SRC_DIR}/wheels/*.whl" >/dev/null; then
|
||||
echo " 检测到本地 wheels,使用离线安装"
|
||||
"${APP_DIR}/.venv/bin/pip" install --no-index --find-links="${SRC_DIR}/wheels" -r "${APP_DIR}/requirements.txt"
|
||||
else
|
||||
"${APP_DIR}/.venv/bin/pip" install --upgrade pip
|
||||
"${APP_DIR}/.venv/bin/pip" install -r "${APP_DIR}/requirements.txt"
|
||||
fi
|
||||
|
||||
echo "==> 安装 systemd 服务"
|
||||
cp "${SRC_DIR}/deploy/hx-gateway.service" /etc/systemd/system/hx-gateway.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable hx-gateway
|
||||
systemctl restart hx-gateway
|
||||
|
||||
echo "==> 完成。查看日志: journalctl -u hx-gateway -f"
|
||||
echo " 寄存器映射自检: ${APP_DIR}/.venv/bin/python -m gateway.app --config ${APP_DIR}/config/config.yaml --print-map"
|
||||
Reference in new issue
Block a user