From: tobias Date: Wed, 1 Mar 2017 06:28:29 +0000 (+0100) Subject: correct errors in database SQL X-Git-Url: https://git.smho.de/?a=commitdiff_plain;h=c7cb52d06aae49ba200634f348af90414d78cfac;p=owTools.git correct errors in database SQL --- diff --git a/src/main.cpp b/src/main.cpp index 1987435..b629617 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -210,8 +210,11 @@ void continuous(std::vector *devices,int intervall,int headline,int s for (owDevice* dev :*devices) { if (dev->configstate!=OWDCS_NONE) { for (size_t i=0;i<4;i++) { - if (dev->config->getPropertyID(i)!=0) - printf("\033[3;34m[%s] \033[0m\t",dev->config->getUnit(i).c_str()); + if (dev->config->getPropertyID(i)!=0) { + size_t l=utf8_length(dev->config->getUnit(i)); + std::string ls=" "; + printf("\033[3;34m[%s]%s\033[0m\t",dev->config->getUnit(i).c_str(),ls.substr(0,5-l).c_str()); + } } } } @@ -242,7 +245,11 @@ void continuous(std::vector *devices,int intervall,int headline,int s if (dev->configstate!=OWDCS_NONE) { for (size_t i=0;i<4;i++) { if (dev->config->getPropertyID(i)!=0) { - if (dev->values[i]<10) + if (dev->values[i]<=-10) + printf("%0.2f \t",dev->values[i]); + else if (dev->values[i]<0) + printf("%0.3f \t",dev->values[i]); + else if (dev->values[i]<10) printf("%0.4f \t",dev->values[i]); else if (dev->values[i]<100) printf("%0.3f \t",dev->values[i]); @@ -290,7 +297,7 @@ void device_menu(owDevice* d) { printf("\n"); d->convertAll(); for (size_t i=0;ivalues.size();i++) { - printf("\033[1;33m%0.4f %s\033[0m ",d->values[i],d->config->getUnit(i).c_str()); + printf("\033[1;33m%0.4f %s\033[0m ",d->values[i],d->config->getUnit(i).c_str()); } printf("\n"); for(int i=0;i<70;i++) printf(HL);printf("\n"); @@ -491,6 +498,18 @@ int main(int argc, char *argv[]) { printf("%i Devices found\n",(int)owi->devices.size()); } else + if ((s=getArg("v"))!="") { + printf("Reset VOC\n"); + int sel=selectDevice(); + if (sel==0) exit(0); + owDevice* dev=owi->devices[sel-1]; + std::vector cl; + cl.push_back(0x4E); + cl.push_back(0x1F); + cl.push_back(0x1F); + cl.push_back(0x1F); + dev->Communicate(&cl,4,0); + } else if ((s=getArg("n"))!="") { printf("Change id of selected Device\n"); diff --git a/src/mySensorDB.cpp b/src/mySensorDB.cpp index 76631e3..891282e 100755 --- a/src/mySensorDB.cpp +++ b/src/mySensorDB.cpp @@ -193,7 +193,7 @@ int mySensorDB::insertValues(owDevice *dev) { sprintf(hs,"%016llX",(unsigned long long)dev->getNum().num); std::string query; query="INSERT INTO `"+mypre+"OW"+std::string(hs)+"` ("; - for (size_t i=0;i<4;i++) if (dev->config->getPropertyID(i)!=0) query+=std::string(hs)+"_"+std::to_string(i+1)+", "; + for (size_t i=0;i<4;i++) if (dev->config->getPropertyID(i)!=0) query+="`"+std::string(hs)+"_"+std::to_string(i+1)+"`, "; query.pop_back();query.pop_back(); query+=") VALUES ("; for (size_t i=0;i<4;i++) if (dev->config->getPropertyID(i)!=0) query+=std::to_string(dev->values[i])+", ";