|
@@ -21,56 +21,56 @@ Element function create_metamodels():
|
|
instantiate_bottom_value(scd, "Type", Type)
|
|
instantiate_bottom_value(scd, "Type", Type)
|
|
instantiate_bottom_value(scd, "__String", String)
|
|
instantiate_bottom_value(scd, "__String", String)
|
|
instantiate_bottom_value(scd, "__name", "name")
|
|
instantiate_bottom_value(scd, "__name", "name")
|
|
- instantiate_bottom_edge(scd, "Attribute", dict_read(scd_model, "Class"), dict_read(scd_model, "Type"))
|
|
|
|
- instantiate_bottom_edge(scd, "__Name", dict_read(scd_model, "Attribute"), dict_read(scd_model, "__String"))
|
|
|
|
- instantiate_bottom_edge(scd, "Association", dict_read(scd_model, "Class"), dict_read(scd_model, "Class"))
|
|
|
|
- instantiate_bottom_edge(scd, "Inheritance", dict_read(scd_model, "Class"), dict_read(scd_model, "Class"))
|
|
|
|
- instantiate_bottom_edge(scd, "__name_edge", dict_read(scd_model, "__Name"), dict_read(scd_model, "__name"))
|
|
|
|
- instantiate_bottom_edge(scd, "__inh_1", dict_read(scd_model, "Association"), dict_read(scd_model, "Class"))
|
|
|
|
- instantiate_bottom_edge(scd, "__inh_2", dict_read(scd_model, "Attribute"), dict_read(scd_model, "Class"))
|
|
|
|
|
|
+ instantiate_bottom_edge(scd, "Attribute", scd_model["Class"], scd_model["Type"])
|
|
|
|
+ instantiate_bottom_edge(scd, "__Name", scd_model["Attribute"], scd_model["__String"])
|
|
|
|
+ instantiate_bottom_edge(scd, "Association", scd_model["Class"], scd_model["Class"])
|
|
|
|
+ instantiate_bottom_edge(scd, "Inheritance", scd_model["Class"], scd_model["Class"])
|
|
|
|
+ instantiate_bottom_edge(scd, "__name_edge", scd_model["__Name"], scd_model["__name"])
|
|
|
|
+ instantiate_bottom_edge(scd, "__inh_1", scd_model["Association"], scd_model["Class"])
|
|
|
|
+ instantiate_bottom_edge(scd, "__inh_2", scd_model["Attribute"], scd_model["Class"])
|
|
instantiate_bottom_value(scd, "__attribute", "attribute")
|
|
instantiate_bottom_value(scd, "__attribute", "attribute")
|
|
- instantiate_bottom_edge(scd, "__attribute_edge", dict_read(scd_model, "Attribute"), dict_read(scd_model, "__attribute"))
|
|
|
|
|
|
+ instantiate_bottom_edge(scd, "__attribute_edge", scd_model["Attribute"], scd_model["__attribute"])
|
|
|
|
|
|
// Instantiated, now retype to make sure that everything is correct
|
|
// Instantiated, now retype to make sure that everything is correct
|
|
Element mapping
|
|
Element mapping
|
|
mapping = create_node()
|
|
mapping = create_node()
|
|
- dict_add(mapping, dict_read(scd_model, "Class"), dict_read(scd_model, "Class"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "Type"), dict_read(scd_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__String"), dict_read(scd_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "Attribute"), dict_read(scd_model, "Attribute"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__Name"), dict_read(scd_model, "Attribute"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "Association"), dict_read(scd_model, "Association"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "Inheritance"), dict_read(scd_model, "Association"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__inh_1"), dict_read(scd_model, "Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__inh_2"), dict_read(scd_model, "Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__name"), dict_read(scd_model, "__String"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__name_edge"), dict_read(scd_model, "__Name"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__attribute"), dict_read(scd_model, "__String"))
|
|
|
|
- dict_add(mapping, dict_read(scd_model, "__attribute_edge"), dict_read(scd_model, "__Name"))
|
|
|
|
- retype(scd, scd, dict_read(scd_model, "Inheritance"), mapping)
|
|
|
|
|
|
+ dict_add(mapping, scd_model["Class"], scd_model["Class"])
|
|
|
|
+ dict_add(mapping, scd_model["Type"], scd_model["Type"])
|
|
|
|
+ dict_add(mapping, scd_model["__String"], scd_model["Type"])
|
|
|
|
+ dict_add(mapping, scd_model["Attribute"], scd_model["Attribute"])
|
|
|
|
+ dict_add(mapping, scd_model["__Name"], scd_model["Attribute"])
|
|
|
|
+ dict_add(mapping, scd_model["Association"], scd_model["Association"])
|
|
|
|
+ dict_add(mapping, scd_model["Inheritance"], scd_model["Association"])
|
|
|
|
+ dict_add(mapping, scd_model["__inh_1"], scd_model["Inheritance"])
|
|
|
|
+ dict_add(mapping, scd_model["__inh_2"], scd_model["Inheritance"])
|
|
|
|
+ dict_add(mapping, scd_model["__name"], scd_model["__String"])
|
|
|
|
+ dict_add(mapping, scd_model["__name_edge"], scd_model["__Name"])
|
|
|
|
+ dict_add(mapping, scd_model["__attribute"], scd_model["__String"])
|
|
|
|
+ dict_add(mapping, scd_model["__attribute_edge"], scd_model["__Name"])
|
|
|
|
+ retype(scd, scd, scd_model["Inheritance"], mapping)
|
|
export_node("models/SimpleClassDiagrams", scd)
|
|
export_node("models/SimpleClassDiagrams", scd)
|
|
|
|
|
|
// TODO this code is also very dirty as there is no nice "dictionary" and "list" syntax yet
|
|
// TODO this code is also very dirty as there is no nice "dictionary" and "list" syntax yet
|
|
Element modeletamodel
|
|
Element modeletamodel
|
|
- modeletamodel = instantiate_new_model(scd, dict_read(scd_model, "Inheritance"))
|
|
|
|
|
|
+ modeletamodel = instantiate_new_model(scd, scd_model["Inheritance"])
|
|
Element tokens
|
|
Element tokens
|
|
tokens = create_node()
|
|
tokens = create_node()
|
|
dict_add(tokens, "tokens", Integer)
|
|
dict_add(tokens, "tokens", Integer)
|
|
- 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())
|
|
|
|
|
|
+ instantiate_model_lib(modeletamodel, scd_model["Class"], "Place", create_node(), tokens, create_node())
|
|
|
|
+ instantiate_model_lib(modeletamodel, scd_model["Class"], "Transition", create_node(), create_node(), create_node())
|
|
Element weight
|
|
Element weight
|
|
weight = create_node()
|
|
weight = create_node()
|
|
dict_add(weight, "weight", Integer)
|
|
dict_add(weight, "weight", Integer)
|
|
Element p2t_links
|
|
Element p2t_links
|
|
p2t_links = create_node()
|
|
p2t_links = create_node()
|
|
- list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Place"))
|
|
|
|
- list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Transition"))
|
|
|
|
|
|
+ list_append(p2t_links, modeletamodel["model"]["Place"])
|
|
|
|
+ list_append(p2t_links, modeletamodel["model"]["Transition"])
|
|
Element t2p_links
|
|
Element t2p_links
|
|
t2p_links = create_node()
|
|
t2p_links = 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())
|
|
|
|
|
|
+ list_append(t2p_links, modeletamodel["model"]["Transition"])
|
|
|
|
+ list_append(t2p_links, modeletamodel["model"]["Place"])
|
|
|
|
+ instantiate_model_lib(modeletamodel, scd_model["Association"], "P2T", p2t_links, weight, create_node())
|
|
|
|
+ instantiate_model_lib(modeletamodel, scd_model["Association"], "T2P", t2p_links, weight, create_node())
|
|
|
|
|
|
set_model_constraints(modeletamodel, petrinet_constraints)
|
|
set_model_constraints(modeletamodel, petrinet_constraints)
|
|
export_node("models/PetriNets", modeletamodel)
|
|
export_node("models/PetriNets", modeletamodel)
|
|
@@ -88,35 +88,35 @@ Element function create_metamodels():
|
|
instantiate_bottom_value(mm_bottom, "Float", Float)
|
|
instantiate_bottom_value(mm_bottom, "Float", Float)
|
|
instantiate_bottom_value(mm_bottom, "String", String)
|
|
instantiate_bottom_value(mm_bottom, "String", String)
|
|
instantiate_bottom_value(mm_bottom, "Boolean", Boolean)
|
|
instantiate_bottom_value(mm_bottom, "Boolean", Boolean)
|
|
- instantiate_bottom_edge(mm_bottom, "Edge", dict_read(mm_bottom_model, "Node"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__Inheritance", dict_read(mm_bottom_model, "Node"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_1", dict_read(mm_bottom_model, "Type"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_2", dict_read(mm_bottom_model, "Integer"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_3", dict_read(mm_bottom_model, "Action"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_4", dict_read(mm_bottom_model, "Float"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_5", dict_read(mm_bottom_model, "String"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_6", dict_read(mm_bottom_model, "Boolean"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- instantiate_bottom_edge(mm_bottom, "__inh_7", dict_read(mm_bottom_model, "Edge"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "Edge", mm_bottom_model["Node"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__Inheritance", mm_bottom_model["Node"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_1", mm_bottom_model["Type"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_2", mm_bottom_model["Integer"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_3", mm_bottom_model["Action"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_4", mm_bottom_model["Float"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_5", mm_bottom_model["String"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_6", mm_bottom_model["Boolean"], mm_bottom_model["Node"])
|
|
|
|
+ instantiate_bottom_edge(mm_bottom, "__inh_7", mm_bottom_model["Edge"], mm_bottom_model["Node"])
|
|
|
|
|
|
// Retype it with itself
|
|
// Retype it with itself
|
|
mapping = create_node()
|
|
mapping = create_node()
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Node"), dict_read(mm_bottom_model, "Node"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Type"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Integer"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Float"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "String"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Boolean"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Action"), dict_read(mm_bottom_model, "Type"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "Edge"), dict_read(mm_bottom_model, "Edge"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__Inheritance"), dict_read(mm_bottom_model, "Edge"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_1"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_2"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_3"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_4"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_5"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_6"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- dict_add(mapping, dict_read(mm_bottom_model, "__inh_7"), dict_read(mm_bottom_model, "__Inheritance"))
|
|
|
|
- retype(mm_bottom, mm_bottom, dict_read(mm_bottom_model, "__Inheritance"), mapping)
|
|
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Node"], mm_bottom_model["Node"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Type"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Integer"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Float"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["String"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Boolean"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Action"], mm_bottom_model["Type"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["Edge"], mm_bottom_model["Edge"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__Inheritance"], mm_bottom_model["Edge"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_1"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_2"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_3"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_4"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_5"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_6"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ dict_add(mapping, mm_bottom_model["__inh_7"], mm_bottom_model["__Inheritance"])
|
|
|
|
+ retype(mm_bottom, mm_bottom, mm_bottom_model["__Inheritance"], mapping)
|
|
export_node("models/LTM_bottom", mm_bottom)
|
|
export_node("models/LTM_bottom", mm_bottom)
|
|
|
|
|
|
return dict_read(dict_read(read_root(), "__hierarchy"), "models")
|
|
return dict_read(dict_read(read_root(), "__hierarchy"), "models")
|
|
@@ -125,21 +125,21 @@ String function petrinet_constraints(model : Element):
|
|
// Check places to have positive number of tokens
|
|
// Check places to have positive number of tokens
|
|
Element all_elems
|
|
Element all_elems
|
|
Element elem_constraint
|
|
Element elem_constraint
|
|
- all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Place"))
|
|
|
|
|
|
+ all_elems = allInstances(model, model["metamodel"]["model"]["Place"])
|
|
while (0 < read_nr_out(all_elems)):
|
|
while (0 < read_nr_out(all_elems)):
|
|
elem_constraint = set_pop(all_elems)
|
|
elem_constraint = set_pop(all_elems)
|
|
if (integer_lt(readAttribute(model, elem_constraint, "tokens"), 0)):
|
|
if (integer_lt(readAttribute(model, elem_constraint, "tokens"), 0)):
|
|
return "Negative number of tokens in Place " + getName(model, elem_constraint)
|
|
return "Negative number of tokens in Place " + getName(model, elem_constraint)
|
|
|
|
|
|
// Check P2T transitions to have positive weight
|
|
// Check P2T transitions to have positive weight
|
|
- all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
|
|
|
+ all_elems = allInstances(model, model["metamodel"]["model"]["P2T"])
|
|
while (0 < read_nr_out(all_elems)):
|
|
while (0 < read_nr_out(all_elems)):
|
|
elem_constraint = set_pop(all_elems)
|
|
elem_constraint = set_pop(all_elems)
|
|
if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
return "Negative weight in arc " + getName(model, elem_constraint)
|
|
return "Negative weight in arc " + getName(model, elem_constraint)
|
|
|
|
|
|
// Check T2P transitions to have positive weight
|
|
// Check T2P transitions to have positive weight
|
|
- all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
|
|
|
|
|
|
+ all_elems = allInstances(model, model["metamodel"]["model"]["T2P"])
|
|
while (0 < read_nr_out(all_elems)):
|
|
while (0 < read_nr_out(all_elems)):
|
|
elem_constraint = set_pop(all_elems)
|
|
elem_constraint = set_pop(all_elems)
|
|
if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
@@ -164,7 +164,7 @@ Element function petrinet_enabled(model : Element):
|
|
|
|
|
|
Element function petrinet_enabled_set(model : Element):
|
|
Element function petrinet_enabled_set(model : Element):
|
|
Element all_transitions
|
|
Element all_transitions
|
|
- all_transitions = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Transition"))
|
|
|
|
|
|
+ all_transitions = allInstances(model, model["metamodel"]["model"]["Transition"])
|
|
|
|
|
|
Element enabled_transitions
|
|
Element enabled_transitions
|
|
enabled_transitions = create_node()
|
|
enabled_transitions = create_node()
|
|
@@ -178,7 +178,7 @@ Element function petrinet_enabled_set(model : Element):
|
|
enabled = True
|
|
enabled = True
|
|
|
|
|
|
// Find all incoming transitions
|
|
// Find all incoming transitions
|
|
- in_arcs = allIncomingAssociationInstances(model, under_study, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
|
|
|
+ in_arcs = allIncomingAssociationInstances(model, under_study, model["metamodel"]["model"]["P2T"])
|
|
|
|
|
|
while (0 < read_nr_out(in_arcs)):
|
|
while (0 < read_nr_out(in_arcs)):
|
|
arc_under_study = set_pop(in_arcs)
|
|
arc_under_study = set_pop(in_arcs)
|
|
@@ -200,15 +200,15 @@ Element function petrinet_fire(model : Element):
|
|
output("Transition to fire?")
|
|
output("Transition to fire?")
|
|
Element transition
|
|
Element transition
|
|
transition = input()
|
|
transition = input()
|
|
- if (dict_in(dict_read(model, "model"), transition)):
|
|
|
|
- transition = dict_read(dict_read(model, "model"), transition)
|
|
|
|
|
|
+ if (dict_in(model["model"], transition)):
|
|
|
|
+ transition = model["model"][transition]
|
|
if (set_in(petrinet_enabled_set(model), transition)):
|
|
if (set_in(petrinet_enabled_set(model), transition)):
|
|
Element workset
|
|
Element workset
|
|
Element working_place
|
|
Element working_place
|
|
Element working_arc
|
|
Element working_arc
|
|
|
|
|
|
// Consume tokens
|
|
// Consume tokens
|
|
- workset = allIncomingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
|
|
|
|
|
|
+ workset = allIncomingAssociationInstances(model, transition, model["metamodel"]["model"]["P2T"])
|
|
while (0 < read_nr_out(workset)):
|
|
while (0 < read_nr_out(workset)):
|
|
working_arc = set_pop(workset)
|
|
working_arc = set_pop(workset)
|
|
working_place = read_edge_src(working_arc)
|
|
working_place = read_edge_src(working_arc)
|
|
@@ -216,7 +216,7 @@ Element function petrinet_fire(model : Element):
|
|
output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
output(((" " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
|
|
|
|
|
|
// Add tokens
|
|
// Add tokens
|
|
- workset = allOutgoingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
|
|
|
|
|
|
+ workset = allOutgoingAssociationInstances(model, transition, model["metamodel"]["model"]["T2P"])
|
|
while (0 < read_nr_out(workset)):
|
|
while (0 < read_nr_out(workset)):
|
|
working_arc = set_pop(workset)
|
|
working_arc = set_pop(workset)
|
|
working_place = read_edge_dst(working_arc)
|
|
working_place = read_edge_dst(working_arc)
|
|
@@ -242,10 +242,10 @@ Element function petrinet_loaded(model : Element):
|
|
|
|
|
|
bottom = False
|
|
bottom = False
|
|
other_metamodel = create_node()
|
|
other_metamodel = create_node()
|
|
- dict_add(other_metamodel, "model", dict_read(model, "model"))
|
|
|
|
|
|
+ dict_add(other_metamodel, "model", model["model"])
|
|
dict_add(other_metamodel, "type_mapping", create_node())
|
|
dict_add(other_metamodel, "type_mapping", create_node())
|
|
dict_add(other_metamodel, "metamodel", import_node("models/LTM_bottom"))
|
|
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"))
|
|
|
|
|
|
+ dict_add(other_metamodel, "inheritance", other_metamodel["metamodel"]["model"]["__Inheritance"])
|
|
|
|
|
|
output("Model loaded, ready for commands!")
|
|
output("Model loaded, ready for commands!")
|
|
output("Use 'help' command for a list of possible commands")
|
|
output("Use 'help' command for a list of possible commands")
|
|
@@ -280,12 +280,12 @@ Element function petrinet_loaded(model : Element):
|
|
String mm_type_name
|
|
String mm_type_name
|
|
output("Type to instantiate?")
|
|
output("Type to instantiate?")
|
|
mm_type_name = input()
|
|
mm_type_name = input()
|
|
- 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)
|
|
|
|
|
|
+ if (dict_in(model["metamodel"]["model"], mm_type_name)):
|
|
|
|
+ metamodel_element_pn = model["metamodel"]["model"], mm_type_name)
|
|
String element_name
|
|
String element_name
|
|
output("Name of new element?")
|
|
output("Name of new element?")
|
|
element_name = input()
|
|
element_name = input()
|
|
- if (dict_in(dict_read(model, "model"), element_name)):
|
|
|
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
output("Element already exists; aborting")
|
|
output("Element already exists; aborting")
|
|
else:
|
|
else:
|
|
Boolean cnt
|
|
Boolean cnt
|
|
@@ -296,13 +296,13 @@ Element function petrinet_loaded(model : Element):
|
|
output("Source name?")
|
|
output("Source name?")
|
|
String src_name
|
|
String src_name
|
|
src_name = input()
|
|
src_name = input()
|
|
- if (dict_in(dict_read(model, "model"), src_name)):
|
|
|
|
- list_append(additional_opts, dict_read(dict_read(model, "model"), src_name))
|
|
|
|
|
|
+ if (dict_in(model["model"], src_name)):
|
|
|
|
+ list_append(additional_opts, model["model"][src_name])
|
|
output("Destination name?")
|
|
output("Destination name?")
|
|
String dst_name
|
|
String dst_name
|
|
dst_name = input()
|
|
dst_name = input()
|
|
- if (dict_in(dict_read(model, "model"), dst_name)):
|
|
|
|
- list_append(additional_opts, dict_read(dict_read(model, "model"), dst_name))
|
|
|
|
|
|
+ if (dict_in(model["model"], dst_name)):
|
|
|
|
+ list_append(additional_opts, model["model"][dst_name])
|
|
else:
|
|
else:
|
|
output("Unknown destination; aborting")
|
|
output("Unknown destination; aborting")
|
|
cnt = False
|
|
cnt = False
|
|
@@ -320,7 +320,7 @@ Element function petrinet_loaded(model : Element):
|
|
attrs = create_node()
|
|
attrs = create_node()
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
attr_key_pn = set_pop(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(((attr_key_pn + " : ") + cast_t2s(attr_list_pn[attr_key_pn])) + "?")
|
|
dict_add(attrs, attr_key_pn, input())
|
|
dict_add(attrs, attr_key_pn, input())
|
|
Element resulting_element
|
|
Element resulting_element
|
|
resulting_element = instantiate_model_lib(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)
|
|
@@ -330,24 +330,24 @@ Element function petrinet_loaded(model : Element):
|
|
elif (cmd == "delete"):
|
|
elif (cmd == "delete"):
|
|
output("What is the name of the element you want to delete?")
|
|
output("What is the name of the element you want to delete?")
|
|
cmd = input()
|
|
cmd = input()
|
|
- if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
|
- delete_element(dict_read(dict_read(model, "model"), cmd))
|
|
|
|
|
|
+ if (dict_in(model["model"], cmd)):
|
|
|
|
+ delete_element(model["model"][cmd])
|
|
output("Deleted!")
|
|
output("Deleted!")
|
|
else:
|
|
else:
|
|
output("No such element; aborting")
|
|
output("No such element; aborting")
|
|
elif (cmd == "modify"):
|
|
elif (cmd == "modify"):
|
|
output("Element to modify?")
|
|
output("Element to modify?")
|
|
cmd = input()
|
|
cmd = input()
|
|
- if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
|
|
|
+ if (dict_in(model["model"], cmd)):
|
|
Element mod
|
|
Element mod
|
|
- mod = dict_read(dict_read(model, "model"), cmd)
|
|
|
|
- metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), mod)
|
|
|
|
|
|
+ mod = model["model"][cmd]
|
|
|
|
+ metamodel_element_pn = dict_read_node(model["type_mapping"], mod)
|
|
|
|
|
|
attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
attr_key_pn = set_pop(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(((" " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn]))
|
|
|
|
|
|
output("Attribute to modify?")
|
|
output("Attribute to modify?")
|
|
String attr_name
|
|
String attr_name
|
|
@@ -364,39 +364,39 @@ Element function petrinet_loaded(model : Element):
|
|
output("Old name?")
|
|
output("Old name?")
|
|
String old_name_e
|
|
String old_name_e
|
|
old_name_e = input()
|
|
old_name_e = input()
|
|
- if (dict_in(dict_read(model, "model"), old_name_e)):
|
|
|
|
|
|
+ if (dict_in(model["model"], old_name_e)):
|
|
output("New name?")
|
|
output("New name?")
|
|
String new_name_e
|
|
String new_name_e
|
|
new_name_e = input()
|
|
new_name_e = input()
|
|
- if (dict_in(dict_read(model, "model"), new_name_e)):
|
|
|
|
|
|
+ if (dict_in(model["model"], new_name_e)):
|
|
output("New name already used; aborting")
|
|
output("New name already used; aborting")
|
|
else:
|
|
else:
|
|
- 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)
|
|
|
|
|
|
+ dict_add(model["model"], new_name_e, model["model"][old_name_e])
|
|
|
|
+ dict_delete(model["model"], old_name_e)
|
|
output("Rename complete!")
|
|
output("Rename complete!")
|
|
else:
|
|
else:
|
|
output("Unknown element; aborting")
|
|
output("Unknown element; aborting")
|
|
elif (cmd == "list"):
|
|
elif (cmd == "list"):
|
|
Element keys_m
|
|
Element keys_m
|
|
- keys_m = dict_keys(dict_read(model, "model"))
|
|
|
|
|
|
+ keys_m = dict_keys(model["model"])
|
|
output("List of all elements:")
|
|
output("List of all elements:")
|
|
String v_m
|
|
String v_m
|
|
while (read_nr_out(keys_m) > 0):
|
|
while (read_nr_out(keys_m) > 0):
|
|
v_m = set_pop(keys_m)
|
|
v_m = set_pop(keys_m)
|
|
// Filter out anonymous objects
|
|
// Filter out anonymous objects
|
|
- typename = getName(dict_read(model, "metamodel"), dict_read_node(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), v_m)))
|
|
|
|
|
|
+ typename = getName(model["metamodel"], dict_read_node(model["type_mapping"], model["model"][v_m]))
|
|
if (bool_not(string_startswith(v_m, "__"))):
|
|
if (bool_not(string_startswith(v_m, "__"))):
|
|
output(((" " + v_m) + " : ") + typename)
|
|
output(((" " + v_m) + " : ") + typename)
|
|
elif (cmd == "read"):
|
|
elif (cmd == "read"):
|
|
output("Element to read?")
|
|
output("Element to read?")
|
|
cmd = input()
|
|
cmd = input()
|
|
- if (dict_in(dict_read(model, "model"), cmd)):
|
|
|
|
|
|
+ if (dict_in(model["model"], cmd)):
|
|
Element read_elem
|
|
Element read_elem
|
|
- read_elem = dict_read(dict_read(model, "model"), cmd)
|
|
|
|
- metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), read_elem)
|
|
|
|
|
|
+ read_elem = model["model"][cmd]
|
|
|
|
+ metamodel_element_pn = dict_read_node(model["type_mapping"], read_elem)
|
|
|
|
|
|
output("Name: " + cmd)
|
|
output("Name: " + cmd)
|
|
- output("Type: " + getName(dict_read(model, "metamodel"), metamodel_element_pn))
|
|
|
|
|
|
+ output("Type: " + getName(model["metamodel"], metamodel_element_pn))
|
|
if (is_edge(read_elem)):
|
|
if (is_edge(read_elem)):
|
|
output("Source: " + getName(model, read_edge_src(read_elem)))
|
|
output("Source: " + getName(model, read_edge_src(read_elem)))
|
|
output("Destination: " + getName(model, read_edge_dst(read_elem)))
|
|
output("Destination: " + getName(model, read_edge_dst(read_elem)))
|
|
@@ -407,39 +407,39 @@ Element function petrinet_loaded(model : Element):
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
attr_key_pn = set_pop(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((((" " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn])))
|
|
output("Attributes:")
|
|
output("Attributes:")
|
|
attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
attr_key_pn = set_pop(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(model, read_elem, attr_key_pn)))
|
|
|
|
|
|
+ output(((((" " + attr_key_pn) + " : ") + cast_t2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
|
|
else:
|
|
else:
|
|
output("Unknown element; aborting")
|
|
output("Unknown element; aborting")
|
|
elif (cmd == "verify"):
|
|
elif (cmd == "verify"):
|
|
output(conformance_scd(model))
|
|
output(conformance_scd(model))
|
|
elif (cmd == "types"):
|
|
elif (cmd == "types"):
|
|
Element keys_t
|
|
Element keys_t
|
|
- keys_t = dict_keys(dict_read(dict_read(model, "metamodel"), "model"))
|
|
|
|
|
|
+ keys_t = dict_keys(model["metamodel"]["model"])
|
|
output("List of types:")
|
|
output("List of types:")
|
|
String v_t
|
|
String v_t
|
|
while (read_nr_out(keys_t) > 0):
|
|
while (read_nr_out(keys_t) > 0):
|
|
v_t = set_pop(keys_t)
|
|
v_t = set_pop(keys_t)
|
|
if (bool_not(string_startswith(v_t, "__"))):
|
|
if (bool_not(string_startswith(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)))))
|
|
|
|
|
|
+ output(string_join((" " + v_t) + " : ", getName(model["metamodel"]["metamodel"], dict_read_node(model["metamodel"]["type_mapping"], model["metamodel"]["model"][v_t]))))
|
|
elif (cmd == "retype"):
|
|
elif (cmd == "retype"):
|
|
output("Element to retype?")
|
|
output("Element to retype?")
|
|
String elementname
|
|
String elementname
|
|
elementname = input()
|
|
elementname = input()
|
|
- if (dict_in(dict_read(model, "model"), elementname)):
|
|
|
|
|
|
+ if (dict_in(model["model"], elementname)):
|
|
output("New type")
|
|
output("New type")
|
|
typename = input()
|
|
typename = input()
|
|
- if (dict_in(dict_read(dict_read(model, "metamodel"), "model"), typename)):
|
|
|
|
|
|
+ if (dict_in(model["metamodel"]["model"], typename)):
|
|
// OK, do the retyping
|
|
// OK, do the retyping
|
|
// First try removing the previous type if it exists
|
|
// First try removing the previous type if it exists
|
|
- dict_delete(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname))
|
|
|
|
|
|
+ dict_delete(model["type_mapping"], model["model"][elementname])
|
|
// Now add the new type
|
|
// Now add the new type
|
|
- dict_add(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname), dict_read(dict_read(dict_read(model, "metamodel"), "model"), typename))
|
|
|
|
|
|
+ dict_add(model["type_mapping"], model["model"][elementname], model["metamodel"]["model"][typename])
|
|
output("Retyped!")
|
|
output("Retyped!")
|
|
else:
|
|
else:
|
|
output("Unknown type; aborting")
|
|
output("Unknown type; aborting")
|
|
@@ -503,7 +503,7 @@ Element function initial_prompt():
|
|
if (dict_in(root, name)):
|
|
if (dict_in(root, name)):
|
|
output("Model exists; aborting")
|
|
output("Model exists; aborting")
|
|
else:
|
|
else:
|
|
- my_model = instantiate_new_model(dict_read(root, mm_name), create_node())
|
|
|
|
|
|
+ my_model = instantiate_new_model(root[mm_name], create_node())
|
|
dict_add(root, name, my_model)
|
|
dict_add(root, name, my_model)
|
|
petrinet_loaded(my_model)
|
|
petrinet_loaded(my_model)
|
|
else:
|
|
else:
|
|
@@ -512,7 +512,7 @@ Element function initial_prompt():
|
|
output("Model to load?")
|
|
output("Model to load?")
|
|
name = input()
|
|
name = input()
|
|
if (dict_in(root, name)):
|
|
if (dict_in(root, name)):
|
|
- my_model = dict_read(root, name)
|
|
|
|
|
|
+ my_model = root[name]
|
|
petrinet_loaded(my_model)
|
|
petrinet_loaded(my_model)
|
|
else:
|
|
else:
|
|
output("Model not found; aborting")
|
|
output("Model not found; aborting")
|
|
@@ -523,7 +523,7 @@ Element function initial_prompt():
|
|
output("Found models:")
|
|
output("Found models:")
|
|
while (read_nr_out(keys) > 0):
|
|
while (read_nr_out(keys) > 0):
|
|
m_menu_list = set_pop(keys)
|
|
m_menu_list = set_pop(keys)
|
|
- output(((" " + m_menu_list) + " : ") + reverseNameLookup(root, dict_read(dict_read(root, m_menu_list), "metamodel")))
|
|
|
|
|
|
+ output(((" " + m_menu_list) + " : ") + reverseNameLookup(root, root[m_menu_list]["metamodel"]))
|
|
elif (command == "delete"):
|
|
elif (command == "delete"):
|
|
output("Model to delete?")
|
|
output("Model to delete?")
|
|
name = input()
|
|
name = input()
|
|
@@ -543,7 +543,7 @@ Element function initial_prompt():
|
|
if (dict_in(root, new_name)):
|
|
if (dict_in(root, new_name)):
|
|
output("Model exists; aborting")
|
|
output("Model exists; aborting")
|
|
else:
|
|
else:
|
|
- dict_add(root, new_name, dict_read(root, old_name))
|
|
|
|
|
|
+ dict_add(root, new_name, root[old_name])
|
|
dict_delete(root, old_name)
|
|
dict_delete(root, old_name)
|
|
output("Rename complete!")
|
|
output("Rename complete!")
|
|
else:
|
|
else:
|