Class SoTimerSensor
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.sensors.SoSensor
-
- com.openinventor.inventor.sensors.SoTimerQueueSensor
-
- com.openinventor.inventor.sensors.SoTimerSensor
-
- Direct Known Subclasses:
SoFileSensor
public class SoTimerSensor extends SoTimerQueueSensor
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 bySbTime.getTimeOfDay()
. For example, a timer might be set up to call its function every second on the second by setting the base time toSbTime
(0.0) and the interval toSbTime
(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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoTimerSensor()
Default constructor.SoTimerSensor(java.lang.Runnable task)
Build a new timer sensor with the task to be executed when the sensor is triggered.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SbTime
getBaseTime()
Gets the base time.SbTime
getInterval()
Gets the interval.void
setBaseTime(SbTime base)
Sets the base time.void
setInterval(SbTime intvl)
Sets the interval.-
Methods inherited from class com.openinventor.inventor.sensors.SoTimerQueueSensor
getTriggerTime
-
Methods inherited from class com.openinventor.inventor.sensors.SoSensor
isScheduled, schedule, setTask, unschedule
-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
setBaseTime
public void setBaseTime(SbTime base)
Sets the base time. The default base time is the time when the sensor is scheduled or rescheduled.
-
getBaseTime
public SbTime getBaseTime()
Gets the base time.
-
setInterval
public void setInterval(SbTime intvl)
Sets the interval. The default interval is 1/30th of a second.
-
getInterval
public SbTime getInterval()
Gets the interval.
-
-