|
|
|
@ -159,12 +159,26 @@ void _print_sockaddr_in(const struct sockaddr_in *addr)
|
|
|
|
|
|
|
|
|
|
void _csg_show()
|
|
|
|
|
{
|
|
|
|
|
char cmd[512] = {0};
|
|
|
|
|
printh("CSG connect: %s \n", (csg.is_connect == 1)? "OK" : "FAIL");
|
|
|
|
|
for (int i = 0; i < PD_SLOTS_MAX; i++)
|
|
|
|
|
{
|
|
|
|
|
printh("dau[%d]:is_connect=%d is_insert=%d\n", i, daus[i].state.is_connect,
|
|
|
|
|
daus[i].state.is_insert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printh("-----------Event----------------\r\n");
|
|
|
|
|
printh("min:%lld max:%lld count=%lld max=%d\r\n", csg.event_file.index_min, csg.event_file.index_max,
|
|
|
|
|
csg.event_file.index_max - csg.event_file.index_min, csg.event_file.files_max);
|
|
|
|
|
sprintf(cmd, "ls -l %s | grep \"^-\" | wc -l", csg.event_file.dir);
|
|
|
|
|
system(cmd);
|
|
|
|
|
|
|
|
|
|
printh("-----------Trend----------------\r\n");
|
|
|
|
|
printh("min:%lld max:%lld count=%lld max=%d\r\n", csg.trend_file.index_min, csg.trend_file.index_max,
|
|
|
|
|
csg.trend_file.index_max - csg.trend_file.index_min, csg.trend_file.files_max);
|
|
|
|
|
sprintf(cmd, "ls -l %s | grep \"^-\" | wc -l", csg.trend_file.dir);
|
|
|
|
|
system(cmd);
|
|
|
|
|
printh("--------------------------------\r\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _csg_server_set(int32_t ip, uint16_t port)
|
|
|
|
@ -365,11 +379,29 @@ void _csg_add_dau_recv(char *pkt)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slot--;
|
|
|
|
|
printf("_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
|
daus[slot].state.is_insert = TRUE;
|
|
|
|
|
modbus.card[slot].is_insert = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _csg_remove_dau_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot >= PD_SLOTS_MAX || slot == 0)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "Remove DAU %d error!\r\n", slot);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slot--;
|
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_remove_dau_recv slot = %d\n", slot);
|
|
|
|
|
daus[slot].state.is_insert = FALSE;
|
|
|
|
|
modbus.card[slot].is_insert = FALSE;
|
|
|
|
|
modbus.card[slot].is_connect = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 解析心跳报文. */
|
|
|
|
|
void _csg_heartbeat_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
@ -530,6 +562,7 @@ int32_t _csg_port_config_set_recv(char *pkt)
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
DBG(DBG_M_PD_CSG, "_csg_port_config_set_recv slot:%d \r\n", head->slot);
|
|
|
|
|
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_config_port_t));
|
|
|
|
|
if (!data)
|
|
|
|
@ -774,6 +807,9 @@ int32_t _csg_recv_process(char *pkt, uint32_t len)
|
|
|
|
|
case CSG_C_RESET:
|
|
|
|
|
_csg_reboot_recv(pkt);
|
|
|
|
|
break;
|
|
|
|
|
case CSG_C_DEL_DAU:
|
|
|
|
|
_csg_remove_dau_recv(pkt);
|
|
|
|
|
break;
|
|
|
|
|
case CSG_C_UPDATE:
|
|
|
|
|
_csg_upgrade_recv(pkt);
|
|
|
|
|
break;
|
|
|
|
@ -836,6 +872,14 @@ int32_t _csg_send_add_dau(uint8_t slot, void *data)
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t _csg_send_del_dau(uint8_t slot, void *data)
|
|
|
|
|
{
|
|
|
|
|
char *pkt = csg.buf_send;
|
|
|
|
|
_csg_send_data(CSG_REPLY, CSG_C_DEL_DAU, pkt, 0, slot + 1);
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t _csg_send_reset(uint8_t slot, void *data)
|
|
|
|
|
{
|
|
|
|
|
char *pkt = csg.buf_send;
|
|
|
|
@ -1477,9 +1521,9 @@ int32_t _csg_send_trend_statistics_data(uint8_t slot, void *data)
|
|
|
|
|
|
|
|
|
|
int32_t _csg_send_trend_data(uint8_t slot, void *data)
|
|
|
|
|
{
|
|
|
|
|
_csg_send_trend_prps_data(slot, data);
|
|
|
|
|
_csg_send_trend_prpd_data(slot, data);
|
|
|
|
|
_csg_send_trend_statistics_data(slot, data);
|
|
|
|
|
LD_E_RETURN(DBG_M_PD_CSG_ERR, _csg_send_trend_prps_data(slot, data));
|
|
|
|
|
LD_E_RETURN(DBG_M_PD_CSG_ERR, _csg_send_trend_prpd_data(slot, data));
|
|
|
|
|
LD_E_RETURN(DBG_M_PD_CSG_ERR, _csg_send_trend_statistics_data(slot, data));
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1585,6 +1629,7 @@ int32_t _csg_write_file(char *filename, char *filehead, int headsize, char *file
|
|
|
|
|
/* 确保数据落盘 */
|
|
|
|
|
fsync(fileno(file));
|
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2028,9 +2073,11 @@ void _csg_report_modbus()
|
|
|
|
|
csg_modbus_magneto_t magneto;
|
|
|
|
|
for (int i = 0; i < PD_SLOTS_MAX; i++)
|
|
|
|
|
{
|
|
|
|
|
if (0 == modbus.card[i].status)
|
|
|
|
|
continue;
|
|
|
|
|
if (modbus.card[i].is_connect == TRUE
|
|
|
|
|
&& modbus.card[i].is_insert == TRUE
|
|
|
|
|
&& modbus.card[i].type_m == DEVICE_M_TYPE)
|
|
|
|
|
&& modbus.card[i].is_insert == TRUE
|
|
|
|
|
&& modbus.card[i].type_m == DEVICE_M_TYPE)
|
|
|
|
|
{
|
|
|
|
|
switch (modbus.card[i].type_s)
|
|
|
|
|
{
|
|
|
|
@ -2112,9 +2159,18 @@ void *_csg_heartbeat_handle(void *arg)
|
|
|
|
|
info.type_s = modbus.card[i].type_s;
|
|
|
|
|
_csg_send_add_dau(i, &info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (modbus.card[i].status == 0)
|
|
|
|
|
{
|
|
|
|
|
if (modbus.card[i].is_connect == TRUE
|
|
|
|
|
&& modbus.card[i].is_insert == TRUE)
|
|
|
|
|
{
|
|
|
|
|
_csg_send_del_dau(i, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count++ > 60)
|
|
|
|
|
if (count++ > 10)
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
_csg_report_modbus();
|
|
|
|
@ -2267,7 +2323,7 @@ int32_t csg_handle_init_after(void)
|
|
|
|
|
snprintf(param.thread_name, THREAD_NAME_LEN, "CSG_HEARTBEAT");
|
|
|
|
|
create_thread(_csg_heartbeat_handle, ¶m);
|
|
|
|
|
|
|
|
|
|
param.priority = 60;
|
|
|
|
|
param.priority = 65;
|
|
|
|
|
snprintf(param.thread_name, THREAD_NAME_LEN, "CSG_SEND_CMD");
|
|
|
|
|
create_thread(_csg_send_cmd_handle, ¶m);
|
|
|
|
|
|
|
|
|
@ -2283,6 +2339,10 @@ int32_t csg_handle_init_after(void)
|
|
|
|
|
snprintf(param.thread_name, THREAD_NAME_LEN, "CSG_SEND_EVENT");
|
|
|
|
|
create_thread(_csg_send_event_handle, ¶m);
|
|
|
|
|
|
|
|
|
|
param.priority = 60;
|
|
|
|
|
snprintf(param.thread_name, THREAD_NAME_LEN, "CSG_SEND_BOOSTER");
|
|
|
|
|
create_thread(_csg_boosterpack_handle, ¶m);
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|