LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya
(CTTC) | 3 * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya
(CTTC) |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 /** | 63 /** |
64 * \ingroup buildings-test | 64 * \ingroup buildings-test |
65 * \ingroup tests | 65 * \ingroup tests |
66 * | 66 * |
67 * \brief data to construct a Building object. We don't want to pass Building | 67 * \brief data to construct a Building object. We don't want to pass Building |
68 * objects to the TestCase constructor because otherwise BuildingList | 68 * objects to the TestCase constructor because otherwise BuildingList |
69 * would contain all of them (even if only one is meant to be in the | 69 * would contain all of them (even if only one is meant to be in the |
70 * test case). | 70 * test case). |
71 * | 71 * |
72 */ | 72 */ |
73 struct BuildingData | 73 struct BuildingData |
74 { | 74 { |
75 BuildingData (); | 75 BuildingData (); |
76 double xmin; ///< X minimum | 76 double xmin; ///< X minimum |
77 double xmax; ///< X maximum | 77 double xmax; ///< X maximum |
78 double ymin; ///< Y minimum | 78 double ymin; ///< Y minimum |
79 double ymax; ///< Y maximum | 79 double ymax; ///< Y maximum |
80 double zmin; ///< Z minimum | 80 double zmin; ///< Z minimum |
81 double zmax; ///< Z maximum | 81 double zmax; ///< Z maximum |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * \param pib The position in the buulding | 118 * \param pib The position in the buulding |
119 * \param bd The building data | 119 * \param bd The building data |
120 */ | 120 */ |
121 BuildingsHelperOneTestCase (PositionInBuilding pib, BuildingData bd); | 121 BuildingsHelperOneTestCase (PositionInBuilding pib, BuildingData bd); |
122 | 122 |
123 private: | 123 private: |
124 virtual void DoRun (void); | 124 virtual void DoRun (void); |
125 | 125 |
126 PositionInBuilding m_pib; ///< position in building | 126 PositionInBuilding m_pib; ///< position in building |
127 BuildingData m_bd; ///< building data | 127 BuildingData m_bd; ///< building data |
128 | 128 |
129 }; | 129 }; |
130 | 130 |
131 std::string BuildingsHelperOneTestCase::BuildNameString (PositionInBuilding pib,
BuildingData bd) | 131 std::string BuildingsHelperOneTestCase::BuildNameString (PositionInBuilding pib,
BuildingData bd) |
132 { | 132 { |
133 std::ostringstream oss; | 133 std::ostringstream oss; |
134 oss << "pos=" << pib.pos; | 134 oss << "pos=" << pib.pos; |
135 if (pib.indoor) | 135 if (pib.indoor) |
136 { | 136 { |
137 oss << ", bid=" << pib.bid | 137 oss << ", bid=" << pib.bid |
138 » << ", rx=" << pib.rx· | 138 << ", rx=" << pib.rx |
139 » << ", ry=" << pib.ry | 139 << ", ry=" << pib.ry |
140 » << ", fn=" << pib.fn; | 140 << ", fn=" << pib.fn; |
141 } | 141 } |
142 else | 142 else |
143 { | 143 { |
144 oss << ", outdoor"; | 144 oss << ", outdoor"; |
145 } | 145 } |
146 return oss.str (); | 146 return oss.str (); |
147 } | 147 } |
148 | 148 |
149 | 149 |
150 BuildingsHelperOneTestCase::BuildingsHelperOneTestCase (PositionInBuilding pib,
BuildingData bd) | 150 BuildingsHelperOneTestCase::BuildingsHelperOneTestCase (PositionInBuilding pib,
BuildingData bd) |
151 : TestCase (BuildNameString (pib, bd)), | 151 : TestCase (BuildNameString (pib, bd)), |
152 m_pib (pib), | 152 m_pib (pib), |
153 m_bd (bd) | 153 m_bd (bd) |
154 { | 154 { |
155 } | 155 } |
156 | 156 |
157 void | 157 void |
158 BuildingsHelperOneTestCase::DoRun () | 158 BuildingsHelperOneTestCase::DoRun () |
159 { | 159 { |
160 NS_LOG_FUNCTION (this << BuildNameString (m_pib, m_bd)); | 160 NS_LOG_FUNCTION (this << BuildNameString (m_pib, m_bd)); |
161 MobilityHelper mobility; | 161 MobilityHelper mobility; |
162 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); | 162 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
163 | 163 |
164 NodeContainer nodes; | 164 NodeContainer nodes; |
165 nodes.Create (1); | 165 nodes.Create (1); |
166 mobility.Install (nodes); | 166 mobility.Install (nodes); |
167 | 167 |
168 Ptr<ConstantPositionMobilityModel> bmm = nodes.Get (0)->GetObject<ConstantPosi
tionMobilityModel> (); | 168 Ptr<ConstantPositionMobilityModel> bmm = nodes.Get (0)->GetObject<ConstantPosi
tionMobilityModel> (); |
169 bmm->SetPosition (m_pib.pos); | 169 bmm->SetPosition (m_pib.pos); |
170 | 170 |
171 NS_LOG_LOGIC ("create building"); | 171 NS_LOG_LOGIC ("create building"); |
172 Ptr<Building> b = CreateObject<Building> (); | 172 Ptr<Building> b = CreateObject<Building> (); |
173 b->SetBoundaries (Box (m_bd.xmin, m_bd.xmax, m_bd.ymin, m_bd.ymax, m_bd.zmin,
m_bd.zmax)); | 173 b->SetBoundaries (Box (m_bd.xmin, m_bd.xmax, m_bd.ymin, m_bd.ymax, m_bd.zmin,
m_bd.zmax)); |
174 b->SetNFloors (m_bd.nf); | 174 b->SetNFloors (m_bd.nf); |
175 b->SetNRoomsX (m_bd.nrx); | 175 b->SetNRoomsX (m_bd.nrx); |
176 b->SetNRoomsY (m_bd.nry); | 176 b->SetNRoomsY (m_bd.nry); |
177 Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> (b
); | 177 Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> (b
); |
178 bmm->AggregateObject (buildingInfo); // operation usually done by BuildingsHel
per::Install | 178 bmm->AggregateObject (buildingInfo); // operation usually done by BuildingsHel
per::Install |
179 BuildingsHelper::MakeMobilityModelConsistent (); | 179 BuildingsHelper::MakeMobilityModelConsistent (); |
180 | 180 |
181 | 181 |
182 NS_TEST_ASSERT_MSG_EQ (buildingInfo->IsIndoor (), m_pib.indoor, "indoor/outdoo
r mismatch"); | 182 NS_TEST_ASSERT_MSG_EQ (buildingInfo->IsIndoor (), m_pib.indoor, "indoor/outdoo
r mismatch"); |
183 if (m_pib.indoor) | 183 if (m_pib.indoor) |
184 { | 184 { |
185 NS_LOG_LOGIC (" got bid=" << buildingInfo->GetBuilding ()->GetId () << ",
f=" << (uint32_t) buildingInfo->GetFloorNumber () << ", rx=" << (uint32_t) build
ingInfo->GetRoomNumberX () << ", roomY=" << (uint32_t) buildingInfo->GetRoomNumb
erY ()); | 185 NS_LOG_LOGIC (" got bid=" << buildingInfo->GetBuilding ()->GetId () << ",
f=" << (uint32_t) buildingInfo->GetFloorNumber () << ", rx=" << (uint32_t) build
ingInfo->GetRoomNumberX () << ", roomY=" << (uint32_t) buildingInfo->GetRoomNumb
erY ()); |
186 // only one building in this test, so Id will be 0 | 186 // only one building in this test, so Id will be 0 |
187 NS_TEST_ASSERT_MSG_EQ (buildingInfo->GetBuilding ()->GetId (), 0, "Buildin
g ID mismatch"); | 187 NS_TEST_ASSERT_MSG_EQ (buildingInfo->GetBuilding ()->GetId (), 0, "Buildin
g ID mismatch"); |
188 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetFloorNumber (), m_pib.f
n, "floor number mismatch"); | 188 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetFloorNumber (), m_pib.f
n, "floor number mismatch"); |
189 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetRoomNumberX (), m_pib.r
x, "x room number mismatch"); | 189 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetRoomNumberX (), m_pib.r
x, "x room number mismatch"); |
190 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetRoomNumberY (), m_pib.r
y, "y room number mismatch"); | 190 NS_TEST_ASSERT_MSG_EQ ((uint32_t) buildingInfo->GetRoomNumberY (), m_pib.r
y, "y room number mismatch"); |
191 } | 191 } |
192 | 192 |
193 Simulator::Destroy (); | 193 Simulator::Destroy (); |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 | 197 |
198 | 198 |
199 | 199 |
200 | 200 |
201 /** | 201 /** |
202 * \ingroup buildings-test | 202 * \ingroup buildings-test |
203 * \ingroup tests | 203 * \ingroup tests |
(...skipping 14 matching lines...) Expand all Loading... |
218 | 218 |
219 BuildingData b1; | 219 BuildingData b1; |
220 b1.xmin = 1; | 220 b1.xmin = 1; |
221 b1.xmax = 3; | 221 b1.xmax = 3; |
222 b1.ymin = 1; | 222 b1.ymin = 1; |
223 b1.ymax = 2; | 223 b1.ymax = 2; |
224 b1.zmin = 0; | 224 b1.zmin = 0; |
225 b1.zmax = 4; | 225 b1.zmax = 4; |
226 b1.nrx = 1; | 226 b1.nrx = 1; |
227 b1.nry = 1; | 227 b1.nry = 1; |
228 b1.nf = 1; | 228 b1.nf = 1; |
229 | 229 |
230 Vector vp1 (1.5, 1.5, 0.5); | 230 Vector vp1 (1.5, 1.5, 0.5); |
231 PositionInBuilding p1; | 231 PositionInBuilding p1; |
232 p1.pos = vp1; | 232 p1.pos = vp1; |
233 p1.indoor = true; | 233 p1.indoor = true; |
234 p1.bid = 0; | 234 p1.bid = 0; |
235 p1.rx = 1; | 235 p1.rx = 1; |
236 p1.ry = 1; | 236 p1.ry = 1; |
237 p1.fn = 1; | 237 p1.fn = 1; |
238 AddTestCase (new BuildingsHelperOneTestCase (p1, b1), TestCase::QUICK); | 238 AddTestCase (new BuildingsHelperOneTestCase (p1, b1), TestCase::QUICK); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 Vector vq6 (0.2, 0.3, -0.2); | 344 Vector vq6 (0.2, 0.3, -0.2); |
345 PositionInBuilding q6; | 345 PositionInBuilding q6; |
346 q6.pos = vq6; | 346 q6.pos = vq6; |
347 q6.indoor = false; | 347 q6.indoor = false; |
348 AddTestCase (new BuildingsHelperOneTestCase (q6, b2), TestCase::QUICK); | 348 AddTestCase (new BuildingsHelperOneTestCase (q6, b2), TestCase::QUICK); |
349 | 349 |
350 Vector vq7 (0.2, 0.3, 2.001); | 350 Vector vq7 (0.2, 0.3, 2.001); |
351 PositionInBuilding q7; | 351 PositionInBuilding q7; |
352 q7.pos = vq7; | 352 q7.pos = vq7; |
353 q7.indoor = false; | 353 q7.indoor = false; |
354 AddTestCase (new BuildingsHelperOneTestCase (q7, b2), TestCase::QUICK); | 354 AddTestCase (new BuildingsHelperOneTestCase (q7, b2), TestCase::QUICK); |
355 } | 355 } |
356 | 356 |
357 static BuildingsHelperTestSuite buildingsHelperAntennaTestSuiteInstance; | 357 static BuildingsHelperTestSuite buildingsHelperAntennaTestSuiteInstance; |
LEFT | RIGHT |