TopicReplayer.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX
17 * @author Mirko Waechter( mirko.waechter at kit dot edu)
18 * @date 2016
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 #pragma once
23 
24 
25 #include <unordered_set>
26 
30 #include <ArmarXCore/interface/components/TopicRecorderInterface.h>
32 
33 #include "TopicReaderInterface.h"
34 
35 namespace armarx
36 {
37 
39  {
40  public:
42  {
43  defineOptionalProperty<bool>("Loop", false, "Loop playback");
44  defineRequiredProperty<std::string>("RecordFile", "File with recorded data");
45  defineOptionalProperty<std::string>(
46  "StorageMode",
47  "database",
48  "Storage variant to use, currently 'database' (default) and 'file' are available");
49  defineOptionalProperty<std::string>("DebugObserverName",
50  "DebugObserver",
51  "Name of the topic the DebugObserver listens on");
52  defineOptionalProperty<std::string>(
53  "TopicName",
54  "TopicReplayerListener",
55  "Name of the topic the recorded data should be written to");
56  }
57  };
58 
59  class TopicReplayer : public Component
60  {
61  public:
62  TopicReplayer();
63 
64  std::string getDefaultName() const override;
65  void pauseReplay();
66  void resumeReplay();
67  void setReplaySpeed(double factor);
68 
69  std::vector<std::string> getRecordedTopics();
70  void setReplayingTopics(std::vector<std::string> topics);
71 
74  void jumpToPosition(IceUtil::Time timestamp);
75  void setAutoplay(bool autoplay);
76  void setLoop(bool loop);
77 
78  // ManagedIceObject interface
80 
81  protected:
82  void onInitComponent() override;
83  void onConnectComponent() override;
84  void onDisconnectComponent() override;
85 
86  void play();
88 
89  private:
90  TopicReaderInterfacePtr replayer;
91  TopicReplayerListenerInterfacePrx replayerListener;
92  TimeKeeper timeKeeper;
93  bool autoplay = true;
94  bool loop;
95  std::unordered_set<std::string> replayingTopics;
96  bool replayingTopicsNotSupportedByFile = false;
97  DebugObserverInterfacePrx debugObserver;
98  };
99 
100 } // namespace armarx
armarx::TimeKeeper
The TimeKeeper class tracks the passing of time and allows to stop it, restart it,...
Definition: TimeKeeper.h:41
armarx::TopicReplayer::setReplayingTopics
void setReplayingTopics(std::vector< std::string > topics)
Definition: TopicReplayer.cpp:242
armarx::TopicReplayer::resumeReplay
void resumeReplay()
Definition: TopicReplayer.cpp:196
TopicReaderInterface.h
TimeKeeper.h
DebugObserver.h
armarx::TopicReplayer::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: TopicReplayer.cpp:177
armarx::TopicReplayer::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: TopicReplayer.cpp:44
armarx::TopicReplayer::TopicReplayer
TopicReplayer()
Definition: TopicReplayer.cpp:39
armarx::TopicReplayer::jumpToPosition
void jumpToPosition(IceUtil::Time timestamp)
Definition: TopicReplayer.cpp:218
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::TopicReplayer::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: TopicReplayer.cpp:100
RunningTask.h
armarx::TopicReplayer::pauseReplay
void pauseReplay()
Definition: TopicReplayer.cpp:186
armarx::TopicReplayer::setLoop
void setLoop(bool loop)
Definition: TopicReplayer.cpp:266
armarx::TopicReplayer::setReplaySpeed
void setReplaySpeed(double factor)
Definition: TopicReplayer.cpp:212
armarx::TopicReplayer::getReplayLength
IceUtil::Time getReplayLength() const
Definition: TopicReplayer.cpp:248
armarx::TopicReplayer::getCurrentTimePosition
IceUtil::Time getCurrentTimePosition() const
Definition: TopicReplayer.cpp:254
armarx::TopicReplayer::task
RunningTask< TopicReplayer >::pointer_type task
Definition: TopicReplayer.h:87
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::TopicReplayerProperties
Definition: TopicReplayer.h:38
armarx::TopicReplayerProperties::TopicReplayerProperties
TopicReplayerProperties(std::string prefix)
Definition: TopicReplayer.h:41
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::TopicReplayer::play
void play()
Definition: TopicReplayer.cpp:106
armarx::TopicReaderInterfacePtr
std::shared_ptr< TopicReaderInterface > TopicReaderInterfacePtr
Definition: TopicReaderInterface.h:46
armarx::TopicReplayer::getRecordedTopics
std::vector< std::string > getRecordedTopics()
Definition: TopicReplayer.cpp:230
armarx::TopicReplayer::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: TopicReplayer.cpp:50
armarx::TopicReplayer::setAutoplay
void setAutoplay(bool autoplay)
Definition: TopicReplayer.cpp:260
armarx::TopicReplayer::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: TopicReplayer.cpp:79
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::TopicReplayer
Definition: TopicReplayer.h:59