author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 17 Mar 2008 05:22:29 +0100 | |
changeset 2637 | ac94e4889027 |
parent 2310 | 52e0cd1de091 |
permissions | -rw-r--r-- |
2310
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 University of Washington |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
*/ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
#include "ns3/log.h" |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
#include "energy-model.h" |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
NS_LOG_COMPONENT_DEFINE("EnergyModel"); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
namespace ns3 { |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// Some dimensional analysis ... |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
// 1 [watt] = 1 [joule] / [second] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
// 1 [watt] = 1 [volt] * 1 [amp] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
// 1 [amp] = 1 [coulomb] / 1 [second] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
// 1 [watt-second] = 1 [joule] / [second] * [second] = 1 [joule] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
// A watt has dimensions of energy per second. A watt-second has dimensions |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
// of energy. |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
// 1 [amp-hour] = 1 [coulomb] / 1 [second] * 1 [hour] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
// 1 [amp-hour] = 1 [coulomb] / 1 [second] * 3600 [seconds] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
// 1 [amp-hour] = 3600 [amp-seconds] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
// 1 [watt-second] = 1 [amp-seconds] * 1 [volt] |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
// To get the energy capacity of your battery in watt-seconds from its |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
// amp-hour rating, multiply by 3600 and then the voltage. For example, your |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
// Alkaline AAA battery may be rated at 1.5 volts and 900 milli-amp-hours; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
// so the energy capacity will be .9 * 3600 * 1.5 = 4860 watt-seconds. |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
// In a very simple battery model, we'll take this naively to mean that this |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
// battery can supply one watt continuously for 4860 seconds and then will die |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
// instantaneously. |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
// We'll assume our transmitter is measured in watts. When it is turned on |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
// it draws some amount of power, 100 milliwatts for example. If it transmits |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
// for one second, it will suck up .1 watt-seconds of our precious energy. |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
// |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
const InterfaceId EnergyModel::iid = |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
MakeInterfaceId ("EnergyModel", Object::iid); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
EnergyModel::EnergyModel ( |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
double ampHours, |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
double volts, |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
double idlePower, |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
double receivePower, |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
double transmitPower) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
: |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
m_capacity (ampHours * 3600. * volts), |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
m_idlePower (idlePower), |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
m_receivePower (receivePower), |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
m_transmitPower (transmitPower), |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
m_totalTransmitPower (0.), |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
m_totalReceivePower (0.) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
SetInterfaceId (EnergyModel::iid); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
EnergyModel::~EnergyModel () |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
double |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
EnergyModel::GetCapacity (Time t) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
double c = m_capacity - m_idlePower * t.GetSeconds (); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
return c >= 0. ? c : 0.; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
double |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
EnergyModel::GetTotalIdlePower (Time t) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
return m_idlePower * t.GetSeconds (); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
double |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
EnergyModel::GetTotalReceivePower (void) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
return m_totalReceivePower; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
double |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
EnergyModel::GetTotalTransmitPower (void) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
return m_totalTransmitPower; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
bool |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
EnergyModel::DrawTransmitPower (Time t) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
double power = m_transmitPower * t.GetSeconds (); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
m_totalTransmitPower += power; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
m_capacity -= power; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
return m_capacity - m_idlePower * t.GetSeconds () >= 0. ? true : false; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
bool |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
EnergyModel::DrawReceivePower (Time t) |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
{ |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
NS_LOG_FUNCTION; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
double power = m_receivePower * t.GetSeconds (); |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
m_totalReceivePower += power; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
m_capacity -= power; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
return m_capacity - m_idlePower * t.GetSeconds () >= 0. ? true : false; |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
} |
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
|
52e0cd1de091
half of example describing how to plumb in new model without plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
}; // namespace ns3 |