ExamplePollDemodSampleΒΆ

 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
// ExamplePollDemodSample connects to the device,
// subscribes to a demodulator, polls the data for 0.1 s
// and returns the data.
public static void ExamplePollDemodSample(string dev = DEFAULT_DEVICE)
{
  ziDotNET daq = connect(dev);
  SkipForDeviceFamily(daq, dev, "HDAWG");

  resetDeviceToDefault(daq, dev);
  String path = String.Format("/{0}/demods/0/sample", dev);
  daq.subscribe(path);
  // After the subscribe, poll() can be executed continuously within a loop.
  // Arguments to poll() are:
  // - 'duration': poll duration in seconds
  // - 'timeOutMilliseconds': timeout to wait for any packet from data server
  // - 'flags': combination of poll flags that determine the
  //   behavior upon sample loss (see e.g., Python API for more information)
  // - 'bufferSize': should be provided as 1 and will be removed in a
  //   future version
  Lookup lookup = daq.poll(0.1, 100, 0, 1);
  Dictionary<String, Chunk[]> nodes = lookup.nodes;  // Iterable nodes
  Chunk[] chunks = lookup[path];  // Iterable chunks
  Chunk chunk = lookup[path][0];  // Single chunk
                                  // Vector of samples
  ZIDemodSample[] demodSamples = lookup[path][0].demodSamples;
  // Single sample
  ZIDemodSample demodSample0 = lookup[path][0].demodSamples[0];
  daq.disconnect();

  Debug.Assert(0 != demodSample0.timeStamp);
}