-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtestdaq.js
121 lines (88 loc) · 3 KB
/
testdaq.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var daqmx = require('./build/Release/nodedaqmx');
try{
console.log(daqmx.devices());
/*
// Continuous samples, internal clock, digital start trigger
var task = new daqmx.AIVoltageTask({
name: "myAIVoltageTask", // optional name for task, default ""
device: "Dev1", // physical device name
channels: [{ // array of objects specifying the channels to acquire
terminal: "ai0", // physical terminal name
assignName: "someChannelName" // optional name for channel
minVal: -10.0, // optional, default -10.0
maxVal: 10.0 // optional, default 10.0
}],
sampleTiming: { // timing for individual samples
terminal: "OnboardClock", // optional, default is 'OnboardClock'
rate: 10000.0, // sample rate in Hz
triggerSlope: "falling", // optional, default rising
sampleMode: "continuous", // optional, default finite
samplesPerChannel: 10 // max number of samples to read per round
},
startTiming: { // optional timing for when to start the task
type: "digital", // analog, or digital
terminal: "PFI0",
triggerSlope: "falling" // optional, default rising
}
});
// finite samples, external clock, analog start trigger with hysterisis
var task = new daqmx.AIVoltageTask({
name: "myAIVoltageTask",
device: "Dev1",
channels: [{
terminal: "ai0",
minVal: -10.0,
maxVal: 10.0
}],
sampleTiming: {
terminal: "PFI7",
rate: 10000.0,
triggerSlope: "rising",
sampleMode: "finite",
samplesPerChannel: 10
},
startTiming: {
type: "analog",
terminal: "APFI0",
triggerSlope: "rising", // optional, default rising
triggerLevel: 1.0, // analog trigger only in volts
hysteresis: 1.0 // optional for analog trigger only, default 0.0
}
});
*/
// geterdone example with two channels
var task = new daqmx.AIVoltageTask({
device: "Dev1",
channels: [{terminal: "ai0:3"}],
sampleTiming: {
rate: 10000.0,
samplesPerChannel: 10
}
});
task.start();
var x = task.read(); // infinite timeout
console.log(x);
/*
// restart same task
task.stop();
task.start();
// do a read asyncronously
var readAsync = function(callback) {
process.nextTick(function(){
// call canRead without argument tests if all samples can be read
if (task.canRead()) {
var data = task.read(0.0); // no timeout because I know its ready
callback(data);
}else{
// not ready so wait until next tick
readAsync(callback);
}
});
};
readAsync(function(data){
console.log(data);
});
*/
}catch(e){
console.log(e);
}