|
@@ -4,148 +4,7 @@ include "object_operations.alh"
|
|
|
include "library.alh"
|
|
|
include "conformance_scd.alh"
|
|
|
include "io.alh"
|
|
|
-
|
|
|
-Element function create_metamodels():
|
|
|
- // TODO
|
|
|
- // For the moment, we make the assumption that it doesn't exist yet.
|
|
|
- // We create both the Simple Class Diagrams model, retype it, and then make the metamodel as an instance of this
|
|
|
- // In the future, this should already exist though...
|
|
|
-
|
|
|
- if (bool_not(dict_in(dict_read(read_root(), "__hierarchy"), "models"))):
|
|
|
- Element scd
|
|
|
- Element scd_model
|
|
|
- scd = create_node()
|
|
|
- scd_model = create_node()
|
|
|
- dict_add(scd, "model", scd_model)
|
|
|
- instantiate_bottom_node(scd, "Class")
|
|
|
- instantiate_bottom_value(scd, "Type", Type)
|
|
|
- instantiate_bottom_value(scd, "__String", String)
|
|
|
- instantiate_bottom_value(scd, "__name", "name")
|
|
|
- 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_edge(scd, "__attribute_edge", scd_model["Attribute"], scd_model["__attribute"])
|
|
|
-
|
|
|
- // Instantiated, now retype to make sure that everything is correct
|
|
|
- Element mapping
|
|
|
- mapping = create_node()
|
|
|
- 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)
|
|
|
-
|
|
|
- // TODO this code is also very dirty as there is no nice "dictionary" and "list" syntax yet
|
|
|
- Element modeletamodel
|
|
|
- modeletamodel = instantiate_new_model(scd, scd_model["Inheritance"])
|
|
|
- Element tokens
|
|
|
- tokens = create_node()
|
|
|
- dict_add(tokens, "tokens", Integer)
|
|
|
- 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
|
|
|
- weight = create_node()
|
|
|
- dict_add(weight, "weight", Integer)
|
|
|
- Element p2t_links
|
|
|
- p2t_links = create_node()
|
|
|
- list_append(p2t_links, modeletamodel["model"]["Place"])
|
|
|
- list_append(p2t_links, modeletamodel["model"]["Transition"])
|
|
|
- Element t2p_links
|
|
|
- t2p_links = 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)
|
|
|
- export_node("models/PetriNets", modeletamodel)
|
|
|
-
|
|
|
- // Also create conformance bottom metamodel
|
|
|
- Element mm_bottom
|
|
|
- Element mm_bottom_model
|
|
|
- mm_bottom = create_node()
|
|
|
- mm_bottom_model = create_node()
|
|
|
- dict_add(mm_bottom, "model", mm_bottom_model)
|
|
|
- instantiate_bottom_node(mm_bottom, "Node")
|
|
|
- instantiate_bottom_value(mm_bottom, "Type", Type)
|
|
|
- instantiate_bottom_value(mm_bottom, "Integer", Integer)
|
|
|
- instantiate_bottom_value(mm_bottom, "Action", Action)
|
|
|
- instantiate_bottom_value(mm_bottom, "Float", Float)
|
|
|
- instantiate_bottom_value(mm_bottom, "String", String)
|
|
|
- instantiate_bottom_value(mm_bottom, "Boolean", Boolean)
|
|
|
- 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
|
|
|
- mapping = create_node()
|
|
|
- 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)
|
|
|
-
|
|
|
- return dict_read(dict_read(read_root(), "__hierarchy"), "models")
|
|
|
-
|
|
|
-String function petrinet_constraints(model : Element):
|
|
|
- // Check places to have positive number of tokens
|
|
|
- Element all_elems
|
|
|
- Element elem_constraint
|
|
|
- all_elems = allInstances(model, model["metamodel"]["model"]["Place"])
|
|
|
- while (0 < read_nr_out(all_elems)):
|
|
|
- elem_constraint = set_pop(all_elems)
|
|
|
- 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(model, model["metamodel"]["model"]["P2T"])
|
|
|
- while (0 < read_nr_out(all_elems)):
|
|
|
- elem_constraint = set_pop(all_elems)
|
|
|
- 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(model, model["metamodel"]["model"]["T2P"])
|
|
|
- while (0 < read_nr_out(all_elems)):
|
|
|
- elem_constraint = set_pop(all_elems)
|
|
|
- if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
|
|
|
- return "Negative weight in arc " + getName(model, elem_constraint)
|
|
|
-
|
|
|
- return "OK"
|
|
|
+include "metamodels.alh"
|
|
|
|
|
|
Element function pn_operations():
|
|
|
Element ops
|