-
Notifications
You must be signed in to change notification settings - Fork 6
/
playground.py
44 lines (30 loc) · 1.19 KB
/
playground.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
import numpy as np
from PyDAQmx import *
class CallbackTask(Task):
def __init__(self):
Task.__init__(self)
self.data = np.zeros(1000)
self.a = []
self.CreateAIVoltageChan("cDAQ1Mod2/ai0", "", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, None)
self.CfgSampClkTiming("", 10000.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000)
self.AutoRegisterEveryNSamplesEvent(DAQmx_Val_Acquired_Into_Buffer, 1000, 0)
self.AutoRegisterDoneEvent(0)
def EveryNCallback(self):
read = int32()
self.ReadAnalogF64(1000, 10.0, DAQmx_Val_GroupByChannel, self.data, 1000, byref(read), None)
self.a.extend(self.data.tolist())
if len(self.a) > 10000:
print('a getting big', len(self.a))
self.Complete()
return 0 # The function should return an integer
def DoneCallback(self, status):
print("Status", status.value)
return 0 # The function should return an integer
def Complete(self):
self.StopTask()
self.ClearTask()
task = CallbackTask()
task.StartTask()
input('Acquiring samples continuously. Press Enter to interrupt\n')
# task.StopTask()
# task.ClearTask()