source: trunk/lang/tcl/scripts/result.tcl @ 1090

Last change on this file since 1090 was 1018, checked in by gah, 16 years ago

Massive changes: New directory/file layout

  • Property svn:keywords set to Date Rev
File size: 2.2 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: result - use this to report results
3#
4#  This utility makes it easy to report results at the end of a
5#  run within a simulator.  It takes the XML object containing the
6#  inputs and outputs and writes it out to a "run" file with an
7#  automatically generated name.  Then, it writes out the name
8#  of the run file as "=RAPPTURE-RUN=>name" so the Rappture GUI
9#  knows the name of the result file.
10# ======================================================================
11#  AUTHOR:  Michael McLennan, Purdue University
12#  Copyright (c) 2004-2005  Purdue Research Foundation
13#
14#  See the file "license.terms" for information on usage and
15#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16# ======================================================================
17
18namespace eval Rappture { # forward declaration }
19
20# ----------------------------------------------------------------------
21# USAGE: result <libraryObj> ?<status>?
22#
23# This utility takes the <libraryObj> representing a run (driver file
24# plus outputs) and writes it out to the run file.  It should be called
25# within a simulator at the end of simulation, to communicate back
26# the results.
27#
28# If the optional <status> is specified, then it represents the exit
29# status code for the tool.  "0" means "ok" and anything non-zero means
30# "failed".
31# ----------------------------------------------------------------------
32proc Rappture::result {libobj {status 0}} {
33    global tcl_platform
34
35    $libobj put output.time [clock format [clock seconds]]
36    if {$status != 0} {
37        $libobj put output.status "failed"
38    } else {
39        $libobj put output.status "ok"
40    }
41
42    $libobj put tool.version.rappture.revision "\$LastChangedRevision: 1018 $"
43    $libobj put tool.version.rappture.modified "\$LastChangedDate: 2008-06-09 01:24:34 +0000 (Mon, 09 Jun 2008) $"
44    $libobj put tool.version.rappture.language "tcl"
45
46    if {[info exists tcl_platform(user)]} {
47        $libobj put output.user $tcl_platform(user)
48    }
49
50    set oname "run[clock seconds].xml"
51    set fid [open $oname w]
52    puts $fid "<?xml version=\"1.0\"?>"
53    puts $fid [$libobj xml]
54    close $fid
55
56    if {$status == 0} {
57        puts "=RAPPTURE-RUN=>$oname"
58    }
59}
Note: See TracBrowser for help on using the repository browser.