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 <ArmarXCore/interface/components/TopicRecorderInterface.h>
26 
30 
32 
33 #include "TopicReaderInterface.h"
34 
35 #include <unordered_set>
36 
37 
38 namespace armarx
39 {
40 
43  {
44  public:
47  {
48  defineOptionalProperty<bool>("Loop", false, "Loop playback");
49  defineRequiredProperty<std::string>("RecordFile", "File with recorded data");
50  defineOptionalProperty<std::string>("StorageMode", "database", "Storage variant to use, currently 'database' (default) and 'file' are available");
51  defineOptionalProperty<std::string>("DebugObserverName", "DebugObserver", "Name of the topic the DebugObserver listens on");
52  defineOptionalProperty<std::string>("TopicName", "TopicReplayerListener", "Name of the topic the recorded data should be written to");
53  }
54  };
55 
56 
57  class TopicReplayer : public Component
58  {
59  public:
60  TopicReplayer();
61 
62  std::string getDefaultName() const override;
63  void pauseReplay();
64  void resumeReplay();
65  void setReplaySpeed(double factor);
66 
67  std::vector<std::string> getRecordedTopics();
68  void setReplayingTopics(std::vector<std::string> topics);
69 
72  void jumpToPosition(IceUtil::Time timestamp);
73  void setAutoplay(bool autoplay);
74  void setLoop(bool loop);
75 
76  // ManagedIceObject interface
78  protected:
79  void onInitComponent() override;
80  void onConnectComponent() override;
81  void onDisconnectComponent() override;
82 
83  void play();
85 
86  private:
87  TopicReaderInterfacePtr replayer;
88  TopicReplayerListenerInterfacePrx replayerListener;
89  TimeKeeper timeKeeper;
90  bool autoplay = true;
91  bool loop;
92  std::unordered_set<std::string> replayingTopics;
93  bool replayingTopicsNotSupportedByFile = false;
94  DebugObserverInterfacePrx debugObserver;
95  };
96 
97 }
98 
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:225
armarx::TopicReplayer::resumeReplay
void resumeReplay()
Definition: TopicReplayer.cpp:183
TopicReaderInterface.h
TimeKeeper.h
DebugObserver.h
armarx::TopicReplayer::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: TopicReplayer.cpp:166
armarx::TopicReplayer::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: TopicReplayer.cpp:43
armarx::TopicReplayer::TopicReplayer
TopicReplayer()
Definition: TopicReplayer.cpp:38
armarx::TopicReplayer::jumpToPosition
void jumpToPosition(IceUtil::Time timestamp)
Definition: TopicReplayer.cpp:203
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::TopicReplayer::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: TopicReplayer.cpp:92
RunningTask.h
armarx::TopicReplayer::pauseReplay
void pauseReplay()
Definition: TopicReplayer.cpp:174
armarx::TopicReplayer::setLoop
void setLoop(bool loop)
Definition: TopicReplayer.cpp:245
armarx::TopicReplayer::setReplaySpeed
void setReplaySpeed(double factor)
Definition: TopicReplayer.cpp:198
armarx::TopicReplayer::getReplayLength
IceUtil::Time getReplayLength() const
Definition: TopicReplayer.cpp:230
armarx::TopicReplayer::getCurrentTimePosition
IceUtil::Time getCurrentTimePosition() const
Definition: TopicReplayer.cpp:235
armarx::TopicReplayer::task
RunningTask< TopicReplayer >::pointer_type task
Definition: TopicReplayer.h:84
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:95
armarx::TopicReplayerProperties
Definition: TopicReplayer.h:41
armarx::TopicReplayerProperties::TopicReplayerProperties
TopicReplayerProperties(std::string prefix)
Definition: TopicReplayer.h:45
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::TopicReplayer::play
void play()
Definition: TopicReplayer.cpp:97
armarx::TopicReaderInterfacePtr
std::shared_ptr< TopicReaderInterface > TopicReaderInterfacePtr
Definition: TopicReaderInterface.h:46
armarx::TopicReplayer::getRecordedTopics
std::vector< std::string > getRecordedTopics()
Definition: TopicReplayer.cpp:214
armarx::TopicReplayer::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: TopicReplayer.cpp:49
armarx::TopicReplayer::setAutoplay
void setAutoplay(bool autoplay)
Definition: TopicReplayer.cpp:240
armarx::TopicReplayer::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: TopicReplayer.cpp:73
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::TopicReplayer
Definition: TopicReplayer.h:57