de.cau.cs.kieler.sim.syncsignalreset
Class DataComponent

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.sim.syncsignalreset.DataComponent
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension

public class DataComponent
extends JSONObjectDataComponent
implements IJSONObjectDataComponent

The class DataComponent implements the KIEM Extension Point. The step(JSONObject) method looks out for present signals and resets the to be absent again, because signals within the KIELER Execution Manager are explicitly made present or absent.

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
DataComponent()
           
 
Method Summary
 void initialize()
          Initialize.
 boolean isDeltaObserver()
          Checks if component is a delta observer.
 boolean isObserver()
          To check whether the DataComponent is an observer.
 boolean isProducer()
          To check whether the DataComponent is a producer.
 JSONObject step(JSONObject allDataIn)
          Step method for a DataObserver and a DataPrroducer.
 void wrapup()
          Wrap-up.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
getInitialVariables, provideFilterKeysJSON, provideInitialVariables, setInitialVariables
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
checkProperties, finalize, getConfigurationElement, getCurrentComponentID, getDataComponentId, getName, getPluginId, getProperties, getShell, isHistoryObserver, 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

DataComponent

public DataComponent()
Method Detail

step

public JSONObject step(JSONObject allDataIn)
                throws KiemExecutionException
Step method for a DataObserver and a DataPrroducer.

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 IJSONObjectDataComponent
Parameters:
allDataIn - the concrete JSONObject of input data (if observer)
Returns:
the JSONObject with the output data (if producer)
Throws:
KiemExecutionException - a KiemExecutionException

initialize

public void initialize()
                throws KiemInitializationException
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
Throws:
KiemInitializationException - a KiemInitializationException

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

wrapup

public void wrapup()
            throws KiemInitializationException
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
Throws:
KiemInitializationException - a KiemInitializationException

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