Skip to content

Instantly share code, notes, and snippets.

@jbeard4
Created March 3, 2011 22:29
Show Gist options
  • Save jbeard4/853759 to your computer and use it in GitHub Desktop.
Save jbeard4/853759 to your computer and use it in GitHub Desktop.
revised scxml step algorithm patch
From 5aaf3c0a528f9863b19c7a1d99ae8a48fbc8ce64 Mon Sep 17 00:00:00 2001
From: jbeard4 <jbeard4@cs.mcgill.ca>
Date: Thu, 3 Mar 2011 14:24:31 -0800
Subject: [PATCH]
---
gistfile1.py | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/gistfile1.py b/gistfile1.py
index 35a3a17..0403bdf 100644
--- a/gistfile1.py
+++ b/gistfile1.py
@@ -4,8 +4,9 @@ procedure enterStates(enabledTransitions):
for t in enabledTransitions:
if t.target:
LCA = findLCA([t.source].append(getTargetStates(t.target)))
- for s in getTargetStates(t.target):
- addStatesToEnter(s,LCA,statesToEnter,statesForDefaultEntry)
+
+ addStatesToEnter(getTargetStates(t.target),LCA,statesToEnter,statesForDefaultEntry)
+
if isParallelState(LCA):
for child in getChildStates(LCA):
addStatesToEnter(child,LCA,statesToEnter,statesForDefaultEntry)
@@ -30,8 +31,7 @@ procedure enterStates(enabledTransitions):
continue = false
-
-procedure addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry):
+procedure recursiveAddStatesToEnter(s,root,statesToEnter,statesForDefaultEntry):
if isHistoryState(s):
if historyValue[s.id]:
for s0 in historyValue[s.id]:
@@ -55,3 +55,24 @@ procedure addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry):
for pChild in getChildStates(anc):
if not statesToEnter.toList().some(lambda s2: isDescendant(s2,pChild)):
addStatesToEnter(pChild,anc,statesToEnter,statesForDefaultEntry)
+
+
+procedure addStatesToEnter(statesToRecursivelyAdd,root,statesToEnter,statesForDefaultEntry):
+ do:
+ for s in statesToRecursivelyAdd
+ recursiveAddStatesToEnter(s,root,statesToEnter,statesForDefaultEntry);
+ while ((statesToRecursivelyAdd =
+ getChildrenOfParallelStatesWithoutDescendantsInStatesToEnter(statesToEnter)) &&
+ statesToRecursivelyAdd.length);
+
+
+function getChildrenOfParallelStatesWithoutDescendantsInStatesToEnter(statesToEnter){
+ return statesToEnter
+ .toList()
+ .filter(isParallelState)
+ .map(getChildStates)
+ .reduce(function(a,b){return a.concat(b)},[])
+ .filter(function(pChild){
+ return !statesToEnter.toList().some(
+ function(s2){return isDescendant(s2,pChild)})});
+}
--
1.7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment