update 解决相关bug
This commit is contained in:
+16
-14
File diff suppressed because one or more lines are too long
@@ -55,7 +55,7 @@
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
/* #define HAL_I2C_MODULE_ENABLED */
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
/* #define HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "dma.h"
|
||||
#include "iwdg.h"
|
||||
#include "spi.h"
|
||||
#include "usart.h"
|
||||
#include "gpio.h"
|
||||
@@ -96,6 +97,7 @@ int main(void)
|
||||
MX_SPI2_Init();
|
||||
MX_USART3_UART_Init();
|
||||
MX_USART6_UART_Init();
|
||||
// MX_IWDG_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
app_init();
|
||||
//HAL_GPIO_WritePin(JK1_GPIO_Port,JK1_Pin,GPIO_PIN_SET);
|
||||
@@ -130,8 +132,9 @@ void SystemClock_Config(void)
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
|
||||
@@ -407,6 +407,62 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>iwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/iwdg.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -484,9 +540,9 @@
|
||||
<GroupName>Drivers/STM32F4xx_HAL_Driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_spi.c</FileName>
|
||||
<FileName>stm32f4xx_hal_iwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c</FilePath>
|
||||
<FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_iwdg.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
@@ -604,6 +660,62 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x800
|
||||
Stack_Size EQU 0x400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
@@ -40,7 +40,7 @@ __initial_sp
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x400
|
||||
Heap_Size EQU 0x200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
|
||||
@@ -115,21 +115,25 @@ Dma.USART6_TX.9.Priority=DMA_PRIORITY_LOW
|
||||
Dma.USART6_TX.9.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
IWDG.IPParameters=Reload,Prescaler
|
||||
IWDG.Prescaler=IWDG_PRESCALER_128
|
||||
IWDG.Reload=750
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32F407VGT6
|
||||
Mcu.Family=STM32F4
|
||||
Mcu.IP0=DMA
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP10=USART6
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=SPI1
|
||||
Mcu.IP4=SPI2
|
||||
Mcu.IP5=SYS
|
||||
Mcu.IP6=UART4
|
||||
Mcu.IP7=USART1
|
||||
Mcu.IP8=USART2
|
||||
Mcu.IP9=USART3
|
||||
Mcu.IPNb=11
|
||||
Mcu.IP1=IWDG
|
||||
Mcu.IP10=USART3
|
||||
Mcu.IP11=USART6
|
||||
Mcu.IP2=NVIC
|
||||
Mcu.IP3=RCC
|
||||
Mcu.IP4=SPI1
|
||||
Mcu.IP5=SPI2
|
||||
Mcu.IP6=SYS
|
||||
Mcu.IP7=UART4
|
||||
Mcu.IP8=USART1
|
||||
Mcu.IP9=USART2
|
||||
Mcu.IPNb=12
|
||||
Mcu.Name=STM32F407V(E-G)Tx
|
||||
Mcu.Package=LQFP100
|
||||
Mcu.Pin0=PH0-OSC_IN
|
||||
@@ -164,14 +168,15 @@ Mcu.Pin34=PB5
|
||||
Mcu.Pin35=PB6
|
||||
Mcu.Pin36=PB7
|
||||
Mcu.Pin37=PB8
|
||||
Mcu.Pin38=VP_SYS_VS_Systick
|
||||
Mcu.Pin38=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin39=VP_SYS_VS_Systick
|
||||
Mcu.Pin4=PA2
|
||||
Mcu.Pin5=PA3
|
||||
Mcu.Pin6=PA5
|
||||
Mcu.Pin7=PA6
|
||||
Mcu.Pin8=PA7
|
||||
Mcu.Pin9=PC4
|
||||
Mcu.PinsNb=39
|
||||
Mcu.PinsNb=40
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F407VGTx
|
||||
@@ -366,7 +371,7 @@ ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_UART4_Init-UART4-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_USART3_UART_Init-USART3-false-HAL-true,10-MX_USART6_UART_Init-USART6-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_UART4_Init-UART4-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_USART3_UART_Init-USART3-false-HAL-true,10-MX_USART6_UART_Init-USART6-false-HAL-true,11-MX_IWDG_Init-IWDG-false-HAL-true
|
||||
RCC.48MHZClocksFreq_Value=84000000
|
||||
RCC.AHBFreq_Value=168000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||
@@ -423,6 +428,8 @@ USART3.IPParameters=VirtualMode
|
||||
USART3.VirtualMode=VM_ASYNC
|
||||
USART6.IPParameters=VirtualMode
|
||||
USART6.VirtualMode=VM_ASYNC
|
||||
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
|
||||
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
board=custom
|
||||
|
||||
@@ -57,6 +57,7 @@ app_timer_class_t app_timer_task[] =
|
||||
******************************************/
|
||||
void app_init(void)
|
||||
{
|
||||
// Wdg.Init();
|
||||
/*flash*/
|
||||
w25q32.init();
|
||||
|
||||
@@ -72,6 +73,8 @@ void app_init(void)
|
||||
/*网口*/
|
||||
W5500.Init();
|
||||
|
||||
|
||||
|
||||
/*屏幕通讯*/
|
||||
tjc_hmi.init();
|
||||
|
||||
@@ -89,7 +92,6 @@ void app_init(void)
|
||||
relay.init();
|
||||
buzzer.init();
|
||||
led.init();
|
||||
|
||||
leakage.init();
|
||||
/*com口绑定*/
|
||||
app_com.init();
|
||||
@@ -98,7 +100,6 @@ void app_init(void)
|
||||
/*分时复用,时间片轮询*/
|
||||
app_timer.init(APP_TIMER_TASK_NUM,app_timer_task);
|
||||
|
||||
//Wdg.Init();
|
||||
}
|
||||
|
||||
/******************************************
|
||||
@@ -112,7 +113,7 @@ void app_task(void)
|
||||
{
|
||||
app_timer.task();
|
||||
task_idle();
|
||||
W5500.Task();
|
||||
// W5500.Task();
|
||||
}
|
||||
/*空闲执行的函数*/
|
||||
void task_idle(void)
|
||||
@@ -123,6 +124,7 @@ void task_idle(void)
|
||||
com_uart4.rx_task(&com_uart4);
|
||||
com_uart6.rx_task(&com_uart6);
|
||||
W5500.Task();
|
||||
// Wdg.Feed();
|
||||
}
|
||||
|
||||
void task_10ms(void)
|
||||
@@ -160,6 +162,7 @@ void task_1s(void)
|
||||
DS1302.Task();
|
||||
buzzer.task();
|
||||
relay.task();
|
||||
W5500.Monitor_task();
|
||||
}
|
||||
|
||||
void task_2s(void)
|
||||
|
||||
@@ -163,7 +163,7 @@ void app_leakage_task(void)
|
||||
}
|
||||
|
||||
/* 检查设备是否屏蔽 */
|
||||
if(p_leakage->sub_device_data[sub_device_index].flash_data.shield != UNBLOCKED)
|
||||
if(p_leakage->sub_device_data[sub_device_index].shield != UNBLOCKED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ typedef struct
|
||||
u8 state; /*状态 使能 非使能*/
|
||||
u8 com; /*端口*/
|
||||
u8 baudrate; /*波特率*/
|
||||
u8 shield; /*设备屏蔽状态*/
|
||||
u8 modbus_id; /*modbus id*/
|
||||
u8 device_name[APP_LEAKAGE_STRING_NANE_LEN]; /*设备名*/
|
||||
u8 region_name[APP_LEAKAGE_STRING_NANE_LEN]; /*区域名*/
|
||||
@@ -45,6 +44,7 @@ typedef struct
|
||||
}ch_data[APP_LEAKAGE_SUB_DEVICE_CH_NUM]; /*通道数据*/
|
||||
u8 heartbeat; /*心跳包,0-59循环*/
|
||||
u8 test_mode; /*测试模式,0=正常,1-4=测试对应通道*/
|
||||
u8 shield; /*设备屏蔽状态*/
|
||||
}app_leakage_sub_device_class_t;
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ typedef struct
|
||||
u8 sub_device_index[APP_LEAKAGE_SUB_DEVICE_NUM]; /*设备的索引*/
|
||||
}app_leakage_region_data_class_t;
|
||||
|
||||
/* 网络配置结构体 */
|
||||
typedef struct {
|
||||
u8 ip[4];
|
||||
u8 mask[4];
|
||||
u8 gateway[4];
|
||||
u16 port;
|
||||
}network_config_t;
|
||||
|
||||
/* 历史报警记录结构 */
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
#define BSP_W5500_PORT_DATA_RECEIVE 0x01 /*端口接收到一个数据包*/
|
||||
#define BSP_W5500_PORT_DATA_TRANSMITOK 0x02 /*端口发送一个数据包完成*/
|
||||
|
||||
static u8 last_link_status = 0; // 保存上一次链路状态
|
||||
|
||||
static void bsp_W5500_Interrupt_Process(void);
|
||||
static void bsp_W5500_Init(void);
|
||||
static void bsp_W5500_Task(void);
|
||||
static void Write_SOCK_Data_Buffer(bsp_W5500_Class_t *pW5500_Class, u8 *dat_ptr, u16 size);
|
||||
static void network_monitor_task(void);
|
||||
|
||||
bsp_W5500_t W5500 =
|
||||
{
|
||||
@@ -36,6 +39,7 @@ bsp_W5500_t W5500 =
|
||||
|
||||
.Init = bsp_W5500_Init,
|
||||
.Task = bsp_W5500_Task,
|
||||
.Monitor_task = network_monitor_task,
|
||||
.Socket_Send = Write_SOCK_Data_Buffer,
|
||||
|
||||
.W5500_Class[0] =
|
||||
@@ -741,7 +745,7 @@ void bsp_W5500_Socket_Set(bsp_W5500_Class_t *pW5500_Class)
|
||||
|
||||
static void bsp_W5500_Init()
|
||||
{
|
||||
u8 i;
|
||||
u8 i,ver;
|
||||
W5500_Hardware_Reset(); /*硬件复位W5500*/
|
||||
W5500_Init(); /*初始化W5500寄存器函数*/
|
||||
Detect_Gateway(); /*检查网关服务器*/
|
||||
@@ -752,6 +756,8 @@ static void bsp_W5500_Init()
|
||||
pW5500->W5500_Class[i].Run_State = 0; /*复位状态*/
|
||||
//bsp_W5500_Socket_Set(&pW5500->W5500_Class[i]); /*W5500端口初始化配置*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void bsp_W5500_Task(void)
|
||||
@@ -781,3 +787,25 @@ static void bsp_W5500_Task(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取 W5500 物理链路状态
|
||||
* @return 1: 链路连接, 0: 链路断开
|
||||
*/
|
||||
static u8 w5500_get_link_status(void)
|
||||
{
|
||||
u8 phycfgr = Read_W5500_1Byte(PHYCFGR); // 读取 PHYCFGR 寄存器
|
||||
return (phycfgr & LINK) ? 1 : 0; // 返回 LINK 位
|
||||
}
|
||||
|
||||
|
||||
static void network_monitor_task(void)
|
||||
{
|
||||
u8 current_link = w5500_get_link_status();
|
||||
|
||||
if (last_link_status == 0 && current_link == 1) {
|
||||
/*链路从断开变为连接,执行恢复操作*/
|
||||
W5500.Init();
|
||||
}
|
||||
|
||||
last_link_status = current_link;
|
||||
}
|
||||
|
||||
@@ -261,6 +261,7 @@ typedef struct
|
||||
void (*Interrupt_Process)(void); /*处理进程*/
|
||||
void (*Init)(void); /*初始化*/
|
||||
void (*Task)(void); /*任务*/
|
||||
void (*Monitor_task)(void); /*断线重连*/
|
||||
void (*Socket_Send)(bsp_W5500_Class_t *, u8 *, u16 ); /*端口发送数据*/
|
||||
}bsp_W5500_t;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "bsp_Wdg.h"
|
||||
|
||||
//#include "iwdg.h"
|
||||
#include "iwdg.h"
|
||||
|
||||
static void bsp_Wdg_Init(void);
|
||||
static void bsp_Wdg_Feed(void);
|
||||
@@ -15,11 +15,12 @@ bsp_Wdg_t *pWdg = &Wdg;
|
||||
|
||||
static void bsp_Wdg_Init(void)
|
||||
{
|
||||
// __HAL_DBGMCU_FREEZE_IWDG(); //调试模式下,冻结看门狗计数器时钟
|
||||
__HAL_DBGMCU_FREEZE_IWDG(); //调试模式下,冻结看门狗计数器时钟
|
||||
Wdg.Feed();
|
||||
}
|
||||
|
||||
static void bsp_Wdg_Feed(void)
|
||||
{
|
||||
// HAL_IWDG_Refresh(&hiwdg);
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "app_leakage.h"
|
||||
#include "bsp_W5500.h"
|
||||
|
||||
/* spi flash 片选引脚 - pb12 */
|
||||
#define W25Q32_CS_LOW() HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_RESET)
|
||||
@@ -95,12 +96,27 @@ static void gui_tjc_hmi_read_device_info_from_w25q(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void gui_tjc_hmi_read_network_config_from_w25q(void)
|
||||
{
|
||||
network_config_t config;
|
||||
w25q32.read(W25Q32_NETWORK_CONFIG_ADDR, (uint8_t*)&config, sizeof(config));
|
||||
|
||||
/* 检查数据有效性(判断第一个IP字节不是0xFF,表示有有效数据) */
|
||||
if (config.ip[0] != 0xFF && config.ip[0] != 0x00) {
|
||||
memcpy(W5500.IP_Addr, config.ip, 4);
|
||||
memcpy(W5500.Sub_Mask, config.mask, 4);
|
||||
memcpy(W5500.Gateway_IP, config.gateway, 4);
|
||||
W5500.W5500_Class[0].ConfigData.Port[0] = (config.port >> 8) & 0xFF;
|
||||
W5500.W5500_Class[0].ConfigData.Port[1] = config.port & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* 初始化函数 */
|
||||
static void w25q32_init(void) {
|
||||
W25Q32_CS_HIGH(); /* 初始时片选拉高 */
|
||||
w25q32_wake_up(); /* 唤醒芯片 */
|
||||
gui_tjc_hmi_read_device_info_from_w25q();
|
||||
gui_tjc_hmi_read_network_config_from_w25q();
|
||||
}
|
||||
|
||||
/* 读取芯片id */
|
||||
|
||||
@@ -55,6 +55,8 @@ void w25q32_sector_erase(uint32_t sector_addr);
|
||||
/* 蜂鸣器状态存储地址 - 使用独立扇区(扇区14) */
|
||||
#define W25Q32_BUZZER_STATE_ADDR 0x00E000 /*存储蜂鸣器状态(1字节)*/
|
||||
|
||||
#define W25Q32_NETWORK_CONFIG_ADDR 0x00F000 /* 网络配置存储地址(使用独立扇区) */
|
||||
|
||||
/* w25q32 对象结构体 */
|
||||
typedef struct {
|
||||
void (*init)(void);
|
||||
|
||||
@@ -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++) {
|
||||
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;
|
||||
|
||||
@@ -268,7 +268,7 @@ static u16 proto_modbus_data_read(u16 addr)
|
||||
// data = (leakage.sub_device_data[sensor_index].flash_data.com + 1)<< 8 | leakage.sub_device_data[sensor_index].flash_data.modbus_id;
|
||||
u16 value = (leakage.sub_device_data[sensor_index].flash_data.com + 1) << 8;
|
||||
value |= leakage.sub_device_data[sensor_index].flash_data.modbus_id;
|
||||
if (leakage.sub_device_data[sensor_index].flash_data.shield == BLOCKED) {
|
||||
if (leakage.sub_device_data[sensor_index].shield == BLOCKED) {
|
||||
value |= 0x8000; /*最高位表示屏蔽*/
|
||||
}
|
||||
if (leakage.sub_device_data[sensor_index].flash_data.state == ENABLE) {
|
||||
|
||||
Reference in New Issue
Block a user