Stability | experimental |
---|---|

Maintainer | David Sorokin <david.sorokin@gmail.com> |

Safe Haskell | None |

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.

- data Signal a
- data SignalSource a
- newSignalSource :: EventQueue -> Simulation (SignalSource a)
- newSignalSourceWithUpdate :: Dynamics () -> Simulation (SignalSource a)
- newSignalInTimes :: EventQueue -> [Double] -> Dynamics (Signal Double)
- newSignalInIntegTimes :: EventQueue -> Dynamics (Signal Double)
- newSignalInStartTime :: EventQueue -> Dynamics (Signal Double)
- newSignalInStopTime :: EventQueue -> Dynamics (Signal Double)
- publishSignal :: SignalSource a -> Signal a
- triggerSignal :: SignalSource a -> a -> Dynamics ()
- handleSignal :: Signal a -> (a -> Dynamics ()) -> Dynamics (Dynamics ())
- handleSignal_ :: Signal a -> (a -> Dynamics ()) -> Dynamics ()
- updateSignal :: Signal a -> Dynamics ()
- awaitSignal :: Signal a -> Process a
- mapSignal :: (a -> b) -> Signal a -> Signal b
- mapSignalM :: (a -> Dynamics b) -> Signal a -> Signal b
- apSignal :: Dynamics (a -> b) -> Signal a -> Signal b
- filterSignal :: (a -> Bool) -> Signal a -> Signal a
- filterSignalM :: (a -> Dynamics Bool) -> Signal a -> Signal a
- emptySignal :: Signal a
- merge2Signals :: Signal a -> Signal a -> Signal a
- merge3Signals :: Signal a -> Signal a -> Signal a -> Signal a
- merge4Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a
- merge5Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a -> Signal a
- data SignalHistory a
- signalHistorySignal :: SignalHistory a -> Signal a
- newSignalHistory :: Signal a -> Dynamics (SignalHistory a)
- newSignalHistoryThrough :: EventQueue -> Signal a -> Dynamics (SignalHistory a)
- readSignalHistory :: SignalHistory a -> Dynamics (Array Int Double, Array Int a)

# Documentation

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.

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

Compose 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.

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.