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
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
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
13#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17# ======================================================================
18
19itcl::class Rappture::Tool {
20    inherit Rappture::ControlOwner
21
22    constructor {xmlobj installdir} {
23        Rappture::ControlOwner::constructor ""
24    } { # defined below }
25
26    destructor { # defined below }
27
28    public method installdir {} {
29        return [$_task installdir]
30    }
31    public method run {args} {
32        sync  ;# sync all widget values to XML
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]
41    }
42    public method abort {} {
43        $_task abort
44    }
45    public method reset {} {
46        $_task reset
47    }
48
49    private variable _task ""  ;# underlying task for the tool
50
51    # global resources for this tool session (from task)
52    public proc resources {{option ""}} {
53        eval ::Rappture::Task::resources $option
54    }
55}
56
57# ----------------------------------------------------------------------
58# CONSTRUCTOR
59# ----------------------------------------------------------------------
60itcl::body Rappture::Tool::constructor {xmlobj installdir} {
61    if {![Rappture::library isvalid $xmlobj]} {
62        error "bad value \"$xmlobj\": should be Rappture::Library"
63    }
64
65    set _task [Rappture::Task ::#auto $xmlobj $installdir \
66        -logger ::Rappture::Logger::log]
67
68    # save a reference to the tool XML in the ControlOwner
69    set _xmlobj $xmlobj
70}
71
72# ----------------------------------------------------------------------
73# DESTRUCTOR
74# ----------------------------------------------------------------------
75itcl::body Rappture::Tool::destructor {} {
76    itcl::delete object $_task
77}
Note: See TracBrowser for help on using the repository browser.