From 5d02cc2a04483823b90e2cc963e8836cd589655f Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 28 Dec 2023 22:41:41 +0100 Subject: [PATCH] Work on eclipse epsilon --- experimental_epsilon/src/Declaration.egl | 2 +- experimental_epsilon/src/DeclarationState.egl | 6 ++--- experimental_epsilon/src/Model.egl | 22 +++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/experimental_epsilon/src/Declaration.egl b/experimental_epsilon/src/Declaration.egl index 9106a89..10c640f 100644 --- a/experimental_epsilon/src/Declaration.egl +++ b/experimental_epsilon/src/Declaration.egl @@ -17,5 +17,5 @@ public: regionTemplate.populate("region", statemachine.region); regionTemplate.populate("statemachine", statemachine); %] -[%=regionTemplate.process()%] + [%=regionTemplate.process()%] }; diff --git a/experimental_epsilon/src/DeclarationState.egl b/experimental_epsilon/src/DeclarationState.egl index e3a47e5..91ed7f5 100644 --- a/experimental_epsilon/src/DeclarationState.egl +++ b/experimental_epsilon/src/DeclarationState.egl @@ -1,12 +1,12 @@ // State [%=state.name%] static Transition [%=state.name%]Handler(ImplPtr impl, Event event); -static const State k[%=state.name%]; +static const State [%=state.variable_name%]; [% for (transition in state.transitions) { %] // Transition [%=transition.trigger%]: [%=transition.start%] -> [%=transition.target%] -static const Transition::ActionType [%=transition.name%]Actions[]; -static const Transition [%=transition.name%]; +static const Transition::ActionType [%=transition.variable_name%]Actions[]; +static const Transition [%=transition.variable_name%]; [% } if(state.region.isDefined()) { diff --git a/experimental_epsilon/src/Model.egl b/experimental_epsilon/src/Model.egl index 3638976..5c37860 100644 --- a/experimental_epsilon/src/Model.egl +++ b/experimental_epsilon/src/Model.egl @@ -1,28 +1,25 @@ [% -// Statemachine: name : String, region : Tuple -// Region: states: List>, initial: String, initialIsHistory: Boolean -// State: region: Tuple, parent?: String, entry?: String, exit?: String, region?: Tuple, transitions: List> +// Statemachine: name: String, region: Region +// Region: states: List, initial: String, history: Boolean +// State: region?: Region, parent?: String, entry?: String, exit?: String, transitions: List // Transition: actions: List, guards: List, start: String, target: String, trigger: String operation StateMachine getModel() : Tuple { var result = new Tuple(); result.name = self.name; - - result.region = new Tuple(); result.region = sm.regions.first.getModel(result); - return result; } operation Region getModel(sm : Tuple) : Tuple { var result = new Tuple(); - var initial = self.subvertices.select(s | (s.type.name = "Pseudostate") and ((s.kind = PseudostateKind#initial) or (s.kind = PseudostateKind#shallowHistory))).first; + var initial = self.subvertices.select(s | s.isKindOf(Pseudostate) and ((s.kind = PseudostateKind#initial) or (s.kind = PseudostateKind#shallowHistory))).first; result.initial = initial.outgoing.first.target.name; - result.initialIsHistory = (initial.kind = PseudostateKind#shallowHistory); + result.history = (initial.kind = PseudostateKind#shallowHistory); result.states = new List(); - for (state in self.subvertices.select(s|s.type.name = "State").sortBy(s | s.name)) { + for (state in self.subvertices.select(s | s.isKindOf(State)).sortBy(s | s.name)) { result.states.add(state.getModel(sm)); } @@ -32,6 +29,7 @@ operation Region getModel(sm : Tuple) : Tuple { operation State getModel(sm : Tuple) : Tuple { var result = new Tuple(); result.name = self.name; + result.variable_name = "k" + result.name; if (self.container.state != null) { result.parent = self.container.state.name; @@ -76,12 +74,12 @@ operation Transition getTarget(sm : Tuple, transition : Tuple, transitions : Lis transition.guards.add(self.guard.name); } - if (self.target.type.name = "State") { + if (self.target.isKindOf(State)) { transition.target = self.target.name; - transition.name = "k" + transition.start + "To" + transition.target + "By"+ transition.trigger; + transition.variable_name = "k" + transition.start + "To" + transition.target + "By"+ transition.trigger; transitions.add(transition); } - if ((self.target.type.name = "Pseudostate") and (self.target.kind = PseudostateKind#choice)) { + if ((self.target.isKindOf(Pseudostate)) and (self.target.kind = PseudostateKind#choice)) { for (choice_transition in self.target.outgoing.sortBy(t | (t.guard = null) or (t.guard.name = "else"))) { var t = new Tuple(); t.start = transition.start;