13 changed files with 58 additions and 582 deletions
-
2iflytoplinuxsdk
-
10src/configs/gconfig.hpp
-
9src/configs/project_setting.hpp
-
0src/configs/version.hpp
-
374src/extapi_service.cpp
-
77src/extapi_service.hpp
-
67src/main.cpp
-
51src/main.hpp
-
36src/main_control_service.cpp
-
7src/main_control_service.hpp
-
0src/services.hpp
-
3src/zservice_container/zservice_container.hpp
@ -1 +1 @@ |
|||||
Subproject commit bfbd9026128cafcb5d33faff829757f36a2156be |
|
||||
|
Subproject commit 350e65242ec5ce5afe60210254af303f95a31b74 |
@ -1,10 +1 @@ |
|||||
#pragma once
|
#pragma once
|
||||
#define LINUX_HARDWARE_ID (0x02)
|
|
||||
|
|
||||
/*******************************************************************************
|
|
||||
* LINUX_HARDWARE_REG * |
|
||||
*******************************************************************************/ |
|
||||
|
|
||||
#define REG_REBOOT_FLAG 0x0000 // 重启标识
|
|
||||
#define REG_DEVICE_ID 0x0001 // 重启标识
|
|
||||
#define REG_EXCEPTION_FLAG 0x0100 // 异常标志位
|
|
@ -1,73 +1,20 @@ |
|||||
#include "main.hpp"
|
|
||||
|
|
||||
#include <signal.h>
|
#include <signal.h>
|
||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||
|
|
||||
|
#include "main_control_service.hpp"
|
||||
|
|
||||
using namespace iflytop; |
using namespace iflytop; |
||||
using namespace core; |
using namespace core; |
||||
using namespace std; |
using namespace std; |
||||
|
|
||||
namespace iflytop { |
|
||||
bool g_in_test = false; |
|
||||
}; |
|
||||
|
|
||||
/*******************************************************************************
|
/*******************************************************************************
|
||||
* MAIN => MAIN * |
* 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 解析命令行参数 |
|
||||
*/ |
|
||||
string test_mode = "false"; |
|
||||
auto cli = ((required("--test_mode") & value("test_mode", test_mode)).doc("test_mode")); |
|
||||
if (!parse(argc, argv, cli)) { |
|
||||
test_mode = "false"; |
|
||||
// cout << make_man_page(cli, argv[0]);
|
|
||||
// exit(-1);
|
|
||||
} |
|
||||
if (test_mode == "false") { |
|
||||
g_in_test = false; |
|
||||
} else { |
|
||||
g_in_test = true; |
|
||||
|
int main(int argc, char *argv[]) { |
||||
|
shared_ptr<MainControlService> main = make_shared<MainControlService>(); |
||||
|
main->initialize(argc, argv); |
||||
|
while (true) { |
||||
|
sleep(1); |
||||
} |
} |
||||
logger->info("test_mode:{}:{}", test_mode, g_in_test); |
|
||||
|
|
||||
/**
|
|
||||
* @brief 系统初始化 |
|
||||
*/ |
|
||||
logger->info("system setup start."); |
|
||||
spdlog::flush_on(spdlog::level::debug); |
|
||||
logger->info("#"); |
|
||||
logger->info("# company:{}", "ifytop"); |
|
||||
logger->info("# version:{}", VERSION); |
|
||||
logger->info("#"); |
|
||||
logger->info("build {}.....", "Config"); |
|
||||
// 构造GConfig
|
|
||||
BUILD_AND_REG_SERRVICE(GConfig); |
|
||||
GET_SERVICE(GConfig)->initialize(); |
|
||||
|
|
||||
/**
|
|
||||
* @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); |
|
||||
} |
} |
@ -1,51 +0,0 @@ |
|||||
// #include <curl/curl.h>
|
|
||||
#pragma once
|
|
||||
#include <fstream>
|
|
||||
#include <functional>
|
|
||||
#include <iostream>
|
|
||||
#include <list>
|
|
||||
#include <map>
|
|
||||
#include <memory>
|
|
||||
#include <set>
|
|
||||
#include <sstream>
|
|
||||
#include <string>
|
|
||||
#include <vector>
|
|
||||
//
|
|
||||
#include "configs/gconfig.hpp"
|
|
||||
#include "iflytop/core/spdlogfactory/logger.hpp"
|
|
||||
#include "iflytop/core/thread/thread.hpp"
|
|
||||
#include "version.hpp"
|
|
||||
#include "zservice_container/zservice_container.hpp"
|
|
||||
#include "iflytop/components/zclicpp/clipp.h"
|
|
||||
//
|
|
||||
#include "main_control_service.hpp"
|
|
||||
|
|
||||
namespace iflytop { |
|
||||
using namespace iflytop; |
|
||||
using namespace core; |
|
||||
using namespace std; |
|
||||
using namespace clipp; |
|
||||
class Main { |
|
||||
ENABLE_LOGGER(Main); |
|
||||
|
|
||||
private: |
|
||||
unique_ptr<Thread> thread; |
|
||||
|
|
||||
private: |
|
||||
int main(int argc, char *argv[]); |
|
||||
|
|
||||
public: |
|
||||
static Main *g_main; |
|
||||
static void _onsignal(int signo) { g_main->onsignal(signo); } |
|
||||
void onsignal(int signo); |
|
||||
|
|
||||
public: |
|
||||
Main(/* args */) {} |
|
||||
~Main() {} |
|
||||
void run(int argc, char *argv[]); |
|
||||
void dosystem(string order, bool dump) { |
|
||||
if (dump) logger->info("{}", order); |
|
||||
system(order.c_str()); |
|
||||
} |
|
||||
}; |
|
||||
} // namespace iflytop
|
|
@ -1,28 +1,38 @@ |
|||||
#include "main_control_service.hpp"
|
#include "main_control_service.hpp"
|
||||
|
|
||||
#include "configs/project_setting.hpp"
|
#include "configs/project_setting.hpp"
|
||||
|
#include "configs/version.hpp"
|
||||
#include "iflytop/components/zcanreceiver/zcanreceiverhost.hpp"
|
#include "iflytop/components/zcanreceiver/zcanreceiverhost.hpp"
|
||||
#include "iflytop/core/components/stringutils.hpp"
|
#include "iflytop/core/components/stringutils.hpp"
|
||||
#include "iflytop/core/core.hpp"
|
#include "iflytop/core/core.hpp"
|
||||
#include "version.hpp"
|
|
||||
|
|
||||
using namespace iflytop; |
using namespace iflytop; |
||||
using namespace core; |
using namespace core; |
||||
using namespace std; |
using namespace std; |
||||
using namespace nlohmann; |
using namespace nlohmann; |
||||
#define BIND
|
|
||||
|
|
||||
|
#define OBJECT GET_SERVICE
|
||||
|
|
||||
namespace iflytop {}; |
namespace iflytop {}; |
||||
void MainControlService::initialize() { |
|
||||
GET_TO_SERVICE(m_zconfig); |
|
||||
|
void MainControlService::initialize(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("#"); |
||||
|
logger->info("build {}.....", "Config"); |
||||
|
|
||||
#if 0
|
|
||||
BUILD_AND_REG_SERRVICE(DeviceIoControlService); |
|
||||
REG_SERRVICE(DeviceIoControlService, new DeviceIoControlServiceTest()); |
|
||||
|
initializeService(); |
||||
|
}; |
||||
|
|
||||
GET_SERVICE(DeviceIoControlService)->initialize(); |
|
||||
GET_TO_SERVICE(m_deviceIoControlService); |
|
||||
m_deviceIoControlService->startScan(); |
|
||||
#endif
|
|
||||
|
void MainControlService::initializeService() { |
||||
|
BUILD_AND_REG_SERRVICE(GConfig); |
||||
|
OBJECT(GConfig)->initialize(); |
||||
|
|
||||
m_extAPIService.initialize(m_zconfig->get_iflytopSubDeviceCanIFName(), m_zconfig->get_iflytopSubDeviceCanBitrate(), false); |
|
||||
}; |
|
||||
|
m_extAPIService.initialize(OBJECT(GConfig)->get_canName(), //
|
||||
|
OBJECT(GConfig)->get_canBaudRate(), false); |
||||
|
} |
@ -1,3 +0,0 @@ |
|||||
#pragma once
|
|
||||
|
|
||||
#include "iflytoplinuxsdk/src/iflytop/core/components/zservice_container/zservice_container.hpp"
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue