Commit 98272102 authored by Depasse Arthur's avatar Depasse Arthur

Progression acceleo

parent 877a9a7b
......@@ -59,3 +59,4 @@ _UI_StringToStringMap_key_feature = Key
_UI_StringToStringMap_value_feature = Value
_UI_Message_name_feature = Name
_UI_FSM_dataTypes_feature = Data Types
_UI_Message_enumsDef_feature = Enums Def
......@@ -11,7 +11,6 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
......@@ -55,6 +54,7 @@ public class MessageItemProvider extends ItemProviderAdapter implements IEditing
addEventPropertyDescriptor(object);
addDataPropertyDescriptor(object);
addNamePropertyDescriptor(object);
addEnumsDefPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
......@@ -103,6 +103,21 @@ public class MessageItemProvider extends ItemProviderAdapter implements IEditing
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Enums Def feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEnumsDefPropertyDescriptor(Object object) {
itemPropertyDescriptors
.add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
getResourceLocator(), getString("_UI_Message_enumsDef_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Message_enumsDef_feature",
"_UI_Message_type"),
FsmPackage.Literals.MESSAGE__ENUMS_DEF, true, false, false, null, null, null));
}
/**
* This returns Message.gif.
* <!-- begin-user-doc -->
......@@ -152,6 +167,7 @@ public class MessageItemProvider extends ItemProviderAdapter implements IEditing
case FsmPackage.MESSAGE__EVENT:
case FsmPackage.MESSAGE__DATA:
case FsmPackage.MESSAGE__NAME:
case FsmPackage.MESSAGE__ENUMS_DEF:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
......
......@@ -472,6 +472,22 @@
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_OtM08HWjEemLj80b9HKNdQ" id="(0.7288135593220338,1.0)"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_OtM08XWjEemLj80b9HKNdQ" id="(0.0,0.8163265306122449)"/>
</edges>
<edges xmi:type="notation:Edge" xmi:id="_PZaNsHsUEemYJOqwvk8KJA" type="4001" element="_PY53YHsUEemYJOqwvk8KJA" source="_QjJLQHWVEemSG6CGjg3iew" target="_Q46fkHWYEemSG6CGjg3iew">
<children xmi:type="notation:Node" xmi:id="_PZgUUHsUEemYJOqwvk8KJA" type="6001">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_PZgUUXsUEemYJOqwvk8KJA" x="34" y="36"/>
</children>
<children xmi:type="notation:Node" xmi:id="_PZg7YHsUEemYJOqwvk8KJA" type="6002">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_PZg7YXsUEemYJOqwvk8KJA" y="10"/>
</children>
<children xmi:type="notation:Node" xmi:id="_PZhicHsUEemYJOqwvk8KJA" type="6003">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_PZhicXsUEemYJOqwvk8KJA" y="10"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_PZaNsXsUEemYJOqwvk8KJA" routing="Rectilinear"/>
<styles xmi:type="notation:FontStyle" xmi:id="_PZaNsnsUEemYJOqwvk8KJA" fontColor="7490599" fontName=".AppleSystemUIFont" fontHeight="8"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_PZaNs3sUEemYJOqwvk8KJA" points="[0, 0, 0, -298]$[0, 298, 0, 0]"/>
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_PZklwHsUEemYJOqwvk8KJA" id="(0.3644067796610169,1.0)"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_PZklwXsUEemYJOqwvk8KJA" id="(0.16101694915254236,0.0)"/>
</edges>
</data>
</ownedAnnotationEntries>
<ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_o0qEMC8REemUD62u2ND_rQ" name="FSM" tooltipText="" outgoingEdges="_Ll21EF-gEemRWcGjpF2T8A _Ll5RUF-gEemRWcGjpF2T8A _Ll6fcF-gEemRWcGjpF2T8A _LmDpYF-gEemRWcGjpF2T8A _36f_EGXREemlk9JwcFvGuA _EAE1EGtJEemJMoCNZztO6w _Hm05UGtJEemJMoCNZztO6w _TJPDwHWVEemSG6CGjg3iew _OsiGkHWjEemLj80b9HKNdQ" width="12" height="10">
......@@ -778,7 +794,7 @@
</ownedStyle>
<actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/>
</ownedDiagramElements>
<ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_Qio08HWVEemSG6CGjg3iew" name="Message" tooltipText="" outgoingEdges="_txebwHWXEemSG6CGjg3iew _p1RPcHWYEemSG6CGjg3iew" incomingEdges="_TJPDwHWVEemSG6CGjg3iew _OGyysHWXEemSG6CGjg3iew" width="12" height="10">
<ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_Qio08HWVEemSG6CGjg3iew" name="Message" tooltipText="" outgoingEdges="_txebwHWXEemSG6CGjg3iew _p1RPcHWYEemSG6CGjg3iew _PY53YHsUEemYJOqwvk8KJA" incomingEdges="_TJPDwHWVEemSG6CGjg3iew _OGyysHWXEemSG6CGjg3iew" width="12" height="10">
<target xmi:type="ecore:EClass" href="fsm.ecore#//Message"/>
<semanticElements xmi:type="ecore:EClass" href="fsm.ecore#//Message"/>
<arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
......@@ -835,7 +851,7 @@
</ownedStyle>
<actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/>
</ownedDiagramElements>
<ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_Q4x8sHWYEemSG6CGjg3iew" name="StringToStringMap" tooltipText="" incomingEdges="_p1RPcHWYEemSG6CGjg3iew _OsiGkHWjEemLj80b9HKNdQ" width="12" height="10">
<ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_Q4x8sHWYEemSG6CGjg3iew" name="StringToStringMap" tooltipText="" incomingEdges="_p1RPcHWYEemSG6CGjg3iew _OsiGkHWjEemLj80b9HKNdQ _PY53YHsUEemYJOqwvk8KJA" width="12" height="10">
<target xmi:type="ecore:EClass" href="fsm.ecore#//StringToStringMap"/>
<semanticElements xmi:type="ecore:EClass" href="fsm.ecore#//StringToStringMap"/>
<ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_cmb2oHWYEemSG6CGjg3iew" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216">
......@@ -885,6 +901,19 @@
</ownedStyle>
<actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/>
</ownedDiagramElements>
<ownedDiagramElements xmi:type="diagram:DEdge" xmi:id="_PY53YHsUEemYJOqwvk8KJA" name="[0..*] enumsDef" sourceNode="_Qio08HWVEemSG6CGjg3iew" targetNode="_Q4x8sHWYEemSG6CGjg3iew">
<target xmi:type="ecore:EReference" href="fsm.ecore#//Message/enumsDef"/>
<semanticElements xmi:type="ecore:EReference" href="fsm.ecore#//Message/enumsDef"/>
<ownedStyle xmi:type="diagram:EdgeStyle" xmi:id="_PY7FgHsUEemYJOqwvk8KJA" description="_36gmIGXREemlk9JwcFvGuA" sourceArrow="FillDiamond" routingStyle="manhattan" strokeColor="0,0,0">
<centerLabelStyle xmi:type="diagram:CenterLabelStyle" xmi:id="_PY7FgXsUEemYJOqwvk8KJA" showIcon="false">
<customFeatures>labelSize</customFeatures>
</centerLabelStyle>
<endLabelStyle xmi:type="diagram:EndLabelStyle" xmi:id="_PY7FgnsUEemYJOqwvk8KJA" showIcon="false" labelColor="39,76,114">
<customFeatures>labelSize</customFeatures>
</endLabelStyle>
</ownedStyle>
<actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/>
</ownedDiagramElements>
<description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/>
<filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_jGVPci8REemUD62u2ND_rQ"/>
<activatedLayers xmi:type="description_1:Layer" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer"/>
......
......@@ -63,6 +63,8 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="data" upperBound="-1" eType="#//StringToStringMap"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="enumsDef" upperBound="-1"
eType="#//StringToStringMap" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="StringToStringMap" instanceClassName="java.util.Map$Entry">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="key" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
......
......@@ -54,6 +54,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EReference fsm.ecore#//Message/event"/>
<genFeatures createChild="false" ecoreFeature="ecore:EReference fsm.ecore#//Message/data"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute fsm.ecore#//Message/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EReference fsm.ecore#//Message/enumsDef"/>
</genClasses>
<genClasses ecoreClass="fsm.ecore#//StringToStringMap">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute fsm.ecore#//StringToStringMap/key"/>
......
......@@ -513,6 +513,15 @@ public interface FsmPackage extends EPackage {
*/
int MESSAGE__NAME = 2;
/**
* The feature id for the '<em><b>Enums Def</b></em>' map.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int MESSAGE__ENUMS_DEF = 3;
/**
* The number of structural features of the '<em>Message</em>' class.
* <!-- begin-user-doc -->
......@@ -520,7 +529,7 @@ public interface FsmPackage extends EPackage {
* @generated
* @ordered
*/
int MESSAGE_FEATURE_COUNT = 3;
int MESSAGE_FEATURE_COUNT = 4;
/**
* The number of operations of the '<em>Message</em>' class.
......@@ -988,6 +997,17 @@ public interface FsmPackage extends EPackage {
*/
EAttribute getMessage_Name();
/**
* Returns the meta object for the map '{@link fr.supelec.plong9.fsm.Message#getEnumsDef <em>Enums Def</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for the map '<em>Enums Def</em>'.
* @see fr.supelec.plong9.fsm.Message#getEnumsDef()
* @see #getMessage()
* @generated
*/
EReference getMessage_EnumsDef();
/**
* Returns the meta object for class '{@link java.util.Map.Entry <em>String To String Map</em>}'.
* <!-- begin-user-doc -->
......@@ -1363,6 +1383,14 @@ public interface FsmPackage extends EPackage {
*/
EAttribute MESSAGE__NAME = eINSTANCE.getMessage_Name();
/**
* The meta object literal for the '<em><b>Enums Def</b></em>' map feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
EReference MESSAGE__ENUMS_DEF = eINSTANCE.getMessage_EnumsDef();
/**
* The meta object literal for the '{@link fr.supelec.plong9.fsm.impl.StringToStringMapImpl <em>String To String Map</em>}' class.
* <!-- begin-user-doc -->
......
......@@ -18,6 +18,7 @@ import org.eclipse.emf.ecore.EObject;
* <li>{@link fr.supelec.plong9.fsm.Message#getEvent <em>Event</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.Message#getData <em>Data</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.Message#getName <em>Name</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.Message#getEnumsDef <em>Enums Def</em>}</li>
* </ul>
*
* @see fr.supelec.plong9.fsm.FsmPackage#getMessage()
......@@ -94,4 +95,21 @@ public interface Message extends EObject {
*/
void setName(String value);
/**
* Returns the value of the '<em><b>Enums Def</b></em>' map.
* The key is of type {@link java.lang.String},
* and the value is of type {@link java.lang.String},
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Enums Def</em>' map isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Enums Def</em>' map.
* @see fr.supelec.plong9.fsm.FsmPackage#getMessage_EnumsDef()
* @model mapType="fr.supelec.plong9.fsm.StringToStringMap&lt;org.eclipse.emf.ecore.EString, org.eclipse.emf.ecore.EString&gt;"
* @generated
*/
EMap<String, String> getEnumsDef();
} // Message
......@@ -489,6 +489,15 @@ public class FsmPackageImpl extends EPackageImpl implements FsmPackage {
return (EAttribute) messageEClass.getEStructuralFeatures().get(2);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EReference getMessage_EnumsDef() {
return (EReference) messageEClass.getEStructuralFeatures().get(3);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
......@@ -589,6 +598,7 @@ public class FsmPackageImpl extends EPackageImpl implements FsmPackage {
createEReference(messageEClass, MESSAGE__EVENT);
createEReference(messageEClass, MESSAGE__DATA);
createEAttribute(messageEClass, MESSAGE__NAME);
createEReference(messageEClass, MESSAGE__ENUMS_DEF);
stringToStringMapEClass = createEClass(STRING_TO_STRING_MAP);
createEAttribute(stringToStringMapEClass, STRING_TO_STRING_MAP__KEY);
......@@ -727,6 +737,9 @@ public class FsmPackageImpl extends EPackageImpl implements FsmPackage {
IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getMessage_Name(), ecorePackage.getEString(), "name", null, 0, 1, Message.class, !IS_TRANSIENT,
!IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getMessage_EnumsDef(), this.getStringToStringMap(), null, "enumsDef", null, 0, -1, Message.class,
!IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(stringToStringMapEClass, Map.Entry.class, "StringToStringMap", !IS_ABSTRACT, !IS_INTERFACE,
!IS_GENERATED_INSTANCE_CLASS);
......
......@@ -32,6 +32,7 @@ import org.eclipse.emf.ecore.util.InternalEList;
* <li>{@link fr.supelec.plong9.fsm.impl.MessageImpl#getEvent <em>Event</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.impl.MessageImpl#getData <em>Data</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.impl.MessageImpl#getName <em>Name</em>}</li>
* <li>{@link fr.supelec.plong9.fsm.impl.MessageImpl#getEnumsDef <em>Enums Def</em>}</li>
* </ul>
*
* @generated
......@@ -77,6 +78,16 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getEnumsDef() <em>Enums Def</em>}' map.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEnumsDef()
* @generated
* @ordered
*/
protected EMap<String, String> enumsDef;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
......@@ -169,6 +180,19 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
eNotify(new ENotificationImpl(this, Notification.SET, FsmPackage.MESSAGE__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EMap<String, String> getEnumsDef() {
if (enumsDef == null) {
enumsDef = new EcoreEMap<String, String>(FsmPackage.Literals.STRING_TO_STRING_MAP,
StringToStringMapImpl.class, this, FsmPackage.MESSAGE__ENUMS_DEF);
}
return enumsDef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
......@@ -179,6 +203,8 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
switch (featureID) {
case FsmPackage.MESSAGE__DATA:
return ((InternalEList<?>) getData()).basicRemove(otherEnd, msgs);
case FsmPackage.MESSAGE__ENUMS_DEF:
return ((InternalEList<?>) getEnumsDef()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
......@@ -202,6 +228,11 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
return getData().map();
case FsmPackage.MESSAGE__NAME:
return getName();
case FsmPackage.MESSAGE__ENUMS_DEF:
if (coreType)
return getEnumsDef();
else
return getEnumsDef().map();
}
return super.eGet(featureID, resolve, coreType);
}
......@@ -223,6 +254,9 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
case FsmPackage.MESSAGE__NAME:
setName((String) newValue);
return;
case FsmPackage.MESSAGE__ENUMS_DEF:
((EStructuralFeature.Setting) getEnumsDef()).set(newValue);
return;
}
super.eSet(featureID, newValue);
}
......@@ -244,6 +278,9 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
case FsmPackage.MESSAGE__NAME:
setName(NAME_EDEFAULT);
return;
case FsmPackage.MESSAGE__ENUMS_DEF:
getEnumsDef().clear();
return;
}
super.eUnset(featureID);
}
......@@ -262,6 +299,8 @@ public class MessageImpl extends MinimalEObjectImpl.Container implements Message
return data != null && !data.isEmpty();
case FsmPackage.MESSAGE__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case FsmPackage.MESSAGE__ENUMS_DEF:
return enumsDef != null && !enumsDef.isEmpty();
}
return super.eIsSet(featureID);
}
......
......@@ -72,7 +72,7 @@ public class AcceleoGenerateFSMtoJavaAction extends ActionDelegate implements IA
URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true);
IContainer targetFolder = null;
try {
IContainer target = model.getProject().getFolder("src-gen");
IContainer target = model.getProject().getFolder(model.getName().split("\\.")[0]);
targetFolder = target;
GenerateAll generator = new GenerateAll(modelURI, targetFolder, getArguments());
generator.doGenerate(monitor);
......
......@@ -17,7 +17,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.acceleo.engine;bundle-version="3.3.0",
com.google.guava,
org.eclipse.osgi,
org.eclipse.core.resources
org.eclipse.core.resources,
org.eclipse.ui.workbench,
org.eclipse.jface
Bundle-RequiredExecutionEnvironment: JavaSE-10
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
......
......@@ -8,17 +8,13 @@
[msg.name/] DEFINITIONS IMPLICIT TAGS::=
BEGIN
[for (d : StringToStringMap | msg.data)]
[if (d.value.startsWith('ENUMDEF:'))]
[d.key.toUpper()/] ::= ENUMERATED {[d.value.substring(9)/]}
[/if]
[for (d : StringToStringMap | msg.enumsDef)]
[d.key.toUpper()/] ::= ENUMERATED {[d.value/]}
[/for]
[msg.name/] ::= SEQUENCE {
[for (d : StringToStringMap | msg.data) separator(',')]
[if (not d.value.startsWith('ENUMDEF:'))]
[d.key.toLower()/] [d.value.toUpper()/]
[/if]
[/for]
}
......
......@@ -5,10 +5,10 @@
[template public generateAction(aFSM : FSM)]
[for (action : Action | aFSM.ownedActions)]
[if not (action.name = 'DisconnectClientAction')]
[file (aFSM.name + '/' + action.name.toUpper() + '.java', false, 'UTF-8')]
[if not (action.name = 'DisconnectClientAction' or action.name = 'DisconnectFromServerAction')]
[file ('src/main/java' + '/' + action.name.toUpper() + '.java', false, 'UTF-8')]
package [aFSM.name/]
package [aFSM.name/];
import java.io.IOException;
......@@ -23,20 +23,24 @@ import fsm.FSMServer;
import fsm.FSMClient;
[/if]
// [protected ('imports')]
// your imports
// [/protected]
public class [action.name.toUpper()/] extends Action {
@Override
public void execute(FSM fsm, Event e) {
// [protected ('for ' + action.name + ' contents')]
[if (aFSM.isServer)]
var dos = ((FSMServer)fsm).getNetworkServer().getOutputStreamByClient(e.origin);
[else]
var dos = ((FSMClient)fsm).getNetworkClient().getOutputStream();
[/if]
// [protected ('for ' + action.name + ' contents')]
// TODO : Action contents
// [/protected]
......
......@@ -4,7 +4,33 @@
[template public generateGuard(aFSM : FSM)]
[file (aFSM.name, false, 'UTF-8')]
[for (guard : Guard | aFSM.ownedGuards)]
[file ('src/main/java' + '/' + guard.name.toUpper() + '.java', false, 'UTF-8')]
package [aFSM.name/];
import fsm.Event;
import fsm.FSM;
import fsm.Guard;
// [protected ('imports')]
// your imports
// [/protected]
public class [guard.name.toUpper()/] extends Guard{
@Override
public boolean eval(FSM fsm, Event e) {
// [protected ('for ' + guard.name + ' contents')]
// TODO : Guard content
return true;
// [/protected]
}
}
[/file]
[/for]
[/template]
......@@ -4,27 +4,25 @@
[template public generateMain(aFSM : FSM)]
[file (aFSM.name + '/main.java', false, 'UTF-8')]
[file ('src/main/java' + '/main.java', false, 'UTF-8')]
package [aFSM.name/];
import java.util.logging.Level;
[if (aFSM.isServer)]
import fsm.FSMServer;
import fsm.*;
[if (aFSM.isServer)]
[else]
import java.net.InetAddress;
import java.net.UnknownHostException;
import fsm.FSMClient;
[/if]
import fsm.State;
import fsm.Transition;
[for (a : Action | aFSM.ownedActions)]
[if (a.name = 'DisconnectClientAction')]
import fsm.DisconnectClientAction;
[elseif (a.name = 'DisconnectFromServerAction')]
import fsm.DisconnectFromServerAction;
[else]
import [aFSM.name/].[a.name.toUpper()/];
[/if]
......@@ -35,7 +33,7 @@ public class main {
public static void main(String['['/][']'/] args) {
[if (aFSM.isServer)]
FSMServer fsm = new FSMServer("[aFSM.name/]", (dis, f) -> new NetworkMessageParser(dis, f), 50300, "serverpw");
FSMServer fsm = new FSMServer("[aFSM.name/]", (dis, f) -> new [aFSM.name/]NetworkMessageParser(dis, f), 50300, "serverpw");
[else]
InetAddress host = null;
try {
......@@ -44,28 +42,41 @@ public class main {
} catch (UnknownHostException e) {
e.printStackTrace();
}
var fsm = new FSMClient("[aFSM.name/]", (dis, f) -> new MyClientNetworkMessageParser(dis, f), host, 50300, "clientpw");
var fsm = new FSMClient("[aFSM.name/]", (dis, f) -> new [aFSM.name/]NetworkMessageParser(dis, f), host, 50300, "clientpw");
[/if]
fsm.LOGGER.setLevel(Level.INFO);
[for (s : State | aFSM.ownedStates)]
State state_[s.name.toLower()/] = new State("[s.name/]");
[for (a : Action | s.onEnteredActions)]
[if (a.name='DisconnectClientAction')]
state_[s.name.toLower()/].onEnteredAction(new [a.name/]());
[else]
state_[s.name.toLower()/].onEnteredAction(new [a.name.toUpper()/]());
[/if]
[/for]
[for (a : Action | s.onExitedActions)]
[if (a.name='DisconnectClientAction')]
state_[s.name.toLower()/].onExitedAction(new [a.name/]());
[else]
state_[s.name.toLower()/].onExitedAction(new [a.name.toUpper()/]());
[/if]
[/for]
[/for]
[for (s : State | aFSM.ownedStates)]
[for (t : Transition | s.outgoingTransitions)]
Transition trans_[t.name.toLower()/] = new Transition("[t.name/]");
trans_[t.name.toLower()/].setSource([t.source.name/]);
trans_[t.name.toLower()/].setTarget([t.target.name/]);
trans_[t.name.toLower()/].setSource(state_[t.source.name.toLower()/]);
trans_[t.name.toLower()/].setTarget(state_[t.target.name.toLower()/]);
trans_[t.name.toLower()/].registerEvent("[t.event.name/]");
[for (a : Action | t.actions)]
[if (a.name='DisconnectClientAction' or a.name='DisconnectFromServerAction')]
trans_[t.name.toLower()/].registerAction(new [a.name/]());
[else]
trans_[t.name.toLower()/].registerAction(new [a.name.toUpper()/]());
[/if]
[/for]
[if (not t.guard.oclIsUndefined())]
trans_[t.name.toLower()/].registerGuard(new [t.guard.name.toUpper()/]());
......
[comment encoding = UTF-8 /]
[module generateMessageParser('http://fr.supelec.plong9.fsm')]
[template public generateMessageParser(aFSM : FSM)]
[file ('src/main/java' + '/' + aFSM.name + 'NetworkMessageParser.java', false, 'UTF-8')]
package [aFSM.name/];
import fsm.*;
import network.NetworkMessageParser;
import javafx.util.Pair;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.util.UUID;
[for (m : Message | aFSM.ownedMessages)]
import asn1.[m.name.toLower()/].*;
[/for]
public class [aFSM.name/]NetworkMessageParser extends NetworkMessageParser {
[if not (aFSM.isServer)]
boolean alreadyParsed;
[/if]
[if (aFSM.isServer)]
public [aFSM.name/]NetworkMessageParser(Pair<UUID, DataInputStream> origin, FSMServer fsm) {
super(origin, fsm);
[if not (aFSM.isServer)]
alreadyParsed = false;
[/if]
}
[else]
public [aFSM.name/]NetworkMessageParser(Pair<UUID, DataInputStream> origin, FSMClient fsm) {
super(origin, fsm);
[if not (aFSM.isServer)]
alreadyParsed = false;
[/if]
}
[/if]
@Override
public void parse(String currentState) {
[if not (aFSM.isServer)]
if(!alreadyParsed) {
[/if]
switch (currentState) {
[for (state : State | aFSM.ownedStates)]
[if (not state.expectedMessage.name.oclIsInvalid())]
case "[state.name/]":
[state.expectedMessage.name/] m = new [state.expectedMessage.name/]();
try {
m.decode(input);
Event e = new Event();
e.name = "[state.expectedMessage.event.name/]";
e.origin = originId;
[for (d : StringToStringMap | state.expectedMessage.data)]
[if (d.value.toUpper()='INTEGER')]
e.setData("[d.key.toLower()/]", m.get[d.key.toUpperFirst()/]().intValue());
[elseif (d.value.toUpper()='STRING')]
e.setData("[d.key.toLower()/]", m.get[d.key.toUpperFirst()/]());
[elseif (d.value.toUpper()='BOOL')]
e.setData("[d.key.toLower()/]", (boolean)m.get[d.key.toUpperFirst()/]());
[/if]
[/for]
fsm.queueEvent(e);
[if not (aFSM.isServer)]
alreadyParsed = true;
[/if]
} catch (EOFException e) {
} catch (IOException e) {
fsm.LOGGER.warning("Cannot read from InputStream of client " + originId);
running = false;
e.printStackTrace();
}
break;
[/if]
[/for]
default: