OLD | NEW |
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 * | 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 { | 60 { |
61 NS_ASSERT (device != NULL); | 61 NS_ASSERT (device != NULL); |
62 NS_ASSERT (source != NULL); | 62 NS_ASSERT (source != NULL); |
63 // check if device is WifiNetDevice | 63 // check if device is WifiNetDevice |
64 std::string deviceName = device->GetInstanceTypeId ().GetName (); | 64 std::string deviceName = device->GetInstanceTypeId ().GetName (); |
65 if (deviceName.compare ("ns3::WifiNetDevice") != 0) | 65 if (deviceName.compare ("ns3::WifiNetDevice") != 0) |
66 { | 66 { |
67 NS_FATAL_ERROR ("NetDevice type is not WifiNetDevice!"); | 67 NS_FATAL_ERROR ("NetDevice type is not WifiNetDevice!"); |
68 } | 68 } |
69 Ptr<Node> node = device->GetNode (); | 69 Ptr<Node> node = device->GetNode (); |
70 Ptr<WifiRadioEnergyModel> model = m_radioEnergy.Create ()-> | 70 Ptr<WifiRadioEnergyModel> model = m_radioEnergy.Create ()->GetObject<WifiRadio
EnergyModel> (); |
71 GetObject<WifiRadioEnergyModel> (); | |
72 NS_ASSERT (model != NULL); | 71 NS_ASSERT (model != NULL); |
73 // set node pointer | |
74 model->SetNode (node); | |
75 // set energy source pointer | 72 // set energy source pointer |
76 model->SetEnergySource (source); | 73 model->SetEnergySource (source); |
77 // set energy depletion callback | 74 // set energy depletion callback |
78 model->SetEnergyDepletionCallback (m_depletionCallback); | 75 model->SetEnergyDepletionCallback (m_depletionCallback); |
79 // add model to device model list in energy source | 76 // add model to device model list in energy source |
80 source->AppendDeviceEnergyModel (model); | 77 source->AppendDeviceEnergyModel (model); |
81 // create and install energy model callback | 78 // create and register energy model phy listener |
82 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); | 79 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); |
83 Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy (); | 80 Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy (); |
84 DeviceEnergyModel::ChangeStateCallback callback; | 81 wifiPhy->RegisterListener (model->GetPhyListener ()); |
85 callback = MakeCallback (&DeviceEnergyModel::ChangeState, model); | |
86 //wifiPhy->SetEnergyModelCallback (callback); | |
87 return model; | 82 return model; |
88 } | 83 } |
89 | 84 |
90 } // namespace ns3 | 85 } // namespace ns3 |
OLD | NEW |