|
|
@@ -531,19 +531,19 @@ export async function apiGetHomeSnapshot() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-/** GET /api/home/control-mode-stats — 控制模式分布(总数与信号机总数同步,内部重分配) */
|
|
|
+/** GET /api/home/control-mode-stats — 控制模式分布(总数与信号机在线数同步) */
|
|
|
export async function apiGetControlModeStats() {
|
|
|
await delay(150)
|
|
|
- const sm = DB.deviceStatus.signalMachine
|
|
|
- const total = sm.chartData[0].value + sm.chartData[1].value
|
|
|
+ const snap = _getSmFaultSnapshot()
|
|
|
+ const onlineTotal = snap.total - snap.faultTotal
|
|
|
const modes = DB.homeData.controlModes
|
|
|
// 各项按基准值波动
|
|
|
const fluctuated = modes.map(m => ({
|
|
|
...m, value: Math.max(0, _fluctuate(m.value, Math.ceil(m.value * 0.05))),
|
|
|
}))
|
|
|
- // 修正总数:将差值补到第一项(定周期控制),保证总数 = 信号机总数
|
|
|
+ // 修正总数:将差值补到第一项(定周期控制),保证总数 = 信号机在线数
|
|
|
const currentSum = fluctuated.reduce((s, m) => s + m.value, 0)
|
|
|
- fluctuated[0].value = Math.max(0, fluctuated[0].value + (total - currentSum))
|
|
|
+ fluctuated[0].value = Math.max(0, fluctuated[0].value + (onlineTotal - currentSum))
|
|
|
return ok(fluctuated)
|
|
|
}
|
|
|
|