1 | # ---------------------------------------------------------------------- |
---|
2 | # LANGUAGE: MATLAB API |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Michael McLennan, Purdue University |
---|
5 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
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 "MATLAB" { |
---|
11 | extension ".m" |
---|
12 | command {matlab -nodisplay -r infile='@driver',path('@tool',path),@@FILEROOT@@} |
---|
13 | |
---|
14 | main {% ---------------------------------------------------------------------- |
---|
15 | % MAIN PROGRAM - generated by the Rappture Builder |
---|
16 | % ---------------------------------------------------------------------- |
---|
17 | |
---|
18 | % open the XML file containing the run parameters |
---|
19 | % the file name comes in from the command-line via variable 'infile' |
---|
20 | io = rpLib(infile); |
---|
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 | rpUtilsProgress(0, 'Starting...'); |
---|
33 | rpUtilsProgress(5, 'Loading data...'); |
---|
34 | rpUtilsProgress(50, 'Half-way there'); |
---|
35 | rpUtilsProgress(100, 'Done'); |
---|
36 | |
---|
37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
38 | % Save output values back to Rappture |
---|
39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
40 | @@OUTPUTS@@ |
---|
41 | |
---|
42 | rpLibResult(io); |
---|
43 | quit; |
---|
44 | } |
---|
45 | |
---|
46 | input boolean { |
---|
47 | code "\n% get input value for $path" |
---|
48 | code "str = rpLibGetString(io,'$path.current');" |
---|
49 | code "$id = strcmpi(str,'yes');" |
---|
50 | } |
---|
51 | input image { |
---|
52 | code "\n% get input value for $path" |
---|
53 | code "% returns base64-encoded image data" |
---|
54 | code "$id = rpLibGetString(io,'$path.current');" |
---|
55 | } |
---|
56 | input integer { |
---|
57 | code "\n% get input value for $path" |
---|
58 | code "$id = int32(rpLibGetDouble(io,'$path.current'));" |
---|
59 | } |
---|
60 | input number { |
---|
61 | set units [attr get units] |
---|
62 | if {$units ne ""} { |
---|
63 | code "\n% get input value for $path and convert to $units" |
---|
64 | code "str = rpLibGetString(io,'$path.current');" |
---|
65 | code "\[$id,err\] = rpUnitsConvertDbl(str, '$units');" |
---|
66 | } else { |
---|
67 | code "\n% get input value for $path" |
---|
68 | code "$id = rpLibGetDouble(io,'$path.current');" |
---|
69 | } |
---|
70 | } |
---|
71 | input * { |
---|
72 | code "\n% get input value for $path" |
---|
73 | code "$id = rpLibGetString(io,'$path.current');" |
---|
74 | } |
---|
75 | |
---|
76 | output curve { |
---|
77 | code "\n% save output value for $path" |
---|
78 | code "% this assumes a vector 'x' and a vector 'y'" |
---|
79 | code "xydata = \[x;y\];" |
---|
80 | code "str = sprintf('%12g %12g\\n', xydata);" |
---|
81 | code "rpLibPutString(io,'$path.component.xy',str,0);" |
---|
82 | } |
---|
83 | output histogram { |
---|
84 | code "\n% save output value for $path" |
---|
85 | code "% vectors x,h,w: x-coord, height of bar, and width of bar (optional)" |
---|
86 | code "xhwdata = \[x;h;w\];" |
---|
87 | code "str = sprintf('%12g %12g %12g\\n', xhwdata);" |
---|
88 | code "rpLibPutString(io,'$path.component.xhw',str,0);" |
---|
89 | } |
---|
90 | output image { |
---|
91 | code "\n% save output value for $path" |
---|
92 | code "% data should be base64-encoded image data" |
---|
93 | code "rpLibPutString(io,'$path.current',imdata,0);" |
---|
94 | } |
---|
95 | output integer { |
---|
96 | code "\n% save output value for $path" |
---|
97 | code "rpLibPutString(io,'$path.current',num2str($id),0);" |
---|
98 | } |
---|
99 | output number { |
---|
100 | code "\n% save output value for $path" |
---|
101 | code "rpLibPutString(io,'$path.current',num2str($id),0);" |
---|
102 | } |
---|
103 | output * { |
---|
104 | code "\n% save output value for $path" |
---|
105 | code "rpLibPutString(io,'$path.current',$id,0);" |
---|
106 | } |
---|
107 | } |
---|