projet-mini-genie-logiciel-.../eclipse-workspace/fr.n7.simplepdl2petrinet/SimplePDL2PetriNet.atl

97 lines
2.7 KiB
Plaintext
Raw Normal View History

2021-10-13 16:13:04 +00:00
module SimplePDL2PetriNet;
create OUT: petrinet from IN: simplepdl;
-- Obtenir le processus qui contient ce process element.
-- Remarque: Ce helper ne serait pas utile si une r<>f<EFBFBD>rence opposite
-- avait <20>t<EFBFBD> plac<61>e entre Process et ProcessElement
helper context simplepdl!ProcessElement
def: getProcess(): simplepdl!Process =
simplepdl!Process.allInstances()
->select(p | p.processElements->includes(self))
->asSequence()->first();
-- Traduire un Process en un PetriNet de m<>me nom
rule Process2PetriNet {
from p: simplepdl!Process
to pn: petrinet!Network (name <- p.name)
}
-- Traduire une WorkDefinition en un motif sur le r<>seau de Petri
rule WorkDefinition2PetriNet {
from wd: simplepdl!WorkDefinition
to
-- PLACES d'une WorkDefinition
2021-10-15 07:28:18 +00:00
p_idle: petrinet!Place(
name <- wd.name + '_idle',
tokens <- 1,
network <- wd.process),
p_running: petrinet!Place(
name <- wd.name + '_running',
tokens <- 1,
network <- wd.process),
p_started: petrinet!Place(
name <- wd.name + '_started',
tokens <- 1,
network <- wd.process),
p_finished: petrinet!Place(
name <- wd.name + '_finished',
tokens <- 1,
network <- wd.process),
-- TRANSITIONS d'une WorkDefinition
t_start: petrinet!Transition(
name <- wd.name + '_start',
weight <- 1,
network <- wd.process),
t_finish: petrinet!Transition(
name <- wd.name + '_finish',
weight <- 1,
network <- wd.process),
-- ARCS d'une WorkDefinition
a_idle2start: petrinet!Arc(
weight <- 1,
place <- p_idle,
transition <- t_start,
outgoing <- false),
a_start2running: petrinet!Arc(
weight <- 1,
place <- p_running,
transition <- t_start,
outgoing <- true),
a_start2started: petrinet!Arc(
weight <- 1,
place <- p_started,
transition <- t_start,
outgoing <- true),
a_running2finish: petrinet!Arc(
weight <- 1,
place <- p_running,
transition <- t_finish,
outgoing <- false),
a_finish2finished: petrinet!Arc(
weight <- 1,
place <- p_finished,
transition <- t_finish,
outgoing <- true)
2021-10-13 16:13:04 +00:00
}
2021-10-15 07:28:18 +00:00
-- Traduire une WorkSequence en un motif sur le r<>seau de Petri
rule WorkSequence2PetriNet {
from ws: simplepdl!WorkSequence
to
-- ARCS d'une WorkSequence
a_s2s: petrinet!Arc(
place <- ws.predecessor.name + '_started',
transition <- ws.successor.name + '_start'),
a_s2f: petrinet!Arc(
place <- ws.predecessor.name + '_started',
transition <- ws.successor.name + '_finish'),
a_f2s: petrinet!Arc(
place <- ws.predecessor.name + '_finished',
transition <- ws.successor.name + '_start'),
a_f2f: petrinet!Arc(
place <- ws.predecessor.name + '_finished',
transition <- ws.successor.name + '_fnish')
}