![]() |
http://www.sim.no http://www.coin3d.org |
Timer sensors triggers upon specific points in time. More...
#include <Inventor/sensors/SoTimerQueueSensor.h>
Public Member Functions | |
SoTimerQueueSensor (void) | |
SoTimerQueueSensor (SoSensorCB *func, void *data) | |
virtual | ~SoTimerQueueSensor (void) |
const SbTime & | getTriggerTime (void) const |
virtual void | schedule (void) |
virtual void | unschedule (void) |
virtual SbBool | isScheduled (void) const |
virtual void | trigger (void) |
Protected Member Functions | |
void | setTriggerTime (const SbTime &time) |
Protected Attributes | |
SbBool | scheduled |
Timer sensors triggers upon specific points in time.
This class is an abstract superclass which collects the common interface of the various non-abstract timer sensor classes. See the documentation of the subclasses for information on what ways there are to specify base times, intervals, alarm-style single triggering, repeated triggers, etc.
Note that Coin timer sensors should in no way be considered "hard real-time". That is, you can not expect a timer to always trigger at the exact moment it was set up for. Delays in triggering could be due to other activities in Coin, a task suspended, or heavy load from other applications on the system. These situations could all cause the processing of sensor queues (from SoQt / SoWin / SoXt / whatever) to be slightly delayed, thereby causing delays in timer sensor triggering.
On modern systems, a timer will usually trigger within a few milliseconds of it's designated time, though.
If a timer sensor can not trigger at the exact moment it has been scheduled, it will be triggered at the first opportunity after the scheduled time has passed.
Here's a simple usage example. It's a stand-alone example, which only demonstrates how to set up a repeating timer sensor with a callback:
#include <Inventor/Xt/SoXt.h> #include <Inventor/sensors/SoTimerSensor.h> #include <stdio.h> static void timeSensorCallback(void * data, SoSensor * sensor) { SbTime time = SbTime::getTimeOfDay(); SbString string = time.format("%S.%i"); (void)printf("%s\n", string.getString()); } int main(int argc, char ** argv) { SoXt::init("test"); SoTimerSensor * timeSensor = new SoTimerSensor; timeSensor->setFunction(timeSensorCallback); timeSensor->setBaseTime(SbTime::getTimeOfDay()); timeSensor->setInterval(1.0f); timeSensor->schedule(); SoXt::mainLoop(); return 0; }
SoTimerQueueSensor::SoTimerQueueSensor | ( | void | ) |
Default constructor.
SoTimerQueueSensor::SoTimerQueueSensor | ( | SoSensorCB * | func, | |
void * | data | |||
) |
Constructor taking as arguments the sensor callback function and the userdata which will be passed the callback.
SoTimerQueueSensor::~SoTimerQueueSensor | ( | void | ) | [virtual] |
Destructor.
References isScheduled(), and unschedule().
const SbTime & SoTimerQueueSensor::getTriggerTime | ( | void | ) | const |
Returns the time at which the sensor will trigger.
Referenced by SoSensorManager::insertTimerSensor(), and SoTimerSensor::reschedule().
void SoTimerQueueSensor::schedule | ( | void | ) | [virtual] |
Put the sensor in the global timer queue.
Implements SoSensor.
Reimplemented in SoAlarmSensor, and SoTimerSensor.
References SoDB::getSensorManager(), SoSensorManager::insertTimerSensor(), isScheduled(), SoDebugError::postWarning(), and scheduled.
Referenced by SoTimerSensor::reschedule(), and SoAlarmSensor::schedule().
void SoTimerQueueSensor::unschedule | ( | void | ) | [virtual] |
Remove sensor from the timer queue, without triggering it first.
Implements SoSensor.
Reimplemented in SoTimerSensor.
References SoDB::getSensorManager(), isScheduled(), SoDebugError::postWarning(), SoSensorManager::removeTimerSensor(), and scheduled.
Referenced by SoTimerSensor::unschedule(), and ~SoTimerQueueSensor().
SbBool SoTimerQueueSensor::isScheduled | ( | void | ) | const [virtual] |
Check if this sensor is scheduled for triggering.
Implements SoSensor.
References scheduled.
Referenced by SoDB::enableRealTimeSensor(), SoTimerSensor::schedule(), schedule(), SoDB::setRealTimeInterval(), setTriggerTime(), SoTimerSensor::unschedule(), unschedule(), ~SoTimerQueueSensor(), and SoTimerSensor::~SoTimerSensor().
void SoTimerQueueSensor::trigger | ( | void | ) | [virtual] |
Trigger the sensor's callback function.
Reimplemented from SoSensor.
References scheduled, and SoSensor::trigger().
void SoTimerQueueSensor::setTriggerTime | ( | const SbTime & | time | ) | [protected] |
Set absolute time at which to trigger sensor.
References SoDB::getSensorManager(), SoSensorManager::insertTimerSensor(), isScheduled(), and SoSensorManager::removeTimerSensor().
Referenced by SoTimerSensor::reschedule(), and SoAlarmSensor::schedule().
SbBool SoTimerQueueSensor::scheduled [protected] |
TRUE
if the sensor is currently scheduled.
Referenced by isScheduled(), SoTimerSensor::reschedule(), SoTimerSensor::schedule(), schedule(), trigger(), SoTimerSensor::unschedule(), and unschedule().
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 23 16:34:03 2009 for Coin by Doxygen. 1.5.8