Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
0cd2a670
Commit
0cd2a670
authored
Apr 22, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(DB): Сделал сохранение аналоговых данных в БД с учётом precision
parent
32e2b96e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+7
-4
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+6
-3
No files found.
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
0cd2a670
...
...
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_MySQL.h"
...
...
@@ -220,6 +221,8 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
gettimeofday
(
const_cast
<
struct
timeval
*>
(
&
si
->
tm
),
&
tz
);
}
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
...
...
@@ -227,10 +230,10 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
// Поля таблицы
<<
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
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
(
ulog
.
debugging
(
DBLEVEL
)
)
ulog
[
DBLEVEL
]
<<
myname
<<
"(insert_main_history): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
0cd2a670
...
...
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_SQLite.h"
...
...
@@ -205,6 +206,8 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage *si )
gettimeofday
(
const_cast
<
struct
timeval
*>
(
&
si
->
tm
),
&
tz
);
}
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
...
...
@@ -213,9 +216,9 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage *si )
<<
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv_usec
<<
"',"
// time_usec
<<
si
->
id
<<
"
,
"
// sensor_id
<<
si
->
value
<<
",
"
// value
<<
si
->
node
<<
")"
;
// node
<<
si
->
id
<<
"
','
"
// sensor_id
<<
val
<<
"','
"
// value
<<
si
->
node
<<
"
'
)"
;
// node
if
(
ulog
.
debugging
(
DBLEVEL
)
)
ulog
[
DBLEVEL
]
<<
myname
<<
"(insert_main_history): "
<<
data
.
str
()
<<
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment