EMANE  1.0.1
libemane/eventtablepublisher.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 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");
59 }
60 
62 {
63  for(const auto & location : locations)
64  {
65  auto targetNEM = location.getNEMId();
66 
67  if(locationNEMSet_.find(targetNEM) == locationNEMSet_.end())
68  {
69  auto position = location.getPosition();
70 
71  auto optionalOrientation = location.getOrientation();
72 
73  auto optionalVelocity = location.getVelocity();
74 
75  pLocationTable_->addRow(targetNEM,{Any{targetNEM},
76  Any{position.getLatitudeDegrees()},
77  Any{position.getLongitudeDegrees()},
78  Any{position.getAltitudeMeters()},
79  Any{optionalOrientation.first.getPitchDegrees()},
80  Any{optionalOrientation.first.getRollDegrees()},
81  Any{optionalOrientation.first.getYawDegrees()},
82  Any{optionalVelocity.first.getAzimuthDegrees()},
83  Any{optionalVelocity.first.getElevationDegrees()},
84  Any{optionalVelocity.first.getMagnitudeMetersPerSecond()}});
85 
86  locationNEMSet_.insert(targetNEM);
87  }
88  else
89  {
90  auto position = location.getPosition();
91 
92  auto optionalOrientation = location.getOrientation();
93 
94  auto optionalVelocity = location.getVelocity();
95 
96  pLocationTable_->setCell(targetNEM,1,Any{position.getLatitudeDegrees()});
97  pLocationTable_->setCell(targetNEM,2,Any{position.getLongitudeDegrees()});
98  pLocationTable_->setCell(targetNEM,3,Any{position.getAltitudeMeters()});
99 
100  if(optionalOrientation.second)
101  {
102  pLocationTable_->setCell(targetNEM,4,Any{optionalOrientation.first.getPitchDegrees()});
103  pLocationTable_->setCell(targetNEM,5,Any{optionalOrientation.first.getRollDegrees()});
104  pLocationTable_->setCell(targetNEM,6,Any{optionalOrientation.first.getYawDegrees()});
105  }
106 
107  if(optionalVelocity.second)
108  {
109  pLocationTable_->setCell(targetNEM,7,Any{optionalVelocity.first.getAzimuthDegrees()});
110  pLocationTable_->setCell(targetNEM,8,Any{optionalVelocity.first.getElevationDegrees()});
111  pLocationTable_->setCell(targetNEM,9,Any{optionalVelocity.first.getMagnitudeMetersPerSecond()});
112 
113  }
114  }
115  }
116 }
117 
119 {
120  for(const auto & pathloss : pathlosses)
121  {
122  auto targetNEM = pathloss.getNEMId();
123 
124  std::vector<Any> row{Any{targetNEM},
125  Any{pathloss.getForwardPathlossdB()},
126  Any{pathloss.getReversePathlossdB()}};
127 
128  if(pathlossNEMSet_.find(targetNEM) == pathlossNEMSet_.end())
129  {
130  pPathlossTable_->addRow(targetNEM,row);
131 
132  pathlossNEMSet_.insert(targetNEM);
133  }
134  else
135  {
136  pPathlossTable_->setRow(targetNEM,row);
137  }
138  }
139 }
140 
142 {
143 
144  for(const auto & profile : profiles)
145  {
146  auto targetNEM = profile.getNEMId();
147 
148  std::vector<Any> row{Any{targetNEM},
149  Any{profile.getAntennaProfileId()},
150  Any{profile.getAntennaAzimuthDegrees()},
151  Any{profile.getAntennaElevationDegrees()}};
152 
153  if(antennaProfileNEMSet_.find(targetNEM) == antennaProfileNEMSet_.end())
154  {
155  pAntennaProfileTable_->addRow(targetNEM,row);
156 
157  antennaProfileNEMSet_.insert(targetNEM);
158  }
159  else
160  {
161  pAntennaProfileTable_->setRow(targetNEM,row);
162  }
163  }
164 }
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={})
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