Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.energy
Class Energy

    java.lang.Object
      avrora.sim.energy.Energy

All Implemented Interfaces:
  FiniteStateMachine.Probe

public class Energy
extends java.lang.Object
implements FiniteStateMachine.Probe

Class for energy modeling. All consumers create an instance of this class and keep it updated with all state changes concerning power consumption. This class keeps track of all these state changes and cycles spend in each state. The state changes are propagated to monitors based on a subscription system. This enables logging of power consumption.

Constructor Summary
`Energy(java.lang.String deviceName, double[] modeAmpere, FiniteStateMachine fsm)` create new energy class, to enable energy modelling

Method Summary
`void` | `activate()` active energy modeling, e.g. insert the probe into to component state machine
`void` | `fireAfterTransition(int beforeState, int afterState)` The `fireAfterTransition()` method allows the probe to gain control after the state machine transitions between two states.
`void` | `fireBeforeTransition(int beforeState, int afterState)` The `fireBeforeTransition()` method allows the probe to gain control before the state machine transitions between two states.
`double` | `getConsumedEnergy(int mode)` get the power consumption of a state
`double` | `getCurrentAmpere()` get the current draw
`int` | `getCurrentMode()` get the current state or mode of the device
`long` | `getCycles(int mode)` get the cycles spend in a device state
`double` | `getModeAmpere(int mode)` get the current draw of a mode
`java.lang.String` | `getModeName(int mode)` get the name of a mode
`int` | `getModeNumber()` get the number of modes of this device
`java.lang.String` | `getName()` get the device name
`double` | `getOldAmpere()` get the current draw of the old mode
`int` | `getOldMode()` get old mode
`double` | `getTotalConsumedEnergy()` get the power consumption of this device

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Energy

    public Energy(java.lang.String deviceName,
                  double[] modeAmpere,
                  FiniteStateMachine fsm)

  create new energy class, to enable energy modelling

Parameters:
  `deviceName` - name of the device to model
  `modeAmpere` - array of current draw for each device state (in Ampere)
  `fsm` - finite state machine of this device

Method Detail

### fireBeforeTransition

    public void fireBeforeTransition(int beforeState,
                                     int afterState)

  The `fireBeforeTransition()` method allows the probe to gain control before the state machine transitions between two states. The before state and the after state are passed as parameters.

  Specified by:
    `fireBeforeTransition` in interface `FiniteStateMachine.Probe`
  Parameters:
    `beforeState` - the before state represented as an integer
    `afterState` - the after state represented as an integer

### fireAfterTransition

    public void fireAfterTransition(int beforeState,
                                    int afterState)

  The `fireAfterTransition()` method allows the probe to gain control after the state machine transitions between two states. The before state and the after state are passed as parameters.

  Specified by:
    `fireAfterTransition` in interface `FiniteStateMachine.Probe`
  Parameters:
    `beforeState` - the before state represented as an integer
    `afterState` - the after state represented as an integer

### getTotalConsumedEnergy

    public double getTotalConsumedEnergy()

  get the power consumption of this device

  Returns:
    power consumption in Joule

### getConsumedEnergy

    public double getConsumedEnergy(int mode)

  get the power consumption of a state

  Parameters:
    `mode` - the mode or state
  Returns:
    power consumption in Joule

### getModeNumber

    public int getModeNumber()

  get the number of modes of this device

  Returns:
    mode number

### getCurrentMode

    public int getCurrentMode()

  get the current state or mode of the device

  Returns:
    current mode

### getModeName

    public java.lang.String getModeName(int mode)

  get the name of a mode

  Parameters:
    `mode` - mode number
  Returns:
    mode name

### getModeAmpere

    public double getModeAmpere(int mode)

  get the current draw of a mode

  Parameters:
    `mode` - mode number
  Returns:
    current draw in Ampere

### getCycles

    public long getCycles(int mode)

  get the cycles spend in a device state

  Parameters:
    `mode` - mode number
  Returns:
    cycles

### getName

    public java.lang.String getName()

  get the device name

  Returns:
    device name

### getOldMode

    public int getOldMode()

  get old mode

  Returns:
    old mode

### getCurrentAmpere

    public double getCurrentAmpere()

  get the current draw

  Returns:
    current draw in Ampere

### getOldAmpere

    public double getOldAmpere()

  get the current draw of the old mode

  Returns:
    current draw

### activate

    public void activate()

  active energy modeling, e.g. insert the probe into to component state machine

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD