GAMS  1.4.0
MessageProfiling.h
Go to the documentation of this file.
1 
55 #ifndef _GAMS_ALGORITHMS_MESSAGE_PROFILING_H_
56 #define _GAMS_ALGORITHMS_MESSAGE_PROFILING_H_
57 
59 
60 #include <map>
61 #include <vector>
62 #include <string>
63 
64 #include "gams/variables/Sensor.h"
67 #include "gams/variables/Self.h"
68 
70 
71 #include "madara/filters/AggregateFilter.h"
72 #include "madara/transport/QoSTransportSettings.h"
73 
74 namespace gams
75 {
76  namespace algorithms
77  {
82  {
83  public:
93  const madara::knowledge::KnowledgeRecord& send,
94  madara::knowledge::KnowledgeBase * knowledge = 0,
95  platforms::Base * platform = 0,
96  variables::Sensors * sensors = 0,
97  variables::Self * self = 0);
98 
103 
107  void init_filtered_transport(madara::transport::QoSTransportSettings
108  settings);
109 
114  void operator=(const MessageProfiling & rhs);
115 
120  virtual int analyze(void);
121 
126  virtual int execute(void);
127 
132  virtual int plan(void);
133 
134  private:
138  const static std::string key_prefix_;
139 
141  madara::knowledge::KnowledgeBase * local_knowledge_;
142 
146  madara::knowledge::containers::String data_;
147 
151  //madara::knowledge::containers::Integer count_;
152 
157  class MessageFilter : public madara::filters::AggregateFilter
158  {
159  public:
163  virtual ~MessageFilter();
164 
165  void filter(madara::knowledge::KnowledgeMap& records,
166  const madara::transport::TransportContext& transport_context,
167  madara::knowledge::Variables& var);
168 
169  std::string missing_messages_string() const;
170 
174  struct MessageData
175  {
176  size_t first;
177  size_t last;
178  std::vector<bool> present;
179  };
180 
184  //std::map<std::string, MessageData> msg_map;
185  std::map<std::string, size_t> msg_map;
186  };
187 
192 
196  size_t send_size_;
197  };
198 
203  {
204  public:
205 
221  const madara::knowledge::KnowledgeMap & args,
222  madara::knowledge::KnowledgeBase * knowledge,
223  platforms::BasePlatform * platform,
224  variables::Sensors * sensors,
225  variables::Self * self,
226  variables::Agents * agents);
227  };
228  }
229 }
230 
231 #endif // _GAMS_ALGORITHMS_MESSAGE_PROFILING_H_
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
#define GAMS_EXPORT
Definition: GamsExport.h:20
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Base class for algorithm factories that classes derived from.
The base class that algorithms in GAMS use.
Definition: BaseAlgorithm.h:95
A factory class for creating MessageProfiling Algorithms.
virtual BaseAlgorithm * create(const madara::knowledge::KnowledgeMap &args, madara::knowledge::KnowledgeBase *knowledge, platforms::BasePlatform *platform, variables::Sensors *sensors, variables::Self *self, variables::Agents *agents)
Creates a MessageProfiling Algorithm.
std::map< std::string, size_t > msg_map
Keep a MessageData struct for each peer.
void filter(madara::knowledge::KnowledgeMap &records, const madara::transport::TransportContext &transport_context, madara::knowledge::Variables &var)
An algorithm for profiling message generation and receipt.
virtual int execute(void)
Plans the next execution of the algorithm.
madara::knowledge::containers::String data_
Container for storing data to be sent to other controllers.
MessageProfiling(const madara::knowledge::KnowledgeRecord &send, madara::knowledge::KnowledgeBase *knowledge=0, platforms::Base *platform=0, variables::Sensors *sensors=0, variables::Self *self=0)
Constructor.
madara::knowledge::KnowledgeBase * local_knowledge_
provides access to the knowledge base
void operator=(const MessageProfiling &rhs)
Assignment operator.
virtual int plan(void)
Plans the next execution of the algorithm.
MessageFilter filter_
Message Filter object.
void init_filtered_transport(madara::transport::QoSTransportSettings settings)
Initialize the transport with the filter.
size_t send_size_
size of message to send
static const std::string key_prefix_
Prefix for message keys.
virtual int analyze(void)
Analyzes environment, platform, or other information.
The base platform for all platforms to use.
Definition: BasePlatform.h:113
A container for self referencing information.
Definition: Self.h:70
std::map< std::string, Sensor * > Sensors
a map of sensor names to the sensor information
Definition: Sensor.h:238
std::vector< Agent > Agents
An array of agent knowledge.
Definition: Agent.h:246
Contains all GAMS-related tools, classes and code.