fix(engine): stop coal_feeder before starting distributor on acc_time trigger

When accumulated_run_sec reaches acc_time_sec, the coal feeder must be stopped
before entering DistributorRunning state. Previously the feeder was left running
while the distributor also ran, which is incorrect per the control spec.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-03-25 13:00:24 +08:00
parent 3a8a2c1389
commit 0077a4ad90
1 changed files with 22 additions and 1 deletions

View File

@ -291,10 +291,31 @@ async fn tick_state_machine(
return; return;
} }
// Check AccTime — trigger distributor // Check AccTime — stop feeder then trigger distributor
if unit.acc_time_sec > 0 if unit.acc_time_sec > 0
&& runtime.accumulated_run_sec >= unit.acc_time_sec as i64 * 1000 && runtime.accumulated_run_sec >= unit.acc_time_sec as i64 * 1000
{ {
let monitor = state
.connection_manager
.get_point_monitor_data_read_guard()
.await;
if let Some((pid, vt)) =
feeder_roles.and_then(|r| find_cmd(r, "stop_cmd", &monitor))
{
drop(monitor);
if let Err(e) =
send_pulse_command(&state.connection_manager, pid, vt.as_ref(), 300).await
{
tracing::warn!("Engine: stop coal_feeder before distributor failed: {}", e);
return;
}
if state.config.simulate_plc {
if let Some(eq_id) = feeder_eq_id {
crate::control::command::simulate_run_feedback(state, eq_id, false)
.await;
}
}
}
runtime.state = UnitRuntimeState::DistributorRunning; runtime.state = UnitRuntimeState::DistributorRunning;
runtime.distributor_run_elapsed_sec = 0; runtime.distributor_run_elapsed_sec = 0;
} }