add power on total time
authorkyz <kongyuzhong@google.com>
Wed, 13 Aug 2025 04:42:16 +0000 (12:42 +0800)
committerkyz <kongyuzhong@google.com>
Wed, 13 Aug 2025 04:42:16 +0000 (12:42 +0800)
MDK-ARM/bootloader.uvprojx
user/user_app.c
user/user_report.c
user/user_valve_ctrl.c

index f39587dbd6f4c5dff86e6c5a4d8d198e5a94aa04..0792529f1041bfce38eb7be4276466b744021586 100644 (file)
               <MiscControls></MiscControls>
               <Define>USE_HAL_DRIVER,STM32H730xx,BOOTLOADER</Define>
               <Undefine></Undefine>
-              <IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32H7xx_HAL_Driver/Inc;../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32H7xx/Include;../Drivers/CMSIS/Include;../LWIP/App;../LWIP/Target;../Middlewares/Third_Party/LwIP/src/include;../Middlewares/Third_Party/LwIP/system;../Drivers/BSP/Components/lan8742;../Middlewares/Third_Party/LwIP/src/include/netif/ppp;../Middlewares/Third_Party/LwIP/src/include/lwip;../Middlewares/Third_Party/LwIP/src/include/lwip/apps;../Middlewares/Third_Party/LwIP/src/include/lwip/priv;../Middlewares/Third_Party/LwIP/src/include/lwip/prot;../Middlewares/Third_Party/LwIP/src/include/netif;../Middlewares/Third_Party/LwIP/src/include/compat/posix;../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa;../Middlewares/Third_Party/LwIP/src/include/compat/posix/net;../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys;../Middlewares/Third_Party/LwIP/src/include/compat/stdc;../Middlewares/Third_Party/LwIP/system/arch;../lib</IncludePath>
+              <IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32H7xx_HAL_Driver/Inc;../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32H7xx/Include;../Drivers/CMSIS/Include;../LWIP/App;../LWIP/Target;../Middlewares/Third_Party/LwIP/src/include;../Middlewares/Third_Party/LwIP/system;../Drivers/BSP/Components/lan8742;../Middlewares/Third_Party/LwIP/src/include/netif/ppp;../Middlewares/Third_Party/LwIP/src/include/lwip;../Middlewares/Third_Party/LwIP/src/include/lwip/apps;../Middlewares/Third_Party/LwIP/src/include/lwip/priv;../Middlewares/Third_Party/LwIP/src/include/lwip/prot;../Middlewares/Third_Party/LwIP/src/include/netif;../Middlewares/Third_Party/LwIP/src/include/compat/posix;../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa;../Middlewares/Third_Party/LwIP/src/include/compat/posix/net;../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys;../Middlewares/Third_Party/LwIP/src/include/compat/stdc;../Middlewares/Third_Party/LwIP/system/arch;../lib;..\user</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
index 557750f1384462ebcffca394d18280c577b07119..3fdf1b97d2893733d6ab2bd54c98726ec58bb68b 100644 (file)
@@ -76,6 +76,9 @@ void beep_init( void );
 extern void user_rtc_init( void );
 extern uint32_t hw_ver_read( void );
 
+static void device_poweron_total_time_update( uint32_t secs );
+
+
 void StartDefaultTask(void *argument)
 {
     EventBits_t uxBits;
@@ -95,6 +98,7 @@ void StartDefaultTask(void *argument)
     dev_cfg_v2_load(&g_dev.cfg2);
     lfs_load_device_serial(g_dev.serial_number, sizeof(g_dev.serial_number));
     g_dev.offline_secs = lfs_load_offline_time();
+    g_dev.all_time_total = lfs_load_all_time();
 
     g_dev.hw_ver = hw_ver_read();
 
@@ -148,6 +152,8 @@ void StartDefaultTask(void *argument)
                        HAL_IWDG_Refresh( &hiwdg1 ); //4s iwdg
                        flow_total_update( 1000 ); //软件计算累计流量
 
+                       device_poweron_total_time_update(1); //开机总时长更新
+
 #if 1  //离线锁定检查,
                        //g_dev.cfg2.offline_max_time, 0:离线不锁定,大于0允许离线时间,到达时间自动锁定。
                        time_t now = time(NULL);
@@ -695,3 +701,20 @@ uint32_t hw_ver_read( void )
         return HW_V3;
     }
 }
+
+void device_poweron_total_time_update( uint32_t secs ){
+       static int n = 0;
+       static int welding = 0;
+       n++;
+       g_dev.all_time_total += secs;
+       if( n>=60 ){
+               //60秒保存一次
+               n = 0;
+               lfs_store_all_time(g_dev.all_time_total);
+       }else if( welding != g_dev.welding_start ){
+               welding = g_dev.welding_start;
+               //焊接开始和停止时也保存
+               n = 0;
+               lfs_store_all_time(g_dev.all_time_total);
+       }
+}
\ No newline at end of file
index c522b8641680de89f7f2adaac40611168b920c43..9a57a1bbf1a009d8378b299dfaec2313014d255f 100644 (file)
@@ -133,7 +133,7 @@ int32_t get_new_rpt_info( rpt_info_t *rpt )
                else
                        rpt->gas = 1;
        }
-       
+
        rpt->weld_time = g_dev.welding_time_total/1000;
 #if 1
 /*
@@ -158,8 +158,7 @@ E10:流量故障
                rpt->alarm = 0;
        }
 #endif
-       rpt->on_time = 0;
-       
+       rpt->on_time = g_dev.all_time_total;
 
        if( memcmp( rpt, &g_rpt_sent, sizeof( g_rpt_sent ) ) ){
                rpt->cid++;
index 84990ecb5f4a1eee03f7252ac110c19649e5e525..cab668e793e88f4d76cd09759a17d7869be0c77f 100644 (file)
@@ -408,7 +408,7 @@ void user_valve_set_current( float current )
 }
 
 extern void welding_data_store( uint16_t index ); //记录焊接数据
-
+extern int32_t  is_curr_valid( float curr );
 //static uint64_t g_welding_time_total = 0;
 //static uint64_t g_time_total = 0;
 
@@ -480,7 +480,8 @@ void user_valve_ctrl_task( void* unused )
         //200毫秒扫描一次, 考虑pid的流量计反馈,让扫描周期大于流量计的采集周期,
         vTaskDelayUntil(&last_tick, 100 ); 
         welding_current = g_dev.welding_current;
-               
+               if( !is_curr_valid( welding_current ) )
+                       welding_current = 0;
 //             g_time_total += 100;
 //             
 //             static int i = 0;