Ignore:
Timestamp:
Feb 23, 2008 8:16:38 PM (15 years ago)
Author:
mmc
Message:

Final tweaks on the optimization package. The demo now works properly.
Just run "wish simple.tcl" to see it work.

Fixed the Tool class to work better with the optimizer. The "run"
method now returns the result directly as a Rappture::Library object,
and the Analyzer merely loads the object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/analyzer.tcl

    r822 r903  
    5252    public method simulate {args}
    5353    public method reset {{when -eventually}}
    54     public method load {file}
     54    public method load {xmlobj}
    5555    public method clear {}
    5656    public method download {option args}
     
    7777
    7878    private common job                 ;# array var used for blt::bgexec jobs
    79 
    80     # resources file tells us the results directory
    81     public common _resultdir ""
    82     public proc setResultDir {path} { set _resultdir $path }
    83 }
    84 
    85 # must use this name -- plugs into Rappture::resources::load
    86 proc analyzer_init_resources {} {
    87     Rappture::resources::register \
    88         results_directory Rappture::Analyzer::setResultDir
    89 }
    90                                                                                
     79}
     80
    9181itk::usual Analyzer {
    9282    keep -background -cursor foreground -font
     
    354344    }
    355345
    356     # read back the results from run.xml
     346    # load results from run.xml into analyzer
    357347    if {$status == 0 && $result != "ABORT"} {
    358         if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} {
    359             set status [catch {load $file} msg]
    360             if {$status != 0} {
    361                 global errorInfo
    362                 set result "$msg\n$errorInfo"
    363             }
    364 
    365             # if there's a results_directory defined in the resources
    366             # file, then move the run.xml file there for storage
    367             if {"" != $_resultdir} {
    368                 catch {
    369                     if {![file exists $_resultdir]} {
    370                         _mkdir $_resultdir
    371                     }
    372                     file rename -force -- $file $_resultdir
    373                 }
    374             }
    375         } else {
    376             set status 1
    377             set result "Can't find result file in output.\nDid you call Rappture::result in your simulator?"
    378         }
     348        set status [catch {load $result} result]
    379349    }
    380350
     
    441411
    442412# ----------------------------------------------------------------------
    443 # USAGE: load <file>
    444 #
    445 # Loads the data from the given <file> into the appropriate results
     413# USAGE: load <xmlobj>
     414#
     415# Loads the data from the given <xmlobj> into the appropriate results
    446416# sets.  If necessary, new results sets are created to store the data.
    447417# ----------------------------------------------------------------------
    448 itcl::body Rappture::Analyzer::load {file} {
     418itcl::body Rappture::Analyzer::load {xmlobj} {
    449419    # only show the last result? then clear first
    450420    if {[$_tool xml get tool.analyzer] == "last"} {
     
    452422    }
    453423
    454     # try to load new results from the given file
    455     set xmlobj [Rappture::library $file]
    456424    lappend _runs $xmlobj
    457425
Note: See TracChangeset for help on using the changeset viewer.