feat(vd960Loop): 0xC0 主动上报 — 4种杂项类型轮转 + 事件优先级

杂项类型轮转:
- 0b00 时间量: 进场=车间距, 离开=通过时间, 空闲=0
- 0b01 线圈断开次数
- 0b10 车流量累计
- 0b11 继电器动作次数

上报间隔:
- 空闲稳定: 600ms, 轮流上报 0→1→2→3
- 进场/离开事件: 150ms, 强制时间量, 最高优先级

TaskLoop.h: 新增 MISC_TYPE_* / REPORT_*_TICKS 宏
           Loop154_Unit 新增 flow_count/relay_count/passtime_start/misc_value
           Loop154_States 新增 report_misc_round
TaskLoop.c: 进场时记录时间戳+累计; 离开时计算通过时间
main.c:    重写 uart_report_packet_loop_acs
This commit is contained in:
wangfq
2026-07-02 18:18:16 +08:00
parent 9bab650c27
commit 9e125f953c
3 changed files with 114 additions and 28 deletions

View File

@@ -69,6 +69,21 @@
*===========================================================================*/
#define LOOP_CAPTURE_MAX 4
/*===========================================================================
* 主动上报 — 杂项类型 (misc_type 低2bit)
*===========================================================================*/
#define MISC_TYPE_TIME 0 // 时间量 (通过时间/车间距)
#define MISC_TYPE_CUT 1 // 线圈断开次数
#define MISC_TYPE_FLOW 2 // 车流量数
#define MISC_TYPE_RELAY 3 // 继电器输出次数
#define MISC_TYPE_COUNT 4 // 总类型数
/*===========================================================================
* 主动上报 — 间隔 (5ms tick)
*===========================================================================*/
#define REPORT_IDLE_TICKS 120 // 空闲稳定: 120×5ms = 600ms
#define REPORT_EVENT_TICKS 30 // 事件/变化: 30×5ms = 150ms
/*===========================================================================
* 灵敏度表4级: 0=低, 3=高)
* 进入阈值 = Origin × SensTable[SENS] / 65536
@@ -162,13 +177,20 @@ typedef struct {
/*--- 调试 ---*/
uint32_t xn_counter;
/*--- 主动上报杂项计数 ---*/
uint32_t flow_count; // 车流量累计
uint32_t relay_count; // 继电器动作次数
uint32_t passtime_start; // 进场/离开 时间戳(5ms tick)
uint32_t misc_value; // 当前要上报的杂项值
} Loop154_Unit;
/*===========================================================================
* 全局状态
*===========================================================================*/
typedef struct {
uint32_t report_counter;
uint32_t report_counter; // 上报间隔计数器 (5ms tick)
uint8_t report_misc_round; // 空闲轮转: 0=MISC_TYPE_TIME, 1=CUT, 2=FLOW, 3=RELAY
Loop154_Unit loop_unit[LOOP_CAPTURE_MAX];
} Loop154_States;