aivika-realtime-0.3: Soft real-time simulation module for the Aivika library

CopyrightCopyright (c) 2016-2017 David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Simulation.Aivika.RealTime.RT

Contents

Description

Tested with: GHC 8.0.1

This module defines a soft real-time computation based on IO.

Synopsis

Soft real-time computation

data RT m a Source #

The soft real-time computation based on IO-derived computation m.

Instances

Monad m => Monad (RT m) Source # 

Methods

(>>=) :: RT m a -> (a -> RT m b) -> RT m b #

(>>) :: RT m a -> RT m b -> RT m b #

return :: a -> RT m a #

fail :: String -> RT m a #

Functor m => Functor (RT m) Source # 

Methods

fmap :: (a -> b) -> RT m a -> RT m b #

(<$) :: a -> RT m b -> RT m a #

Applicative m => Applicative (RT m) Source # 

Methods

pure :: a -> RT m a #

(<*>) :: RT m (a -> b) -> RT m a -> RT m b #

(*>) :: RT m a -> RT m b -> RT m b #

(<*) :: RT m a -> RT m b -> RT m a #

MonadException m => MonadException (RT m) Source # 

Methods

catchComp :: Exception e => RT m a -> (e -> RT m a) -> RT m a #

finallyComp :: RT m a -> RT m b -> RT m a #

throwComp :: Exception e => e -> RT m a #

MonadIO m => MonadIO (RT m) Source # 

Methods

liftIO :: IO a -> RT m a #

data Ref (RT m) # 
data Ref (RT m) = Ref {}
data Ref (RT m) # 
data Ref (RT m) = Ref {}
data EventQueue (RT m) # 
data Generator (RT m) # 
data StrategyQueue (RT m) SIRO # 
data StrategyQueue (RT m) StaticPriorities # 
data StrategyQueue (RT m) LCFS # 
data StrategyQueue (RT m) FCFS # 

data RTParams Source #

The parameters for the RT computation.

Constructors

RTParams 

Fields

data RTContext m Source #

The context of the RT computation.

data RTScaling Source #

How the modeling time is scaled to a real time.

Constructors

RTLinearScaling Double

one unit of modeling time interval matches the specified amount of real seconds

RTLogScaling Double

the logarithm of one unit of modeling time interval matches the specified amount of real seconds

RTScalingFunction (Double -> Double -> Double)

we explicitly define how many real seconds will we receive for the interval specified by the provided start time and current modeling time

runRT :: RT m a -> RTContext m -> m a Source #

Run the computation using the specified context.

defaultRTParams :: RTParams Source #

The default parameters for the RT computation, where one unit of modeling time matches one real second and the real time interval is specified with precision of one millisecond.

newRTContext :: RTParams -> IO (RTContext m) Source #

Create a new real-time computation context.

rtParams :: Monad m => RT m RTParams Source #

Return the parameters of the current computation.

rtScale Source #

Arguments

:: RTScaling

the scaling method

-> Double

the start modeling time

-> Double

the current modeling time

-> Double

the real time interval

Scale the modeling time to a real time.

Invoking actions within the simulation

applyEventRT :: MonadIO m => RTContext m -> Event (RT m) a -> m (Async a) Source #

Apply the Event computation within the soft real-time simulation with the specified context and return the result.

applyEventRT_ :: MonadIO m => RTContext m -> Event (RT m) () -> m () Source #

Apply the Event computation within the soft real-time simulation with the specified context.

enqueueEventRT :: MonadIO m => RTContext m -> Double -> Event (RT m) a -> m (Async a) Source #

Enqueue the Event computation within the soft real-time simulation with the specified context at the modeling time provided and then return the result.

enqueueEventRT_ :: MonadIO m => RTContext m -> Double -> Event (RT m) () -> m () Source #

Enqueue the Event computation within the soft real-time simulation with the specified context at the modeling time provided.

Orphan instances

(Monad m, MonadIO m, MonadException m) => EventIOQueueing (RT m) Source #

An implementation of the EventIOQueueing type class.

Methods

enqueueEventIO :: Double -> Event (RT m) () -> Event (RT m) () #

(Monad m, MonadIO m, MonadException m, MonadComp m) => MonadDES (RT m) Source #

An implementation of the MonadDES type class.