27#include <IceStorm/IceStorm.h>
56 if (!storageMode.compare(
"file"))
60 else if (!storageMode.compare(
"database"))
68 <<
"StorageMode " << storageMode
69 <<
" is not supported (database, file). Falling back to default 'database' mode.";
85 timeKeeper.setSpeed(1.0);
102 return "TopicReplayer";
108 std::map<std::string, Ice::ObjectPrx> topics;
111 while (!
task->isStopped())
113 if (replayer->read(
data))
116 if (topics.count(
topic) == 0)
119 topics[
topic] = topicPrx;
121 Ice::ObjectPrx t = topics[
topic];
122 std::vector<Ice::Byte> dataBytesOut;
124 while (this->timeKeeper.getTime() <
data.timestamp && !
task->isStopped())
128 if (this->replayingTopicsNotSupportedByFile ||
129 replayingTopics.count(
data.topicName))
131 t->ice_invoke(
data.operationName, Ice::Normal,
data.inParams, dataBytesOut);
136 if (!replayer->seekTo(IceUtil::Time::seconds(0.0)))
148 debugValues[
"file"] =
150 debugValues[
"status"] =
new Variant(
"rewinding");
151 debugObserver->setDebugChannel(
getName(), debugValues);
158 replayerListener->onStopReply();
161 debugValues[
"status"] =
new Variant(
"stopped");
162 debugObserver->setDebugChannel(
getName(), debugValues);
188 this->timeKeeper.stop();
191 debugValues[
"status"] =
new Variant(
"paused");
192 debugObserver->setDebugChannel(
getName(), debugValues);
198 if (
task->isStopped())
202 this->timeKeeper.start();
207 debugValues[
"status"] =
new Variant(
"started");
208 debugObserver->setDebugChannel(
getName(), debugValues);
214 this->timeKeeper.setSpeed((
float)factor);
221 this->timeKeeper.step(
timestamp - this->timeKeeper.getTime());
229 std::vector<std::string>
232 std::vector<std::string> topics = replayer->getReplayTopics();
235 replayingTopicsNotSupportedByFile =
true;
244 this->replayingTopics = std::unordered_set<std::string>(topics.begin(), topics.end());
250 return replayer->getReplayLength();
256 return timeKeeper.getTime();
262 this->autoplay = autoplay;
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
std::string getName() const
Retrieve name of object.
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
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 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.
The Variant class is described here: Variants.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.