module Simulation.Aivika.GPSS.Block.Test
(awaitingTestBlock,
awaitingTestBlockM,
transferringTestBlock,
transferringTestBlockM) where
import Simulation.Aivika
import Simulation.Aivika.GPSS.Block
awaitingTestBlock :: (a -> Signalable Bool)
-> Block 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 :: (a -> Process (Signalable Bool))
-> Block 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 :: (a -> Bool)
-> Block a ()
-> Block a a
transferringTestBlock pred block =
Block { blockProcess = \a ->
do let f = pred a
if f
then return a
else transferProcess (blockProcess block a)
}
transferringTestBlockM :: (a -> Process Bool)
-> Block a ()
-> Block a a
transferringTestBlockM pred block =
Block { blockProcess = \a ->
do f <- pred a
if f
then return a
else transferProcess (blockProcess block a)
}