GenericTopicSubscriber.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 #include "TopicWriterInterface.h"
25 
26 #include <Ice/Object.h>
27 
28 #include <queue>
29 #include <mutex>
30 
31 
32 namespace armarx
33 {
34 
35  class TopicRecorderComponent;
37 
38  class GenericTopicSubscriber : public Ice::Blobject
39  {
40  public:
41  GenericTopicSubscriber(TopicRecorderComponentPtr recorder, const std::string& topicName, IceUtil::Time startTimestamp, float maxFrequency = -1.0f);
42  void getData(std::queue<TopicUtil::TopicData>& data);
43 
45  {
46  startTimestamp = time;
47  }
48 
49  // Blobject interface
50  public:
51  bool ice_invoke(const std::vector<Ice::Byte>& inParams, std::vector<Ice::Byte>& outParams, const Ice::Current& current) override;
52  private:
53  bool checkTimestamp(const std::string& operationName, const IceUtil::Time& timestamp);
54  std::string topicName;
55  std::queue<TopicUtil::TopicData> dataQueue;
56  std::mutex queueMutex;
58  IceUtil::Time startTimestamp;
59  float maxFrequency;
60  std::map<std::string, IceUtil::Time> functionCallTimestamps;
61  };
62 
64 
65 
66 }
67 
armarx::GenericTopicSubscriber
Definition: GenericTopicSubscriber.h:38
TopicWriterInterface.h
IceInternal::Handle< TopicRecorderComponent >
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::GenericTopicSubscriber::ice_invoke
bool ice_invoke(const std::vector< Ice::Byte > &inParams, std::vector< Ice::Byte > &outParams, const Ice::Current &current) override
Definition: GenericTopicSubscriber.cpp:45
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::GenericTopicSubscriber::getData
void getData(std::queue< TopicUtil::TopicData > &data)
Definition: GenericTopicSubscriber.cpp:39
armarx::GenericTopicSubscriber::GenericTopicSubscriber
GenericTopicSubscriber(TopicRecorderComponentPtr recorder, const std::string &topicName, IceUtil::Time startTimestamp, float maxFrequency=-1.0f)
Definition: GenericTopicSubscriber.cpp:30
armarx::GenericTopicSubscriber::setTime
void setTime(IceUtil::Time time)
Definition: GenericTopicSubscriber.h:44
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28