module Simulation.Aivika.Trans.GPSS.Block.Test
(awaitingTestBlock,
awaitingTestBlockM,
transferringTestBlock,
transferringTestBlockM) where
import Simulation.Aivika.Trans
import Simulation.Aivika.Trans.GPSS.Block
awaitingTestBlock :: MonadDES m
=> (a -> Signalable m Bool)
-> Block m a a
awaitingTestBlock f =
Block { blockProcess = \a ->
do let s = f a
loop =
do f <- liftEvent $ readSignalable s
if f
then return ()
else do processAwait $ signalableChanged_ s
loop
loop
return a
}
awaitingTestBlockM :: MonadDES m
=> (a -> Process m (Signalable m Bool))
-> Block m a a
awaitingTestBlockM f =
Block { blockProcess = \a ->
do s <- f a
let loop =
do f <- liftEvent $ readSignalable s
if f
then return ()
else do processAwait $ signalableChanged_ s
loop
loop
return a
}
transferringTestBlock :: MonadDES m
=> (a -> Bool)
-> Block m a ()
-> Block m a a
transferringTestBlock pred block =
Block { blockProcess = \a ->
do let f = pred a
if f
then return a
else transferProcess (blockProcess block a)
}
transferringTestBlockM :: MonadDES m
=> (a -> Process m Bool)
-> Block m a ()
-> Block m a a
transferringTestBlockM pred block =
Block { blockProcess = \a ->
do f <- pred a
if f
then return a
else transferProcess (blockProcess block a)
}