44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
[comment encoding = UTF-8 /]
|
|
[module PetriNet2TINA('http://petrinet')]
|
|
|
|
[template public networkToTINA(aNetwork : Network)]
|
|
[comment @main/]
|
|
[file (aNetwork.name + '.net', false, 'UTF-8')]
|
|
net [aNetwork.name/]
|
|
[let places : OrderedSet(Place) = aNetwork.getPlaces() ]
|
|
[if (places->size() > 0)]
|
|
[for (place : Place | places)]
|
|
pl [place.name/] ([place.tokens/])
|
|
[/for]
|
|
[else]
|
|
[/if]
|
|
[/let]
|
|
[let transitions : OrderedSet(Transition) = aNetwork.getTransitions() ]
|
|
[if (transitions->size() > 0)]
|
|
[for (transition : Transition | transitions)]
|
|
[transition.afficher()/]
|
|
[/for]
|
|
[else]
|
|
[/if]
|
|
[/let]
|
|
[/file]
|
|
[/template]
|
|
|
|
[query public getPlaces(n: Network) : OrderedSet(Place) =
|
|
n.nodes
|
|
->select( e | e.oclIsTypeOf(Place) )
|
|
->collect( e | e.oclAsType(Place) )
|
|
->asOrderedSet()
|
|
/]
|
|
|
|
[query public getTransitions(n: Network) : OrderedSet(Transition) =
|
|
n.nodes
|
|
->select( e | e.oclIsTypeOf(Transition) )
|
|
->collect( e | e.oclAsType(Transition) )
|
|
->asOrderedSet()
|
|
/]
|
|
|
|
[template public afficher(t : Transition) post (trim()) ]
|
|
[comment][let outgoing = t.getArcs()->select( e | e.isOutgoing() ) /][/comment]
|
|
tr [t.name/] [for (a : Arc | t.arcs)][if (not a.outgoing)][a.place.name/]*[a.weight/] [/if][/for]-> [for (a : Arc | t.arcs)][if (a.outgoing)][a.place.name/]*[a.weight/] [/if][/for]
|
|
[/template] |