module Simulation.Aivika.Trans.Activity
(
Activity,
newActivity,
newStateActivity,
newPreemptibleActivity,
newPreemptibleStateActivity,
activityNet,
activityInitState,
activityState,
activityTotalUtilisationTime,
activityTotalIdleTime,
activityTotalPreemptionTime,
activityUtilisationTime,
activityIdleTime,
activityPreemptionTime,
activityUtilisationFactor,
activityIdleFactor,
activityPreemptionFactor,
resetActivity,
activitySummary,
activityStateChanged,
activityStateChanged_,
activityTotalUtilisationTimeChanged,
activityTotalUtilisationTimeChanged_,
activityTotalIdleTimeChanged,
activityTotalIdleTimeChanged_,
activityTotalPreemptionTimeChanged,
activityTotalPreemptionTimeChanged_,
activityUtilisationTimeChanged,
activityUtilisationTimeChanged_,
activityIdleTimeChanged,
activityIdleTimeChanged_,
activityPreemptionTimeChanged,
activityPreemptionTimeChanged_,
activityUtilisationFactorChanged,
activityUtilisationFactorChanged_,
activityIdleFactorChanged,
activityIdleFactorChanged_,
activityPreemptionFactorChanged,
activityPreemptionFactorChanged_,
activityUtilising,
activityUtilised,
activityPreemptionBeginning,
activityPreemptionEnding,
activityChanged_) where
import Data.Monoid
import Control.Monad
import Control.Monad.Trans
import Control.Arrow
import Simulation.Aivika.Trans.Ref.Base
import Simulation.Aivika.Trans.DES
import Simulation.Aivika.Trans.Parameter
import Simulation.Aivika.Trans.Simulation
import Simulation.Aivika.Trans.Dynamics
import Simulation.Aivika.Trans.Internal.Specs
import Simulation.Aivika.Trans.Internal.Event
import Simulation.Aivika.Trans.Signal
import Simulation.Aivika.Trans.Cont
import Simulation.Aivika.Trans.Process
import Simulation.Aivika.Trans.Net
import Simulation.Aivika.Trans.Server
import Simulation.Aivika.Trans.Statistics
data Activity m s a b =
Activity { Activity m s a b -> s
activityInitState :: s,
Activity m s a b -> Ref m s
activityStateRef :: Ref m s,
Activity m s a b -> s -> a -> Process m (s, b)
activityProcess :: s -> a -> Process m (s, b),
Activity m s a b -> Bool
activityProcessPreemptible :: Bool,
Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef :: Ref m Double,
Activity m s a b -> Ref m Double
activityTotalIdleTimeRef :: Ref m Double,
Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef :: Ref m Double,
Activity m s a b -> Ref m (SamplingStats Double)
activityUtilisationTimeRef :: Ref m (SamplingStats Double),
Activity m s a b -> Ref m (SamplingStats Double)
activityIdleTimeRef :: Ref m (SamplingStats Double),
Activity m s a b -> Ref m (SamplingStats Double)
activityPreemptionTimeRef :: Ref m (SamplingStats Double),
Activity m s a b -> SignalSource m a
activityUtilisingSource :: SignalSource m a,
Activity m s a b -> SignalSource m (a, b)
activityUtilisedSource :: SignalSource m (a, b),
Activity m s a b -> SignalSource m a
activityPreemptionBeginningSource :: SignalSource m a,
Activity m s a b -> SignalSource m a
activityPreemptionEndingSource :: SignalSource m a
}
newActivity :: MonadDES m
=> (a -> Process m b)
-> Simulation m (Activity m () a b)
{-# INLINABLE newActivity #-}
newActivity :: (a -> Process m b) -> Simulation m (Activity m () a b)
newActivity = Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
False
newStateActivity :: MonadDES m
=> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
{-# INLINABLE newStateActivity #-}
newStateActivity :: (s -> a -> Process m (s, b))
-> s -> Simulation m (Activity m s a b)
newStateActivity = Bool
-> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
forall (m :: * -> *) s a b.
MonadDES m =>
Bool
-> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
newPreemptibleStateActivity Bool
False
newPreemptibleActivity :: MonadDES m
=> Bool
-> (a -> Process m b)
-> Simulation m (Activity m () a b)
{-# INLINABLE newPreemptibleActivity #-}
newPreemptibleActivity :: Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible a -> Process m b
provide =
((() -> a -> Process m ((), b))
-> () -> Simulation m (Activity m () a b))
-> ()
-> (() -> a -> Process m ((), b))
-> Simulation m (Activity m () a b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Bool
-> (() -> a -> Process m ((), b))
-> ()
-> Simulation m (Activity m () a b)
forall (m :: * -> *) s a b.
MonadDES m =>
Bool
-> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
newPreemptibleStateActivity Bool
preemptible) () ((() -> a -> Process m ((), b))
-> Simulation m (Activity m () a b))
-> (() -> a -> Process m ((), b))
-> Simulation m (Activity m () a b)
forall a b. (a -> b) -> a -> b
$ \()
s a
a ->
do b
b <- a -> Process m b
provide a
a
((), b) -> Process m ((), b)
forall (m :: * -> *) a. Monad m => a -> m a
return (()
s, b
b)
newPreemptibleStateActivity :: MonadDES m
=> Bool
-> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
{-# INLINABLE newPreemptibleStateActivity #-}
newPreemptibleStateActivity :: Bool
-> (s -> a -> Process m (s, b))
-> s
-> Simulation m (Activity m s a b)
newPreemptibleStateActivity Bool
preemptible s -> a -> Process m (s, b)
provide s
state =
do Ref m s
r0 <- s -> Simulation m (Ref m s)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef s
state
Ref m Double
r1 <- Double -> Simulation m (Ref m Double)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Double
0
Ref m Double
r2 <- Double -> Simulation m (Ref m Double)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Double
0
Ref m Double
r3 <- Double -> Simulation m (Ref m Double)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Double
0
Ref m (SamplingStats Double)
r4 <- SamplingStats Double -> Simulation m (Ref m (SamplingStats Double))
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
Ref m (SamplingStats Double)
r5 <- SamplingStats Double -> Simulation m (Ref m (SamplingStats Double))
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
Ref m (SamplingStats Double)
r6 <- SamplingStats Double -> Simulation m (Ref m (SamplingStats Double))
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
SignalSource m a
s1 <- Simulation m (SignalSource m a)
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m (a, b)
s2 <- Simulation m (SignalSource m (a, b))
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s3 <- Simulation m (SignalSource m a)
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s4 <- Simulation m (SignalSource m a)
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
Activity m s a b -> Simulation m (Activity m s a b)
forall (m :: * -> *) a. Monad m => a -> m a
return Activity :: forall (m :: * -> *) s a b.
s
-> Ref m s
-> (s -> a -> Process m (s, b))
-> Bool
-> Ref m Double
-> Ref m Double
-> Ref m Double
-> Ref m (SamplingStats Double)
-> Ref m (SamplingStats Double)
-> Ref m (SamplingStats Double)
-> SignalSource m a
-> SignalSource m (a, b)
-> SignalSource m a
-> SignalSource m a
-> Activity m s a b
Activity { activityInitState :: s
activityInitState = s
state,
activityStateRef :: Ref m s
activityStateRef = Ref m s
r0,
activityProcess :: s -> a -> Process m (s, b)
activityProcess = s -> a -> Process m (s, b)
provide,
activityProcessPreemptible :: Bool
activityProcessPreemptible = Bool
preemptible,
activityTotalUtilisationTimeRef :: Ref m Double
activityTotalUtilisationTimeRef = Ref m Double
r1,
activityTotalIdleTimeRef :: Ref m Double
activityTotalIdleTimeRef = Ref m Double
r2,
activityTotalPreemptionTimeRef :: Ref m Double
activityTotalPreemptionTimeRef = Ref m Double
r3,
activityUtilisationTimeRef :: Ref m (SamplingStats Double)
activityUtilisationTimeRef = Ref m (SamplingStats Double)
r4,
activityIdleTimeRef :: Ref m (SamplingStats Double)
activityIdleTimeRef = Ref m (SamplingStats Double)
r5,
activityPreemptionTimeRef :: Ref m (SamplingStats Double)
activityPreemptionTimeRef = Ref m (SamplingStats Double)
r6,
activityUtilisingSource :: SignalSource m a
activityUtilisingSource = SignalSource m a
s1,
activityUtilisedSource :: SignalSource m (a, b)
activityUtilisedSource = SignalSource m (a, b)
s2,
activityPreemptionBeginningSource :: SignalSource m a
activityPreemptionBeginningSource = SignalSource m a
s3,
activityPreemptionEndingSource :: SignalSource m a
activityPreemptionEndingSource = SignalSource m a
s4 }
activityNet :: MonadDES m => Activity m s a b -> Net m a b
{-# INLINABLE activityNet #-}
activityNet :: Activity m s a b -> Net m a b
activityNet Activity m s a b
act = (a -> Process m (b, Net m a b)) -> Net m a b
forall (m :: * -> *) a b.
(a -> Process m (b, Net m a b)) -> Net m a b
Net ((a -> Process m (b, Net m a b)) -> Net m a b)
-> (a -> Process m (b, Net m a b)) -> Net m a b
forall a b. (a -> b) -> a -> b
$ s -> Maybe Double -> a -> Process m (b, Net m a b)
loop (Activity m s a b -> s
forall (m :: * -> *) s a b. Activity m s a b -> s
activityInitState Activity m s a b
act) Maybe Double
forall a. Maybe a
Nothing
where
loop :: s -> Maybe Double -> a -> Process m (b, Net m a b)
loop s
s Maybe Double
r a
a =
do Double
t0 <- Dynamics m Double -> Process m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
Event m () -> Process m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m () -> Process m ()) -> Event m () -> Process m ()
forall a b. (a -> b) -> a -> b
$
do case Maybe Double
r of
Maybe Double
Nothing -> () -> Event m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just Double
t' ->
do Ref m Double -> (Double -> Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t'))
Ref m (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityIdleTimeRef Activity m s a b
act) ((SamplingStats Double -> SamplingStats Double) -> Event m ())
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t')
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityUtilisingSource Activity m s a b
act) a
a
(s
s', b
b, Double
dt) <- if Activity m s a b -> Bool
forall (m :: * -> *) s a b. Activity m s a b -> Bool
activityProcessPreemptible Activity m s a b
act
then Activity m s a b -> s -> a -> Process m (s, b, Double)
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> s -> a -> Process m (s, b, Double)
activityProcessPreempting Activity m s a b
act s
s a
a
else do (s
s', b
b) <- Activity m s a b -> s -> a -> Process m (s, b)
forall (m :: * -> *) s a b.
Activity m s a b -> s -> a -> Process m (s, b)
activityProcess Activity m s a b
act s
s a
a
(s, b, Double) -> Process m (s, b, Double)
forall (m :: * -> *) a. Monad m => a -> m a
return (s
s', b
b, Double
0)
Double
t1 <- Dynamics m Double -> Process m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
Event m () -> Process m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m () -> Process m ()) -> Event m () -> Process m ()
forall a b. (a -> b) -> a -> b
$
do Ref m s -> s -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m s
forall (m :: * -> *) s a b. Activity m s a b -> Ref m s
activityStateRef Activity m s a b
act) (s -> Event m ()) -> s -> Event m ()
forall a b. (a -> b) -> a -> b
$! s
s'
Ref m Double -> (Double -> Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
dt))
Ref m (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityUtilisationTimeRef Activity m s a b
act) ((SamplingStats Double -> SamplingStats Double) -> Event m ())
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
dt)
SignalSource m (a, b) -> (a, b) -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Activity m s a b -> SignalSource m (a, b)
forall (m :: * -> *) s a b.
Activity m s a b -> SignalSource m (a, b)
activityUtilisedSource Activity m s a b
act) (a
a, b
b)
(b, Net m a b) -> Process m (b, Net m a b)
forall (m :: * -> *) a. Monad m => a -> m a
return (b
b, (a -> Process m (b, Net m a b)) -> Net m a b
forall (m :: * -> *) a b.
(a -> Process m (b, Net m a b)) -> Net m a b
Net ((a -> Process m (b, Net m a b)) -> Net m a b)
-> (a -> Process m (b, Net m a b)) -> Net m a b
forall a b. (a -> b) -> a -> b
$ s -> Maybe Double -> a -> Process m (b, Net m a b)
loop s
s' (Double -> Maybe Double
forall a. a -> Maybe a
Just Double
t1))
activityProcessPreempting :: MonadDES m => Activity m s a b -> s -> a -> Process m (s, b, Double)
{-# INLINABLE activityProcessPreempting #-}
activityProcessPreempting :: Activity m s a b -> s -> a -> Process m (s, b, Double)
activityProcessPreempting Activity m s a b
act s
s a
a =
do ProcessId m
pid <- Process m (ProcessId m)
forall (m :: * -> *). MonadDES m => Process m (ProcessId m)
processId
Double
t0 <- Dynamics m Double -> Process m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
Ref m Double
rs <- Simulation m (Ref m Double) -> Process m (Ref m Double)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Double) -> Process m (Ref m Double))
-> Simulation m (Ref m Double) -> Process m (Ref m Double)
forall a b. (a -> b) -> a -> b
$ Double -> Simulation m (Ref m Double)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Double
0
Ref m Double
r0 <- Simulation m (Ref m Double) -> Process m (Ref m Double)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Double) -> Process m (Ref m Double))
-> Simulation m (Ref m Double) -> Process m (Ref m Double)
forall a b. (a -> b) -> a -> b
$ Double -> Simulation m (Ref m Double)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Double
t0
DisposableEvent m
h1 <- Event m (DisposableEvent m) -> Process m (DisposableEvent m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m (DisposableEvent m) -> Process m (DisposableEvent m))
-> Event m (DisposableEvent m) -> Process m (DisposableEvent m)
forall a b. (a -> b) -> a -> b
$
Signal m () -> (() -> Event m ()) -> Event m (DisposableEvent m)
forall (m :: * -> *) a.
Signal m a -> (a -> Event m ()) -> Event m (DisposableEvent m)
handleSignal (ProcessId m -> Signal m ()
forall (m :: * -> *). MonadDES m => ProcessId m -> Signal m ()
processPreemptionBeginning ProcessId m
pid) ((() -> Event m ()) -> Event m (DisposableEvent m))
-> (() -> Event m ()) -> Event m (DisposableEvent m)
forall a b. (a -> b) -> a -> b
$ \() ->
do Double
t0 <- Dynamics m Double -> Event m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
Ref m Double -> Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef Ref m Double
r0 Double
t0
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityPreemptionBeginningSource Activity m s a b
act) a
a
DisposableEvent m
h2 <- Event m (DisposableEvent m) -> Process m (DisposableEvent m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m (DisposableEvent m) -> Process m (DisposableEvent m))
-> Event m (DisposableEvent m) -> Process m (DisposableEvent m)
forall a b. (a -> b) -> a -> b
$
Signal m () -> (() -> Event m ()) -> Event m (DisposableEvent m)
forall (m :: * -> *) a.
Signal m a -> (a -> Event m ()) -> Event m (DisposableEvent m)
handleSignal (ProcessId m -> Signal m ()
forall (m :: * -> *). MonadDES m => ProcessId m -> Signal m ()
processPreemptionEnding ProcessId m
pid) ((() -> Event m ()) -> Event m (DisposableEvent m))
-> (() -> Event m ()) -> Event m (DisposableEvent m)
forall a b. (a -> b) -> a -> b
$ \() ->
do Double
t0 <- Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef Ref m Double
r0
Double
t1 <- Dynamics m Double -> Event m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
let dt :: Double
dt = Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0
Ref m Double -> (Double -> Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef Ref m Double
rs (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
dt)
Ref m Double -> (Double -> Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
dt)
Ref m (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityPreemptionTimeRef Activity m s a b
act) ((SamplingStats Double -> SamplingStats Double) -> Event m ())
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats Double
dt
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityPreemptionEndingSource Activity m s a b
act) a
a
let m1 :: Process m (s, b, Double)
m1 =
do (s
s', b
b) <- Activity m s a b -> s -> a -> Process m (s, b)
forall (m :: * -> *) s a b.
Activity m s a b -> s -> a -> Process m (s, b)
activityProcess Activity m s a b
act s
s a
a
Double
dt <- Event m Double -> Process m Double
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m Double -> Process m Double)
-> Event m Double -> Process m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef Ref m Double
rs
(s, b, Double) -> Process m (s, b, Double)
forall (m :: * -> *) a. Monad m => a -> m a
return (s
s', b
b, Double
dt)
m2 :: Process m ()
m2 =
Event m () -> Process m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m () -> Process m ()) -> Event m () -> Process m ()
forall a b. (a -> b) -> a -> b
$
do DisposableEvent m -> Event m ()
forall (m :: * -> *). DisposableEvent m -> Event m ()
disposeEvent DisposableEvent m
h1
DisposableEvent m -> Event m ()
forall (m :: * -> *). DisposableEvent m -> Event m ()
disposeEvent DisposableEvent m
h2
Process m (s, b, Double)
-> Process m () -> Process m (s, b, Double)
forall (m :: * -> *) a b.
MonadDES m =>
Process m a -> Process m b -> Process m a
finallyProcess Process m (s, b, Double)
m1 Process m ()
m2
activityState :: MonadDES m => Activity m s a b -> Event m s
{-# INLINABLE activityState #-}
activityState :: Activity m s a b -> Event m s
activityState Activity m s a b
act =
(Point m -> m s) -> Event m s
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m s) -> Event m s) -> (Point m -> m s) -> Event m s
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m s -> m s
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m s -> m s) -> Event m s -> m s
forall a b. (a -> b) -> a -> b
$ Ref m s -> Event m s
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m s
forall (m :: * -> *) s a b. Activity m s a b -> Ref m s
activityStateRef Activity m s a b
act)
activityStateChanged :: MonadDES m => Activity m s a b -> Signal m s
{-# INLINABLE activityStateChanged #-}
activityStateChanged :: Activity m s a b -> Signal m s
activityStateChanged Activity m s a b
act =
(() -> Event m s) -> Signal m () -> Signal m s
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m s -> () -> Event m s
forall a b. a -> b -> a
const (Event m s -> () -> Event m s) -> Event m s -> () -> Event m s
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m s
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m s
activityState Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityStateChanged_ Activity m s a b
act)
activityStateChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityStateChanged_ #-}
activityStateChanged_ :: Activity m s a b -> Signal m ()
activityStateChanged_ Activity m s a b
act =
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act)
activityTotalUtilisationTime :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityTotalUtilisationTime #-}
activityTotalUtilisationTime :: Activity m s a b -> Event m Double
activityTotalUtilisationTime Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act)
activityTotalUtilisationTimeChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityTotalUtilisationTimeChanged #-}
activityTotalUtilisationTimeChanged :: Activity m s a b -> Signal m Double
activityTotalUtilisationTimeChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityTotalUtilisationTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityTotalUtilisationTimeChanged_ Activity m s a b
act)
activityTotalUtilisationTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityTotalUtilisationTimeChanged_ #-}
activityTotalUtilisationTimeChanged_ :: Activity m s a b -> Signal m ()
activityTotalUtilisationTimeChanged_ Activity m s a b
act =
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act)
activityTotalIdleTime :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityTotalIdleTime #-}
activityTotalIdleTime :: Activity m s a b -> Event m Double
activityTotalIdleTime Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act)
activityTotalIdleTimeChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityTotalIdleTimeChanged #-}
activityTotalIdleTimeChanged :: Activity m s a b -> Signal m Double
activityTotalIdleTimeChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityTotalIdleTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityTotalIdleTimeChanged_ Activity m s a b
act)
activityTotalIdleTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityTotalIdleTimeChanged_ #-}
activityTotalIdleTimeChanged_ :: Activity m s a b -> Signal m ()
activityTotalIdleTimeChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act)
activityTotalPreemptionTime :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityTotalPreemptionTime #-}
activityTotalPreemptionTime :: Activity m s a b -> Event m Double
activityTotalPreemptionTime Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act)
activityTotalPreemptionTimeChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityTotalPreemptionTimeChanged #-}
activityTotalPreemptionTimeChanged :: Activity m s a b -> Signal m Double
activityTotalPreemptionTimeChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityTotalPreemptionTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityTotalPreemptionTimeChanged_ Activity m s a b
act)
activityTotalPreemptionTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityTotalPreemptionTimeChanged_ #-}
activityTotalPreemptionTimeChanged_ :: Activity m s a b -> Signal m ()
activityTotalPreemptionTimeChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activityUtilisationTime :: MonadDES m => Activity m s a b -> Event m (SamplingStats Double)
{-# INLINABLE activityUtilisationTime #-}
activityUtilisationTime :: Activity m s a b -> Event m (SamplingStats Double)
activityUtilisationTime Activity m s a b
act =
(Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double))
-> (Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityUtilisationTimeRef Activity m s a b
act)
activityUtilisationTimeChanged :: MonadDES m => Activity m s a b -> Signal m (SamplingStats Double)
{-# INLINABLE activityUtilisationTimeChanged #-}
activityUtilisationTimeChanged :: Activity m s a b -> Signal m (SamplingStats Double)
activityUtilisationTimeChanged Activity m s a b
act =
(() -> Event m (SamplingStats Double))
-> Signal m () -> Signal m (SamplingStats Double)
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double)
forall a b. a -> b -> a
const (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double))
-> Event m (SamplingStats Double)
-> ()
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m (SamplingStats Double)
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m (SamplingStats Double)
activityUtilisationTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityUtilisationTimeChanged_ Activity m s a b
act)
activityUtilisationTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityUtilisationTimeChanged_ #-}
activityUtilisationTimeChanged_ :: Activity m s a b -> Signal m ()
activityUtilisationTimeChanged_ Activity m s a b
act =
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act)
activityIdleTime :: MonadDES m => Activity m s a b -> Event m (SamplingStats Double)
{-# INLINABLE activityIdleTime #-}
activityIdleTime :: Activity m s a b -> Event m (SamplingStats Double)
activityIdleTime Activity m s a b
act =
(Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double))
-> (Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityIdleTimeRef Activity m s a b
act)
activityIdleTimeChanged :: MonadDES m => Activity m s a b -> Signal m (SamplingStats Double)
{-# INLINABLE activityIdleTimeChanged #-}
activityIdleTimeChanged :: Activity m s a b -> Signal m (SamplingStats Double)
activityIdleTimeChanged Activity m s a b
act =
(() -> Event m (SamplingStats Double))
-> Signal m () -> Signal m (SamplingStats Double)
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double)
forall a b. a -> b -> a
const (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double))
-> Event m (SamplingStats Double)
-> ()
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m (SamplingStats Double)
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m (SamplingStats Double)
activityIdleTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityIdleTimeChanged_ Activity m s a b
act)
activityIdleTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityIdleTimeChanged_ #-}
activityIdleTimeChanged_ :: Activity m s a b -> Signal m ()
activityIdleTimeChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act)
activityPreemptionTime :: MonadDES m => Activity m s a b -> Event m (SamplingStats Double)
{-# INLINABLE activityPreemptionTime #-}
activityPreemptionTime :: Activity m s a b -> Event m (SamplingStats Double)
activityPreemptionTime Activity m s a b
act =
(Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double))
-> (Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityPreemptionTimeRef Activity m s a b
act)
activityPreemptionTimeChanged :: MonadDES m => Activity m s a b -> Signal m (SamplingStats Double)
{-# INLINABLE activityPreemptionTimeChanged #-}
activityPreemptionTimeChanged :: Activity m s a b -> Signal m (SamplingStats Double)
activityPreemptionTimeChanged Activity m s a b
act =
(() -> Event m (SamplingStats Double))
-> Signal m () -> Signal m (SamplingStats Double)
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double)
forall a b. a -> b -> a
const (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double))
-> Event m (SamplingStats Double)
-> ()
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m (SamplingStats Double)
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m (SamplingStats Double)
activityPreemptionTime Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityPreemptionTimeChanged_ Activity m s a b
act)
activityPreemptionTimeChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityPreemptionTimeChanged_ #-}
activityPreemptionTimeChanged_ :: Activity m s a b -> Signal m ()
activityPreemptionTimeChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activityUtilisationFactor :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityUtilisationFactor #-}
activityUtilisationFactor :: Activity m s a b -> Event m Double
activityUtilisationFactor Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Double
x1 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act)
Double
x2 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act)
Double
x3 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act)
Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x1 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3))
activityUtilisationFactorChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityUtilisationFactorChanged #-}
activityUtilisationFactorChanged :: Activity m s a b -> Signal m Double
activityUtilisationFactorChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityUtilisationFactor Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityUtilisationFactorChanged_ Activity m s a b
act)
activityUtilisationFactorChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityUtilisationFactorChanged_ #-}
activityUtilisationFactorChanged_ :: Activity m s a b -> Signal m ()
activityUtilisationFactorChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activityIdleFactor :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityIdleFactor #-}
activityIdleFactor :: Activity m s a b -> Event m Double
activityIdleFactor Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Double
x1 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act)
Double
x2 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act)
Double
x3 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act)
Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3))
activityIdleFactorChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityIdleFactorChanged #-}
activityIdleFactorChanged :: Activity m s a b -> Signal m Double
activityIdleFactorChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityIdleFactor Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityIdleFactorChanged_ Activity m s a b
act)
activityIdleFactorChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityIdleFactorChanged_ #-}
activityIdleFactorChanged_ :: Activity m s a b -> Signal m ()
activityIdleFactorChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activityPreemptionFactor :: MonadDES m => Activity m s a b -> Event m Double
{-# INLINABLE activityPreemptionFactor #-}
activityPreemptionFactor :: Activity m s a b -> Event m Double
activityPreemptionFactor Activity m s a b
act =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Double
x1 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act)
Double
x2 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act)
Double
x3 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act)
Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x3 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3))
activityPreemptionFactorChanged :: MonadDES m => Activity m s a b -> Signal m Double
{-# INLINABLE activityPreemptionFactorChanged #-}
activityPreemptionFactorChanged :: Activity m s a b -> Signal m Double
activityPreemptionFactorChanged Activity m s a b
act =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Activity m s a b -> Event m Double
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Event m Double
activityPreemptionFactor Activity m s a b
act) (Activity m s a b -> Signal m ()
forall (m :: * -> *) s a b.
MonadDES m =>
Activity m s a b -> Signal m ()
activityPreemptionFactorChanged_ Activity m s a b
act)
activityPreemptionFactorChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityPreemptionFactorChanged_ #-}
activityPreemptionFactorChanged_ :: Activity m s a b -> Signal m ()
activityPreemptionFactorChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activityUtilising :: Activity m s a b -> Signal m a
{-# INLINABLE activityUtilising #-}
activityUtilising :: Activity m s a b -> Signal m a
activityUtilising = SignalSource m a -> Signal m a
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (SignalSource m a -> Signal m a)
-> (Activity m s a b -> SignalSource m a)
-> Activity m s a b
-> Signal m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityUtilisingSource
activityUtilised :: Activity m s a b -> Signal m (a, b)
{-# INLINABLE activityUtilised #-}
activityUtilised :: Activity m s a b -> Signal m (a, b)
activityUtilised = SignalSource m (a, b) -> Signal m (a, b)
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (SignalSource m (a, b) -> Signal m (a, b))
-> (Activity m s a b -> SignalSource m (a, b))
-> Activity m s a b
-> Signal m (a, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Activity m s a b -> SignalSource m (a, b)
forall (m :: * -> *) s a b.
Activity m s a b -> SignalSource m (a, b)
activityUtilisedSource
activityPreemptionBeginning :: Activity m s a b -> Signal m a
{-# INLINABLE activityPreemptionBeginning #-}
activityPreemptionBeginning :: Activity m s a b -> Signal m a
activityPreemptionBeginning = SignalSource m a -> Signal m a
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (SignalSource m a -> Signal m a)
-> (Activity m s a b -> SignalSource m a)
-> Activity m s a b
-> Signal m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityPreemptionBeginningSource
activityPreemptionEnding :: Activity m s a b -> Signal m a
{-# INLINABLE activityPreemptionEnding #-}
activityPreemptionEnding :: Activity m s a b -> Signal m a
activityPreemptionEnding = SignalSource m a -> Signal m a
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (SignalSource m a -> Signal m a)
-> (Activity m s a b -> SignalSource m a)
-> Activity m s a b
-> Signal m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Activity m s a b -> SignalSource m a
forall (m :: * -> *) s a b. Activity m s a b -> SignalSource m a
activityPreemptionEndingSource
activityChanged_ :: MonadDES m => Activity m s a b -> Signal m ()
{-# INLINABLE activityChanged_ #-}
activityChanged_ :: Activity m s a b -> Signal m ()
activityChanged_ Activity m s a b
act =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityUtilising Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal m (a, b) -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m (a, b)
forall (m :: * -> *) s a b. Activity m s a b -> Signal m (a, b)
activityUtilised Activity m s a b
act) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Activity m s a b -> Signal m a
forall (m :: * -> *) s a b. Activity m s a b -> Signal m a
activityPreemptionEnding Activity m s a b
act)
activitySummary :: MonadDES m => Activity m s a b -> Int -> Event m ShowS
{-# INLINABLE activitySummary #-}
activitySummary :: Activity m s a b -> Int -> Event m ShowS
activitySummary Activity m s a b
act Int
indent =
(Point m -> m ShowS) -> Event m ShowS
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m ShowS) -> Event m ShowS)
-> (Point m -> m ShowS) -> Event m ShowS
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Double
tx1 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act)
Double
tx2 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act)
Double
tx3 <- Point m -> Event m Double -> m Double
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Double -> m Double) -> Event m Double -> m Double
forall a b. (a -> b) -> a -> b
$ Ref m Double -> Event m Double
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act)
let xf1 :: Double
xf1 = Double
tx1 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3)
xf2 :: Double
xf2 = Double
tx2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3)
xf3 :: Double
xf3 = Double
tx3 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3)
SamplingStats Double
xs1 <- Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityUtilisationTimeRef Activity m s a b
act)
SamplingStats Double
xs2 <- Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityIdleTimeRef Activity m s a b
act)
SamplingStats Double
xs3 <- Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityPreemptionTimeRef Activity m s a b
act)
let tab :: [Char]
tab = Int -> Char -> [Char]
forall a. Int -> a -> [a]
replicate Int
indent Char
' '
ShowS -> m ShowS
forall (m :: * -> *) a. Monad m => a -> m a
return (ShowS -> m ShowS) -> ShowS -> m ShowS
forall a b. (a -> b) -> a -> b
$
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total utilisation time = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total idle time = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx2 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total preemption time = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx3 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"utilisation factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"idle factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf2 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"preemption factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf3 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"utilisation time (locked while awaiting the input):\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs1 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"idle time:\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs2 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"preemption time:\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs3 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent)
resetActivity :: MonadDES m => Activity m s a b -> Event m ()
{-# INLINABLE resetActivity #-}
resetActivity :: Activity m s a b -> Event m ()
resetActivity Activity m s a b
act =
do Ref m Double -> Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalUtilisationTimeRef Activity m s a b
act) Double
0
Ref m Double -> Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalIdleTimeRef Activity m s a b
act) Double
0
Ref m Double -> Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m Double
forall (m :: * -> *) s a b. Activity m s a b -> Ref m Double
activityTotalPreemptionTimeRef Activity m s a b
act) Double
0
Ref m (SamplingStats Double) -> SamplingStats Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityUtilisationTimeRef Activity m s a b
act) SamplingStats Double
forall a. Monoid a => a
mempty
Ref m (SamplingStats Double) -> SamplingStats Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityIdleTimeRef Activity m s a b
act) SamplingStats Double
forall a. Monoid a => a
mempty
Ref m (SamplingStats Double) -> SamplingStats Double -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Activity m s a b -> Ref m (SamplingStats Double)
forall (m :: * -> *) s a b.
Activity m s a b -> Ref m (SamplingStats Double)
activityPreemptionTimeRef Activity m s a b
act) SamplingStats Double
forall a. Monoid a => a
mempty