123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729 |
- include "primitives.alh"
- include "modelling.alh"
- include "object_operations.alh"
- Composite schedule {
- {Contains} Success success {}
- {Contains} Failure failure {}
- {Contains} ForAll finish {
- LHS {
- Pre_Encapsulated_PetriNet/Port {
- label = "0"
- }
- }
- RHS {
- Post_Encapsulated_PetriNet/Port {
- label = "0"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return string_join("plant/", read_attribute(model, name, "name"))!
- $
- }
- }
- }
- {Contains} Atomic init_ports {
- LHS {}
- RHS {
- Post_Encapsulated_PetriNet/Place post_ports_00 {
- label = "00"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "up"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_10 {
- label = "10"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "up"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_10, post_ports_00) {
- label = "20"
- }
- Post_Encapsulated_PetriNet/Place post_ports_01 {
- label = "01"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "neutral"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_11 {
- label = "11"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "neutral"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_11, post_ports_01) {
- label = "21"
- }
- Post_Encapsulated_PetriNet/Place post_ports_02 {
- label = "02"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "down"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_12 {
- label = "12"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "down"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_12, post_ports_02) {
- label = "22"
- }
- Post_Encapsulated_PetriNet/Place post_ports_03 {
- label = "03"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "interrupt"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_13 {
- label = "13"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "interrupt"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_13, post_ports_03) {
- label = "23"
- }
- Post_Encapsulated_PetriNet/Place post_ports_04 {
- label = "04"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "objDetected"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- // Set the detected output based on the initial state
- Element states
- String state
- states = allInstances(model, "PW_Plant/State")
- while (set_len(states) > 0):
- state = set_pop(states)
- if (value_eq(read_attribute(model, state, "isInitial"), True)):
- if (read_type(model, state) == "PW_Plant/ErrorState"):
- return 1!
- else:
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_14 {
- label = "14"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "objDetected"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_14, post_ports_04) {
- label = "24"
- }
- Post_Encapsulated_PetriNet/Place post_ports_05 {
- label = "05"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "no_objDetected"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- // Set the detected output based on the initial state
- Element states
- String state
- states = allInstances(model, "PW_Plant/State")
- while (set_len(states) > 0):
- state = set_pop(states)
- if (value_eq(read_attribute(model, state, "isInitial"), True)):
- if (read_type(model, state) == "PW_Plant/ErrorState"):
- return 0!
- else:
- return 1!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_15 {
- label = "15"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "no_objDetected"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_15, post_ports_05) {
- label = "25"
- }
- Post_Encapsulated_PetriNet/Place post_ports_06 {
- label = "06"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "objPresent"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_16 {
- label = "16"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "objPresent"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_16, post_ports_06) {
- label = "26"
- }
- Post_Encapsulated_PetriNet/Place post_ports_07 {
- label = "07"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "no_objPresent"!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- return 0!
- $
- }
- Post_Encapsulated_PetriNet/Port post_ports_17 {
- label = "17"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return "no_objPresent"!
- $
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ports_17, post_ports_07) {
- label = "27"
- }
- }
- }
- {Contains} ForAll create_states {
- LHS {
- Pre_PW_Plant/State {
- label = "0"
- }
- }
- RHS {
- Post_PW_Plant/State post_cs_0 {
- label = "0"
- }
- Post_Encapsulated_PetriNet/Place post_cs_1 {
- label = "1"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return read_attribute(model, mapping["0"], "name")!
- $
- value_tokens = $
- Integer function value(model : Element, name : String, mapping : Element):
- if (value_eq(read_attribute(model, mapping["0"], "isInitial"), True)):
- return 1!
- else:
- return 0!
- $
- }
- Post_PLANT2EPN_link (post_cs_0, post_cs_1) {
- label = "2"
- }
- }
- }
- {Contains} ForAll command_transition {
- LHS {
- Pre_PW_Plant/State pre_ct_0{
- label = "0"
- }
- Pre_PW_Plant/State pre_ct_1{
- label = "1"
- }
- Pre_PW_Plant/Transition pre_ct_2 (pre_ct_0, pre_ct_1) {
- label = "2"
- }
- Pre_Encapsulated_PetriNet/Place pre_ct_3{
- label = "3"
- }
- Pre_Encapsulated_PetriNet/Place pre_ct_4{
- label = "4"
- }
- Pre_PLANT2EPN_link P2E_l1 (pre_ct_0, pre_ct_3) {
- label = "5"
- }
- Pre_PLANT2EPN_link P2E_l2(pre_ct_1, pre_ct_4) {
- label = "6"
- }
- Pre_Encapsulated_PetriNet/Place pre_ct_7 {
- label = "7"
- constraint_name = $
- Boolean function constraint(value : String):
- return (bool_or(bool_or(value == "up", value == "neutral"), value == "down"))!
- $
- }
- Pre_Encapsulated_PetriNet/Port pre_ct_8 {
- label = "8"
- constraint_name = $
- Boolean function constraint(value : String):
- return (bool_or(bool_or(value == "up", value == "neutral"), value == "down"))!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace pp_l (pre_ct_8, pre_ct_7) {
- label = "9"
- }
- constraint = $
- Boolean function constraint(model : Element, mapping : Element):
- String transition_type
- String port_name
- transition_type = read_type(model, mapping["2"])
- port_name = read_attribute(model, mapping["8"], "name")
- if (transition_type == "PW_Plant/OnUp"):
- return (port_name == "up")!
- elif (transition_type == "PW_Plant/OnNeutral"):
- return (port_name == "neutral")!
- elif (transition_type == "PW_Plant/OnDown"):
- return (port_name == "down")!
- else:
- return False!
- $
- }
- RHS {
- Post_PW_Plant/State post_ct_0{
- label = "0"
- }
- Post_PW_Plant/State post_ct_1{
- label = "1"
- }
- Post_PW_Plant/Transition post_ct_2 (post_ct_0, post_ct_1) {
- label = "2"
- }
- Post_Encapsulated_PetriNet/Place post_ct_3{
- label = "3"
- }
- Post_Encapsulated_PetriNet/Place post_ct_4{
- label = "4"
- }
- Post_PLANT2EPN_link (post_ct_0, post_ct_3) {
- label = "5"
- }
- Post_PLANT2EPN_link (post_ct_1, post_ct_4) {
- label = "6"
- }
- Post_Encapsulated_PetriNet/Place post_ct_7 {
- label = "7"
- }
- Post_Encapsulated_PetriNet/Port post_ct_8 {
- label = "8"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_ct_8, post_ct_7) {
- label = "9"
- }
- Post_Encapsulated_PetriNet/Transition post_ct_10 {
- label = "10"
- value_name = $
- String function value(model : Element, name : String, mapping : Element):
- return string_join(string_join(read_attribute(model, mapping["0"], "name"), read_type(model, mapping["2"])), read_attribute(model, mapping["2"], "objPresent"))!
- $
- }
- Post_Encapsulated_PetriNet/P2T (post_ct_3, post_ct_10) {
- label = "11"
- }
- Post_Encapsulated_PetriNet/T2P (post_ct_10, post_ct_4) {
- label = "12"
- }
- Post_Encapsulated_PetriNet/P2T (post_ct_7, post_ct_10) {
- label = "13"
- }
- Post_Encapsulated_PetriNet/T2P (post_ct_10, post_ct_7) {
- label = "14"
- }
- Post_PLANT2EPN_tlink (post_ct_2, post_ct_10) {
- label = "100"
- }
- }
- }
- {Contains} ForAll check_object {
- LHS {
- Pre_PW_Plant/State pre_co_0{
- label = "0"
- }
- Pre_PW_Plant/State pre_co_1{
- label = "1"
- }
- Pre_PW_Plant/Transition pre_co_2 (pre_co_0, pre_co_1) {
- label = "2"
- constraint_objPresent = $
- Boolean function constraint(value : String):
- return (bool_or(value == "Y", value == "N"))!
- $
- }
- Pre_Encapsulated_PetriNet/Place pre_co_8 {
- label = "8"
- }
- Pre_Encapsulated_PetriNet/Port pre_co_11 {
- label = "11"
- constraint_name = $
- Boolean function constraint(value : String):
- return (bool_or(value == "objPresent", value == "no_objPresent"))!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_co_11, pre_co_8) {
- label = "12"
- }
- Pre_Encapsulated_PetriNet/Transition pre_co_15 {
- label = "15"
- }
- Pre_PLANT2EPN_tlink (pre_co_2, pre_co_15) {
- label = "100"
- }
- constraint = $
- Boolean function constraint (host_model : Element, mapping : Element):
- // Check whether the bound primary places match with the state
- String objPresent
- String port_name
- objPresent = read_attribute(host_model, mapping["2"], "objPresent")
- port_name = read_attribute(host_model, mapping["11"], "name")
- if (objPresent == "Y"):
- return (port_name == "objPresent")!
- elif (objPresent == "N"):
- return (port_name == "no_objPresent")!
- else:
- return False!
- $
- }
- RHS {
- Post_PW_Plant/State post_co_0{
- label = "0"
- }
- Post_PW_Plant/State post_co_1{
- label = "1"
- }
- Post_PW_Plant/Transition post_co_2 (post_co_0, post_co_1) {
- label = "2"
- }
- Post_Encapsulated_PetriNet/Place post_co_8 {
- label = "8"
- }
- Post_Encapsulated_PetriNet/Port post_co_11 {
- label = "11"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_co_11, post_co_8) {
- label = "12"
- }
- Post_Encapsulated_PetriNet/Transition post_co_15 {
- label = "15"
- }
- Post_Encapsulated_PetriNet/P2T (post_co_8, post_co_15) {
- label = "9"
- }
- Post_Encapsulated_PetriNet/T2P (post_co_15, post_co_8) {
- label = "10"
- }
- Post_PLANT2EPN_tlink (post_co_2, post_co_15) {
- label = "100"
- }
- }
- }
- {Contains} ForAll detect {
- LHS {
- Pre_PW_Plant/NormalState pre_de_0{
- label = "0"
- }
- Pre_PW_Plant/ErrorState pre_de_1{
- label = "1"
- }
- Pre_PW_Plant/Transition pre_de_2 (pre_de_0, pre_de_1) {
- label = "2"
- }
- Pre_Encapsulated_PetriNet/Transition pre_de_7 {
- label = "7"
- }
- Pre_Encapsulated_PetriNet/Place pre_de_10 {
- label = "10"
- }
- Pre_Encapsulated_PetriNet/Port pre_de_11 {
- label = "11"
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_de_11, pre_de_10) {
- label = "12"
- }
- Pre_Encapsulated_PetriNet/Place pre_de_13 {
- label = "13"
- }
- Pre_Encapsulated_PetriNet/Port pre_de_14 {
- label = "14"
- constraint_name = $
- Boolean function constraint(value : String):
- return (value == "interrupt")!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_de_14, pre_de_13) {
- label = "15"
- }
- Pre_Encapsulated_PetriNet/Place pre_de_16 {
- label = "16"
- }
- Pre_Encapsulated_PetriNet/Port pre_de_17 {
- label = "17"
- constraint_name = $
- Boolean function constraint(value : String):
- return (value == "no_objDetected")!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_de_17, pre_de_16) {
- label = "18"
- }
- Pre_Encapsulated_PetriNet/Place pre_de_19 {
- label = "19"
- }
- Pre_Encapsulated_PetriNet/Port pre_de_20 {
- label = "20"
- constraint_name = $
- Boolean function constraint(value : String):
- return (value == "objDetected")!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_de_20, pre_de_19) {
- label = "21"
- }
- Pre_Encapsulated_PetriNet/T2P (pre_de_7, pre_de_10) {
- label = "26"
- }
- Pre_PLANT2EPN_tlink (pre_de_2, pre_de_7) {
- label = "100"
- }
- constraint = $
- Boolean function constraint (host_model : Element, mapping : Element):
- // Check whether the bound primary places match with the state
- String source_type
- String port_name
- source_type = read_type(host_model, mapping["2"])
- port_name = read_attribute(host_model, mapping["11"], "name")
- if (source_type == "PW_Plant/OnUp"):
- return (port_name == "up")!
- elif (source_type == "PW_Plant/OnNeutral"):
- return (port_name == "neutral")!
- elif (source_type == "PW_Plant/OnDown"):
- return (port_name == "down")!
- else:
- return False!
- $
- }
- RHS {
- Post_PW_Plant/NormalState post_de_0{
- label = "0"
- }
- Post_PW_Plant/ErrorState post_de_1{
- label = "1"
- }
- Post_PW_Plant/Transition post_de_2 (post_de_0, post_de_1){
- label = "2"
- }
- Post_Encapsulated_PetriNet/Transition post_de_7 {
- label = "7"
- }
- Post_Encapsulated_PetriNet/Place post_de_10 {
- label = "10"
- }
- Post_Encapsulated_PetriNet/Port post_de_11 {
- label = "11"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_de_11, post_de_10) {
- label = "12"
- }
- Post_Encapsulated_PetriNet/Place post_de_13 {
- label = "13"
- }
- Post_Encapsulated_PetriNet/Port post_de_14 {
- label = "14"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_de_14, post_de_13) {
- label = "15"
- }
- Post_Encapsulated_PetriNet/Place post_de_16 {
- label = "16"
- }
- Post_Encapsulated_PetriNet/Port post_de_17 {
- label = "17"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_de_17, post_de_16) {
- label = "18"
- }
- Post_Encapsulated_PetriNet/Place post_de_19 {
- label = "19"
- }
- Post_Encapsulated_PetriNet/Port post_de_20 {
- label = "20"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_de_20, post_de_19) {
- label = "21"
- }
- Post_Encapsulated_PetriNet/T2P (post_de_7, post_de_13) {
- label = "23"
- }
- Post_Encapsulated_PetriNet/P2T (post_de_16, post_de_7) {
- label = "24"
- }
- Post_Encapsulated_PetriNet/T2P (post_de_7, post_de_19) {
- label = "25"
- }
- Post_PLANT2EPN_tlink (post_de_2, post_de_7) {
- label = "100"
- }
- }
- }
- {Contains} ForAll remove_detect {
- LHS {
- Pre_PW_Plant/ErrorState pre_rd_0{
- label = "0"
- }
- Pre_PW_Plant/NormalState pre_rd_1{
- label = "1"
- }
- Pre_PW_Plant/Transition pre_rd_2 (pre_rd_0, pre_rd_1){
- label = "2"
- }
- Pre_Encapsulated_PetriNet/Transition pre_rd_7 {
- label = "7"
- }
- Pre_Encapsulated_PetriNet/Place pre_rd_10 {
- label = "10"
- }
- Pre_Encapsulated_PetriNet/Port pre_rd_11 {
- label = "11"
- constraint_name = $
- Boolean function constraint(value : String):
- return (value == "objDetected")!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_rd_11, pre_rd_10) {
- label = "12"
- }
- Pre_Encapsulated_PetriNet/Place pre_rd_13 {
- label = "13"
- }
- Pre_Encapsulated_PetriNet/Port pre_rd_14 {
- label = "14"
- constraint_name = $
- Boolean function constraint(value : String):
- return (value == "no_objDetected")!
- $
- }
- Pre_Encapsulated_PetriNet/PortPlace (pre_rd_14, pre_rd_13) {
- label = "15"
- }
- Pre_PLANT2EPN_tlink (pre_rd_2, pre_rd_7) {
- label = "100"
- }
- }
- RHS {
- Post_PW_Plant/ErrorState post_rd_0{
- label = "0"
- }
- Post_PW_Plant/NormalState post_rd_1{
- label = "1"
- }
- Post_PW_Plant/Transition post_rd_2 (post_rd_0, post_rd_1){
- label = "2"
- }
- Post_Encapsulated_PetriNet/Transition post_rd_7 {
- label = "7"
- }
- Post_Encapsulated_PetriNet/Place post_rd_10 {
- label = "10"
- }
- Post_Encapsulated_PetriNet/Port post_rd_11 {
- label = "11"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_rd_11, post_rd_10) {
- label = "12"
- }
- Post_Encapsulated_PetriNet/Place post_rd_13 {
- label = "13"
- }
- Post_Encapsulated_PetriNet/Port post_rd_14 {
- label = "14"
- }
- Post_Encapsulated_PetriNet/PortPlace (post_rd_14, post_rd_13) {
- label = "15"
- }
- Post_Encapsulated_PetriNet/P2T (post_rd_10, post_rd_7) {
- label = "16"
- }
- Post_Encapsulated_PetriNet/T2P (post_rd_7, post_rd_13) {
- label = "17"
- }
- Post_PLANT2EPN_tlink (post_rd_2, post_rd_7) {
- label = "100"
- }
- }
- }
- }
- Initial (schedule, init_ports) {}
- OnSuccess (init_ports, create_states) {}
- OnSuccess (create_states, command_transition) {}
- OnSuccess (command_transition, check_object) {}
- OnSuccess (check_object, detect) {}
- OnSuccess (detect, remove_detect) {}
- OnSuccess (remove_detect, finish) {}
- OnSuccess (finish, success) {}
- OnFailure (init_ports, create_states) {}
- OnFailure (create_states, command_transition) {}
- OnFailure (command_transition, check_object) {}
- OnFailure (check_object, detect) {}
- OnFailure (detect, remove_detect) {}
- OnFailure (remove_detect, finish) {}
- OnFailure (finish, failure) {}
|