Commit 3e5a3923 authored by Pavel Vainerman's avatar Pavel Vainerman

(DB): Сделал сохранение аналоговых датчиков в БД с учётом precision

parent dda3e2fc
......@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_MySQL.h"
......@@ -282,6 +283,8 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
gettimeofday(&si->tm,&tz);
}
float val = (float)si->value / (float)pow10(si->ci.precision);
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream data;
data << "INSERT INTO " << tblName(si->type)
......@@ -289,10 +292,10 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
// Поля таблицы
<< ui.dateToString(si->sm_tv_sec,"-") << "','" // date
<< ui.timeToString(si->sm_tv_sec,":") << "','" // time
<< si->sm_tv_usec << "'," // time_usec
<< si->id << "," // sensor_id
<< si->value << "," // value
<< si->node << ")"; // node
<< si->sm_tv_usec << "','" // time_usec
<< si->id << "','" // sensor_id
<< val << "','" // value
<< si->node << "')"; // node
if( unideb.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl;
......
......@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_SQLite.h"
......@@ -259,6 +260,8 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
gettimeofday(&si->tm,&tz);
}
float val = (float)si->value / (float)pow10(si->ci.precision);
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream data;
data << "INSERT INTO " << tblName(si->type)
......@@ -266,10 +269,10 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
// Поля таблицы
<< ui.dateToString(si->sm_tv_sec,"-") << "','" // date
<< ui.timeToString(si->sm_tv_sec,":") << "','" // time
<< si->sm_tv_usec << "'," // time_usec
<< si->id << "," // sensor_id
<< si->value << "," // value
<< si->node << ")"; // node
<< si->sm_tv_usec << "','" // time_usec
<< si->id << "','" // sensor_id
<< si->value << "','" // value
<< si->node << "')"; // node
if( unideb.debugging(DBLEVEL) )
unideb[DBLEVEL] << myname << "(insert_main_history): " << data.str() << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment