TimeKeeper.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5
*
6
* ArmarX is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
9
*
10
* ArmarX is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*
18
* @package ArmarXCore::application::ArmarXTimeserver
19
* @author Clemens Wallrath ( uagzs at student dot kit dot edu )
20
* @date 2015
21
* @copyright http://www.gnu.org/licenses/gpl.txt
22
* GNU General Public License
23
*/
24
25
#include "
TimeKeeper.h
"
26
27
namespace
armarx
28
{
29
TimeKeeper::TimeKeeper
()
30
{
31
reset
();
32
running =
false
;
33
}
34
35
IceUtil::Time
36
TimeKeeper::getTime
()
const
37
{
38
39
if
(running)
40
{
41
return
offset + (IceUtil::Time::now() - startTime) * speed;
42
}
43
else
44
{
45
return
offset;
46
}
47
}
48
49
void
50
TimeKeeper::reset
()
51
{
52
offset = IceUtil::Time::microSeconds(0);
53
startTime = IceUtil::Time::now();
54
speed = 1;
55
}
56
57
void
58
TimeKeeper::setSpeed
(
float
newSpeed)
59
{
60
offset =
getTime
();
61
startTime = IceUtil::Time::now();
62
speed = newSpeed;
63
}
64
65
float
66
TimeKeeper::getSpeed
()
67
{
68
return
speed;
69
}
70
71
void
72
TimeKeeper::start
()
73
{
74
if
(!running)
75
{
76
startTime = IceUtil::Time::now();
77
running =
true
;
78
}
79
}
80
81
void
82
TimeKeeper::stop
()
83
{
84
if
(running)
85
{
86
offset =
getTime
();
87
running =
false
;
88
}
89
}
90
91
void
92
TimeKeeper::step
(
IceUtil::Time
stepSize)
93
{
94
offset += stepSize;
95
}
96
}
// namespace armarx
TimeKeeper.h
armarx::TimeKeeper::stop
void stop()
stops the clock.
Definition:
TimeKeeper.cpp:82
armarx::TimeKeeper::step
void step(IceUtil::Time stepSize)
adds a timedelta to the current time
Definition:
TimeKeeper.cpp:92
armarx::TimeKeeper::setSpeed
void setSpeed(float newSpeed)
sets the speed factor of the clock
Definition:
TimeKeeper.cpp:58
armarx::armem::Time
armarx::core::time::DateTime Time
Definition:
forward_declarations.h:13
armarx::TimeKeeper::reset
void reset()
resets the clock
Definition:
TimeKeeper.cpp:50
armarx::TimeKeeper::getTime
IceUtil::Time getTime() const
get the current time of this clock
Definition:
TimeKeeper.cpp:36
armarx::TimeKeeper::getSpeed
float getSpeed()
Definition:
TimeKeeper.cpp:66
armarx::TimeKeeper::TimeKeeper
TimeKeeper()
Definition:
TimeKeeper.cpp:29
armarx::TimeKeeper::start
void start()
starts the clock
Definition:
TimeKeeper.cpp:72
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:27
ArmarXCore
core
time
TimeKeeper.cpp
Generated on Sat Apr 12 2025 09:13:28 for armarx_documentation by
1.8.17