Previous Page TOC Index Next Page

BeeSoft User's Guide and Reference

3.6 Callbacks


When executing your application, the BeeSoft Scheduler looks at each module and attempts to execute each callback according to your specifications. It continues to do this - executing callbacks whose conditions are met - until it received orders to shut down.

Polled Callbacks

Use a polled callback when you want to specify a specific interval between executions of the function. For example, you might want to take a look at the sonar readings every 50 milliseconds, whether or not any new readings have come in. The polled callback is the most frequently used callback.

Module-Specific Callbacks

Each module — whether BeeSoft-supplied or user-written — may allow you to define one or more module-specific callbacks. Use this type of callback when you want to execute your function whenever a particular event occurs. For example, the BeeSoft-supplied baseClient module accepts a callback executed whenever the robot’s base reports a new heading.

Shutdown Callbacks

Use a shutdown callback to do any necessary cleanup once the BeeSoft Scheduler has been told to halt. Since most robot resources are controlled by BeeSoft-supplied modules that take care of cleanly closing down those resources, you’ll seldom have to supply any of your own shutdown callbacks.

Select Callbacks

Use a select callback when you need to get data from a specific file before performing some function. For example, you might want to use a file of data communicated from the robot’s base as input to a particular function. With a select callback, as soon as that base data file is ready, your function will be executed. The BeeSoft servers themselves make frequent use of select callbacks to manage the streams of data flowing in through the physical connections to the robot’s resources.

Timeout Callbacks

Use a timeout callback when you want to execute a particular function only when its associated timer expires. If you don’t then reset the timer, the BeeSoft Scheduler won’t execute that callback again. (Remember, if you want a function executed periodically, use a polled callback.)

Combining Callbacks

Let’s say you want to see an error message if you haven’t heard anything from the robot’s base for more than two seconds. You might set up your module with both a select callback and a timeout callback. The BeeSoft Scheduler will execute the select callback each time a report is received from the robot’s base, and then reset the timer for two seconds hence. But if no report from the robot base is forthcoming in two seconds, the Scheduler will execute the timeout callback.

Previous Page Page Top TOC Index Next Page