2025-01-16 16:17:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file: $RCSfile: rdb_client.c,v $
|
|
|
|
|
|
* @brief: $PROFIBUS <EFBFBD><EFBFBD>SSRTDB<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @version: $Revision: 1.11 $
|
|
|
|
|
|
* @date: $Date: 2020/10/28 05:21:18 $
|
|
|
|
|
|
* @author: $Author: lizhongming $
|
|
|
|
|
|
* @state: $State: Exp $
|
|
|
|
|
|
*
|
|
|
|
|
|
* @latest: $Id: rdb_client.c,v 1.11 2020/10/28 05:21:18 lizhongming Exp $
|
|
|
|
|
|
*/
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "rdb_client.h"
|
|
|
|
|
|
#include "db_interface.h"
|
|
|
|
|
|
#include "node.h"
|
|
|
|
|
|
#include <pthread.h>//lnk20250114<31><34>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
/*lnk10-10 */////////////////////////////////
|
|
|
|
|
|
extern int HTTP_PORT;
|
|
|
|
|
|
extern int SOCKET_PORT;
|
|
|
|
|
|
extern int G_TEST_FLAG;
|
|
|
|
|
|
extern int g_front_seg_index;
|
|
|
|
|
|
extern int g_front_seg_num;
|
|
|
|
|
|
|
|
|
|
|
|
#include "../include/rocketmq/SimpleProducer.h"
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
#ifdef DEBUG_SISCO
|
|
|
|
|
|
SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
extern RPT_TYPEIDS g_rpt_typeids;
|
|
|
|
|
|
//ied_info_t *my_info;
|
|
|
|
|
|
|
|
|
|
|
|
extern apr_pool_t* g_root_pool;
|
|
|
|
|
|
uint8_t set_mx_q;
|
|
|
|
|
|
//rdb_t *g_rdb = NULL;
|
|
|
|
|
|
node_t* g_node = NULL;
|
|
|
|
|
|
extern char g_my_conf_fname[256];
|
|
|
|
|
|
apr_pool_t* g_init_pool;
|
|
|
|
|
|
apr_pool_t* g_run_pool;
|
|
|
|
|
|
apr_pool_t* g_temp_dev_pool;
|
|
|
|
|
|
|
|
|
|
|
|
//lnk20250114<31><34>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
|
|
extern char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
//Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
uint8_t set_mx_q;
|
|
|
|
|
|
|
|
|
|
|
|
pt61850app_t* g_pt61850app;
|
|
|
|
|
|
|
|
|
|
|
|
//application_t g_sysfile_app; //ϵͳ<CFB5>ļ<EFBFBD><C4BC><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϣ<EFBFBD>ṹ
|
|
|
|
|
|
//int g_sysfile_appid = -1;
|
|
|
|
|
|
//char *g_sysfile_filedir;
|
|
|
|
|
|
//byte_t g_Master;
|
|
|
|
|
|
//byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
//apr_time_t g_file_valid_time; //ֻ<>ٻ<EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
|
//byte_t g_file_name_len; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ȣ<F3B3A4B6>Ĭ<EFBFBD><C4AC>Ϊ40<34><30><EFBFBD><EFBFBD>Ϊ0ʱ<30><CAB1>ʾ<EFBFBD><CABE><EFBFBD>ⳤ<EFBFBD><E2B3A4>
|
|
|
|
|
|
//byte_t g_file_time_from; //<2F>ļ<EFBFBD><C4BC><EFBFBD>Чʱ<D0A7><CAB1>ȡֵ<C8A1>δ<EFBFBD><CEB4><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>1ȡϵͳʱ<CDB3><CAB1>
|
|
|
|
|
|
|
|
|
|
|
|
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data);
|
|
|
|
|
|
|
|
|
|
|
|
static apr_status_t pt61850app_init();
|
|
|
|
|
|
//static apr_status_t app_process_command(command_t *cmd);
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
extern int three_secs_enabled;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
//WW 2023-08-22 start
|
|
|
|
|
|
int server_socket = -1;
|
|
|
|
|
|
extern int g_iOTLFlag;
|
|
|
|
|
|
//WW 2023-08-22 end
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
static apr_status_t pt61850app_init()
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
if ((g_pt61850app = apr_pcalloc(g_run_pool, sizeof(pt61850app_t))) == NULL)
|
|
|
|
|
|
return APR_ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
rv = apr_pool_create(&(g_pt61850app->tmp_pool), g_root_pool);
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
g_pt61850app->chnl_counts = 0;
|
|
|
|
|
|
|
|
|
|
|
|
g_pt61850app->initNum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static apr_status_t allocate_LD_chnl_ext_mem()
|
|
|
|
|
|
{
|
|
|
|
|
|
int iedno, cpuno, chnl_no;
|
|
|
|
|
|
ied_t* ied;
|
|
|
|
|
|
ied_usr_t* ied_usr;
|
|
|
|
|
|
chnl_usr_t* chnl_usr;
|
|
|
|
|
|
|
|
|
|
|
|
g_pt61850app->chnl_counts = 0;
|
|
|
|
|
|
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
|
|
|
|
|
|
ied = g_node->clients[iedno];
|
|
|
|
|
|
ied_usr = apr_pcalloc(g_init_pool, sizeof(ied_usr_t));
|
|
|
|
|
|
ied->usr_ext = ied_usr;
|
|
|
|
|
|
if (ied_usr == NULL)
|
|
|
|
|
|
return APR_ENOMEM;
|
|
|
|
|
|
ied_usr->last_call_wavelist_time = sGetMsTime() + g_pt61850app->giTime * 1000 * 0.5;
|
|
|
|
|
|
ied_usr->LD_info = apr_pcalloc(g_init_pool, ied->cpucount * sizeof(LD_info_t));
|
|
|
|
|
|
if (ied_usr->LD_info == NULL)
|
|
|
|
|
|
return APR_ENOMEM;
|
|
|
|
|
|
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
|
|
|
|
|
|
ied_usr->LD_info[cpuno].ied = ied;
|
|
|
|
|
|
ied_usr->LD_info[cpuno].cpuno = ied->cpuinfo[cpuno].addr;
|
|
|
|
|
|
ied_usr->LD_info[cpuno].ht_fcd = apr_hash_make(g_init_pool);
|
|
|
|
|
|
ied_usr->LD_info[cpuno].ht_full_fcda = apr_hash_make(g_init_pool);
|
|
|
|
|
|
ied_usr->LD_info[cpuno].rptcount = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (chnl_no = 0; chnl_no < ied->chncount; chnl_no++) {
|
|
|
|
|
|
chnl_usr = apr_pcalloc(g_init_pool, sizeof(chnl_usr_t));
|
|
|
|
|
|
ied->channel[chnl_no].connect = chnl_usr;
|
|
|
|
|
|
chnl_usr->chnl = &(ied->channel[chnl_no]);
|
|
|
|
|
|
chnl_usr->chnl_id = chnl_no;
|
|
|
|
|
|
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
|
|
|
|
|
chnl_usr->m_ClosedMsTime = NEXT_CONNECT_TIME * (-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
g_pt61850app->chnl_counts += ied->chncount;
|
|
|
|
|
|
}
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static apr_status_t read_DEV_idx_from_db()
|
|
|
|
|
|
{
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
int iedno, cpuno;
|
|
|
|
|
|
ied_t* ied;
|
|
|
|
|
|
ied_usr_t* ied_usr;
|
|
|
|
|
|
LD_info_t* LD_info;
|
|
|
|
|
|
loginfo_t* loginfo = NULL;
|
|
|
|
|
|
int len, tmp;
|
|
|
|
|
|
|
|
|
|
|
|
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
|
|
|
|
|
|
ied = g_node->clients[iedno];
|
|
|
|
|
|
ied_usr = GET_IEDEXT_ADDR(ied);
|
|
|
|
|
|
//read_DEV_Index_from_db(ied->channel[0].addr, &ied_usr->dev_idx);
|
|
|
|
|
|
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
|
|
|
|
|
|
LD_info = &(ied_usr->LD_info[cpuno]);
|
|
|
|
|
|
if (LD_info->LD_name == NULL)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
len = strlen(LD_info->LD_name);
|
|
|
|
|
|
tmp = LD_info->LD_name[len - 1] - '0';
|
|
|
|
|
|
LD_info->line_id = ied_usr->dev_idx * 10 + tmp;
|
|
|
|
|
|
//ret = read_line_infos_from_db(LD_info->line_id, &LD_info->SubV_Index,&LD_info->Dev_Index,&LD_info->Sub_Index,&LD_info->GD_Index);
|
|
|
|
|
|
if (ret != TRUE)
|
|
|
|
|
|
LD_info->line_id = -1;
|
|
|
|
|
|
if (LD_info->loginfo) {
|
|
|
|
|
|
loginfo = LD_info->loginfo[0];
|
|
|
|
|
|
//read_updatetime_from_db(ied->channel[0].addr, &loginfo->start_time);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
apr_status_t init_rdb()
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
// driver_t* driver;
|
|
|
|
|
|
rv = apr_pool_create(&g_init_pool, g_root_pool);
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
rv = apr_pool_create(&g_run_pool, g_root_pool);
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
rv = apr_pool_create(&g_temp_dev_pool, g_root_pool);
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_node = apr_pcalloc(g_run_pool, sizeof(node_t));
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
//my_info = apr_pcalloc(g_run_pool,sizeof(ied_info_t));
|
|
|
|
|
|
rv = pt61850app_init();
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*rv = parse_json_cfg();
|
|
|
|
|
|
if ( rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Failed to parse json define xml file! \n");
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
init_config();
|
|
|
|
|
|
GetServerIndexFromDB();
|
|
|
|
|
|
/*lnk10-10*/
|
|
|
|
|
|
//<2F><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>web<65>ӿ<EFBFBD>
|
|
|
|
|
|
//rv = parse_device_web_test_ext();
|
|
|
|
|
|
//rv = parse_device_web_test_dev();
|
|
|
|
|
|
//rv = parse_device_web_test_front_read();
|
|
|
|
|
|
//rv = parse_device_web_test_front_write();
|
|
|
|
|
|
rv = parse_device_cfg_web();
|
|
|
|
|
|
|
|
|
|
|
|
//rv = parse_device_cfg();
|
|
|
|
|
|
//rv = parse_device_cfg_json();
|
|
|
|
|
|
//rv = parse_device_cfg_pg();
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Parsed device config xml file with error,try to run! \n");
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*lnk10-10*/
|
|
|
|
|
|
//rv = parse_line_cfg_web(); <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ն<EFBFBD>̨<EFBFBD><CCA8>
|
|
|
|
|
|
|
|
|
|
|
|
//rv = parse_line_cfg();
|
|
|
|
|
|
//rv = parse_line_cfg_pg();
|
|
|
|
|
|
|
|
|
|
|
|
/*lnk10-10*/
|
|
|
|
|
|
rv = parse_model_cfg_web();
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Parsed model with error,try to run! \n");
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//OTL_Select_xmlModel(); //xmlģ<6C><C4A3><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
|
|
|
|
|
|
Set_xml_nodeinfo();//<2F><><EFBFBD><EFBFBD>xmlģ<6C><C4A3>
|
|
|
|
|
|
|
|
|
|
|
|
rv = parse_rpt_log_ini();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
if (rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Failed to parse report log define ini file! \n");
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (app_get_private_config(g_my_conf_fname) != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Failed when processing private configuration\n");
|
|
|
|
|
|
return APR_EGENERAL;
|
|
|
|
|
|
}
|
|
|
|
|
|
init_rem_dib_table();
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern int SOCKETENABLE;
|
|
|
|
|
|
extern int HTTPENABLE;
|
|
|
|
|
|
/*--------------------------- <20><>Լ<EFBFBD><D4BC>ʼ<EFBFBD><CABC> -----------------------------------*/
|
|
|
|
|
|
apr_status_t run_protocol()
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
apr_thread_t* rtdb_thread;
|
|
|
|
|
|
// apr_thread_t* mms_thread;
|
|
|
|
|
|
static apr_threadattr_t* worker_attr = NULL;
|
|
|
|
|
|
|
2025-02-14 16:44:38 +08:00
|
|
|
|
//lnk20250214//<2F><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>0<EFBFBD><30>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>̨<EFBFBD>ˣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>Ľ<EFBFBD><C4BD>̺<EFBFBD>
|
|
|
|
|
|
if (g_onlyIP[0] != 0 && g_front_seg_index == 0 && g_front_seg_num >= 10){ //<2F><><EFBFBD><EFBFBD>web<65>˿<EFBFBD><CBBF>ƴĵ<F2BFAAB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
g_front_seg_index = g_front_seg_num; //<2F><><EFBFBD>½<EFBFBD><C2BD>̺<EFBFBD>Ϊ<EFBFBD><CEAA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĽ<C3B5><C4BD>̺ţ<CCBA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1>־
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
init_MMS();
|
|
|
|
|
|
|
|
|
|
|
|
if (worker_attr == NULL)
|
|
|
|
|
|
if ((rv = apr_threadattr_create(&worker_attr, g_run_pool)) != APR_SUCCESS)
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
|
|
|
|
if ((rv = apr_threadattr_detach_set(worker_attr, 1)) != APR_SUCCESS)
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
|
|
|
|
if ((rv = apr_threadattr_stacksize_set(worker_attr, 1920 * 1024)) != APR_SUCCESS)
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
|
|
|
|
rv = apr_threadattr_guardsize_set(worker_attr, 4096);
|
|
|
|
|
|
if (rv != APR_SUCCESS && rv != APR_ENOTIMPL)
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
|
|
|
|
if ((rv = apr_thread_create(&rtdb_thread, worker_attr, rtdb_worker, NULL, g_run_pool)) != APR_SUCCESS)
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
2025-02-14 16:44:38 +08:00
|
|
|
|
try_start_kafka_thread();//mq<6D>߳<EFBFBD>
|
2025-01-16 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
//lnk20241213<31><33><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
|
|
|
|
|
try_start_mqconsumer_thread();
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>WebSocket<65>߳<EFBFBD>
|
|
|
|
|
|
if (g_onlyIP[0] != 0 || g_node_id == NEW_HIS_DATA_BASE_NODE_ID || g_node_id == HIS_DATA_BASE_NODE_ID || g_node_id == RECALL_ALL_DATA_BASE_NODE_ID)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("g_onlyIP[0] != 0!\n\a");
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
2025-02-14 16:44:38 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>socket<65><74>http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
}
|
2025-02-14 16:44:38 +08:00
|
|
|
|
else //socket<65><74>http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳Ŀ<CCB5><C4BF><EFBFBD>
|
2025-01-16 16:17:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
printf("g_onlyIP[0] == 0!\n\a");
|
2025-02-11 18:23:19 +08:00
|
|
|
|
if (1 == SOCKETENABLE)
|
2025-01-16 16:17:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
server_socket = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
|
|
if (server_socket == -1) {
|
|
|
|
|
|
printf("Web Socket failed,error msg=%s\n\a", strerror(errno));
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ServerPort = 13000;//WW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ı<EFBFBD><C4B1>ж<EFBFBD>ȡ
|
|
|
|
|
|
if (g_node_id == STAT_DATA_BASE_NODE_ID)//ͳ<>Ʋɼ<C6B2>
|
|
|
|
|
|
ServerPort = SOCKET_PORT + STAT_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
else if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
ServerPort = SOCKET_PORT + RECALL_HIS_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (g_node_id == THREE_SECS_DATA_BASE_NODE_ID) {//3<><33><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
|
ServerPort = SOCKET_PORT + THREE_SECS_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//<2F><>̬¼<CCAC><C2BC>
|
|
|
|
|
|
ServerPort = SOCKET_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct sockaddr_in server_sockaddr;
|
|
|
|
|
|
memset(&server_sockaddr, 0, sizeof(server_sockaddr));
|
|
|
|
|
|
|
|
|
|
|
|
server_sockaddr.sin_family = AF_INET;
|
|
|
|
|
|
server_sockaddr.sin_port = htons(ServerPort);
|
|
|
|
|
|
server_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
|
|
|
|
|
|
|
|
|
|
if (bind(server_socket, (struct sockaddr*)&server_sockaddr, sizeof(server_sockaddr)) == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("bind failed, error msg = %s\n\a", strerror(errno));
|
|
|
|
|
|
printf("bind ServerPort is = %s\n\a", ServerPort);
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (listen(server_socket, 20) == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("listen server_socket= %d,ServerPort= %d failed,error msg = %s\n\a", server_socket, ServerPort, strerror(errno));
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("\n listen server_socket= %d,ServerPort= %d,wait for Web Socket client connecting......\n", server_socket, ServerPort);
|
|
|
|
|
|
|
|
|
|
|
|
printf("try_start_socket_thread \n");
|
|
|
|
|
|
try_start_socket_thread();
|
|
|
|
|
|
}
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (1 == HTTPENABLE)
|
2025-01-16 16:17:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
if (g_node_id == STAT_DATA_BASE_NODE_ID)//ͳ<>Ʋɼ<C6B2>
|
|
|
|
|
|
HTTP_PORT = HTTP_PORT + STAT_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
else if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
HTTP_PORT = HTTP_PORT + RECALL_HIS_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (g_node_id == THREE_SECS_DATA_BASE_NODE_ID) {//3<><33><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
|
HTTP_PORT = HTTP_PORT + THREE_SECS_DATA_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//<2F><>̬¼<CCAC><C2BC>
|
|
|
|
|
|
HTTP_PORT = HTTP_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("try_start_web_http_thread \n");
|
|
|
|
|
|
try_start_web_http_thread();
|
|
|
|
|
|
printf("try_start_http_thread \n");
|
|
|
|
|
|
try_start_http_thread();
|
|
|
|
|
|
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
if (1 == G_TEST_FLAG) {
|
|
|
|
|
|
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("try_start_mqtest_thread \n");
|
|
|
|
|
|
try_start_mqtest_thread(0,NULL);
|
|
|
|
|
|
}
|
2025-01-16 16:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//lnkɾ<6B><C9BE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD>
|
|
|
|
|
|
#if 0
|
2025-01-16 16:17:01 +08:00
|
|
|
|
if (1 == g_iOTLFlag) {
|
|
|
|
|
|
printf("try_start_sql_thread \n");
|
|
|
|
|
|
try_start_sql_thread();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
printf("sql_thread ignore \n");
|
2025-02-11 18:23:19 +08:00
|
|
|
|
#endif
|
2025-01-16 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
printf("try_start_ontimer_thread \n");
|
|
|
|
|
|
try_start_ontimer_thread();
|
|
|
|
|
|
|
|
|
|
|
|
//OTLTestSelect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////WW end
|
|
|
|
|
|
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern uint32_t g_dead_lock_counter;
|
|
|
|
|
|
extern uint32_t g_thread_blocked_times;
|
|
|
|
|
|
/*--------------------------- <20><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>߳<EFBFBD> -----------------------------------*/
|
|
|
|
|
|
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
|
|
|
|
|
|
{
|
|
|
|
|
|
// apr_event_t event;
|
|
|
|
|
|
// command_t cmd[1];
|
|
|
|
|
|
// int i =0;
|
|
|
|
|
|
|
|
|
|
|
|
/* Maintenance the clients request */
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>rocketmq<6D><71>Ϣ lnk10-10*/
|
|
|
|
|
|
//producer_send0();
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error4 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
doCommService();//<2F><><EFBFBD><EFBFBD>61850<35><30>Ϣ
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error5 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
check_3s_config();//3<><33><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>̶<EFBFBD>ȡ3<C8A1>봥<EFBFBD><EBB4A5>
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error6 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
pthread_mutex_lock(&mtx);
|
|
|
|
|
|
CheckNextNotConnectedChannel();//<2F><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
pthread_mutex_unlock(&mtx);
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error7 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
pthread_mutex_lock(&mtx);
|
|
|
|
|
|
CheckAllConnectedChannel();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>桢<EFBFBD><E6A1A2>־<EFBFBD><D6BE><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
pthread_mutex_unlock(&mtx);
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error8 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
//check_recall_config();//<2F><><EFBFBD>ٽ<EFBFBD><D9BD>̶<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
create_recall_xml();//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error9 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
check_ledger_update();//lnk20250113<31><33>ȡ̨<C8A1>˸<EFBFBD><CBB8>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD>
|
|
|
|
|
|
|
2025-02-11 18:23:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error3 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
//Check_Recall_Config();
|
|
|
|
|
|
/*if ((g_protect_file) && (g_pt61850app->initNum>=MIN_INIT_NUM) ) {
|
|
|
|
|
|
tryCallWaveList_in_AllIeds();
|
|
|
|
|
|
}*/
|
|
|
|
|
|
//clear_old_comtrade_files();
|
|
|
|
|
|
check_disk_quota();//<2F>жϴ<D0B6><CFB4>̿ռ<CCBF>
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error1 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
apr_pool_clear(g_pt61850app->tmp_pool);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
2025-02-11 18:23:19 +08:00
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
printf("check error2 !!!!!!!!!!!!!!\n");
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
g_dead_lock_counter = 0;
|
|
|
|
|
|
g_thread_blocked_times = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo_msg("rtdb worker thread terminated...");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
void Set_val_from_61850rpt(element_t* elem, double v)
|
|
|
|
|
|
{
|
|
|
|
|
|
GET_DOTEXT_ADDR(elem)->DataStatus |= VALUE_REACHED;
|
|
|
|
|
|
GET_DOTEXT_ADDR(elem)->m_v = v;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Set_q_from_61850rpt(char* q)
|
|
|
|
|
|
{
|
|
|
|
|
|
int quality = 0;
|
|
|
|
|
|
if (q[0] == '0' && q[1] == '0')
|
|
|
|
|
|
quality = 0;
|
|
|
|
|
|
else
|
|
|
|
|
|
quality = 1;
|
|
|
|
|
|
return quality;
|
|
|
|
|
|
//set_rpt_QualityFlag(quality);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define TIME_T_2036 (66*365* SECONDS_PER_DAY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apr_time_t convert_btod_to_apr_time(MMS_BTOD* btod)
|
|
|
|
|
|
{
|
|
|
|
|
|
MMS_BTIME6 btime6;
|
|
|
|
|
|
btime6.day = btod->day;
|
|
|
|
|
|
btime6.ms = btod->ms;
|
|
|
|
|
|
return convert_btime6_to_apr_time(&btime6);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
apr_time_t convert_btime6_to_apr_time(MMS_BTIME6* bTime6)
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_time_t ticks;
|
|
|
|
|
|
if ((TIME_T_1984_JAN_1 + (bTime6->day * SECONDS_PER_DAY)) > TIME_T_2036) {
|
|
|
|
|
|
echo_warn("ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2036<EFBFBD>꣡");
|
|
|
|
|
|
}
|
|
|
|
|
|
ticks = TIME_T_1984_JAN_1;
|
|
|
|
|
|
ticks += (bTime6->day * SECONDS_PER_DAY);
|
|
|
|
|
|
ticks *= 1000;
|
|
|
|
|
|
ticks += bTime6->ms;
|
|
|
|
|
|
ticks *= 1000;
|
|
|
|
|
|
return ticks;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
61850
|
|
|
|
|
|
λ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
|
|
|
|
|
|
0-1 Good 00
|
|
|
|
|
|
Invalid 01
|
|
|
|
|
|
Reserved 10
|
|
|
|
|
|
Questionable11
|
|
|
|
|
|
2 Overflow
|
|
|
|
|
|
3 OutofRange
|
|
|
|
|
|
4 BadReference
|
|
|
|
|
|
5 Oscillatory
|
|
|
|
|
|
6 Failure
|
|
|
|
|
|
7 OldData
|
|
|
|
|
|
8 Inconsistent
|
|
|
|
|
|
9 Inaccurate
|
|
|
|
|
|
10 Source 0(process)/1(Substituted)
|
|
|
|
|
|
11 Test
|
|
|
|
|
|
12 OperatorBlocked
|
|
|
|
|
|
*/
|
|
|
|
|
|
/*
|
|
|
|
|
|
60870
|
|
|
|
|
|
λ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
|
|
|
|
|
|
0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
4 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
5 <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
|
|
|
|
|
|
6 <EFBFBD>ǵ<EFBFBD>ǰֵ
|
|
|
|
|
|
7 <EFBFBD><EFBFBD>Ч
|
|
|
|
|
|
*/
|
|
|
|
|
|
byte_t get_mx_q_from_61850(char* q_61850)
|
|
|
|
|
|
{
|
|
|
|
|
|
QDS q;
|
|
|
|
|
|
|
|
|
|
|
|
q.bits = 0;
|
|
|
|
|
|
if (set_mx_q) {
|
|
|
|
|
|
if (!strlen(q_61850)) {
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!strcmp("0000000000000", q_61850)) {
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (q_61850[0] == '0' && q_61850[1] == '1')
|
|
|
|
|
|
q.parts.IV = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[0] == '1' && q_61850[1] == '1' && q_61850[7] == '1')
|
|
|
|
|
|
q.parts.NT = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[2] == '1')
|
|
|
|
|
|
q.parts.OV = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[12] == '1')
|
|
|
|
|
|
q.parts.BL = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[10] == '1')
|
|
|
|
|
|
q.parts.SB = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
60870
|
|
|
|
|
|
λ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
|
|
|
|
|
|
0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
4 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
5 <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
|
|
|
|
|
|
6 <EFBFBD>ǵ<EFBFBD>ǰֵ
|
|
|
|
|
|
7 <EFBFBD><EFBFBD>Ч
|
|
|
|
|
|
*/
|
|
|
|
|
|
byte_t get_st_q_from_61850(char* q_61850)
|
|
|
|
|
|
{
|
|
|
|
|
|
SIQ q;
|
|
|
|
|
|
|
|
|
|
|
|
q.bits = 0;
|
|
|
|
|
|
if (!strlen(q_61850)) {
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!strcmp("0000000000000", q_61850)) {
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (q_61850[0] == '0' && q_61850[1] == '1')
|
|
|
|
|
|
q.parts.IV = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[0] == '1' && q_61850[1] == '1' && q_61850[7] == '1')
|
|
|
|
|
|
q.parts.NT = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[12] == '1')
|
|
|
|
|
|
q.parts.BL = 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (q_61850[10] == '1')
|
|
|
|
|
|
q.parts.SB = 1;
|
|
|
|
|
|
|
|
|
|
|
|
return q.bits;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte_t get_pulse_q_from_61850(char* q_61850)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!strlen(q_61850)) {
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (q_61850[0] == '0' && q_61850[1] == '1')
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
else
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|