Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <Controller.h>
Inheritance diagram for Controller:
Keeps track of a command stack. A Control can designate another sub-control, which will receive events until it finishes
Events will then be sent to the parent again.
The GUI uses the same commands as the user (makes it much easier to have only one parser). The commands are:
!refresh
' - redisplays the current control (handy on first connecting, or when other output has scrolled it off the screen)!reset
' - return to the root control!next
' - calls ControlBase::doNextItem() of the current control!prev
' - calls ControlBase::doPrevItem() of the current control!select
' - calls ControlBase::doSelect() of the current control!cancel
' - calls ControlBase::doCancel() of the current control!msg
text' - broadcasts text as a TextMsgEvent!root
text' - calls ControlBase::takeInput(text) on the root control!hello
' - responds with 'hello
count' where count is the number of times '!hello
' has been sent. Good for detecting first connection after boot vs. a reconnect.!hilight
[n1 [n2 [...]]]' - hilights zero, one, or more items in the menu!input
text' - calls ControlBase::takeInput(text) on the currently hilighted control(s)In return, to send the menus to the GUI, the following messages are sent: (newlines are required where shown)
push
' - signals a submenu has been activatedpop
' - signals a submenu has been closedrefresh
status
text' - sets the status bar to text (until the next refresh)load
Classname(String
host, int
port, String
args[])
the argument list is parsed as if it were on the console - unescaped or unquoted spaces will separate args into elements in the arrayclose
close()
on an object previously created by a load
message. The Java object is expected to contain a function void close()
.goodbye
bool types are expected to be numerical values, 0 for false, non-zero for true.
load
and close
are intended to allow pop-up windows for custom displays.
The upstream is the responsibility of the individual Controls, but the protocol is listed here to keep it together. When a control's state changes, it's that control's responsiblity to refresh the UI (LEDs, console, and GUI as appropriate). Thus, future extensions to the upstream protocol are between the control which will use it and the GUI. Future extensions to the downstream protocol would involve changing Controller and the GUI.
The Controller may connect to serr in the future to pop-up an alert anytime output to serr occurs.
Note that all state is maintained on the robot - even if the GUI is connected, you can still use the buttons to interact with the controller, and the GUI will update to reflect the changes. In HCI (Human Computer Interaction) parlance, this is the MVC, Model-View-Controller architecture, almost by necessity. (HCI happens to be my double major when I was an undergrad ;)
Definition at line 87 of file Controller.h.
Public Member Functions | |
Controller () | |
Constructor. | |
Controller (ControlBase *r) | |
Constructor, sets a default root control. | |
virtual | ~Controller () |
Destructor. | |
virtual void | DoStart () |
register for events and resets the cmdstack | |
virtual void | DoStop () |
stop listening for events and resets the cmdstack | |
virtual bool | trapEvent (const EventBase &e) |
passes an event to the top control | |
virtual void | processEvent (const EventBase &e) |
just for e-stop activation/deactivation | |
void | reset () |
will take the command stack back down to the root | |
void | refresh () |
refreshes the display, for times like sub-control dying, the previous control needs to reset it's display | |
void | push (ControlBase *c) |
puts a new control on top | |
void | pop () |
kills the top control, goes to previous | |
ControlBase * | top () |
returns the current control | |
Controller & | setRoot (ControlBase *r) |
sets the root level control | |
Controller & | setEStopID (MotionManager::MC_ID estopid) |
Sets the emergency stop MC to monitor for pausing. | |
virtual std::string | getName () const |
Identifies the behavior in menus and such. | |
Static Public Member Functions | |
std::string | getClassDescription () |
Gives a short description of what this class of behaviors does... you should override this (but don't have to). | |
void | loadGUI (const std::string &type, const std::string &name, unsigned int port) |
attempts to open a Java object on the desktop | |
void | loadGUI (const std::string &type, const std::string &name, unsigned int port, const std::vector< std::string > &args) |
attempts to open a Java object on the desktop | |
void | closeGUI (const std::string &name) |
calls close() on a Java object loaded with loadGUI() (on the desktop) | |
int | gui_comm_callback (char *buf, int bytes) |
called by wireless when there's new data from the GUI | |
int | console_callback (char *buf, int bytes) |
called by wireless when someone has entered new data on the tekkotsu console (NOT cin) | |
Static Public Attributes | |
EventBase | nextItem |
event masks used by processEvent() | |
EventBase | prevItem |
event masks used by processEvent() | |
EventBase | nextItemFast |
event masks used by processEvent() | |
EventBase | prevItemFast |
event masks used by processEvent() | |
EventBase | selectItem |
event masks used by processEvent() | |
EventBase | cancel |
event masks used by processEvent() | |
Protected Member Functions | |
void | init () |
assigns appropriate values to the static event bases | |
void | takeLine (const std::string &s) |
called with each line that's entered on the tekkotsu console or from the GUI | |
int | setConfig (const char *str) |
sets a config value - some values may require additional processing (done here) to have the new values take effect | |
bool | setNext (ControlBase *next) |
maintains top Control | |
void | activate () |
called when the estop switches on | |
void | deactivate () |
called when the estop switches off | |
bool | chkCmdStack () |
returns true if a valid control is available on the stack | |
Static Protected Member Functions | |
bool | calcPulse (unsigned int t, unsigned int last, unsigned int period) |
returns true when the current time and last time are in different periods | |
Protected Attributes | |
MotionManager::MC_ID | display |
invalid_MC_ID if not active, otherwise id of high priority LEDs | |
MotionManager::MC_ID | estop_id |
the EmergencyStopMC MC_ID that this Controller is monitoring | |
ControlBase * | root |
the base control, if cmdstack underflows, it will be reset to this | |
std::stack< ControlBase * > | cmdstack |
the stack of the current control hierarchy should never contain NULL entries | |
unsigned int | last_time |
the time of the last event | |
unsigned int | cur_time |
the time of the current event (do*() can check this instead of calling get_time() ) | |
float | nextEv_val |
the magnitude of the last next event (::nextItem) | |
unsigned int | nextEv_dur |
the duration of the last next event (::nextItem) | |
float | prevEv_val |
the magnitude of the last prev event (::prevItem) | |
unsigned int | prevEv_dur |
the duration of the last prev event (::prevItem) | |
bool | alreadyGotBoth |
if doReadStdIn() was already called, but the buttons are both still down | |
bool | isControlling |
true if the Controller is currently active (in the activate()/deactivate() sense, not DoStart()/DoStop() sense - use isActive() for that...) | |
Socket * | gui_comm |
the socket to listen on for the gui | |
Static Protected Attributes | |
Controller * | theOneController = NULL |
currently can't pull connection socket off of server socket, so only one Controller | |
Private Member Functions | |
Controller (const Controller &) | |
shouldn't be called... | |
Controller & | operator= (const Controller &) |
shouldn't be called... |
|
Constructor.
Definition at line 89 of file Controller.h. |
|
Constructor, sets a default root control.
Definition at line 90 of file Controller.h. |
|
Destructor.
Definition at line 91 of file Controller.h. |
|
shouldn't be called...
|
|
called when the estop switches on causes the top control to activate, registers for button events Definition at line 402 of file Controller.cc. Referenced by processEvent(), and setEStopID(). |
|
returns true when the current time and last time are in different periods
Definition at line 176 of file Controller.h. Referenced by trapEvent(). |
|
returns true if a valid control is available on the stack if the stack is empty, will push root if it's non-null Definition at line 422 of file Controller.cc. Referenced by activate(), push(), refresh(), takeLine(), and trapEvent(). |
|
calls close() on a Java object loaded with loadGUI() (on the desktop)
Definition at line 201 of file Controller.cc. Referenced by WalkControllerBehavior::DoStop(), ViewWMVarsBehavior::DoStop(), HeadPointControllerBehavior::DoStop(), and Aibo3DControllerBehavior::DoStop(). |
|
called by wireless when someone has entered new data on the tekkotsu console (NOT cin)
Definition at line 233 of file Controller.cc. Referenced by StartupBehavior::DoStart(). |
|
called when the estop switches off causes the top control to deactivate, stops listening for buttons Definition at line 412 of file Controller.cc. Referenced by processEvent(), and setEStopID(). |
|
register for events and resets the cmdstack
Reimplemented from BehaviorBase. Definition at line 29 of file Controller.cc. Referenced by StartupBehavior::DoStart(). |
|
stop listening for events and resets the cmdstack
Reimplemented from BehaviorBase. Definition at line 50 of file Controller.cc. |
|
Gives a short description of what this class of behaviors does... you should override this (but don't have to).
Reimplemented from BehaviorBase. Definition at line 124 of file Controller.h. |
|
Identifies the behavior in menus and such.
Implements BehaviorBase. Definition at line 123 of file Controller.h. |
|
called by wireless when there's new data from the GUI
Definition at line 209 of file Controller.cc. Referenced by DoStart(). |
|
assigns appropriate values to the static event bases
Definition at line 261 of file Controller.cc. Referenced by Controller(). |
|
attempts to open a Java object on the desktop
Definition at line 183 of file Controller.cc. |
|
attempts to open a Java object on the desktop
Definition at line 128 of file Controller.h. Referenced by WalkControllerBehavior::DoStart(), ViewWMVarsBehavior::DoStart(), HeadPointControllerBehavior::DoStart(), Aibo3DControllerBehavior::DoStart(), and WalkCalibration::err(). |
|
shouldn't be called...
|
|
kills the top control, goes to previous
Definition at line 157 of file Controller.cc. |
|
just for e-stop activation/deactivation
Reimplemented from BehaviorBase. Definition at line 122 of file Controller.cc. |
|
puts a new control on top
Definition at line 148 of file Controller.cc. Referenced by chkCmdStack(), and setNext(). |
|
refreshes the display, for times like sub-control dying, the previous control needs to reset it's display
Definition at line 142 of file Controller.cc. Referenced by pop(), reset(), setRoot(), and takeLine(). |
|
will take the command stack back down to the root
Definition at line 132 of file Controller.cc. Referenced by DoStart(), DoStop(), setRoot(), and takeLine(). |
|
sets a config value - some values may require additional processing (done here) to have the new values take effect
Definition at line 373 of file Controller.cc. Referenced by takeLine(). |
|
Sets the emergency stop MC to monitor for pausing.
Definition at line 171 of file Controller.cc. Referenced by StartupBehavior::DoStart(). |
|
maintains top Control
Definition at line 394 of file Controller.cc. Referenced by push(), takeLine(), and trapEvent(). |
|
sets the root level control
Definition at line 164 of file Controller.cc. Referenced by StartupBehavior::DoStart(). |
|
called with each line that's entered on the tekkotsu console or from the GUI
Definition at line 293 of file Controller.cc. Referenced by console_callback(), and gui_comm_callback(). |
|
returns the current control
Definition at line 117 of file Controller.h. |
|
passes an event to the top control
Implements EventTrapper. Definition at line 70 of file Controller.cc. |
|
if doReadStdIn() was already called, but the buttons are both still down
Definition at line 191 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
event masks used by processEvent()
Definition at line 24 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
the stack of the current control hierarchy
Definition at line 173 of file Controller.h. Referenced by activate(), chkCmdStack(), Controller(), deactivate(), pop(), push(), refresh(), reset(), setNext(), takeLine(), top(), and trapEvent(). |
|
the time of the current event (do*() can check this instead of calling get_time() )
Definition at line 186 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
invalid_MC_ID if not active, otherwise id of high priority LEDs
Definition at line 163 of file Controller.h. Referenced by activate(), chkCmdStack(), Controller(), deactivate(), DoStart(), DoStop(), and push(). |
|
the EmergencyStopMC MC_ID that this Controller is monitoring
Definition at line 166 of file Controller.h. Referenced by Controller(), and setEStopID(). |
|
the socket to listen on for the gui
Definition at line 194 of file Controller.h. Referenced by activate(), chkCmdStack(), closeGUI(), console_callback(), Controller(), DoStart(), DoStop(), loadGUI(), pop(), push(), and takeLine(). |
|
true if the Controller is currently active (in the activate()/deactivate() sense, not DoStart()/DoStop() sense - use isActive() for that...)
Definition at line 192 of file Controller.h. Referenced by activate(), Controller(), deactivate(), DoStart(), processEvent(), and setEStopID(). |
|
the time of the last event
Definition at line 185 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
the duration of the last next event (::nextItem)
Definition at line 188 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
the magnitude of the last next event (::nextItem)
Definition at line 187 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
event masks used by processEvent()
Definition at line 19 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
event masks used by processEvent()
Definition at line 21 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
the duration of the last prev event (::prevItem)
Definition at line 190 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
the magnitude of the last prev event (::prevItem)
Definition at line 189 of file Controller.h. Referenced by Controller(), and trapEvent(). |
|
event masks used by processEvent()
Definition at line 20 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
event masks used by processEvent()
Definition at line 22 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
the base control, if cmdstack underflows, it will be reset to this
Definition at line 169 of file Controller.h. Referenced by chkCmdStack(), Controller(), setRoot(), takeLine(), and ~Controller(). |
|
event masks used by processEvent()
Definition at line 23 of file Controller.cc. Referenced by init(), and trapEvent(). |
|
currently can't pull connection socket off of server socket, so only one Controller
Definition at line 16 of file Controller.cc. Referenced by closeGUI(), console_callback(), DoStart(), DoStop(), gui_comm_callback(), loadGUI(), pop(), push(), takeLine(), and ~Controller(). |
Tekkotsu v2.0 |
Generated Wed Jan 21 03:23:06 2004 by Doxygen 1.3.4 |