|
@@ -45,8 +45,8 @@ Element function petrinet_enabled_set(model : Element):
|
|
|
|
|
|
Integer present_tokens
|
|
|
Integer required_tokens
|
|
|
- required_tokens = readAttribute(model, arc_under_study, "weight")
|
|
|
- present_tokens = readAttribute(model, read_edge_src(arc_under_study), "tokens")
|
|
|
+ required_tokens = read_attribute(model, getName(model, arc_under_study), "weight")
|
|
|
+ present_tokens = read_attribute(model, getName(model, read_edge_src(arc_under_study)), "tokens")
|
|
|
if (present_tokens < required_tokens):
|
|
|
// Less tokens than required, so disable the transition completely
|
|
|
enabled = False
|
|
@@ -73,20 +73,20 @@ Element function petrinet_fire(model : Element):
|
|
|
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"))
|
|
|
+ new_value = integer_subtraction(read_attribute(model, getName(model, working_place), "tokens"), read_attribute(model, getName(model, working_arc), "weight"))
|
|
|
unset_attribute(model, getName(model, working_place), "tokens")
|
|
|
instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
|
|
|
- output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
|
+ output(((" " + getName(model, working_place)) + ": ") + cast_i2s(read_attribute(model, getName(model, working_place), "tokens")))
|
|
|
|
|
|
// Add tokens
|
|
|
workset = allOutgoingAssociationInstances(model, transition, model["metamodel"]["model"]["T2P"])
|
|
|
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"))
|
|
|
+ new_value = integer_addition(read_attribute(model, getName(model, working_place), "tokens"), read_attribute(model, getName(model, working_arc), "weight"))
|
|
|
unset_attribute(model, getName(model, working_place), "tokens")
|
|
|
instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
|
|
|
- output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
|
+ output(((" " + getName(model, working_place)) + ": ") + cast_i2s(read_attribute(model, getName(model, working_place), "tokens")))
|
|
|
output("Transition fired!")
|
|
|
else:
|
|
|
output("Cannot fire if not enabled; aborting")
|
|
@@ -249,17 +249,17 @@ Element function petrinet_loaded(model : Element):
|
|
|
if (cast_v2s(read_elem) != "None"):
|
|
|
output("Value: " + cast_v2s(read_elem))
|
|
|
output("Defines attributes:")
|
|
|
- attr_list_pn = getInstantiatableAttributes(model, read_elem)
|
|
|
- attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
- while (0 < read_nr_out(attr_keys_pn)):
|
|
|
- attr_key_pn = set_pop(attr_keys_pn)
|
|
|
- output((((" " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])))
|
|
|
+ //attr_list_pn = getInstantiatableAttributes(model, read_elem)
|
|
|
+ //attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
+ //while (0 < read_nr_out(attr_keys_pn)):
|
|
|
+ // attr_key_pn = set_pop(attr_keys_pn)
|
|
|
+ // output((((" " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])))
|
|
|
output("Attributes:")
|
|
|
- attr_list_pn = getAttributeList(model, read_elem)
|
|
|
+ attr_list_pn = getAttributeList(model, cmd)
|
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
|
attr_key_pn = set_pop(attr_keys_pn)
|
|
|
- output(((((" " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
|
|
|
+ output(((((" " + cast_v2s(attr_key_pn)) + " : ") + cast_v2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(read_attribute(model, getName(model, read_elem), attr_key_pn)))
|
|
|
else:
|
|
|
output("Unknown element; aborting")
|
|
|
elif (cmd == "verify"):
|