Stability | experimental |
---|---|
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Safe Haskell | Safe-Inferred |
Tested with: GHC 7.6.3
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.
Since version 0.6.1 its updateSignal
function calls runQueueSyncBefore
instead of runQueueSync
as it was before. In case of need you can
define your own update function with help of newSignalSourceWithUpdate
.
The function has the following defintion:
newSignalSource queue = newSignalSourceWithUpdate $ runQueueSyncBefore 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.
If the signal is bound up with the event queue then the signal in the current time is not lost by the handler any more. Changed in version 0.6.1.
handleSignal_ :: Signal a -> (a -> Dynamics ()) -> Dynamics ()Source
Subscribe the handler to the specified signal.
To subscribe the disposable handlers, use function handleSignal
.
If the signal is bound up with the event queue then the signal in the current time is not lost by the handler any more. Changed in version 0.6.1.
updateSignal :: Signal a -> Dynamics ()Source
Update the signal to its actual state.
You will rarely need to call this function directly as it is usually called implicitly.
Since version 0.6.1 it processes only those events
which time is less than the current simulation time
if the signal is bound up with the event queue,
although you can define your own updateSignal
function when creating a new signal source with help of
newSignalSourceWithUpdate
.
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.
Since version 0.6.1, this function has less meaning than before. Please use carefully as the behavior depends on the state of the event queue.
readSignalHistory :: SignalHistory a -> Dynamics (Array Int Double, Array Int a)Source
Read the history of signal values.