/* Includes ------------------------------------------------------------------*/
#include "lan8742.h"
-
+#include "user.h"
/** @addtogroup BSP
* @{
*/
/* Wait for 2s to perform initialization */
while((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO)
{
+ osDelay(100);
}
pObj->Is_Initialized = 1;
}
def __init__( self ):
super().__init__()
self.setupUi(self)
- self.setWindowTitle( u"焊接控制器调试工具 V0.6")
+ self.setWindowTitle( u"焊接控制器调试工具 V0.7")
self.trigger_rx_pkt.connect( self.on_rx_pkt )
self.trigger_ctrl_write.connect( self.on_ctrl_write_signal )
if item == "timer":
self.tx_cmd( cmd = 0x00B6, wait=False )
else:
- #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存
+ #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存, fix_target_flow_x10
method = factor = prev = comp = coeff = bypass_save = bypass = 0x7FFFFFFF
if item == "method" :
method = 0 if action == "tig" else 1 if action=="mig" else 2
if self.connected != 0 or self.ser_opened:
return
if cfg == 1 or cfg == 2:
- #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypass_save 4B, bypass 4B
+ #B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypass_save 4B, bypass 4B, fix_target_flow_x10 4B
cmd = 0x00B6
elif cfg == 3:
cmd = 0x00B8
if cfg == 1:
#B6 read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存
cmd = 0x00B7
- d = struct.pack( '>LLLlLLL',
+ try:
+ fix_target_flow_x10 = int( float( self.lineEdit_fix_target_flow.text())*10 )
+ if fix_target_flow_x10 <0 or fix_target_flow_x10 >500:
+ fix_target_flow_x10 = 0x7FFFFFFF
+ except:
+ fix_target_flow_x10 = 0x7FFFFFFF
+ d = struct.pack( '>LLLlLLLL',
#int(self.lineEdit_cfg_method.text()),
self.cb_cfg_method.currentIndex(),
int(self.lineEdit_cfg_factor.text()),
0x7FFFFFFF, #填无效值 comp
0x7FFFFFFF, #填无效值 coeff 修正系数
1 if self.cb_path_save.isChecked() else 0,
- 0x7FFFFFFF #填无效值 bypass
- )
+ 0x7FFFFFFF, #填无效值 bypass
+ fix_target_flow_x10
+ )
+ print( "----------write fix target flow:", fix_target_flow_x10 )
print( "write cfg cmd:%04X"%cmd, d.hex())
elif cfg == 2:
cmd = 0x00B7
break
self.cb_path_save.setChecked( bypass_save == 1 )
+ if len(data) >= 32:
+ fix_target_flow_x10 = struct.unpack( '>L', data[28:32] )[0]
+ self.lineEdit_fix_target_flow.setText( "%0.1f"%(fix_target_flow_x10/10) )
+ else:
+ self.lineEdit_fix_target_flow.setText( "" )
+
elif cmd == 0x00B8 and len(data)>=128+16: #参数读取
print( "B8 resp:", data.hex() )
#SSID 128B,passwd 16B
<rect>
<x>0</x>
<y>0</y>
- <width>1333</width>
- <height>845</height>
+ <width>1352</width>
+ <height>862</height>
</rect>
</property>
<property name="windowTitle">
</rect>
</property>
<property name="currentIndex">
- <number>3</number>
+ <number>5</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<property name="geometry">
<rect>
<x>20</x>
- <y>30</y>
+ <y>10</y>
<width>421</width>
- <height>171</height>
+ <height>201</height>
</rect>
</property>
<property name="title">
<string>气路选择断电保存</string>
</property>
</widget>
+ <widget class="QLineEdit" name="lineEdit_fix_target_flow">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>160</y>
+ <width>41</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>99.9</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="readOnly">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_23">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>160</y>
+ <width>151</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>焊接目标流量锁定(0-50.0)</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_36">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>160</y>
+ <width>41</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>(L/min)</string>
+ </property>
+ </widget>
</widget>
<widget class="QGroupBox" name="groupBox_12">
<property name="geometry">
uint8_t bl; //0-4 5级
uint32_t offline_max_time; //0:离线不锁定; >0:允许离线时间 秒 //使用RTC获取时间
uint32_t offline_start_time; //0:未开始计时; >0:离线开始时间点 秒 //使用RTC获取时间
- uint8_t reserved[16];
+ uint32_t fix_flow_x10; //固定流量值单位0.1L, 大于0 小于50L,焊接时忽略焊接电流,固定按这个值供气。
+ uint8_t reserved[12];
uint8_t flag;
}dev_cfg_v2_t;
cfg->bl = 10;
cfg->flag = DEV_CFG_V2_FLAG;
cfg->offline_max_time = 0; //0为默认禁用(平台协议下发值-1禁用)
+ cfg->fix_flow_x10 = 0;
}
//检查参数
if( cfg->offline_max_time == 0xffffffff ){
cfg->offline_max_time = 0;
}
-
+ if( cfg->fix_flow_x10 > 500 ){
+ cfg->fix_flow_x10 = 0;
+ }
return 0;
}
case 0xB5: //焊接数据清0
break;
case 0xB6: //设备参数读取
- //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B bypass 4B
+ //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B bypass 4B,目标流量固定值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[16], g_dev.cfg.cal.flow_coeff_x1000 );
put_u32_big( &resp[20], g_dev.cfg.bypass_save );
put_u32_big( &resp[24], g_dev.cfg.bypass );
- tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 28 );
+ put_u32_big( &resp[28], g_dev.cfg2.fix_flow_x10 );
+ tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 32 );
break;
case 0xB7: //设备参数写入
- //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B, bypass 4B
+ //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B, bypass 4B, 目标流量固定值4B
{
uint32_t method = get_u32_big( &pkt->pdata[0] );
uint32_t factor = get_u32_big( &pkt->pdata[4] );
uint32_t coeff = get_u32_big( &pkt->pdata[16] );
uint32_t bypass_save = get_u32_big( &pkt->pdata[20] );
uint32_t bypass = get_u32_big( &pkt->pdata[24] );
+ uint32_t fix_flow_x10 = get_u32_big( &pkt->pdata[28] );
if( !g_dev.has_bypass ){
bypass = 0;
g_dev.cfg.bypass_save = bypass_save;
if( bypass == 1 || bypass == 0 )
g_dev.cfg.bypass = bypass;
-
dev_cfg_store( &g_dev.cfg );
ui_cfg_remote_update();
+
+ if( pkt->data_len >= 32 && fix_flow_x10 <= 500 ){
+ g_dev.cfg2.fix_flow_x10 = fix_flow_x10;
+ dev_cfg_v2_store( &g_dev.cfg2 );
+ }
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[16], g_dev.cfg.cal.flow_coeff_x1000 );
put_u32_big( &resp[20], g_dev.cfg.bypass_save );
put_u32_big( &resp[24], g_dev.cfg.bypass );
- tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 28 );
+ put_u32_big( &resp[28], g_dev.cfg2.fix_flow_x10 );
+ tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 32 );
break;
}
case 0xB8: //WIFI参数读取
"offLineTime":100
}
}
+//焊接时气体流量固定
+{
+ "action":"updateGasFlow",
+ "timeStamp":1716445485381,
+ "data":{
+ "mac":"123",
+ "gasFlow":1.1 // 气体流量 范围0-50, 0:焊接时气体流量按电流调节, 大于0: 焊接时气体流量固定到这个值
+ }
+}
//设备回应,原包返回
#endif
cJSON * gasPathType;
cJSON * solarTermFactor;
cJSON * offLineTime;
+ cJSON * item;
int32_t act = 0;
act = 4; //原包回发。
}
}
+ }else if( strcmp( action->valuestring, "updateGasFlow" )== 0 ){
+ data = cJSON_GetObjectItem( root, "data" );
+ if(data){
+ mac = cJSON_GetObjectItem( data, "mac" );
+ item = cJSON_GetObjectItem( data, "gasFlow" );
+ if( mac && item && strcasecmp( mac->valuestring, g_mac_str ) == 0 ){
+ if( item->valuedouble >= 0 && item->valuedouble <= 50 ){
+ debug_printf( "fix gasFlow: %d -->%d\n", g_dev.cfg2.fix_flow_x10, item->valuedouble );
+ g_dev.cfg2.fix_flow_x10 = (uint32_t)(item->valuedouble * 10);
+ dev_cfg_v2_store( &g_dev.cfg2 );
+ act = 4; //原包回发。
+ }
+ }
+ }
}else if( strcmp( action->valuestring, "unlockDevice" )== 0 ){
debug_printf( "unlockdevice %d->0\n", g_dev.cfg.remote_locked );
g_dev.cfg.remote_locked = 0;
g_dev.welding_time += 100; //0.1秒扫描一次
}
- if( calc_target_flow( &target_flowspeed )== 0 ){
+ if( g_dev.cfg2.fix_flow_x10 > 0 ){
+ //按参数设定值作为目标流量,不考虑焊接电流
+ g_dev.target_flowspeed = g_dev.cfg2.fix_flow_x10/10.0f;
+ }else if( calc_target_flow( &target_flowspeed )== 0 ){
//控制流量输出, 按焊接电流和节气因子计算目标流量
g_dev.target_flowspeed = target_flowspeed;
}