Update of /cvsroot/pymerase/smw/smw/sart/metamodel In directory sc8-pr-cvs1:/tmp/cvs-serv32238/smw/sart/metamodel Added Files: SART.py SARTModel.smw SARTModel.xml SARTtemplate.py __init__.py makefile Log Message: Imported version of SMW downloaded on 2003 Apr 14 --- NEW FILE: SART.py --- from __future__ import nested_scopes import copy from smw.metamodel.MetaMM import * MMFullName='SART 0.1' MMVersion='0.1' MMName='SART' class PromptKind(MMEnumeration): pk_enable=0 pk_trigger=1 description=[u'enable/disable', u'trigger'] class FlowKind(MMEnumeration): fk_discrete=0 fk_continous=1 description=[u'discrete', u'continous'] [...1089 lines suppressed...] 'flow': (MMClass.kind__Association,ControlFlow,0,'event',0,0), 'state': (MMClass.kind__Association,State,0,'deferrableEvent',0,0), 'store': (MMClass.kind__Association,ControlStore,0,'contents',0,0), 'name': (MMClass.kind__Attribute,Name,1,None,None,0), 'presentation': (MMClass.kind__Composition,PresentationElement,0,'subject',0,0), 'comment': (MMClass.kind__Association,Comment,0,'element',0,0), 'constraint': (MMClass.kind__Association,Constraint,0,'constrainedElement',0,0), 'namespace': (MMClass.kind__Association,Namespace,1,'ownedElement',0,0) } Association.__subclasses__=[Flow, DataFlow, ControlFlow, PromptFlow] Association.__mm__={ 'connection': (MMClass.kind__Composition,AssociationEnd,0,'association',1,0), 'name': (MMClass.kind__Attribute,Name,1,None,None,0), 'presentation': (MMClass.kind__Composition,PresentationElement,0,'subject',0,0), 'comment': (MMClass.kind__Association,Comment,0,'element',0,0), 'constraint': (MMClass.kind__Association,Constraint,0,'constrainedElement',0,0), 'namespace': (MMClass.kind__Association,Namespace,1,'ownedElement',0,0) } --- NEW FILE: SARTModel.smw --- SMW_MODEL METAMODEL smw.metamodel.UML14 PROFILE UML14 (ismw.metamodel.UML14 Model p1 (dp2 S'isAbstract' p3 I0 sS'isSpecification' p4 I0 sS'__uniqueID__' p5 S'DCE:D712E5F8-CF96-11D6-B84D-0004768CE271' p6 sS'modulestring' p7 [...49415 lines suppressed...] (ismw.metamodel.MetaMM MMAssociationEnd p9242 (dp9243 g16 (I3 g79 I0 g80 I0 I0 tp9244 sg20 g76 sg21 g1 sg22 (lp9245 g5869 asbsb. --- NEW FILE: SARTModel.xml --- <?xml version='1.0' encoding='ISO-8859-15'?> <XMI xmi.version='1.1' timestamp='Wed, 06 Nov 2002 10:20:54 +0200'> <XMI.header> <XMI.metamodel xmi.name="UML" xmi.version='1.4'/> </XMI.header> <XMI.content> <UML:Model xmi.id='DCE:D712E5F8-CF96-11D6-B84D-0004768CE271' xmi.uuid='DCE:D712E5F8-CF96-11D6-B84D-0004768CE271' isAbstract="false" isSpecification="false" visibility="public" isLeaf="false" isRoot="false" name="UntitledModel"> <UML:Namespace.ownedElement> <UML:Package xmi.id='DCE:DCA5B0AC-CF96-11D6-B84D-0004768CE271' xmi.uuid='DCE:DCA5B0AC-CF96-11D6-B84D-0004768CE271' isAbstract="false" isSpecification="false" namespace="DCE:D712E5F8-CF96-11D6-B84D-0004768CE271" visibility="public" isLeaf="false" isRoot="false" name="Core"> <UML:Namespace.ownedElement> <UML:Class xmi.id='DCE:0ECB98DA-CF97-11D6-B84D-0004768CE271' xmi.uuid='DCE:0ECB98DA-CF97-11D6-B84D-0004768CE271' isAbstract="true" isSpecification="false" isRoot="false" visibility="public" name="Element" namespace="DCE:DCA5B0AC-CF96-11D6-B84D-0004768CE271" isActive="false" isLeaf="false"> <UML:GeneralizableElement.specialization> <UML:Generalization xmi.idref='DCE:0CCFE8A0-CF98-11D6-B84D-0004768CE271'/> <UML:Generalization xmi.idref='DCE:E255E66A-CFA6-11D6-B84D-0004768CE271'/> <UML:Generalization xmi.idref='DCE:E28CC630-CFA6-11D6-B84D-0004768CE271'/> <UML:Generalization xmi.idref='DCE:E28E9262-CFA6-11D6-B84D-0004768CE271'/> <UML:Generalization xmi.idref='DCE:1D17591E-CFA7-11D6-B84D-0004768CE271'/> </UML:GeneralizableElement.specialization> </UML:Class> [...1533 lines suppressed...] <UML:Generalization xmi.id='DCE:4B284A3A-CFA6-11D6-B84D-0004768CE271' xmi.uuid='DCE:4B284A3A-CFA6-11D6-B84D-0004768CE271' isSpecification="false" child="DCE:61B9BD6C-CFA4-11D6-B84D-0004768CE271" visibility="public" discriminator="" parent="DCE:1009873E-CF97-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:0FC1C2E8-E64C-11D6-868C-0004768CE271' xmi.uuid='DCE:0FC1C2E8-E64C-11D6-868C-0004768CE271' isSpecification="false" child="DCE:6742C36E-E5AC-11D6-868C-0004768CE271" visibility="public" discriminator="" parent="DCE:5E362900-CFA4-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:4CE3555E-CFA6-11D6-B84D-0004768CE271' xmi.uuid='DCE:4CE3555E-CFA6-11D6-B84D-0004768CE271' isSpecification="false" child="DCE:60D01556-CFA4-11D6-B84D-0004768CE271" visibility="public" discriminator="" parent="DCE:1009873E-CF97-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:E255E66A-CFA6-11D6-B84D-0004768CE271' xmi.uuid='DCE:E255E66A-CFA6-11D6-B84D-0004768CE271' isSpecification="false" child="DCE:A208AA98-CFA6-11D6-B84D-0004768CE271" visibility="public" discriminator="" parent="DCE:0ECB98DA-CF97-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:181D8640-E64C-11D6-868C-0004768CE271' xmi.uuid='DCE:181D8640-E64C-11D6-868C-0004768CE271' isSpecification="false" child="DCE:79338BC6-E5AC-11D6-868C-0004768CE271" visibility="public" discriminator="" parent="DCE:03C2BA06-E5AC-11D6-868C-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:89BEA7F2-EE33-11D6-9845-0004768CE271' xmi.uuid='DCE:89BEA7F2-EE33-11D6-9845-0004768CE271' isSpecification="false" child="DCE:11545844-CF97-11D6-B84D-0004768CE271" visibility="public" discriminator="" parent="DCE:1009873E-CF97-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:E28CC630-CFA6-11D6-B84D-0004768CE271' xmi.uuid='DCE:E28CC630-CFA6-11D6-B84D-0004768CE271' isSpecification="false" child="DCE:A208AA98-CFA6-11D6-B84D-0004768CE271" visibility="public" discriminator="" parent="DCE:0ECB98DA-CF97-11D6-B84D-0004768CE271" name=""> </UML:Generalization> <UML:Generalization xmi.id='DCE:187D57EE-E64C-11D6-868C-0004768CE271' xmi.uuid='DCE:187D57EE-E64C-11D6-868C-0004768CE271' isSpecification="false" child="DCE:79338BC6-E5AC-11D6-868C-0004768CE271" visibility="public" discriminator="" parent="DCE:03C2BA06-E5AC-11D6-868C-0004768CE271" name=""> </UML:Generalization> </UML:Namespace.ownedElement> </UML:Model> </XMI.content> </XMI> --- NEW FILE: SARTtemplate.py --- class FlowKind(MMEnumeration): fk_discrete=0 fk_continous=1 description=[u'discrete', u'continous'] class PromptKind(MMEnumeration): pk_enable=0 pk_trigger=1 description=[u'enable/disable', u'trigger'] class Transition: def getDescription(self): text='' if self.trigger: text=self.trigger.name if self.guard: text=text+'['+self.guard.guardExpression.body+']' if self.effect: text=text+'/'+self.effect.effect.body return text class Constraint: def wfrConstraint1(self): "A Constraint cannot be applied to itself" return not(self.constrainedElement.includes(self)) class Classifier: def getOutgoingAssociationEnds(self): "Returns the outgoing associationEnds from a Classifier" return (self.association.select(lambda ae: not (ae.isNavigable))) def getIncomingAssociationEnds(self): "Returns the outgoing associationEnds from a Classifier" return (self.association.select(lambda ae: ae.isNavigable)) def getAssociations(self): "Returns all associations connected to a Classifier" myAss=MMSet() for x in self.association: myAss.insert(x.association) return myAss def getConnectedClassifiers(self): "Returns all other classifiers connected to this classifier through Flows" myAss=self.getAssociations() connected=MMSet() for x in myAss: for y in x.connection: if not (y.participant == self): connected.insert(y.participant) return connected class AssociationEnd: def wfrAssociationEnd1(self): "AssociationEnds are unnamed" return (self.name=="") class Flow: def isRefinementFlow(self, refinedElement): "Returns true if the flow connects a refined element and its refiner" for x in self.connection: if refinedElement.includedElements.includes(x.participant): return 1 return 0 def wfrFlow1(self): "Flows may not have the same source and target elements" return (self.connection.forAll( lambda ae1,ae2: implies((ae1.participant==ae2.participant), ae1==ae2))) def wfrFlow2(self): "Flows connected to Stores are unnamed" return (self.connection.forAll(lambda a: implies(isinstance(a.participant,Store)), a.participant.name=="")) class FlowModifier: def existsConnectedDataFlows(self): "Returns true if there are DataFlows connected to this FlowModifier" ownAss = MMSet() for x in self.association: if x.association.oclIsKindOf(DataFlow): ownAss.insert(x.association) return (ownAss.size()>0) def existsConnectedControlFlows(self): "Returns true if there are ControlFlows connected to this FlowModifier" ownAss = MMSet() for x in self.association: if x.association.oclIsKindOf(ControlFlow): ownAss.insert(x.association) return (ownAss.size()>0) def existsConnectedPromptFlows(self): "Returns true if there are PromptFlows connected to this FlowModifier" ownAss = MMSet() for x in self.association: if x.association.oclIsKindOf(PromptFlow): ownAss.insert(x.association) return (ownAss.size()>0) def wfrModifier1(self): "A FlowModifier can only have one kind of Flows connected to itself" ownAss = MMSet() for x in self.association: ownAss.insert(x.association) return (ownAss.forAll(lambda a: a.oclIsKindOf(DataFlow)) or ownAss.forAll(lambda a: a.oclIsKindOf(ControlFlow)) or ownAss.forAll(lambda a: a.oclIsKindOf(PromptFlow))) def wfrModifier2(self): "A FlowModifier can only have discrete or continous Flows connected to itself" ownAss = MMSet() for x in self.association: ownAss.insert(x.association) return (ownAss.forAll(lambda a: a.type==FlowKind.fk_discrete) or ownAss.forAll(lambda a: a.type==FlowKind.fk_continous)) class Split: def wfrSplit1(self): "A Split has exactly one incoming and at least two outgoing AssociationEnds" return ((self.getIncomingAssociationEnds().size()==1) and (self.getOutgoingAssociationEnds().size()>=2)) class CloneSplit: def wfrCloneSplit1(self): "Outgoing flows from a Clonesplits are unnamed" return((self.getOutgoingAssociationEnds(). forAll(lambda a: a.association.name==""))) class Join: def wfrJoin1(self): "A Join has at least two incoming and exactly one outgoing AssociationEnd" return ((self.getIncomingAssociationEnds().size()>=2) and (self.getOutgoingAssociationEnds().size()==1)) class OrJoin: def wfrOrJoin1(self): "Incoming flows to an OrJoin are unnamed" return((self.getIncomingAssociationEnds(). forAll(lambda a: a.association.name==""))) class Transformation: def wfrTransformation1(self): "All Transformations must have both incoming and outgoing Flows" return (self.getIncomingAssociationEnds().size()>0 and self.getOutgoingAssociationEnds().size()>0) class ControlTransformation: def wfrControlTransformation1(self): "A ControlTransformation can have only ControlFlows as inputs and outputs" return (self.association.forAll( lambda ae: ae.association.oclIsKindOf(ControlFlow))) class ExternalEntity: def wfrExternalEntity1(self): "An ExternalEntity may only be connected to top-level DataTransformations" return(self.getConnectedClassifiers(). forAll(lambda c: c.oclIsKindOf(DataTransformation) and c.namespace.oclIsKindOf(Model))) class DataTransformation: def wfrDataTransformation1(self): "A non-abstract DataTransformation can have only DataFlows or PromptFlows as inputs" if (self.includedElements.size()>0): return True else: return(self.getIncomingAssociationEnds().forAll( lambda ae: (ae.association.oclIsKindOf(DataFlow)) or ae.association.oclIsKindOf(PromptFlow))) class Store: def wfrStore1(self): "A Store may only be connected to a Transformation" return(self.getConnectedClassifiers().forAll (lambda c: c.oclIsKindOf(Transformation))) class DataStore: def wfrDataStore1(self): "A DataStore may only be connected to DataFlows" return(self.association.forAll( lambda ae: ae.association.oclIsKindOf(DataFlow))) class ControlStore: def wfrControlStore1(self): "A ControlStore may only be connected to ControlFlows" return(self.association.forAll( lambda ae: ae.association.oclIsKindOf(ControlFlow))) class PromptFlow: def wfrPromptFlow1(self): "A PromptFlow may contain either one event named 'trigger' or two events named 'enable' and 'disable'" return((self.event.size()==1 and self.event.includes(lambda a: a.name=="trigger")) or (self.event.size()==2 and self.event.includes(lambda a: a.name=="enable") and self.event.includes(lambda a: a.name=="disable"))) def wfrPromptFlow2(self): "A PromptFlow must be discrete" return (self.type==FlowKind.fk_discrete) def wfrPromptFlow3(self): "All PromptFlows are unidirectional" return (self.connection.forAll( lambda ae1,ae2: implies((ae1.isNavigable == ae2.isNavigable),ae1==ae2))) class CompositeState: def wfrCompositeState1(self): "A composite state can have at most one initial vertex" return self.subvertex.select( lambda v: v.oclIsKindOf(Pseudostate) and v.kind== PseudostateKind.pk_initial).size() <=1 def wfrCompositeState2(self): "A composite state can have at most one deep history vertex" return self.subvertex.select( lambda v: v.oclIsKindOf(Pseudostate) and v.kind== PseudostateKind.pk_deepHistory).size() <=1 def wfrCompositeState3(self): "A composite state can have at most one shallow history vertex" return self.subvertex.select( lambda v: v.oclIsKindOf(Pseudostate) and v.kind== PseudostateKind.pk_shallowHistory).size() <=1 def wfrCompositeState4(self): "There have to be at least two composite substates in a concurrent composite state" return implies(self.isConcurrent, self.subvertex.select(lambda v: v.oclIsKindOf(CompositeState)).size()>=2) def wfrCompositeState5(self): "A concurrent state can only have composite states as substates" return implies(self.isConcurrent, self.subvertex.forAll(lambda s: s.oclIsKindOf(CompositeState))) def wfrCompositeState6(self): "The substates of a composite state are part of only that composite state" return self.subvertex.forAll(lambda s: s.container.asSet().size()==1 and s.container == self) class FinalState: def wfrFinalState1(self): "A final state cannot have any outgoing transitions" return self.outgoing.size()==0 class Pseudostate: def wfrPseudostate1(self): "An initial vertex can have at most one outgoing transition and no incoming transitions" return implies(self.kind == PseudostateKind.pk_initial, self.outgoing.size()<=1 and self.incoming.isEmpty()) def wftPseudostate2(self): "History vertices can have at most one outgoing transition" return implies(self.kind == PseudostateKind.pk_deepHistory or self.kind== PseudostateKind.pk_shallowHistory, self.outgoing.size()<=1) --- NEW FILE: __init__.py --- """ SMW The System Modeling Workbench Copyright 2001,2002 by Ivan Porres ip...@ab... The System Modeling Workbench is a collection of tools for modeling software systems. From the programmer's point of view, each supported modeling language is represented by a metamodel module. A metamodel module contains a Python class for each model element. These classes have the same attributes and associations with the same name as in the metamodel of the modeling language. Since the model elements are represented as Python classes, we create a models by instantiating new objects and manipulating its associations. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. """ --- NEW FILE: makefile --- SART.py: SARTModel.xml ../../mmgen/mmgen.py python2 ../../mmgen/mmgen.py --uml SARTModel.xml SART.py SART 0.1 SARTtemplate.py |