Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph
Commits
14e57e84
Commit
14e57e84
authored
Apr 14, 2019
by
Olivier Stasse
Browse files
[entity] Add set/getTimeSample and set/getStreamPrintPeriod.
This should be externalized as it has an impact on output messages.
parent
b2202b5f
Pipeline
#4067
passed with stage
in 4 minutes and 23 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/entity.h
View file @
14e57e84
...
...
@@ -112,7 +112,24 @@ namespace dynamicgraph
/// \brief Get the logger's verbosity level.
LoggerVerbosity
getLoggerVerbosityLevel
()
{
return
logger_
.
getVerbosity
();
};
{
return
logger_
.
getVerbosity
();
}
/// \brief Set the time sample.
bool
setTimeSample
(
double
t
)
{
return
logger_
.
setTimeSample
(
t
);
}
/// \brief Get the time sample.
double
getTimeSample
()
{
return
logger_
.
getTimeSample
();}
/// \brief Set the period of the stream period
bool
setStreamPrintPeriod
(
double
t
)
{
return
logger_
.
setStreamPrintPeriod
(
t
);
}
/// \brief Get the period of the stream period
double
getStreamPrintPeriod
()
{
return
logger_
.
getStreamPrintPeriod
();}
protected:
void
addCommand
(
const
std
::
string
&
name
,
command
::
Command
*
command
);
...
...
include/dynamic-graph/logger.h
View file @
14e57e84
...
...
@@ -178,9 +178,16 @@ namespace dynamicgraph {
* is going to be called. */
bool
setTimeSample
(
double
t
);
/** Get the sampling time at which the method countdown()
* is going to be called. */
double
getTimeSample
();
/** Set the time period for printing of streaming messages. */
bool
setStreamPrintPeriod
(
double
s
);
/** Get the time period for printing of streaming messages. */
double
getStreamPrintPeriod
();
/** Set the verbosity level of the logger. */
void
setVerbosity
(
LoggerVerbosity
lv
);
...
...
src/debug/logger.cpp
View file @
14e57e84
...
...
@@ -62,7 +62,7 @@ namespace dynamicgraph
return
;
// if print is allowed by current verbosity level
if
(
isStreamMsg
(
type
))
if
(
isStreamMsg
(
type
))
{
// check whether counter already exists
string
id
=
file
+
toString
(
line
);
...
...
@@ -101,4 +101,14 @@ namespace dynamicgraph
m_streamPrintPeriod
=
s
;
return
true
;
}
double
Logger
::
getTimeSample
()
{
return
m_timeSample
;
}
double
Logger
::
getStreamPrintPeriod
()
{
return
m_streamPrintPeriod
;
}
}
// namespace dynamicgraph
src/debug/real-time-logger.cpp
View file @
14e57e84
...
...
@@ -87,22 +87,22 @@ namespace dynamicgraph
int
threadPolicy
;
struct
sched_param
threadParam
;
if
(
pthread_getschedparam
(
pthread_self
(),
&
threadPolicy
,
&
threadParam
)
==
0
)
{
threadPolicy
=
SCHED_OTHER
;
threadParam
.
sched_priority
-=
5
;
if
(
threadParam
.
sched_priority
<
sched_get_priority_min
(
threadPolicy
))
threadParam
.
sched_priority
=
sched_get_priority_min
(
threadPolicy
);
{
threadPolicy
=
SCHED_OTHER
;
threadParam
.
sched_priority
-=
5
;
if
(
threadParam
.
sched_priority
<
sched_get_priority_min
(
threadPolicy
))
threadParam
.
sched_priority
=
sched_get_priority_min
(
threadPolicy
);
pthread_setschedparam
(
pthread_self
(),
threadPolicy
,
&
threadParam
);
}
pthread_setschedparam
(
pthread_self
(),
threadPolicy
,
&
threadParam
);
}
while
(
!
requestShutdown_
||
!
logger
->
empty
())
{
// If the logger did not write anything, it means the buffer is empty.
// Do a pause
if
(
!
logger
->
spinOnce
())
boost
::
this_thread
::
sleep
(
boost
::
posix_time
::
milliseconds
(
100
));
}
{
// If the logger did not write anything, it means the buffer is empty.
// Do a pause
if
(
!
logger
->
spinOnce
())
boost
::
this_thread
::
sleep
(
boost
::
posix_time
::
milliseconds
(
100
));
}
}
};
...
...
tests/debug-logger-winit.cpp
View file @
14e57e84
...
...
@@ -16,11 +16,15 @@
#include
<dynamic-graph/real-time-logger.h>
#include
<dynamic-graph/logger.h>
#define BOOST_TEST_MODULE debug-logger
#include
<boost/test/unit_test.hpp>
#include
<boost/test/output_test_stream.hpp>
#include
<boost/thread/thread.hpp>
#include
<boost/date_time/posix_time/posix_time.hpp>
using
boost
::
test_tools
::
output_test_stream
;
...
...
@@ -78,7 +82,7 @@ BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization)
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"CustomEntity"
,
"my-entity-2"
)));
for
(
unsigned
int
i
=
0
;
i
<
1000
0
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
1000
;
i
++
)
{
entity
.
testDebugTrace
();
}
...
...
tests/debug-logger.cpp
View file @
14e57e84
...
...
@@ -78,6 +78,11 @@ BOOST_AUTO_TEST_CASE(debug_logger)
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"CustomEntity"
,
"my-entity"
)));
entity
.
setTimeSample
(
0.002
);
BOOST_CHECK_EQUAL
(
entity
.
getTimeSample
(),
0.002
);
entity
.
setStreamPrintPeriod
(
0.004
);
BOOST_CHECK_EQUAL
(
entity
.
getStreamPrintPeriod
(),
0.004
);
for
(
unsigned
int
i
=
0
;
i
<
10000
;
i
++
)
{
entity
.
testDebugTrace
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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