module Simulation.Aivika.Trans.GPSS.Block.Generate
(streamGeneratorBlock0,
streamGeneratorBlock,
streamGeneratorBlockM) where
import Simulation.Aivika.Trans
import Simulation.Aivika.Trans.GPSS.Block
import Simulation.Aivika.Trans.GPSS.Transact
streamGeneratorBlockM :: MonadDES m
=> Stream m (Arrival a)
-> Event m Int
-> GeneratorBlock m (Transact m 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 :: MonadDES m
=> Stream m (Arrival a)
-> Int
-> GeneratorBlock m (Transact m a)
streamGeneratorBlock s = streamGeneratorBlockM s . return
streamGeneratorBlock0 :: MonadDES m
=> Stream m (Arrival a)
-> GeneratorBlock m (Transact m a)
streamGeneratorBlock0 s = streamGeneratorBlock s 0