change: 时间量上报单位 5ms→10ms
- 进场车间距 / 离场通过时间: misc_value = (差值)/2 - 内部时间戳保持 5ms 精度, 仅上报值转为 10ms - 更新注释和 devlog (V2.6)
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
#define MISC_TYPE_COUNT 4 // 总类型数
|
||||
|
||||
/*===========================================================================
|
||||
* 主动上报 — 间隔 (5ms tick)
|
||||
* 主动上报 — 间隔 (5ms tick, misc_value 上报时 /2 转 10ms)
|
||||
*===========================================================================*/
|
||||
#define REPORT_IDLE_TICKS 120 // 空闲稳定: 120×5ms = 600ms
|
||||
#define REPORT_EVENT_TICKS 30 // 事件/变化: 30×5ms = 150ms
|
||||
@@ -181,8 +181,8 @@ typedef struct {
|
||||
/*--- 主动上报杂项计数 ---*/
|
||||
uint32_t flow_count; // 车流量累计
|
||||
uint32_t relay_count; // 继电器动作次数
|
||||
uint32_t passtime_start; // 进场 时间戳(5ms tick)
|
||||
uint32_t last_exit_tick; // 上次离场 时间戳(5ms tick), 用于车间距计算
|
||||
uint32_t passtime_start; // 进场 时间戳(5ms tick, 上报/2→10ms)
|
||||
uint32_t last_exit_tick; // 上次离场 时间戳(5ms tick, 上报/2→10ms)
|
||||
uint32_t misc_value; // 当前要上报的杂项值
|
||||
} Loop154_Unit;
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ 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.report_counter - unit->last_exit_tick) / 2;
|
||||
} else {
|
||||
unit->misc_value = 0; // 首次检测, 车间距为0
|
||||
}
|
||||
@@ -608,8 +608,8 @@ void vd1_task_per_channel(Loop154_Unit *unit)
|
||||
unit->flat_ok_cnt = 0;
|
||||
unit->exit_state = 0;
|
||||
|
||||
/* 主动上报: 计算通过时间 = 当前-进场时间戳 (5ms单位) */
|
||||
unit->misc_value = g_loop_states.report_counter - unit->passtime_start;
|
||||
/* 主动上报: 计算通过时间 = (当前-进场)/2 (10ms单位) */
|
||||
unit->misc_value = (g_loop_states.report_counter - unit->passtime_start) / 2;
|
||||
unit->last_exit_tick = g_loop_states.report_counter;
|
||||
unit->relay_count++; // 离开时继电器翻转
|
||||
}
|
||||
@@ -641,7 +641,7 @@ 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->misc_value = (g_loop_states.report_counter - unit->passtime_start) / 2;
|
||||
unit->last_exit_tick = g_loop_states.report_counter;
|
||||
unit->relay_count++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user