|
|
@ -47,6 +47,7 @@
|
|
|
|
#include "pd_main.h"
|
|
|
|
#include "pd_main.h"
|
|
|
|
#include "pd_csg.h"
|
|
|
|
#include "pd_csg.h"
|
|
|
|
#include "pd_dau.h"
|
|
|
|
#include "pd_dau.h"
|
|
|
|
|
|
|
|
#include "pd_hf.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
@ -58,12 +59,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
extern void _hf_contact_recv(int slot, char *pkt);
|
|
|
|
|
|
|
|
extern void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
extern void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
extern void _hf_real_image_recv(int slot, char *pkt);
|
|
|
|
extern void _hf_prps_get_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
extern void _hf_trend_recv(int slot, char *pkt);
|
|
|
|
extern void _hf_trend_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
extern void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
extern void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void _hf_prps_get_send(uint8_t slot, void *data);
|
|
|
|
|
|
|
|
|
|
|
|
// 命令映射表
|
|
|
|
// 命令映射表
|
|
|
|
static dau_recv_fun_cb _hf_command[] =
|
|
|
|
static dau_recv_fun_cb _hf_command[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -88,31 +90,43 @@ static dau_recv_fun_cb _hf_prv_command[] =
|
|
|
|
NULL, // DAU_P_CONFIG_GET 2
|
|
|
|
NULL, // DAU_P_CONFIG_GET 2
|
|
|
|
NULL, // DAU_P_CONFIG_PORT_SET 3
|
|
|
|
NULL, // DAU_P_CONFIG_PORT_SET 3
|
|
|
|
NULL, // DAU_P_CONFIG_PORT_GET 4
|
|
|
|
NULL, // DAU_P_CONFIG_PORT_GET 4
|
|
|
|
NULL, // DAU_P_CONFIG_REAL_WAVE 5
|
|
|
|
_hf_prps_get_recv, // DAU_P_CONFIG_REAL_WAVE 5
|
|
|
|
NULL, // 6
|
|
|
|
NULL, // 6
|
|
|
|
NULL, // 7
|
|
|
|
NULL, // 7
|
|
|
|
NULL, // 8
|
|
|
|
NULL, // 8
|
|
|
|
NULL, // 9
|
|
|
|
NULL, // 9
|
|
|
|
NULL, // DAU_P_TREND 10
|
|
|
|
_hf_trend_recv, // DAU_P_TREND 10
|
|
|
|
NULL, // DAU_P_REAL_PRPS 11
|
|
|
|
NULL, // DAU_P_REAL_PRPS 11
|
|
|
|
NULL, // DAU_P_EVENT 12
|
|
|
|
_hf_event_recv, // DAU_P_EVENT 12
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Interface functions -------------------------------------------------------*/
|
|
|
|
// 命令映射表
|
|
|
|
void _hf_real_image_recv(int slot, char *pkt)
|
|
|
|
static dau_send_fun_cb _hf_send_command[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
NULL, // 0
|
|
|
|
head->slot = slot;
|
|
|
|
_hf_prps_get_send, // DAU_SEND_PRPS 1
|
|
|
|
head->sdev_id = head->dev_id;
|
|
|
|
};
|
|
|
|
_csg_send_data(CSG_PRV_REPLY, CSG_PRV_REAL_PRPS, pkt, head->len - sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _hf_trend_recv(int slot, char *pkt)
|
|
|
|
/* Interface functions -------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* PRPS 关注报文发送 */
|
|
|
|
|
|
|
|
void _hf_prps_get_send(uint8_t slot, void *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
dau_head_init_t head_data;
|
|
|
|
head->slot = slot;
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
head->sdev_id = head->dev_id;
|
|
|
|
hf_prps_get_t *param = (hf_prps_get_t*)(dau->buf_send + sizeof(dau_pkt_head_t));
|
|
|
|
_csg_send_data(CSG_PRV_REPLY, CSG_PRV_TREND, pkt, head->len - sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
/* 回复报文 */
|
|
|
|
|
|
|
|
head_data.cmd_type = DAU_PRV_REQUEST;
|
|
|
|
|
|
|
|
head_data.cmd = DAU_P_CONFIG_REAL_WAVE;
|
|
|
|
|
|
|
|
head_data.pkt_id = dau->pkt_id++;
|
|
|
|
|
|
|
|
head_data.pkt = dau->buf_send;
|
|
|
|
|
|
|
|
head_data.len = sizeof(dau_pkt_head_t) + sizeof(hf_prps_get_t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(param, data, sizeof(hf_prps_get_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dau_send_data(dau, &head_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 心跳报文接收 */
|
|
|
|
/* 心跳报文接收 */
|
|
|
@ -121,10 +135,11 @@ void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
dau_head_init_t head_data;
|
|
|
|
dau_head_init_t head_data;
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
dau_heartbeat_t *data = (dau_heartbeat_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
hf_heartbeat_t *data = (hf_heartbeat_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
hf_data_t *hf_data = (hf_data_t*)dau->private_data;
|
|
|
|
uint32_t *timestamp = (uint32_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
uint32_t *timestamp = (uint32_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&dau->run_status, data, sizeof(dau_heartbeat_t));
|
|
|
|
memcpy(&hf_data->run_status, data, sizeof(hf_heartbeat_t));
|
|
|
|
|
|
|
|
|
|
|
|
/* 回复报文 */
|
|
|
|
/* 回复报文 */
|
|
|
|
head_data.cmd_type = DAU_REQUEST;
|
|
|
|
head_data.cmd_type = DAU_REQUEST;
|
|
|
@ -138,19 +153,141 @@ void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 心跳报文接收 */
|
|
|
|
|
|
|
|
void _hf_prps_get_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 趋势报文接收 */
|
|
|
|
|
|
|
|
void _hf_trend_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dau_head_init_t head_data;
|
|
|
|
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
|
|
|
|
hf_data_t *hf_data = (hf_data_t*)dau->private_data;
|
|
|
|
|
|
|
|
hf_trend_t *trend = &hf_data->trend;
|
|
|
|
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
|
|
|
|
hf_trend_head_t *head_trend = (hf_trend_head_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
char *data = (char*)(pkt + sizeof(dau_pkt_head_t) + sizeof(hf_trend_head_t));
|
|
|
|
|
|
|
|
char *point = NULL;
|
|
|
|
|
|
|
|
uint8_t port = 0;
|
|
|
|
|
|
|
|
hf_trend_ack_t ack;
|
|
|
|
|
|
|
|
hf_trend_ack_t *ack_p = (hf_trend_ack_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 不处理补包数据 */
|
|
|
|
|
|
|
|
if (!head_trend->boosterpack)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//printh("#1 %d %d %d %d\r\n", head_trend->vport, head_trend->sum, head_trend->index, head_trend->type);
|
|
|
|
|
|
|
|
//printh("#2 %d %d\r\n", head_trend->utc, head_trend->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
port = head_trend->vport - 1;
|
|
|
|
|
|
|
|
if (HF_TREND_TYPE_STAT == head_trend->type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
trend->col.index = head_trend->identifier;
|
|
|
|
|
|
|
|
trend->col.utc = head_trend->utc;
|
|
|
|
|
|
|
|
memcpy(&trend->col.port[port], data, sizeof(hf_trend_stat));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((head_trend->index + 1) == head_trend->sum)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//printh("vport %d index %d utc %d max %d\r\n", head_trend->vport, trend->col.index, trend->col.utc, trend->col.port[port].max);
|
|
|
|
|
|
|
|
//printh("avg %d cnt %d phase %d noise %d\r\n", trend->col.port[port].avg, trend->col.port[port].cnt, trend->col.port[port].phase, trend->col.port[port].noise);
|
|
|
|
|
|
|
|
//printh("event_cnt %d\r\n", trend->col.port[port].event_cnt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (HF_TREND_TYPE_PRPD == head_trend->type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
point = (char*)trend->prpd.port[port].data;
|
|
|
|
|
|
|
|
point += head_trend->index * HF_DATA_LEN;
|
|
|
|
|
|
|
|
memcpy(point, data, head_trend->len);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (HF_TREND_TYPE_PRPS == head_trend->type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (0 == head_trend->index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
trend->prps.port[port].point_cnt = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 这里左移 2 位是因为 sizeof(hf_data_point_t) 等于 4 */
|
|
|
|
|
|
|
|
trend->prps.port[port].point_cnt += head_trend->len >> 2;
|
|
|
|
|
|
|
|
point = (char*)trend->prps.port[port].point;
|
|
|
|
|
|
|
|
point += head_trend->index * HF_DATA_LEN;
|
|
|
|
|
|
|
|
memcpy(point, data, head_trend->len);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 回复报文 */
|
|
|
|
|
|
|
|
head_data.cmd_type = DAU_PRV_REQUEST;
|
|
|
|
|
|
|
|
head_data.cmd = DAU_P_TREND;
|
|
|
|
|
|
|
|
head_data.pkt_id = head->pkt_id;
|
|
|
|
|
|
|
|
head_data.pkt = pkt;
|
|
|
|
|
|
|
|
head_data.len = sizeof(dau_pkt_head_t) + sizeof(hf_trend_ack_t);
|
|
|
|
|
|
|
|
ack.index = head_trend->index;
|
|
|
|
|
|
|
|
ack.result = 0;
|
|
|
|
|
|
|
|
ack.boosterpack = head_trend->boosterpack;
|
|
|
|
|
|
|
|
memcpy(ack_p, &ack, sizeof(hf_trend_ack_t));
|
|
|
|
|
|
|
|
dau_send_data(dau, &head_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 事件报文接收 */
|
|
|
|
/* 事件报文接收 */
|
|
|
|
void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//dau_head_init_t head_data;
|
|
|
|
dau_head_init_t head_data;
|
|
|
|
//dau_t *dau = &daus[slot];
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
//dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
hf_data_t *hf_data = (hf_data_t*)dau->private_data;
|
|
|
|
//dau_event_head_t *head_event = (dau_event_head_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
hf_event_t *event = &hf_data->event;
|
|
|
|
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
|
|
|
|
hf_event_head_t *head_event = (hf_event_head_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
char *data = (char*)(pkt + sizeof(dau_pkt_head_t) + sizeof(hf_event_head_t));
|
|
|
|
|
|
|
|
char *point = NULL;
|
|
|
|
|
|
|
|
hf_event_ack_t ack;
|
|
|
|
|
|
|
|
hf_event_ack_t *ack_p = (hf_event_ack_t*)(pkt + sizeof(dau_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 不处理补包数据 */
|
|
|
|
|
|
|
|
if (!head_event->boosterpack)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//printh("#3 %d %d %d %d\r\n", head_event->vport, head_event->sum, head_event->index, head_event->type);
|
|
|
|
|
|
|
|
//printh("#4 %d %d\r\n\n", head_event->utc, head_event->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 第一个报文 */
|
|
|
|
|
|
|
|
if (0 == head_event->index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
event->head.vport = head_event->vport;
|
|
|
|
|
|
|
|
event->head.boosterpack = head_event->boosterpack;
|
|
|
|
|
|
|
|
event->head.power_fre = head_event->power_fre;
|
|
|
|
|
|
|
|
event->head.type = head_event->type;
|
|
|
|
|
|
|
|
event->head.max = head_event->max;
|
|
|
|
|
|
|
|
event->head.identifier = head_event->identifier;
|
|
|
|
|
|
|
|
event->head.utc = head_event->utc;
|
|
|
|
|
|
|
|
event->head.cnt = head_event->cnt;
|
|
|
|
|
|
|
|
event->head.avg_o = head_event->avg_o;
|
|
|
|
|
|
|
|
event->head.avg = head_event->avg;
|
|
|
|
|
|
|
|
event->head.point_cnt = head_event->point_cnt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((head_event->index + 1) == head_event->sum)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//printh("vport %d power_fre %d type %d max %d\r\n", event->head.vport, event->head.power_fre, event->head.type, event->head.max);
|
|
|
|
|
|
|
|
//printh("identifier %d utc %d cnt %d avg %d\r\n", event->head.identifier, event->head.utc, event->head.cnt, event->head.avg);
|
|
|
|
|
|
|
|
//printh("point_cnt %d\r\n\n", event->head.point_cnt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 第一个报文 */
|
|
|
|
point = (char*)event->point;
|
|
|
|
//if (0 == head_event->index)
|
|
|
|
point += head_event->index * HF_DATA_LEN;
|
|
|
|
//{
|
|
|
|
memcpy(point, data, head_event->len);
|
|
|
|
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/* 回复报文 */
|
|
|
|
|
|
|
|
head_data.cmd_type = DAU_PRV_REQUEST;
|
|
|
|
|
|
|
|
head_data.cmd = DAU_P_EVENT;
|
|
|
|
|
|
|
|
head_data.pkt_id = head->pkt_id;
|
|
|
|
|
|
|
|
head_data.pkt = pkt;
|
|
|
|
|
|
|
|
head_data.len = sizeof(dau_pkt_head_t) + sizeof(hf_event_ack_t);
|
|
|
|
|
|
|
|
ack.index = head_event->index;
|
|
|
|
|
|
|
|
ack.result = 0;
|
|
|
|
|
|
|
|
ack.boosterpack = head_event->boosterpack;
|
|
|
|
|
|
|
|
memcpy(ack_p, &ack, sizeof(hf_event_ack_t));
|
|
|
|
|
|
|
|
dau_send_data(dau, &head_data);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -195,7 +332,7 @@ int32_t hf_recv_process(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
|
|
|
|
|
|
|
|
|
|
|
|
/* 报文头和 CRC 校验. */
|
|
|
|
/* 报文头和 CRC 校验. */
|
|
|
|
LD_E_RETURN_N(_hf_pkt_check(slot, pkt));
|
|
|
|
LD_E_RETURN_N(_hf_pkt_check(slot, pkt));
|
|
|
|
|
|
|
|
|
|
|
|
if (DAU_REPLY == head->cmd_type)
|
|
|
|
if (DAU_REPLY == head->cmd_type)
|
|
|
@ -209,12 +346,29 @@ int32_t hf_recv_process(uint8_t slot, char *pkt, uint16_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_hf_prv_command[head->cmd])
|
|
|
|
if (_hf_prv_command[head->cmd])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_hf_command[head->cmd](slot, pkt, len);
|
|
|
|
_hf_prv_command[head->cmd](slot, pkt, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 高频发包处理函数 */
|
|
|
|
|
|
|
|
int32_t hf_send_process(uint8_t slot, uint8_t type, void *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_hf_send_command[type])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_hf_send_command[type](slot, data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 高频私有数据 */
|
|
|
|
|
|
|
|
void* hf_data_malloc(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return XMALLOC_Q(MTYPE_HF, sizeof(hf_data_t));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/
|
|
|
|
/************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/
|
|
|
|