de.cau.cs.kieler.sim.validator
Class InputDataComponent

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.validator.InputDataComponent
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension

public class InputDataComponent
extends JSONObjectDataComponent
implements IJSONObjectDataComponent

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
InputDataComponent()
           
 
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.
 void notifyEvent(KiemEvent event)
          This is the basic notify method that is called by KIEM whenever an event occurs for which this DataComponent is registered (see AbstractDataComponent.provideEventOfInterest()).
 KiemEvent provideEventOfInterest()
          Return a KiemEvent type (integer value) that represents a number of events this component wants to listen to.

A KiemEvent can be a combination of several events.
 KiemProperty[] provideProperties()
          Provide properties.
 JSONObject step(JSONObject jSONObject)
          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, provideFilterKeys, setConfigurationElemenet, setCurrentComponentID, setHistoryStep, setInitializationData, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputDataComponent

public InputDataComponent()
Method Detail

initialize

public void initialize()
                throws KiemInitializationException
Description copied from interface: IDataComponent
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

provideProperties

public KiemProperty[] provideProperties()
Provide properties.

Overrides:
provideProperties in class AbstractDataComponent
Returns:
the kiem property[]

isObserver

public boolean isObserver()
Description copied from interface: IDataComponent
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()
Description copied from interface: IDataComponent
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
Description copied from interface: IDataComponent
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()
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

step

public JSONObject step(JSONObject jSONObject)
                throws KiemExecutionException
Description copied from interface: IJSONObjectDataComponent
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:
jSONObject - the concrete JSONObject of input data (if observer)
Returns:
the JSONObject with the output data (if producer)
Throws:
KiemExecutionException - a KiemExecutionException

provideEventOfInterest

public KiemEvent provideEventOfInterest()
Description copied from class: AbstractDataComponent
Return a KiemEvent type (integer value) that represents a number of events this component wants to listen to.

A KiemEvent can be a combination of several events. The simplest way to register for two events that e.g., indicate a step-command and the save event is to have the following code:

public KiemEvent provideEventOfInterest() {
int[] events = {KiemEvent.CMD_STEP, KiemEvent.SAVE};
KiemEvent event = new KiemEvent(events);
System.out.println(event.getEventCodesAsList());
return (event);
} * }

NOTE: The provision of event types is only read by KIEM once before the execution starts. Hence, changes during the execution are not having any effect. In doubt, this method should return more events than needed. These could dynamically be ignored when temporarily not of interest.

Overrides:
provideEventOfInterest in class AbstractDataComponent
Returns:
the KiemEvent type indicating the events of interest

notifyEvent

public void notifyEvent(KiemEvent event)
Description copied from class: AbstractDataComponent
This is the basic notify method that is called by KIEM whenever an event occurs for which this DataComponent is registered (see AbstractDataComponent.provideEventOfInterest()).

Overrides:
notifyEvent in class AbstractDataComponent
Parameters:
event - the KiemEvent with additional attached information, depending on the specific event