|
@@ -131,6 +131,18 @@ Void function start_class(model : Element, data : Element, class : String, ident
|
|
|
initial_state = set_pop(allAssociationDestinations(model, class, "SCCD/behaviour"))
|
|
|
dict_add(class_handle, "states", expand_initial_state(model, initial_state))
|
|
|
|
|
|
+ // Initialize history for all composite states
|
|
|
+ Element history
|
|
|
+ Element cstates
|
|
|
+ String cstate
|
|
|
+
|
|
|
+ history = create_node()
|
|
|
+ dict_add(class_handle, "history", history)
|
|
|
+ cstates = allInstances(model, "SCCD/CompositeState")
|
|
|
+ while (read_nr_out(cstates) > 0):
|
|
|
+ cstate = set_pop(cstates)
|
|
|
+ dict_add(history, cstate, expand_initial_state(model, cstate))
|
|
|
+
|
|
|
// Add all attributes
|
|
|
Element attributes
|
|
|
attributes = create_node()
|
|
@@ -243,13 +255,13 @@ Element function get_enabled_transitions(model : Element, state : String, data :
|
|
|
|
|
|
return result!
|
|
|
|
|
|
-Void function execute_actions(model : Element, source_states : Element, target_states : Element, attributes : Element):
|
|
|
+Void function execute_actions(model : Element, source_states : Element, target_states : Element, class_data : Element):
|
|
|
Element actions
|
|
|
- actions = get_actions_to_execute(model, source_states, target_states)
|
|
|
+ actions = get_actions_to_execute(model, source_states, target_states, class_data)
|
|
|
while (read_nr_out(actions) > 0):
|
|
|
Element action
|
|
|
action = list_pop(actions, 0)
|
|
|
- action(attributes)
|
|
|
+ action(class_data["attributes"])
|
|
|
return!
|
|
|
|
|
|
Element function execute_transition(model : Element, data : Element, class : String, transition_tuple : Element):
|
|
@@ -315,7 +327,7 @@ 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))
|
|
|
|
|
|
- execute_actions(model, source_states, target_states, data["classes"][class]["attributes"])
|
|
|
+ execute_actions(model, source_states, target_states, data["classes"][class])
|
|
|
|
|
|
return target_states!
|
|
|
|
|
@@ -439,7 +451,7 @@ Element function find_hierarchy(model : Element, state : String):
|
|
|
list_append(result, state)
|
|
|
return result!
|
|
|
|
|
|
-Element function get_actions_to_execute(model : Element, source_states : Element, target_states : Element):
|
|
|
+Element function get_actions_to_execute(model : Element, source_states : Element, target_states : Element, class_data : Element):
|
|
|
Element result
|
|
|
result = create_node()
|
|
|
|
|
@@ -534,6 +546,10 @@ Element function get_actions_to_execute(model : Element, source_states : Element
|
|
|
// Add this state as visited, even though there might not have been an associated action
|
|
|
set_add(visited, state)
|
|
|
|
|
|
+ // Also update the history of this state, which will be important if we have a history state later on
|
|
|
+ if (read_type(model, state) == "SCCD/CompositeState"):
|
|
|
+ dict_overwrite(class_data["history"], state, expand_current_state(model, state, class_data["states"]))
|
|
|
+
|
|
|
// Add hierarchy_targets actions
|
|
|
// Clear visited, just to be safe, though it should not matter
|
|
|
visited = create_node()
|