From 83ec0efd0e1b4fd581c4b7a3143c02659b500d22 Mon Sep 17 00:00:00 2001 From: Alexey P Date: Sat, 28 Jan 2017 20:16:56 +0300 Subject: [PATCH 1/2] support lowcase log config --- libutils/logging.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libutils/logging.cpp b/libutils/logging.cpp index 1c558a6..1f2d5f1 100644 --- a/libutils/logging.cpp +++ b/libutils/logging.cpp @@ -18,10 +18,10 @@ LogParam::LogParam() #ifdef USE_CONFIG LogParam::LogParam(CConfigItem node) { - FileName = node.getStr("FileName"); - LogTime = (node.getStr("LogTime", false, "yes")=="yes")?true:false; - ConsoleLevel = node.getInt("ConsoleLevel", false, -1); - FileLevel = node.getInt("FileLevel", false, 0); + FileName = node.getStr("FileName", false, node.getStr("file_name")); + LogTime = (node.getStr("LogTime", false, node.getStr("log_time", false, "yes"))=="yes")?true:false; + ConsoleLevel = node.getInt("ConsoleLevel", false, node.getInt("console_level", false, -1)); + FileLevel = node.getInt("FileLevel", false, node.getInt("file_level", false, 0)); } #endif @@ -112,10 +112,13 @@ void CLog::Init(CConfigItem *Config) { CConfigItemList nodes; Config->getList("Log", nodes); + + if (nodes.size()==0) + Config->getList("log", nodes); for(CConfigItemList::iterator i=nodes.begin();i!=nodes.end();i++) { - m_LogsCfg[(*i)->getStr("Name")] = LogParam(**i); + m_LogsCfg[(*i)->getStr("Name", false, (*i)->getStr("name"))] = LogParam(**i); } } #endif From 6d56462dc4a5061352753c60b6a1eecff458da23 Mon Sep 17 00:00:00 2001 From: Alexey P Date: Sun, 29 Jan 2017 19:31:17 +0300 Subject: [PATCH 2/2] First release for wb2ih --- libutils/logging.cpp | 4 ++-- libwb/WBDevice.cpp | 17 ++++++++++------- libwb/WBDevice.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libutils/logging.cpp b/libutils/logging.cpp index 1c558a6..7cdd4d5 100644 --- a/libutils/logging.cpp +++ b/libutils/logging.cpp @@ -73,8 +73,8 @@ CLog* CLog::GetLog(string Name) if (pos>0) m_BasePath = m_BasePath.substr(0, pos+1); #else - m_BasePath = "."; -// m_BasePath = "/run/"; +// m_BasePath = "."; + m_BasePath = "/run/"; #endif log->Open((m_BasePath+Name+".log").c_str()); diff --git a/libwb/WBDevice.cpp b/libwb/WBDevice.cpp index a93705c..6117f6d 100644 --- a/libwb/WBDevice.cpp +++ b/libwb/WBDevice.cpp @@ -16,17 +16,17 @@ const char *g_Topics[] = "value", "temperature", "rel_humidity", - "pressure", + "atmospheric_pressure", "sound_level", "PrecipitationRate", //(rainfall rate) rainfall mm per hour float "WindSpeed", // wind_speed m / s float "PowerPower", // watt float "PowerConsumption", // power_consumption kWh float - "VoltageVoltage", // volts float - "WaterFlow", // water_flow m ^ 3 / hour float + "voltage", // volts float + "water_flow", // water_flow m ^ 3 / hour float "WaterTotal", // consumption water_consumption m ^ 3 float - "Resistance", // resistance Ohm float - "GasConcentration", // concentration ppm float(unsigned) + "resistance", // resistance Ohm float + "concentration", // concentration ppm float(unsigned) "", }; @@ -94,6 +94,9 @@ string CWBControl::getTypeName() void CWBControl::setType(const string& type) { Type = getType(type); + + if (Type == Error && type != "" && type != "Error") + throw CHaException(CHaException::ErrBadParam, "Unknown device type '%s'", type.c_str()); } bool CWBControl::isLoaded() @@ -271,7 +274,7 @@ void CWBDevice::setBySource(string source, string sourceType, string Value) } } -void CWBDevice::subscribeToEntich(string_vector &v) +void CWBDevice::subscribeToEnrich(string_vector &v) { if (m_Description.size()==0) v.push_back("/devices/" + m_Name+ "/meta/#"); @@ -313,4 +316,4 @@ bool CWBDevice::isLoaded() } return true; -} +} \ No newline at end of file diff --git a/libwb/WBDevice.h b/libwb/WBDevice.h index ba826aa..a26d557 100644 --- a/libwb/WBDevice.h +++ b/libwb/WBDevice.h @@ -78,7 +78,7 @@ class LIBWB_API CWBDevice void updateValues(string_map &); const CControlMap *getControls(){return &m_Controls;}; string getTopic(string Control); - void subscribeToEntich(string_vector &v); + void subscribeToEnrich(string_vector &v); void enrichDevice(const string &meta, const string &val); void enrichControl(const string &control, const string &meta, const string &val); bool isLoaded();