Using Chunk Data in CVB

The same example in .NET:

using System;
using Stemmer.Cvb;
using Stemmer.Cvb.Driver;
using Stemmer.Cvb.GenApi;

namespace CVB_UsingChunkDataFromNodemap
{
  internal class Program
  {
    static void Main(string[] args)
    {
      DiscoveryInformationList discoveryList = DeviceFactory.Discover(DiscoverFlags.IgnoreVins);
      //Enable ChunkMode on Driver
      discoveryList[0].SetParameter("AttachChunk", "1");
      using (Device device = DeviceFactory.Open(discoveryList[0].AccessToken))
      {
        Stream stream = device.Stream;
        NodeMap deviceNodeMap = device.NodeMaps[NodeMapNames.Device];

        //Enable ChunkMode in device NodeMap
        BooleanNode ChunkModeActive = deviceNodeMap["Std::ChunkModeActive"] as BooleanNode;
        ChunkModeActive.Value = true;

        long TimestampPrevious = 0;
        stream.Start();
        for (int i = 0; i < 10; i++)
        {
          using (var image = stream.Wait(out WaitStatus status))
          {
            //this is valid, well defined until new wait returns
            IntegerNode ChunkTimestampNode = deviceNodeMap["Std::ChunkTimestamp"] as IntegerNode;
            long Chunk_Timestamp = ChunkTimestampNode.Value;
            long TSP_Diff = Chunk_Timestamp - TimestampPrevious;
            TimestampPrevious = Chunk_Timestamp;
            Console.WriteLine("FrameID: " + i + " Timestamp: " + image.RawTimestamp + " Chunk Timestamp: " + Chunk_Timestamp + " Difference to previous Frame: " + TSP_Diff);
          }
        }
        stream.Stop();
      }

      Console.ReadLine();
    }
  }
}
3 Likes