From be5c09579278701be8d0aa5a1deaf0b72e7224ca Mon Sep 17 00:00:00 2001 From: wangbo Date: Mon, 4 Aug 2025 01:21:46 +0000 Subject: [PATCH] =?UTF-8?q?FIX=201.=E9=93=81=E8=8A=AF=E4=B8=8E=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BA=A4=E4=BA=92=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E8=AF=BB=E5=8F=96=E4=B8=8A=E4=BC=A0=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E5=8F=82=E6=95=B0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/include/pd_csg.h | 1 + app/include/pd_csgiron.h | 20 +++++++++ app/include/pd_main.h | 1 + app/lib/a_process/pd_csg.c | 32 +++++++++++++- app/lib/a_process/pd_csgiron.c | 78 ++++++++++++++++++++++++++++++++++ app/lib/a_process/pd_dau.c | 18 +++++++- app/lib/a_process/pd_hf.c | 3 ++ app/lib/a_process/pd_main.c | 1 + 8 files changed, 152 insertions(+), 2 deletions(-) create mode 100755 app/include/pd_csgiron.h create mode 100755 app/lib/a_process/pd_csgiron.c diff --git a/app/include/pd_csg.h b/app/include/pd_csg.h index 5e83e21..a853516 100755 --- a/app/include/pd_csg.h +++ b/app/include/pd_csg.h @@ -132,6 +132,7 @@ enum CSG_TREND_TYPE }; typedef int32_t (*csg_send_cb)(uint8_t, uint8_t, void*); +//typedef int32_t (*csg_recv_cb)(uint8_t, uint8_t, void*); typedef int32_t (*csg_send_fun_cb)(uint8_t, void*); typedef int32_t (*csg_write_file_cb)(uint8_t, void *); diff --git a/app/include/pd_csgiron.h b/app/include/pd_csgiron.h new file mode 100755 index 0000000..dbf893a --- /dev/null +++ b/app/include/pd_csgiron.h @@ -0,0 +1,20 @@ +#ifndef __PD_CSGIRON_H__ +#define __PD_CSGIRON_H__ + +#ifdef CFG_DEV_TYPE_LAND_PD +/* Includes ------------------------------------------------------------------*/ +//#include "pd_dau.h" + +typedef int32_t (*csgiron_recv_fun_cb)(uint8_t, char*, uint16_t); + +typedef struct +{ + uint16_t report_period; + uint8_t reserved[2]; +} iron_config_t; + + +extern int32_t _csgiron_recv_process(uint8_t slot, char *pkt, uint16_t len); +#endif +#endif + diff --git a/app/include/pd_main.h b/app/include/pd_main.h index 48f9bfd..89923ba 100755 --- a/app/include/pd_main.h +++ b/app/include/pd_main.h @@ -360,6 +360,7 @@ typedef struct { uint8_t slot; // slot id uint8_t reserved0[1]; uint16_t timeout; // slot 连接断开监测时间, 单位: 分钟 + uint16_t report_period; // 铁芯 上报间隔 } pd_config_slot_t; /* 实时波形配置. */ diff --git a/app/lib/a_process/pd_csg.c b/app/lib/a_process/pd_csg.c index 7bc26a4..ae1b888 100755 --- a/app/lib/a_process/pd_csg.c +++ b/app/lib/a_process/pd_csg.c @@ -67,6 +67,7 @@ #include "pd_dau.h" #include "pd_hf.h" #include "pd_modbus.h" +#include "pd_csgiron.h" /* Private define ------------------------------------------------------------*/ @@ -785,15 +786,44 @@ UP_ERR: return E_NONE; } + +int32_t _csg_slot_match(uint8_t slot, uint8_t *type_m, uint8_t *type_s) +{ + uint8_t typem, types; + dau_t *dau = &daus[slot]; + + typem = dau->info.type_m; + types = dau->info.type_s; + if (*type_m == 0 || *type_s == 0) + { + return E_ERROR; + } + *type_m = typem; + *type_s = types; + return E_NONE; +} int32_t _csg_recv_process(char *pkt, uint32_t len) { + uint8_t typem, types; csg_pkt_head_t *head = (csg_pkt_head_t *)pkt; /* 报文头和 CRC 校验. */ LD_E_RETURN(DBG_M_PD_CSG_ERR, _csg_pkt_check(pkt)); csg.heartbeat_timeout_cnt = 0; - + + if (_csg_slot_match(head->slot - 1, &typem, &types) != E_NONE) + { + DBG(DBG_M_PD_CSG_ERR, "Invalid slot=%d typem=%d types=%d\n", head->slot, typem, types); + return E_ERROR; + } + + if (3 == typem && 4 == types) + { + _csgiron_recv_process(head->slot - 1, pkt, len); + return E_NONE; + } + if (CSG_REQUEST == head->cmd_type) { switch (head->cmd) diff --git a/app/lib/a_process/pd_csgiron.c b/app/lib/a_process/pd_csgiron.c new file mode 100755 index 0000000..5a84848 --- /dev/null +++ b/app/lib/a_process/pd_csgiron.c @@ -0,0 +1,78 @@ + +/* Includes ------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef CFG_DEV_TYPE_LAND_PD +/* 标准C库头文件. */ +#include +#include +#include +#include +#include +#include + +/* 用户代码头文件. */ +#include "pd_csgiron.h" +#include "pd_csg.h" + +/* Private define ------------------------------------------------------------*/ + +/* Private macro -------------------------------------------------------------*/ + +/* Private typedef -----------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ + +/* Private function prototypes -----------------------------------------------*/ + +/* Internal functions --------------------------------------------------------*/ +int32_t _csgiron_config_port_get(uint8_t slot, char* pkt, uint16_t len) +{ + csg_pkt_head_t *head = (csg_pkt_head_t*)pkt; + iron_config_t *pdata = (iron_config_t*)(pkt + sizeof(csg_pkt_head_t)); + pdata->report_period = pd_config.config_slot[slot].report_period; + + _csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(iron_config_t), slot + 1); + return E_NONE; +} + +int32_t _csgiron_config_port_set(uint8_t slot, char* pkt, uint16_t len) +{ + iron_config_t *pdata = (iron_config_t*)(pkt + sizeof(csg_pkt_head_t)); + pd_config.config_slot[slot].report_period = pdata->report_period; + return E_NONE; +} + +/* 命令映射表 */ +static csgiron_recv_fun_cb _csgiron_command[] = +{ + NULL, // 0 +}; + +/* 命令映射表 */ +static csgiron_recv_fun_cb _csgiron_prv_command[] = +{ + NULL, // 0 + NULL, // CSG_PRV_CONFIG_GLOBAL_SET + NULL, // CSG_PRV_CONFIG_GLOBAL_GET + _csgiron_config_port_set, // CSG_PRV_CONFIG_PORT_SET + _csgiron_config_port_get, // CSG_PRV_CONFIG_PORT_GET +}; + +int32_t _csgiron_recv_process(uint8_t slot, char *pkt, uint16_t len) +{ + dau_pkt_head_t *head = (dau_pkt_head_t*)pkt; + if (CSG_REQUEST == head->cmd) + { + _csgiron_command[head->cmd](slot, pkt, len); + } + else if (CSG_PRV_REQUEST == head->cmd) + { + _csgiron_prv_command[head->cmd](slot, pkt, len); + } + return E_NONE; +} +#endif + diff --git a/app/lib/a_process/pd_dau.c b/app/lib/a_process/pd_dau.c index 275c30b..af1317e 100755 --- a/app/lib/a_process/pd_dau.c +++ b/app/lib/a_process/pd_dau.c @@ -134,12 +134,26 @@ CMD(dau_connect_timeout, "Connect timeout\n" "Timeout time: min\n") { - uint8_t slot = pd_slot_node.param_num; + uint8_t slot = pd_slot_node.param_num - 1; pd_config.config_slot[slot].timeout = strtol(argv[0], NULL, 10); return CMD_SUCCESS; } + +/* 铁芯等上报周期 */ +CMD(dau_report_period, + dau_report_period_cmd, + "report-period <1-500>", + "Report period\n" + "Report period time: sec\n") +{ + uint8_t slot = pd_slot_node.param_num - 1; + + pd_config.config_slot[slot].report_period = strtol(argv[0], NULL, 10); + + return CMD_SUCCESS; +} /* Slot 状态显示 */ CMD(dau_slot_show, @@ -493,6 +507,7 @@ void *_dau_state_handle(void *arg) int _dau_port_config_save(vty_t *vty, uint8_t slot) { vty_out(vty, " connect-timeout %d%s", pd_config.config_slot[slot].timeout, VTY_NEWLINE); + vty_out(vty, " report-period %d%s", pd_config.config_slot[slot].report_period, VTY_NEWLINE); return E_NONE; } @@ -512,6 +527,7 @@ int32_t dau_handle_init(void) } cmd_install_element(PORT_NODE, &dau_connect_timeout_cmd); + cmd_install_element(PORT_NODE, &dau_report_period_cmd); cmd_install_element(COMMON_NODE, &dau_slot_show_cmd); cmd_install_element(COMMON_NODE, &dau_state_show_cmd); diff --git a/app/lib/a_process/pd_hf.c b/app/lib/a_process/pd_hf.c index ea42794..aca6066 100755 --- a/app/lib/a_process/pd_hf.c +++ b/app/lib/a_process/pd_hf.c @@ -965,10 +965,13 @@ static hf_send_fun_cb _hf_send_command[] = int32_t hf_recv_process(uint8_t slot, char *pkt, uint16_t len) { dau_pkt_head_t *head = (dau_pkt_head_t*)pkt; + dau_t *dau = &daus[slot]; /* 报文头和 CRC 校验. */ LD_E_RETURN_N(_hf_pkt_check(slot, pkt)); + dau->state.beat_cnt = 0; + if (DAU_REPLY == head->cmd_type) { if (_hf_command[head->cmd]) diff --git a/app/lib/a_process/pd_main.c b/app/lib/a_process/pd_main.c index 3f0837a..6492e36 100755 --- a/app/lib/a_process/pd_main.c +++ b/app/lib/a_process/pd_main.c @@ -657,6 +657,7 @@ int32_t _pd_main_init(void) { pd_config.config_slot[i].slot = i; pd_config.config_slot[i].timeout = 3; + pd_config.config_slot[i].report_period = 60; } for(i = 0; i < PD_DAU_SUM; i++)