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
b4190951
Commit
b4190951
authored
Dec 27, 2012
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SQLite): немного откорректировал реализацию DBServer_SQLite
parent
3519c924
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
9 deletions
+37
-9
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+5
-8
create_db.sh
extensions/DBServer-SQLite/create_db.sh
+32
-1
No files found.
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
b4190951
...
@@ -78,11 +78,14 @@ DBServer_SQLite::~DBServer_SQLite()
...
@@ -78,11 +78,14 @@ DBServer_SQLite::~DBServer_SQLite()
{
{
db
->
close
();
db
->
close
();
delete
db
;
delete
db
;
db
=
0
;
}
}
}
}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
void
DBServer_SQLite
::
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
void
DBServer_SQLite
::
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
{
{
DBServer
::
processingMessage
(
msg
);
switch
(
msg
->
type
)
switch
(
msg
->
type
)
{
{
case
Message
:
:
Timer
:
case
Message
:
:
Timer
:
...
@@ -93,13 +96,14 @@ void DBServer_SQLite::processingMessage( UniSetTypes::VoidMessage *msg )
...
@@ -93,13 +96,14 @@ void DBServer_SQLite::processingMessage( UniSetTypes::VoidMessage *msg )
}
}
default
:
default
:
DBServer
::
processingMessage
(
msg
);
break
;
break
;
}
}
}
}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
void
DBServer_SQLite
::
sysCommand
(
UniSetTypes
::
SystemMessage
*
sm
)
void
DBServer_SQLite
::
sysCommand
(
UniSetTypes
::
SystemMessage
*
sm
)
{
{
DBServer
::
sysCommand
(
sm
);
switch
(
sm
->
command
)
switch
(
sm
->
command
)
{
{
case
SystemMessage
:
:
StartUp
:
case
SystemMessage
:
:
StartUp
:
...
@@ -108,7 +112,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -108,7 +112,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
case
SystemMessage
:
:
Finish
:
case
SystemMessage
:
:
Finish
:
{
{
activate
=
false
;
activate
=
false
;
// db->freeResult();
db
->
close
();
db
->
close
();
}
}
break
;
break
;
...
@@ -116,7 +119,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -116,7 +119,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
FoldUp
:
{
{
activate
=
false
;
activate
=
false
;
// db->freeResult();
db
->
close
();
db
->
close
();
}
}
break
;
break
;
...
@@ -125,7 +127,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -125,7 +127,6 @@ void DBServer_SQLite::sysCommand( UniSetTypes::SystemMessage *sm )
break
;
break
;
}
}
}
}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
void
DBServer_SQLite
::
parse
(
UniSetTypes
::
DBMessage
*
dbm
)
void
DBServer_SQLite
::
parse
(
UniSetTypes
::
DBMessage
*
dbm
)
{
{
...
@@ -155,8 +156,6 @@ void DBServer_SQLite::parse( UniSetTypes::DBMessage* dbm )
...
@@ -155,8 +156,6 @@ void DBServer_SQLite::parse( UniSetTypes::DBMessage* dbm )
if
(
!
writeToBase
(
query
.
str
())
)
if
(
!
writeToBase
(
query
.
str
())
)
{
{
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(update): error: "
<<
db
->
error
()
<<
endl
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(update): error: "
<<
db
->
error
()
<<
endl
;
// if( dbm->qtype == DBMessage::Query )
// db->freeResult();
}
}
}
}
...
@@ -181,7 +180,6 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem )
...
@@ -181,7 +180,6 @@ void DBServer_SQLite::parse( UniSetTypes::ConfirmMessage* cem )
{
{
if
(
unideb
.
debugging
(
Debug
::
CRIT
)
)
if
(
unideb
.
debugging
(
Debug
::
CRIT
)
)
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(update_confirm): db error: "
<<
db
->
error
()
<<
endl
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(update_confirm): db error: "
<<
db
->
error
()
<<
endl
;
// db->freeResult();
}
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
...
@@ -278,7 +276,6 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
...
@@ -278,7 +276,6 @@ void DBServer_SQLite::parse( UniSetTypes::SensorMessage *si )
{
{
if
(
unideb
.
debugging
(
Debug
::
CRIT
)
)
if
(
unideb
.
debugging
(
Debug
::
CRIT
)
)
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(insert) sensor msg error: "
<<
db
->
error
()
<<
endl
;
unideb
[
Debug
::
CRIT
]
<<
myname
<<
"(insert) sensor msg error: "
<<
db
->
error
()
<<
endl
;
// db->freeResult();
}
}
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
...
...
extensions/DBServer-SQLite/create_db.sh
View file @
b4190951
...
@@ -25,7 +25,38 @@ INSERT INTO main_history VALUES(NULL,0,0,0,105,20.3,1,0);
...
@@ -25,7 +25,38 @@ INSERT INTO main_history VALUES(NULL,0,0,0,105,20.3,1,0);
INSERT INTO main_history VALUES
(
NULL,0,0,0,106,20.65,1,0
)
;
INSERT INTO main_history VALUES
(
NULL,0,0,0,106,20.65,1,0
)
;
INSERT INTO main_history VALUES
(
NULL,0,0,0,107,20233.7,1,0
)
;
INSERT INTO main_history VALUES
(
NULL,0,0,0,107,20233.7,1,0
)
;
INSERT INTO main_history VALUES
(
NULL,0,0,0,108,245560.67671,1,0
)
;
INSERT INTO main_history VALUES
(
NULL,0,0,0,108,245560.67671,1,0
)
;
DROP TABLE IF EXISTS
`
main_emergencylog
`
;
CREATE TABLE
`
main_emergencylog
`
(
`
id
`
INTEGER PRIMARY KEY AUTOINCREMENT,
`
date
`
date
NOT NULL,
`
time
`
time
NOT NULL,
`
time_usec
`
INTEGER
(
5
)
NOT NULL,
`
type_id
`
INTEGER
(
5
)
NOT NULL,
CONSTRAINT
`
type_id_refs_id_a3133ca
`
FOREIGN KEY
(
`
type_id
`
)
REFERENCES
`
main_emergencytype
`
(
`
id
`
)
)
;
DROP TABLE IF EXISTS
`
main_emergencyrecords
`
;
CREATE TABLE
`
main_emergencyrecords
`
(
`
id
`
INTEGER PRIMARY KEY AUTOINCREMENT,
`
date
`
date
NOT NULL,
`
time
`
time
NOT NULL,
`
time_usec
`
INTEGER
(
10
)
NOT NULL,
`
log_id
`
INTEGER
(
11
)
NOT NULL,
`
sensor_id
`
INTEGER
(
10
)
NOT NULL,
`
value
`
double NOT NULL,
CONSTRAINT
`
log_id_refs_id_77a37ea9
`
FOREIGN KEY
(
`
log_id
`
)
REFERENCES
`
main_emergencylog
`
(
`
id
`
)
,
CONSTRAINT
`
sensor_id_refs_id_436bab5e
`
FOREIGN KEY
(
`
sensor_id
`
)
REFERENCES
`
main_sensor
`
(
`
id
`
)
)
;
_EOF_
_EOF_
#
# KEY `main_emergencyrecords_log_id` (`log_id`),
# KEY `main_emergencyrecords_sensor_id` (`sensor_id`),
#
KEY main_history_sensor_id (sensor_id)
# KEY main_history_sensor_id (sensor_id)
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