|
@@ -1139,8 +1139,10 @@ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
SimpleClassDiagrams (Inheritance) PetriNets_Runtime{
|
|
|
Class Natural {}
|
|
|
Class Boolean {}
|
|
|
+ Class String {}
|
|
|
Class Place {
|
|
|
tokens : Natural
|
|
|
+ name : String
|
|
|
}
|
|
|
Class Transition {
|
|
|
executing : Boolean
|
|
@@ -1186,11 +1188,11 @@ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
export pn to models/pn
|
|
|
"""
|
|
|
|
|
|
- schedule_model = \
|
|
|
+ schedule_model_annotate = \
|
|
|
"""
|
|
|
- import models/PetriNets_SCHEDULE as PN_Transform
|
|
|
+ import models/RAM_PetriNets_Design_Runtime as RAM_PN_DR
|
|
|
|
|
|
- PN_Transform annotate {
|
|
|
+ RAM_PN_DR annotate {
|
|
|
Composite schedule {
|
|
|
{Contains} Failure failure {}
|
|
|
{Contains} Success success {}
|
|
@@ -1236,6 +1238,7 @@ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
include "modelling.alh"
|
|
|
Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
instantiate_attribute(host_model, name, "tokens", read_attribute(host_model, mapping["0"], "tokens"))
|
|
|
+ instantiate_attribute(host_model, name, "name", mapping["0"])
|
|
|
return!
|
|
|
$
|
|
|
}
|
|
@@ -1375,6 +1378,212 @@ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
export annotate to models/pn_annotate
|
|
|
"""
|
|
|
|
|
|
+ schedule_model_print = \
|
|
|
+ """
|
|
|
+ import models/RAM_PetriNets_Runtime as RAM_PN_R
|
|
|
+
|
|
|
+ RAM_PN_R print {
|
|
|
+ Composite schedule {
|
|
|
+ {Contains} Success success {}
|
|
|
+ {Contains} ForAll print_tokens {
|
|
|
+ LHS {
|
|
|
+ Pre_Place {
|
|
|
+ label = "0"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RHS {
|
|
|
+ Post_Place {
|
|
|
+ label = "0"
|
|
|
+ action = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
+ output((cast_v2s(read_attribute(host_model, name, "name")) + " --> ") + cast_v2s(read_attribute(host_model, name, "tokens")))
|
|
|
+ return!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OnSuccess (print_tokens, success) {}
|
|
|
+ OnFailure (print_tokens, success) {}
|
|
|
+ Initial (schedule, print_tokens) {}
|
|
|
+ }
|
|
|
+
|
|
|
+ export print to models/pn_print
|
|
|
+ """
|
|
|
+
|
|
|
+ schedule_model_simulate = \
|
|
|
+ """
|
|
|
+ import models/RAM_PetriNets_Runtime as RAM_PN_R
|
|
|
+
|
|
|
+ RAM_PN_R s {
|
|
|
+ Composite schedule {
|
|
|
+ {Contains} Failure failure {}
|
|
|
+ {Contains} Success success {}
|
|
|
+ {Contains} Atomic mark {
|
|
|
+ LHS {
|
|
|
+ Pre_Transition {
|
|
|
+ label = "1"
|
|
|
+ constraint = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ include "object_operations.alh"
|
|
|
+ Boolean function constraint(host_model : Element, name : String):
|
|
|
+ Element links
|
|
|
+ String link
|
|
|
+ String place
|
|
|
+ links = allIncomingAssociationInstances(host_model, name, "P2T")
|
|
|
+ while (read_nr_out(links) > 0):
|
|
|
+ link = set_pop(links)
|
|
|
+ place = readAssociationSource(host_model, link)
|
|
|
+ if (integer_lt(read_attribute(host_model, place, "tokens"), read_attribute(host_model, link, "weight"))):
|
|
|
+ return False!
|
|
|
+ return True!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RHS {
|
|
|
+ Post_Transition {
|
|
|
+ label = "1"
|
|
|
+ action = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
+ unset_attribute(host_model, name, "executing")
|
|
|
+ instantiate_attribute(host_model, name, "executing", True)
|
|
|
+ return!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {Contains} ForAll consume {
|
|
|
+ LHS {
|
|
|
+ Pre_Transition lhs_consume_t{
|
|
|
+ label = "0"
|
|
|
+ constraint = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Boolean function constraint(host_model : Element, name : String):
|
|
|
+ // Check if this node is executing currently
|
|
|
+ return value_eq(read_attribute(host_model, name, "executing"), True)!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ Pre_Place lhs_consume_p{
|
|
|
+ label = "1"
|
|
|
+ }
|
|
|
+ Pre_P2T lhs_consume_p2t(lhs_consume_p, lhs_consume_t){
|
|
|
+ label = "2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RHS {
|
|
|
+ Post_Transition rhs_consume_t {
|
|
|
+ label = "0"
|
|
|
+ }
|
|
|
+ Post_Place rhs_consume_p {
|
|
|
+ label = "1"
|
|
|
+ action = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
+ Integer tokens
|
|
|
+ Integer weight
|
|
|
+ tokens = read_attribute(host_model, name, "tokens")
|
|
|
+ weight = read_attribute(host_model, mapping["2"], "weight")
|
|
|
+ unset_attribute(host_model, name, "tokens")
|
|
|
+ instantiate_attribute(host_model, name, "tokens", tokens - weight)
|
|
|
+ return!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ Post_P2T (rhs_consume_p, rhs_consume_t){
|
|
|
+ label = "2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {Contains} ForAll produce {
|
|
|
+ LHS {
|
|
|
+ Pre_Transition lhs_produce_t{
|
|
|
+ label = "0"
|
|
|
+ constraint = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Boolean function constraint(host_model : Element, name : String):
|
|
|
+ // Check if this node is executing currently
|
|
|
+ return value_eq(read_attribute(host_model, name, "executing"), True)!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ Pre_Place lhs_produce_p{
|
|
|
+ label = "1"
|
|
|
+ }
|
|
|
+ Pre_T2P (lhs_produce_t, lhs_produce_p){
|
|
|
+ label = "2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RHS {
|
|
|
+ Post_Transition rhs_produce_t{
|
|
|
+ label = "0"
|
|
|
+ }
|
|
|
+ Post_Place rhs_produce_p{
|
|
|
+ label = "1"
|
|
|
+ action = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
+ Integer tokens
|
|
|
+ Integer weight
|
|
|
+ tokens = read_attribute(host_model, name, "tokens")
|
|
|
+ weight = read_attribute(host_model, mapping["2"], "weight")
|
|
|
+ unset_attribute(host_model, name, "tokens")
|
|
|
+ instantiate_attribute(host_model, name, "tokens", tokens + weight)
|
|
|
+ return!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ Post_T2P (rhs_produce_t, rhs_produce_p){
|
|
|
+ label = "2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {Contains} Atomic unmark_transition {
|
|
|
+ LHS {
|
|
|
+ Pre_Transition {
|
|
|
+ label = "0"
|
|
|
+ constraint = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Boolean function constraint(host_model : Element, name : String):
|
|
|
+ // Check if this node is executing currently
|
|
|
+ return value_eq(read_attribute(host_model, name, "executing"), True)!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RHS {
|
|
|
+ Post_Transition {
|
|
|
+ label = "0"
|
|
|
+ action = $
|
|
|
+ include "primitives.alh"
|
|
|
+ include "modelling.alh"
|
|
|
+ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
+ unset_attribute(host_model, name, "executing")
|
|
|
+ instantiate_attribute(host_model, name, "executing", False)
|
|
|
+ return!
|
|
|
+ $
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OnSuccess (mark, consume) {}
|
|
|
+ OnFailure (mark, failure) {}
|
|
|
+ OnSuccess (consume, produce) {}
|
|
|
+ OnFailure (consume, produce) {}
|
|
|
+ OnSuccess (produce, unmark_transition) {}
|
|
|
+ OnFailure (produce, unmark_transition) {}
|
|
|
+ OnSuccess (unmark_transition, success) {}
|
|
|
+ OnFailure (unmark_transition, failure) {}
|
|
|
+ Initial (schedule, mark) {}
|
|
|
+ }
|
|
|
+
|
|
|
+ export s to models/pn_simulate
|
|
|
+ """
|
|
|
self.assertTrue(run_file(all_files,
|
|
|
get_model_constructor(PN_runtime) + \
|
|
|
get_model_constructor(PN_model) + [
|
|
@@ -1384,12 +1593,15 @@ Void function action(host_model : Element, name : String, mapping : Element):
|
|
|
"instantiate", "Association", "PlaceLink", "SOURCE_Place", "TARGET_Place",
|
|
|
"instantiate", "Association", "TransitionLink", "SOURCE_Transition", "TARGET_Transition",
|
|
|
"exit",
|
|
|
- "ramify", "PetriNets_SCHEDULE", "PetriNets_Design_to_Runtime",
|
|
|
- ] + get_model_constructor(schedule_model) + [
|
|
|
+ "ramify", "RAM_PetriNets_Design_Runtime", "PetriNets_Design_to_Runtime",
|
|
|
+ "ramify", "RAM_PetriNets_Runtime", "PetriNets_Runtime",
|
|
|
+ ] + get_model_constructor(schedule_model_annotate) + [
|
|
|
+ ] + get_model_constructor(schedule_model_print) + [
|
|
|
+ ] + get_model_constructor(schedule_model_simulate) + [
|
|
|
"transform", "pn", "pn_annotate",
|
|
|
"split", "pn", "PetriNets_Runtime", "TARGET_",
|
|
|
- "load", "pn",
|
|
|
- "verify",
|
|
|
- "exit",
|
|
|
+ "transform", "pn", "pn_print",
|
|
|
+ "transform", "pn", "pn_simulate",
|
|
|
+ "transform", "pn", "pn_print",
|
|
|
],
|
|
|
None, "PO"))
|