module Simulation.Aivika.GPSS.Block.Generate
(streamGeneratorBlock0,
streamGeneratorBlock,
streamGeneratorBlockM) 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