de.cau.cs.kieler.synccharts.sim.ptolemy
Class SyncchartsSimDataComponent

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.kiem.ui.datacomponent.JSONObjectSimulationDataComponent
              extended by de.cau.cs.kieler.synccharts.sim.ptolemy.SyncchartsSimDataComponent
All Implemented Interfaces:
IDataComponent, IJSONObjectDataComponent, IExecutableExtension

public class SyncchartsSimDataComponent
extends JSONObjectSimulationDataComponent

The class SimpleRailCtrl DataComponent implements a KIELER Execution Manager DataComponent.
Within its initialize() method it performs the model2model Xtend transformation to create a semantically equivalent but executable Ptolemy model out of the SimpleRailCtrl EMF model instance. It also loads the Ptolemy model within a PtolemyExecutor and adapts the port and host for connecting to the model railway simulation engine.
Within its JSONObjectSimulationDataComponent.step(JSONObject) method it then triggers a step of the PtolemyExecutor. Because this is done asynchronously the triggering of a consecutive step may lead to an KiemExecutionError be thrown that was initially the consequence of the last (async) call to the step method of the PtolemyExecutor.

Rating red

Field Summary
 
Fields inherited from class de.cau.cs.kieler.sim.kiem.ui.datacomponent.JSONObjectSimulationDataComponent
activePage, activePageFlag, exception, modelEditor
 
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
SyncchartsSimDataComponent()
          Instantiates a new SimpleRailCtrl DataComponent for the KIELER Execution Manager.
 
Method Summary
 boolean checkModelValidation(EObject rootEObject)
          Check the model validation.
 void doModel2ModelTransform(KielerProgressMonitor monitor)
          Implementation of model 2 model transformation.
 JSONObject doProvideInitialVariables()
          Performs the normal provide initial variables method.
 KiemProperty[] doProvideProperties()
          Do provide an additional property to set the state name.
 JSONObject doStep(JSONObject jSONObject)
          Implements the real step method for this simulation datacomponent.
 void initialize()
          Initialize.
 void loadAndExecuteModel()
           
 URL resolveBundelFile(String relativePath)
           
 void wrapup()
          Wrap-up.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.ui.datacomponent.JSONObjectSimulationDataComponent
bringProblemsViewToFront, checkProperties, getActivePage, getEditor, getInputEditor, getInputModel, getInputModelAsURI, getInputModelEObject, getInputResourceSet, getInputWorkspaceModel, getModelRootElement, getNotationElement, isObserver, isProducer, isTransformationCompleted, isTransformationError, provideFilterKeysJSON, provideInitialVariables, provideProperties, step
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.JSONObjectDataComponent
getInitialVariables, setInitialVariables
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.internal.AbstractDataComponent
finalize, getConfigurationElement, getCurrentComponentID, getDataComponentId, getName, getPluginId, getProperties, getShell, isDeltaObserver, isHistoryObserver, isHistoryStep, isInvisible, isMacroStepDone, isMaster, isMasterImplementingGUI, isMultiInstantiable, masterCommand, masterGetAimedStepDuration, masterGUI, masterGUIisEnabled, masterIsPaused, masterIsRunning, masterSetAimedStepDuration, masterSetKIEMInstance, notifyEvent, provideEventOfInterest, 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

SyncchartsSimDataComponent

public SyncchartsSimDataComponent()
Instantiates a new SimpleRailCtrl DataComponent for the KIELER Execution Manager.

Method Detail

doStep

public JSONObject doStep(JSONObject jSONObject)
                  throws KiemExecutionException
Description copied from class: JSONObjectSimulationDataComponent
Implements the real step method for this simulation datacomponent.

Overrides:
doStep in class JSONObjectSimulationDataComponent
Parameters:
jSONObject - the j son object
Returns:
the jSON object
Throws:
KiemExecutionException - the kiem execution exception

doModel2ModelTransform

public void doModel2ModelTransform(KielerProgressMonitor monitor)
                            throws Exception
Description copied from class: JSONObjectSimulationDataComponent
Implementation of model 2 model transformation.

Overrides:
doModel2ModelTransform in class JSONObjectSimulationDataComponent
Parameters:
monitor - the monitor
Throws:
Exception - the exception

checkModelValidation

public boolean checkModelValidation(EObject rootEObject)
Description copied from class: JSONObjectSimulationDataComponent
Check the model validation. Should return true if the model is valid, false otherwise.

Example:
Region syncChart = (de.cau.cs.kieler.synccharts.Region) rootEObject;
Diagnostic diagnostic = diagnostician.validate(syncChart);
int serenity = diagnostic.getSeverity();
return (serenity == Diagnostic.OK);

Overrides:
checkModelValidation in class JSONObjectSimulationDataComponent
Returns:
true, if successful

doProvideInitialVariables

public JSONObject doProvideInitialVariables()
                                     throws KiemInitializationException
Description copied from class: JSONObjectSimulationDataComponent
Performs the normal provide initial variables method.

Overrides:
doProvideInitialVariables in class JSONObjectSimulationDataComponent
Returns:
the jSON object
Throws:
KiemInitializationException - the kiem initialization exception

resolveBundelFile

public URL resolveBundelFile(String relativePath)
Overrides:
resolveBundelFile in class JSONObjectSimulationDataComponent

loadAndExecuteModel

public void loadAndExecuteModel()
                         throws KiemInitializationException
Throws:
KiemInitializationException

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
Overrides:
initialize in class JSONObjectSimulationDataComponent
Throws:
KiemInitializationException - a KiemInitializationException

wrapup

public void wrapup()
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.


doProvideProperties

public KiemProperty[] doProvideProperties()
Do provide an additional property to set the state name.

Overrides:
doProvideProperties in class JSONObjectSimulationDataComponent
Returns:
the kiem property[]