Преглед на файлове

完善setting

Signed-off-by: wlxuz <myxuan475@126.com>
Change-Id: Ia67bc752086bf1961efb731003243c18e73bc090
wlxuz преди 1 месец
родител
ревизия
dfdc05c584
променени са 8 файла, в които са добавени 28 реда и са изтрити 14 реда
  1. 1 1
      CMakeLists.txt
  2. 6 2
      settings/CMakeLists.txt
  3. 9 5
      settings/basic_config.xml
  4. 5 0
      settings/config_parser.cpp
  5. 2 2
      settings/config_parser.h
  6. 3 2
      settings/xmlconfig.cpp
  7. 1 1
      settings/xmlconfig.h
  8. 1 1
      web-deamon/CMakeLists.txt

+ 1 - 1
CMakeLists.txt

@@ -1,6 +1,6 @@
 # add_subdirectory(apps)
 # add_subdirectory(http)
 
-#add_subdirectory(web-deamon)
+# add_subdirectory(web-deamon)
 add_subdirectory(settings)
 add_subdirectory(dbms)

+ 6 - 2
settings/CMakeLists.txt

@@ -7,6 +7,10 @@ target_include_directories(${MODULE} PUBLIC ${TINYXML2_INCLUDE_DIR})
 target_link_directories(${MODULE} PUBLIC ${TINYXML2_LIBS_DIR})
 target_link_libraries(${MODULE} tinyxml2  utils)
 
-install(TARGETS ${MODULE}
-        DESTINATION lib/
+if (PROJECT_ENABLE_TEST)
+    add_subdirectory(test)
+endif()
+
+install(FILES basic_config.xml
+        DESTINATION $<CONFIG>/config/
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ)

+ 9 - 5
settings/basic_config.xml

@@ -1,7 +1,7 @@
 <globe>
-<id>0000000000000</id>
-<key>1234567890abcdef</key>
-<host>gateway.leotechnology.cn</host>
+<id>OQKWB9RUR9L20</id>
+<key>swx9sd0rkfa5uw6x</key>
+<host>test-gateway.leotechnology.cn</host>
 <port>8889</port>
 <tls>1</tls>
 <username>admin</username>
@@ -12,6 +12,10 @@
 <useRemoteServerTime>1</useRemoteServerTime>
 <retry>3</retry>
 <historyPeriod>10000</historyPeriod>
-<portNames>/dev/tty11,/dev/tty13,/dev/tty15,/dev/tty17,,,,,</portNames>
-<net>[{"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"}]</net>
+<Channel>
+<COM1>/dev/tty11</COM1>
+<COM2>/dev/tty13</COM2>
+<COM3>/dev/tty15</COM3>
+<COM4>/dev/tty17</COM4>
+</Channel>
 </globe>

+ 5 - 0
settings/config_parser.cpp

@@ -132,6 +132,11 @@ std::unordered_map<std::string, ConfigParser::Channel> ConfigParser::GetChannels
     }
     return channels;
 }
+int32_t ConfigParser::GetLogDuration() const
+{
+	return xmlConfig_->GetElemValueInt("", "logStoreDuration");
+}
+
 ConfigParser::Channel ConfigParser::FindChannel(const std::string &name)
 {
 	std::unordered_map<std::string, ConfigParser::Channel> mapChannels =

+ 2 - 2
settings/config_parser.h

@@ -3,7 +3,6 @@
 #include "xmlconfig.h"
 #include <unordered_map>
 #include <vector>
-
 namespace settings {
 class ConfigParser {
 public:
@@ -36,7 +35,8 @@ public:
     std::vector<LoginUser> GetLoginUsers() const;
     int16_t GetWWWPort() const;
     int32_t GetRetryTimes();
-    std::unordered_map<std::string, Channel> GetChannels() const;
+	int32_t GetLogDuration() const;
+	std::unordered_map<std::string, Channel> GetChannels() const;
 	Channel FindChannel(const std::string &name);
 
 private:

+ 3 - 2
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<int32_t>(err));
+		return false;
     }
     return true;
 }

+ 1 - 1
settings/xmlconfig.h

@@ -5,7 +5,7 @@
 extern "C" {
 #endif
 
-#include <tinyxml2/tinyxml2.h>
+#include <tinyxml2.h>
 #ifndef __cplusplus
 }
 #endif

+ 1 - 1
web-deamon/CMakeLists.txt

@@ -16,5 +16,5 @@ add_dependencies(${MODULE} vendor)
 target_link_libraries(${MODULE} $<TARGET_OBJECTS:vendor> settings
         go jsoncpp)
 install(TARGETS ${MODULE}
-        DESTINATION webconfig/
+        DESTINATION $<CONFIG>/www/
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ)