FIRST Robot Simulator - ByteMonitorObject


What Is Performed

ByteMonitorObject provides monitoring of variables. It does not simulate any functions of the robot. Instead, its purpose is to assist in debug.


Where Used

ByteMonitorObject.tcl will typically be sourced in TheSimulationPanel.tcl. The declaration for ::Bytemonitor::new will then also be created in TheSimulationPanel.tcl.


GUI View

The name and value of the chosen variable are displayed.


Programmers View

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

  proc new { {ByteObjName} {NameOnCanv} {variable} \
			 {FgCol} {BgCol} } \
  {
    # ByteObjName = Unique name for the byte object.
    # variable = The name of the variable being monitored,
    #		generally in ::name form.
    # FgCol and BgCol = Foreground and Background colors.
  
  proc update { {ByteObjName} } \
  {
  

Typically ::Bytemonitor:: will be managed by CanvasObject or Notify. If so, there is no need to explicitly call ::Bytemonitor::update.


Example

We can put a group of bytemonitors inside a canvas object using code like this:

  source {ByteMonitorObject.tcl}

  set Fg {#000000}
  set Bg {#9f8f9f}
  set canvasname [::Canvas::new byte .byteCanvas $Bg $Fg  {Byte Monitor}]
  # ::Bytemonitor::new {ByteObjName} {NameOnCanv} {var} {FgCol} {BgCol}
  set labelname [::Canvas::IncludeObject byte ::Bytemonitor::update pwm01_bmon]
  ::Bytemonitor::new {pwm01_bmon}   $labelname {::pwm01}   $Fg $Bg
  pack $labelname -side top
  # repeat the last three lines for as many variables as you want to monitor.
  pack .byteCanvas -side top
  

The declaration above is in TheSimulationPanel.tcl. The double colons in front of each variable name makes them operate at the root namespace of the Tcl program. Notice that the call to ::Canvas::IncludeObject passes the ::Bytemonitor::update call with the name of the Bytemonitor object.

  ::Notify::Subscribe Cycle ::Canvas::UpdateAll byte
  

By subscribing to the Cycle notify this canvas is told to update every cycle.


Caveats



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