Line | |
---|
1 | # ---------------------------------------------------------------------- |
---|
2 | # GRAPH |
---|
3 | # |
---|
4 | # This simple example shows how you can use the Rappture toolkit |
---|
5 | # to handle I/O for a simple simulator--in this case, one that |
---|
6 | # evaluates an x/y graph |
---|
7 | # |
---|
8 | # ====================================================================== |
---|
9 | # AUTHOR: Michael McLennan, Purdue University |
---|
10 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
11 | # |
---|
12 | # See the file "license.terms" for information on usage and |
---|
13 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | # ====================================================================== |
---|
15 | |
---|
16 | import Rappture |
---|
17 | import sys |
---|
18 | from math import * |
---|
19 | |
---|
20 | io = Rappture.library(sys.argv[1]) |
---|
21 | |
---|
22 | xmin = float(io.get('input.number(min).current')) |
---|
23 | xmax = float(io.get('input.number(max).current')) |
---|
24 | formula = io.get('input.string(formula).current') |
---|
25 | print 'formula = %s' % formula |
---|
26 | npts = 100 |
---|
27 | |
---|
28 | for i in range(npts): |
---|
29 | x = (xmax-xmin)/npts * i + xmin; |
---|
30 | y = eval(formula) |
---|
31 | io.put('output.curve.component.xy', '%g %g\n' % (x,y), append=1) |
---|
32 | |
---|
33 | Rappture.result(io) |
---|
Note: See
TracBrowser
for help on using the repository browser.