de.cau.cs.kieler.sj
Class ValuedSignal

java.lang.Object
  extended by de.cau.cs.kieler.sj.Signal
      extended by de.cau.cs.kieler.sj.ValuedSignal

public class ValuedSignal
extends Signal

SJ realization of a valued signal.

Rating red

Field Summary
 
Fields inherited from class de.cau.cs.kieler.sj.Signal
ABSENT, hasStateChecked, index, lastSignalAssignments, present, PRESENT, program
 
Constructor Summary
ValuedSignal(String name)
          Creates a new valued signal with the given name.
ValuedSignal(String name, CombinationFunction combinationFuction)
          Creates a new valued signal with the given name an combination function for more than one value.
ValuedSignal(String name, CombinationFunction combinationFunction, int historyLength)
          Creates a new valued signal.
ValuedSignal(String name, int historyLength)
          Creates a new valued signal.
 
Method Summary
 void emit(Number val)
          Emits a signal with a given value.
 Number getValue()
          Returns the value of the valued signal.
 ValuedSignal pre()
          Returns the previous instance of a signal.
 void setStartValue(Number startVal)
          Sets the default value for the signal at the beginning of every new tick.
 void sustainCB(Number val)
          Sustain a signal using the given value.
 String toJSONString()
          The JSON representation of the ValuedSignal object.
 String toString()
          Return a sting representation of the this valued signal.
 
Methods inherited from class de.cau.cs.kieler.sj.Signal
emit, getName, isPresent, sustainCB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValuedSignal

public ValuedSignal(String name)
Creates a new valued signal with the given name.

Parameters:
name - The name for the valued signal.

ValuedSignal

public ValuedSignal(String name,
                    CombinationFunction combinationFuction)
Creates a new valued signal with the given name an combination function for more than one value.

Parameters:
name - The name for the valued signal.
combinationFuction - The combination function for the valued signal.

ValuedSignal

public ValuedSignal(String name,
                    int historyLength)
Creates a new valued signal.

Parameters:
name - The name for the valued signal.
historyLength - The history length of the valued signal.

ValuedSignal

public ValuedSignal(String name,
                    CombinationFunction combinationFunction,
                    int historyLength)
Creates a new valued signal.

Parameters:
name - The name for the signal.
combinationFunction - The combination function for the signal.
historyLength - The length of the signal history to log.
Method Detail

pre

public ValuedSignal pre()
Description copied from class: Signal
Returns the previous instance of a signal. In other words how it was at the last tick. To use this the historyLength must be greater than 0. The command s.pre().pre() is possible.

Overrides:
pre in class Signal
Returns:
The signal with the status from the last tick.
See Also:
Signal.Signal(String, int)

emit

public void emit(Number val)
Emits a signal with a given value. If the signal has already a value in this tick the new value for the signal will be calculated using the old signal value, the new signal value and the combination function of the signal.

Parameters:
val - The given value.
See Also:
Signal.emit()

sustainCB

public void sustainCB(Number val)
Sustain a signal using the given value.

Parameters:
val - The value.

getValue

public Number getValue()
Returns the value of the valued signal.

Returns:
The current value of the valued signal.

toJSONString

public String toJSONString()
The JSON representation of the ValuedSignal object. The value is null if he has not been set for the signal.

Overrides:
toJSONString in class Signal
Returns:
A string with the JSON representation of the valued signal.

toString

public String toString()
Return a sting representation of the this valued signal.

Overrides:
toString in class Signal
Returns:
A string representation of the valued signal

setStartValue

public void setStartValue(Number startVal)
Sets the default value for the signal at the beginning of every new tick.

Parameters:
startVal - The start value.