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
6a27d830
Commit
6a27d830
authored
Aug 19, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Глобальный переход от microseconds --> nanoseconds
[timeval --> timespec, gettimeofday --> clock_gettime] ТРЕБУЕТСЯ КОНВЕРТИРОВАНИЕ БД! т.к. поле 'time_usec' меняется на 'time_nsec'
parent
0b8286f5
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
101 additions
and
117 deletions
+101
-117
IOController_i.idl
IDL/Processes/IOController_i.idl
+8
-6
configure.ac
configure.ac
+1
-1
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+11
-6
DBServer_MySQL.h
extensions/DBServer-MySQL/DBServer_MySQL.h
+3
-3
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+12
-13
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+11
-6
DBServer_SQLite.h
extensions/DBServer-SQLite/DBServer_SQLite.h
+3
-3
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+6
-6
IOBase.h
extensions/include/IOBase.h
+1
-1
IOController.h
include/IOController.h
+2
-2
IONotifyController.h
include/IONotifyController.h
+1
-1
MessageType.h
include/MessageType.h
+5
-7
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+2
-2
IOController.cc
src/Processes/IOController.cc
+7
-13
IONotifyController.cc
src/Processes/IONotifyController.cc
+11
-16
Makefile.am
src/Processes/Makefile.am
+1
-1
MessageType.cc
src/Various/MessageType.cc
+7
-21
SMonitor.cc
src/Various/SMonitor.cc
+3
-3
test_messagetype.cc
tests/test_messagetype.cc
+6
-6
No files found.
IDL/Processes/IOController_i.idl
View file @
6a27d830
...
@@ -103,8 +103,8 @@ interface IOController_i : UniSetManager_i
...
@@ -103,8 +103,8 @@ interface IOController_i : UniSetManager_i
IOController_i
::
SensorInfo
si
;
IOController_i
::
SensorInfo
si
;
long
default_val
; /*!< значение по умолчанию */
long
default_val
; /*!< значение по умолчанию */
CalibrateInfo
ci
; /*!< калибровочные параметры */
CalibrateInfo
ci
; /*!< калибровочные параметры */
long
tv_sec
; /*!< время последнего изменения датчика, секунды (gettimeofday
) */
unsigned
long
tv_sec
; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME
) */
long
tv_usec
; /*!< время последнего изменения датчика, мксек (gettimeofday
) */
unsigned
long
tv_nsec
; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME
) */
UniSetTypes
::
ObjectId
supplier
; /*!< идентификатор объекта изменившего состояние датчика */
UniSetTypes
::
ObjectId
supplier
; /*!< идентификатор объекта изменившего состояние датчика */
boolean
dbignore
; /*!< не сохранять изменения в БД */
boolean
dbignore
; /*!< не сохранять изменения в БД */
}
;
}
;
...
@@ -140,8 +140,10 @@ interface IOController_i : UniSetManager_i
...
@@ -140,8 +140,10 @@ interface IOController_i : UniSetManager_i
struct
ShortIOInfo
struct
ShortIOInfo
{
{
long
value
;
long
value
;
long
tv_sec
; /*!< время последнего изменения датчика, секунды (gettimeofday) */
long
tv_usec
; /*!< время последнего изменения датчика, мксек (gettimeofday) */
//
могут
быть
проблеммы
в
64b
it
-
ных
unsigned
long
tv_sec
; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME) */
unsigned
long
tv_nsec
; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME) */
UniSetTypes
::
ObjectId
supplier
; /*!< идентификатор того, кто менял датчик (последний раз) */
UniSetTypes
::
ObjectId
supplier
; /*!< идентификатор того, кто менял датчик (последний раз) */
}
;
}
;
...
@@ -207,8 +209,8 @@ interface IONotifyController_i : IOController_i
...
@@ -207,8 +209,8 @@ interface IONotifyController_i : IOController_i
long
hilimit
; /*!< верхняя граница срабатывания */
long
hilimit
; /*!< верхняя граница срабатывания */
long
lowlimit
; /*!< нижняя гранийа срабатывания */
long
lowlimit
; /*!< нижняя гранийа срабатывания */
ThresholdState
state
;
ThresholdState
state
;
long
tv_sec
; /*!< время последнего изменения датчика, секунды (gettimeofday
) */
unsigned
long
tv_sec
; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME
) */
long
tv_usec
; /*!< время последнего изменения датчика, мксек (gettimeofday
) */
unsigned
long
tv_nsec
; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME
) */
boolean
invert
; /*!< инвертированная логика */
boolean
invert
; /*!< инвертированная логика */
}
;
}
;
...
...
configure.ac
View file @
6a27d830
...
@@ -317,7 +317,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
...
@@ -317,7 +317,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
# export
# export
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${COMCPP_LIBS}"
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${COMCPP_LIBS}"
# all developer liked options add to autogen.sh, please
# all developer liked options add to autogen.sh, please
CXXFLAGS="
$CXXFLAGS -funsigned-char -std=c++11 -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${COMCPP_CFLAGS} -I\$(top_builddir)/include
$CXX_EXTRA_FLAGS"
CXXFLAGS="
-I\$(top_builddir)/include $CXXFLAGS -funsigned-char -std=c++11 -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${COMCPP_CFLAGS}
$CXX_EXTRA_FLAGS"
AC_SUBST(LDFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(CXXFLAGS)
...
...
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
6a27d830
...
@@ -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
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time_
usec='"
<<
cem
->
time_u
sec
<<
" '"
;
<<
" AND time_
nsec='"
<<
cem
->
time_n
sec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -201,7 +201,12 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -201,7 +201,12 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
// если время не было выставлено (указываем время сохранения в БД)
// если время не было выставлено (указываем время сохранения в БД)
if
(
!
si
->
tm
.
tv_sec
)
if
(
!
si
->
tm
.
tv_sec
)
{
{
gettimeofday
(
const_cast
<
struct
timeval
*>
(
&
si
->
tm
),
NULL
);
// Выдаём CRIT, но тем не менее сохраняем в БД
dbcrit
<<
myname
<<
"(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<<
" for sid="
<<
si
->
id
<<
" supplier="
<<
uniset_conf
()
->
oind
->
getMapName
(
si
->
supplier
)
<<
endl
;
}
}
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
...
@@ -209,11 +214,11 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -209,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_
u
sec, sensor_id, value, node) VALUES( '"
<<
"(date, time, time_
n
sec, sensor_id, value, node) VALUES( '"
// Поля таблицы
// Поля таблицы
<<
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
dateToString
(
si
->
sm_tv
.
tv
_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
"','"
// time
<<
timeToString
(
si
->
sm_tv
.
tv
_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv
_usec
<<
"','"
// time_u
sec
<<
si
->
sm_tv
.
tv_nsec
<<
"','"
// time_n
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 @
6a27d830
...
@@ -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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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,
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
6a27d830
...
@@ -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
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time_
usec='"
<<
cem
->
time_u
sec
<<
" '"
;
<<
" AND time_
nsec='"
<<
cem
->
time_n
sec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -249,23 +249,22 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -249,23 +249,22 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
{
{
try
try
{
{
#if 0
if
(
!
si
->
tm
.
tv_sec
)
// если время не было выставлено (указываем время сохранения в БД)
struct timeval tm = si->tm;
if( !tm.tv_sec )
{
{
struct timezone tz;
// Выдаём CRIT, но тем не менее сохраняем в БД
gettimeofday(&tm, &tz);
dbcrit
<<
myname
<<
"(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<<
" for sid="
<<
si
->
id
<<
" supplier="
<<
uniset_conf
()
->
oind
->
getMapName
(
si
->
supplier
)
<<
endl
;
}
}
#endif
// (date, time, time_nsec, sensor_id, value, node)
// (date, time, time_usec, sensor_id, value, node)
PostgreSQLInterface
::
Record
rec
=
PostgreSQLInterface
::
Record
rec
=
{
{
dateToString
(
si
->
sm_tv_sec
,
"-"
),
// date
dateToString
(
si
->
sm_tv
.
tv
_sec
,
"-"
),
// date
timeToString
(
si
->
sm_tv_sec
,
":"
),
// time
timeToString
(
si
->
sm_tv
.
tv
_sec
,
":"
),
// time
std
::
to_string
(
si
->
sm_tv
_u
sec
),
std
::
to_string
(
si
->
sm_tv
.
tv_n
sec
),
std
::
to_string
(
si
->
id
),
std
::
to_string
(
si
->
id
),
std
::
to_string
(
si
->
value
),
std
::
to_string
(
si
->
value
),
std
::
to_string
(
si
->
node
),
std
::
to_string
(
si
->
node
),
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
6a27d830
...
@@ -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
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time_
usec='"
<<
cem
->
time_u
sec
<<
" '"
;
<<
" AND time_
nsec='"
<<
cem
->
time_n
sec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
@@ -184,7 +184,12 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -184,7 +184,12 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
// если время не было выставлено (указываем время сохранения в БД)
// если время не было выставлено (указываем время сохранения в БД)
if
(
!
si
->
tm
.
tv_sec
)
if
(
!
si
->
tm
.
tv_sec
)
{
{
gettimeofday
(
const_cast
<
struct
timeval
*>
(
&
si
->
tm
),
NULL
);
// Выдаём CRIT, но тем не менее сохраняем в БД
dbcrit
<<
myname
<<
"(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<<
" for sid="
<<
si
->
id
<<
" supplier="
<<
uniset_conf
()
->
oind
->
getMapName
(
si
->
supplier
)
<<
endl
;
}
}
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
float
val
=
(
float
)
si
->
value
/
(
float
)
pow10
(
si
->
ci
.
precision
);
...
@@ -192,11 +197,11 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
...
@@ -192,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_
u
sec, sensor_id, value, node) VALUES( '"
<<
"(date, time, time_
n
sec, sensor_id, value, node) VALUES( '"
// Поля таблицы
// Поля таблицы
<<
dateToString
(
si
->
sm_tv_sec
,
"-"
)
<<
"','"
// date
<<
dateToString
(
si
->
sm_tv
.
tv
_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
"','"
// time
<<
timeToString
(
si
->
sm_tv
.
tv
_sec
,
":"
)
<<
"','"
// time
<<
si
->
sm_tv
_usec
<<
"',"
// time_u
sec
<<
si
->
sm_tv
.
tv_nsec
<<
"',"
// time_n
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 @
6a27d830
...
@@ -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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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_
u
sec` int(10) unsigned NOT NULL,
`time_
n
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,
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
6a27d830
...
@@ -761,13 +761,13 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
...
@@ -761,13 +761,13 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
// return;
// return;
long
value
=
0
;
long
value
=
0
;
long
sm_tv_sec
=
0
;
unsigned
long
sm_tv_sec
=
0
;
long
sm_tv_u
sec
=
0
;
unsigned
long
sm_tv_n
sec
=
0
;
{
{
uniset_rwmutex_rlock
lock
(
usi
->
val_lock
);
uniset_rwmutex_rlock
lock
(
usi
->
val_lock
);
value
=
usi
->
value
;
value
=
usi
->
value
;
sm_tv_sec
=
usi
->
tv_sec
;
sm_tv_sec
=
usi
->
tv_sec
;
sm_tv_
usec
=
usi
->
tv_u
sec
;
sm_tv_
nsec
=
usi
->
tv_n
sec
;
}
}
sminfo
<<
myname
<<
"(updateHistory): "
sminfo
<<
myname
<<
"(updateHistory): "
...
@@ -792,7 +792,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
...
@@ -792,7 +792,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_usec
=
sm_tv_
u
sec
;
it
->
fuse_usec
=
sm_tv_
n
sec
;
m_historySignal
.
emit
(
(
*
it
)
);
m_historySignal
.
emit
(
(
*
it
)
);
}
}
}
}
...
@@ -811,7 +811,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
...
@@ -811,7 +811,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_usec
=
sm_tv_
u
sec
;
it
->
fuse_usec
=
sm_tv_
n
sec
;
m_historySignal
.
emit
(
(
*
it
)
);
m_historySignal
.
emit
(
(
*
it
)
);
}
}
}
}
...
@@ -822,7 +822,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
...
@@ -822,7 +822,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
sminfo
<<
myname
<<
"(updateHistory): HISTORY EVENT for "
<<
(
*
it
)
<<
endl
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_sec
=
sm_tv_sec
;
it
->
fuse_usec
=
sm_tv_
u
sec
;
it
->
fuse_usec
=
sm_tv_
n
sec
;
m_historySignal
.
emit
(
(
*
it
)
);
m_historySignal
.
emit
(
(
*
it
)
);
}
}
}
}
...
...
extensions/include/IOBase.h
View file @
6a27d830
...
@@ -85,7 +85,7 @@ struct IOBase
...
@@ -85,7 +85,7 @@ struct IOBase
ti
.
id
=
UniSetTypes
::
DefaultObjectId
;
ti
.
id
=
UniSetTypes
::
DefaultObjectId
;
ti
.
state
=
IONotifyController_i
::
NormalThreshold
;
ti
.
state
=
IONotifyController_i
::
NormalThreshold
;
ti
.
tv_sec
=
0
;
ti
.
tv_sec
=
0
;
ti
.
tv_
u
sec
=
0
;
ti
.
tv_
n
sec
=
0
;
}
}
bool
check_channel_break
(
long
val
);
/*!< проверка обрыва провода */
bool
check_channel_break
(
long
val
);
/*!< проверка обрыва провода */
...
...
include/IOController.h
View file @
6a27d830
...
@@ -326,8 +326,8 @@ class IOController:
...
@@ -326,8 +326,8 @@ class IOController:
{
{
UniSetTypes
::
uniset_rwmutex_rlock
lock
(
val_lock
);
UniSetTypes
::
uniset_rwmutex_rlock
lock
(
val_lock
);
sm
.
value
=
value
;
sm
.
value
=
value
;
sm
.
sm_tv_sec
=
tv_sec
;
sm
.
sm_tv
.
tv
_sec
=
tv_sec
;
sm
.
sm_tv
_usec
=
tv_u
sec
;
sm
.
sm_tv
.
tv_nsec
=
tv_n
sec
;
sm
.
ci
=
ci
;
sm
.
ci
=
ci
;
sm
.
supplier
=
supplier
;
sm
.
supplier
=
supplier
;
sm
.
undefined
=
undefined
;
sm
.
undefined
=
undefined
;
...
...
include/IONotifyController.h
View file @
6a27d830
...
@@ -237,7 +237,7 @@ class IONotifyController:
...
@@ -237,7 +237,7 @@ class IONotifyController:
r
.
lowlimit
=
lowlimit
;
r
.
lowlimit
=
lowlimit
;
r
.
invert
=
invert
;
r
.
invert
=
invert
;
r
.
tv_sec
=
tv_sec
;
r
.
tv_sec
=
tv_sec
;
r
.
tv_
usec
=
tv_u
sec
;
r
.
tv_
nsec
=
tv_n
sec
;
r
.
state
=
state
;
r
.
state
=
state
;
return
r
;
return
r
;
}
}
...
...
include/MessageType.h
View file @
6a27d830
...
@@ -56,8 +56,7 @@ namespace UniSetTypes
...
@@ -56,8 +56,7 @@ namespace UniSetTypes
ObjectId
node
=
{
UniSetTypes
::
DefaultObjectId
};
// откуда
ObjectId
node
=
{
UniSetTypes
::
DefaultObjectId
};
// откуда
ObjectId
supplier
=
{
UniSetTypes
::
DefaultObjectId
};
// от кого
ObjectId
supplier
=
{
UniSetTypes
::
DefaultObjectId
};
// от кого
ObjectId
consumer
=
{
UniSetTypes
::
DefaultObjectId
};
// кому
ObjectId
consumer
=
{
UniSetTypes
::
DefaultObjectId
};
// кому
struct
timeval
tm
=
{
0
,
0
};
struct
timespec
tm
=
{
0
,
0
};
Message
(
Message
&&
)
=
default
;
Message
(
Message
&&
)
=
default
;
Message
&
operator
=
(
Message
&&
)
=
default
;
Message
&
operator
=
(
Message
&&
)
=
default
;
...
@@ -106,7 +105,7 @@ namespace UniSetTypes
...
@@ -106,7 +105,7 @@ namespace UniSetTypes
if
(
tm
.
tv_sec
!=
msg
.
tm
.
tv_sec
)
if
(
tm
.
tv_sec
!=
msg
.
tm
.
tv_sec
)
return
tm
.
tv_sec
>=
msg
.
tm
.
tv_sec
;
return
tm
.
tv_sec
>=
msg
.
tm
.
tv_sec
;
return
tm
.
tv_
usec
>=
msg
.
tm
.
tv_u
sec
;
return
tm
.
tv_
nsec
>=
msg
.
tm
.
tv_n
sec
;
}
}
inline
TransportMessage
transport_msg
()
const
inline
TransportMessage
transport_msg
()
const
...
@@ -127,8 +126,7 @@ namespace UniSetTypes
...
@@ -127,8 +126,7 @@ namespace UniSetTypes
bool
undefined
;
bool
undefined
;
// время изменения состояния датчика
// время изменения состояния датчика
long
sm_tv_sec
;
struct
timespec
sm_tv
;
long
sm_tv_usec
;
UniversalIO
::
IOType
sensor_type
;
UniversalIO
::
IOType
sensor_type
;
IOController_i
::
CalibrateInfo
ci
;
IOController_i
::
CalibrateInfo
ci
;
...
@@ -233,7 +231,7 @@ namespace UniSetTypes
...
@@ -233,7 +231,7 @@ namespace UniSetTypes
ConfirmMessage
(
ObjectId
in_sensor_id
,
ConfirmMessage
(
ObjectId
in_sensor_id
,
double
in_value
,
double
in_value
,
time_t
in_time
,
time_t
in_time
,
time_t
in_time_
u
sec
,
time_t
in_time_
n
sec
,
time_t
in_confirm
,
time_t
in_confirm
,
Priority
in_priority
=
Message
::
Medium
);
Priority
in_priority
=
Message
::
Medium
);
...
@@ -245,7 +243,7 @@ namespace UniSetTypes
...
@@ -245,7 +243,7 @@ namespace UniSetTypes
ObjectId
sensor_id
;
/* ID датчика */
ObjectId
sensor_id
;
/* ID датчика */
double
value
;
/* значение датчика */
double
value
;
/* значение датчика */
time_t
time
;
/* время, когда датчик получил сигнал */
time_t
time
;
/* время, когда датчик получил сигнал */
time_t
time_
usec
;
/* время в микр
осекундах */
time_t
time_
nsec
;
/* время в нан
осекундах */
time_t
confirm
;
/* время, когда произошло квитирование */
time_t
confirm
;
/* время, когда произошло квитирование */
bool
broadcast
;
bool
broadcast
;
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
6a27d830
...
@@ -539,7 +539,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
...
@@ -539,7 +539,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
<<
" lowlim="
<<
ti
.
lowlimit
<<
" lowlim="
<<
ti
.
lowlimit
<<
" state="
<<
ti
.
state
<<
" state="
<<
ti
.
state
<<
" tv_sec="
<<
ti
.
tv_sec
<<
" tv_sec="
<<
ti
.
tv_sec
<<
" tv_
usec="
<<
ti
.
tv_u
sec
<<
" tv_
nsec="
<<
ti
.
tv_n
sec
<<
" invert="
<<
ti
.
invert
<<
" invert="
<<
ti
.
invert
<<
" ]"
;
<<
" ]"
;
...
@@ -549,7 +549,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
...
@@ -549,7 +549,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
std
::
ostream
&
UniSetTypes
::
operator
<<
(
std
::
ostream
&
os
,
const
IOController_i
::
ShortIOInfo
&
s
)
std
::
ostream
&
UniSetTypes
::
operator
<<
(
std
::
ostream
&
os
,
const
IOController_i
::
ShortIOInfo
&
s
)
{
{
os
<<
setw
(
10
)
<<
dateToString
(
s
.
tv_sec
)
os
<<
setw
(
10
)
<<
dateToString
(
s
.
tv_sec
)
<<
" "
<<
setw
(
8
)
<<
timeToString
(
s
.
tv_sec
)
<<
"."
<<
s
.
tv_
u
sec
<<
" "
<<
setw
(
8
)
<<
timeToString
(
s
.
tv_sec
)
<<
"."
<<
s
.
tv_
n
sec
<<
" [ value="
<<
s
.
value
<<
" supplier="
<<
s
.
supplier
<<
" ]"
;
<<
" [ value="
<<
s
.
value
<<
" supplier="
<<
s
.
supplier
<<
" ]"
;
return
os
;
return
os
;
...
...
src/Processes/IOController.cc
View file @
6a27d830
...
@@ -304,12 +304,10 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
...
@@ -304,12 +304,10 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
usi
->
value
=
(
blocked
?
usi
->
d_off_value
:
value
);
usi
->
value
=
(
blocked
?
usi
->
d_off_value
:
value
);
// запоминаем время изменения
// запоминаем время изменения
struct
timeval
tm
=
{
0
};
struct
timespec
tm
;
tm
.
tv_sec
=
0
;
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
usi
->
tv_sec
=
tm
.
tv_sec
;
usi
->
tv_sec
=
tm
.
tv_sec
;
usi
->
tv_
usec
=
tm
.
tv_u
sec
;
usi
->
tv_
nsec
=
tm
.
tv_n
sec
;
}
}
}
// unlock
}
// unlock
...
@@ -376,12 +374,10 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
...
@@ -376,12 +374,10 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
IOStateList
::
mapped_type
ai
=
usi
;
IOStateList
::
mapped_type
ai
=
usi
;
// запоминаем начальное время
// запоминаем начальное время
struct
timeval
tm
;
struct
timespec
tm
;
tm
.
tv_sec
=
0
;
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
ai
->
tv_sec
=
tm
.
tv_sec
;
ai
->
tv_sec
=
tm
.
tv_sec
;
ai
->
tv_
usec
=
tm
.
tv_u
sec
;
ai
->
tv_
nsec
=
tm
.
tv_n
sec
;
ai
->
value
=
ai
->
default_val
;
ai
->
value
=
ai
->
default_val
;
ai
->
supplier
=
getId
();
ai
->
supplier
=
getId
();
...
@@ -426,8 +422,6 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
...
@@ -426,8 +422,6 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
try
try
{
{
// struct timezone tz;
// gettimeofday(&sm.tm,&tz);
ObjectId
dbID
=
uniset_conf
()
->
getDBServer
();
ObjectId
dbID
=
uniset_conf
()
->
getDBServer
();
// значит на этом узле нет DBServer-а
// значит на этом узле нет DBServer-а
...
@@ -701,7 +695,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( UniSetTypes::ObjectId
...
@@ -701,7 +695,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( UniSetTypes::ObjectId
uniset_rwmutex_rlock
lock
(
s
->
val_lock
);
uniset_rwmutex_rlock
lock
(
s
->
val_lock
);
i
.
value
=
s
->
value
;
i
.
value
=
s
->
value
;
i
.
tv_sec
=
s
->
tv_sec
;
i
.
tv_sec
=
s
->
tv_sec
;
i
.
tv_
usec
=
s
->
tv_u
sec
;
i
.
tv_
nsec
=
s
->
tv_n
sec
;
i
.
supplier
=
s
->
supplier
;
i
.
supplier
=
s
->
supplier
;
return
i
;
return
i
;
}
}
...
...
src/Processes/IONotifyController.cc
View file @
6a27d830
...
@@ -316,8 +316,8 @@ void IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
...
@@ -316,8 +316,8 @@ void IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
sm
.
priority
=
(
Message
::
Priority
)
usi
->
priority
;
sm
.
priority
=
(
Message
::
Priority
)
usi
->
priority
;
sm
.
supplier
=
sup_id
;
// owner_id
sm
.
supplier
=
sup_id
;
// owner_id
sm
.
sensor_type
=
usi
->
type
;
sm
.
sensor_type
=
usi
->
type
;
sm
.
sm_tv_sec
=
usi
->
tv_sec
;
sm
.
sm_tv
.
tv
_sec
=
usi
->
tv_sec
;
sm
.
sm_tv
_usec
=
usi
->
tv_u
sec
;
sm
.
sm_tv
.
tv_nsec
=
usi
->
tv_n
sec
;
sm
.
ci
=
usi
->
ci
;
sm
.
ci
=
usi
->
ci
;
}
// unlock
}
// unlock
...
@@ -648,12 +648,10 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&&
...
@@ -648,12 +648,10 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&&
addConsumer
(
ti
.
clst
,
ci
);
addConsumer
(
ti
.
clst
,
ci
);
// запоминаем начальное время
// запоминаем начальное время
struct
timeval
tm
;
struct
timespec
tm
;
tm
.
tv_sec
=
0
;
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
ti
.
tv_sec
=
tm
.
tv_sec
;
ti
.
tv_sec
=
tm
.
tv_sec
;
ti
.
tv_
usec
=
tm
.
tv_u
sec
;
ti
.
tv_
nsec
=
tm
.
tv_n
sec
;
lst
.
emplace_back
(
std
::
move
(
ti
)
);
lst
.
emplace_back
(
std
::
move
(
ti
)
);
return
true
;
return
true
;
...
@@ -716,10 +714,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
...
@@ -716,10 +714,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
SensorMessage
sm
(
std
::
move
(
usi
->
makeSensorMessage
()));
SensorMessage
sm
(
std
::
move
(
usi
->
makeSensorMessage
()));
// текущее время
// текущее время
struct
timeval
tm
;
struct
timespec
tm
;
tm
.
tv_sec
=
0
;
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
{
{
uniset_rwmutex_rlock
l
(
ti
->
mut
);
uniset_rwmutex_rlock
l
(
ti
->
mut
);
...
@@ -761,9 +757,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
...
@@ -761,9 +757,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
// запоминаем время изменения состояния
// запоминаем время изменения состояния
it
->
tv_sec
=
tm
.
tv_sec
;
it
->
tv_sec
=
tm
.
tv_sec
;
it
->
tv_usec
=
tm
.
tv_usec
;
it
->
tv_nsec
=
tm
.
tv_nsec
;
sm
.
sm_tv_sec
=
tm
.
tv_sec
;
sm
.
sm_tv
=
tm
;
sm
.
sm_tv_usec
=
tm
.
tv_usec
;
// если порог связан с датчиком, то надо его выставить
// если порог связан с датчиком, то надо его выставить
if
(
it
->
sid
!=
UniSetTypes
::
DefaultObjectId
)
if
(
it
->
sid
!=
UniSetTypes
::
DefaultObjectId
)
...
@@ -889,7 +884,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
...
@@ -889,7 +884,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
res
->
tlist
[
k
].
lowlimit
=
it2
.
lowlimit
;
res
->
tlist
[
k
].
lowlimit
=
it2
.
lowlimit
;
res
->
tlist
[
k
].
state
=
it2
.
state
;
res
->
tlist
[
k
].
state
=
it2
.
state
;
res
->
tlist
[
k
].
tv_sec
=
it2
.
tv_sec
;
res
->
tlist
[
k
].
tv_sec
=
it2
.
tv_sec
;
res
->
tlist
[
k
].
tv_
usec
=
it2
.
tv_u
sec
;
res
->
tlist
[
k
].
tv_
nsec
=
it2
.
tv_n
sec
;
k
++
;
k
++
;
}
}
...
@@ -943,7 +938,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
...
@@ -943,7 +938,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
(
*
res
)[
i
].
tlist
[
k
].
lowlimit
=
it2
.
lowlimit
;
(
*
res
)[
i
].
tlist
[
k
].
lowlimit
=
it2
.
lowlimit
;
(
*
res
)[
i
].
tlist
[
k
].
state
=
it2
.
state
;
(
*
res
)[
i
].
tlist
[
k
].
state
=
it2
.
state
;
(
*
res
)[
i
].
tlist
[
k
].
tv_sec
=
it2
.
tv_sec
;
(
*
res
)[
i
].
tlist
[
k
].
tv_sec
=
it2
.
tv_sec
;
(
*
res
)[
i
].
tlist
[
k
].
tv_
usec
=
it2
.
tv_u
sec
;
(
*
res
)[
i
].
tlist
[
k
].
tv_
nsec
=
it2
.
tv_n
sec
;
k
++
;
k
++
;
}
}
...
...
src/Processes/Makefile.am
View file @
6a27d830
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
############################################################################
############################################################################
noinst_LTLIBRARIES
=
libProcesses.la
noinst_LTLIBRARIES
=
libProcesses.la
libProcesses_la_CXXFLAGS
=
$(SIGC_CFLAGS)
$(EV_CFLAGS)
libProcesses_la_CXXFLAGS
=
-I
$(top_builddir)
/include
$(SIGC_CFLAGS)
$(EV_CFLAGS)
libProcesses_la_LIBADD
=
$(SIGC_LIBS)
$(EV_LIBS)
libProcesses_la_LIBADD
=
$(SIGC_LIBS)
$(EV_LIBS)
libProcesses_la_SOURCES
=
IOController_iSK.cc IOController.cc IONotifyController.cc
\
libProcesses_la_SOURCES
=
IOController_iSK.cc IOController.cc IONotifyController.cc
\
NCRestorer.cc NCRestorer_XML.cc EventLoopServer.cc CommonEventLoop.cc
NCRestorer.cc NCRestorer_XML.cc EventLoopServer.cc CommonEventLoop.cc
...
...
src/Various/MessageType.cc
View file @
6a27d830
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
*/
*/
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
#include <chrono>
#include <unistd.h>
#include <unistd.h>
#include <time.h>
#include <time.h>
#include <sys/time.h>
#include <sys/time.h>
...
@@ -56,21 +57,9 @@ namespace UniSetTypes
...
@@ -56,21 +57,9 @@ namespace UniSetTypes
supplier
(
DefaultObjectId
),
supplier
(
DefaultObjectId
),
consumer
(
DefaultObjectId
)
consumer
(
DefaultObjectId
)
{
{
tm
.
tv_sec
=
0
;
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
.
tv_usec
=
0
;
gettimeofday
(
&
tm
,
NULL
);
}
}
/*
template<class In>
TransportMessage Message::transport(const In &msg)
{
TransportMessage tmsg;
assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(msg));
memcpy(&tmsg.data,&msg,sizeof(msg));
return tmsg;
}
*/
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
VoidMessage
::
VoidMessage
(
const
TransportMessage
&
tm
)
:
VoidMessage
::
VoidMessage
(
const
TransportMessage
&
tm
)
:
...
@@ -95,10 +84,8 @@ namespace UniSetTypes
...
@@ -95,10 +84,8 @@ namespace UniSetTypes
threshold
(
false
),
threshold
(
false
),
tid
(
UniSetTypes
::
DefaultThresholdId
)
tid
(
UniSetTypes
::
DefaultThresholdId
)
{
{
type
=
Message
::
SensorInfo
;
type
=
Message
::
SensorInfo
;
sm_tv_sec
=
tm
.
tv_sec
;
sm_tv
=
tm
;
// или инициализировать нулём ?
sm_tv_usec
=
tm
.
tv_usec
;
ci
.
minRaw
=
0
;
ci
.
minRaw
=
0
;
ci
.
maxRaw
=
0
;
ci
.
maxRaw
=
0
;
ci
.
minCal
=
0
;
ci
.
minCal
=
0
;
...
@@ -120,8 +107,7 @@ namespace UniSetTypes
...
@@ -120,8 +107,7 @@ namespace UniSetTypes
type
=
Message
::
SensorInfo
;
type
=
Message
::
SensorInfo
;
this
->
priority
=
priority
;
this
->
priority
=
priority
;
this
->
consumer
=
consumer
;
this
->
consumer
=
consumer
;
sm_tv_sec
=
tm
.
tv_sec
;
sm_tv
=
tm
;
sm_tv_usec
=
tm
.
tv_usec
;
}
}
SensorMessage
::
SensorMessage
(
const
VoidMessage
*
msg
)
:
SensorMessage
::
SensorMessage
(
const
VoidMessage
*
msg
)
:
...
@@ -212,13 +198,13 @@ namespace UniSetTypes
...
@@ -212,13 +198,13 @@ namespace UniSetTypes
ConfirmMessage
::
ConfirmMessage
(
UniSetTypes
::
ObjectId
in_sensor_id
,
ConfirmMessage
::
ConfirmMessage
(
UniSetTypes
::
ObjectId
in_sensor_id
,
double
in_value
,
double
in_value
,
time_t
in_time
,
time_t
in_time
,
time_t
in_time_
u
sec
,
time_t
in_time_
n
sec
,
time_t
in_confirm
,
time_t
in_confirm
,
Priority
in_priority
)
:
Priority
in_priority
)
:
sensor_id
(
in_sensor_id
),
sensor_id
(
in_sensor_id
),
value
(
in_value
),
value
(
in_value
),
time
(
in_time
),
time
(
in_time
),
time_
usec
(
in_time_u
sec
),
time_
nsec
(
in_time_n
sec
),
confirm
(
in_confirm
),
confirm
(
in_confirm
),
broadcast
(
false
),
broadcast
(
false
),
route
(
false
)
route
(
false
)
...
...
src/Various/SMonitor.cc
View file @
6a27d830
...
@@ -111,8 +111,8 @@ void SMonitor::sensorInfo( const SensorMessage* si )
...
@@ -111,8 +111,8 @@ void SMonitor::sensorInfo( const SensorMessage* si )
cout
<<
"("
<<
setw
(
6
)
<<
si
->
id
<<
"):"
cout
<<
"("
<<
setw
(
6
)
<<
si
->
id
<<
"):"
<<
"[("
<<
std
::
right
<<
setw
(
5
)
<<
si
->
supplier
<<
")"
<<
"[("
<<
std
::
right
<<
setw
(
5
)
<<
si
->
supplier
<<
")"
<<
std
::
left
<<
setw
(
20
)
<<
s_sup
<<
"] "
<<
std
::
left
<<
setw
(
20
)
<<
s_sup
<<
"] "
<<
std
::
right
<<
setw
(
8
)
<<
timeToString
(
si
->
sm_tv_sec
,
":"
)
<<
std
::
right
<<
setw
(
8
)
<<
timeToString
(
si
->
sm_tv
.
tv
_sec
,
":"
)
<<
"("
<<
setw
(
6
)
<<
si
->
sm_tv
_u
sec
<<
"): "
<<
"("
<<
setw
(
6
)
<<
si
->
sm_tv
.
tv_n
sec
<<
"): "
<<
std
::
right
<<
setw
(
45
)
<<
conf
->
oind
->
getMapName
(
si
->
id
)
<<
std
::
right
<<
setw
(
45
)
<<
conf
->
oind
->
getMapName
(
si
->
id
)
<<
" value:"
<<
std
::
right
<<
setw
(
9
)
<<
si
->
value
<<
" value:"
<<
std
::
right
<<
setw
(
9
)
<<
si
->
value
<<
" fvalue:"
<<
std
::
right
<<
setw
(
12
)
<<
(
(
float
)
si
->
value
/
pow
(
10.0
,
si
->
ci
.
precision
)
)
<<
endl
;
<<
" fvalue:"
<<
std
::
right
<<
setw
(
12
)
<<
(
(
float
)
si
->
value
/
pow
(
10.0
,
si
->
ci
.
precision
)
)
<<
endl
;
...
@@ -128,7 +128,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
...
@@ -128,7 +128,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
else
else
cmd
<<
conf
->
getBinDir
()
<<
script
;
cmd
<<
conf
->
getBinDir
()
<<
script
;
cmd
<<
" "
<<
si
->
id
<<
" "
<<
si
->
value
<<
" "
<<
si
->
sm_tv
_sec
<<
" "
<<
si
->
sm_tv_u
sec
;
cmd
<<
" "
<<
si
->
id
<<
" "
<<
si
->
value
<<
" "
<<
si
->
sm_tv
.
tv_sec
<<
" "
<<
si
->
sm_tv
.
tv_n
sec
;
int
ret
=
system
(
cmd
.
str
().
c_str
());
int
ret
=
system
(
cmd
.
str
().
c_str
());
int
res
=
WEXITSTATUS
(
ret
);
int
res
=
WEXITSTATUS
(
ret
);
...
...
tests/test_messagetype.cc
View file @
6a27d830
...
@@ -190,12 +190,12 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -190,12 +190,12 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
ObjectId
sid
=
1
;
ObjectId
sid
=
1
;
double
val
=
100
;
double
val
=
100
;
time_t
t_sec
=
10
;
time_t
t_sec
=
10
;
time_t
t_
u
sec
=
300
;
time_t
t_
n
sec
=
300
;
time_t
t_confirm
=
10
;
time_t
t_confirm
=
10
;
SECTION
(
"Default consturctor"
)
SECTION
(
"Default consturctor"
)
{
{
ConfirmMessage
cm
(
sid
,
val
,
t_sec
,
t_
u
sec
,
t_confirm
);
ConfirmMessage
cm
(
sid
,
val
,
t_sec
,
t_
n
sec
,
t_confirm
);
CHECK
(
cm
.
type
==
Message
::
Confirm
);
CHECK
(
cm
.
type
==
Message
::
Confirm
);
CHECK
(
cm
.
priority
==
Message
::
Medium
);
CHECK
(
cm
.
priority
==
Message
::
Medium
);
CHECK
(
cm
.
node
==
conf
->
getLocalNode
()
);
CHECK
(
cm
.
node
==
conf
->
getLocalNode
()
);
...
@@ -204,7 +204,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -204,7 +204,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
time_
usec
==
t_u
sec
);
REQUIRE
(
cm
.
time_
nsec
==
t_n
sec
);
REQUIRE
(
cm
.
confirm
==
t_confirm
);
REQUIRE
(
cm
.
confirm
==
t_confirm
);
CHECK
(
cm
.
broadcast
==
false
);
CHECK
(
cm
.
broadcast
==
false
);
CHECK
(
cm
.
route
==
false
);
CHECK
(
cm
.
route
==
false
);
...
@@ -212,11 +212,11 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -212,11 +212,11 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
SECTION
(
"Transport ConfirmMessage"
)
SECTION
(
"Transport ConfirmMessage"
)
{
{
ConfirmMessage
cm
(
sid
,
val
,
t_sec
,
t_
u
sec
,
t_confirm
);
ConfirmMessage
cm
(
sid
,
val
,
t_sec
,
t_
n
sec
,
t_confirm
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
time_
usec
==
t_u
sec
);
REQUIRE
(
cm
.
time_
nsec
==
t_n
sec
);
REQUIRE
(
cm
.
confirm
==
t_confirm
);
REQUIRE
(
cm
.
confirm
==
t_confirm
);
auto
tm
=
cm
.
transport_msg
();
auto
tm
=
cm
.
transport_msg
();
...
@@ -228,7 +228,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -228,7 +228,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
REQUIRE
(
cm2
.
sensor_id
==
sid
);
REQUIRE
(
cm2
.
sensor_id
==
sid
);
REQUIRE
(
cm2
.
value
==
val
);
REQUIRE
(
cm2
.
value
==
val
);
REQUIRE
(
cm2
.
time
==
t_sec
);
REQUIRE
(
cm2
.
time
==
t_sec
);
REQUIRE
(
cm2
.
time_
usec
==
t_u
sec
);
REQUIRE
(
cm2
.
time_
nsec
==
t_n
sec
);
REQUIRE
(
cm2
.
confirm
==
t_confirm
);
REQUIRE
(
cm2
.
confirm
==
t_confirm
);
}
}
}
}
...
...
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