SOTIMERSENSOR(3iv)

πŸ’– SoTimerSensor β€” the sensor that just keeps going, and going, and going ✨

okay bestie, welcome to the SoTimerSensor page πŸ’… she's a real one, she shows up on schedule, every time, no cap.

🌸 INHERITS FROM 🌸

SoSensor > SoTimerQueueSensor > SoTimerSensor

so like, she's the grandbaby of the whole sensor bloodline, and she inherited all the family drama (and all the family methods, which we're listing below, don't worry 🫢).


✨ SYNOPSIS ✨

#include <Inventor/sensors/SoTimerSensor.h>

Methods from class SoTimerSensor:

              SoTimerSensor()
              SoTimerSensor(SoSensorCB *func, void *data)
              ~SoTimerSensor()
void          setBaseTime(const SbTime &base)
const SbTime &getBaseTime() const
void          setInterval(const SbTime &interval)
const SbTime &getInterval() const

Methods from class SoTimerQueueSensor:

const SbTime &getTriggerTime()
virtual void  schedule()
virtual void  unschedule()
virtual SbBool isScheduled()

Methods from class SoSensor:

void         setFunction(SoSensorCB *callbackFunction)
SoSensorCB * getFunction() const
void         setData(void *callbackData)
void *       getData() const

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so timer sensors trigger their callback function at regular intervals ⏰ like, that's the whole vibe. for example, a timer might be set up to call its callback function every second on the second by setting the base time to SbTime(0.0) and the interval to SbTime(1.0). iconic behaviour honestly.

now here's the part where you gotta pay attention bestie πŸ‘€ 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's busy doing something else, we've all been there πŸ’€) then the once-a-second sensor's callback will be called only once every 5 seconds. she's not gonna spam you, she respects your boundaries βœ‹

also note bestie: SoTimers always schedule themselves to be triggered the next even multiple of the interval time after the base time. so for example, if the once-a-second sensor is triggered at time 2.9 (because the application was 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. but if the base time was never set, the sensor would be scheduled for time 3.9. the way that difference matters 😭

πŸ’œ METHODS πŸ’œ

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

creation methods, bestie πŸŽ€ the second method takes the callback function and data to be called when the sensor is triggered. that's it, that's the whole thing.

  • ~SoTimerSensor()

destroys the sensor, freeing up any memory associated with it after unscheduling it. so she cleans up after herself, unlike some people πŸ™ˆ

  • void setBaseTime(const SbTime &base)
  • const SbTime &getBaseTime() const
  • void setInterval(const SbTime &interval)
  • const SbTime &getInterval() const

sets/gets the base time and the interval ✨ now for the defaults, because everyone asks: the default base time is the time when the sensor is scheduled or rescheduled, and the default interval is 1/30th of a second. periodt πŸ’…


🌈 SEE ALSO 🌈

SoOneShotSensor, SoAlarmSensor, SoTimerQueueSensor, SbTime

like, go read those too, they're all in the same friend group 🫢


and that's the whole page bestie!! this was SoTimerSensor(3IV) β€” the (3IV) being the manual section vibe and all that β€” so yeah, that's the source/version energy right there πŸ“šπŸ’– no cap, you're gonna slay with this sensor. go forth and schedule something iconic πŸ‘‘βœ¨