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
8ff38cde
Commit
8ff38cde
authored
Aug 20, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Для обратной совместимости оставил в таблицах название поля time_usec,
хотя фактически теперь в БД сохраняются наносекунды.
parent
7f787ab6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
12 deletions
+21
-12
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+3
-3
DBServer_MySQL.h
extensions/DBServer-MySQL/DBServer_MySQL.h
+6
-3
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+2
-2
DBServer_PostgreSQL.h
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.h
+3
-0
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+3
-3
DBServer_SQLite.h
extensions/DBServer-SQLite/DBServer_SQLite.h
+3
-0
MessageType.h
include/MessageType.h
+1
-1
No files found.
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
8ff38cde
...
@@ -106,7 +106,7 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -106,7 +106,7 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_
nsec='"
<<
cem
->
sensor_time
.
tv_nsec
<<
" '"
;
<<
" AND time_
usec='"
<<
cem
->
sensor_time
.
tv_nsec
/
1000
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -214,11 +214,11 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -214,11 +214,11 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
// см. DBTABLE AnalogSensors, DigitalSensors
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream
data
;
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
<<
"(date, time, time_
n
sec, sensor_id, value, node) VALUES( '"
<<
"(date, time, time_
u
sec, sensor_id, value, node) VALUES( '"
// Поля таблицы
// Поля таблицы
<<
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
si
->
sm_tv
.
tv_sec
,
":"
)
<<
"','"
// time
<<
timeToString
(
si
->
sm_tv
.
tv_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv
.
tv_nsec
<<
"','"
// time_
n
sec
<<
si
->
sm_tv
.
tv_nsec
<<
"','"
// time_
u
sec
<<
si
->
id
<<
"','"
// sensor_id
<<
si
->
id
<<
"','"
// sensor_id
<<
val
<<
"','"
// value
<<
val
<<
"','"
// value
<<
si
->
node
<<
"')"
;
// node
<<
si
->
node
<<
"')"
;
// node
...
...
extensions/DBServer-MySQL/DBServer_MySQL.h
View file @
8ff38cde
...
@@ -87,7 +87,7 @@ CREATE TABLE `main_history` (
...
@@ -87,7 +87,7 @@ CREATE TABLE `main_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`time` time NOT NULL,
`time_
n
sec` int(10) unsigned NOT NULL,
`time_
u
sec` int(10) unsigned NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
`value` double NOT NULL,
`node` int(10) unsigned NOT NULL,
`node` int(10) unsigned NOT NULL,
...
@@ -102,7 +102,7 @@ CREATE TABLE `main_emergencylog` (
...
@@ -102,7 +102,7 @@ CREATE TABLE `main_emergencylog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`time` time NOT NULL,
`time_
n
sec` int(10) unsigned NOT NULL,
`time_
u
sec` int(10) unsigned NOT NULL,
`type_id` int(10) unsigned NOT NULL,
`type_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
PRIMARY KEY (`id`),
KEY `main_emergencylog_type_id` (`type_id`),
KEY `main_emergencylog_type_id` (`type_id`),
...
@@ -115,7 +115,7 @@ CREATE TABLE `main_emergencyrecords` (
...
@@ -115,7 +115,7 @@ CREATE TABLE `main_emergencyrecords` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`time` time NOT NULL,
`time_
n
sec` int(10) unsigned NOT NULL,
`time_
u
sec` int(10) unsigned NOT NULL,
`log_id` int(11) NOT NULL,
`log_id` int(11) NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
`value` double NOT NULL,
...
@@ -127,6 +127,9 @@ CREATE TABLE `main_emergencyrecords` (
...
@@ -127,6 +127,9 @@ CREATE TABLE `main_emergencyrecords` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\endcode
\endcode
\warning Временно, для обратной совместимости поле 'time_usec' в таблицах оставлено с таким названием,
хотя фактически туда сейчас сохраняется значение в наносекундах!
*/
*/
class
DBServer_MySQL
:
class
DBServer_MySQL
:
public
DBServer
public
DBServer
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
8ff38cde
...
@@ -117,7 +117,7 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -117,7 +117,7 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_
n
sec='"
<<
cem
->
sensor_time
.
tv_nsec
<<
" '"
;
<<
" AND time_
u
sec='"
<<
cem
->
sensor_time
.
tv_nsec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -259,7 +259,7 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -259,7 +259,7 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
<<
endl
;
<<
endl
;
}
}
// (date, time, time_
n
sec, sensor_id, value, node)
// (date, time, time_
u
sec, sensor_id, value, node)
PostgreSQLInterface
::
Record
rec
=
PostgreSQLInterface
::
Record
rec
=
{
{
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
),
// date
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
),
// date
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.h
View file @
8ff38cde
...
@@ -44,6 +44,9 @@
...
@@ -44,6 +44,9 @@
* И второе, т.к. это vector - то идёт выделение "непрерывного куска памяти", поэтому у ОС могут
* И второе, т.к. это vector - то идёт выделение "непрерывного куска памяти", поэтому у ОС могут
* быть проблеммы найти "большой непрерывный кусок".
* быть проблеммы найти "большой непрерывный кусок".
* Тем не менее реализация сделана на vector-е чтобы избежать лишних "перевыделений" (и сегментации) памяти во время работы.
* Тем не менее реализация сделана на vector-е чтобы избежать лишних "перевыделений" (и сегментации) памяти во время работы.
*
* \warning Временно, для обратной совместимости поле 'time_usec' в таблицах оставлено с таким названием,
* хотя фактически туда сейчас сохраняется значение в наносекундах!
*/
*/
class
DBServer_PostgreSQL
:
class
DBServer_PostgreSQL
:
public
DBServer
public
DBServer
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
8ff38cde
...
@@ -103,7 +103,7 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -103,7 +103,7 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_
n
sec='"
<<
cem
->
sensor_time
.
tv_nsec
<<
" '"
;
<<
" AND time_
u
sec='"
<<
cem
->
sensor_time
.
tv_nsec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -197,11 +197,11 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -197,11 +197,11 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
// см. DBTABLE AnalogSensors, DigitalSensors
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream
data
;
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
data
<<
"INSERT INTO "
<<
tblName
(
si
->
type
)
<<
"(date, time, time_
n
sec, sensor_id, value, node) VALUES( '"
<<
"(date, time, time_
u
sec, sensor_id, value, node) VALUES( '"
// Поля таблицы
// Поля таблицы
<<
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
dateToString
(
si
->
sm_tv
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
si
->
sm_tv
.
tv_sec
,
":"
)
<<
"','"
// time
<<
timeToString
(
si
->
sm_tv
.
tv_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv
.
tv_nsec
<<
"',"
// time_
n
sec
<<
si
->
sm_tv
.
tv_nsec
<<
"',"
// time_
u
sec
<<
si
->
id
<<
"','"
// sensor_id
<<
si
->
id
<<
"','"
// sensor_id
<<
val
<<
"','"
// value
<<
val
<<
"','"
// value
<<
si
->
node
<<
"')"
;
// node
<<
si
->
node
<<
"')"
;
// node
...
...
extensions/DBServer-SQLite/DBServer_SQLite.h
View file @
8ff38cde
...
@@ -127,6 +127,9 @@ CREATE TABLE `main_emergencyrecords` (
...
@@ -127,6 +127,9 @@ CREATE TABLE `main_emergencyrecords` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\endcode
\endcode
\warning Временно, для обратной совместимости поле 'time_usec' в таблицах оставлено с таким названием,
хотя фактически туда сейчас сохраняется значение в наносекундах!
*/
*/
class
DBServer_SQLite
:
class
DBServer_SQLite
:
public
DBServer
public
DBServer
...
...
include/MessageType.h
View file @
8ff38cde
...
@@ -241,7 +241,7 @@ namespace UniSetTypes
...
@@ -241,7 +241,7 @@ namespace UniSetTypes
ObjectId
sensor_id
;
/* ID датчика (события) */
ObjectId
sensor_id
;
/* ID датчика (события) */
double
sensor_value
;
/* значение датчика (события) */
double
sensor_value
;
/* значение датчика (события) */
struct
timespec
sensor_time
;
/* время срабат
вание
датчика(события), который квитируем */
struct
timespec
sensor_time
;
/* время срабат
ывания
датчика(события), который квитируем */
struct
timespec
confirm_time
;
/* время, когда произошло квитирование */
struct
timespec
confirm_time
;
/* время, когда произошло квитирование */
bool
broadcast
;
bool
broadcast
;
...
...
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