public class EnergyModel extends java.lang.Object implements ModuleCommunicationListener
scanEnergy value).| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BASE_ENERGY_S
Base energy usage per second -setting id ("baseEnergy").
|
static java.lang.String |
ENERGY_VALUE_ID
ModuleCommunicationBus identifier for the "current amount of
energy left" variable. |
static java.lang.String |
INIT_ENERGY_S
Initial units of energy -setting id ("initialEnergy").
|
static java.lang.String |
SCAN_ENERGY_S
Energy usage per scanning (device discovery) -setting id ("scanEnergy").
|
static java.lang.String |
SCAN_RSP_ENERGY_S
Energy usage per scanning (device discovery) response -setting id
("scanResponseEnergy").
|
static java.lang.String |
TRANSMIT_ENERGY_S
Energy usage per second when sending -setting id ("transmitEnergy").
|
static java.lang.String |
WARMUP_S
Energy update warmup period -setting id ("energyWarmup").
|
| Modifier | Constructor and Description |
|---|---|
protected |
EnergyModel(EnergyModel proto)
Copy constructor.
|
|
EnergyModel(Settings s)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getEnergy()
Returns the current energy level
|
void |
moduleValueChanged(java.lang.String key,
java.lang.Object newValue)
Called by the combus if the energy value is changed
|
void |
reduceDiscoveryEnergy()
Reduces the energy reserve for the amount that is used when another
host connects (does device discovery)
|
protected void |
reduceEnergy(double amount)
Updates the current energy so that the given amount is reduced from it.
|
EnergyModel |
replicate() |
protected void |
setEnergy(double[] range)
Sets the current energy level into the given range using uniform
random distribution.
|
void |
update(NetworkInterface iface,
ModuleCommunicationBus comBus)
Reduces the energy reserve for the amount that is used by sending data
and scanning for the other nodes.
|
public static final java.lang.String INIT_ENERGY_S
public static final java.lang.String SCAN_ENERGY_S
public static final java.lang.String SCAN_RSP_ENERGY_S
public static final java.lang.String TRANSMIT_ENERGY_S
public static final java.lang.String BASE_ENERGY_S
public static final java.lang.String WARMUP_S
Report.WARMUP_S from the namespace
"Report".public static final java.lang.String ENERGY_VALUE_ID
ModuleCommunicationBus identifier for the "current amount of
energy left" variable. Value type: doublepublic EnergyModel(Settings s)
s - The settings objectprotected EnergyModel(EnergyModel proto)
proto - The model prototype where setting values are copied frompublic EnergyModel replicate()
protected void setEnergy(double[] range)
range - The min and max values of the range, or if only one value
is given, that is used as the energy levelpublic double getEnergy()
protected void reduceEnergy(double amount)
amount - The amount of energy to reducepublic void reduceDiscoveryEnergy()
public void update(NetworkInterface iface, ModuleCommunicationBus comBus)
public void moduleValueChanged(java.lang.String key,
java.lang.Object newValue)
moduleValueChanged in interface ModuleCommunicationListenerkey - The energy IDnewValue - The new energy value