You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
#include "main.hpp"
|
|
|
|
#include <signal.h>
|
|
#include <sqlite3.h>
|
|
|
|
#include "iflytop/components/uart_printer/uart_printer.hpp"
|
|
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
|
|
namespace iflytop {
|
|
bool g_in_test = false;
|
|
};
|
|
|
|
/*******************************************************************************
|
|
* MAIN => MAIN *
|
|
*******************************************************************************/
|
|
Main *Main::g_main;
|
|
int main(int argc, char *argv[]) {
|
|
Main main;
|
|
Main::g_main = &main;
|
|
main.run(argc, argv);
|
|
}
|
|
void Main::onsignal(int signo) { exit(0); }
|
|
void Main::run(int argc, char *argv[]) {
|
|
// ::signal(SIGINT, Main::_onsignal);
|
|
thread.reset(new Thread("main", [&]() { exit(main(argc, argv)); }));
|
|
while (true) sleep(1000);
|
|
}
|
|
int Main::main(int argc, char *argv[]) {
|
|
/**
|
|
* @brief 系统初始化
|
|
*/
|
|
logger->info("system setup start.");
|
|
spdlog::flush_on(spdlog::level::debug);
|
|
logger->info("#");
|
|
logger->info("# company:{}", "ifytop");
|
|
logger->info("# version:{}", VERSION);
|
|
logger->info("# project:{}", PROJECT_NAME);
|
|
logger->info("#");
|
|
logger->info("build {}.....", "Config");
|
|
// 构造GConfig
|
|
BUILD_AND_REG_SERRVICE(GConfig);
|
|
GET_SERVICE(GConfig)->initialize();
|
|
|
|
g_in_test = GET_SERVICE(GConfig)->get_testMode();
|
|
|
|
BUILD_AND_REG_SERRVICE(UartPrinter);
|
|
GET_SERVICE(UartPrinter)->initialize("/dev/ttyS5", "9600");
|
|
|
|
/**
|
|
* @brief
|
|
*/
|
|
// if (!device_id.empty()) GET_SERVICE(GConfig)->set_deviceId(device_id);
|
|
|
|
auto config = GET_SERVICE(GConfig);
|
|
|
|
// 构造MainControlService
|
|
BUILD_AND_REG_SERRVICE(MainControlService);
|
|
GET_SERVICE(MainControlService)->initialize();
|
|
logger->info("system setup end.");
|
|
while (true) sleep(1000);
|
|
}
|