def test_petrinet(self): net = metamodel.load("petrinets.m2") modeldesc = str(net).split("\n") self.assertTrue(" Element Place" in modeldesc) self.assertTrue(" <attribute> name" in modeldesc) self.assertTrue(" OutputArc[] fromtransitions" in modeldesc) netin = net.instance().load("petrinet.m1") repr(netin) netin.identifiers = dict(root=netin.root()) repr(netin)
def test_mof(self): mof = metamodel.load("mof.m3") modeldesc = str(mof).split("\n") self.assertTrue(" Element extends (optional)" in modeldesc) self.assertTrue(" Element MetaModel" in modeldesc) self.assertTrue(" <attribute> limit" in modeldesc) net = mof.instance().load("petrinets.m2") repr(net) mofi = mof.instance().load("mof.m3") mofdesc = repr(mofi) mof2 = metamodel.MetaModel(mofdesc) mofi2 = mof2.instance().parse(mofdesc)
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv) == 1: sys.argv.append("-") if len(sys.argv) != 2 or not (sys.argv[1] == "-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("declare.m2") netin = net.instance().load(sys.argv[1]) M = type("DeclareModel", (), net.elements) @metamodel.TransformationRule def declare2graphviz(declare): global activitycount, relationcount, negatecount activitycount = 0 relationcount = 0 negatecount = 0 r = ["digraph {", "overlap=false;", "splines=true;", "model=mds;"] r.append("// Activities:") for activity in declare.init: activity2graphviz(activity, r)
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv) == 1: sys.argv.append("-") if len(sys.argv) != 2 or not (sys.argv[1] == "-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("petrinets.m2") netin = net.instance().load(sys.argv[1]) M = type("PetrinetsModel", (), net.elements) @metamodel.TransformationRule def petrinet2graphviz(petrinet): global elementcount elementcount = 0 r = ["digraph {", "overlap=false", "model=mds"] r.append("// Places:") for place in petrinet.places: element2graphviz(place, r, "circle") r.append("\n// Transitions:") for transition in petrinet.transitions:
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv)==1: sys.argv.append("-") if len(sys.argv)!=2 or not (sys.argv[1]=="-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("declare.m2") netin = net.instance().load(sys.argv[1]) M=type("DeclareModel", (), net.elements) @metamodel.TransformationRule def declare2graphviz(declare): global activitycount, relationcount, negatecount activitycount=0 relationcount=0 negatecount=0 r = ["digraph {", "overlap=false;", "splines=true;", "model=mds;"] r.append("// Activities:") for activity in declare.init: activity2graphviz(activity, r) for activity in declare.activities:
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv)==1: sys.argv.append("-") if len(sys.argv)!=2 or not (sys.argv[1]=="-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("petrinets.m2") netin = net.instance().load(sys.argv[1]) M=type("PetrinetsModel", (), net.elements) @metamodel.TransformationRule def petrinet2graphviz(petrinet): global elementcount elementcount=0 r = ["digraph {", "overlap=false", "model=mds"] r.append("// Places:") for place in petrinet.places: element2graphviz(place, r, "circle") r.append("\n// Transitions:") for transition in petrinet.transitions: element2graphviz(transition, r, "square")
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv)==1: sys.argv.append("-") if len(sys.argv)!=2 or not (sys.argv[1]=="-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("mof.m3") netin = net.instance().load(sys.argv[1]) @metamodel.TransformationRule def metamodel2graphviz(metamodel): global attributecount, associationcount attributecount=0 associationcount=0 r = ["digraph {", "overlap=false;", "splines=true;", "edge[fontsize=12, len=1];", "model=mds;"] r.append("// Elements:") for element in metamodel.elements: element2graphviz(element, r) r.append("\n// Associations:") for element in metamodel.elements: for a in element.childlist:
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import os if len(sys.argv) == 1: sys.argv.append("-") if len(sys.argv) != 2 or not (sys.argv[1] == "-" or os.path.isfile(sys.argv[1])): print("Usage: {0} [filename.m1|-]".format(sys.argv[0])) sys.exit(1) import metamodel net = metamodel.load("mof.m3") netin = net.instance().load(sys.argv[1]) @metamodel.TransformationRule def metamodel2graphviz(metamodel): global attributecount, associationcount attributecount = 0 associationcount = 0 r = [ "digraph {", "overlap=false;", "splines=true;", "edge[fontsize=12, len=1];", "model=mds;" ] r.append("// Elements:") for element in metamodel.elements: element2graphviz(element, r)