98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
#include <signal.h>
|
||
#include <sys/ioctl.h>
|
||
#include <sys/socket.h>
|
||
#include <unistd.h>
|
||
#include <fstream>
|
||
#include <iostream>
|
||
#include <string.h>
|
||
#include <sys/types.h>
|
||
#include <sys/wait.h>
|
||
#include <boost/thread.hpp>
|
||
#include "platform/SH_PlatformInit.hpp"
|
||
#include "common/SH_CommonFunc.hpp"
|
||
#include "API_log/SH_log.h"
|
||
#include "common/SH_global.h"
|
||
#include "threadfunc/SH_ThreadFunc.hpp"
|
||
#include "secure/SH_Secure.hpp"
|
||
#include "aes/aes.h"
|
||
#include "dbaccess/SH_SqlDB.hpp"
|
||
#include "uart/SH_Uart.hpp"
|
||
|
||
namespace{
|
||
PlatformInit *platform = PlatformInit::instance();
|
||
Uart *pUart = Uart::instance();
|
||
}
|
||
|
||
|
||
int main(int argc, char *argv[])
|
||
{
|
||
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
|
||
log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024);
|
||
LOG_INFO("####CIDNSOFT start####\n");
|
||
|
||
// 查看版本信息
|
||
if (CheckFileVersion(argc, argv)) {
|
||
return 0;
|
||
}
|
||
|
||
// 设置线程属性之栈空间大小
|
||
boost::thread::attributes attrs;
|
||
attrs.set_stack_size(1024*1024*2);
|
||
|
||
// 初始化平台配置文件
|
||
platform->PlatFormInit();
|
||
|
||
// UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之
|
||
boost::thread searchT(attrs,SearchThread);
|
||
searchT.detach();
|
||
|
||
// 串口处理线程,用于与 ZigBee 模块通信,通过ZigBee无线通信技术与无线传感器通信
|
||
boost::thread uartReadTh(UartStart);
|
||
uartReadTh.detach();
|
||
|
||
// 休眠2秒,等待串口线程初始化完毕
|
||
boost::this_thread::sleep(boost::posix_time::seconds(2));
|
||
|
||
// 串口数据处理,读取传感器原始波形数据
|
||
boost::thread uartWaveReadTh(UartStartWave);
|
||
uartWaveReadTh.detach();
|
||
|
||
//启动 mqtt客户端
|
||
boost::thread startMqtt(StartMqttClient);
|
||
startMqtt.detach();
|
||
|
||
//启动 mqtt 心跳
|
||
boost::thread startHeart(HeartRep);
|
||
startHeart.detach();
|
||
|
||
// 通过UDP接收数据
|
||
boost::thread StartConnectSys(attrs, StartUdpSys);
|
||
StartConnectSys.detach();
|
||
|
||
//循环检测线程
|
||
boost::thread normalCheckThread(attrs,CheckThread);
|
||
normalCheckThread.detach();
|
||
|
||
//启动软件升级线程
|
||
boost::thread StartDownloadThread(attrs, RecvUpdateFile);
|
||
StartDownloadThread.detach();
|
||
|
||
//启动cgi server
|
||
boost::thread startTcpCgi(attrs,StartCgiServer);
|
||
startTcpCgi.detach();
|
||
|
||
//pUart->UpdateZigbeeInfoCtrl();
|
||
pUart->ZigbeeInit();
|
||
pUart->UpdateZigbeeInfoCtrl();
|
||
boost::this_thread::sleep(boost::posix_time::seconds(5));
|
||
|
||
while (GlobalConfig::QuitFlag_G) {
|
||
boost::this_thread::sleep(boost::posix_time::seconds(20));
|
||
// data_publish(senddata.c_str(), GlobalConfig::Topic_G.mPubData.c_str());
|
||
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
|