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 | |
---|
18 | namespace 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 | # ---------------------------------------------------------------------- |
---|
32 | proc 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 | if {[info exists tcl_platform(user)]} { |
---|
43 | $libobj put output.user $tcl_platform(user) |
---|
44 | } |
---|
45 | |
---|
46 | set oname "run[clock seconds].xml" |
---|
47 | set fid [open $oname w] |
---|
48 | puts $fid "<?xml version=\"1.0\"?>" |
---|
49 | puts $fid [$libobj xml] |
---|
50 | close $fid |
---|
51 | |
---|
52 | if {$status == 0} { |
---|
53 | puts "=RAPPTURE-RUN=>$oname" |
---|
54 | } |
---|
55 | } |
---|