module Simulation.Aivika.GPSS.Block.Generate
(streamGeneratorBlock0,
streamGeneratorBlock,
streamGeneratorBlockM,
signalGeneratorBlock0,
signalGeneratorBlock,
signalGeneratorBlockM) where
import Simulation.Aivika
import Simulation.Aivika.GPSS.Block
import Simulation.Aivika.GPSS.Transact
streamGeneratorBlockM :: Stream (Arrival a)
-> Event Int
-> GeneratorBlock (Transact a)
streamGeneratorBlockM s priority =
let loop s block =
do (a, xs) <- runStream s
liftEvent $
do p <- priority
t <- liftSimulation $ newTransact a p
runProcess $
do takeTransact t
blockProcess block t
loop xs block
in GeneratorBlock (loop s)
streamGeneratorBlock :: Stream (Arrival a)
-> Int
-> GeneratorBlock (Transact a)
streamGeneratorBlock s = streamGeneratorBlockM s . return
streamGeneratorBlock0 :: Stream (Arrival a)
-> GeneratorBlock (Transact a)
streamGeneratorBlock0 s = streamGeneratorBlock s 0
signalGeneratorBlockM :: Signal (Arrival a)
-> Event Int
-> GeneratorBlock (Transact a)
signalGeneratorBlockM s priority =
let handle block a =
do p <- priority
t <- liftSimulation $ newTransact a p
runProcess $
do takeTransact t
blockProcess block t
in GeneratorBlock $ \block ->
do h <- liftEvent $
handleSignal s $
handle block
finallyProcess neverProcess
(liftEvent $ disposeEvent h)
signalGeneratorBlock :: Signal (Arrival a)
-> Int
-> GeneratorBlock (Transact a)
signalGeneratorBlock s = signalGeneratorBlockM s . return
signalGeneratorBlock0 :: Signal (Arrival a)
-> GeneratorBlock (Transact a)
signalGeneratorBlock0 s = signalGeneratorBlock s 0