-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample2.py
41 lines (34 loc) · 1.23 KB
/
example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from genie_python import genie as g
from genie_python.genie_script_generator import ScriptDefinition, cast_parameters_to
def mytype(string_input):
if string_input == "default":
return 0.0
else:
return float(string_input)
class DoRun(ScriptDefinition):
@cast_parameters_to(temperature=float, field=float, uamps=mytype)
def run(self, temperature=0.0, field=0.0, uamps=0.0):
g.cset("temperature", temperature)
g.cset("field", field)
g.begin()
g.waitfor_uamps(uamps)
g.end()
@cast_parameters_to(temperature=float, field=float, uamps=mytype)
def parameters_valid(self, temperature=0.0, field=0.0, uamps=0.0):
errors = ""
if not 0.1 <= temperature <= 300:
errors += "Temperature outside range\n"
if not -5 <= field < 5:
errors += "Field outside range"
if not -20 <= uamps <= 32:
errors += "uamps outside of range"
if errors != "":
return errors
return None
@cast_parameters_to(temperature=float, field=float, uamps=mytype)
def estimate_time(self, temperature=0.0, field=0.0, uamps=0.0):
return uamps
def get_help(self):
return """
A useful help string
"""