forked from Doridian/NetDAQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
78 lines (61 loc) · 2.21 KB
/
__main__.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
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
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
from lib.netdaq import NetDAQ
from lib.config.instrument import DAQConfiguration, DAQConfigTrigger
from lib.config.enums import *
from lib.config.channels.analog import *
from lib.config.channels.computed import *
from lib.config.equation import DAQEquation
from lib.config.equation_compiler import DAQEQuationCompiler
from sys import argv
from asyncio import run, sleep
async def main3():
eqc = DAQEQuationCompiler()
print(eqc.compile("1 + 3 + 4 + 5 + 6 + 7d + ln(c5) * -35.3e+8 ** 4 / -ln((-C7))"))
print(eqc.compile("C1 + C2 + C3 + C4 + C5"))
async def main2():
eq = DAQEquation()
print(eq.push_channel(1).push_float(1).add().end().encode())
async def main():
instrument = NetDAQ(ip=argv[1], port=4369)
await instrument.connect()
try:
await instrument.ping()
print("Base channel", await instrument.get_base_channel())
print("Version info", await instrument.get_version_info())
await instrument.wait_for_idle()
await instrument.stop()
await instrument.set_monitor_channel(0)
print("LC version", await instrument.get_lc_version())
await instrument.set_time()
print("Time set!")
eq = DAQEquation().push_channel(1).push_double(123456789.0).add().end()
await instrument.set_config(
DAQConfiguration(
triggers=[DAQConfigTrigger.INTERVAL],
interval_time=0.5,
analog_channels=[
DAQAnalogVDCChannel(
range=DAQVDCRange.VDC_3V,
),
],
computed_channels=[
DAQComputedEquationChannel(
equation=eq,
)
],
)
)
print("Config set!")
await instrument.reset_totalizer()
await instrument.start()
await instrument.set_monitor_channel(1)
while True:
readings = await instrument.get_readings()
print(readings)
if readings.instrument_queue == 0:
await sleep(1)
finally:
print("Clean shutdown...")
await instrument.close()
print("Done!")
run(main3())