de.cau.cs.kieler.kev.extension.dataobserver
Class KEVDataObserver

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
      extended by de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
          extended by de.cau.cs.kieler.kev.extension.dataobserver.KEVDataObserver
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension

public class KEVDataObserver
extends JSONObjectDataComponent
implements IJSONObjectDataComponent

Rating proposed yellow
(2010-02-17)

Field Summary
 
Fields inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
MASTER_CMD_MACROSTEP, MASTER_CMD_PAUSE, MASTER_CMD_RUN, MASTER_CMD_STEP, MASTER_CMD_STEPBACK, MASTER_CMD_STOP
 
Constructor Summary
KEVDataObserver()
           
 
Method Summary
 void initialize()
          Disables the load button during execution and creates the KEV-view if it's not already done.
 boolean isDeltaObserver()
          Checks if component is a delta observer.
 boolean isHistoryObserver()
          Tells the ExecutionManager to store all data for an eventually history playback.
 boolean isObserver()
          Tells the ExecutionManager that the KEV-view is an observer.
 boolean isProducer()
          Tells the ExecutionManager that the KEV-view is not a producer.
 JSONObject provideInitialVariables()
          Sets the initial values for the KIEM data table with the SVG element id's from mapping file as JSON keys.
 JSONObject step(JSONObject jSONObject)
          Applies the JSON data to the SVG document.
 void wrapup()
          Sets the running status of the ExecutionManager to false an enables the open wizard button.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
getInitialVariables, provideFilterKeysJSON, setInitialVariables
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
checkProperties, finalize, getConfigurationElement, getCurrentComponentID, getDataComponentId, getName, getPluginId, getProperties, getShell, isHistoryStep, isInvisible, isMacroStepDone, isMaster, isMasterImplementingGUI, isMultiInstantiable, masterCommand, masterGetAimedStepDuration, masterGUI, masterGUIisEnabled, masterIsPaused, masterIsRunning, masterSetAimedStepDuration, masterSetKIEMInstance, notifyEvent, provideEventOfInterest, provideFilterKeys, provideProperties, setConfigurationElemenet, setCurrentComponentID, setHistoryStep, setInitializationData, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KEVDataObserver

public KEVDataObserver()
Method Detail

step

public JSONObject step(JSONObject jSONObject)
Applies the JSON data to the SVG document.

Specified by:
step in interface IJSONObjectDataComponent
Parameters:
jSONObject - The actual JSONObject, returned by the ExecutionManager.
Returns:
null Here we don't need to return a JSON object, because the KEV-view is an observer only now.
See Also:
IJSONObjectDataComponent#step(de.cau.cs.kieler.sim.kiem.json.JSONObject), JSONObject, ExecutionManager

provideInitialVariables

public JSONObject provideInitialVariables()
Sets the initial values for the KIEM data table with the SVG element id's from mapping file as JSON keys.

Overrides:
provideInitialVariables in class JSONObjectDataComponent
Returns:
The JSONObject with all SVG element id's of the current mapping file.

initialize

public void initialize()
                throws KiemInitializationException
Disables the load button during execution and creates the KEV-view if it's not already done.

Specified by:
initialize in interface IDataComponent
Throws:
KiemInitializationException - An exception which raises if the KEV-view can't be created.

isDeltaObserver

public boolean isDeltaObserver()
Description copied from class: AbstractDataComponent
Checks if component is a delta observer. Delta values are all changed values that exist in the present tick (and in the past ticks when this component may have been skipped).
If a component wants all (accumulated & updated) values of the present tick, it should return false.

Example:

Step...........|..1..|..2..|..3..|..4..|..5..|
-----------------------------------------------------
Producer.......|..A..|../..|..B..|..C..|..D..|
-----------------------------------------------------
Observer.......|.A...|.skip|.skip|.ABC.|.ABCD|
-----------------------------------------------------
DeltaObserver..|.A...|.skip|.skip|.BC..|.D...|
-----------------------------------------------------

The above figure shows an execution of 5 steps with three participating DataComponents. One producer generates (different) data at steps 1, 3, 4, and 5. It does not produce any data in step 2. Both observers get skipped in steps 2 and 3 (e. g., because they might be a little slow). In step 1 both observers get the A data. Because there is no data in the pool, both inputs (their parameter values) are the same. In steps 2 and 3 both get skipped. Their step() method is not called in these steps. In step 4 the DeltaObserver gets only the B and the D data, produced in steps 3 and 4 (these are the delta values to the last time it was not skipped, i. e., step 1). The other observer gets the whole data of the pool, namely the A, B, and the C data. In step 5 the recently produced D data are the only ones that arrive at the DeltaObserver while the other observer gets all ever produced data A, B, C and D.

Overrides:
isDeltaObserver in class AbstractDataComponent
Returns:
true, if is delta observer

isObserver

public boolean isObserver()
Tells the ExecutionManager that the KEV-view is an observer.

Specified by:
isObserver in interface IDataComponent
Returns:
true, because the KEV-view is an observer.
See Also:
de.cau.cs.kieler.sim.kiem.extension.IDataComponent#isObserver(), ExecutionManager

isProducer

public boolean isProducer()
Tells the ExecutionManager that the KEV-view is not a producer.

Specified by:
isProducer in interface IDataComponent
Returns:
false, because the KEV-view is not a producer.
See Also:
de.cau.cs.kieler.sim.kiem.extension.IDataComponent#isProducer()

isHistoryObserver

public boolean isHistoryObserver()
Tells the ExecutionManager to store all data for an eventually history playback.

Overrides:
isHistoryObserver in class AbstractDataComponent
Returns:
true, because KEV-view should be able the show history steps.

wrapup

public void wrapup()
Sets the running status of the ExecutionManager to false an enables the open wizard button.

Specified by:
wrapup in interface IDataComponent
See Also:
de.cau.cs.kieler.sim.kiem.extension.IDataComponent#wrapup(), Activator