Skip to content

Commit

Permalink
Add a metamodel for Timed Composite FSM
Browse files Browse the repository at this point in the history
  • Loading branch information
fcoulon committed Feb 19, 2015
1 parent d3b8730 commit 0932db1
Show file tree
Hide file tree
Showing 47 changed files with 6,928 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Require-Bundle: org.eclipse.xtend.lib,
com.google.guava,
org.eclipse.xtext.xbase.lib,
fr.inria.diverse.k3.al.annotationprocessor.plugin;bundle-version="3.0.0",
fr.inria.diverse.example.fsm.metamodel.composite;bundle-version="0.0.0";visibility:=reexport,
fr.inria.diverse.example.fsm.metamodel.timedComposite;bundle-version="0.0.0";visibility:=reexport,
fr.inria.diverse.examples.fsm.interfaces;bundle-version="1.0.0"
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package finitestatemachines.timedcomposite

import FSM.interfaces.Context
import finitestatemachinescomposite.Fork
import finitestatemachinescomposite.InitialState
import finitestatemachinescomposite.Join
import finitestatemachinescomposite.State
import finitestatemachinescomposite.StateMachine
import finitestatemachinescomposite.Transition
import finitestatemachinestimedcomposite.Fork
import finitestatemachinestimedcomposite.InitialState
import finitestatemachinestimedcomposite.Join
import finitestatemachinestimedcomposite.State
import finitestatemachinestimedcomposite.StateMachine
import finitestatemachinestimedcomposite.Transition
import fr.inria.diverse.k3.al.annotationprocessor.Aspect
import fr.inria.diverse.k3.al.annotationprocessor.OverrideAspectMethod
import java.util.ArrayList
Expand All @@ -15,7 +15,7 @@ import java.util.List
import static extension finitestatemachines.timedcomposite.StateAspect.*
import static extension finitestatemachines.timedcomposite.CompositeStateAspect.*
import static extension finitestatemachines.timedcomposite.TransitionAspect.*
import finitestatemachinescomposite.CompositeState
import finitestatemachinestimedcomposite.CompositeState

