| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2026-02-04 Administrator the first version
- */
- #ifndef APPLICATIONS_SYS_MONITOR_H_
- #define APPLICATIONS_SYS_MONITOR_H_
- #include <rtthread.h>
- /* 根据你的MCU字长选择合适的数据类型 */
- typedef uint32_t time_sec_t; // 用于秒级的时间统计
- typedef uint64_t time_ms_t; // 用于毫秒级的时间统计
- typedef uint32_t counter_t; // 用于计数器
- typedef uint16_t small_counter_t; // 用于小计数器
- /* 系统运行统计结构体 */
- typedef struct
- {
- /* 1. 系统运行时间相关 */
- time_sec_t system_uptime; // 系统总运行时长(秒)
- time_sec_t network_connected_time; // 联网时间(秒)
- time_sec_t network_disconnected_time; // 断网时间(秒)
- /* 2. CPU相关 */
- uint8_t cpu_tempture;
- uint8_t cpu_usage; // CPU占用率(0-100%)
- uint8_t cpu_usage_max; // 历史最大CPU占用率
- /* 3. 通信统计 */
- counter_t uart2_rx_bytes; // 串口接收字节数
- counter_t uart2_tx_bytes; // 串口发送字节数
- counter_t json_upload_count; // JSON数据上传次数
- counter_t uart4_rx_bytes; // 串口接收字节数
- counter_t uart4_tx_bytes; // 串口发送字节数
- /* 4. 动作次数统计 */
- counter_t photo_taken_count; // 拍照次数统计
- counter_t cleaning_count; // 清扫次数统计
- counter_t vibration_count; // 震动次数统计
- /* 5. 仓门状态统计 */
- counter_t upper_door_open_count; // 上仓门打开次数
- counter_t upper_door_close_count; // 上仓门关闭次数
- counter_t lower_door_open_count; // 下仓门打开次数
- counter_t lower_door_close_count; // 下仓门关闭次数
- /* 6. 传感器触发统计 */
- counter_t rain_control_triggers; // 雨控触发次数
- counter_t light_control_triggers; // 光控触发次数
- /* 7. 设备运行时间统计 */
- time_sec_t lamp_start_time;
- time_sec_t lamp_running_time; // 灯管运行时间
- time_sec_t heat_start_time;
- time_sec_t heater_running_time; // 加热时间
- time_sec_t fill_light_running_time; // 补光灯运行时间
- /* 8. 时间戳信息(可选) */
- time_sec_t last_reset_time; // 上次重置时间戳
- uint32_t reset_count; // 系统重置次数
- uint32_t rain_value; // 雨控值
- } System_stats_t;
- /* 刷新实时统计字段(CPU温度/利用率/运行时长)。
- * 原 sys_monitor 后台线程已取消,现由控制台命令 Msh_DisplaySysMonitor 与
- * upload_sys_monitor_info() 上报前调用(非阻塞,可任意线程上下文调用)。 */
- void sys_monitor_refresh(void);
- #endif /* APPLICATIONS_SYS_MONITOR_H_ */
|