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

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.Timed
      extended by hu.mta.sztaki.lpds.cloud.simulator.energy.EnergyMeter
          extended by hu.mta.sztaki.lpds.cloud.simulator.energy.DirectEnergyMeter
All Implemented Interfaces:
PowerState.PowerCharacteristicsChange, PowerBehaviorChangeListener, Comparable<Timed>

public class DirectEnergyMeter
extends EnergyMeter
implements PowerBehaviorChangeListener, PowerState.PowerCharacteristicsChange

Direct energy meters can monitor a single resource spreader and can convert their processed consumption values to a continuously updated energy figure.

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
private  double maxProcessable
          the maximum amount of totalprocessed increase possible during the metering time interval.
private  ResourceSpreader measuredResource
          the resource spreader that needs to be measured energywise
private  double previousProcessingReport
          the last collected totalProcessed value from the meteredResource.
private  PowerState usedPowerState
          the power state the particular measuredResource is in
 
Fields inherited from class hu.mta.sztaki.lpds.cloud.simulator.energy.EnergyMeter
lastMetered
 
Constructor Summary
DirectEnergyMeter(ResourceSpreader spreader)
          sets up the new meter.
 
Method Summary
 void behaviorChanged(ResourceSpreader onSpreader, PowerState newState)
          on this function the meter receives notifications on power state changes of the particular resource spreader
private  double collectProcessingReport()
          collects the total processed value from the measured resource spreader
 void prePowerChangeEvent(PowerState onMe)
          if the power state of the resource spreader changes then the meter is readjusted for the new power state - this usually means the meter collects all uncolledted resource consumption related information from the spreader
 boolean startMeter(long interval, boolean dropPriorReading)
          starts the metering session for the particular resource spreader
 void stopMeter()
          stops the metering session for the resource spreader
 void tick(long fires)
          Maintains the totalconsumption value in every desired time interval
 String toString()
          offers a convenient human readable output for debugging energy meters and their readings where both the metered resource and its currently reported total consumpiton is printed out
private  void updateFieldsUsingNewInterval(long interval)
          The maxProcessable field is updated with the metering frequency specified here
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.energy.EnergyMeter
getMeteringStarted, getMeteringStopped, getTotalConsumption, increaseTotalConsumption, readjustMeter
 
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, unsubscribe, updateFrequency
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

measuredResource

private ResourceSpreader measuredResource
the resource spreader that needs to be measured energywise


usedPowerState

private PowerState usedPowerState
the power state the particular measuredResource is in


previousProcessingReport

private double previousProcessingReport
the last collected totalProcessed value from the meteredResource.


maxProcessable

private double maxProcessable
the maximum amount of totalprocessed increase possible during the metering time interval.

Constructor Detail

DirectEnergyMeter

public DirectEnergyMeter(ResourceSpreader spreader)
sets up the new meter. keep in mind that metering is not started by calling this function.

Parameters:
spreader - specifies the resource spreader to be monitored in the later metering sessions.
Method Detail

toString

public String toString()
offers a convenient human readable output for debugging energy meters and their readings where both the metered resource and its currently reported total consumpiton is printed out

Overrides:
toString in class Timed

startMeter

public boolean startMeter(long interval,
                          boolean dropPriorReading)
starts the metering session for the particular resource spreader

Overrides:
startMeter in class EnergyMeter
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()
stops the metering session for the resource spreader

Overrides:
stopMeter in class EnergyMeter

behaviorChanged

public void behaviorChanged(ResourceSpreader onSpreader,
                            PowerState newState)
on this function the meter receives notifications on power state changes of the particular resource spreader

Specified by:
behaviorChanged in interface PowerBehaviorChangeListener
Parameters:
onSpreader - the resource spreader which changed its power state
newState - the new power state that is used by the spreader from now on.

prePowerChangeEvent

public void prePowerChangeEvent(PowerState onMe)
if the power state of the resource spreader changes then the meter is readjusted for the new power state - this usually means the meter collects all uncolledted resource consumption related information from the spreader

Specified by:
prePowerChangeEvent in interface PowerState.PowerCharacteristicsChange
Parameters:
onMe - with this parameter the change event propagates the power state for which the change is happening

updateFieldsUsingNewInterval

private void updateFieldsUsingNewInterval(long interval)
The maxProcessable field is updated with the metering frequency specified here

Parameters:
interval - the metering period (in ticks)

collectProcessingReport

private double collectProcessingReport()
collects the total processed value from the measured resource spreader

Returns:
the amount of processed resource consumptions the metered resource spreader has processed in its entire lifetime

tick

public void tick(long fires)
Maintains the totalconsumption value in every desired time interval

Specified by:
tick in class Timed
Parameters:
fires - The particular time instance when the function was called. The time instance is passed so the tick functions will not need to call getFireCount() if they need to operate on the actual time.


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