123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- include "primitives.alh"
- Diagram dynamic_trafficlight {
- name = "Dynamic Traffic Light"
- author = "Yentl Van Tendeloo"
- }
- Class manager {
- name = "Manager"
- default = True
- constructor_body = $
- Void function constructor(attributes : Element, parameters : Element):
- dict_add(attributes, "counter", 0)
- return !
- $
- {behaviour} CompositeState manager_root {
- name = "root"
- isInitial = True
- {composite_children} BasicState manager_root_start {
- name = "start"
- isInitial = True
- }
- }
- }
- transition (manager_root_start, manager_root_start) {
- name = "create"
- event = "create"
- {transition_raises} Raise {
- scope = "cd"
- event = "create_instance"
- parameter = $
- Element function raise(attributes : Element, parameters : Element):
- Element result
- result = create_node()
- list_append(result, "TrafficLight")
- list_append(result, attributes["counter"])
- list_append(result, read_root())
- dict_overwrite(attributes, "counter", integer_addition(attributes["counter"], 1))
- return result!
- $
- }
- }
- transition (manager_root_start, manager_root_start) {
- name = "delete"
- event = "delete"
- {transition_raises} Raise {
- scope = "cd"
- event = "delete_instance"
- parameter = $
- Element function raise(attributes : Element, parameters : Element):
- Element result
- result = create_node()
- list_append(result, parameters["id"])
- return result!
- $
- }
- }
- Class trafficlight {
- name = "TrafficLight"
- default = False
- constructor_body = $
- Void function constructor(attributes : Element, parameters : Element):
- dict_add(attributes, "counter", 0)
- return!
- $
- {behaviour} CompositeState trafficlight_root {
- name = "root"
- isInitial = True
- {composite_children} BasicState trafficlight_root_off {
- name = "off"
- isInitial = True
- }
- {composite_children} ParallelState trafficlight_root_main {
- name = "main"
- isInitial = False
- {parallel_children} CompositeState trafficlight_root_main_trafficlight {
- name = "trafficlight"
- isInitial = False
- {composite_children} CompositeState trafficlight_root_main_trafficlight_normal {
- name = "normal"
- isInitial = True
- {composite_children} BasicState trafficlight_root_main_trafficlight_normal_red {
- name = "red"
- isInitial = True
- }
- {composite_children} BasicState trafficlight_root_main_trafficlight_normal_green {
- name = "green"
- isInitial = False
- }
- {composite_children} BasicState trafficlight_root_main_trafficlight_normal_yellow {
- name = "yellow"
- isInitial = False
- }
- {composite_children} HistoryState trafficlight_root_main_trafficlight_normal_hist {
- name = "hist"
- }
- }
- {composite_children} CompositeState trafficlight_root_main_trafficlight_interrupted {
- {composite_children} BasicState trafficlight_root_main_trafficlight_interrupted_yellow {
- name = "yellow"
- isInitial = True
- }
- {composite_children} BasicState trafficlight_root_main_trafficlight_interrupted_black {
- name = "black"
- isInitial = False
- }
- }
- }
- {parallel_children} CompositeState trafficlight_root_main_timer {
- name = "timer"
- isInitial = False
- {composite_children} BasicState trafficlight_root_main_timer_disabled {
- name = "disabled"
- isInitial = False
- }
- {composite_children} BasicState trafficlight_root_main_timer_running {
- name = "running"
- isInitial = True
- }
- }
- }
- }
- }
|