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