hu.mta.sztaki.lpds.cloud.simulator.energy
Class EnergyMeter

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.Timed
      extended by hu.mta.sztaki.lpds.cloud.simulator.energy.EnergyMeter
All Implemented Interfaces:
Comparable<Timed>
Direct Known Subclasses:
AggregatedEnergyMeter, DirectEnergyMeter

public abstract class EnergyMeter
extends Timed

Base class for all energy meters. Defines the basic operations but allows high level of customization

Author:
"Gabor Kecskemeti, Distributed and Parallel Systems Group, University of Innsbruck (c) 2013" "Gabor Kecskemeti, Laboratory of Parallel and Distributed Systems, MTA SZTAKI (c) 2014-5"

Field Summary
protected  long lastMetered
          when was the last metering result collected.
private  long meteringStarted
          determines the time instance when the current metering session has started.
private  long meteringStopped
          when did the metering stopped reported in absolute time.
private  double totalConsumption
          the currently collected totalConsumption in all metering sessions so far.
 
Constructor Summary
EnergyMeter()
           
 
Method Summary
 long getMeteringStarted()
          Allows the reading of the beginning time instance of the metering session If there were several metering sessions done by this meter, then this function reports the time instance when a hypothetical single continuous metering session would have started
 long getMeteringStopped()
          Enables access to the time when the last reading was stored for the last stopped metering session.
 double getTotalConsumption()
          Allows the reading of the meter's current consumption report.
protected  void increaseTotalConsumption(double amount)
          increases the total consumption value with the specified amount.
protected  void readjustMeter()
          Allows internal realignment to new metering situations that need an immediate utilization reading
 boolean startMeter(long interval, boolean dropPriorReading)
          Initiates an energy metering session.
 void stopMeter()
          Terminates the metering session, the totalconsumption values will no longer be updated!
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.Timed
calcTimeJump, compareTo, fire, getFireCount, getFrequency, getNextEvent, getNextFire, isSubscribed, jumpTime, nextEventDistance, resetTimed, setBackPreference, simulateUntil, simulateUntilLastEvent, skipEventsTill, subscribe, tick, toString, unsubscribe, updateFrequency
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

totalConsumption

private double totalConsumption
the currently collected totalConsumption in all metering sessions so far.


meteringStarted

private long meteringStarted
determines the time instance when the current metering session has started. This does not actually specify the time instance when the first metering session starts if there are gaps between metering sessions. instead it gives the time instance when a continuous metering session would start.


lastMetered

protected long lastMetered
when was the last metering result collected.


meteringStopped

private long meteringStopped
when did the metering stopped reported in absolute time.

Constructor Detail

EnergyMeter

public EnergyMeter()
Method Detail

startMeter

public boolean startMeter(long interval,
                          boolean dropPriorReading)
Initiates an energy metering session.

Parameters:
interval - The meter refresh frequency.
dropPriorReading -
    False: the totalConsumption values will accumulate from a previous metering session True: the totalconsumption values will start from 0 after the completion of this function.
Returns:
  • False: if a metering session is already underway
  • True: if the metering session was successfully initiated

stopMeter

public void stopMeter()
Terminates the metering session, the totalconsumption values will no longer be updated!


getTotalConsumption

public double getTotalConsumption()
Allows the reading of the meter's current consumption report.

Returns:
the total consumption collected during the metering sessions

getMeteringStarted

public long getMeteringStarted()
Allows the reading of the beginning time instance of the metering session If there were several metering sessions done by this meter, then this function reports the time instance when a hypothetical single continuous metering session would have started

Returns:
The time instance when the metering session started

getMeteringStopped

public long getMeteringStopped()
Enables access to the time when the last reading was stored for the last stopped metering session.

Returns:
Three values are possible:
  • -1: The metering session is ongoing it is not yet terminated
  • 0: There was no metering session so far with this meter
  • arbitrary positive number: The last reading time of the last stopped session.

increaseTotalConsumption

protected void increaseTotalConsumption(double amount)
increases the total consumption value with the specified amount. this is one of the main functions to be used by energy meters. Ensures that metering values are continuously increasing from a particular meter.

Parameters:
amount - the amount of additional energy consumed to be reported in this meter

readjustMeter

protected void readjustMeter()
Allows internal realignment to new metering situations that need an immediate utilization reading



Copyright © 2012–2015 University of Innsbruck & MTA SZTAKI. All rights reserved.