Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoTimerSensor Class Reference

Sensor that triggers repeatedly at regular intervals. More...

#include <Inventor/sensors/SoTimerSensor.h>

+ Inheritance diagram for SoTimerSensor:

Public Member Functions

 SoTimerSensor ()
 Default constructor.
 
 SoTimerSensor (SoSensorCB *func, void *data)
 Constructor that takes the function and data to be called when the sensor is triggered.
 
virtual ~SoTimerSensor ()
 Destroys the sensor, freeing up any memory associated with it after unscheduling it.
 
void setBaseTime (const SbTime &base)
 Sets the base time.
 
void setInterval (const SbTime &intvl)
 Sets the interval.
 
const SbTimegetBaseTime () const
 Gets the base time.
 
const SbTimegetInterval () const
 Gets the interval.
 
virtual void schedule ()
 Adds this sensor to the timer queue.
 
virtual void unschedule ()
 If this sensor is scheduled, removes it from the timer queue so that it will not be triggered.
 
- Public Member Functions inherited from SoTimerQueueSensor
 SoTimerQueueSensor ()
 Constructor.
 
 SoTimerQueueSensor (SoSensorCB *func, void *data)
 Constructor that takes standard callback function and data.
 
const SbTimegetTriggerTime () const
 Returns the time at which this sensor is scheduled to be triggered.
 
- Public Member Functions inherited from SoSensor
 SoSensor ()
 Constructor.
 
 SoSensor (SoSensorCB *f, void *d)
 Constructor that takes standard callback function and data.
 
void setFunction (SoSensorCB *f, void *userData)
 
void setFunction (SoSensorCB *f)
 Sets the callback function that is called when the sensor is triggered.
 
void setData (void *d)
 Sets the callback data passed to the callback function.
 
SoSensorCBgetFunction () const
 Returns the callback that will be called when the sensor is triggered.
 
void * getData () const
 Returns the user-supplied pointer that will be passed to the callback function.
 
virtual SbBool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in a sensor queue to be triggered.
 

Detailed Description

Sensor that triggers repeatedly at regular intervals.

Timer sensors trigger their function at regular intervals. A base time may be specified, which causes the sensor to be triggered at multiples of the interval starting from the base time. The base time is an absolute time, as returned by SbTime::getTimeOfDay(). For example, a timer might be set up to call its function every second on the second by setting the base time to SbTime (0.0) and the interval to SbTime (1.0) . Timers are guaranteed to be triggered only once when the timer queue is processed, so if the application only processes the timer queue once every 5 seconds (because it is busy doing something else) the once-a-second sensor's function will only be called once every 5 seconds.

If no base time is set, then the function will be rescheduled from the present time using the interval value.

When a base time has been specified, SoTimers always schedule themselves to be triggered the next multiple of the interval time after the base time. For example, if the once-a-second sensor is triggered at time 2.9 (because the application way busy doing something at time 2.0 and didn't get around to processing the sensor queue for a while) it will reschedule itself to go off at time 3.0, not at time 3.9. On the other hand, if the base time had never been set, then the sensor would be scheduled for time 3.9.

SEE ALSO

SoOneShotSensor, SoAlarmSensor, SoTimerQueueSensor, SbTime

Definition at line 91 of file SoTimerSensor.h.

Constructor & Destructor Documentation

◆ SoTimerSensor() [1/2]

SoTimerSensor::SoTimerSensor ( )

Default constructor.

◆ SoTimerSensor() [2/2]

SoTimerSensor::SoTimerSensor ( SoSensorCB func,
void *  data 
)

Constructor that takes the function and data to be called when the sensor is triggered.

◆ ~SoTimerSensor()

virtual SoTimerSensor::~SoTimerSensor ( )
virtual

Destroys the sensor, freeing up any memory associated with it after unscheduling it.

Member Function Documentation

◆ getBaseTime()

const SbTime & SoTimerSensor::getBaseTime ( ) const
inline

Gets the base time.

Definition at line 125 of file SoTimerSensor.h.

◆ getInterval()

const SbTime & SoTimerSensor::getInterval ( ) const
inline

Gets the interval.

Definition at line 129 of file SoTimerSensor.h.

◆ schedule()

virtual void SoTimerSensor::schedule ( )
virtual

Adds this sensor to the timer queue.

Subclasses provide methods for setting when the sensor will be triggered.

Reimplemented from SoTimerQueueSensor.

◆ setBaseTime()

void SoTimerSensor::setBaseTime ( const SbTime base)
inline

Sets the base time.

The default base time is the time when the sensor is scheduled or rescheduled.

Definition at line 115 of file SoTimerSensor.h.

◆ setInterval()

void SoTimerSensor::setInterval ( const SbTime intvl)
inline

Sets the interval.

The default interval is 1/30th of a second.

Definition at line 121 of file SoTimerSensor.h.

◆ unschedule()

virtual void SoTimerSensor::unschedule ( )
virtual

If this sensor is scheduled, removes it from the timer queue so that it will not be triggered.

Reimplemented from SoTimerQueueSensor.


The documentation for this class was generated from the following file: