ExamplePollVectorData#

 1// ExamplePollVectorData connects to the device, requests data from
 2// vector nodes, and polls until data is received.
 3public static void ExamplePollVectorData(string dev = DEFAULT_DEVICE)
 4{
 5  ziDotNET daq = connect(dev);
 6
 7  // This example only works for devices with the AWG option
 8  if (hasOption(daq, dev, "AWG") || isDeviceFamily(daq, dev, "UHFQA") || isDeviceFamily(daq, dev, "UHFAWG") || isDeviceFamily(daq, dev, "HDAWG"))
 9  {
10    resetDeviceToDefault(daq, dev);
11
12    // Request vector node from device
13    String path = String.Format("/{0}/awgs/0/waveform/waves/0", dev);
14    daq.getAsEvent(path);
15
16    // Poll until the node path is found in the result data
17    double timeout = 20;
18    double poll_time = 0.1;
19    Lookup lookup = null;
20    for (double time = 0; ; time += poll_time)
21    {
22      lookup = daq.poll(poll_time, 100, 0, 1);
23      if (lookup.nodes.ContainsKey(path))
24        break;
25      if (time > timeout)
26        Fail("Vector node data not received within timeout");
27    }
28
29    Chunk[] chunks = lookup[path]; // Iterable chunks
30    Chunk chunk = chunks[0];       // Single chunk
31    ZIVectorData vectorData = chunk.vectorData[0];
32
33    // The vector attribute of a ZIVectorData object holds a ZIVector object,
34    // which can contain a String or arrays of the following types:
35    // byte, UInt16, Uint32, Uint64, float, double
36
37    // Waveform vector data is stored as 32-bit unsigned integer
38    if (vectorData.vector != null)  // Check for empty container
39    {
40      UInt32[] vector = vectorData.vector.data as UInt32[];
41    }
42
43    AssertNotEqual(0ul, vectorData.timeStamp);
44  }
45  daq.disconnect();
46}