|
@@ -63,7 +63,7 @@ Element function expand_current_state(model : Element, state : String, data : El
|
|
|
Element result
|
|
|
Element current_states
|
|
|
result = create_node()
|
|
|
- current_states = set_copy(data["classes"][data["current_class"]]["states"])
|
|
|
+ current_states = set_copy(data["current_class_handle"]["states"])
|
|
|
|
|
|
Element hierarchy
|
|
|
String deep_state
|
|
@@ -90,7 +90,7 @@ Element function expand_initial_state(model : Element, state : String, data : El
|
|
|
elif (t == "SCCD/HistoryState"):
|
|
|
// Reset the history
|
|
|
// This is not really an initial state, but it is called in exactly the same places
|
|
|
- return data["classes"][data["current_class"]]["history"][get_parent(model, state)]!
|
|
|
+ return data["current_class_handle"]["history"][get_parent(model, state)]!
|
|
|
else:
|
|
|
// Probably just an atomic, so return this one only
|
|
|
Element result
|
|
@@ -142,6 +142,7 @@ Void function start_class(model : Element, data : Element, class : String, ident
|
|
|
String prev_class
|
|
|
prev_class = data["current_class"]
|
|
|
dict_overwrite(data, "current_class", identifier)
|
|
|
+ dict_overwrite(data, "current_class_handle", data["classes"][identifier])
|
|
|
|
|
|
// Add the current state of the class
|
|
|
String initial_state
|
|
@@ -188,6 +189,7 @@ Void function start_class(model : Element, data : Element, class : String, ident
|
|
|
execute_actions(model, init, set_copy(class_handle["states"]), data, "")
|
|
|
|
|
|
dict_overwrite(data, "current_class", prev_class)
|
|
|
+ dict_overwrite(data, "current_class_handle", data["classes"][prev_class])
|
|
|
|
|
|
return!
|
|
|
|
|
@@ -209,7 +211,7 @@ Element function get_enabled_transitions(model : Element, state : String, data :
|
|
|
|
|
|
event_names = create_node()
|
|
|
event_parameters = create_node()
|
|
|
- events = set_copy(data["classes"][data["current_class"]]["events"])
|
|
|
+ events = set_copy(data["current_class_handle"]["events"])
|
|
|
while (read_nr_out(events) > 0):
|
|
|
evt = set_pop(events)
|
|
|
evt_name = list_read(evt, 0)
|
|
@@ -233,9 +235,9 @@ Element function get_enabled_transitions(model : Element, state : String, data :
|
|
|
// Check after
|
|
|
// Only an after if there was no event!
|
|
|
if (bool_and(element_eq(attr, read_root()), read_attribute(model, transition, "after"))):
|
|
|
- if (dict_in(data["classes"][data["current_class"]]["timers"], transition)):
|
|
|
+ if (dict_in(data["current_class_handle"]["timers"], transition)):
|
|
|
// Registered timer already, let's check if it has expired
|
|
|
- if (float_gt(data["classes"][data["current_class"]]["timers"][transition], data["time_sim"])):
|
|
|
+ if (float_gt(data["current_class_handle"]["timers"][transition], data["time_sim"])):
|
|
|
// Not enabled yet
|
|
|
continue!
|
|
|
else:
|
|
@@ -257,7 +259,7 @@ Element function get_enabled_transitions(model : Element, state : String, data :
|
|
|
param = set_pop(params)
|
|
|
if (element_neq(cond, read_root())):
|
|
|
// Got a condition to check first
|
|
|
- if (bool_not(cond(data["classes"][data["current_class"]]["attributes"], param))):
|
|
|
+ if (bool_not(cond(data["current_class_handle"]["attributes"], param))):
|
|
|
// Condition failed, so skip
|
|
|
continue!
|
|
|
// Fine to add this one with the specified parameters
|
|
@@ -266,7 +268,7 @@ Element function get_enabled_transitions(model : Element, state : String, data :
|
|
|
// No event to think about, just add the transition
|
|
|
if (element_neq(cond, read_root())):
|
|
|
// Check the condition first
|
|
|
- if (bool_not(cond(data["classes"][data["current_class"]]["attributes"], read_root()))):
|
|
|
+ if (bool_not(cond(data["current_class_handle"]["attributes"], read_root()))):
|
|
|
// Condition false, so skip
|
|
|
continue!
|
|
|
// Fine to add this one without event parameters (no event)
|
|
@@ -314,7 +316,7 @@ Void function process_raised_event(model : Element, event : Element, parameter_a
|
|
|
set_add(data["classes"][read_attribute(model, event, "target")]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
|
|
|
else:
|
|
|
// Same as local
|
|
|
- set_add(data["classes"][data["current_class"]]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
|
|
|
+ set_add(data["current_class_handle"]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
|
|
|
|
|
|
return !
|
|
|
|
|
@@ -329,7 +331,7 @@ Element function execute_transition(model : Element, data : Element, transition_
|
|
|
script = read_attribute(model, transition, "script")
|
|
|
if (element_neq(script, read_root())):
|
|
|
script = resolve_function(script, data)
|
|
|
- script(data["classes"][data["current_class"]]["attributes"], event_parameter)
|
|
|
+ script(data["current_class_handle"]["attributes"], event_parameter)
|
|
|
|
|
|
// Raise events (if any)
|
|
|
Element events
|
|
@@ -343,7 +345,7 @@ Element function execute_transition(model : Element, data : Element, transition_
|
|
|
if (element_neq(parameter_action, read_root())):
|
|
|
// Got a parameter to evaluate
|
|
|
parameter_action = resolve_function(parameter_action, data)
|
|
|
- parameter_action = parameter_action(data["classes"][data["current_class"]]["attributes"], event_parameter)
|
|
|
+ parameter_action = parameter_action(data["current_class_handle"]["attributes"], event_parameter)
|
|
|
|
|
|
process_raised_event(model, event, parameter_action, data)
|
|
|
|
|
@@ -377,8 +379,9 @@ Boolean function step_class(model : Element, data : Element, class : String):
|
|
|
|
|
|
// Notify everyone of the current class
|
|
|
dict_overwrite(data, "current_class", class)
|
|
|
+ dict_overwrite(data, "current_class_handle", data["classes"][class])
|
|
|
|
|
|
- states = set_copy(data["classes"][data["current_class"]]["states"])
|
|
|
+ states = set_copy(data["current_class_handle"]["states"])
|
|
|
new_states = create_node()
|
|
|
transitioned = False
|
|
|
|
|
@@ -413,7 +416,7 @@ Boolean function step_class(model : Element, data : Element, class : String):
|
|
|
set_add(new_states, state)
|
|
|
|
|
|
// Update states
|
|
|
- dict_overwrite(data["classes"][data["current_class"]], "states", new_states)
|
|
|
+ dict_overwrite(data["current_class_handle"], "states", new_states)
|
|
|
|
|
|
return transitioned!
|
|
|
|
|
@@ -586,14 +589,14 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
|
|
|
// Set history when leaving
|
|
|
if (read_type(model, state) == "SCCD/CompositeState"):
|
|
|
- dict_overwrite(data["classes"][data["current_class"]]["history"], state, expand_current_state(model, state, data))
|
|
|
+ dict_overwrite(data["current_class_handle"]["history"], state, expand_current_state(model, state, data))
|
|
|
|
|
|
// Do exit actions
|
|
|
action = read_attribute(model, state, "onExitScript")
|
|
|
if (element_neq(action, read_root())):
|
|
|
// Got a script, so execute!
|
|
|
action = resolve_function(action, data)
|
|
|
- action(data["classes"][data["current_class"]]["attributes"])
|
|
|
+ action(data["current_class_handle"]["attributes"])
|
|
|
|
|
|
// Raise events
|
|
|
events = allAssociationDestinations(model, state, "SCCD/onExitRaise")
|
|
@@ -605,7 +608,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
if (element_neq(parameter_action, read_root())):
|
|
|
// Got a parameter to evaluate
|
|
|
parameter_action = resolve_function(parameter_action, data)
|
|
|
- parameter_action = parameter_action(data["classes"][data["current_class"]]["attributes"])
|
|
|
+ parameter_action = parameter_action(data["current_class_handle"]["attributes"])
|
|
|
|
|
|
process_raised_event(model, event, parameter_action, data)
|
|
|
|
|
@@ -613,7 +616,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
Element timed_transitions
|
|
|
timed_transitions = filter_exists(model, allOutgoingAssociationInstances(model, state, "SCCD/transition"), "after")
|
|
|
while (read_nr_out(timed_transitions) > 0):
|
|
|
- dict_delete(data["classes"][data["current_class"]]["timers"], set_pop(timed_transitions))
|
|
|
+ dict_delete(data["current_class_handle"]["timers"], set_pop(timed_transitions))
|
|
|
|
|
|
// Then do entry actions
|
|
|
while (read_nr_out(entry) > 0):
|
|
@@ -624,7 +627,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
if (element_neq(action, read_root())):
|
|
|
// Got a script, so execute!
|
|
|
action = resolve_function(action, data)
|
|
|
- action(data["classes"][data["current_class"]]["attributes"])
|
|
|
+ action(data["current_class_handle"]["attributes"])
|
|
|
|
|
|
// Raise events
|
|
|
events = allAssociationDestinations(model, state, "SCCD/onEntryRaise")
|
|
@@ -636,7 +639,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
if (element_neq(parameter_action, read_root())):
|
|
|
// Got a parameter to evaluate
|
|
|
parameter_action = resolve_function(parameter_action, data)
|
|
|
- parameter_action = parameter_action(data["classes"][data["current_class"]]["attributes"])
|
|
|
+ parameter_action = parameter_action(data["current_class_handle"]["attributes"])
|
|
|
|
|
|
process_raised_event(model, event, parameter_action, data)
|
|
|
|
|
@@ -648,7 +651,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
|
|
|
while (read_nr_out(timed_transitions) > 0):
|
|
|
transition = set_pop(timed_transitions)
|
|
|
after = resolve_function(read_attribute(model, transition, "after"), data)
|
|
|
- dict_add(data["classes"][data["current_class"]]["timers"], transition, float_addition(data["time_sim"], after(data["classes"][data["current_class"]]["attributes"])))
|
|
|
+ dict_add(data["current_class_handle"]["timers"], transition, float_addition(data["time_sim"], after(data["current_class_handle"]["attributes"])))
|
|
|
|
|
|
return !
|
|
|
|