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
3e5a3923
Commit
3e5a3923
authored
Apr 22, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(DB): Сделал сохранение аналоговых датчиков в БД с учётом precision
parent
dda3e2fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+8
-5
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+8
-5
No files found.
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
3e5a3923
...
...
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_MySQL.h"
...
...
@@ -281,7 +282,9 @@ void DBServer_MySQL::parse( UniSetTypes::SensorMessage *si )
struct
timezone
tz
;
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
;
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
3e5a3923
...
...
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "ORepHelpers.h"
#include "DBServer_SQLite.h"
...
...
@@ -258,7 +259,9 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
struct
timezone
tz
;
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
;
...
...
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