1 | # ---------------------------------------------------------------------- |
---|
2 | # EXAMPLE: Rappture <number> elements |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Martin Hunt, Purdue University |
---|
5 | # Copyright (c) 2015 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 | |
---|
11 | import Rappture |
---|
12 | import sys |
---|
13 | |
---|
14 | # uncomment these for debugging |
---|
15 | # sys.stderr = open('tool.err', 'w') |
---|
16 | # sys.stdout = open('tool.out', 'w') |
---|
17 | |
---|
18 | rx = Rappture.PyXml(sys.argv[1]) |
---|
19 | |
---|
20 | # The example this is based on did a copy of the inputs |
---|
21 | # to outputs, like below. This is very efficient, but |
---|
22 | # would not be a normal thing to do. |
---|
23 | # rx.copy('output.number(outt)', 'input.(temperature)') |
---|
24 | # rx.copy('output.number(outv)', 'input.(vsweep)') |
---|
25 | |
---|
26 | temp = rx['input.(temperature).current'].value |
---|
27 | |
---|
28 | # If we need a unitless float, then this is necessary. |
---|
29 | # But in this example, we do not because Rappture accepts |
---|
30 | # numbers with units for the value. |
---|
31 | # temp = float(Rappture.Units.convert(temp, to='K', units='off')) |
---|
32 | |
---|
33 | vsweep = rx['input.(vsweep).current'].value |
---|
34 | # vsweep = float(Rappture.Units.convert(vsweep, to='V', units='off')) |
---|
35 | |
---|
36 | rx['output.number(temperature).about.label'] = 'Ambient temperature' |
---|
37 | rx['output.number(temperature).units'] = 'K' |
---|
38 | rx['output.number(temperature).current'] = temp |
---|
39 | |
---|
40 | rx['output.number(vsweep).about.label'] = 'Voltage Sweep' |
---|
41 | rx['output.number(vsweep).units'] = 'V' |
---|
42 | rx['output.number(vsweep).current'] = vsweep |
---|
43 | |
---|
44 | rx.close() |
---|