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) 2010 Network Security Lab, University of Washington, Seattle. | 3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
4 * Copyright (c) 2014 Laboratory A.R.T.S. - University Mediterranea of Reggio Ca
labria | 4 * Copyright (c) 2014 Laboratory A.R.T.S. - University Mediterranea of Reggio Ca
labria |
5 * | 5 * |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
9 * published by the Free Software Foundation; | 9 * published by the Free Software Foundation; |
10 * | 10 * |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 NS_ASSERT (source != NULL); | 65 NS_ASSERT (source != NULL); |
66 // check if device is WifiNetDevice | 66 // check if device is WifiNetDevice |
67 std::string deviceName = device->GetInstanceTypeId ().GetName (); | 67 std::string deviceName = device->GetInstanceTypeId ().GetName (); |
68 if (deviceName.compare ("ns3::WifiNetDevice") != 0) | 68 if (deviceName.compare ("ns3::WifiNetDevice") != 0) |
69 { | 69 { |
70 NS_FATAL_ERROR ("NetDevice type is not WifiNetDevice!"); | 70 NS_FATAL_ERROR ("NetDevice type is not WifiNetDevice!"); |
71 } | 71 } |
72 Ptr<Node> node = device->GetNode (); | 72 Ptr<Node> node = device->GetNode (); |
73 Ptr<WifiRadioEnergyModel> model = m_radioEnergy.Create ()->GetObject<WifiRadio
EnergyModel> (); | 73 Ptr<WifiRadioEnergyModel> model = m_radioEnergy.Create ()->GetObject<WifiRadio
EnergyModel> (); |
74 NS_ASSERT (model != NULL); | 74 NS_ASSERT (model != NULL); |
75 device->AggregateObject(model); | |
76 // set energy source pointer | 75 // set energy source pointer |
77 model->SetEnergySource (source); | 76 model->SetEnergySource (source); |
| 77 device->AggregateObject (model); |
78 // set energy depletion callback | 78 // set energy depletion callback |
79 model->SetEnergyDepletionCallback (m_depletionCallback); | 79 model->SetEnergyDepletionCallback (m_depletionCallback); |
80 // add model to device model list in energy source | 80 // add model to device model list in energy source |
81 source->AppendDeviceEnergyModel (model); | 81 source->AppendDeviceEnergyModel (model); |
82 // create and register energy model phy listener | 82 // create and register energy model phy listener |
83 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); | 83 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); |
84 Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy (); | 84 Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy (); |
85 wifiPhy->RegisterListener (model->GetPhyListener ()); | 85 wifiPhy->RegisterListener (model->GetPhyListener ()); |
86 return model; | 86 return model; |
87 } | 87 } |
88 | 88 |
89 } // namespace ns3 | 89 } // namespace ns3 |
LEFT | RIGHT |