//
// *.*
Expand Down Expand Up @@ -222,9 +222,6 @@ class CompositeStateAspect extends StateAspect {

@Aspect(className=Transition)
class TransitionAspect {

public int time = 0

def public void process(Context context) {
Context.stateWorking(_self.time)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import static extension finitestatemachines.timedcomposite.StateAspect.*

class ForkThread extends Thread {

finitestatemachinescomposite.State state
finitestatemachinestimedcomposite.State state
Context context

new (finitestatemachinescomposite.State _state, Context _context){
new (finitestatemachinestimedcomposite.State _state, Context _context){
state = _state
context = _context
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import com.itextpdf.awt.DefaultFontMapper
import java.awt.Graphics2D
import java.awt.geom.Rectangle2D

import finitestatemachinescomposite.State
import finitestatemachinescomposite.StateMachine
import finitestatemachinescomposite.Fork
import finitestatemachinescomposite.Join
import finitestatemachinestimedcomposite.State
import finitestatemachinestimedcomposite.StateMachine
import finitestatemachinestimedcomposite.Fork
import finitestatemachinestimedcomposite.Join

class Printer {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.inria.diverse.example.fsm.metamodel.timedComposite</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: fr.inria.diverse.example.fsm.metamodel.timedComposite;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: finitestatemachinestimedcomposite,
finitestatemachinestimedcomposite.impl,
finitestatemachinestimedcomposite.util
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#

bin.includes = .,\
model/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src/
output.. = bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="finitestatemachinestimedcomposite" nsURI="http://fr.inria.diverse.examples.fsm.composite" nsPrefix="finitestatemachinestimedcomposite">
<eClassifiers xsi:type="ecore:EClass" name="NamedElement">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="StateMachine" eSuperTypes="//NamedElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="states" upperBound="-1" eType="//State" containment="true" eOpposite="//State/stateMachine"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="transitions" upperBound="-1" eType="//Transition" containment="true" eOpposite="//Transition/stateMachine"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="State" eSuperTypes="//NamedElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="outgoing" upperBound="-1" eType="//Transition" eOpposite="//Transition/source"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="incoming" upperBound="-1" eType="//Transition" eOpposite="//Transition/target"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="stateMachine" eType="//StateMachine" eOpposite="//StateMachine/states"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="initialTime">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="finalTime">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="parentState" eType="//CompositeState"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="FinalState" eSuperTypes="//State"/>
<eClassifiers xsi:type="ecore:EClass" name="InitialState" eSuperTypes="//State"/>
<eClassifiers xsi:type="ecore:EClass" name="Transition" eSuperTypes="//NamedElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="target" lowerBound="1" eType="//State" eOpposite="//State/incoming"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="source" lowerBound="1" eType="//State" eOpposite="//State/outgoing"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="trigger" eType="//Trigger" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="stateMachine" lowerBound="1" eType="//StateMachine" eOpposite="//StateMachine/transitions"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="initialTime">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="finalTime">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="time">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TimedTransition" eSuperTypes="//Transition">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="duration">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Trigger">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="expression" lowerBound="1">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Pseudostate" eSuperTypes="//State"/>
<eClassifiers xsi:type="ecore:EClass" name="Fork" eSuperTypes="//Pseudostate"/>
<eClassifiers xsi:type="ecore:EClass" name="Join" eSuperTypes="//Pseudostate"/>
<eClassifiers xsi:type="ecore:EClass" name="CompositeState" eSuperTypes="//State">
<eStructuralFeatures xsi:type="ecore:EReference" name="regions" lowerBound="1" upperBound="-1" eType="//Region" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Region">
<eStructuralFeatures xsi:type="ecore:EReference" name="states" upperBound="-1" eType="//State" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parent" lowerBound="1" eType="//CompositeState"/>
</eClassifiers>
</ecore:EPackage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="ASCII"?>
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/fr.inria.diverse.example.fsm.metamodel.timedComposite/src" modelPluginID="fr.inria.diverse.example.fsm.metamodel.timedComposite" modelName="Fsm" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" importerID="org.eclipse.emf.importer.ecore" complianceLevel="7.0" copyrightFields="false" operationReflection="true" importOrganizing="true">
<foreignModel>fsm.ecore</foreignModel>
<genPackages prefix="Finitestatemachinestimedcomposite" disposableProviderFactory="true">
<ecorePackage href="fsm.ecore#/"/>
<genClasses>
<ecoreClass href="fsm.ecore#//NamedElement"/>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//NamedElement/name"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//StateMachine"/>
<genFeatures property="None" children="true" createChild="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//StateMachine/states"/>
</genFeatures>
<genFeatures property="None" children="true" createChild="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//StateMachine/transitions"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//State"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//State/outgoing"/>
</genFeatures>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//State/incoming"/>
</genFeatures>
<genFeatures property="None" notify="false" createChild="false">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//State/stateMachine"/>
</genFeatures>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//State/initialTime"/>
</genFeatures>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//State/finalTime"/>
</genFeatures>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//State/parentState"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//FinalState"/>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//InitialState"/>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Transition"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Transition/target"/>
</genFeatures>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Transition/source"/>
</genFeatures>
<genFeatures property="None" children="true" createChild="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Transition/trigger"/>
</genFeatures>
<genFeatures property="None" notify="false" createChild="false">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Transition/stateMachine"/>
</genFeatures>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//Transition/initialTime"/>
</genFeatures>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//Transition/finalTime"/>
</genFeatures>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//Transition/time"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//TimedTransition"/>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//TimedTransition/duration"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Trigger"/>
<genFeatures createChild="false">
<ecoreFeature xsi:type="ecore:EAttribute" href="fsm.ecore#//Trigger/expression"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Pseudostate"/>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Fork"/>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Join"/>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//CompositeState"/>
<genFeatures property="None" children="true" createChild="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//CompositeState/regions"/>
</genFeatures>
</genClasses>
<genClasses>
<ecoreClass href="fsm.ecore#//Region"/>
<genFeatures property="None" children="true" createChild="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Region/states"/>
</genFeatures>
<genFeatures notify="false" createChild="false" propertySortChoices="true">
<ecoreFeature xsi:type="ecore:EReference" href="fsm.ecore#//Region/parent"/>
</genFeatures>
</genClasses>
</genPackages>
</genmodel:GenModel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#

pluginName = Fsm Model
providerName = www.example.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>

<!--
-->

<plugin>

<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated fsm -->
<package
uri="http://fr.inria.diverse.examples.fsm.composite"
class="finitestatemachinestimedcomposite.FinitestatemachinestimedcompositePackage"
genModel="model/fsm.genmodel"/>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
*/
package finitestatemachinestimedcomposite;

import org.eclipse.emf.common.util.EList;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Composite State</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link finitestatemachinestimedcomposite.CompositeState#getRegions <em>Regions</em>}</li>
* </ul>
* </p>
*
* @see finitestatemachinestimedcomposite.FinitestatemachinestimedcompositePackage#getCompositeState()
* @model
* @generated
*/
public interface CompositeState extends State {
/**
* Returns the value of the '<em><b>Regions</b></em>' containment reference list.
* The list contents are of type {@link finitestatemachinestimedcomposite.Region}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Regions</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Regions</em>' containment reference list.
* @see finitestatemachinestimedcomposite.FinitestatemachinestimedcompositePackage#getCompositeState_Regions()
* @model containment="true" required="true"
* @generated
*/
EList<Region> getRegions();

} // CompositeState
Loading

0 comments on commit 0932db1

Please sign in to comment.