/****************************************************************************
** File name    :  HTGolbal.h
** Description  :  global variable define
** Create date  :  2018.09.01
** Auther by    :  Liuyx
** Version info :  V1.0.01
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
** Update record:  
** DATE         AUTHER   DESC 
** -------------------------------------------------------------------------               
** 2018.09.01   Liuyx    first build
****************************************************************************/
#pragma warning (disable:4786)
#ifndef __HT_GLOBAL_H
#define __HT_GLOBAL_H

#include "HTType.h"
#include "HTConst.h"
#include "HTMutex.h"
#include "HTPublic.h"
#include "HTLogger.h"
#include "HTConfig.h"
#include "HTDatabase.h"
#include "HTDataStruct.h"
#include "HTBusiDatabase.h"
#include "HTError.h"
#include "HTThread.h"
#include "HTInitUtils.h"
#include "HTTcpSocket.h"
#include "HTUnit.h"
#include "HTStrConvert.h"
#include "HTXmlMethod.h"
#include "HTVersion.h"
#include "HTModbus.h"
#include "HTIEC61850.h"
#include "HTIEC61850Thread.h"
//#include "HTMmslite.h"
#include "sntp/HTSntp.h"
#include <list>
#include <map>
#include <vector>
#include <iostream>

#if (defined(__UNIX__) || defined(UNIX) || defined(LINUX) || defined(linux))
#include <dlfcn.h>
#endif

using namespace std;
//#define  _CRT_SECURE_NO_WARNINGS 1

extern map<string,ST_IED_CONN_HANDLE>    g_MapIedConn;   // IED链接句柄
extern mutex                 g_MapIedConn_mutex;

extern int                g_Running;
extern TConfig            g_TConfig;

//extern map<string, ST_IMG_THRESHOLD>               g_map_img_thres;      // 图片识别阈值
//extern mutex                                       g_map_img_thres_mutex;

extern list<ST_FILES_ATTRIB>                   g_list_comtrad_files;  // 录播文件队列
extern mutex                                   g_list_comtrad_files_mutex;

extern list<ST_DB_BODY>                        g_list_db_body;  // 入库队列
extern mutex                                   g_list_db_body_mutex;

extern list<ST_DB_WARN>                        g_list_db_warn;  // 入库队列
extern mutex                                   g_list_db_warn_mutex;

extern map<string, ST_DEVICE_INFO>             g_map_device;   // 装置设备缓存
extern mutex                                   g_map_device_mutex;

extern map<string, ST_THRES_CONF>              g_thres_conf;    // 振动传感器阈值配置
extern mutex                                   g_thres_conf_mutex;

extern map<string, ST_CONTROL_CONF>            g_ctrl_conf;    // 振动传感器控制参数配置
extern mutex                                   g_ctrl_conf_mutex;

extern map<string, ST_HT_IEC61850>             g_ied;
extern mutex                                   g_ied_mutex;

extern map<string, ST_PARAM_BIND>              g_map_parambind;   // icd配置节点绑定关系,key=nodename
extern mutex                                   g_map_parambind_mutex;   // icd配置节点绑定关系,key=nodename

extern  int         g_seqno;          // 交换的流水号
extern  mutex       g_seq_mutex;      // 流水号 

extern pthread_t   thread_handle_cache_proc;  // 内存数据同步线程句柄
extern pthread_t   thread_handle_database_proc; // 入库线程句柄
extern pthread_t   thread_handle_dbalarm_proc; // 入库线程句柄
extern pthread_t   thread_handle_sntpd;       // SNTP校时服务端线程句柄
extern pthread_t   thread_handle_sntpc;       // SNTP校时客户端线程句柄
extern pthread_t   thread_handle_iec61850_manager_proc;
extern pthread_t   thread_handle_modbus_service;  //Modbus服务线程句柄
extern pthread_t   thread_handle_modbus_recv;     //Modbus接收线程句柄
extern pthread_t   thread_handle_modbus_send;     //Modbus发送线程句柄

extern pthread_t   thread_handle_iec61850_service;    //iec61850服务线程句柄
extern pthread_t   thread_handle_iec61850_client;     //iec61850接收线程句柄
extern pthread_t   thread_handle_iec61850_server;     //iec61850发送线程句柄

#endif // end __HT_GLOBAL_H

