Changeset 903 for trunk/gui


Ignore:
Timestamp:
Feb 23, 2008, 8:16:38 PM (17 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.

Location:
trunk/gui/scripts
Files:
2 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
  • trunk/gui/scripts/tool.tcl

    r775 r903  
    4040
    4141    public common _resources
    42     public proc setAppName {name} { set _resources(-appname) $name }
    43     public proc setHubName {name} { set _resources(-hubname) $name }
    44     public proc setHubURL {name}  { set _resources(-huburl) $name }
    45     public proc setSession {name} { set _resources(-session) $name }
    46     public proc setJobPrt {name}  { set _resources(-jobprotocol) $name }
     42    public proc setAppName {name}   { set _resources(-appname) $name }
     43    public proc setHubName {name}   { set _resources(-hubname) $name }
     44    public proc setHubURL {name}    { set _resources(-huburl) $name }
     45    public proc setSession {name}   { set _resources(-session) $name }
     46    public proc setJobPrt {name}    { set _resources(-jobprotocol) $name }
     47    public proc setResultDir {name} { set _resources(-resultdir) $name }
    4748}
    4849
     
    5051proc tool_init_resources {} {
    5152    Rappture::resources::register \
    52         application_name Rappture::Tool::setAppName \
    53         application_id   Rappture::Tool::setAppId \
    54         hub_name         Rappture::Tool::setHubName \
    55         hub_url          Rappture::Tool::setHubURL \
    56         session_token    Rappture::Tool::setSession \
    57         job_protocol     Rappture::Tool::setJobPrt
     53        application_name  Rappture::Tool::setAppName \
     54        application_id    Rappture::Tool::setAppId \
     55        hub_name          Rappture::Tool::setHubName \
     56        hub_url           Rappture::Tool::setHubURL \
     57        session_token     Rappture::Tool::setSession \
     58        job_protocol      Rappture::Tool::setJobPrt \
     59        results_directory Rappture::Tool::setResultDir
    5860}
    5961                                                                               
     
    263265    #
    264266    if {$status == 0} {
    265         set file [string trim $job(output)]
    266         return [list $status $file]
     267        set result [string trim $job(output)]
     268        if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} {
     269            set status [catch {Rappture::library $file} result]
     270            if {$status != 0} {
     271                global errorInfo
     272                set result "$result\n$errorInfo"
     273            }
     274
     275            # if there's a results_directory defined in the resources
     276            # file, then move the run.xml file there for storage
     277            if {[info exists _resources(-resultdir)]
     278                  && "" != $_resources(-resultdir)} {
     279                catch {
     280                    if {![file exists $_resources(-resultdir)]} {
     281                        _mkdir $_resources(-resultdir)
     282                    }
     283                    file rename -force -- $file $_resources(-resultdir)
     284                }
     285            }
     286        } else {
     287            set status 1
     288            set result "Can't find result file in output.\nDid you call Rappture
     289::result in your simulator?"
     290        }
     291        return [list $status $result]
    267292    } elseif {"" != $job(output) || "" != $job(error)} {
    268293        return [list $status [string trim "$job(output)\n$job(error)"]]
Note: See TracChangeset for help on using the changeset viewer.