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