update 解决相关bug
This commit is contained in:
@@ -39,6 +39,16 @@
|
||||
#define HMI_PROTO_GUI_HELP (0x17)/*帮助界面 */
|
||||
#define HMI_PROTO_GUI_TIME (0x18)/*时间设置界面*/
|
||||
|
||||
/*界面ID*/
|
||||
#define GUI_MAIN (10)/*主界面*/
|
||||
#define GUI_CURR_ALARM (11)/*实时报警界面*/
|
||||
#define GUI_DETALL_MAIN (12)/*主界面_详细信息*/
|
||||
#define GUI_LOGIN (13)/*登陆界面*/
|
||||
#define GUI_HISTORY_ALARM (14)/*历史报警界面*/
|
||||
#define GUI_TCP_CONFIG (15)/*网络配置界面*/
|
||||
#define GUI_DEVICE_CONFIG (16)/*设备配置界面*/
|
||||
#define GUI_TIME (18)/*时间设置界面*/
|
||||
|
||||
#define HMI_PROTO_ASCII_RX_DELINITER (0xAA)/*接收分隔符*/
|
||||
|
||||
#define HMI_PROTO_ASCII_TX_DELINITER (0xFF)/*发送分隔符*/
|
||||
@@ -125,7 +135,7 @@ static void gui_tjc_hmi_read_password_from_w25q(void)
|
||||
/*将密码保存到W25Q32*/
|
||||
static void gui_tjc_hmi_save_password_to_w25q(void)
|
||||
{
|
||||
uint32_t erase_addr = W25Q32_PASSWORD_ADDR & ~(W25Q32_SECTOR_SIZE - 1);
|
||||
u32 erase_addr = W25Q32_PASSWORD_ADDR & ~(W25Q32_SECTOR_SIZE - 1);
|
||||
w25q32_sector_erase(erase_addr);
|
||||
/*将4字节密码写入W25Q32*/
|
||||
w25q32.write(W25Q32_PASSWORD_ADDR, p_tjc_hmi->password, 4);
|
||||
@@ -144,7 +154,7 @@ static void gui_tjc_hmi_save_device_info_to_w25q(void)
|
||||
}
|
||||
|
||||
/* 添加Flash擦除操作 - 必须擦除后才能写入 */
|
||||
uint32_t erase_addr = W25Q32_DEVICE_INFO_ADDR;
|
||||
u32 erase_addr = W25Q32_DEVICE_INFO_ADDR;
|
||||
|
||||
/* 确保地址是4K对齐(W25Q32_SECTOR_SIZE = 4096) */
|
||||
erase_addr &= ~(W25Q32_SECTOR_SIZE - 1);
|
||||
@@ -158,6 +168,24 @@ static void gui_tjc_hmi_save_device_info_to_w25q(void)
|
||||
DEVICE_INFO_STORAGE_SIZE);
|
||||
}
|
||||
|
||||
/* 将当前W5500的网络配置保存到W25Q32 */
|
||||
static void gui_tjc_hmi_save_network_config_to_w25q(void)
|
||||
{
|
||||
network_config_t config;
|
||||
memcpy(config.ip, W5500.IP_Addr, 4);
|
||||
memcpy(config.mask, W5500.Sub_Mask, 4);
|
||||
memcpy(config.gateway, W5500.Gateway_IP, 4);
|
||||
config.port = (W5500.W5500_Class[0].ConfigData.Port[0] << 8) |
|
||||
W5500.W5500_Class[0].ConfigData.Port[1];
|
||||
|
||||
/* 擦除整个扇区(4K对齐) */
|
||||
u32 erase_addr = W25Q32_NETWORK_CONFIG_ADDR & ~(W25Q32_SECTOR_SIZE - 1);
|
||||
w25q32_sector_erase(erase_addr);
|
||||
|
||||
/* 写入配置数据 */
|
||||
w25q32.write(W25Q32_NETWORK_CONFIG_ADDR, (uint8_t*)&config, sizeof(config));
|
||||
}
|
||||
|
||||
/*解析网络函数*/
|
||||
static void parse_ip_string(u8 *str, u8 len, u8 *ip)
|
||||
{
|
||||
@@ -182,7 +210,7 @@ buffer
|
||||
format:格式化输入
|
||||
...:不定长
|
||||
*/
|
||||
static u16 gui_tjc_hmi_tx_text_display(u16 x,u16 y,char *buffer,const char *format,...)
|
||||
static u16 gui_tjc_hmi_tx_text_display(u16 z,u16 x,u16 y,char *buffer,const char *format,...)
|
||||
{
|
||||
u16 i,len;
|
||||
s16 state;
|
||||
@@ -202,7 +230,7 @@ static u16 gui_tjc_hmi_tx_text_display(u16 x,u16 y,char *buffer,const char *form
|
||||
}
|
||||
|
||||
/*拼接字符串*/
|
||||
sprintf(buffer,"t%d_%d.txt=\"%s\"",x,y,gui_tjc_hmi_text_buffer);
|
||||
sprintf(buffer,"t%d_%d_%d.txt=\"%s\"",z,x,y,gui_tjc_hmi_text_buffer);
|
||||
len = strlen(buffer);
|
||||
for(i=0;i<HMI_PROTO_ASCII_TX_DELINITER_NUM;i++)
|
||||
{
|
||||
@@ -240,10 +268,10 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
DS1302.Time.Hour,
|
||||
DS1302.Time.Minute,
|
||||
DS1302.Time.Second);
|
||||
len += gui_tjc_hmi_tx_text_display(0,0,(char *)&hmi_tx_buffer[len],"%s",time);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,0,0,(char *)&hmi_tx_buffer[len],"%s",time);
|
||||
|
||||
/*IP地址*/
|
||||
len += gui_tjc_hmi_tx_text_display(0,1,(char *)&hmi_tx_buffer[len],
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,0,1,(char *)&hmi_tx_buffer[len],
|
||||
"%d.%d.%d.%d",
|
||||
W5500.IP_Addr[0],
|
||||
W5500.IP_Addr[1],
|
||||
@@ -272,7 +300,7 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
for (y = 0; y < 5; y++)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(j+1, y+1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,j+1, y+1, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -286,36 +314,36 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
x = j;
|
||||
/*名称*/
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.region_data[index].name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.region_data[index].name);
|
||||
/*区域内设备总数量*/
|
||||
y = 1;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].sub_device_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].sub_device_num);
|
||||
/*漏液数量*/
|
||||
y = 2;
|
||||
if(leakage.region_data[index].leakage_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].leakage_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].leakage_num);
|
||||
}
|
||||
/*断带*/
|
||||
y = 3;
|
||||
if(leakage.region_data[index].open_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].open_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].open_num);
|
||||
}
|
||||
/*通讯*/
|
||||
y = 4;
|
||||
if(leakage.region_data[index].time_out_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].time_out_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].time_out_num);
|
||||
}
|
||||
}
|
||||
// 清除多余列的所有行(设置为空字符串)
|
||||
@@ -323,7 +351,7 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
for(y = 0; y < 5; y++) // 共有5行数据
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(j+1, y+1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,j+1, y+1, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,36 +363,36 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
x = j;
|
||||
/*名称*/
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.region_data[index].name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.region_data[index].name);
|
||||
/*区域内设备总数量*/
|
||||
y = 1;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].sub_device_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].sub_device_num);
|
||||
/*漏液数量*/
|
||||
y = 2;
|
||||
if(leakage.region_data[index].leakage_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].leakage_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].leakage_num);
|
||||
}
|
||||
/*断带*/
|
||||
y = 3;
|
||||
if(leakage.region_data[index].open_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].open_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].open_num);
|
||||
}
|
||||
/*通讯*/
|
||||
y = 4;
|
||||
if(leakage.region_data[index].time_out_num == 0)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s","Normal");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].time_out_num);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_MAIN,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.region_data[index].time_out_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,7 +473,7 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
continue ;
|
||||
}
|
||||
|
||||
if(UNBLOCKED != leakage.sub_device_data[i].flash_data.shield)
|
||||
if(UNBLOCKED != leakage.sub_device_data[i].shield)
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
@@ -492,15 +520,15 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
|
||||
/*区域名称*/
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.region_name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.region_name);
|
||||
|
||||
/*设备ID*/
|
||||
y = 1;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.sub_device_data[device_index].flash_data.modbus_id);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.sub_device_data[device_index].flash_data.modbus_id);
|
||||
|
||||
/*设备名称*/
|
||||
y = 2;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.device_name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.device_name);
|
||||
|
||||
/*通讯状态*/
|
||||
y =3;
|
||||
@@ -515,10 +543,10 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
if(comm_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"异常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"异常");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
/*通道状态*/
|
||||
@@ -530,28 +558,28 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
y = 4 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"漏液");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"漏液");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
y =5 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"断带");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"断带");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
y = 6 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",ch_distance);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",ch_distance);
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,15 +595,15 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
|
||||
/*区域名称*/
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.region_name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.region_name);
|
||||
|
||||
/*设备ID*/
|
||||
y = 1;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.sub_device_data[device_index].flash_data.modbus_id);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",leakage.sub_device_data[device_index].flash_data.modbus_id);
|
||||
|
||||
/*设备名称*/
|
||||
y = 2;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.device_name);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[device_index].flash_data.device_name);
|
||||
|
||||
/*通讯状态*/
|
||||
y =3;
|
||||
@@ -590,10 +618,10 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
if(comm_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"异常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"异常");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
/*通道状态*/
|
||||
@@ -605,28 +633,28 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
y = 4 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"漏液");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"漏液");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
y =5 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"断带");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"断带");
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
y = 6 + (ch * 3);
|
||||
if(ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",ch_distance);
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"%d",ch_distance);
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,15 +662,15 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
for (; j < REAL_ALARM_PAGE_NUM; j++)
|
||||
{
|
||||
x = j;
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 1, (char *)&hmi_tx_buffer[len], ""); // 区域名
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 2, (char *)&hmi_tx_buffer[len], ""); // 设备ID
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 3, (char *)&hmi_tx_buffer[len], ""); // 设备名称
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 4, (char *)&hmi_tx_buffer[len], ""); // 通讯状态
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 1, (char *)&hmi_tx_buffer[len], ""); // 区域名
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 2, (char *)&hmi_tx_buffer[len], ""); // 设备ID
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 3, (char *)&hmi_tx_buffer[len], ""); // 设备名称
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 4, (char *)&hmi_tx_buffer[len], ""); // 通讯状态
|
||||
for (ch = 0; ch < APP_LEAKAGE_SUB_DEVICE_CH_NUM; ch++)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 5 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 6 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x + 1, 7 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 5 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 6 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_CURR_ALARM,x + 1, 7 + (ch * 3), (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
}
|
||||
}break;
|
||||
@@ -757,14 +785,14 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
|
||||
/* 设备ID: t(x+1)_1 */
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
leakage.sub_device_data[sub_device_index].flash_data.modbus_id);
|
||||
|
||||
/* 设备名称: t(x+1)_2 */
|
||||
y = 1;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
leakage.sub_device_data[sub_device_index].flash_data.device_name);
|
||||
@@ -781,23 +809,23 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(leakage.sub_device_data[sub_device_index].flash_data.shield == UNBLOCKED)
|
||||
if(leakage.sub_device_data[sub_device_index].shield == UNBLOCKED)
|
||||
{
|
||||
if (comm_state)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"超时");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
@@ -811,23 +839,23 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
|
||||
/* 漏液状态 */
|
||||
y = 3 + (ch * 3);
|
||||
if(leakage.sub_device_data[sub_device_index].flash_data.shield == UNBLOCKED)
|
||||
if(leakage.sub_device_data[sub_device_index].shield == UNBLOCKED)
|
||||
{
|
||||
if (ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"漏液");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
@@ -835,23 +863,23 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
|
||||
/* 断带状态 */
|
||||
y = 4 + (ch * 3);
|
||||
if(leakage.sub_device_data[sub_device_index].flash_data.shield == UNBLOCKED)
|
||||
if(leakage.sub_device_data[sub_device_index].shield == UNBLOCKED)
|
||||
{
|
||||
if (ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"断带");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
@@ -859,24 +887,24 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
|
||||
/* 漏液位置 */
|
||||
y = 5 + (ch * 3);
|
||||
if(leakage.sub_device_data[sub_device_index].flash_data.shield == UNBLOCKED)
|
||||
if(leakage.sub_device_data[sub_device_index].shield == UNBLOCKED)
|
||||
{
|
||||
if (ch_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
ch_distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"0");
|
||||
}
|
||||
}else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"0");
|
||||
}
|
||||
@@ -884,13 +912,13 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
}
|
||||
/* 屏蔽状态显示: t(x+1)_16 */
|
||||
y = 15; // 第16列对应y=15
|
||||
if (leakage.sub_device_data[sub_device_index].flash_data.shield == BLOCKED)
|
||||
if (leakage.sub_device_data[sub_device_index].shield == BLOCKED)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1, (char *)&hmi_tx_buffer[len], "禁用中");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1, (char *)&hmi_tx_buffer[len], "禁用中");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1, (char *)&hmi_tx_buffer[len], "启用中");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, y+1, (char *)&hmi_tx_buffer[len], "启用中");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,16 +926,16 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
for (; i < DETAIL_MAIN_NUM; i++)
|
||||
{
|
||||
x = i;
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
for (ch = 0; ch < APP_LEAKAGE_SUB_DEVICE_CH_NUM; ch++)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 4 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 5 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 6 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 4 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 5 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 6 + (ch*3), (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, 16, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DETALL_MAIN,x+1, 16, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1005,9 +1033,9 @@ static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
if (leakage.sub_device_data[i].flash_data.state == ENABLE &&
|
||||
leakage.sub_device_data[i].flash_data.modbus_id == device_id) {
|
||||
if (operation == 0x01) {
|
||||
leakage.sub_device_data[i].flash_data.shield = BLOCKED; /* 屏蔽 */
|
||||
leakage.sub_device_data[i].shield = BLOCKED; /* 屏蔽 */
|
||||
} else if (operation == 0x02) {
|
||||
leakage.sub_device_data[i].flash_data.shield = UNBLOCKED; /* 恢复 */
|
||||
leakage.sub_device_data[i].shield = UNBLOCKED; /* 恢复 */
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -1043,7 +1071,7 @@ static void gui_tjc_hmi_login_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
gui_tjc_hmi_read_password_from_w25q();
|
||||
memset(hmi_tx_buffer, 0, sizeof(hmi_tx_buffer));
|
||||
/* 将密码数值以连续数字形式发送到控件 t22_1 */
|
||||
len = gui_tjc_hmi_tx_text_display(22, 1, (char *)hmi_tx_buffer,
|
||||
len = gui_tjc_hmi_tx_text_display(GUI_LOGIN,22, 1, (char *)hmi_tx_buffer,
|
||||
"%d%d%d%d",
|
||||
p_tjc_hmi->password[0],
|
||||
p_tjc_hmi->password[1],
|
||||
@@ -1114,6 +1142,8 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
page_num++;
|
||||
}
|
||||
|
||||
memset(hmi_tx_buffer, 0, sizeof(hmi_tx_buffer));
|
||||
|
||||
if(HMI_PROTO_CMD_GET == cmd) /* 获取数据 */
|
||||
{
|
||||
switch(opa)
|
||||
@@ -1153,22 +1183,22 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
if(history.read_history(record_index, &history_record))
|
||||
{
|
||||
/* 区域名: t(i+1)_1 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
history_record.region_name);
|
||||
|
||||
/* 设备ID: t(i+1)_2 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 2,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
history_record.device_id);
|
||||
|
||||
/*通道信息:t(i+1)_3*/
|
||||
len += gui_tjc_hmi_tx_text_display(i+1,3,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1,3,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
history_record.channel);
|
||||
history_record.channel+1);
|
||||
|
||||
/* 报警类型: t(i+1)_4 */
|
||||
alarm_type_str[0] = '\0';
|
||||
@@ -1179,13 +1209,13 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
else if(history_record.alarm_type == APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
strcat(alarm_type_str, "通讯超时");
|
||||
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 4,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
alarm_type_str);
|
||||
|
||||
/* 设备名称: t(i+1)_5 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 5,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 5,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
history_record.device_name);
|
||||
@@ -1193,14 +1223,14 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
/* 漏液距离: t(i+1)_6 (如果是漏液报警才显示) */
|
||||
if(history_record.alarm_type == APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 6,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 6,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
history_record.leak_distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 6,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 6,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"0");
|
||||
}
|
||||
@@ -1214,7 +1244,7 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
history_record.start_time[4],
|
||||
history_record.start_time[5],
|
||||
history_record.start_time[6]);
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 7,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 7,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
time_str);
|
||||
@@ -1222,24 +1252,26 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
else
|
||||
{
|
||||
/* 读取失败,显示空 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 5, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 6, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 5, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 6, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 7, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
}
|
||||
|
||||
/* 如果本页不足15条记录,清空剩余行 */
|
||||
for(; i < HISTORY_ALARM_PER_PAGE; i++)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 5, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 6, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 5, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 6, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_HISTORY_ALARM,i+1, 7, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
@@ -1330,33 +1362,39 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
if(p_data[0] == 0x01)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(1,1,(char *)&hmi_tx_buffer[len],
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,1,(char *)&hmi_tx_buffer[len],
|
||||
"%d.%d.%d.%d",
|
||||
W5500.IP_Addr[0],
|
||||
W5500.IP_Addr[1],
|
||||
W5500.IP_Addr[2],
|
||||
W5500.IP_Addr[3]);
|
||||
|
||||
len += gui_tjc_hmi_tx_text_display(1,2,(char *)&hmi_tx_buffer[len],
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,2,(char *)&hmi_tx_buffer[len],
|
||||
"%d.%d.%d.%d",
|
||||
W5500.Sub_Mask[0],
|
||||
W5500.Sub_Mask[1],
|
||||
W5500.Sub_Mask[2],
|
||||
W5500.Sub_Mask[3]);
|
||||
|
||||
len += gui_tjc_hmi_tx_text_display(1,3,(char *)&hmi_tx_buffer[len],
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,3,(char *)&hmi_tx_buffer[len],
|
||||
"%d.%d.%d.%d",
|
||||
W5500.Gateway_IP[0],
|
||||
W5500.Gateway_IP[1],
|
||||
W5500.Gateway_IP[2],
|
||||
W5500.Gateway_IP[3]);
|
||||
len += gui_tjc_hmi_tx_text_display(1,4,(char *)&hmi_tx_buffer[len],"%s","5000");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,4,(char *)&hmi_tx_buffer[len],"%d",(W5500.W5500_Class[0].ConfigData.Port[0] << 8) | W5500.W5500_Class[0].ConfigData.Port[1]);
|
||||
}else if(p_data[0] == 0x00)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(1,1,(char *)&hmi_tx_buffer[len],"%s","192.168.100.100");
|
||||
len += gui_tjc_hmi_tx_text_display(1,2,(char *)&hmi_tx_buffer[len],"%s","255.255.255.0");
|
||||
len += gui_tjc_hmi_tx_text_display(1,3,(char *)&hmi_tx_buffer[len],"%s","192.168.50.1");
|
||||
len += gui_tjc_hmi_tx_text_display(1,4,(char *)&hmi_tx_buffer[len],"%s","5000");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,1,(char *)&hmi_tx_buffer[len],"%s","192.168.100.100");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,2,(char *)&hmi_tx_buffer[len],"%s","255.255.255.0");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,3,(char *)&hmi_tx_buffer[len],"%s","192.168.50.1");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_TCP_CONFIG,1,4,(char *)&hmi_tx_buffer[len],"%s","5000");
|
||||
sscanf("192.168.100.100","%hhu.%hhu.%hhu.%hhu",&W5500.IP_Addr[0],&W5500.IP_Addr[1],&W5500.IP_Addr[2],&W5500.IP_Addr[3]);
|
||||
sscanf("255.255.255.0","%hhu.%hhu.%hhu.%hhu",&W5500.Sub_Mask[0],&W5500.Sub_Mask[1],&W5500.Sub_Mask[2],&W5500.Sub_Mask[3]);
|
||||
sscanf("192.168.50.1","%hhu.%hhu.%hhu.%hhu",&W5500.Gateway_IP[0],&W5500.Gateway_IP[1],&W5500.Gateway_IP[2],&W5500.Gateway_IP[3]);
|
||||
W5500.W5500_Class[0].ConfigData.Port[0] = (5000 >> 8) & 0xFF;
|
||||
W5500.W5500_Class[0].ConfigData.Port[1] = 5000 & 0xFF;
|
||||
W5500.Init();
|
||||
}
|
||||
}break;
|
||||
case 0x02:/*无*/
|
||||
@@ -1376,8 +1414,9 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
u8 field_count = 0;
|
||||
u8 *current_pos = p_data;
|
||||
u8 ip_str[16], mask_str[16], gw_str[16], dns_str[16];
|
||||
u8 ip_len, mask_len, gw_len, dns_len;
|
||||
u8 ip_str[16], mask_str[16], gw_str[16], port_str[16];
|
||||
u8 ip_len, mask_len, gw_len, port_len;
|
||||
u16 port_val;
|
||||
|
||||
/* 解析IP地址 */
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -1415,12 +1454,12 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
/* 解析DNS服务器 */
|
||||
for (i = 0; i < 16; i++) {
|
||||
/* 解析端口号 */
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (current_pos[i] == HMI_PROTO_ASCII_RX_DELINITER) {
|
||||
dns_len = i;
|
||||
memcpy(dns_str, current_pos, dns_len);
|
||||
dns_str[dns_len] = '\0';
|
||||
port_len = i;
|
||||
memcpy(port_str, current_pos, port_len);
|
||||
port_str[port_len] = '\0';
|
||||
current_pos += (i + 1);
|
||||
field_count++;
|
||||
break;
|
||||
@@ -1431,6 +1470,16 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
parse_ip_string(ip_str, ip_len, W5500.IP_Addr);
|
||||
parse_ip_string(mask_str, mask_len, W5500.Sub_Mask);
|
||||
parse_ip_string(gw_str, gw_len, W5500.Gateway_IP);
|
||||
/* 端口号转换为整数 */
|
||||
port_val = atoi((char*)port_str);
|
||||
W5500.W5500_Class[0].ConfigData.Port[0] = (port_val >> 8) & 0xFF;
|
||||
W5500.W5500_Class[0].ConfigData.Port[1] = port_val & 0xFF;
|
||||
|
||||
/* 保存到Flash */
|
||||
gui_tjc_hmi_save_network_config_to_w25q();
|
||||
|
||||
/* 重启W5500使新配置生效 */
|
||||
W5500.Init();
|
||||
}
|
||||
|
||||
}break;
|
||||
@@ -1473,7 +1522,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
enabled_device_count = 0;
|
||||
for(i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
if(leakage.sub_device_data[i].flash_data.state == ENABLE)
|
||||
if(leakage.sub_device_data[i].flash_data.state == ENABLE && leakage.sub_device_data[i].flash_data.modbus_id > 0)
|
||||
{
|
||||
enabled_device_count++;
|
||||
}
|
||||
@@ -1497,10 +1546,10 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
for(i = 0; i < DEVICES_PER_PAGE; i++)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 1, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 2, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 3, (char *)&hmi_tx_buffer[len], "");
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 4, (char *)&hmi_tx_buffer[len], "");
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer, len);
|
||||
@@ -1538,7 +1587,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
device_index = page_device_indices[i];
|
||||
|
||||
/*区域名: t(i+1)_1 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
leakage.sub_device_data[device_index].flash_data.region_name);
|
||||
@@ -1547,26 +1596,26 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
u8 com_port = leakage.sub_device_data[device_index].flash_data.com;
|
||||
if(com_port < 4) /*确保端口号在有效范围内*/
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 2,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
hmi_proto_string_com[com_port]);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 2,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"未知");
|
||||
}
|
||||
|
||||
/*设备ID: t(i+1)_3 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 3,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 3,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%d",
|
||||
leakage.sub_device_data[device_index].flash_data.modbus_id);
|
||||
|
||||
/*设备名称: t(i+1)_4 */
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 4,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
leakage.sub_device_data[device_index].flash_data.device_name);
|
||||
@@ -1578,22 +1627,22 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
for(i = page_device_count; i < DEVICES_PER_PAGE; i++)
|
||||
{
|
||||
/*清空区域名*/
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 1,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"");
|
||||
|
||||
/*清空端口号*/
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 2,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 2,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"");
|
||||
|
||||
/*清空设备ID*/
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 3,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 3,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"");
|
||||
|
||||
/*清空设备名称*/
|
||||
len += gui_tjc_hmi_tx_text_display(i+1, 4,
|
||||
len += gui_tjc_hmi_tx_text_display(GUI_DEVICE_CONFIG,i+1, 4,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"");
|
||||
}
|
||||
@@ -1814,6 +1863,11 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
id_str[i] = '\0';
|
||||
new_device.modbus_id = atoi(id_str);
|
||||
|
||||
if(new_device.modbus_id < 1 && new_device.modbus_id > 255)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
current_pos += (i + 1);
|
||||
field_count++;
|
||||
break;
|
||||
@@ -1841,7 +1895,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
new_device.state = ENABLE;
|
||||
new_device.baudrate = app_com.com[new_device.com].flash_data.baudrate;
|
||||
new_device.shield = UNBLOCKED;
|
||||
leakage.sub_device_data[x].shield = UNBLOCKED;
|
||||
leakage.sub_device_data[x].flash_data = new_device;
|
||||
gui_tjc_hmi_save_device_info_to_w25q();
|
||||
gui_tjc_hmi_class_update();
|
||||
@@ -1859,7 +1913,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
/*波特率设置*/
|
||||
new_device.baudrate = app_com.com[new_device.com].flash_data.baudrate;
|
||||
|
||||
new_device.shield = UNBLOCKED;
|
||||
leakage.sub_device_data[empty_slot_index].shield = UNBLOCKED;
|
||||
|
||||
/*添加到app_leakage的设备列表中*/
|
||||
leakage.sub_device_data[empty_slot_index].flash_data = new_device;
|
||||
@@ -1892,7 +1946,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
case 0x02:/*删除设备,将设备信息从w25q中删除*/
|
||||
{
|
||||
|
||||
u8 page_device_indices[8] = {0}; /*存储当前页8个设备在app_leakage中的索引*/
|
||||
u8 page_device_indices[8] = {0}; /*存储当前页8个设备在app_leakage中的索引*/
|
||||
u8 page_device_count = 0; /*当前页实际启用的设备数量*/
|
||||
u8 current_enabled_index = 0; /*当前是第几个启用的设备*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user