FIX 1.铁芯与平台交互增加设置,读取上传间隔参数;

main
wangbo 1 month ago
parent 286ae19de0
commit be5c095792

@ -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 *);

@ -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

@ -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;
/* 实时波形配置. */

@ -67,6 +67,7 @@
#include "pd_dau.h"
#include "pd_hf.h"
#include "pd_modbus.h"
#include "pd_csgiron.h"
/* Private define ------------------------------------------------------------*/
@ -786,14 +787,43 @@ 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)

@ -0,0 +1,78 @@
/* Includes ------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef CFG_DEV_TYPE_LAND_PD
/* 标准C库头文件. */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
/* 用户代码头文件. */
#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

@ -134,13 +134,27 @@ 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,
dau_slot_show_cmd,
@ -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);

@ -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])

@ -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++)

Loading…
Cancel
Save