using System;
using System.Linq;
using A1560APICOM;

namespace MinimalExample
{
    class Program
    {
        private static readonly A1560 A1560 = new A1560();
        static void Main(string[] args)
        {
            A1560.Connect("192.168.1.2");
            //Automatic acquisition is assumed running on connect, stop it.
            A1560.Stop();
            //Set Device to make one measurement per Start() command
            A1560.TriggeringMode = 0;
            //Subscribe dedicated processing function to be called for each new vector.
            A1560.DataReceived += A1560OnDataReceived;
            //Launch 
            A1560.Start();
            //Keep application alive for a moment (so we can see the vector event) 
            Console.ReadKey();
            A1560.Disconnect();
        }

        private static void A1560OnDataReceived(AcquisitionData data)
        {
            var vector = data.Vector;
            Console.WriteLine($"Vector received, Length: {vector.Length} samples, CTP={data.Ctp[0]:X08}:{data.Ctp[1]:X08}:{data.Ctp[2]:X08}, maximum sample value = {vector.Max()} ");
            //Unsubscribe, since we’re getting only one vector in this app.
            A1560.DataReceived -= A1560OnDataReceived;
            //Inform users they can leave now
            Console.WriteLine("Press any key to exit");
        }
       
    }
}

