add code
This commit is contained in:
parent
f271ae369f
commit
2ece225952
290
main.cpp
290
main.cpp
@ -4,179 +4,179 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
// #include <string.h>
|
#include <string.h>
|
||||||
// #include <sys/types.h>
|
#include <sys/types.h>
|
||||||
// #include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
// #include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <zlog.h>
|
#include <zlog.h>
|
||||||
// #include "platform/platform_init.hpp"
|
#include "platform/platform_init.hpp"
|
||||||
// #include "common/common_func.hpp"
|
#include "common/common_func.hpp"
|
||||||
// #include "common/global.hpp"
|
#include "common/global.hpp"
|
||||||
// #include "threadfunc/thread_func.hpp"
|
#include "threadfunc/thread_func.hpp"
|
||||||
// #include "utility/secure.hpp"
|
#include "utility/secure.hpp"
|
||||||
// #include "utility/aes.h"
|
#include "utility/aes.h"
|
||||||
// #include "dbaccess/sql_db.hpp"
|
#include "dbaccess/sql_db.hpp"
|
||||||
// #include "uart/uart.hpp"
|
#include "uart/uart.hpp"
|
||||||
// #include "minilzo/minilzo.h"
|
#include "minilzo/minilzo.h"
|
||||||
|
|
||||||
// extern std::vector<RecvData> g_VecWaveDataX;
|
extern std::vector<RecvData> g_VecWaveDataX;
|
||||||
// extern std::vector<RecvData> g_VecWaveDataY;
|
extern std::vector<RecvData> g_VecWaveDataY;
|
||||||
// extern std::vector<RecvData> g_VecWaveDataZ;
|
extern std::vector<RecvData> g_VecWaveDataZ;
|
||||||
// extern std::vector<RecvData> g_VecWaveDataVolX;
|
extern std::vector<RecvData> g_VecWaveDataVolX;
|
||||||
// extern std::vector<RecvData> g_VecWaveDataVolY;
|
extern std::vector<RecvData> g_VecWaveDataVolY;
|
||||||
// extern std::vector<RecvData> g_VecWaveDataVolZ;
|
extern std::vector<RecvData> g_VecWaveDataVolZ;
|
||||||
zlog_category_t *zct = NULL;
|
zlog_category_t *zct = NULL;
|
||||||
zlog_category_t *zbt = NULL;
|
zlog_category_t *zbt = NULL;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// int rc = zlog_init("/opt/configenv/wlg.conf");
|
int rc = zlog_init("/opt/configenv/wlg.conf");
|
||||||
// if (rc) {
|
if (rc) {
|
||||||
// printf("init failed\n");
|
printf("init failed\n");
|
||||||
// return -1;
|
return -1;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// zct = zlog_get_category("wlg");
|
zct = zlog_get_category("wlg");
|
||||||
// zbt = zlog_get_category("cfg");
|
zbt = zlog_get_category("cfg");
|
||||||
// if (!zct || !zbt) {
|
if (!zct || !zbt) {
|
||||||
// printf("get category fail\n");
|
printf("get category fail\n");
|
||||||
// zlog_fini();
|
zlog_fini();
|
||||||
// return -2;
|
return -2;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// zlog_info(zbt, " Firmware compile time:%s %s,version %s", __DATE__, __TIME__, GlobalConfig::Version.c_str());
|
zlog_info(zbt, " Firmware compile time:%s %s,version %s", __DATE__, __TIME__, GlobalConfig::Version.c_str());
|
||||||
// zlog_info(zbt, "####CIDNSOFT start####");
|
zlog_info(zbt, "####CIDNSOFT start####");
|
||||||
// GlobalConfig::Version += " " + std::string(__DATE__) ;
|
GlobalConfig::Version += " " + std::string(__DATE__) ;
|
||||||
// g_VecWaveDataX.reserve(1000);
|
g_VecWaveDataX.reserve(1000);
|
||||||
// g_VecWaveDataY.reserve(1000);
|
g_VecWaveDataY.reserve(1000);
|
||||||
// g_VecWaveDataZ.reserve(1500);
|
g_VecWaveDataZ.reserve(1500);
|
||||||
// g_VecWaveDataVolX.reserve(1000);
|
g_VecWaveDataVolX.reserve(1000);
|
||||||
// g_VecWaveDataVolY.reserve(1000);
|
g_VecWaveDataVolY.reserve(1000);
|
||||||
// g_VecWaveDataVolZ.reserve(1500);
|
g_VecWaveDataVolZ.reserve(1500);
|
||||||
// boost::thread::attributes attrs;
|
boost::thread::attributes attrs;
|
||||||
// attrs.set_stack_size(1024 * 1024);
|
attrs.set_stack_size(1024 * 1024);
|
||||||
|
|
||||||
// PlatformInit::Init();
|
PlatformInit::Init();
|
||||||
|
|
||||||
// sqlite_db_ctrl::instance().InintGateway();
|
sqlite_db_ctrl::instance().InintGateway();
|
||||||
// char localtimestamp[32] = { 0 };
|
char localtimestamp[32] = { 0 };
|
||||||
// char insertSql[128] = { 0 };
|
char insertSql[128] = { 0 };
|
||||||
// GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
// memset(insertSql,0,sizeof(insertSql));
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
// sprintf(insertSql, " '3','CIDNSOFT start','%s'",localtimestamp);
|
sprintf(insertSql, " '3','CIDNSOFT start','%s'",localtimestamp);
|
||||||
// sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
|
|
||||||
// uart_inst::instance().InitZigbeeHW();
|
uart_inst::instance().InitZigbeeHW();
|
||||||
// // UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之
|
// UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之
|
||||||
// boost::thread searchT(SearchThread);
|
boost::thread searchT(SearchThread);
|
||||||
// searchT.detach();
|
searchT.detach();
|
||||||
|
|
||||||
// // 串口处理线程,用于与 ZigBee 模块通信,通过ZigBee无线通信技术与无线传感器通信
|
// 串口处理线程,用于与 ZigBee 模块通信,通过ZigBee无线通信技术与无线传感器通信
|
||||||
// boost::thread uartReadTh(UartStart);
|
boost::thread uartReadTh(UartStart);
|
||||||
// uartReadTh.detach();
|
uartReadTh.detach();
|
||||||
|
|
||||||
// boost::thread uartTestReadTh(TestUart);
|
boost::thread uartTestReadTh(TestUart);
|
||||||
// uartReadTh.detach();
|
uartReadTh.detach();
|
||||||
|
|
||||||
// // boost::thread InitModuleReadTh(InitModule);
|
// boost::thread InitModuleReadTh(InitModule);
|
||||||
// // InitModuleReadTh.detach();
|
// InitModuleReadTh.detach();
|
||||||
|
|
||||||
// InitModule();
|
InitModule();
|
||||||
|
|
||||||
// // 休眠2秒,等待串口线程初始化完毕
|
// 休眠2秒,等待串口线程初始化完毕
|
||||||
// sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
// // 串口数据处理,读取传感器原始波形数据
|
// 串口数据处理,读取传感器原始波形数据
|
||||||
// boost::thread uartWaveReadTh(UartStartWave);
|
boost::thread uartWaveReadTh(UartStartWave);
|
||||||
// uartWaveReadTh.detach();
|
uartWaveReadTh.detach();
|
||||||
// //启动 RUN LED
|
//启动 RUN LED
|
||||||
// boost::thread startRunLED(RunLED);
|
boost::thread startRunLED(RunLED);
|
||||||
// startRunLED.detach();
|
startRunLED.detach();
|
||||||
|
|
||||||
|
|
||||||
// #ifdef NR5G_MODULE
|
#ifdef NR5G_MODULE
|
||||||
// zlog_info(zbt,"NR5G_MODULE \n");
|
zlog_info(zbt,"NR5G_MODULE \n");
|
||||||
// // 5G
|
// 5G
|
||||||
// boost::thread startCSQ(GetCSQ);
|
boost::thread startCSQ(GetCSQ);
|
||||||
// startCSQ.detach();
|
startCSQ.detach();
|
||||||
// #ifndef NR5G_MEIGE
|
#ifndef NR5G_MEIGE
|
||||||
// boost::thread startDial(Dial5G);
|
boost::thread startDial(Dial5G);
|
||||||
// startDial.detach();
|
startDial.detach();
|
||||||
// #endif
|
#endif
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
// #ifdef Q4G_MODULE
|
#ifdef Q4G_MODULE
|
||||||
// boost::thread startCSQ(GetCSQ);
|
boost::thread startCSQ(GetCSQ);
|
||||||
// startCSQ.detach();
|
startCSQ.detach();
|
||||||
// zlog_info(zbt, "4G_MODULE");
|
zlog_info(zbt, "4G_MODULE");
|
||||||
|
|
||||||
// #endif
|
#endif
|
||||||
// #ifdef WIFI_MODULE
|
#ifdef WIFI_MODULE
|
||||||
// zlog_info(zbt,"WiFi_MODULE");
|
zlog_info(zbt,"WiFi_MODULE");
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
// //通过UDP接收数据
|
//通过UDP接收数据
|
||||||
// boost::thread StartConnectSys(attrs, StartUdpSys);
|
boost::thread StartConnectSys(attrs, StartUdpSys);
|
||||||
// StartConnectSys.detach();
|
StartConnectSys.detach();
|
||||||
|
|
||||||
// //循环检测线程
|
//循环检测线程
|
||||||
// boost::thread normalCheckThread(attrs, CheckThread);
|
boost::thread normalCheckThread(attrs, CheckThread);
|
||||||
// normalCheckThread.detach();
|
normalCheckThread.detach();
|
||||||
|
|
||||||
// //启动cgi server
|
//启动cgi server
|
||||||
// boost::thread startTcpCgi(attrs, StartCgiServer);
|
boost::thread startTcpCgi(attrs, StartCgiServer);
|
||||||
// startTcpCgi.detach();
|
startTcpCgi.detach();
|
||||||
|
|
||||||
// sleep(5);
|
sleep(5);
|
||||||
// uart_inst::instance().ZigbeeParameterConfig();
|
uart_inst::instance().ZigbeeParameterConfig();
|
||||||
// sleep(1);
|
sleep(1);
|
||||||
// uart_inst::instance().UpdateZigbeeInfoCtrl();
|
uart_inst::instance().UpdateZigbeeInfoCtrl();
|
||||||
|
|
||||||
// //启动 mqtt客户端
|
//启动 mqtt客户端
|
||||||
// boost::thread startMqtt(StartMqttClient);
|
boost::thread startMqtt(StartMqttClient);
|
||||||
// startMqtt.detach();
|
startMqtt.detach();
|
||||||
|
|
||||||
// //启动 mqtt 心跳
|
//启动 mqtt 心跳
|
||||||
// boost::thread startHeart(HeartRep);
|
boost::thread startHeart(HeartRep);
|
||||||
// startHeart.detach();
|
startHeart.detach();
|
||||||
|
|
||||||
// boost::thread DiskCheck(attrs, DiskSpaceCheck);
|
boost::thread DiskCheck(attrs, DiskSpaceCheck);
|
||||||
// DiskCheck.detach();
|
DiskCheck.detach();
|
||||||
// #ifdef BLUETEETH_MODULE
|
#ifdef BLUETEETH_MODULE
|
||||||
// //启动蓝牙扫描
|
//启动蓝牙扫描
|
||||||
// boost::thread startScanBlueteeth(attrs, ScanBlueteethDevice);
|
boost::thread startScanBlueteeth(attrs, ScanBlueteethDevice);
|
||||||
// startScanBlueteeth.detach();
|
startScanBlueteeth.detach();
|
||||||
// #endif // BLUETEETH_MODULE
|
#endif // BLUETEETH_MODULE
|
||||||
// //启动CMT server
|
//启动CMT server
|
||||||
// boost::thread startTcpCmt(attrs, StartCMTServer);
|
boost::thread startTcpCmt(attrs, StartCMTServer);
|
||||||
// startTcpCmt.detach();
|
startTcpCmt.detach();
|
||||||
|
|
||||||
// if (lzo_init() != LZO_E_OK) {
|
if (lzo_init() != LZO_E_OK) {
|
||||||
// zlog_error(zbt, "internal error - lzo_init() failed !!!");
|
zlog_error(zbt, "internal error - lzo_init() failed !!!");
|
||||||
// zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)");
|
zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)");
|
||||||
// }
|
}
|
||||||
// int fd = OpenWatchDog();
|
int fd = OpenWatchDog();
|
||||||
// int count = 0;
|
int count = 0;
|
||||||
// while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
// gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 1);
|
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 1);
|
||||||
// usleep(20000);
|
usleep(20000);
|
||||||
// gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 0);
|
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 0);
|
||||||
// WriteWatchDog(fd);
|
WriteWatchDog(fd);
|
||||||
// sleep(20);
|
sleep(20);
|
||||||
// if (GlobalConfig::threadStatus == 0) {
|
if (GlobalConfig::threadStatus == 0) {
|
||||||
// count++;
|
count++;
|
||||||
// } else if (GlobalConfig::threadStatus == 1) {
|
} else if (GlobalConfig::threadStatus == 1) {
|
||||||
// GlobalConfig::threadStatus = 0;
|
GlobalConfig::threadStatus = 0;
|
||||||
// count = 0;
|
count = 0;
|
||||||
// }
|
}
|
||||||
// if (count >= 30) {
|
if (count >= 30) {
|
||||||
// zlog_error(zbt, "===========threadStatus ========failed");
|
zlog_error(zbt, "===========threadStatus ========failed");
|
||||||
// char localtimestamp[32] = { 0 };
|
char localtimestamp[32] = { 0 };
|
||||||
// GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
// memset(insertSql,0,sizeof(insertSql));
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
// sprintf(insertSql, " '1','CheckThread failed','%s'",localtimestamp);
|
sprintf(insertSql, " '1','CheckThread failed','%s'",localtimestamp);
|
||||||
// sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user