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

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

  • Property svn:keywords set to Date Rev
File size: 2.4 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-2012  HUBzero Foundation, LLC
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: 3177 $"
43    $libobj put tool.version.rappture.modified "\$LastChangedDate: 2012-09-21 17:01:16 +0000 (Fri, 21 Sep 2012) $"
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    # fake milliseconds by using clock clicks
51    # fake microseconds by using 000
52    # this will be fixed when tcl uses C bindings
53    set timestamp [format %d%03d%03d [clock seconds] [expr [clock clicks -milliseconds]%1000] 0]
54    set oname "run$timestamp.xml"
55    set fid [open $oname w]
56    puts $fid "<?xml version=\"1.0\"?>"
57    puts $fid [$libobj xml]
58    close $fid
59
60    if {$status == 0} {
61        puts "=RAPPTURE-RUN=>$oname"
62    }
63}
Note: See TracBrowser for help on using the repository browser.