-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathioniclient_demo.py
More file actions
69 lines (49 loc) · 1.94 KB
/
Copy pathioniclient_demo.py
File metadata and controls
69 lines (49 loc) · 1.94 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#################################################
# #
# Ionicon WebAPI - usage example #
# #
#################################################
import os
import time
import json
import ioniclient
client = ioniclient.IoniClient('localhost', port=8002)
print('# Example 1: Quick measurement (with default filename) for 10 seconds, then stop')
print(client.start_measurement())
time.sleep(10)
print(client.stop_measurement())
print('# Example 2: Measurement with filename, for 10 seconds, then stop')
folder = os.path.join('D:', 'Data')
os.makedirs(folder, exist_ok=True)
filename = time.strftime("example2_%m-%d-%Y_%H-%M-%S", time.localtime())
path = os.path.join(folder, filename)
print(client.start_measurement(path))
time.sleep(10)
print(client.stop_measurement())
print('# Example 3: Start measurement, print some TPS parameters')
print(client.start_measurement())
for parameter in ['TPS_Pull_L', 'TPS_Lens1', 'DPS_Udrift', 'E/N', 'Press_Foreline']:
raw = client.get(parameter)
data = json.loads(raw)
setv = data[0]['Act']
print(data[0]['Name'], setv['Real'], setv['Unit'], setv['Time'])
print(client.stop_measurement())
print('# Example 4: Start measurement, for 10 seconds, print the first few calc traces')
print(client.start_measurement())
for i in range(10):
traces = client.get_traces()
if not traces:
continue
parsed = json.loads(traces)
for name, value in zip(parsed["CalcTracesNames"], parsed["CalcTraces"]):
print(name, value)
print(client.stop_measurement())
print('# Example 5: use API to set TPS parameters')
prev = client.get('DPS_Udrift')
data = json.loads(prev)
original = data[0]['Set']['Real']
print('scanning drift voltage in 100 V steps...')
for voltage in range(400, 700, 100):
client.set('DPS_Udrift', voltage)
print(client.get('DPS_Udrift'))
client.set('DPS_Udrift', original)