se.liu.ida.critiquer.constraints
Class ResourceUsageCritic

java.lang.Object
  extended by se.liu.ida.critiquer.activities.AbstractParamChangedListener
      extended by se.liu.ida.critiquer.constraints.StandardConstraint
          extended by se.liu.ida.critiquer.constraints.ResourceUsageCritic
All Implemented Interfaces:
Serializable, Comparable<ActivityUpdateListener>, ActivityUpdateListener, GUIComponentCritic, SingletonConstraint, VisualConstraint, ViewRenderingListener

public class ResourceUsageCritic
extends StandardConstraint
implements GUIComponentCritic

A critic that is supposed to display information on resource usage depending on which resources are used at the current time in the time view

For each activity that is created, a constraint map is maintained that holds eq constraints for the activity start and end times so that their values reflect those of the mission time. The map also contains IfOnlyIf constraints that forces an integer variable agentUsage to 1 if the current time in the time view is within the mission time and 0 otherwise.

There is finally a total sum of the resource usage which is the sum of all agentUsage variables for all activities.

Author:
olale
See Also:
Serialized Form

Field Summary
static int MAX_USAGE
           
 
Fields inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
applicableViews, statusListeners, violationActivities
 
Constructor Summary
ResourceUsageCritic()
           
 
Method Summary
 JComponent getComponent()
          Return the chart panel
 String getDescription()
           
protected  void initApplicableViews()
          This view is only applicable to the time view
<T> void
paramChanged(Activity activity, Parameter<T> p)
          A parameter has changed value
 void viewUpdated(View v, Graphics2D g2)
          We only need set the currentTime through changing the currentTime eq constraint since the updating is already done by the ChartPanel component
 
Methods inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
addStatusListener, debug, error, getApplicableViews, getColor, info, isActive, isApplicableFor, isConsistent, removeStatusListener, setActive, setColor, setConsistent, warn
 
Methods inherited from class se.liu.ida.critiquer.activities.AbstractParamChangedListener
activityCreated, activityRemoved, activityUpdated, compareTo, paramAdded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_USAGE

public static final int MAX_USAGE
See Also:
Constant Field Values
Constructor Detail

ResourceUsageCritic

ResourceUsageCritic()
Method Detail

initApplicableViews

protected void initApplicableViews()
This view is only applicable to the time view

Overrides:
initApplicableViews in class StandardConstraint

getDescription

public String getDescription()
Specified by:
getDescription in interface SingletonConstraint

viewUpdated

public void viewUpdated(View v,
                        Graphics2D g2)
We only need set the currentTime through changing the currentTime eq constraint since the updating is already done by the ChartPanel component

Specified by:
viewUpdated in interface ViewRenderingListener

paramChanged

public <T> void paramChanged(Activity activity,
                             Parameter<T> p)
Description copied from interface: ActivityUpdateListener
A parameter has changed value

Specified by:
paramChanged in interface ActivityUpdateListener
Specified by:
paramChanged in class AbstractParamChangedListener

getComponent

public JComponent getComponent()
Return the chart panel

Specified by:
getComponent in interface GUIComponentCritic
Returns:
See Also:
GUIComponentCritic.getComponent()