|
@@ -51,29 +51,29 @@ Element function create_metamodels():
|
|
|
export_node("models/SimpleClassDiagrams", scd)
|
|
|
|
|
|
// TODO this code is also very dirty as there is no nice "dictionary" and "list" syntax yet
|
|
|
- Element pn_metamodel
|
|
|
- pn_metamodel = instantiate_new_model(scd, dict_read(scd_model, "Inheritance"))
|
|
|
+ Element modeletamodel
|
|
|
+ modeletamodel = instantiate_new_model(scd, dict_read(scd_model, "Inheritance"))
|
|
|
Element tokens
|
|
|
tokens = create_node()
|
|
|
dict_add(tokens, "tokens", Integer)
|
|
|
- instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Class"), "Place", create_node(), tokens, create_node())
|
|
|
- instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Class"), "Transition", create_node(), create_node(), create_node())
|
|
|
+ instantiate_model_lib(modeletamodel, dict_read(scd_model, "Class"), "Place", create_node(), tokens, create_node())
|
|
|
+ instantiate_model_lib(modeletamodel, dict_read(scd_model, "Class"), "Transition", create_node(), create_node(), create_node())
|
|
|
Element weight
|
|
|
weight = create_node()
|
|
|
dict_add(weight, "weight", Integer)
|
|
|
Element p2t_links
|
|
|
p2t_links = create_node()
|
|
|
- list_append(p2t_links, dict_read(dict_read(pn_metamodel, "model"), "Place"))
|
|
|
- list_append(p2t_links, dict_read(dict_read(pn_metamodel, "model"), "Transition"))
|
|
|
+ list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Place"))
|
|
|
+ list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Transition"))
|
|
|
Element t2p_links
|
|
|
t2p_links = create_node()
|
|
|
- list_append(t2p_links, dict_read(dict_read(pn_metamodel, "model"), "Transition"))
|
|
|
- list_append(t2p_links, dict_read(dict_read(pn_metamodel, "model"), "Place"))
|
|
|
- instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Association"), "P2T", p2t_links, weight, create_node())
|
|
|
- instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Association"), "T2P", t2p_links, weight, create_node())
|
|
|
+ list_append(t2p_links, dict_read(dict_read(modeletamodel, "model"), "Transition"))
|
|
|
+ list_append(t2p_links, dict_read(dict_read(modeletamodel, "model"), "Place"))
|
|
|
+ instantiate_model_lib(modeletamodel, dict_read(scd_model, "Association"), "P2T", p2t_links, weight, create_node())
|
|
|
+ instantiate_model_lib(modeletamodel, dict_read(scd_model, "Association"), "T2P", t2p_links, weight, create_node())
|
|
|
|
|
|
- set_model_constraints(pn_metamodel, petrinet_constraints)
|
|
|
- export_node("models/PetriNets", pn_metamodel)
|
|
|
+ set_model_constraints(modeletamodel, petrinet_constraints)
|
|
|
+ export_node("models/PetriNets", modeletamodel)
|
|
|
|
|
|
// Also create conformance bottom metamodel
|
|
|
Element mm_bottom
|
|
@@ -121,29 +121,29 @@ Element function create_metamodels():
|
|
|
|
|
|
return 0
|
|
|
|
|
|
-String function petrinet_constraints(pn_mo : Element):
|
|
|
+String function petrinet_constraints(model : Element):
|
|
|
// Check places to have positive number of tokens
|
|
|
Element all_elems
|
|
|
Element elem_constraint
|
|
|
- all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "Place"))
|
|
|
+ all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Place"))
|
|
|
while (0 < read_nr_out(all_elems)):
|
|
|
elem_constraint = set_pop(all_elems)
|
|
|
- if (integer_lt(readAttribute(pn_mo, elem_constraint, "tokens"), 0)):
|
|
|
- return "Negative number of tokens in Place " + getName(pn_mo, elem_constraint)
|
|
|
+ if (integer_lt(readAttribute(model, elem_constraint, "tokens"), 0)):
|
|
|
+ return "Negative number of tokens in Place " + getName(model, elem_constraint)
|
|
|
|
|
|
// Check P2T transitions to have positive weight
|
|
|
- all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "P2T"))
|
|
|
+ all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
while (0 < read_nr_out(all_elems)):
|
|
|
elem_constraint = set_pop(all_elems)
|
|
|
- if (integer_lt(readAttribute(pn_mo, elem_constraint, "weight"), 0)):
|
|
|
- return "Negative weight in arc " + getName(pn_mo, elem_constraint)
|
|
|
+ if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
|
+ return "Negative weight in arc " + getName(model, elem_constraint)
|
|
|
|
|
|
// Check T2P transitions to have positive weight
|
|
|
- all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "T2P"))
|
|
|
+ all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
|
|
|
while (0 < read_nr_out(all_elems)):
|
|
|
elem_constraint = set_pop(all_elems)
|
|
|
- if (integer_lt(readAttribute(pn_mo, elem_constraint, "weight"), 0)):
|
|
|
- return "Negative weight in arc " + getName(pn_mo, elem_constraint)
|
|
|
+ if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
|
+ return "Negative weight in arc " + getName(model, elem_constraint)
|
|
|
|
|
|
return "OK"
|
|
|
|
|
@@ -154,17 +154,17 @@ Element function pn_operations():
|
|
|
dict_add(ops, "enabled", petrinet_enabled)
|
|
|
return ops
|
|
|
|
|
|
-Element function petrinet_enabled(pn_m : Element):
|
|
|
+Element function petrinet_enabled(model : Element):
|
|
|
Element set_enabled
|
|
|
- set_enabled = petrinet_enabled_set(pn_m)
|
|
|
+ set_enabled = petrinet_enabled_set(model)
|
|
|
output("Enabled transitions:")
|
|
|
while (0 < read_nr_out(set_enabled)):
|
|
|
- output(getName(pn_m, set_pop(set_enabled)))
|
|
|
- return pn_m
|
|
|
+ output(getName(model, set_pop(set_enabled)))
|
|
|
+ return model
|
|
|
|
|
|
-Element function petrinet_enabled_set(pn_mod : Element):
|
|
|
+Element function petrinet_enabled_set(model : Element):
|
|
|
Element all_transitions
|
|
|
- all_transitions = allInstances(pn_mod, dict_read(dict_read(dict_read(pn_mod, "metamodel"), "model"), "Transition"))
|
|
|
+ all_transitions = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Transition"))
|
|
|
|
|
|
Element enabled_transitions
|
|
|
enabled_transitions = create_node()
|
|
@@ -178,15 +178,15 @@ Element function petrinet_enabled_set(pn_mod : Element):
|
|
|
enabled = True
|
|
|
|
|
|
// Find all incoming transitions
|
|
|
- in_arcs = allIncomingAssociationInstances(pn_mod, under_study, dict_read(dict_read(dict_read(pn_mod, "metamodel"), "model"), "P2T"))
|
|
|
+ in_arcs = allIncomingAssociationInstances(model, under_study, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
|
|
|
while (0 < read_nr_out(in_arcs)):
|
|
|
arc_under_study = set_pop(in_arcs)
|
|
|
|
|
|
Integer present_tokens
|
|
|
Integer required_tokens
|
|
|
- required_tokens = readAttribute(pn_mod, arc_under_study, "weight")
|
|
|
- present_tokens = readAttribute(pn_mod, read_edge_src(arc_under_study), "tokens")
|
|
|
+ required_tokens = readAttribute(model, arc_under_study, "weight")
|
|
|
+ present_tokens = readAttribute(model, read_edge_src(arc_under_study), "tokens")
|
|
|
if (present_tokens < required_tokens):
|
|
|
// Less tokens than required, so disable the transition completely
|
|
|
enabled = False
|
|
@@ -196,40 +196,40 @@ Element function petrinet_enabled_set(pn_mod : Element):
|
|
|
|
|
|
return enabled_transitions
|
|
|
|
|
|
-Element function petrinet_fire(pn_mode : Element):
|
|
|
+Element function petrinet_fire(model : Element):
|
|
|
output("Transition to fire?")
|
|
|
Element transition
|
|
|
transition = input()
|
|
|
- if (dict_in(dict_read(pn_mode, "model"), transition)):
|
|
|
- transition = dict_read(dict_read(pn_mode, "model"), transition)
|
|
|
- if (set_in(petrinet_enabled_set(pn_mode), transition)):
|
|
|
+ if (dict_in(dict_read(model, "model"), transition)):
|
|
|
+ transition = dict_read(dict_read(model, "model"), transition)
|
|
|
+ if (set_in(petrinet_enabled_set(model), transition)):
|
|
|
Element workset
|
|
|
Element working_place
|
|
|
Element working_arc
|
|
|
|
|
|
// Consume tokens
|
|
|
- workset = allIncomingAssociationInstances(pn_mode, transition, dict_read(dict_read(dict_read(pn_mode, "metamodel"), "model"), "P2T"))
|
|
|
+ workset = allIncomingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
while (0 < read_nr_out(workset)):
|
|
|
working_arc = set_pop(workset)
|
|
|
working_place = read_edge_src(working_arc)
|
|
|
- setAttribute(pn_mode, working_place, "tokens", integer_subtraction(readAttribute(pn_mode, working_place, "tokens"), readAttribute(pn_mode, working_arc, "weight")))
|
|
|
- output(((" " + getName(pn_mode, working_place)) + ": ") + cast_i2s(readAttribute(pn_mode, working_place, "tokens")))
|
|
|
+ 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")))
|
|
|
|
|
|
// Add tokens
|
|
|
- workset = allOutgoingAssociationInstances(pn_mode, transition, dict_read(dict_read(dict_read(pn_mode, "metamodel"), "model"), "T2P"))
|
|
|
+ workset = allOutgoingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
|
|
|
while (0 < read_nr_out(workset)):
|
|
|
working_arc = set_pop(workset)
|
|
|
working_place = read_edge_dst(working_arc)
|
|
|
- setAttribute(pn_mode, working_place, "tokens", integer_addition(readAttribute(pn_mode, working_place, "tokens"), readAttribute(pn_mode, working_arc, "weight")))
|
|
|
- output(((" " + getName(pn_mode, working_place)) + ": ") + cast_i2s(readAttribute(pn_mode, working_place, "tokens")))
|
|
|
+ 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!")
|
|
|
else:
|
|
|
output("Cannot fire if not enabled; aborting")
|
|
|
else:
|
|
|
output("Unknown transition; aborting")
|
|
|
- return pn_mode
|
|
|
+ return model
|
|
|
|
|
|
-Element function petrinet_loaded(pn_model : Element):
|
|
|
+Element function petrinet_loaded(model : Element):
|
|
|
String cmd
|
|
|
|
|
|
Element attr_list_pn
|
|
@@ -242,7 +242,7 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
|
|
|
bottom = False
|
|
|
other_metamodel = create_node()
|
|
|
- dict_add(other_metamodel, "model", dict_read(pn_model, "model"))
|
|
|
+ dict_add(other_metamodel, "model", dict_read(model, "model"))
|
|
|
dict_add(other_metamodel, "type_mapping", create_node())
|
|
|
dict_add(other_metamodel, "metamodel", import_node("models/LTM_bottom"))
|
|
|
dict_add(other_metamodel, "inheritance", dict_read(dict_read(dict_read(other_metamodel, "metamodel"), "model"), "__Inheritance"))
|
|
@@ -275,17 +275,17 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
specific_op = set_pop(specific_ops)
|
|
|
output(" " + specific_op)
|
|
|
elif (cmd == "exit"):
|
|
|
- return pn_model
|
|
|
+ return model
|
|
|
elif (cmd == "instantiate"):
|
|
|
String mm_type_name
|
|
|
output("Type to instantiate?")
|
|
|
mm_type_name = input()
|
|
|
- if (dict_in(dict_read(dict_read(pn_model, "metamodel"), "model"), mm_type_name)):
|
|
|
- metamodel_element_pn = dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), mm_type_name)
|
|
|
+ if (dict_in(dict_read(dict_read(model, "metamodel"), "model"), mm_type_name)):
|
|
|
+ metamodel_element_pn = dict_read(dict_read(dict_read(model, "metamodel"), "model"), mm_type_name)
|
|
|
String element_name
|
|
|
output("Name of new element?")
|
|
|
element_name = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), element_name)):
|
|
|
+ if (dict_in(dict_read(model, "model"), element_name)):
|
|
|
output("Element already exists; aborting")
|
|
|
else:
|
|
|
Boolean cnt
|
|
@@ -296,13 +296,13 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
output("Source name?")
|
|
|
String src_name
|
|
|
src_name = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), src_name)):
|
|
|
- list_append(additional_opts, dict_read(dict_read(pn_model, "model"), src_name))
|
|
|
+ if (dict_in(dict_read(model, "model"), src_name)):
|
|
|
+ list_append(additional_opts, dict_read(dict_read(model, "model"), src_name))
|
|
|
output("Destination name?")
|
|
|
String dst_name
|
|
|
dst_name = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), dst_name)):
|
|
|
- list_append(additional_opts, dict_read(dict_read(pn_model, "model"), dst_name))
|
|
|
+ if (dict_in(dict_read(model, "model"), dst_name)):
|
|
|
+ list_append(additional_opts, dict_read(dict_read(model, "model"), dst_name))
|
|
|
else:
|
|
|
output("Unknown destination; aborting")
|
|
|
cnt = False
|
|
@@ -314,7 +314,7 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
output("Value?")
|
|
|
list_append(additional_opts, input())
|
|
|
if (cnt):
|
|
|
- attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
|
|
|
+ attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
Element attrs
|
|
|
attrs = create_node()
|
|
@@ -323,27 +323,27 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
output(((attr_key_pn + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))) + "?")
|
|
|
dict_add(attrs, attr_key_pn, input())
|
|
|
Element resulting_element
|
|
|
- resulting_element = instantiate_model_lib(pn_model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
|
|
|
+ resulting_element = instantiate_model_lib(model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
|
|
|
output("Instantiation successful!")
|
|
|
else:
|
|
|
output("Unknown type specified; aborting")
|
|
|
elif (cmd == "delete"):
|
|
|
output("What is the name of the element you want to delete?")
|
|
|
cmd = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), cmd)):
|
|
|
- delete_element(dict_read(dict_read(pn_model, "model"), cmd))
|
|
|
+ if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
+ delete_element(dict_read(dict_read(model, "model"), cmd))
|
|
|
output("Deleted!")
|
|
|
else:
|
|
|
output("No such element; aborting")
|
|
|
elif (cmd == "modify"):
|
|
|
output("Element to modify?")
|
|
|
cmd = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), cmd)):
|
|
|
+ if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
Element mod
|
|
|
- mod = dict_read(dict_read(pn_model, "model"), cmd)
|
|
|
- metamodel_element_pn = dict_read_node(dict_read(pn_model, "type_mapping"), mod)
|
|
|
+ mod = dict_read(dict_read(model, "model"), cmd)
|
|
|
+ metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), mod)
|
|
|
|
|
|
- attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
|
|
|
+ attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
|
attr_key_pn = set_pop(attr_keys_pn)
|
|
@@ -352,9 +352,9 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
output("Attribute to modify?")
|
|
|
String attr_name
|
|
|
attr_name = input()
|
|
|
- if (set_in(dict_keys(getAttributeList(pn_model, metamodel_element_pn)), attr_name)):
|
|
|
+ if (set_in(dict_keys(getAttributeList(model, metamodel_element_pn)), attr_name)):
|
|
|
output("New value?")
|
|
|
- setAttribute(pn_model, mod, attr_name, input())
|
|
|
+ setAttribute(model, mod, attr_name, input())
|
|
|
output("Modified!")
|
|
|
else:
|
|
|
output("Unknown attribute; aborting")
|
|
@@ -364,82 +364,82 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
output("Old name?")
|
|
|
String old_name_e
|
|
|
old_name_e = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), old_name_e)):
|
|
|
+ if (dict_in(dict_read(model, "model"), old_name_e)):
|
|
|
output("New name?")
|
|
|
String new_name_e
|
|
|
new_name_e = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), new_name_e)):
|
|
|
+ if (dict_in(dict_read(model, "model"), new_name_e)):
|
|
|
output("New name already used; aborting")
|
|
|
else:
|
|
|
- dict_add(dict_read(pn_model, "model"), new_name_e, dict_read(dict_read(pn_model, "model"), old_name_e))
|
|
|
- dict_delete(dict_read(pn_model, "model"), old_name_e)
|
|
|
+ dict_add(dict_read(model, "model"), new_name_e, dict_read(dict_read(model, "model"), old_name_e))
|
|
|
+ dict_delete(dict_read(model, "model"), old_name_e)
|
|
|
output("Rename complete!")
|
|
|
else:
|
|
|
output("Unknown element; aborting")
|
|
|
elif (cmd == "list"):
|
|
|
Element keys_m
|
|
|
- keys_m = dict_keys(dict_read(pn_model, "model"))
|
|
|
+ keys_m = dict_keys(dict_read(model, "model"))
|
|
|
output("List of all elements:")
|
|
|
String v_m
|
|
|
while (read_nr_out(keys_m) > 0):
|
|
|
v_m = set_pop(keys_m)
|
|
|
// Filter out anonymous objects
|
|
|
- typename = getName(dict_read(pn_model, "metamodel"), dict_read_node(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), v_m)))
|
|
|
+ typename = getName(dict_read(model, "metamodel"), dict_read_node(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), v_m)))
|
|
|
if (bool_not(string_startswith(v_m, "__"))):
|
|
|
output(((" " + v_m) + " : ") + typename)
|
|
|
elif (cmd == "read"):
|
|
|
output("Element to read?")
|
|
|
cmd = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), cmd)):
|
|
|
+ if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
Element read_elem
|
|
|
- read_elem = dict_read(dict_read(pn_model, "model"), cmd)
|
|
|
- metamodel_element_pn = dict_read_node(dict_read(pn_model, "type_mapping"), read_elem)
|
|
|
+ read_elem = dict_read(dict_read(model, "model"), cmd)
|
|
|
+ metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), read_elem)
|
|
|
|
|
|
output("Name: " + cmd)
|
|
|
- output("Type: " + getName(dict_read(pn_model, "metamodel"), metamodel_element_pn))
|
|
|
+ output("Type: " + getName(dict_read(model, "metamodel"), metamodel_element_pn))
|
|
|
if (is_edge(read_elem)):
|
|
|
- output("Source: " + getName(pn_model, read_edge_src(read_elem)))
|
|
|
- output("Destination: " + getName(pn_model, read_edge_dst(read_elem)))
|
|
|
+ output("Source: " + getName(model, read_edge_src(read_elem)))
|
|
|
+ output("Destination: " + getName(model, read_edge_dst(read_elem)))
|
|
|
if (cast_v2s(read_elem) != "None"):
|
|
|
output("Value: " + cast_v2s(read_elem))
|
|
|
output("Defines attributes:")
|
|
|
- attr_list_pn = getInstantiatableAttributes(pn_model, read_elem)
|
|
|
+ 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_t2s(dict_read(attr_list_pn, attr_key_pn))))
|
|
|
output("Attributes:")
|
|
|
- attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
|
|
|
+ attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
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_t2s(dict_read(attr_list_pn, attr_key_pn))) + " = ") + cast_v2s(readAttribute(pn_model, read_elem, attr_key_pn)))
|
|
|
+ output(((((" " + attr_key_pn) + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
|
|
|
else:
|
|
|
output("Unknown element; aborting")
|
|
|
elif (cmd == "verify"):
|
|
|
- output(conformance_scd(pn_model))
|
|
|
+ output(conformance_scd(model))
|
|
|
elif (cmd == "types"):
|
|
|
Element keys_t
|
|
|
- keys_t = dict_keys(dict_read(dict_read(pn_model, "metamodel"), "model"))
|
|
|
+ keys_t = dict_keys(dict_read(dict_read(model, "metamodel"), "model"))
|
|
|
output("List of types:")
|
|
|
String v_t
|
|
|
while (read_nr_out(keys_t) > 0):
|
|
|
v_t = set_pop(keys_t)
|
|
|
if (bool_not(string_startswith(v_t, "__"))):
|
|
|
- output(string_join((" " + v_t) + " : ", getName(dict_read(dict_read(pn_model, "metamodel"), "metamodel"), dict_read_node(dict_read(dict_read(pn_model, "metamodel"), "type_mapping"), dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), v_t)))))
|
|
|
+ output(string_join((" " + v_t) + " : ", getName(dict_read(dict_read(model, "metamodel"), "metamodel"), dict_read_node(dict_read(dict_read(model, "metamodel"), "type_mapping"), dict_read(dict_read(dict_read(model, "metamodel"), "model"), v_t)))))
|
|
|
elif (cmd == "retype"):
|
|
|
output("Element to retype?")
|
|
|
String elementname
|
|
|
elementname = input()
|
|
|
- if (dict_in(dict_read(pn_model, "model"), elementname)):
|
|
|
+ if (dict_in(dict_read(model, "model"), elementname)):
|
|
|
output("New type")
|
|
|
typename = input()
|
|
|
- if (dict_in(dict_read(dict_read(pn_model, "metamodel"), "model"), typename)):
|
|
|
+ if (dict_in(dict_read(dict_read(model, "metamodel"), "model"), typename)):
|
|
|
// OK, do the retyping
|
|
|
// First try removing the previous type if it exists
|
|
|
- dict_delete(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), elementname))
|
|
|
+ dict_delete(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname))
|
|
|
// Now add the new type
|
|
|
- dict_add(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), elementname), dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), typename))
|
|
|
+ dict_add(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname), dict_read(dict_read(dict_read(model, "metamodel"), "model"), typename))
|
|
|
output("Retyped!")
|
|
|
else:
|
|
|
output("Unknown type; aborting")
|
|
@@ -449,15 +449,15 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
bottom = bool_not(bottom)
|
|
|
|
|
|
Element tmp_model
|
|
|
- tmp_model = pn_model
|
|
|
- pn_model = other_metamodel
|
|
|
+ tmp_model = model
|
|
|
+ model = other_metamodel
|
|
|
other_metamodel = tmp_model
|
|
|
|
|
|
if (bottom):
|
|
|
// The type mapping we are using is probably not complete for our model
|
|
|
// so we completely recreate it from the model we have.
|
|
|
output("Switching to conformance bottom mode!")
|
|
|
- generate_bottom_type_mapping(pn_model)
|
|
|
+ generate_bottom_type_mapping(model)
|
|
|
else:
|
|
|
// We already switched the models and such, so we are already done!
|
|
|
output("Switching to linguistic metamodel!")
|
|
@@ -465,7 +465,7 @@ Element function petrinet_loaded(pn_model : Element):
|
|
|
// A model-specific operation, so execute that one
|
|
|
Element specific_op
|
|
|
specific_op = dict_read(pn_operations(), cmd)
|
|
|
- specific_op(pn_model)
|
|
|
+ specific_op(model)
|
|
|
else:
|
|
|
output("Unknown command; aborting")
|
|
|
output("Use command 'help' to get a list of available commands")
|