From f04037818f88ddcdcbc7ad240a8f16b31c996c55 Mon Sep 17 00:00:00 2001 From: kyz Date: Sun, 28 Apr 2024 15:39:00 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=B0=94=E8=B7=AF=E9=80=89?= =?utf8?q?=E6=8B=A9=E6=96=AD=E7=94=B5=E4=BF=9D=E5=AD=98=E5=8A=9F=E8=83=BD?= =?utf8?q?=EF=BC=8C=E9=80=9A=E8=BF=87=E4=B8=8A=E4=BD=8D=E6=9C=BA=E6=8C=87?= =?utf8?q?=E4=BB=A4=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- MDK-ARM/welding_controller_v2.uvprojx | 2 +- tools_v2/test.py | 15 +++++++++------ tools_v2/test.ui | 21 +++++++++++++++++---- user/user.h | 4 +++- user/user_app.c | 4 ++++ user/user_cdc_rx_2.c | 13 +++++++++---- user/user_ui.c | 12 ++++++++---- user/user_valve_ctrl.c | 4 ++-- 8 files changed, 53 insertions(+), 22 deletions(-) diff --git a/MDK-ARM/welding_controller_v2.uvprojx b/MDK-ARM/welding_controller_v2.uvprojx index 886a6c1..03363b8 100644 --- a/MDK-ARM/welding_controller_v2.uvprojx +++ b/MDK-ARM/welding_controller_v2.uvprojx @@ -361,7 +361,7 @@ - 1 + 0 0 0 0 diff --git a/tools_v2/test.py b/tools_v2/test.py index 2a5683c..dc54662 100644 --- a/tools_v2/test.py +++ b/tools_v2/test.py @@ -126,26 +126,28 @@ class App( QDialog, ui_welding.Ui_Dialog ): return d = b'' if cfg == 1: - #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B + #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存 cmd = 0x00B7 - d = struct.pack( '>LLLlL', + d = struct.pack( '>LLLlLL', #int(self.lineEdit_cfg_method.text()), self.cb_cfg_method.currentIndex(), int(self.lineEdit_cfg_factor.text()), int(self.lineEdit_cfg_prev.text()), 100000, #填无效值 - 100000 #填无效值 + 100000, #填无效值 + 1 if self.cb_path_save.isChecked() else 0 ) print( "write cfg cmd:%04X"%cmd, d.hex()) elif cfg == 2: cmd = 0x00B7 - d = struct.pack( '>LLLlL', + d = struct.pack( '>LLLlLL', 100000, #填无效值 100000, #填无效值 100000, #填无效值 int(self.lineEdit_flow_comp.text()), #int(self.lineEdit_flow_coeff.text()) - gas_coefficient[ self.cb_flow_coeff.currentIndex()][1] + gas_coefficient[ self.cb_flow_coeff.currentIndex()][1], + 0xFFFFFFFF, #填无效值 ) elif cfg == 3: cmd = 0x00B9 @@ -483,7 +485,7 @@ class App( QDialog, ui_welding.Ui_Dialog ): elif cmd == 0x00B6 and len(data)>=20: #参数读取 print( "B6 resp:", data.hex() ) #//节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B - method, factor, prev, comp, coeff = struct.unpack( '>LLLlL', data ) + method, factor, prev, comp, coeff, bypass_save = struct.unpack( '>LLLlLL', data ) #self.lineEdit_cfg_method.setText( "%d"%method ) self.lineEdit_cfg_factor.setText( "%d"%factor ) self.lineEdit_cfg_prev.setText( "%d"%prev ) @@ -494,6 +496,7 @@ class App( QDialog, ui_welding.Ui_Dialog ): if gas_coefficient[idx][1] == coeff: self.cb_flow_coeff.setCurrentIndex(idx) break + self.cb_path_save.setChecked( bypass_save == 1 ) elif cmd == 0x00B8 and len(data)>=128+16: #参数读取 print( "B8 resp:", data.hex() ) diff --git a/tools_v2/test.ui b/tools_v2/test.ui index 0ea53bf..44adfe2 100644 --- a/tools_v2/test.ui +++ b/tools_v2/test.ui @@ -189,7 +189,7 @@ - 2 + 3 @@ -1978,12 +1978,25 @@ + + + + 260 + 120 + 131 + 41 + + + + 气路选择断电保存 + + 20 - 210 + 220 421 131 @@ -2114,7 +2127,7 @@ 20 - 350 + 370 421 131 @@ -2211,7 +2224,7 @@ 20 - 490 + 520 421 131 diff --git a/user/user.h b/user/user.h index 51436f8..fd56b43 100644 --- a/user/user.h +++ b/user/user.h @@ -109,6 +109,8 @@ typedef struct{ net_cfg_t net; cal_t cal; uint8_t remote_locked; //1:locked 远程锁定 + uint8_t bypass_save; //1:bypass 断电保存, other:断电不保存 + uint8_t bypass; //1:bypass, other: uint8_t flag; }dev_cfg_t; @@ -143,7 +145,7 @@ typedef struct { osMutexId_t sflash_lock; uint32_t welding_record_number; //焊接记录长度 - uint32_t ui_bypass; +// uint32_t ui_bypass; uint32_t welding_start; //1焊接中, 0:焊接未开始 uint32_t welding_time; //焊接持续时间 diff --git a/user/user_app.c b/user/user_app.c index 81d4483..21f7f84 100644 --- a/user/user_app.c +++ b/user/user_app.c @@ -185,6 +185,10 @@ int32_t dev_cfg_load( dev_cfg_t *cfg ) cfg->net.tcp_server[i] = 0; } } + if( cfg->bypass_save != 1){ + cfg->bypass = 0; + } + // for( int i=0; inet.tcp_port); i++ ){ // if( cfg->net.tcp_port[i] <= 0x20 || cfg->net.tcp_port[i]>0x7f ){ // cfg->net.tcp_port[i] = 0; diff --git a/user/user_cdc_rx_2.c b/user/user_cdc_rx_2.c index 3a6424f..f390716 100644 --- a/user/user_cdc_rx_2.c +++ b/user/user_cdc_rx_2.c @@ -406,22 +406,24 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt ) case 0xB5: //焊接数据清0 break; case 0xB6: //设备参数读取 - //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B + //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B put_u32_big( &resp[0], g_dev.cfg.welding_method ); put_u32_big( &resp[4], g_dev.cfg.save_gas_factor ); put_u32_big( &resp[8], g_dev.cfg.valve_open_default ); put_u32_big( &resp[12], g_dev.cfg.cal.flow_comp_x1000 ); put_u32_big( &resp[16], g_dev.cfg.cal.flow_coeff_x1000 ); - tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 20 ); + put_u32_big( &resp[20], g_dev.cfg.bypass_save ); + tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 24 ); break; case 0xB7: //设备参数写入 - //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B + //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B { uint32_t method = get_u32_big( &pkt->pdata[0] ); uint32_t factor = get_u32_big( &pkt->pdata[4] ); uint32_t valve_open = get_u32_big( &pkt->pdata[8] ); int32_t comp = get_u32_big( &pkt->pdata[12] ); uint32_t coeff = get_u32_big( &pkt->pdata[16] ); + uint32_t bypass_save = get_u32_big( &pkt->pdata[20] ); if( factor >=2 && factor <= 30 ) g_dev.cfg.save_gas_factor = factor; @@ -433,6 +435,8 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt ) g_dev.cfg.cal.flow_comp_x1000 = comp; if(coeff == 0 ||( coeff >100 && coeff < 3000 ) ) g_dev.cfg.cal.flow_coeff_x1000 = coeff; + if( bypass_save == 1 || bypass_save == 0 ) + g_dev.cfg.bypass_save = bypass_save; dev_cfg_store( &g_dev.cfg ); ui_cfg_remote_update(); @@ -441,7 +445,8 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt ) put_u32_big( &resp[8], g_dev.cfg.valve_open_default ); put_u32_big( &resp[12], g_dev.cfg.cal.flow_comp_x1000 ); put_u32_big( &resp[16], g_dev.cfg.cal.flow_coeff_x1000 ); - tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 20 ); + put_u32_big( &resp[20], g_dev.cfg.bypass_save ); + tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 24 ); break; } case 0xB8: //WIFI参数读取 diff --git a/user/user_ui.c b/user/user_ui.c index c2f78ae..017e40d 100644 --- a/user/user_ui.c +++ b/user/user_ui.c @@ -205,7 +205,9 @@ void ui_handle_lcd_pkt( void ) } }else if( ctrl_addr == lcd_valve_bypass_addr ){//比例阀旁路 uint8_t bypass = ctrl_value; - g_dev.ui_bypass = bypass; + //g_dev.ui_bypass = bypass; + g_dev.cfg.bypass = bypass; + dev_cfg_store( &g_dev.cfg ); }else if( ctrl_addr == lcd_wifi_config_addr ){ //点击配置按钮 lcd_read( lcd_wifi_ssid_addr, lcd_net_cfg_size/2 ); }else if( ctrl_addr == lcd_flow_cal_start_addr ){ //点击流量校准按钮 @@ -364,11 +366,12 @@ void ui_cfg_remote_update( void ) void lcd_update_cfg( void ) { char port_str[8]; - uint16_t reg_values[3]; + uint16_t reg_values[4]; reg_values[0] = g_dev.cfg.welding_method+1; reg_values[1] = g_dev.cfg.save_gas_factor; reg_values[2] = g_dev.cfg.valve_open_default; - lcd_write( lcd_welding_method_addr, reg_values, 3 ); + reg_values[3] = g_dev.cfg.bypass; + lcd_write( lcd_welding_method_addr, reg_values, 4 ); osDelay(10 ); lcd_write_text( lcd_wifi_ssid_addr, (uint8_t*)&g_dev.cfg.net.wifi_ssid, lcd_wifi_ssid_size ); @@ -414,7 +417,8 @@ void user_ui_task( void* unused ) reg_values[4] = g_dev.cfg.welding_method+1; reg_values[5] = g_dev.cfg.save_gas_factor; reg_values[6] = g_dev.cfg.valve_open_default; - lcd_write( lcd_welding_current_addr, reg_values, 7 ); + reg_values[7] = g_dev.cfg.bypass==1?1:0; + lcd_write( lcd_welding_current_addr, reg_values, 8 ); osDelay(10 ); lcd_write_text( lcd_wifi_ssid_addr, (uint8_t*)&g_dev.cfg.net.wifi_ssid, lcd_wifi_ssid_size ); osDelay(10 ); diff --git a/user/user_valve_ctrl.c b/user/user_valve_ctrl.c index eec07c8..3b798e9 100644 --- a/user/user_valve_ctrl.c +++ b/user/user_valve_ctrl.c @@ -500,10 +500,10 @@ void user_valve_ctrl_task( void* unused ) g_dev.state &= ~(TEMP_ERR); } #endif - if( !bypass && (g_dev.ui_bypass || tem_err_state ) ){ + if( !bypass && (g_dev.cfg.bypass || tem_err_state ) ){ //屏上点击旁路或温度故障,开启旁路 bypass = 1; - }else if( bypass && !g_dev.ui_bypass && !tem_err_state ){ + }else if( bypass && !g_dev.cfg.bypass && !tem_err_state ){ //恢复正常,关闭旁路 bypass = 0; } -- 2.34.1