source: trunk/gui/scripts/tool.tcl @ 5092

Last change on this file since 5092 was 4970, checked in by mmc, 9 years ago

Fixed auto-execution via TOOL_PARAMETERS to produce status output in a
file called rappture.status. This makes it easier for the web service
to monitor progress and know when everything is finished. Also, fixed
auto-execution to move the run file to the data/results directory and
clean up the original driver file.

File size: 2.6 KB
RevLine 
[3330]1# -*- mode: tcl; indent-tabs-mode: nil -*-
[11]2# ----------------------------------------------------------------------
3#  COMPONENT: tool - represents an entire tool
4#
5#  This object represents an entire tool defined by Rappture.
6#  Each tool resides in an installation directory with other tool
7#  resources (libraries, examples, etc.).  Each tool is defined by
8#  its inputs and outputs, which are tied to various widgets in the
9#  GUI.  Each tool tracks the inputs, knows when they're changed,
10#  and knows how to run itself to produce new results.
11# ======================================================================
12#  AUTHOR:  Michael McLennan, Purdue University
[4127]13#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
[115]14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
[11]17# ======================================================================
18
19itcl::class Rappture::Tool {
[22]20    inherit Rappture::ControlOwner
[11]21
[4127]22    constructor {xmlobj installdir} {
[1929]23        Rappture::ControlOwner::constructor ""
[22]24    } { # defined below }
[11]25
[2164]26    destructor { # defined below }
27
[4127]28    public method installdir {} {
29        return [$_task installdir]
30    }
31    public method run {args} {
32        sync  ;# sync all widget values to XML
[4970]33
34        foreach {status result} [eval $_task run $args] break
35        if {$status == 0} {
36            # move good results to the data/results directory
37            $_task save $result
38        }
39
40        return [list $status $result]
[4127]41    }
42    public method abort {} {
43        $_task abort
44    }
45    public method reset {} {
46        $_task reset
47    }
[11]48
[4127]49    private variable _task ""  ;# underlying task for the tool
[11]50
[4127]51    # global resources for this tool session (from task)
52    public proc resources {{option ""}} {
53        eval ::Rappture::Task::resources $option
54    }
[11]55}
[413]56
[11]57# ----------------------------------------------------------------------
58# CONSTRUCTOR
59# ----------------------------------------------------------------------
[4127]60itcl::body Rappture::Tool::constructor {xmlobj installdir} {
[11]61    if {![Rappture::library isvalid $xmlobj]} {
[1929]62        error "bad value \"$xmlobj\": should be Rappture::Library"
[11]63    }
64
[4127]65    set _task [Rappture::Task ::#auto $xmlobj $installdir \
66        -logger ::Rappture::Logger::log]
[2164]67
[4127]68    # save a reference to the tool XML in the ControlOwner
69    set _xmlobj $xmlobj
[11]70}
71
72# ----------------------------------------------------------------------
[2164]73# DESTRUCTOR
74# ----------------------------------------------------------------------
75itcl::body Rappture::Tool::destructor {} {
[4127]76    itcl::delete object $_task
[2164]77}
Note: See TracBrowser for help on using the repository browser.