|
@@ -5,6 +5,7 @@ include "library.alh"
|
|
|
include "conformance_scd.alh"
|
|
|
include "io.alh"
|
|
|
include "metamodels.alh"
|
|
|
+include "modelling.alh"
|
|
|
|
|
|
Element function pn_operations():
|
|
|
Element ops
|
|
@@ -65,12 +66,16 @@ Element function petrinet_fire(model : Element):
|
|
|
Element workset
|
|
|
Element working_place
|
|
|
Element working_arc
|
|
|
+ Integer new_value
|
|
|
|
|
|
// Consume tokens
|
|
|
workset = allIncomingAssociationInstances(model, transition, model["metamodel"]["model"]["P2T"])
|
|
|
while (0 < read_nr_out(workset)):
|
|
|
working_arc = set_pop(workset)
|
|
|
working_place = read_edge_src(working_arc)
|
|
|
+ new_value = integer_subtraction(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight"))
|
|
|
+ unset_attribute(model, getName(model, working_place), "tokens")
|
|
|
+ instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
|
|
|
//setAttribute(model, working_place, "tokens", integer_subtraction(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
|
|
|
output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
|
|
|
@@ -79,6 +84,9 @@ Element function petrinet_fire(model : Element):
|
|
|
while (0 < read_nr_out(workset)):
|
|
|
working_arc = set_pop(workset)
|
|
|
working_place = read_edge_dst(working_arc)
|
|
|
+ new_value = integer_addition(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight"))
|
|
|
+ unset_attribute(model, getName(model, working_place), "tokens")
|
|
|
+ instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
|
|
|
//setAttribute(model, working_place, "tokens", integer_addition(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
|
|
|
output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
|
output("Transition fired!")
|