de.cau.cs.kieler.sim.table
Class DataObserver

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
      extended by de.cau.cs.kieler.sim.kiem.JSONStringDataComponent
          extended by de.cau.cs.kieler.sim.table.DataObserver
All Implemented Interfaces:
IDataComponent, IJSONStringDataComponent, IExecutableExtension

public class DataObserver
extends JSONStringDataComponent
implements IJSONStringDataComponent

The class DataObserver implements the observer DataComponent which should be scheduled behind any producer DataComponents. It updates the table's ViewPart according to the variables and signals it gets in its step(String) method from the execution manager.

Rating red

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
DataObserver()
          Instantiates a new observer DataComponent.
 
Method Summary
 void bringToFront()
          This method brings the Table view to the front.
 void initialize()
          Initialize.
 boolean isDeltaObserver()
          Checks if component is a delta observer.
 boolean isHistoryObserver()
          Flags that this component can handle past, already computed history values.
 boolean isObserver()
          To check whether the DataComponent is an observer.
 boolean isProducer()
          To check whether the DataComponent is a producer.
 String step(String jSONString)
          Step method for a DataObserver and a DataProducer.
 void wrapup()
          Wrap-up.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONStringDataComponent
getInitialVariables, provideInitialVariables, 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

DataObserver

public DataObserver()
Instantiates a new observer DataComponent.

Method Detail

step

public String step(String jSONString)
Step method for a DataObserver and a DataProducer.

For a producer only the argument will always be null. For an observer only this method will be called asynchronous. This may mean that in case the observer is slow, it may be skipped at some consecutive steps until it becomes ready again. If this is not desired and the observer MUST NOT be skipped, then the DataComponent should also be a DataProducer but return just null.

If an error occurs during the execution of the step method, a DataComponent should raise a KiemExecutionException that is then catched by the execution manager an brought to the user's attention.

Specified by:
step in interface IJSONStringDataComponent
Parameters:
jSONString - the concrete JSONString of input data (if observer)
Returns:
the JSONString with the output data (if producer)

bringToFront

public void bringToFront()
This method brings the Table view to the front.


initialize

public void initialize()
Initialize. Do some initializing prior to execution. If an error occurs during initialization, the DataComponent should raise a KiemInitializationException.

Specified by:
initialize in interface IDataComponent

isObserver

public boolean isObserver()
To check whether the DataComponent is an observer. If the DataComponent is an observer the arguments in its step() method will be != null.

Specified by:
isObserver in interface IDataComponent
Returns:
true, if is observer

isProducer

public boolean isProducer()
To check whether the DataComponent is a producer. If the DataComponent is a producer it should return != null in its step() method.

Specified by:
isProducer in interface IDataComponent
Returns:
true, if is producer

isDeltaObserver

public boolean isDeltaObserver()
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

isHistoryObserver

public boolean isHistoryObserver()
Flags that this component can handle past, already computed history values. Overwrite this if this component can explicitly handle past recorded history values.
In case the user makes steps back into the history, only observers that return true in this method will get any (recorded) history data. Components that return false (default) will not get any data, while the the user navigates within the recorded tick area.

Overrides:
isHistoryObserver in class AbstractDataComponent
Returns:
a boolean indicating that the component is recorded observer

wrapup

public void wrapup()
Wrap-up. Do some wrapping-up after execution has finished. If an error occurs during wrap up, the DataComponent should raise a KiemInitializationException.

Specified by:
wrapup in interface IDataComponent