update
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "bsp_Led.h"
|
||||
#include "bsp_74HC4067.h"
|
||||
#include "bsp_Flash.h"
|
||||
#include "bsp_w25q.h"
|
||||
|
||||
#include "proto_modbus_master_tdlas.h"
|
||||
#include "proto_modbus_slave_ex.h"
|
||||
|
||||
@@ -192,4 +192,4 @@ u16 app_timer_check_run_time(u16 time_start, u16 time_now, u16 time_out)
|
||||
void delay_ms(u16 delay)
|
||||
{
|
||||
HAL_Delay(delay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,4 @@ void delay_ms(u16 delay);
|
||||
/* 声明外部变量 */
|
||||
extern app_timer_t app_timer;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
#define BSP_LED_ON GPIO_PIN_RESET
|
||||
#define BSP_LED_OFF GPIO_PIN_SET
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_TX_SW_GPIO[4] = {TX_S0_GPIO_Port,TX_S1_GPIO_Port,TX_S2_GPIO_Port,TX_S3_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_TX_SW_Pin[4] = {TX_S0_Pin, TX_S1_Pin, TX_S2_Pin, TX_S3_Pin};
|
||||
//static GPIO_TypeDef* bsp_74HC4067_TX_SW_GPIO[4] = {TX_S0_GPIO_Port,TX_S1_GPIO_Port,TX_S2_GPIO_Port,TX_S3_GPIO_Port};
|
||||
//static uint16_t bsp_74HC4067_TX_SW_Pin[4] = {TX_S0_Pin, TX_S1_Pin, TX_S2_Pin, TX_S3_Pin};
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_RX_SW_GPIO[4] = {RX_S0_GPIO_Port,RX_S1_GPIO_Port,RX_S2_GPIO_Port,RX_S3_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_RX_SW_Pin[4] = {RX_S0_Pin, RX_S1_Pin, RX_S2_Pin, RX_S3_Pin};
|
||||
//static GPIO_TypeDef* bsp_74HC4067_RX_SW_GPIO[4] = {RX_S0_GPIO_Port,RX_S1_GPIO_Port,RX_S2_GPIO_Port,RX_S3_GPIO_Port};
|
||||
//static uint16_t bsp_74HC4067_RX_SW_Pin[4] = {RX_S0_Pin, RX_S1_Pin, RX_S2_Pin, RX_S3_Pin};
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_LED_CH_GPIO[BSP_74HC4067_CH_MAX] = {LED_CH1_GPIO_Port, LED_CH2_GPIO_Port, LED_CH3_GPIO_Port, LED_CH4_GPIO_Port, LED_CH5_GPIO_Port, LED_CH6_GPIO_Port, LED_CH7_GPIO_Port, LED_CH8_GPIO_Port, LED_CH9_GPIO_Port, LED_CH10_GPIO_Port, LED_CH11_GPIO_Port, LED_CH12_GPIO_Port, LED_CH13_GPIO_Port, LED_CH14_GPIO_Port, LED_CH15_GPIO_Port, LED_CH16_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_LED_CH_Pin[BSP_74HC4067_CH_MAX] = {LED_CH1_Pin, LED_CH2_Pin, LED_CH3_Pin, LED_CH4_Pin, LED_CH5_Pin, LED_CH6_Pin, LED_CH7_Pin, LED_CH8_Pin, LED_CH9_Pin, LED_CH10_Pin, LED_CH11_Pin, LED_CH12_Pin, LED_CH13_Pin, LED_CH14_Pin, LED_CH15_Pin, LED_CH16_Pin};
|
||||
//static GPIO_TypeDef* bsp_74HC4067_LED_CH_GPIO[BSP_74HC4067_CH_MAX] = {LED_CH1_GPIO_Port, LED_CH2_GPIO_Port, LED_CH3_GPIO_Port, LED_CH4_GPIO_Port, LED_CH5_GPIO_Port, LED_CH6_GPIO_Port, LED_CH7_GPIO_Port, LED_CH8_GPIO_Port, LED_CH9_GPIO_Port, LED_CH10_GPIO_Port, LED_CH11_GPIO_Port, LED_CH12_GPIO_Port, LED_CH13_GPIO_Port, LED_CH14_GPIO_Port, LED_CH15_GPIO_Port, LED_CH16_GPIO_Port};
|
||||
//static uint16_t bsp_74HC4067_LED_CH_Pin[BSP_74HC4067_CH_MAX] = {LED_CH1_Pin, LED_CH2_Pin, LED_CH3_Pin, LED_CH4_Pin, LED_CH5_Pin, LED_CH6_Pin, LED_CH7_Pin, LED_CH8_Pin, LED_CH9_Pin, LED_CH10_Pin, LED_CH11_Pin, LED_CH12_Pin, LED_CH13_Pin, LED_CH14_Pin, LED_CH15_Pin, LED_CH16_Pin};
|
||||
|
||||
/*通道转换,硬件实际连接的通道与芯片定义通道不一致*/
|
||||
static u8 bsp_74HC4067_TX_CH_Conv[BSP_74HC4067_CH_MAX] = {13,14,15,12,11,10,9, 8, 7, 4, 3, 2, 1, 0, 6, 5};
|
||||
@@ -53,8 +53,8 @@ bsp_74HC4067_t UartCH_Config =
|
||||
static void bsp_74HC4067_Init(void)
|
||||
{
|
||||
bsp_74HC4067_CH = 0;
|
||||
TX_EN_ENABLE;
|
||||
RX_EN_ENABLE;
|
||||
// TX_EN_ENABLE;
|
||||
// RX_EN_ENABLE;
|
||||
bsp_74HC4067_Set_CH(0);
|
||||
}
|
||||
|
||||
@@ -76,19 +76,19 @@ static void bsp_74HC4067_Set_CH(u8 CH1)
|
||||
{
|
||||
if((TX_CH >> i) & 0x01)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_HIG);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_HIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_LOW);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_LOW);
|
||||
}
|
||||
if((RX_CH >> i) & 0x01)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_HIG);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_HIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_LOW);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_LOW);
|
||||
}
|
||||
}
|
||||
/*开启对应指示灯*/
|
||||
@@ -96,11 +96,11 @@ static void bsp_74HC4067_Set_CH(u8 CH1)
|
||||
{
|
||||
if(i == CH)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_ON);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_OFF);
|
||||
// HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_OFF);
|
||||
}
|
||||
}
|
||||
// HAL_Delay(20);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#include "bsp_Led.h"
|
||||
#include "app_timer.h"
|
||||
|
||||
#define LED1_ON HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
|
||||
#define LED1_OFF HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET)
|
||||
#define LED1_TOGGLE HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
|
||||
//#define LED1_ON HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
|
||||
//#define LED1_OFF HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET)
|
||||
//#define LED1_TOGGLE HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
|
||||
|
||||
#define LED2_ON HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET)
|
||||
#define LED2_OFF HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET)
|
||||
#define LED2_TOGGLE HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin)
|
||||
//#define LED2_ON HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET)
|
||||
//#define LED2_OFF HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET)
|
||||
//#define LED2_TOGGLE HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin)
|
||||
|
||||
#define LED3_ON HAL_GPIO_WritePin (LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET)
|
||||
#define LED3_OFF HAL_GPIO_WritePin (LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET)
|
||||
#define LED3_TOGGLE HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin)
|
||||
//#define LED3_ON HAL_GPIO_WritePin (LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET)
|
||||
//#define LED3_OFF HAL_GPIO_WritePin (LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET)
|
||||
//#define LED3_TOGGLE HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin)
|
||||
|
||||
|
||||
static void bsp_led_init(void);
|
||||
@@ -28,11 +28,11 @@ static void bsp_led_init(void)
|
||||
for(u8 i = 0;i < 20;i++)
|
||||
{
|
||||
delay_ms(50);
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
}
|
||||
}
|
||||
|
||||
static void bsp_led_task(void)
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
}
|
||||
|
||||
+480
-104
@@ -66,6 +66,7 @@ static char *hmi_proto_string_baudrate[] =
|
||||
};
|
||||
|
||||
|
||||
|
||||
static bsp_uart_t * p_rx_uart = NULL;
|
||||
|
||||
gui_tjc_hmi_t tjc_hmi =
|
||||
@@ -204,21 +205,9 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 0x02:
|
||||
{
|
||||
|
||||
}break;
|
||||
default:return;
|
||||
}
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
else if(HMI_PROTO_CMD_SET == cmd)/*设置*/
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x03:/*翻页*/
|
||||
{
|
||||
if(0x01 == p_data[0])
|
||||
if(0x01 == p_data[5])
|
||||
{
|
||||
if(page_num - 1 <= p_tjc_hmi->page.main_index)
|
||||
{
|
||||
@@ -247,25 +236,251 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
else if(HMI_PROTO_CMD_SET == cmd)/*设置*/
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:/*蜂鸣器开关*/
|
||||
{
|
||||
if(0x01 == p_data[0])
|
||||
{
|
||||
/*01打开蜂鸣器*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/*00关闭蜂鸣器*/
|
||||
}
|
||||
}
|
||||
default:return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
}
|
||||
|
||||
/*实时报警响应*/
|
||||
static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
u16 len = 0,i;
|
||||
/*每页显示的报警设备数量*/
|
||||
#define REAL_ALARM_PAGE_NUM (4)
|
||||
u16 len = 0,i,j,x,y,device_index,ch,index;
|
||||
u8 page_num,remain_alrm_device_num,display_count;
|
||||
u8 alarm_device_count;
|
||||
u8 alarm_device_index[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
|
||||
memset(hmi_tx_buffer,0,sizeof(hmi_tx_buffer));
|
||||
|
||||
/*计算报警设备数量*/
|
||||
alarm_device_count = 0;
|
||||
for(i = 0;i<APP_LEAKAGE_SUB_DEVICE_NUM;i++)
|
||||
{
|
||||
if(ENABLE != leakage.sub_device_data[i].flash_data.state)
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
for(ch=0;ch<APP_LEAKAGE_SUB_DEVICE_CH_NUM;ch++)
|
||||
{
|
||||
u16 ch_state = leakage.sub_device_data[i].ch_data[ch].state;
|
||||
if(ch_state & (APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT | APP_LEAKAGE_SUB_DEVICE_STATE_OPEN | APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE))
|
||||
{
|
||||
alarm_device_index[alarm_device_count] = i;
|
||||
alarm_device_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*计算页面数量*/
|
||||
page_num = alarm_device_count / REAL_ALARM_PAGE_NUM;
|
||||
remain_alrm_device_num = alarm_device_count % REAL_ALARM_PAGE_NUM;
|
||||
if(remain_alrm_device_num > 0)
|
||||
{
|
||||
page_num++;
|
||||
}
|
||||
|
||||
|
||||
if(HMI_PROTO_CMD_GET == cmd)/*获取数据*/
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*获取实时报警信息*/
|
||||
{
|
||||
|
||||
if(p_tjc_hmi->page.real_alarm_index == page_num - 1 && remain_alrm_device_num > 0)
|
||||
{
|
||||
for(j=0;j<remain_alrm_device_num;j++)
|
||||
{
|
||||
index = p_tjc_hmi->page.real_alarm_index * REAL_ALARM_PAGE_NUM + j;
|
||||
device_index = alarm_device_index[index];
|
||||
x = j;
|
||||
|
||||
/*区域名称*/
|
||||
y = 0;
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[index].flash_data.region_name);
|
||||
|
||||
/*设备ID*/
|
||||
y = 1;
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[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[index].flash_data.device_name);
|
||||
|
||||
/*通讯状态*/
|
||||
y =3;
|
||||
u8 comm_state = 0;
|
||||
for(ch=0;ch<APP_LEAKAGE_SUB_DEVICE_CH_NUM;ch++)
|
||||
{
|
||||
if(leakage.sub_device_data[device_index].ch_data[ch].state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
comm_state = APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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],"超时");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
/*通道状态*/
|
||||
for(ch=0;ch<APP_LEAKAGE_SUB_DEVICE_CH_NUM;ch++)
|
||||
{
|
||||
u16 ch_state = leakage.sub_device_data[device_index].ch_data[ch].state;
|
||||
u16 ch_distance = leakage.sub_device_data[device_index].ch_data[ch].distance;
|
||||
|
||||
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],"漏液");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(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],"断带");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(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);
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(j=0;j<REAL_ALARM_PAGE_NUM;j++)
|
||||
{
|
||||
index = p_tjc_hmi->page.real_alarm_index * REAL_ALARM_PAGE_NUM + j;
|
||||
device_index = alarm_device_index[index];
|
||||
|
||||
x = j;
|
||||
|
||||
/*区域名称*/
|
||||
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);
|
||||
|
||||
/*设备ID*/
|
||||
y = 1;
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"%s",leakage.sub_device_data[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[index].flash_data.device_name);
|
||||
|
||||
/*通讯状态*/
|
||||
y =3;
|
||||
u8 comm_state = 0;
|
||||
for(ch=0;ch<APP_LEAKAGE_SUB_DEVICE_CH_NUM;ch++)
|
||||
{
|
||||
if(leakage.sub_device_data[device_index].ch_data[ch].state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
comm_state = APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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],"超时");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"正常");
|
||||
}
|
||||
|
||||
/*通道状态*/
|
||||
for(ch=0;ch<APP_LEAKAGE_SUB_DEVICE_CH_NUM;ch++)
|
||||
{
|
||||
u16 ch_state = leakage.sub_device_data[device_index].ch_data[ch].state;
|
||||
u16 ch_distance = leakage.sub_device_data[device_index].ch_data[ch].distance;
|
||||
|
||||
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],"漏液");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(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],"断带");
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(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);
|
||||
}else
|
||||
{
|
||||
len = gui_tjc_hmi_tx_text_display(x+1,y+1,(char *)&hmi_tx_buffer[len],"0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x03:/*翻页*/
|
||||
{
|
||||
|
||||
}break;
|
||||
if(0x01 == p_data[0])
|
||||
{
|
||||
if(page_num - 1 <= p_tjc_hmi->page.real_alarm_index)
|
||||
{
|
||||
p_tjc_hmi->page.real_alarm_index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tjc_hmi->page.real_alarm_index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(0 == p_tjc_hmi->page.real_alarm_index)
|
||||
{
|
||||
p_tjc_hmi->page.real_alarm_index = page_num - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tjc_hmi->page.real_alarm_index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
@@ -290,43 +505,243 @@ static void gui_tjc_hmi_curr_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
}
|
||||
/*主界面详情*/
|
||||
static void gui_tjc_hmi_detail_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
static void gui_tjc_hmi_detail_main_send(u8 cmd, u8 opa, u8 *p_data)
|
||||
{
|
||||
u16 len = 0,i;
|
||||
#define DETAIL_MAIN_NUM (4) /* 每页显示4个设备 */
|
||||
|
||||
if(HMI_PROTO_CMD_GET == cmd)/*获取数据*/
|
||||
u16 len = 0, i, sub_device_index, ch, x, y, index;
|
||||
u8 page_num, remain_device_num, display_count;
|
||||
u8 region_idx; /* 区域索引 */
|
||||
app_leakage_region_data_class_t *region_data;
|
||||
|
||||
memset(hmi_tx_buffer, 0, sizeof(hmi_tx_buffer));
|
||||
|
||||
/* 计算详情页面数量:每页显示4个设备 */
|
||||
page_num = region_data->sub_device_num / DETAIL_MAIN_NUM;
|
||||
remain_device_num = region_data->sub_device_num % DETAIL_MAIN_NUM;
|
||||
if (remain_device_num > 0)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
{
|
||||
|
||||
}break;
|
||||
default:return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
page_num++;
|
||||
}
|
||||
else if(HMI_PROTO_CMD_SET == cmd)/*设置*/
|
||||
|
||||
if (HMI_PROTO_CMD_GET == cmd) /* 获取数据 */
|
||||
{
|
||||
switch(opa)
|
||||
switch (opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01: /* 获取设备详情信息 */
|
||||
{
|
||||
/* 从指令中获取区域索引 (p_data[0] = 相对区域索引,从1开始,对应当前主界面的1-4) */
|
||||
u8 relative_region_idx = p_data[0];
|
||||
|
||||
if (relative_region_idx < 1 || relative_region_idx > 4)
|
||||
{
|
||||
/* 相对区域索引无效,默认显示第一个 */
|
||||
relative_region_idx = 1;
|
||||
}
|
||||
|
||||
/* 计算全局区域索引: 全局索引 = 主界面页码 * 4 + 相对索引 - 1 */
|
||||
region_idx = p_tjc_hmi->page.main_index * 4 + (relative_region_idx - 1);
|
||||
|
||||
/* 检查区域索引是否有效 */
|
||||
if (region_idx >= leakage.region_num)
|
||||
{
|
||||
/* 区域索引越界,尝试显示第一个区域 */
|
||||
region_idx = 0;
|
||||
}
|
||||
|
||||
/* 判断是否切换了区域 */
|
||||
if (region_idx != p_tjc_hmi->page.deliniter_main_index)
|
||||
{
|
||||
p_tjc_hmi->page.detail_main_index = 0;
|
||||
}
|
||||
|
||||
/* 保存当前区域索引和主界面页码,翻页时使用 */
|
||||
p_tjc_hmi->page.deliniter_main_index = region_idx;
|
||||
|
||||
/* 获取区域数据 */
|
||||
region_data = &leakage.region_data[region_idx];
|
||||
|
||||
/* 获取当前详情页面的设备数据 */
|
||||
u8 start_index = p_tjc_hmi->page.detail_main_index * DETAIL_MAIN_NUM;
|
||||
|
||||
if (p_tjc_hmi->page.detail_main_index == page_num - 1 && remain_device_num > 0)
|
||||
{
|
||||
display_count = remain_device_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
display_count = DETAIL_MAIN_NUM;
|
||||
}
|
||||
|
||||
for (i = 0; i < display_count; i++)
|
||||
{
|
||||
index = start_index + i;
|
||||
|
||||
if (index >= region_data->sub_device_num)
|
||||
break;
|
||||
|
||||
/* 获取设备的全局索引 */
|
||||
sub_device_index = region_data->sub_device_index[index];
|
||||
x = i; /* 0-3表示当前详情页面的4个设备位置 */
|
||||
|
||||
/* 设备ID: t(x+1)_1 */
|
||||
y = 0;
|
||||
len += gui_tjc_hmi_tx_text_display(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,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"%s",
|
||||
leakage.sub_device_data[sub_device_index].flash_data.device_name);
|
||||
|
||||
/* 通讯状态: t(x+1)_3 */
|
||||
y = 2;
|
||||
u8 comm_state = 0;
|
||||
for (ch = 0; ch < APP_LEAKAGE_SUB_DEVICE_CH_NUM; ch++)
|
||||
{
|
||||
if (leakage.sub_device_data[sub_device_index].ch_data[ch].state &
|
||||
APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
comm_state = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (comm_state)
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(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],
|
||||
"正常");
|
||||
}
|
||||
|
||||
/* 通道1-4状态 */
|
||||
for (ch = 0; ch < APP_LEAKAGE_SUB_DEVICE_CH_NUM; ch++)
|
||||
{
|
||||
u16 ch_state = leakage.sub_device_data[sub_device_index].ch_data[ch].state;
|
||||
u16 ch_distance = leakage.sub_device_data[sub_device_index].ch_data[ch].distance;
|
||||
|
||||
/* 漏液状态 */
|
||||
y = 3 + (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],
|
||||
"漏液");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
|
||||
/* 断带状态 */
|
||||
y = 4 + (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],
|
||||
"断带");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"正常");
|
||||
}
|
||||
|
||||
/* 漏液位置 */
|
||||
y = 5 + (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);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += gui_tjc_hmi_tx_text_display(x+1, y+1,
|
||||
(char *)&hmi_tx_buffer[len],
|
||||
"0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x03: /* 翻页 */
|
||||
{
|
||||
/* 使用之前保存的全局区域索引 */
|
||||
region_idx = p_tjc_hmi->page.deliniter_main_index;
|
||||
|
||||
/* 检查区域索引是否有效 */
|
||||
if (region_idx >= leakage.region_num)
|
||||
{
|
||||
return; /* 区域索引越界 */
|
||||
}
|
||||
|
||||
/* 获取区域数据 */
|
||||
region_data = &leakage.region_data[region_idx];
|
||||
|
||||
if(0x01 == p_data[0]) /* 下一页 */
|
||||
{
|
||||
if(page_num - 1 <= p_tjc_hmi->page.detail_main_index)
|
||||
{
|
||||
p_tjc_hmi->page.detail_main_index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tjc_hmi->page.detail_main_index++;
|
||||
}
|
||||
}
|
||||
else /* 上一页 */
|
||||
{
|
||||
if(0 == p_tjc_hmi->page.detail_main_index)
|
||||
{
|
||||
p_tjc_hmi->page.detail_main_index = page_num - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tjc_hmi->page.detail_main_index--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
}break;
|
||||
default:return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
/* 发送数据到HMI屏幕 */
|
||||
if (len > 0)
|
||||
{
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer, len);
|
||||
}
|
||||
}
|
||||
else if (HMI_PROTO_CMD_SET == cmd) /* 设置命令 */
|
||||
{
|
||||
switch (opa)
|
||||
{
|
||||
case 0x01: /* */
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
}
|
||||
/*登录界面*/
|
||||
@@ -338,11 +753,11 @@ static void gui_tjc_hmi_login_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*读取flash中存储的密码,只存储密码*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -355,11 +770,11 @@ static void gui_tjc_hmi_login_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*将密码存入flash中*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -379,11 +794,11 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*读取历史报警信息,历史报警信息应该存储在flash中,显示区域名,设备ID,设备名称,报警类型,开始时间(年月日时分),结束时间*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x03:/*翻页功能,每页15条历史报警数据*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -396,11 +811,11 @@ static void gui_tjc_hmi_history_alarm_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -420,11 +835,11 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*读取网络配置信息,p_data[0]=0x01为读取设置的网络配置,02为读取默认的,网络IP,子网掩码,网关,DNS服务器*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -437,11 +852,11 @@ static void gui_tjc_hmi_tcp_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*添加网络配置,并将网络配置信息存入flash*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*无*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -461,11 +876,11 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*读取已存在的设备,显示区域,端口,设备ID,设备名,*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x03:/*翻页功能,每页显示8个设备*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -478,51 +893,11 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
case 0x01:/*添加设备,将设备信息存入flash中*/
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
{
|
||||
|
||||
}break;
|
||||
default:return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
}
|
||||
/*帮助界面*/
|
||||
static void gui_tjc_hmi_help_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
{
|
||||
u16 len = 0,i;
|
||||
|
||||
if(HMI_PROTO_CMD_GET == cmd)/*获取数据*/
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
{
|
||||
|
||||
}break;
|
||||
default:return;
|
||||
}
|
||||
len = strlen((char *)hmi_tx_buffer);
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
else if(HMI_PROTO_CMD_SET == cmd)/*设置*/
|
||||
{
|
||||
switch(opa)
|
||||
{
|
||||
case 0x01:
|
||||
{
|
||||
|
||||
}break;
|
||||
case 0x02:
|
||||
case 0x02:/*删除设备,将设备信息从flash中删除*/
|
||||
{
|
||||
|
||||
}break;
|
||||
@@ -532,6 +907,7 @@ static void gui_tjc_hmi_help_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
gui_tjc_hmi_data_send(hmi_tx_buffer,len);
|
||||
}
|
||||
}
|
||||
|
||||
/*屏幕指令解析*/
|
||||
static void gui_tjc_hmi_communication_data_analysis(u8 *p_data, u16 len, void *rx_uart)
|
||||
{
|
||||
@@ -558,7 +934,7 @@ static void gui_tjc_hmi_communication_data_analysis(u8 *p_data, u16 len, void *r
|
||||
|
||||
/*CMD*/
|
||||
cmd = p_data[2];
|
||||
if(cmd != HMI_PROTO_CMD_GET || HMI_PROTO_CMD_GET != HMI_PROTO_CMD_SET)
|
||||
if(cmd != HMI_PROTO_CMD_GET || cmd != HMI_PROTO_CMD_SET)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
@@ -582,7 +958,7 @@ static void gui_tjc_hmi_communication_data_analysis(u8 *p_data, u16 len, void *r
|
||||
}break;
|
||||
case HMI_PROTO_GUI_LOGIN :
|
||||
{
|
||||
gui_tjc_hmi_main_send(cmd,opa,p_offset_data);
|
||||
//gui_tjc_hmi_main_send(cmd,opa,p_offset_data);
|
||||
}break;
|
||||
case HMI_PROTO_GUI_HISTORY_ALARM :
|
||||
{
|
||||
@@ -598,7 +974,7 @@ static void gui_tjc_hmi_communication_data_analysis(u8 *p_data, u16 len, void *r
|
||||
}break;
|
||||
case HMI_PROTO_GUI_HELP :
|
||||
{
|
||||
gui_tjc_hmi_help_send(cmd,opa,p_offset_data);
|
||||
//gui_tjc_hmi_help_send(cmd,opa,p_offset_data);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
/*页码*/
|
||||
typedef struct
|
||||
{
|
||||
u8 main_index;
|
||||
u8 deliniter_main_index;
|
||||
|
||||
u8 main_index;/*主界面页码*/
|
||||
u8 deliniter_main_index;/*主界面选中区域的全局索引*/
|
||||
u8 real_alarm_index;/*实时报警界面页码*/
|
||||
u8 detail_main_index;/*区域详情界面页码*/
|
||||
}gui_tjc_hmi_page_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
Reference in New Issue
Block a user