refactor: 新增 misc_counter 替代 report_counter 做时间戳
- Loop154_States 新增 misc_counter (50ms 自由运行不复位) - 7处时间戳操作改用 misc_counter: passtime_start/last_exit_tick/misc_value - report_counter 还原原始清零逻辑, 仅管上报间隔 - 删除 last_report_tick 这样 report_counter 只管上报调度, misc_counter 只管时间戳, 互不干扰, 即使 report_counter 清零也不影响车间距/通过时间计算
This commit is contained in:
@@ -257,6 +257,7 @@ void TMR15_GLOBAL_IRQHandler(void)
|
||||
|
||||
/*--- 上报计数器 (50ms tick) ---*/
|
||||
g_loop_states.report_counter++;
|
||||
g_loop_states.misc_counter++;
|
||||
|
||||
for (i = 0; i < LOOP_CAPTURE_MAX; i++) {
|
||||
Loop154_Unit *unit = &g_loop_states.loop_unit[i];
|
||||
@@ -313,7 +314,7 @@ void TMR15_GLOBAL_IRQHandler(void)
|
||||
unit->loop_stable = 0;
|
||||
unit->loop_ORG_CNT = 0;
|
||||
unit->loop_ORG_SUM = 0;
|
||||
unit->last_exit_tick = g_loop_states.report_counter;
|
||||
unit->last_exit_tick = g_loop_states.misc_counter;
|
||||
#if USE_FLATNESS_EXIT
|
||||
unit->exit_state = 0;
|
||||
unit->max_slope = 0;
|
||||
@@ -523,11 +524,11 @@ void vd1_task_per_channel(Loop154_Unit *unit)
|
||||
unit->flow_count++;
|
||||
unit->relay_count++;
|
||||
if (unit->last_exit_tick > 0) {
|
||||
unit->misc_value = g_loop_states.report_counter - unit->last_exit_tick;
|
||||
unit->misc_value = g_loop_states.misc_counter - unit->last_exit_tick;
|
||||
} else {
|
||||
unit->misc_value = 0; // 首次检测, 车间距为0
|
||||
}
|
||||
unit->passtime_start = g_loop_states.report_counter; // 50ms tick
|
||||
unit->passtime_start = g_loop_states.misc_counter; // 50ms tick
|
||||
if (unit->hold_time > 0) {
|
||||
unit->loop_VD_HOLD = 1;
|
||||
}
|
||||
@@ -609,8 +610,8 @@ void vd1_task_per_channel(Loop154_Unit *unit)
|
||||
unit->exit_state = 0;
|
||||
|
||||
/* 主动上报: 计算通过时间 = 当前-进场 (50ms单位) */
|
||||
unit->misc_value = g_loop_states.report_counter - unit->passtime_start;
|
||||
unit->last_exit_tick = g_loop_states.report_counter;
|
||||
unit->misc_value = g_loop_states.misc_counter - unit->passtime_start;
|
||||
unit->last_exit_tick = g_loop_states.misc_counter;
|
||||
unit->relay_count++; // 离开时继电器翻转
|
||||
}
|
||||
} else {
|
||||
@@ -641,8 +642,8 @@ void vd1_task_per_channel(Loop154_Unit *unit)
|
||||
unit->loop_cnt_release = 0;
|
||||
|
||||
/* 主动上报: 通过时间 + 继电器 */
|
||||
unit->misc_value = g_loop_states.report_counter - unit->passtime_start;
|
||||
unit->last_exit_tick = g_loop_states.report_counter;
|
||||
unit->misc_value = g_loop_states.misc_counter - unit->passtime_start;
|
||||
unit->last_exit_tick = g_loop_states.misc_counter;
|
||||
unit->relay_count++;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -429,7 +429,7 @@ void uart_report_packet_loop_acs(uint8_t flag)
|
||||
} else {
|
||||
_interval = REPORT_IDLE_TICKS; // 12×50ms = 600ms
|
||||
}
|
||||
if ((g_loop_states.report_counter - g_loop_states.last_report_tick) < _interval) return;
|
||||
if (g_loop_states.report_counter < _interval) return;
|
||||
|
||||
/*--- 3. 确定本轮杂项类型 ---*/
|
||||
if (_flag_event) {
|
||||
@@ -526,7 +526,7 @@ void uart_report_packet_loop_acs(uint8_t flag)
|
||||
g_pkg_uart_report.pkg[i++] = _sum & 0xFF;
|
||||
|
||||
usart1_sendstring(g_pkg_uart_report.pkg, i);
|
||||
g_loop_states.last_report_tick = g_loop_states.report_counter;
|
||||
g_loop_states.report_counter = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1062,7 +1062,7 @@ void TMR6_GLOBAL_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
g_loop_states.last_report_tick = g_loop_states.report_counter;
|
||||
g_loop_states.report_counter = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user