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.
TextObject.tcl will typically be sourced in RoboSystem.tcl. The declaration for Text_new is declared in TheSimulationPanel.tcl. Calls to Text_append are made in RoboSystem.tcl.
|
Lines of text output from the main binary are displayed in the scrollable window created by TextObject. |
There are two proc[edures] in TextObject.tcl. The first few lines of each proc lists the parameters required.
proc Text_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 Text_append { {TextName} {text} } \
{
Text_append is called in RoboSystem.tcl. See the example below.
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"