BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
NemeaCollector.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright (C) 2018 CESNET
10  *
11  * LICENSE TERMS
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in
20  * the documentation and/or other materials provided with the
21  * distribution.
22  * 3. Neither the name of the Company nor the names of its contributors
23  * may be used to endorse or promote products derived from this
24  * software without specific prior written permission.
25  *
26  * This software is provided ``as is'', and any express or implied
27  * warranties, including, but not limited to, the implied warranties of
28  * merchantability and fitness for a particular purpose are disclaimed.
29  * In no event shall the company or contributors be liable for any
30  * direct, indirect, incidental, special, exemplary, or consequential
31  * damages (including, but not limited to, procurement of substitute
32  * goods or services; loss of use, data, or profits; or business
33  * interruption) however caused and on any theory of liability, whether
34  * in contract, strict liability, or tort (including negligence or
35  * otherwise) arising in any way out of the use of this software, even
36  * if advised of the possibility of such damage.
37  *
38  */
39 
40 #include "core/AbstractCollector.h"
41 #include <libtrap/trap.h>
42 #include <unirec/unirec.h>
43 #include <string>
44 
45 using namespace std;
46 
47 namespace BeeeOn {
48  /*
49  * Subclass for NemeaCollector
50  * Handle necessary information of libtrap and unirec for every event
51  */
53  public:
54  // Default constructor
55  EventMetaData();
56  // Defaut destructor
57  ~EventMetaData();
58 
59  trap_ctx_t *ctx; // Trap context
60  ur_template_t *utmpl; // Unirec template
61  void *udata; // Unirec data
62  char *uerr; // Unirec error
63  string onEventInterface; // Name of trap output interface
64  string ufields; // Field names in unirec message
65  };
66 
67 
68  /*
69  * NemeaCollector class for collecting data for statistics and analysis purposes
70  */
72  public:
73  // Default constructor
75  // Default destructor
76  ~NemeaCollector();
77 
78  /*
79  * Events inherited from AbstractCollector
80  */
85  void onExport (const SensorData &data) override;
90  void onDriverStats (const ZWaveDriverEvent &event) override;
95  void onNodeStats (const ZWaveNodeEvent &event) override;
100  void onHciStats (const HciInfo &info) override;
101 
106  void onNotification(const OZWNotificationEvent &event) override;
107 
112  void onReceiveDPA(const BeeeOn::IQRFEvent&) override;
113 
118  void onConradMessage(const BeeeOn::ConradEvent&) override;
119 
124  void onDispatch(const Command::Ptr cmd) override;
125 
126  /*
127  * Setters for input data specified in the file factory.xml
128  * Each event has its own setter
129  * Each setter receives parameter value as input param
130  */
131  void setOnExport (const string &interface);
132  void setOnHCIStats (const string &interface);
133  void setOnNodeStats (const string &interface);
134  void setOnDriverStats (const string &interface);
135  void setOnNotification (const string &interface);
136  void setOnReceiveDPA(const string &interface);
137  void setOnConradMessage (const string &interface);
138  void setOnDispatch (const string &interface);
139  void setExportGwID (const string &gwID);
140 
141  /*
142  * Responsible for output interface initialization
143  * \param[in] interfaceMetaInfo Instace of class EventMetaData which handle meta information for one event
144  */
145  void initInterface(EventMetaData& interfaceMetaInfo);
146 
147  private:
148  // EventMetaData instance for each event
149  EventMetaData onExportMetaInfo;
150  EventMetaData onHCIStatsMetaInfo;
151  EventMetaData onNodeStatsMetaInfo;
152  EventMetaData onDriverStatsMetaInfo;
153  EventMetaData onNotificationMetaInfo;
154  EventMetaData onReceiveDPAMetaInfo;
155  EventMetaData onConradMessageMetaInfo;
156  EventMetaData onDispatchMetaInfo;
157  int exportGwID; // ID to identify data from this gateway
158  };
159 }
Definition: ZWaveNodeEvent.h:14
Definition: SensorData.h:20
Definition: NemeaCollector.h:52
Definition: ConradEvent.h:17
The class represents a collector of events occuring inside the Gateway. It implements all available l...
Definition: AbstractCollector.h:19
Definition: HciInfo.h:15
Definition: IQRFEvent.h:15
Definition: NemeaCollector.h:71
Definition: ZWaveDriverEvent.h:14
Low-level OpenZWave notification event. Because, the OpenZWave::Notification cannot be copied nor clo...
Definition: OZWNotificationEvent.h:16