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;
#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 );
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__
\"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\
\"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
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;
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;
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;
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{
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;
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<<i)){
+ if( nr )
+ sprintf( buf, ", %d", i+1 );
+ else
+ sprintf( buf, "%d", i+1 );
+ nr++;
+ strcat( falt_code, buf );
+ }
+ }
+ strcat( falt_code, " ]" );
+ }
+ return falt_code;
+}
char * devinfo_report_str( void )
{
g_rpt_sent.curr_x10/10.0f,
g_rpt_sent.weld_st,
g_rpt_sent.flow_x10/10.0f,
+ g_rpt_sent.vol_x10/10.0f,
weld_method_str[g_rpt_sent.weld_tech],
g_rpt_sent.factor,
g_rpt_sent.pressure,
g_rpt_sent.path,
g_rpt_sent.prev,
g_rpt_sent.freq,
- g_rpt_sent.gas
+ g_rpt_sent.gas,
+ g_rpt_sent.weld_time,
+ rpt_fault_code(g_rpt_sent.alarm),
+ g_rpt_sent.on_time
);
last_rpt_tick = now;
return tx_buf;