|
@@ -150,7 +150,6 @@ Void function start_class(model : Element, data : Element, class : String):
|
|
|
|
|
|
Element function get_enabled_transitions(model : Element, state : String, data : Element, class : String):
|
|
|
// Returns all enabled transitions
|
|
|
- // TODO ignore conditions and afters
|
|
|
Element result
|
|
|
Element to_filter
|
|
|
String attr
|
|
@@ -225,8 +224,6 @@ Element function execute_transition(model : Element, data : Element, class : Str
|
|
|
source_states = expand_current_state(model, readAssociationSource(model, transition), data["classes"][class]["states"])
|
|
|
target_states = expand_initial_state(model, readAssociationDestination(model, transition))
|
|
|
|
|
|
- log("Source state expanded to: " + set_to_string(source_states))
|
|
|
- log("Target state expanded to: " + set_to_string(target_states))
|
|
|
execute_actions(model, source_states, target_states, data["classes"][class]["attributes"])
|
|
|
|
|
|
return target_states!
|
|
@@ -241,6 +238,9 @@ Boolean function step_class(model : Element, data : Element, class : String):
|
|
|
Element transitions
|
|
|
String transition
|
|
|
Boolean transitioned
|
|
|
+ Element hierarchy
|
|
|
+ String current_state
|
|
|
+ Boolean found
|
|
|
|
|
|
states = set_copy(data["classes"][class]["states"])
|
|
|
new_states = create_node()
|
|
@@ -248,20 +248,31 @@ Boolean function step_class(model : Element, data : Element, class : String):
|
|
|
|
|
|
while (read_nr_out(states) > 0):
|
|
|
state = set_pop(states)
|
|
|
+ found = False
|
|
|
+
|
|
|
+ // Loop over the hierarchy of this state and try to apply transitions
|
|
|
+ hierarchy = find_hierarchy(model, state)
|
|
|
+ while (read_nr_out(hierarchy) > 0):
|
|
|
+ current_state = list_pop(hierarchy, 0)
|
|
|
+ transitions = get_enabled_transitions(model, current_state, data, class)
|
|
|
+
|
|
|
+ if (read_nr_out(transitions) > 0):
|
|
|
+ // Found an enabled transition, so store that one
|
|
|
+ transition = random_choice(transitions)
|
|
|
+
|
|
|
+ // Execute transition
|
|
|
+ set_merge(new_states, execute_transition(model, data, class, transition))
|
|
|
+
|
|
|
+ // When leaving an orthogonal component, we must also pop all related states that might be processed in the future!
|
|
|
+ Element leaving
|
|
|
+ leaving = expand_current_state(model, current_state, data["classes"][class]["states"])
|
|
|
+ set_difference(states, leaving)
|
|
|
+
|
|
|
+ transitioned = True
|
|
|
+ found = True
|
|
|
+ break!
|
|
|
|
|
|
- // Fetch transitions in this state specifically (NO parent)
|
|
|
- transitions = get_enabled_transitions(model, state, data, class)
|
|
|
- if (read_nr_out(transitions) != 0):
|
|
|
- // Found an enabled transition, so store that one
|
|
|
- transition = random_choice(transitions)
|
|
|
-
|
|
|
- // Execute transition
|
|
|
- set_merge(new_states, execute_transition(model, data, class, transition))
|
|
|
- transitioned = True
|
|
|
- else:
|
|
|
- // Try going to the parent
|
|
|
- // TODO
|
|
|
-
|
|
|
+ if (bool_not(found)):
|
|
|
// Nothing found, so stay in the current state
|
|
|
set_add(new_states, state)
|
|
|
|
|
@@ -317,8 +328,8 @@ Void function reschedule_timeouts(model : Element, data : Element, class : Strin
|
|
|
|
|
|
String function get_parent(model : Element, state : String):
|
|
|
Element tmp_set
|
|
|
- tmp_set = allAssociationOrigins(model, state, "composite_children")
|
|
|
- set_merge(tmp_set, allAssociationOrigins(model, state, "parallel_children"))
|
|
|
+ tmp_set = allAssociationOrigins(model, state, "SCCD/composite_children")
|
|
|
+ set_merge(tmp_set, allAssociationOrigins(model, state, "SCCD/parallel_children"))
|
|
|
if (read_nr_out(tmp_set) > 0):
|
|
|
return set_pop(tmp_set)!
|
|
|
else:
|
|
@@ -396,7 +407,6 @@ Element function get_actions_to_execute(model : Element, source_states : Element
|
|
|
if (bool_not(finished)):
|
|
|
i = i + 1
|
|
|
|
|
|
- log("Found difference at i = " + cast_v2s(i))
|
|
|
// Found the first differing element at position i
|
|
|
|
|
|
// All elements remaining in hierarchy_source are to be traversed in REVERSE order for the exit actions
|