Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <ControlBase.h>
Inheritance diagram for ControlBase:
These are similar to behaviors in that they can do processing and are told when to start and stop.
However, the important difference is that these have to follow a much tighter set of guidelines for a more refined purpose - user interface. Controls do not directly receive events - the Controller will process events for them and call the appropriate functions at the appropriate times. Controls are expected to fit into a heirarchical scheme, where each control (except the root) has a parent which created it, and may return its own children where appropriate.
This base class will do most of the work of maintain submenus for you, and will call appropriate virtual functions which you can override. Controls generally live in Behaviors/Controls/ as the Controller itself is a behavior, and these controls merely its tools.
The ControlBase pointers which are returned at various points are the responsibility of the creator. Controller will not delete them upon deactivation.
GUI Theory:
There are 3 levels to the user interface.
Obviously, higher levels require more technological resources, which also means there's more to go wrong and debug. However, another important distinction between the first level and the others is that the first level does not require the user to lose direct contact with the robot. Requiring the user to move back and forth from robot to computer can be much more frustrating than decoding LED signals or press head buttons. There are safety issues when triggering behaviors remotely if the robot is out of immediate reach. But of course, having a GUI and text output is extremely valuable in terms of ease of use and efficiency.
So, the lesson is to try to support all 3 levels so that your interfaces will be robust and efficient in a variety of environments. You'll thank yourself when you're demoing on the road and you can't get wavelan up, or the guest machine you're supposed to use doesn't have Java, or whatever.
Definition at line 57 of file ControlBase.h.
Public Member Functions | |
ControlBase () | |
Contructor. | |
ControlBase (const std::string &n) | |
Contructor, initializes with a name. | |
ControlBase (const std::string &n, const std::string &d) | |
Contructor, initializes with a name. | |
virtual | ~ControlBase () |
Destructor. | |
virtual ControlBase & | setName (const std::string &n) |
sets the name of the control | |
virtual std::string | getName () const |
returns the name of the control | |
virtual ControlBase & | setDescription (const std::string d) |
sets the description of the control | |
virtual std::string | getDescription () const |
returns a short description of what the control does | |
const std::vector< ControlBase * > & | getSlots () const |
returns the vector of controls | |
std::string | getSlotName (unsigned int i) const |
returns the string that will appear in slot i | |
unsigned int | slotsSize () const |
returns the number of options available | |
void | setSlot (unsigned int i, ControlBase *o) |
sets i'th element of ::options to o | |
void | pushSlot (ControlBase *o) |
sets next unused element of ::options to o | |
void | clearSlots () |
deletes each slot item and clears the slots | |
virtual const std::vector< unsigned int > & | getHilights () const |
returns a vector of the indicies of hilighted slots | |
virtual void | setHilights (const std::vector< unsigned int > &hi) |
sets the hilighted slots | |
virtual void | hilightFirst () |
sets the hilight to the first non-null slot | |
virtual MotionManager::MC_ID | getDisplay () |
returns display being used | |
virtual ControlBase & | setDisplay (MotionManager::MC_ID d) |
sets display to use | |
Controller Functions | |
You probably want to override some of these, call the ControlBase functions from your code if you want default sound effects (or look in Config::controller_config). | |
virtual ControlBase * | activate (MotionManager::MC_ID disp_id, Socket *gui) |
Called when the control is activated (or the control system is reactivating). | |
virtual void | pause () |
called when a control is being overriden by a child, or the control system is deactivating (e-stop being turned off) | |
virtual void | refresh () |
called when the child has died and this control should refresh its display | |
virtual void | deactivate () |
called when this control is being popped from the control stack | |
virtual ControlBase * | doSelect () |
when the user has trigger an "open selection" - default is to return the hilighted control | |
virtual ControlBase * | doNextItem () |
when the user wants to increment the control - default is to return the first non-null slot after the last hilight | |
virtual ControlBase * | doPrevItem () |
when the user wants to decrement the control - default is to return the last non-null slot before the first hilight | |
virtual ControlBase * | doCancel () |
when the user wants to cancel - you should almost always return NULL now unless you need to confirm something (e.g. "Save changes?") | |
virtual ControlBase * | doReadStdIn (const std::string &prompt=std::string()) |
prompt the user for text input on the current input device (cin, tekkotsu console (sout), or GUI) | |
virtual ControlBase * | takeInput (const std::string &msg) |
called when the user has supplied a text string (may not have been prompted by doReadStdIn()!) | |
virtual bool | validInput (const std::string &msg) |
may be called before takeInput to verify this Control can make sense of msg | |
Protected Member Functions | |
virtual void | clearMenu () |
clears the display (if use_VT100 is on) | |
float | hilightsAvg () const |
returns the average of the hilighted indicies - used to know to play the "next" sound, or the "prev" sound when the hilight changes | |
Protected Attributes | |
std::string | name |
the name of this control | |
std::string | description |
the description of this control | |
std::vector< unsigned int > | hilights |
keep sorted - index(es) of current selection - can have multiple if using GUI | |
std::vector< ControlBase * > | options |
vector of controls to select from | |
bool | doRewrite |
toggles using VT100 codes to reposition the cursor at the beginning of the menu | |
MotionManager::MC_ID | display_id |
LedMC to use for displaying selection. | |
Socket * | gui_comm |
socket to communicate with the GUI, if it is connected | |
Private Member Functions | |
ControlBase (const ControlBase &) | |
you can override, but don't call this... | |
ControlBase & | operator= (const ControlBase &) |
you can override, but don't call this... |
|
Contructor.
Definition at line 60 of file ControlBase.h. References description, display_id, doRewrite, gui_comm, hilights, name, and options. |
|
Contructor, initializes with a name.
Definition at line 61 of file ControlBase.h. References description, display_id, doRewrite, gui_comm, hilights, name, and options. |
|
Contructor, initializes with a name.
Definition at line 62 of file ControlBase.h. References description, display_id, doRewrite, gui_comm, hilights, name, and options. |
|
Destructor.
Definition at line 65 of file ControlBase.h. References clearSlots(). |
|
you can override, but don't call this...
|
|
Called when the control is activated (or the control system is reactivating). Takes the id number of a LedMC which the control should use, maintained by Controller. Controls share the display which is passed, and may use the socket gui to communicate with the GUI controller, if it is connected.
Reimplemented in BatteryCheckControl, BehaviorActivatorControl, BehaviorSwitchActivatorControl, BehaviorSwitchControlBase, FileBrowserControl, HelpControl, NullControl, ProfilerCheckControl, RebootControl, SaveWalkControl, ShutdownControl, StringInputControl, and ValueEditControl< T >. Definition at line 8 of file ControlBase.cc. References display_id, gui_comm, hilightFirst(), and refresh(). |
|
clears the display (if use_VT100 is on)
Definition at line 310 of file ControlBase.cc. References config, Config::main, options, Socket::printf(), sout, and Config::main_config::use_VT100. |
|
deletes each slot item and clears the slots
Definition at line 277 of file ControlBase.cc. |
|
called when this control is being popped from the control stack
Reimplemented in BatteryCheckControl, LoadPostureControl, and SaveWalkControl. Definition at line 87 of file ControlBase.cc. References clearMenu(), config, display_id, doRewrite, hilights, MotionManager::invalid_MC_ID, Config::main, MMAccessor< MC_t >::mc(), and Config::main_config::use_VT100. |
|
when the user wants to cancel - you should almost always return NULL now unless you need to confirm something (e.g. "Save changes?")
Definition at line 178 of file ControlBase.cc. References Config::controller_config::cancel_snd, config, Config::controller, SoundManager::PlayFile(), and sndman. |
|
when the user wants to increment the control - default is to return the first non-null slot after the last hilight
Reimplemented in NullControl, and ValueEditControl< T >. Definition at line 142 of file ControlBase.cc. References config, Config::controller, hilights, Config::controller_config::next_snd, options, SoundManager::PlayFile(), refresh(), and sndman. |
|
when the user wants to decrement the control - default is to return the last non-null slot before the first hilight
Reimplemented in NullControl, and ValueEditControl< T >. Definition at line 160 of file ControlBase.cc. References config, Config::controller, hilights, options, SoundManager::PlayFile(), Config::controller_config::prev_snd, refresh(), and sndman. |
|
prompt the user for text input on the current input device (cin, tekkotsu console (sout), or GUI)
Reimplemented in NullControl, and StringInputControl. Definition at line 184 of file ControlBase.cc. References config, Config::controller, display_id, ERS210Info::FaceLEDMask, gui_comm, MotionManager::invalid_MC_ID, Wireless::isConnected(), MMAccessor< MC_t >::mc(), SoundManager::PlayFile(), Socket::printf(), Config::controller_config::read_snd, sndman, Socket::sock, sout, takeInput(), and wireless. |
|
when the user has trigger an "open selection" - default is to return the hilighted control
Reimplemented in BatteryCheckControl, EventLogger, FileBrowserControl, MCValueEditControl< T >, NullControl, RebootControl, ShutdownControl, and ValueEditControl< T >. Definition at line 101 of file ControlBase.cc. References clearMenu(), config, Config::controller, display_id, doRewrite, ERS210Info::FaceLEDMask, gui_comm, hilights, MotionManager::invalid_MC_ID, Config::main, MMAccessor< MC_t >::mc(), options, SoundManager::PlayFile(), Socket::printf(), Config::controller_config::select_snd, sndman, sout, and Config::main_config::use_VT100. |
|
returns a short description of what the control does
Reimplemented in BehaviorSwitchActivatorControl, and BehaviorSwitchControl< B, Al >. Definition at line 95 of file ControlBase.h. References description. |
|
returns display being used
Definition at line 108 of file ControlBase.h. References display_id, and MotionManager::MC_ID. |
|
returns a vector of the indicies of hilighted slots
Definition at line 104 of file ControlBase.h. References hilights. |
|
returns the name of the control
Reimplemented in BehaviorSwitchActivatorControl, BehaviorSwitchControl< B, Al >, FreeMemReportControl, and ValueEditControl< T >. Definition at line 92 of file ControlBase.h. References name. |
|
returns the string that will appear in slot i
Definition at line 259 of file ControlBase.cc. References options. |
|
returns the vector of controls
Definition at line 97 of file ControlBase.h. References options. |
|
sets the hilight to the first non-null slot
Definition at line 300 of file ControlBase.cc. |
|
returns the average of the hilighted indicies - used to know to play the "next" sound, or the "prev" sound when the hilight changes
Definition at line 317 of file ControlBase.cc. References hilights. |
|
you can override, but don't call this...
|
|
called when a control is being overriden by a child, or the control system is deactivating (e-stop being turned off)
Reimplemented in BatteryCheckControl, and ValueEditControl< T >. Definition at line 16 of file ControlBase.cc. References doRewrite. |
|
sets next unused element of ::options to o
Definition at line 273 of file ControlBase.cc. References options. |
|
called when the child has died and this control should refresh its display
Reimplemented in BatteryCheckControl, EventLogger, FreeMemReportControl, and StringInputControl. Definition at line 22 of file ControlBase.cc. References clearMenu(), config, display_id, doRewrite, getName(), getSlotName(), gui_comm, hilights, MotionManager::invalid_MC_ID, Wireless::isConnected(), Config::main, MMAccessor< MC_t >::mc(), LedEngine::onedigit, options, Socket::printf(), Socket::sock, sout, LedEngine::twodigit, Config::main_config::use_VT100, wireless, and Socket::write(). |
|
sets the description of the control
Definition at line 94 of file ControlBase.h. References description. |
|
sets display to use
Definition at line 109 of file ControlBase.h. References display_id. |
|
sets the hilighted slots
Definition at line 284 of file ControlBase.cc. References config, Config::controller, hilights, hilightsAvg(), Config::controller_config::next_snd, options, SoundManager::PlayFile(), Config::controller_config::prev_snd, refresh(), and sndman. |
|
sets the name of the control
Definition at line 91 of file ControlBase.h. References name. |
|
sets i'th element of ::options to o
Definition at line 267 of file ControlBase.cc. References options. |
|
returns the number of options available
Definition at line 99 of file ControlBase.h. References options. |
|
called when the user has supplied a text string (may not have been prompted by doReadStdIn()!)
Reimplemented in NullControl, SavePostureControl, StringInputControl, and ValueEditControl< T >. Definition at line 213 of file ControlBase.cc. References clearMenu(), config, doRewrite, doSelect(), hilights, Config::main, options, Socket::printf(), refresh(), serr, sout, and Config::main_config::use_VT100. |
|
may be called before takeInput to verify this Control can make sense of msg
Definition at line 254 of file ControlBase.cc. References options. |
|
the description of this control
Definition at line 119 of file ControlBase.h. |
|
LedMC to use for displaying selection.
Definition at line 126 of file ControlBase.h. |
|
toggles using VT100 codes to reposition the cursor at the beginning of the menu we don't always want to do this, any time someone else might have written to the display we set this to false so we don't overwrite it. Definition at line 122 of file ControlBase.h. |
|
socket to communicate with the GUI, if it is connected
Definition at line 127 of file ControlBase.h. |
|
keep sorted - index(es) of current selection - can have multiple if using GUI
Definition at line 120 of file ControlBase.h. |
|
the name of this control
Definition at line 118 of file ControlBase.h. |
|
vector of controls to select from
Definition at line 121 of file ControlBase.h. |
Tekkotsu v1.4 |
Generated Sat Jul 19 00:08:52 2003 by Doxygen 1.3.2 |