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
34
35namespace armarx
36{
37
39 {
40 public:
42 {
43 defineOptionalProperty<bool>("Loop", false, "Loop playback");
44 defineRequiredProperty<std::string>("RecordFile", "File with recorded data");
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");
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:
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
72 IceUtil::Time getReplayLength() const;
73 IceUtil::Time getCurrentTimePosition() const;
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:
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
std::string timestamp()
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
The TimeKeeper class tracks the passing of time and allows to stop it, restart it,...
Definition TimeKeeper.h:42
TopicReplayerProperties(std::string prefix)
void onInitComponent() override
Pure virtual hook for the subclass.
IceUtil::Time getCurrentTimePosition() const
RunningTask< TopicReplayer >::pointer_type task
void onDisconnectComponent() override
Hook for subclass.
void setReplaySpeed(double factor)
void setAutoplay(bool autoplay)
std::vector< std::string > getRecordedTopics()
IceUtil::Time getReplayLength() const
void setLoop(bool loop)
void onConnectComponent() override
Pure virtual hook for the subclass.
PropertyDefinitionsPtr createPropertyDefinitions() override
void setReplayingTopics(std::vector< std::string > topics)
void jumpToPosition(IceUtil::Time timestamp)
std::string getDefaultName() const override
Retrieve default name of component.
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::shared_ptr< TopicReaderInterface > TopicReaderInterfacePtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.