12 changed files with 189 additions and 30 deletions
-
5.gitmodules
-
4.vscode/settings.json
-
6CMakeLists.txt
-
2dep/iflytopcpp
-
1dep/zclipp
-
2dep/zwebservice
-
98src/main.cpp
-
4src/service/device_io_service.cpp
-
45src/service/device_io_service.hpp
-
5src/service/main_control_service.cpp
-
45src/service/main_control_service.hpp
-
2src/version.hpp
@ -1 +1 @@ |
|||
Subproject commit f0124f4fa73a7ee29bddd8275f69cbef1fdedaa9 |
|||
Subproject commit 2d2ac28f73d5a14aba4501831c1c52468b726a10 |
@ -1 +1 @@ |
|||
Subproject commit f4468c3342826fbe6fb693bfc2eb4b1fba12810c |
|||
Subproject commit 2062c64d58a9eed6d22c6b48e6b8b2902f16cc9d |
@ -1,29 +1,77 @@ |
|||
#include "spdlog/spdlog.h"
|
|||
#include "configs/config.hpp"
|
|||
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
|
|||
#include "iflytopcpp/core/thread/thread.hpp"
|
|||
#include "spdlog/spdlog.h"
|
|||
#include "version.hpp"
|
|||
#include "zclipp/include/clipp.h"
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
#include "zwebservice/zwebservice.hpp"
|
|||
//
|
|||
#include "service/device_io_service.hpp"
|
|||
#include "service/main_control_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace core; |
|||
using namespace std; |
|||
int main() |
|||
{ |
|||
|
|||
shared_ptr<Config> config; |
|||
spdlog::info("Welcome to spdlog!"); |
|||
spdlog::error("Some error message with arg: {}", 1); |
|||
|
|||
spdlog::warn("Easy padding in numbers like {:08d}", 12); |
|||
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); |
|||
spdlog::info("Support for floats {:03.2f}", 1.23456); |
|||
spdlog::info("Positional args are {1} {0}..", "too", "supported"); |
|||
spdlog::info("{:<30}", "left aligned"); |
|||
|
|||
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
|
|||
spdlog::debug("This message should be displayed.."); |
|||
|
|||
// change log pattern
|
|||
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v"); |
|||
|
|||
// Compile time log levels
|
|||
// define SPDLOG_ACTIVE_LEVEL to desired level
|
|||
SPDLOG_TRACE("Some trace message with param {}", 42); |
|||
SPDLOG_DEBUG("Some debug message"); |
|||
} |
|||
using namespace clipp; |
|||
|
|||
class Main { |
|||
ENABLE_LOGGER(Main); |
|||
|
|||
private: |
|||
unique_ptr<Thread> thread; |
|||
|
|||
private: |
|||
void main(int argc, char *argv[]); |
|||
|
|||
public: |
|||
Main(/* args */) {} |
|||
~Main() {} |
|||
void run(int argc, char *argv[]) { |
|||
thread.reset(new Thread("main", [&]() { main(argc, argv); })); |
|||
while (true) sleep(1000); |
|||
} |
|||
}; |
|||
int main(int argc, char *argv[]) { |
|||
Main main; |
|||
main.run(argc, argv); |
|||
} |
|||
#define BUILD_AND_REG_SERRVICE(type, ...) \
|
|||
logger->info("build {}.....", #type); \ |
|||
shared_ptr<type> type##_val(new type(__VA_ARGS__)); \ |
|||
ServiceContrainer::get().regService(type##_val); |
|||
|
|||
/***********************************************************************************************************************
|
|||
* =======================================================Main======================================================== * |
|||
***********************************************************************************************************************/ |
|||
void Main::main(int argc, char *argv[]) { |
|||
string g_host_server_ip; |
|||
string g_device_id; |
|||
auto cli = ( //
|
|||
(required("-device_id") & value("device_id", g_device_id)).doc("device_id") //
|
|||
); |
|||
if (!parse(argc, argv, cli)) { |
|||
cout << make_man_page(cli, argv[0]); |
|||
return; |
|||
} |
|||
|
|||
logger->info("#"); |
|||
logger->info("# company:{}", "ifytop"); |
|||
logger->info("# version:{}", VERSION); |
|||
logger->info("#"); |
|||
|
|||
BUILD_AND_REG_SERRVICE(Config); |
|||
GET_SERVICE(Config)->initialize(); |
|||
if (!g_device_id.empty()) GET_SERVICE(Config)->set_deviceId(g_device_id); |
|||
|
|||
BUILD_AND_REG_SERRVICE(DeviceIOService); |
|||
GET_SERVICE(DeviceIOService)->initialize(); |
|||
|
|||
BUILD_AND_REG_SERRVICE(ZWebService); |
|||
GET_SERVICE(ZWebService)->initialize(); |
|||
|
|||
BUILD_AND_REG_SERRVICE(MainControlService); |
|||
GET_SERVICE(MainControlService)->initialize(); |
|||
|
|||
logger->info("system setup end."); |
|||
} |
@ -0,0 +1,4 @@ |
|||
#include "device_io_service.hpp"
|
|||
using namespace iflytop; |
|||
using namespace core; |
|||
using namespace std; |
@ -0,0 +1,45 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "configs/config.hpp"
|
|||
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
|
|||
//
|
|||
#include "configs/config.hpp"
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* service: DeviceIOService |
|||
* |
|||
* 监听事件: |
|||
* 依赖状态: |
|||
* 依赖服务: |
|||
* 作用: |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
class DeviceIOService : public enable_shared_from_this<DeviceIOService> { |
|||
ENABLE_LOGGER(DeviceIOService); |
|||
|
|||
public: |
|||
DeviceIOService(){}; |
|||
|
|||
void initialize(){}; |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,5 @@ |
|||
#include "main_control_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace core; |
|||
using namespace std; |
@ -0,0 +1,45 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "configs/config.hpp"
|
|||
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
|
|||
//
|
|||
#include "configs/config.hpp"
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* service: MainControlService |
|||
* |
|||
* 监听事件: |
|||
* 依赖状态: |
|||
* 依赖服务: |
|||
* 作用: |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
class MainControlService : public enable_shared_from_this<MainControlService> { |
|||
ENABLE_LOGGER(MainControlService); |
|||
|
|||
public: |
|||
MainControlService(){}; |
|||
|
|||
void initialize(){}; |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,2 @@ |
|||
#pragma once
|
|||
#define VERSION "0.1"
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue