diff --git a/CMakeLists.txt b/CMakeLists.txt index eee8370e87d7ad2a5a7c6061d4226dc22a739e54..a06e5109605de79e44f2244beb7a071ad6b8ad54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,16 +3,4 @@ # add_subdirectory(web-deamon) add_subdirectory(settings) - -install(FILES dist/index.html - DESTINATION webconfig -) -install(DIRECTORY dist/static - DESTINATION webconfig/ - FILES_MATCHING PATTERN "*" -) - -install(DIRECTORY config - DESTINATION ./ - FILES_MATCHING PATTERN "*" -) \ No newline at end of file +add_subdirectory(dbms) \ No newline at end of file diff --git a/settings/CMakeLists.txt b/settings/CMakeLists.txt index cdb7df4a7a9bbc25c3593b351b79bb1da5e53704..0478edebba5fdeeb9a84ec55973970270247f923 100644 --- a/settings/CMakeLists.txt +++ b/settings/CMakeLists.txt @@ -1,14 +1,16 @@ # 模块名称 set(MODULE settings) -include_directories(${TINYXML2_INCLUDE_DIR}) -find_library(TYNIXML2_LIBRARY tinyxml2 ${TINYXML2_LIBS_DIR} NO_DEFAULT_PATH) -message("TINYXML2_LIBS_DIR: ${TINYXML2_LIBS_DIR}, TYNIXML2_LIBRARY: ${TYNIXML2_LIBRARY}") - aux_source_directory(. DIRSRCS) add_library(${MODULE} ${DIRSRCS}) -target_link_libraries(${MODULE} ${TYNIXML2_LIBRARY} utils) +target_include_directories(${MODULE} PUBLIC ${TINYXML2_INCLUDE_DIR}) +target_link_directories(${MODULE} PUBLIC ${TINYXML2_LIBS_DIR}) +target_link_libraries(${MODULE} tinyxml2 utils) + +if (PROJECT_ENABLE_TEST) + add_subdirectory(test) +endif() -install(TARGETS ${MODULE} - DESTINATION lib/ +install(FILES basic_config.xml + DESTINATION $/config/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ) \ No newline at end of file diff --git a/settings/basic_config.xml b/settings/basic_config.xml index a6d6233791b08e14ec8865223959082179cbd288..329eec8c8b813cb03185d5317538e735809a77ca 100755 --- a/settings/basic_config.xml +++ b/settings/basic_config.xml @@ -1,7 +1,7 @@ -0000000000000 -1234567890abcdef -gateway.leotechnology.cn +OQKWB9RUR9L20 +swx9sd0rkfa5uw6x +test-gateway.leotechnology.cn 8889 1 admin @@ -12,6 +12,10 @@ 1 3 10000 -/dev/tty11,/dev/tty13,/dev/tty15,/dev/tty17,,,,, -[{"IPADDR":"192.168.201.1","NETMASK":"255.255.255.0","GATEWAY":"192.168.201.1","dhcp":false},{"dhcp":dhcp,"IPADDR":"192.168.0.230","NETMASK":"255.255.255.0","GATEWAY":"192.168.0.1"}] + +/dev/tty11 +/dev/tty13 +/dev/tty15 +/dev/tty17 + diff --git a/settings/config_parser.cpp b/settings/config_parser.cpp index 506122b868cfaa03069d3c4fbfeae921fb85715e..3fd958fc3189c8aa67bf12d63db0e2ae16b6e73a 100644 --- a/settings/config_parser.cpp +++ b/settings/config_parser.cpp @@ -132,4 +132,20 @@ std::unordered_map ConfigParser::GetChannels } return channels; } +int32_t ConfigParser::GetLogDuration() const +{ + return xmlConfig_->GetElemValueInt("", "logStoreDuration"); +} + +ConfigParser::Channel ConfigParser::FindChannel(const std::string &name) +{ + std::unordered_map mapChannels = + GetChannels(); + if (mapChannels.find(name) == mapChannels.end()) { + ConfigParser::Channel chn; + chn.type = CHN_MAX; + return chn; + } + return mapChannels[name]; +} } // namespace settings diff --git a/settings/config_parser.h b/settings/config_parser.h index 14df0dade42d2ce4f61617a1ee98bc27e4c7192a..9c3ffdedc866dbe02c5c1366f4ee4203c6b24c4e 100644 --- a/settings/config_parser.h +++ b/settings/config_parser.h @@ -3,7 +3,6 @@ #include "xmlconfig.h" #include #include - namespace settings { class ConfigParser { public: @@ -31,12 +30,14 @@ public: std::string devPath; }; - enum ChnType { CHN_COM = 0, CHN_TCP, CHN_UDP, CHN_LORA }; - std::vector GetDataCenter() const; + enum ChnType { CHN_COM = 0, CHN_TCP, CHN_UDP, CHN_LORA, CHN_MAX }; + std::vector GetDataCenter() const; std::vector GetLoginUsers() const; int16_t GetWWWPort() const; int32_t GetRetryTimes(); - std::unordered_map GetChannels() const; + int32_t GetLogDuration() const; + std::unordered_map GetChannels() const; + Channel FindChannel(const std::string &name); private: XmlConfig *xmlConfig_; diff --git a/settings/xmlconfig.cpp b/settings/xmlconfig.cpp index cf3f74f7ff3c2058b3e7989cc929c7552588b676..d3627c67c7817fa621e53a607ddc7eb8ea32361c 100644 --- a/settings/xmlconfig.cpp +++ b/settings/xmlconfig.cpp @@ -11,8 +11,9 @@ bool XmlConfig::Load(const std::string &path) { tinyxml2::XMLError err = xmlDocument_.LoadFile(path.c_str()); if (err != tinyxml2::XML_SUCCESS) { - HTELINK_LOG_ERR("load %s failed, %d", path.c_str(), err); - return false; + HTELINK_LOG_ERR( + "load %s failed, %d", path.c_str(), static_cast(err)); + return false; } return true; } diff --git a/settings/xmlconfig.h b/settings/xmlconfig.h index 917c39ad6916b9bfc3bf7ec59504a4b7a15304de..4af8fad165f22db72ad62c20a2e1e72708cfb9dc 100644 --- a/settings/xmlconfig.h +++ b/settings/xmlconfig.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include +#include #ifndef __cplusplus } #endif diff --git a/web-deamon/CMakeLists.txt b/web-deamon/CMakeLists.txt index 21c82ae26cb0b3f595256349ef35bc9ab96716e5..c6d721c7003480342107702b56955ee195c8a40f 100644 --- a/web-deamon/CMakeLists.txt +++ b/web-deamon/CMakeLists.txt @@ -16,5 +16,5 @@ add_dependencies(${MODULE} vendor) target_link_libraries(${MODULE} $ settings go jsoncpp) install(TARGETS ${MODULE} - DESTINATION webconfig/ + DESTINATION $/www/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ) \ No newline at end of file