FIRST Robot Simulator - TextObject


What Is Performed

TextObject manages an on-screen log file. It does not simulate any functions of the robot. Instead, its purpose is to assist in debug.

TextObject provides the capability to color code lines based on their content. It can also take limited action based on content.


Where Used

TextObject.tcl will typically be sourced in RoboSystem.tcl. The declaration for ::Text::new is in TheSimulationPanel.tcl. Calls to ::Text::append are made in RoboSystem.tcl.


GUI View

Lines of text output from the main binary are displayed in the scrollable window created by TextObject.


Programmers View

There are two proc[edures] in TextObject.tcl. The first few lines of each proc lists the parameters required.

  proc new { {TextName} {NameOnCanv} \
		      {Xs} {Ys} {Fg} {Bg} {Colorize} } \
  {
    # TextName = Unique name for the Text Screen.
    # NameOnCanv = must start with lower case.  Can be a child of a frame.
    # Xs and Ys = Size of screen in pixels.
    # Fg and Bg = Foreground and Background colors.
    # Colorize = Triplets of pattern/color/script.  If pattern is
    #		matched, turn the line color and execute script
    #		on the tag.  Color {} says to ignore this pattern.
  
  proc append { {TextName} {text} } \
  {
  

::Text::append is called in RoboSystem.tcl. See the example below.


Example

We declare the scrollable text object inside TheSimulationPanel.tcl.

  ::Text::new logfile .logfile 86 36 white black \
	  {{{^Getdata: oi_analog01} {} {}}
	  {{[Ee][Rr][Rr][Oo][Rr]} {red} {stopButtonEvent simInt}}
	  {{[Ww][Aa][Rr][Nn][Ii][Nn][Gg]} {orange} {}}
	  {{[Nn][Oo][Tt][Ee]} {yellow} {}}
	  {{Putdata:} {cyan} {}} {{^------------} {} {}}
	  {{Getdata:} {green} {}}}
  

Updates to the text are made by calling ::Text::append from within RoboSystem.tcl. Here is an example of that:

      ::Text::append logfile \
	"Getdata: tcopdat pwm13=$::pwm13 pwm14=$::pwm14 pwm15=$::pwm15 pwm16=$::pwm16"
  

In practice a normal user will never have to mess with this. It is already set up for you.



Last modified 11 Dec 2006
http://brown.armoredpenguin.com/~abrown/contact.html
http://brown.armoredpenguin.com/~abrown/first/first2006/Scalawags/Simulator2006/TextObject.html