2021-09-18 13:45:24 +08:00
|
|
|
|
#ifndef _GLOBALCONFIG_H_
|
|
|
|
|
#define _GLOBALCONFIG_H_
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include "../API_log/SH_log.h"
|
|
|
|
|
#include "SH_CommonFunc.hpp"
|
|
|
|
|
#include "../mqttclient/SH_MqttClient.h"
|
|
|
|
|
|
2024-07-09 09:49:42 +08:00
|
|
|
|
|
|
|
|
|
#define SECTION_MAX_LEN 1024
|
2021-09-18 13:45:24 +08:00
|
|
|
|
//******************** 全局变量**********************
|
|
|
|
|
enum enumZigBeeTransmitStatus {
|
|
|
|
|
NO_ENTER_TRANSMITTING_STATUS = 0,
|
|
|
|
|
ENTER_TRANSMITTING_STATUS
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-26 18:40:37 +08:00
|
|
|
|
|
2024-07-09 09:49:42 +08:00
|
|
|
|
//#define NR5G_MODULE
|
|
|
|
|
//#define Q4G_MODULE
|
|
|
|
|
//#define WIFI_MODULE
|
|
|
|
|
//#define NR5G_MEIGE
|
2024-07-18 09:41:33 +08:00
|
|
|
|
//#define G2UL_GATEWAY
|
|
|
|
|
#define IMX6UL_GATEWAY
|
2024-07-09 09:49:42 +08:00
|
|
|
|
|
2021-09-18 13:45:24 +08:00
|
|
|
|
class GlobalConfig
|
|
|
|
|
{
|
|
|
|
|
public :
|
|
|
|
|
static int RUN_MODE; //1调试模式 0运行模式
|
|
|
|
|
static int QuitFlag_G; //程序退出标志
|
|
|
|
|
static int LinkStatus_G; //和服务器连接状态
|
|
|
|
|
static int LinkCount;
|
2024-07-09 09:49:42 +08:00
|
|
|
|
static int NetSignal;
|
|
|
|
|
static int serverStatus;
|
|
|
|
|
static int net0Status;
|
|
|
|
|
static std::string NR5GTemp;
|
|
|
|
|
static std::string NetStatus;
|
|
|
|
|
static std::string NetType;
|
2021-09-18 13:45:24 +08:00
|
|
|
|
static std::string Version; //软件版本号
|
|
|
|
|
static std::string MacAddr_G; //设备MAC地址
|
2024-07-09 09:49:42 +08:00
|
|
|
|
static std::string MacAddr_G2; //设备光纤MAC地址
|
2021-09-18 13:45:24 +08:00
|
|
|
|
static std::string IpAddr_G; //设备IP
|
|
|
|
|
static std::string DbName_G; //数据库名字
|
2024-07-09 09:49:42 +08:00
|
|
|
|
static std::string Config_G; //配置文件
|
2021-09-18 13:45:24 +08:00
|
|
|
|
static std::string ServerIP; //服务器地址
|
|
|
|
|
static int ServerPort; //服务器端口
|
|
|
|
|
static std::string UartName_G;
|
|
|
|
|
static TopicList Topic_G; //发布的主题
|
|
|
|
|
static ZigbeeInfo ZigbeeInfo_G; //gateway zigbee info
|
|
|
|
|
static ZIGBEE Zigbee_G;
|
2024-07-09 09:49:42 +08:00
|
|
|
|
static GPIOInfo GPIO_G;
|
2021-09-18 13:45:24 +08:00
|
|
|
|
static enumZigBeeTransmitStatus EnterZigBeeWaveTransmittingFlag_G; // 进入ZigBee网络原始数据传输状态标志
|
|
|
|
|
static int EnterZigBeeWaveTransmittingCnt_G; // 进入ZigBee网络原始数据传输状态计数器,以秒为单位进行计数
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NONE "\033[m"
|
|
|
|
|
#define RED "\033[0;32;31m"
|
|
|
|
|
#define LIGHT_RED "\033[1;31m"
|
|
|
|
|
#define GREEN "\033[0;32;32m"
|
|
|
|
|
#define LIGHT_GREEN "\033[1;32m"
|
|
|
|
|
#define BLUE "\033[0;32;34m"
|
|
|
|
|
#define LIGHT_BLUE "\033[1;34m"
|
|
|
|
|
#define DARY_GRAY "\033[1;30m"
|
|
|
|
|
#define CYAN "\033[0;36m"
|
|
|
|
|
#define LIGHT_CYAN "\033[1;36m"
|
|
|
|
|
#define PURPLE "\033[0;35m"
|
|
|
|
|
#define LIGHT_PURPLE "\033[1;35m"
|
|
|
|
|
#define BROWN "\033[0;33m"
|
|
|
|
|
#define YELLOW "\033[1;33m"
|
|
|
|
|
#define LIGHT_GRAY "\033[0;37m"
|
|
|
|
|
#define WHITE "\033[1;37m"
|
|
|
|
|
|
2024-07-09 09:49:42 +08:00
|
|
|
|
#ifdef IMX6UL_GATEWAY
|
|
|
|
|
#define SAVE_COUNT 2058 //2058,4800
|
|
|
|
|
#define OneWeek 259359//259359,604800
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef G2UL_GATEWAY
|
|
|
|
|
#define SAVE_COUNT 4800*4
|
|
|
|
|
#define OneWeek 604800*7
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-18 13:45:24 +08:00
|
|
|
|
#define perror_info(info) { \
|
|
|
|
|
if (GlobalConfig::RUN_MODE) { \
|
|
|
|
|
perror(info); \
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define print_dev(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(YELLOW"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define print_error(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_RED"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define print_purple(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(PURPLE"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define print_control(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(GREEN"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define print_red(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(RED"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_light_green(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_GREEN"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_blue(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(BLUE"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), GetCurrentTime().c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_light_blue(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_BLUE"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid),boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_dary_gray(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(DARY_GRAY"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_cyan(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(CYAN info"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_debug(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_CYAN info NONE, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_light_purple(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_PURPLE"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_brown(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(BROWN"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_info(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(LIGHT_GRAY"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
#define print_white(info,...) {\
|
|
|
|
|
if (GlobalConfig::RUN_MODE) {\
|
|
|
|
|
printf(WHITE"[threadid:%ld][%s][%s:%d]" info NONE, syscall(SYS_gettid), boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()).c_str(),__FUNCTION__, __LINE__, ##__VA_ARGS__);\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//按8 取整
|
|
|
|
|
#define Length_(len) do{ \
|
|
|
|
|
len = ((((len>>3) + ((len&0x7)>0?1:0))<<4) + 8); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#endif
|