csTimeSensor
123
Updating csTimeSensor
csTimeSensors are not automatically evaluated. The following method triggers the
evaluation of all instantiated csTimeSensors:
csTimeSensor::updateSensors();
This method should be called at regular intervals, usually once per frame, for
csTimeSensors to function as expected.
Updating with csWindow
By default, if there are instantiated csTimeSensors, csWindow calls
csTimeSensor::updateSensors() at regular intervals; the default interval is 16
milliseconds. The frequency of updates can be modified using the following method:
csWindow::enableTimer(float ms);
where the argument, ms, specifies the frequency of updates in milliseconds. This method
enables a timer event, which is fired every ms milliseconds. When the timer event is
handled csWindow calls csTimeSensor::updateSensors().
The timer event can be disabled by calling:
csWindow::disableTimer();
Note: The Optimizer class, opViewer, also calls csTimeSensor::updateSensors() by
default if there are instantiated time sensors. opViewer also contains the methods
enableTimer() and disableTimer() for enabling and disabling timer events.
Setting the Start and Stop Times
csTimeSensor::startTime() and csTimeSensor::stopTime() are csTime values
representing the times at which the csTimeSensor should start and stop generating time
sensor events.
If stopTime is less than startTime, the csTimeSensor generates events indefinitely, or
terminates at the end of one cycle if csTimeSensor:loop() is FALSE. For more information
about loop(), see “Continuing Timer Events” on page 125.