|
|
@@ -0,0 +1,89 @@
|
|
|
+/*
|
|
|
+ * 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
|
|
|
+ */
|
|
|
+#include "sys_monitor.h"
|
|
|
+#include "cpu_usage.h"
|
|
|
+#include "control.h"
|
|
|
+#include "sht30_collect.h"
|
|
|
+#define DBG_ENABLE
|
|
|
+#define DBG_COLOR
|
|
|
+#define DBG_TAG "sysmonitor"
|
|
|
+#define DBG_LEVEL DBG_LOG
|
|
|
+#include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
|
|
|
+
|
|
|
+rt_thread_t tid_sys_monitor = RT_NULL;
|
|
|
+
|
|
|
+Device_Status_typedef device_status;
|
|
|
+System_stats_t system_status;
|
|
|
+
|
|
|
+
|
|
|
+static void sys_monitor_thread_entry(void *parameter)
|
|
|
+{
|
|
|
+ uint8_t sec_t;
|
|
|
+ system_status.lamp_start_time = 0;
|
|
|
+ system_status.heat_start_time = 0;
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ sec_t++;
|
|
|
+ system_status.cpu_usage = (int)cpu_load_average();
|
|
|
+ if(system_status.cpu_usage>system_status.cpu_usage_max){
|
|
|
+ system_status.cpu_usage_max = system_status.cpu_usage;
|
|
|
+ }
|
|
|
+ rt_tick_t tick = rt_tick_get();
|
|
|
+ rt_uint32_t total_sec = (rt_uint32_t)(tick / RT_TICK_PER_SECOND);
|
|
|
+ system_status.system_uptime = total_sec;
|
|
|
+ system_status.cpu_tempture = (int)Get_Temprate()/100;
|
|
|
+ rt_uint32_t hours = total_sec / 3600;
|
|
|
+ rt_uint32_t minutes = (total_sec % 3600) / 60;
|
|
|
+ rt_uint32_t seconds = total_sec % 60;
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ if(sec_t%10==0){
|
|
|
+ LOG_D("CPU温度:%d℃",system_status.cpu_tempture);
|
|
|
+ LOG_D("CPU利用率 :%d% Max:%d%",system_status.cpu_usage,system_status.cpu_usage_max);
|
|
|
+ LOG_D("系统运行时长:%d时%d分%d秒",hours,minutes,seconds);
|
|
|
+ LOG_D("重启次数:%d",device_status.rebootcnt);
|
|
|
+
|
|
|
+ LOG_D("串口2累计发送字节:%d",system_status.uart2_tx_bytes);
|
|
|
+ LOG_D("串口2累计接收字节:%d",system_status.uart2_rx_bytes);
|
|
|
+
|
|
|
+ LOG_D("串口4累计发送字节:%d",system_status.uart4_tx_bytes);
|
|
|
+ LOG_D("串口4累计接收字节:%d",system_status.uart4_rx_bytes);
|
|
|
+
|
|
|
+ LOG_D("累计上传数据:%d 条",system_status.json_upload_count);
|
|
|
+ LOG_D("累计拍照次数:%d ",system_status.photo_taken_count);
|
|
|
+ LOG_D("累计清扫次数:%d ",system_status.cleaning_count);
|
|
|
+ LOG_D("累计震动次数:%d ",system_status.vibration_count);
|
|
|
+
|
|
|
+ LOG_D("上仓门累计打开:%d ",system_status.upper_door_open_count);
|
|
|
+ LOG_D("上仓门累计关闭:%d ",system_status.upper_door_close_count);
|
|
|
+ LOG_D("下仓门累计打开:%d ",system_status.lower_door_open_count);
|
|
|
+ LOG_D("下仓门累计关闭:%d ",system_status.lower_door_close_count);
|
|
|
+
|
|
|
+ LOG_D("灯管累计运行:%d S",system_status.lamp_running_time/RT_TICK_PER_SECOND);
|
|
|
+ LOG_D("加热累计运行:%d S",system_status.heater_running_time/RT_TICK_PER_SECOND);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int Sys_Motor_Task(void)
|
|
|
+{
|
|
|
+ /* 创建线程*/
|
|
|
+ tid_sys_monitor = rt_thread_create("sys_monitor",
|
|
|
+ sys_monitor_thread_entry, RT_NULL,
|
|
|
+ 1024, //2048
|
|
|
+ 28, //12
|
|
|
+ 5); //5
|
|
|
+
|
|
|
+ if(tid_sys_monitor!=RT_NULL)
|
|
|
+ {
|
|
|
+ rt_thread_startup(tid_sys_monitor);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|