From a4332292a55f6e8f277308e30840c82626ccd1bc Mon Sep 17 00:00:00 2001 From: kyz Date: Sun, 27 Apr 2025 13:50:48 +0800 Subject: [PATCH] =?utf8?q?v4.5=20=E4=B8=8A=E6=8A=A5=E7=84=8A=E6=8E=A5?= =?utf8?q?=E6=97=B6=E9=95=BF=E5=88=B0=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- user/user.h | 2 +- user/user_lfs.c | 38 ++++++++++++++++++++++ user/user_lfs.h | 8 ++++- user/user_report.c | 73 +++++++++++++++++++++++++++++++++++++++--- user/user_valve_ctrl.c | 2 +- 5 files changed, 116 insertions(+), 7 deletions(-) diff --git a/user/user.h b/user/user.h index 99c27b4..e605dfb 100644 --- a/user/user.h +++ b/user/user.h @@ -27,7 +27,7 @@ //#include "fmc.h" //-------------------- #define APP_VER_MAJOR 4 -#define APP_VER_MINOR 4 +#define APP_VER_MINOR 5 #define HW_V2 2 #define HW_V3 3 diff --git a/user/user_lfs.c b/user/user_lfs.c index c004ded..e5bfb66 100644 --- a/user/user_lfs.c +++ b/user/user_lfs.c @@ -165,6 +165,44 @@ int32_t lfs_store_device_serial( char *sn ) return user_lfs_write( DEVICE_SN_PATH, (uint8_t*)sn, strlen( sn ) ) == strlen(sn)?0:-1; } +uint32_t lfs_load_all_time(void) +{ + uint32_t secs = 0; + if( user_lfs_read( ALL_TIME_PATH, (uint8_t*)&secs, sizeof( secs ) ) == sizeof( secs ) ){ + + } + return secs; +} + +uint32_t lfs_store_all_time(uint32_t secs) +{ + int32_t ret = -1; + + if( user_lfs_write( ALL_TIME_PATH, (uint8_t*)&secs, sizeof( secs ) ) == sizeof( secs ) ){ + ret = 0; + } + return ret; +} + +uint32_t lfs_load_weld_time(void) +{ + uint32_t secs = 0; + if( user_lfs_read( WELD_TIME_PATH, (uint8_t*)&secs, sizeof( secs ) ) == sizeof( secs ) ){ + + } + return secs; +} + +uint32_t lfs_store_weld_time(uint32_t secs) +{ + int32_t ret = -1; + + if( user_lfs_write( WELD_TIME_PATH, (uint8_t*)&secs, sizeof( secs ) ) == sizeof( secs ) ){ + ret = 0; + } + return ret; +} + uint32_t lfs_load_offline_time( void ) { uint32_t secs = 0; diff --git a/user/user_lfs.h b/user/user_lfs.h index 29157ff..5a6881f 100644 --- a/user/user_lfs.h +++ b/user/user_lfs.h @@ -8,7 +8,8 @@ #define DEVICE_SN_PATH "device_serial" #define DEVICE_CONFIG_PATH "device_config" #define DEVICE_CONFIG_V2_PATH "device_config_v2" - +#define WELD_TIME_PATH "weld_time" +#define ALL_TIME_PATH "all_time" int32_t user_lfs_init( void ); int32_t user_lfs_read( char *path, uint8_t *read_buffer, uint32_t read_size ); @@ -19,4 +20,9 @@ int32_t lfs_load_device_serial( char *read_buffer, uint32_t buffer_size ); int32_t lfs_store_device_serial( char *sn ); uint32_t lfs_load_offline_time( void ); int32_t lfs_store_offline_time( uint32_t secs ); +uint32_t lfs_store_weld_time(uint32_t secs); +uint32_t lfs_load_weld_time(void); +uint32_t lfs_store_all_time(uint32_t secs); +uint32_t lfs_load_all_time(void); + #endif //__USER_LFS_H__ diff --git a/user/user_report.c b/user/user_report.c index 3c93700..1c68349 100644 --- a/user/user_report.c +++ b/user/user_report.c @@ -36,7 +36,8 @@ static const char *fmt = "{\n\ \"val\":{\n\ \"c\":\"%0.1f\",\n\ \"s\":\"%d\",\n\ - \"g\":\"%0.1f\"\n\ + \"g\":\"%0.1f\",\n\ + \"v\":\"%0.1f\"\n\ },\n\ \"weldTech\":\"%s\",\n\ \"solarTermFactor\":\"%d\",\n\ @@ -49,7 +50,10 @@ static const char *fmt = "{\n\ \"gasPathType\":%d,\n\ \"airRatio\":%d,\n\ \"syncFrequency\":%d,\n\ -\"gasType\":%d\n\ +\"gasType\":%d,\n\ +\"totalTime\":%d,\n\ +\"alarmType\":%s,\n\ +\"onTime\":%d\n\ }"; #endif @@ -62,6 +66,7 @@ typedef struct{ uint32_t curr_x10; uint32_t weld_st; uint32_t flow_x10; + uint32_t vol_x10;//电压 uint32_t weld_tech; uint32_t factor; uint32_t pressure; @@ -74,6 +79,9 @@ typedef struct{ uint32_t prev; uint32_t freq; uint32_t gas; //1,2,3 + uint32_t weld_time; + uint32_t alarm;//1,2,3 + uint32_t on_time; }rpt_info_t; static rpt_info_t g_rpt_sent; @@ -102,6 +110,7 @@ int32_t get_new_rpt_info( rpt_info_t *rpt ) rpt->curr_x10 = (uint32_t)(welding_curr_disp_value( g_dev.welding_current )*10); rpt->weld_st = g_dev.welding_start; rpt->flow_x10 = (uint32_t)(g_dev.flowmeter.flow_speed*10); + rpt->vol_x10 = 0; //(uint32_t)(g_dev.welding_voltage*10); rpt->weld_tech = g_dev.cfg.welding_method; rpt->factor = g_dev.cfg.save_gas_factor, rpt->pressure = (uint32_t)g_dev.pressure; @@ -113,7 +122,7 @@ int32_t get_new_rpt_info( rpt_info_t *rpt ) rpt->path = g_dev.cfg.bypass?0:1, //平台定义节气为1, 旁路为0 rpt->prev = g_dev.cfg.valve_open_default; rpt->freq = g_dev.cfg.iot_rpt_period; - + if( g_dev.cfg2.gas > GAS_DEFAULT && g_dev.cfg2.gas <= GAS_MAX ){ rpt->gas = g_dev.cfg2.gas; }else{ @@ -125,6 +134,33 @@ int32_t get_new_rpt_info( rpt_info_t *rpt ) rpt->gas = 1; } + rpt->weld_time = g_dev.welding_time_total/1000; +#if 1 +/* +E1 :电流传感器故障 +E2:流量计故障 +E3:压力计故障 +E9:漏气故障 +E10:流量故障 +*/ + rpt->alarm = g_dev.state; +#else + if(g_dev.alarm.leakage == 1) + { + rpt->alarm = 2; + } + else if(g_dev.alarm.flow_rate_low == 1) + { + rpt->alarm = 1; + } + else + { + rpt->alarm = 0; + } +#endif + rpt->on_time = 0; + + if( memcmp( rpt, &g_rpt_sent, sizeof( g_rpt_sent ) ) ){ rpt->cid++; return 0; @@ -167,6 +203,31 @@ static void mac_str_init( void ) static const char * weld_method_str[3] = {"TIG", "MIG", "MAG" }; +char *rpt_fault_code( uint32_t alarm ) +{ + static char falt_code[128]; + char buf[16]; + int nr; + + if( alarm == 0 ){ + strcpy( falt_code, "[ 0 ]" ); + }else{ + sprintf( falt_code, "[ " ); + nr = 0; + for( int i=0; i<32; i++ ){ + if( alarm& (1< ms #if 0 -- 2.34.1