aivika-0.5.1: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellSafe-Inferred

Simulation.Aivika.Dynamics.Signal

Description

Tested with: GHC 7.4.1

This module defines the signal which we can subscribe handlers to. These handlers can be disposed. The signal is triggered in the current time point actuating the corresponded computations from the handlers.

Synopsis

Documentation

data Signal a Source

The signal that can have disposable handlers.

Instances

data SignalSource a Source

The signal source that can publish its signal.

newSignalSource :: EventQueue -> Simulation (SignalSource a)Source

Create a new signal source when the state depends on the event queue.

newSignalSourceWithUpdate :: Dynamics () -> Simulation (SignalSource a)Source

Create a new signal source with the specified update computation.

newSignalInTimes :: EventQueue -> [Double] -> Dynamics (Signal Double)Source

Return a signal that is triggered in the specified time points.

newSignalInIntegTimes :: EventQueue -> Dynamics (Signal Double)Source

Return a signal that is triggered in the integration time points. It should be called with help of runDynamicsInStartTime.

newSignalInStartTime :: EventQueue -> Dynamics (Signal Double)Source

Return a signal that is triggered in the start time. It should be called with help of runDynamicsInStartTime.

newSignalInStopTime :: EventQueue -> Dynamics (Signal Double)Source

Return a signal that is triggered in the stop time.

publishSignal :: SignalSource a -> Signal aSource

Publish the signal.

triggerSignal :: SignalSource a -> a -> Dynamics ()Source

Trigger the signal actuating all its handlers at the current simulation time point.

handleSignal :: Signal a -> (a -> Dynamics ()) -> Dynamics (Dynamics ())Source

Subscribe the handler to the specified signal and return a nested computation that, being applied, unsubscribes the handler from this signal.

handleSignal_ :: Signal a -> (a -> Dynamics ()) -> Dynamics ()Source

Subscribe the handler to the specified signal. To subscribe the disposable handlers, use function handleSignal.

updateSignal :: Signal a -> Dynamics ()Source

Update the signal to its actual state.

awaitSignal :: Signal a -> Process aSource

Await the signal.

mapSignal :: (a -> b) -> Signal a -> Signal bSource

Map the signal according the specified function.

mapSignalM :: (a -> Dynamics b) -> Signal a -> Signal bSource

Compose the signal.

apSignal :: Dynamics (a -> b) -> Signal a -> Signal bSource

Transform the signal.

filterSignal :: (a -> Bool) -> Signal a -> Signal aSource

Filter only those signal values that satisfy to the specified predicate.

filterSignalM :: (a -> Dynamics Bool) -> Signal a -> Signal aSource

Filter only those signal values that satisfy to the specified predicate.

emptySignal :: Signal aSource

An empty signal which is never triggered.

merge2Signals :: Signal a -> Signal a -> Signal aSource

Merge two signals.

merge3Signals :: Signal a -> Signal a -> Signal a -> Signal aSource

Merge three signals.

merge4Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal aSource

Merge four signals.

merge5Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a -> Signal aSource

Merge five signals.

data SignalHistory a Source

Represents the history of the signal values.

signalHistorySignal :: SignalHistory a -> Signal aSource

The signal for which the history is created.

newSignalHistory :: Signal a -> Dynamics (SignalHistory a)Source

Create a history of the signal values.

newSignalHistoryThrough :: EventQueue -> Signal a -> Dynamics (SignalHistory a)Source

Create a history of the signal values with delay through the event queue. The history will be created at the same simulation time, just the corresponded handler will be subscribed to the signal after the new event will be processed by the queue.

It is very useful if we want the signal won't be triggered at the current time until we complete some preparation. This is relatated to the fact that the signal is updated at time of subscribing the handler. So, if we subscribe to the signal which must be triggered at the current time then it will be triggered. Using the event queue allows us to complete some preparation logic before the signal will be triggered at the same simulation time point.

readSignalHistory :: SignalHistory a -> Dynamics (Array Int Double, Array Int a)Source

Read the history of signal values.