EMANE  1.2.1
libemane/eventtablepublisher.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014,2017 - Adjacent Link LLC, Bridgewater, New Jersey
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * * Neither the name of Adjacent Link LLC nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include "eventtablepublisher.h"
34 
36  nemId_{nemId}{};
37 
39 {
41  pLocationTable_ =
42  statisticRegistrar.registerTable<NEMId>("LocationEventInfoTable",
43  {"NEM","Latitude","Longitude","Altitude","Pitch","Roll","Yaw","Azimuth","Elevation","Magnitude"},
45  "Shows the location event information received");
46 
47  pPathlossTable_ =
48  statisticRegistrar.registerTable<NEMId>("PathlossEventInfoTable",
49  {"NEM","Forward Pathloss","Reverse Pathloss"},
51  "Shows the precomputed pathloss information received");
52 
53  pAntennaProfileTable_ =
54  statisticRegistrar.registerTable<NEMId>("AntennaProfileEventInfoTable",
55  {"NEM","Antenna Profile","Antenna Azimuth","Antenna Elevation"},
57  "Shows the antenna profile information received");
58 
59  pFadingSelectionTable_ =
60  statisticRegistrar.registerTable<NEMId>("FadingSelectionInfoTable",
61  {"NEM","Model"},
63  "Shows the selected fading model information received");
64 
66 }
67 
69 {
70  for(const auto & location : locations)
71  {
72  auto targetNEM = location.getNEMId();
73 
74  if(locationNEMSet_.find(targetNEM) == locationNEMSet_.end())
75  {
76  auto position = location.getPosition();
77 
78  auto optionalOrientation = location.getOrientation();
79 
80  auto optionalVelocity = location.getVelocity();
81 
82  pLocationTable_->addRow(targetNEM,{Any{targetNEM},
83  Any{position.getLatitudeDegrees()},
84  Any{position.getLongitudeDegrees()},
85  Any{position.getAltitudeMeters()},
86  Any{optionalOrientation.first.getPitchDegrees()},
87  Any{optionalOrientation.first.getRollDegrees()},
88  Any{optionalOrientation.first.getYawDegrees()},
89  Any{optionalVelocity.first.getAzimuthDegrees()},
90  Any{optionalVelocity.first.getElevationDegrees()},
91  Any{optionalVelocity.first.getMagnitudeMetersPerSecond()}});
92 
93  locationNEMSet_.insert(targetNEM);
94  }
95  else
96  {
97  auto position = location.getPosition();
98 
99  auto optionalOrientation = location.getOrientation();
100 
101  auto optionalVelocity = location.getVelocity();
102 
103  pLocationTable_->setCell(targetNEM,1,Any{position.getLatitudeDegrees()});
104  pLocationTable_->setCell(targetNEM,2,Any{position.getLongitudeDegrees()});
105  pLocationTable_->setCell(targetNEM,3,Any{position.getAltitudeMeters()});
106 
107  if(optionalOrientation.second)
108  {
109  pLocationTable_->setCell(targetNEM,4,Any{optionalOrientation.first.getPitchDegrees()});
110  pLocationTable_->setCell(targetNEM,5,Any{optionalOrientation.first.getRollDegrees()});
111  pLocationTable_->setCell(targetNEM,6,Any{optionalOrientation.first.getYawDegrees()});
112  }
113 
114  if(optionalVelocity.second)
115  {
116  pLocationTable_->setCell(targetNEM,7,Any{optionalVelocity.first.getAzimuthDegrees()});
117  pLocationTable_->setCell(targetNEM,8,Any{optionalVelocity.first.getElevationDegrees()});
118  pLocationTable_->setCell(targetNEM,9,Any{optionalVelocity.first.getMagnitudeMetersPerSecond()});
119 
120  }
121  }
122  }
123 }
124 
126 {
127  for(const auto & pathloss : pathlosses)
128  {
129  auto targetNEM = pathloss.getNEMId();
130 
131  std::vector<Any> row{Any{targetNEM},
132  Any{pathloss.getForwardPathlossdB()},
133  Any{pathloss.getReversePathlossdB()}};
134 
135  if(pathlossNEMSet_.find(targetNEM) == pathlossNEMSet_.end())
136  {
137  pPathlossTable_->addRow(targetNEM,row);
138 
139  pathlossNEMSet_.insert(targetNEM);
140  }
141  else
142  {
143  pPathlossTable_->setRow(targetNEM,row);
144  }
145  }
146 }
147 
149 {
150 
151  for(const auto & profile : profiles)
152  {
153  auto targetNEM = profile.getNEMId();
154 
155  std::vector<Any> row{Any{targetNEM},
156  Any{profile.getAntennaProfileId()},
157  Any{profile.getAntennaAzimuthDegrees()},
158  Any{profile.getAntennaElevationDegrees()}};
159 
160  if(antennaProfileNEMSet_.find(targetNEM) == antennaProfileNEMSet_.end())
161  {
162  pAntennaProfileTable_->addRow(targetNEM,row);
163 
164  antennaProfileNEMSet_.insert(targetNEM);
165  }
166  else
167  {
168  pAntennaProfileTable_->setRow(targetNEM,row);
169  }
170  }
171 }
172 
174 {
175  for(const auto & selection : selections)
176  {
177  auto targetNEM = selection.getNEMId();
178 
179  std::string sModel{"unknown"};
180 
181  switch(selection.getFadingModel())
182  {
184  sModel = "none";
185  break;
187  sModel = "nakagami";
188  break;
189  }
190 
191  std::vector<Any> row{Any{targetNEM},
192  Any{sModel}};
193 
194  if(fadingSelectionNEMSet_.find(targetNEM) == fadingSelectionNEMSet_.end())
195  {
196  pFadingSelectionTable_->addRow(targetNEM,row);
197 
198  fadingSelectionNEMSet_.insert(targetNEM);
199  }
200  else
201  {
202  pFadingSelectionTable_->setRow(targetNEM,row);
203  }
204  }
205 }
void setCell(const Key &key, std::size_t columnIndex, const Any &any)
void update(const Events::Locations &locations)
void setRow(const Key &key, const std::vector< Any > &anys)
std::list< Pathloss > Pathlosses
Definition: pathloss.h:95
The StatisticRegistrar allows NEM layers to register statistics and statistic tables. Statistics and Statistic tables are owned by the emulator framework and a borrowed reference is returned to the registering NEM layer.
void registerStatistics(StatisticRegistrar &registrar)
StatisticTable< Key, Compare, scolumn > * registerTable(const std::string &sName, const StatisticTableLabels &labels, const StatisticProperties &properties=StatisticProperties::NONE, const std::string &sDescription="")
std::uint16_t NEMId
Definition: types.h:52
std::list< Location > Locations
Definition: location.h:108
void addRow(const Key &key, const std::vector< Any > &anys={})
std::list< FadingSelection > FadingSelections
The Any class can contain an instance of one of any type in its support type set. ...
Definition: any.h:49
std::list< AntennaProfile > AntennaProfiles