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 |
---|
13 | # Purdue Research Foundation, West Lafayette, IN |
---|
14 | # ====================================================================== |
---|
15 | |
---|
16 | namespace eval Rappture { # forward declaration } |
---|
17 | |
---|
18 | # ---------------------------------------------------------------------- |
---|
19 | # USAGE: result <libraryObj> ?<status>? |
---|
20 | # |
---|
21 | # This utility takes the <libraryObj> representing a run (driver file |
---|
22 | # plus outputs) and writes it out to the run file. It should be called |
---|
23 | # within a simulator at the end of simulation, to communicate back |
---|
24 | # the results. |
---|
25 | # |
---|
26 | # If the optional <status> is specified, then it represents the exit |
---|
27 | # status code for the tool. "0" means "ok" and anything non-zero means |
---|
28 | # "failed". |
---|
29 | # ---------------------------------------------------------------------- |
---|
30 | proc Rappture::result {libobj {status 0}} { |
---|
31 | $libobj put output.time [clock format [clock seconds]] |
---|
32 | if {$status != 0} { |
---|
33 | $libobj put output.status "failed" |
---|
34 | } else { |
---|
35 | $libobj put output.status "ok" |
---|
36 | } |
---|
37 | |
---|
38 | set oname "run[clock seconds].xml" |
---|
39 | set fid [open $oname w] |
---|
40 | puts $fid "<?xml version=\"1.0\"?>" |
---|
41 | puts $fid [$libobj xml] |
---|
42 | close $fid |
---|
43 | |
---|
44 | if {$status == 0} { |
---|
45 | puts "=RAPPTURE-RUN=>$oname" |
---|
46 | } |
---|
47 | } |
---|