123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- include "primitives.alh"
- Diagram my_SCCD {
- name = "SimpleSCCD"
- author = "Yentl"
- }
- Class main {
- name = "Main"
- default = True
- constructor_body = $
- Void function const(attributes : Element, parameters : Element):
- dict_overwrite(attributes, "a", 0)
- if (element_eq(parameters, read_root())):
- dict_overwrite(attributes, "id", 0)
- else:
- dict_overwrite(attributes, "id", parameters)
- return !
- $
- }
- Attribute attr_a {
- name = "a"
- }
- Attribute attr_b {
- name = "id"
- }
- class_attributes (main, attr_a) {}
- class_attributes (main, attr_b) {}
- CompositeState main_statechart {
- name = "root"
- isInitial = True
- {composite_children} BasicState init {
- name = "initial"
- isInitial = True
- onEntryScript = $
- Void function entry(attributes : Element):
- log("ENTRY initial")
- return!
- $
- }
- {composite_children} BasicState exit {
- name = "exit"
- isInitial = False
- onEntryScript = $
- Void function entry(attributes : Element):
- log("ENTRY exit")
- return!
- $
- }
- {composite_children} ParallelState main_parallel {
- name = "parallel"
- isInitial = False
- {parallel_children} CompositeState parallel_x {
- {composite_children} BasicState x_a {
- name = "xa"
- isInitial = True
- onEntryScript = $
- Void function entry(attributes : Element):
- log("ENTRY xa")
- return!
- $
- onExitScript = $
- Void function exit(attributes : Element):
- log("EXIT xa")
- return!
- $
- }
- {composite_children} BasicState x_b {
- name = "xb"
- isInitial = False
- onEntryScript = $
- Void function entry(attributes : Element):
- log("ENTRY xb")
- return!
- $
- onExitScript = $
- Void function exit(attributes : Element):
- log("EXIT xb")
- return!
- $
- }
- {composite_children} BasicState x_c {
- name = "xc"
- isInitial = False
- }
- {composite_children} BasicState x_d {
- name = "xd"
- isInitial = False
- }
- }
- {parallel_children} CompositeState parallel_y {
- {composite_children} BasicState y_a {
- name = "ya"
- isInitial = True
- }
- {composite_children} BasicState y_b {
- name = "yb"
- isInitial = False
- }
- }
- }
- }
- transition (x_a, x_b) {
- name = "X"
- event = "X"
- script = $
- Void function script(attributes : Element, evt_param : Element):
- log("In script")
- dict_overwrite(attributes, "a", 1)
- dict_overwrite(attributes, "id", 2)
- return!
- $
- }
- transition (x_a, x_d) {
- name = "timeout"
- after = $
- Float function after(attributes : Element):
- log("In after")
- return 3.0!
- $
- }
- transition (x_b, x_c) {
- name = "Z"
- cond = $
- Boolean function cond(attributes : Element, evt_param : Element):
- log("In condition")
- return integer_lt(attributes["a"], attributes["id"])!
- $
- }
- transition transition_y (y_a, y_b) {
- name = "Y"
- event = "Y"
- }
- Raise create_new_class {
- scope = "cd"
- event = "create_instance"
- parameter = $
- Element function func(attributes : Element, parameters : Element):
- Element result
- log("Executing create_instance!")
- result = create_node()
- list_append(result, "Main")
- list_append(result, attributes["id"])
- dict_overwrite(attributes, "id", integer_addition(attributes["id"], 1))
- list_append(result, attributes["id"])
- return result!
- $
- }
- transition_raises (transition_y, create_new_class) {}
- transition (init, main_parallel) {
- name = "init"
- event = "init"
- }
- transition (main_parallel, exit) {
- name = "exit"
- event = "exit"
- }
- diagram_classes (my_SCCD, main) {}
- behaviour (main, main_statechart) {}
|