1 | # ---------------------------------------------------------------------- |
---|
2 | # LANGUAGE: Perl API |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Michael McLennan, Purdue University |
---|
5 | # Copyright (c) 2004-2011 Purdue Research Foundation |
---|
6 | # |
---|
7 | # See the file "license.terms" for information on usage and |
---|
8 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
9 | # ====================================================================== |
---|
10 | language "Perl" { |
---|
11 | extension ".pl" |
---|
12 | command {perl @tool/@@FILENAME@@ @driver} |
---|
13 | |
---|
14 | main {# ---------------------------------------------------------------------- |
---|
15 | # MAIN PROGRAM - generated by the Rappture Builder |
---|
16 | # ---------------------------------------------------------------------- |
---|
17 | use Rappture; |
---|
18 | |
---|
19 | # open the XML file containing the run parameters |
---|
20 | $io = Rappture::RpLibrary->new($ARGV[0]); |
---|
21 | |
---|
22 | ######################################################### |
---|
23 | # Get input values from Rappture |
---|
24 | ######################################################### |
---|
25 | @@INPUTS@@ |
---|
26 | |
---|
27 | ######################################################### |
---|
28 | # Add your code here for the main body of your program |
---|
29 | ######################################################### |
---|
30 | |
---|
31 | # spit out progress messages as you go along... |
---|
32 | Rappture::Utils::progress(0, "Starting..."); |
---|
33 | Rappture::Utils::progress(5, "Loading data..."); |
---|
34 | Rappture::Utils::progress(50, "Half-way there"); |
---|
35 | Rappture::Utils::progress(100, "Done"); |
---|
36 | |
---|
37 | ######################################################### |
---|
38 | # Save output values back to Rappture |
---|
39 | ######################################################### |
---|
40 | @@OUTPUTS@@ |
---|
41 | |
---|
42 | $io->result(); |
---|
43 | exit 0; |
---|
44 | } |
---|
45 | |
---|
46 | input boolean { |
---|
47 | code "\n# get input value for $path" |
---|
48 | code "# returns value as string \"yes\" or \"no\"" |
---|
49 | code "\$str = \$io->get(\"$path.current\");" |
---|
50 | code "\$$id = (\$str) ? \"yes\" : \"no\";" |
---|
51 | } |
---|
52 | input image { |
---|
53 | code "\n# get input value for $path" |
---|
54 | code "# returns base64-encoded image data" |
---|
55 | code "\$$id = \$io->get(\"$path.current\");" |
---|
56 | } |
---|
57 | input number { |
---|
58 | set units [attr get units] |
---|
59 | if {$units ne ""} { |
---|
60 | code "\n# get input value for $path and convert to $units" |
---|
61 | code "\$str = \$io->get(\"$path.current\");" |
---|
62 | code "$$id = Rappture::RpUnits::convert(\$str, \"$units\", \"off\");" |
---|
63 | } else { |
---|
64 | code "\n# get input value for $path" |
---|
65 | code "\$$id = \$io->get(\"$path.current\");" |
---|
66 | } |
---|
67 | } |
---|
68 | input * { |
---|
69 | code "\n# get input value for $path" |
---|
70 | code "\$$id = \$io->get(\"$path.current\");" |
---|
71 | } |
---|
72 | |
---|
73 | output curve { |
---|
74 | code "\n# save output value for $path" |
---|
75 | code "# this shows just one (x,y) point -- modify as needed" |
---|
76 | code "\$io->put(\"$path.component.xy\", \"\$x \$y\\n\", 1);" |
---|
77 | } |
---|
78 | output histogram { |
---|
79 | code "\n# save output value for $path" |
---|
80 | code "# this shows just one point -- modify as needed" |
---|
81 | code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)" |
---|
82 | code "\$io->put(\"$path.component.xhw\", \"\$x \$h \$w\\n\", 1);" |
---|
83 | } |
---|
84 | output image { |
---|
85 | code "\n# save output value for $path" |
---|
86 | code "# data in \$$id should be base64-encoded image data" |
---|
87 | code "\$io->put(\"$path.current\", \$$id, 0);" |
---|
88 | } |
---|
89 | output * { |
---|
90 | code "\n# save output value for $path" |
---|
91 | code "\$io->put(\"$path.current\", \$$id, 0);" |
---|
92 | } |
---|
93 | } |
---|