Example #1
0
 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)
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
    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)
Example #5
0
#    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)
Example #6
0
#    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:
Example #7
0
#
#    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:
Example #8
0
#
#    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")
Example #9
0
#
#    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:
Example #10
0
#    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)