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
7f787ab6
Commit
7f787ab6
authored
Aug 19, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил реализацию получения времени (сек,наносек) через std::chrono
(и ряд вспомогательных функций в UniSetTypes).
parent
6a27d830
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
143 additions
and
63 deletions
+143
-63
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+4
-4
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+4
-4
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+4
-4
MessageType.h
include/MessageType.h
+8
-10
UniSetTypes.h
include/UniSetTypes.h
+14
-4
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+38
-0
IOController.cc
src/Processes/IOController.cc
+2
-4
IONotifyController.cc
src/Processes/IONotifyController.cc
+2
-4
MessageType.cc
src/Various/MessageType.cc
+9
-11
develop.cc
tests/develop.cc
+30
-0
test_messagetype.cc
tests/test_messagetype.cc
+14
-18
test_utypes.cc
tests/test_utypes.cc
+14
-0
No files found.
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
7f787ab6
...
@@ -102,11 +102,11 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -102,11 +102,11 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
ostringstream
data
;
ostringstream
data
;
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
<<
" SET confirm='"
<<
cem
->
confirm
<<
"'"
<<
" SET confirm='"
<<
cem
->
confirm
_time
.
tv_sec
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_nsec='"
<<
cem
->
time
_nsec
<<
" '"
;
<<
" AND time_nsec='"
<<
cem
->
sensor_time
.
tv
_nsec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
7f787ab6
...
@@ -113,11 +113,11 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -113,11 +113,11 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
ostringstream
data
;
ostringstream
data
;
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
<<
" SET confirm='"
<<
cem
->
confirm
<<
"'"
<<
" SET confirm='"
<<
cem
->
confirm
_time
.
tv_sec
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_nsec='"
<<
cem
->
time
_nsec
<<
" '"
;
<<
" AND time_nsec='"
<<
cem
->
sensor_time
.
tv
_nsec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
7f787ab6
...
@@ -99,11 +99,11 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
...
@@ -99,11 +99,11 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
ostringstream
data
;
ostringstream
data
;
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
data
<<
"UPDATE "
<<
tblName
(
cem
->
type
)
<<
" SET confirm='"
<<
cem
->
confirm
<<
"'"
<<
" SET confirm='"
<<
cem
->
confirm
_time
.
tv_sec
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" WHERE sensor_id='"
<<
cem
->
sensor_id
<<
"'"
<<
" AND date='"
<<
dateToString
(
cem
->
time
,
"-"
)
<<
" '"
<<
" AND date='"
<<
dateToString
(
cem
->
sensor_time
.
tv_sec
,
"-"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
time
,
":"
)
<<
" '"
<<
" AND time='"
<<
timeToString
(
cem
->
sensor_time
.
tv_sec
,
":"
)
<<
" '"
<<
" AND time_nsec='"
<<
cem
->
time
_nsec
<<
" '"
;
<<
" AND time_nsec='"
<<
cem
->
sensor_time
.
tv
_nsec
<<
" '"
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
dbinfo
<<
myname
<<
"(update_confirm): "
<<
data
.
str
()
<<
endl
;
...
...
include/MessageType.h
View file @
7f787ab6
...
@@ -229,10 +229,9 @@ namespace UniSetTypes
...
@@ -229,10 +229,9 @@ namespace UniSetTypes
ConfirmMessage
(
const
VoidMessage
*
msg
);
ConfirmMessage
(
const
VoidMessage
*
msg
);
ConfirmMessage
(
ObjectId
in_sensor_id
,
ConfirmMessage
(
ObjectId
in_sensor_id
,
double
in_value
,
double
in_sensor_value
,
time_t
in_time
,
const
timespec
&
in_sensor_time
,
time_t
in_time_nsec
,
const
timespec
&
in_confirm_time
,
time_t
in_confirm
,
Priority
in_priority
=
Message
::
Medium
);
Priority
in_priority
=
Message
::
Medium
);
ConfirmMessage
(
ConfirmMessage
&&
)
=
default
;
ConfirmMessage
(
ConfirmMessage
&&
)
=
default
;
...
@@ -240,11 +239,10 @@ namespace UniSetTypes
...
@@ -240,11 +239,10 @@ namespace UniSetTypes
ConfirmMessage
(
const
ConfirmMessage
&
)
=
default
;
ConfirmMessage
(
const
ConfirmMessage
&
)
=
default
;
ConfirmMessage
&
operator
=
(
const
ConfirmMessage
&
)
=
default
;
ConfirmMessage
&
operator
=
(
const
ConfirmMessage
&
)
=
default
;
ObjectId
sensor_id
;
/* ID датчика */
ObjectId
sensor_id
;
/* ID датчика (события) */
double
value
;
/* значение датчика */
double
sensor_value
;
/* значение датчика (события) */
time_t
time
;
/* время, когда датчик получил сигнал */
struct
timespec
sensor_time
;
/* время срабатвание датчика(события), который квитируем */
time_t
time_nsec
;
/* время в наносекундах */
struct
timespec
confirm_time
;
/* время, когда произошло квитирование */
time_t
confirm
;
/* время, когда произошло квитирование */
bool
broadcast
;
bool
broadcast
;
...
@@ -253,7 +251,7 @@ namespace UniSetTypes
...
@@ -253,7 +251,7 @@ namespace UniSetTypes
(т.е. в БД второй раз сохранять не надо, пересылать
(т.е. в БД второй раз сохранять не надо, пересылать
второй раз тоже не надо).
второй раз тоже не надо).
*/
*/
bool
route
;
bool
forward
;
protected
:
protected
:
ConfirmMessage
();
ConfirmMessage
();
...
...
include/UniSetTypes.h
View file @
7f787ab6
...
@@ -174,6 +174,20 @@ namespace UniSetTypes
...
@@ -174,6 +174,20 @@ namespace UniSetTypes
std
::
string
timeToString
(
time_t
tm
=
time
(
0
),
const
std
::
string
&
brk
=
":"
);
/*!< Преобразование времени в строку HH:MM:SS */
std
::
string
timeToString
(
time_t
tm
=
time
(
0
),
const
std
::
string
&
brk
=
":"
);
/*!< Преобразование времени в строку HH:MM:SS */
std
::
string
dateToString
(
time_t
tm
=
time
(
0
),
const
std
::
string
&
brk
=
"/"
);
/*!< Преобразование даты в строку DD/MM/YYYY */
std
::
string
dateToString
(
time_t
tm
=
time
(
0
),
const
std
::
string
&
brk
=
"/"
);
/*!< Преобразование даты в строку DD/MM/YYYY */
struct
timeval
to_timeval
(
const
std
::
chrono
::
system_clock
::
duration
&
d
);
/*!< конвертирование std::chrono в posix timeval */
struct
timespec
to_timespec
(
const
std
::
chrono
::
system_clock
::
duration
&
d
);
/*!< конвертирование std::chrono в posix timespec */
struct
timespec
now_to_timespec
();
/*!< получение текущего времени */
inline
bool
operator
==
(
const
struct
timespec
&
r1
,
const
struct
timespec
&
r2
)
{
return
(
r1
.
tv_sec
==
r2
.
tv_sec
&&
r1
.
tv_nsec
==
r2
.
tv_nsec
);
}
inline
bool
operator
!=
(
const
struct
timespec
&
r1
,
const
struct
timespec
&
r2
)
{
return
!
(
operator
==
(
r1
,
r2
));
}
/*! Разбивка строки по указанному символу */
/*! Разбивка строки по указанному символу */
IDList
explode
(
const
std
::
string
&
str
,
char
sep
=
','
);
IDList
explode
(
const
std
::
string
&
str
,
char
sep
=
','
);
std
::
vector
<
std
::
string
>
explode_str
(
const
std
::
string
&
str
,
char
sep
=
','
);
std
::
vector
<
std
::
string
>
explode_str
(
const
std
::
string
&
str
,
char
sep
=
','
);
...
@@ -297,9 +311,5 @@ namespace UniSetTypes
...
@@ -297,9 +311,5 @@ namespace UniSetTypes
return
destBegin
;
return
destBegin
;
}
}
}
}
// Варварский запрет на использование atoi вместо uni_atoi..
// #define atoi atoi##_Do_not_use_atoi_function_directly_Use_getIntProp90,_getArgInt_or_uni_atoi
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
#endif
#endif
src/ObjectRepository/UniSetTypes.cc
View file @
7f787ab6
...
@@ -588,3 +588,41 @@ std::string UniSetTypes::replace_all( const std::string& src, const std::string&
...
@@ -588,3 +588,41 @@ std::string UniSetTypes::replace_all( const std::string& src, const std::string&
return
std
::
move
(
res
);
return
std
::
move
(
res
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
timeval
UniSetTypes
::
to_timeval
(
const
chrono
::
system_clock
::
duration
&
d
)
{
struct
timeval
tv
;
if
(
d
.
count
()
==
0
)
tv
.
tv_sec
=
tv
.
tv_usec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
tv
.
tv_sec
=
sec
.
count
();
tv
.
tv_usec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
d
-
sec
).
count
();
}
return
std
::
move
(
tv
);
}
// -------------------------------------------------------------------------
timespec
UniSetTypes
::
to_timespec
(
const
chrono
::
system_clock
::
duration
&
d
)
{
struct
timespec
ts
;
if
(
d
.
count
()
==
0
)
ts
.
tv_sec
=
ts
.
tv_nsec
=
0
;
else
{
std
::
chrono
::
seconds
const
sec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
d
);
ts
.
tv_sec
=
sec
.
count
();
ts
.
tv_nsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
d
-
sec
).
count
();
}
return
std
::
move
(
ts
);
}
// -------------------------------------------------------------------------
timespec
UniSetTypes
::
now_to_timespec
()
{
auto
d
=
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
();
return
to_timespec
(
d
);
}
// -------------------------------------------------------------------------
src/Processes/IOController.cc
View file @
7f787ab6
...
@@ -304,8 +304,7 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
...
@@ -304,8 +304,7 @@ 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
timespec
tm
;
struct
timespec
tm
=
UniSetTypes
::
now_to_timespec
();
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
usi
->
tv_sec
=
tm
.
tv_sec
;
usi
->
tv_sec
=
tm
.
tv_sec
;
usi
->
tv_nsec
=
tm
.
tv_nsec
;
usi
->
tv_nsec
=
tm
.
tv_nsec
;
}
}
...
@@ -374,8 +373,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
...
@@ -374,8 +373,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
IOStateList
::
mapped_type
ai
=
usi
;
IOStateList
::
mapped_type
ai
=
usi
;
// запоминаем начальное время
// запоминаем начальное время
struct
timespec
tm
;
struct
timespec
tm
=
UniSetTypes
::
now_to_timespec
();
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
ai
->
tv_sec
=
tm
.
tv_sec
;
ai
->
tv_sec
=
tm
.
tv_sec
;
ai
->
tv_nsec
=
tm
.
tv_nsec
;
ai
->
tv_nsec
=
tm
.
tv_nsec
;
ai
->
value
=
ai
->
default_val
;
ai
->
value
=
ai
->
default_val
;
...
...
src/Processes/IONotifyController.cc
View file @
7f787ab6
...
@@ -648,8 +648,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&&
...
@@ -648,8 +648,7 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&&
addConsumer
(
ti
.
clst
,
ci
);
addConsumer
(
ti
.
clst
,
ci
);
// запоминаем начальное время
// запоминаем начальное время
struct
timespec
tm
;
struct
timespec
tm
=
UniSetTypes
::
now_to_timespec
();
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
ti
.
tv_sec
=
tm
.
tv_sec
;
ti
.
tv_sec
=
tm
.
tv_sec
;
ti
.
tv_nsec
=
tm
.
tv_nsec
;
ti
.
tv_nsec
=
tm
.
tv_nsec
;
...
@@ -714,8 +713,7 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
...
@@ -714,8 +713,7 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
SensorMessage
sm
(
std
::
move
(
usi
->
makeSensorMessage
()));
SensorMessage
sm
(
std
::
move
(
usi
->
makeSensorMessage
()));
// текущее время
// текущее время
struct
timespec
tm
;
struct
timespec
tm
=
UniSetTypes
::
now_to_timespec
();
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
{
{
uniset_rwmutex_rlock
l
(
ti
->
mut
);
uniset_rwmutex_rlock
l
(
ti
->
mut
);
...
...
src/Various/MessageType.cc
View file @
7f787ab6
...
@@ -57,7 +57,7 @@ namespace UniSetTypes
...
@@ -57,7 +57,7 @@ namespace UniSetTypes
supplier
(
DefaultObjectId
),
supplier
(
DefaultObjectId
),
consumer
(
DefaultObjectId
)
consumer
(
DefaultObjectId
)
{
{
::
clock_gettime
(
CLOCK_REALTIME
,
&
tm
);
tm
=
UniSetTypes
::
now_to_timespec
(
);
}
}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
...
@@ -195,19 +195,17 @@ namespace UniSetTypes
...
@@ -195,19 +195,17 @@ namespace UniSetTypes
assert
(
this
->
type
==
Message
::
Confirm
);
assert
(
this
->
type
==
Message
::
Confirm
);
}
}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
ConfirmMessage
::
ConfirmMessage
(
UniSetTypes
::
ObjectId
in_sensor_id
,
ConfirmMessage
::
ConfirmMessage
(
UniSetTypes
::
ObjectId
in_sensor_id
,
double
in_value
,
double
in_sensor_value
,
time_t
in_time
,
const
timespec
&
in_sensor_time
,
time_t
in_time_nsec
,
const
timespec
&
in_confirm_time
,
time_t
in_confirm
,
Priority
in_priority
)
:
Priority
in_priority
)
:
sensor_id
(
in_sensor_id
),
sensor_id
(
in_sensor_id
),
value
(
in_value
),
sensor_value
(
in_sensor_value
),
time
(
in_time
),
sensor_time
(
in_sensor_time
),
time_nsec
(
in_time_nsec
),
confirm_time
(
in_confirm_time
),
confirm
(
in_confirm
),
broadcast
(
false
),
broadcast
(
false
),
route
(
false
)
forward
(
false
)
{
{
type
=
Message
::
Confirm
;
type
=
Message
::
Confirm
;
priority
=
in_priority
;
priority
=
in_priority
;
...
...
tests/develop.cc
View file @
7f787ab6
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include <type_traits>
#include <type_traits>
#include <tuple>
#include <tuple>
#include "UTCPCore.h"
#include "UTCPCore.h"
#include <chrono>
template
<
typename
...
Args
>
template
<
typename
...
Args
>
class
VMon
class
VMon
...
@@ -20,6 +21,35 @@ using namespace std;
...
@@ -20,6 +21,35 @@ using namespace std;
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
auto
now
=
std
::
chrono
::
system_clock
::
now
();
auto
sec
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
nanoseconds
>
(
now
);
auto
nsec
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
seconds
>
(
now
);
cout
<<
"SEC="
<<
std
::
chrono
::
duration
<
double
>
(
sec
.
time_since_epoch
()).
count
()
<<
endl
;
return
0
;
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
p1
,
p2
,
p3
;
p2
=
std
::
chrono
::
system_clock
::
now
();
p3
=
p2
-
std
::
chrono
::
hours
(
24
);
std
::
time_t
epoch_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p1
);
std
::
cout
<<
"epoch: "
<<
std
::
ctime
(
&
epoch_time
);
std
::
time_t
today_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
p2
);
std
::
cout
<<
"today: "
<<
std
::
ctime
(
&
today_time
);
std
::
cout
<<
"hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p2
.
time_since_epoch
()).
count
()
<<
'\n'
;
std
::
cout
<<
"yesterday, hours since epoch: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
hours
>
(
p3
.
time_since_epoch
()).
count
()
<<
'\n'
;
return
0
;
unsigned
char
dat
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
};
unsigned
char
dat
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
};
// UTCPCore::Buffer* buf = new UTCPCore::Buffer( dat, 0 );
// UTCPCore::Buffer* buf = new UTCPCore::Buffer( dat, 0 );
...
...
tests/test_messagetype.cc
View file @
7f787ab6
...
@@ -189,35 +189,32 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -189,35 +189,32 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
ObjectId
sid
=
1
;
ObjectId
sid
=
1
;
double
val
=
100
;
double
val
=
100
;
time_t
t_sec
=
10
;
timespec
t_event
=
{
10
,
300
};
time_t
t_nsec
=
300
;
timespec
t_confirm
=
{
10
,
90
};
time_t
t_confirm
=
10
;
SECTION
(
"Default consturctor"
)
SECTION
(
"Default consturctor"
)
{
{
ConfirmMessage
cm
(
sid
,
val
,
t_
sec
,
t_nsec
,
t_confirm
);
ConfirmMessage
cm
(
sid
,
val
,
t_
event
,
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
()
);
CHECK
(
cm
.
supplier
==
DefaultObjectId
);
CHECK
(
cm
.
supplier
==
DefaultObjectId
);
CHECK
(
cm
.
consumer
==
DefaultObjectId
);
CHECK
(
cm
.
consumer
==
DefaultObjectId
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
sensor_value
==
val
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
sensor_time
==
t_event
);
REQUIRE
(
cm
.
time_nsec
==
t_nsec
);
REQUIRE
(
cm
.
confirm_time
==
t_confirm
);
REQUIRE
(
cm
.
confirm
==
t_confirm
);
CHECK
(
cm
.
broadcast
==
false
);
CHECK
(
cm
.
broadcast
==
false
);
CHECK
(
cm
.
route
==
false
);
CHECK
(
cm
.
forward
==
false
);
}
}
SECTION
(
"Transport ConfirmMessage"
)
SECTION
(
"Transport ConfirmMessage"
)
{
{
ConfirmMessage
cm
(
sid
,
val
,
t_
sec
,
t_nsec
,
t_confirm
);
ConfirmMessage
cm
(
sid
,
val
,
t_
event
,
t_confirm
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
sensor_id
==
sid
);
REQUIRE
(
cm
.
value
==
val
);
REQUIRE
(
cm
.
sensor_value
==
val
);
REQUIRE
(
cm
.
time
==
t_sec
);
REQUIRE
(
cm
.
sensor_time
==
t_event
);
REQUIRE
(
cm
.
time_nsec
==
t_nsec
);
REQUIRE
(
cm
.
confirm_time
==
t_confirm
);;
REQUIRE
(
cm
.
confirm
==
t_confirm
);
auto
tm
=
cm
.
transport_msg
();
auto
tm
=
cm
.
transport_msg
();
...
@@ -226,10 +223,9 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
...
@@ -226,10 +223,9 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
ConfirmMessage
cm2
(
&
vm
);
ConfirmMessage
cm2
(
&
vm
);
REQUIRE
(
cm2
.
sensor_id
==
sid
);
REQUIRE
(
cm2
.
sensor_id
==
sid
);
REQUIRE
(
cm2
.
value
==
val
);
REQUIRE
(
cm2
.
sensor_value
==
val
);
REQUIRE
(
cm2
.
time
==
t_sec
);
REQUIRE
(
cm
.
sensor_time
==
t_event
);
REQUIRE
(
cm2
.
time_nsec
==
t_nsec
);
REQUIRE
(
cm
.
confirm_time
==
t_confirm
);
REQUIRE
(
cm2
.
confirm
==
t_confirm
);
}
}
}
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
tests/test_utypes.cc
View file @
7f787ab6
...
@@ -174,3 +174,17 @@ TEST_CASE("UniSetTypes: replace_all", "[utypes][replace_all]" )
...
@@ -174,3 +174,17 @@ TEST_CASE("UniSetTypes: replace_all", "[utypes][replace_all]" )
REQUIRE
(
res
==
str2
);
REQUIRE
(
res
==
str2
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
TEST_CASE
(
"UniSetTypes: timespec comapre"
,
"[utypes][timespec]"
)
{
timespec
t1
=
{
10
,
300
};
timespec
t2
=
{
10
,
90
};
REQUIRE
(
t1
!=
t2
);
REQUIRE_FALSE
(
t1
==
t2
);
timespec
t3
=
{
20
,
20
};
timespec
t4
=
{
20
,
20
};
REQUIRE_FALSE
(
t3
!=
t4
);
REQUIRE
(
t3
==
t4
);
}
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