Exemplo n.º 1
0
        static void Main()
        {
            Console.WriteLine("C# PS5000a driver example program");
            Console.WriteLine("Version 1.2\n");

            //open unit and show splash screen
            Console.WriteLine("\nOpening the device...");
            short handle;
            uint  status = Imports.OpenUnit(out handle, null, Imports.DeviceResolution.PS5000A_DR_8BIT);
            bool  powerSupplyConnected = true;

            Console.WriteLine("Handle: {0}", handle);

            if (status != Imports.PICO_OK && handle != 0)
            {
                status = Imports.ChangePowerSource(handle, status);
                powerSupplyConnected = false;
            }

            if (status != Imports.PICO_OK)
            {
                Console.WriteLine("Unable to open device");
                Console.WriteLine("Error code : {0}", status);
                WaitForKey();
            }
            else
            {
                Console.WriteLine("Device opened successfully\n");

                StreamingCon consoleExample = new StreamingCon(handle, powerSupplyConnected);
                consoleExample.Run();

                Imports.CloseUnit(handle);
            }
        }
        static void Main()
        {
            Console.WriteLine("PicoScope 5000 Series (ps5000a) Driver Streaming Data Collection Example Program.");
            Console.WriteLine("Version 1.3\n");

            Console.WriteLine("Enumerating devices...\n");

            short         count         = 0;
            short         serialsLength = 40;
            StringBuilder serials       = new StringBuilder(serialsLength);

            uint status = Imports.EnumerateUnits(out count, serials, ref serialsLength);

            if (status != StatusCodes.PICO_OK)
            {
                Console.WriteLine("No devices found.\n");
                Console.WriteLine("Error code : {0}", status);
                Console.WriteLine("Press any key to exit.\n");
                WaitForKey();
                Environment.Exit(0);
            }
            else
            {
                if (count == 1)
                {
                    Console.WriteLine("Found {0} device:", count);
                }
                else
                {
                    Console.WriteLine("Found {0} devices", count);
                }

                Console.WriteLine("Serial(s) {0}", serials);
            }

            //open unit and show splash screen
            Console.WriteLine("\nOpening device...");
            short handle;

            status = Imports.OpenUnit(out handle, null, Imports.DeviceResolution.PS5000A_DR_8BIT);
            bool powerSupplyConnected = true;

            Console.WriteLine("Handle: {0}", handle);

            if (status == StatusCodes.PICO_POWER_SUPPLY_NOT_CONNECTED)
            {
                status = Imports.ChangePowerSource(handle, status);
                powerSupplyConnected = false;
            }
            else if (status != StatusCodes.PICO_OK)
            {
                Console.WriteLine("Cannot open device error code: " + status.ToString());
                System.Environment.Exit(-1);
            }
            else
            {
                // Do nothing - power supply connected
            }

            if (status != StatusCodes.PICO_OK)
            {
                Console.WriteLine("Unable to open device.");
                Console.WriteLine("Error code : {0}", status);
                WaitForKey();
            }
            else
            {
                Console.WriteLine("Device opened successfully.\n");

                StreamingCon consoleExample = new StreamingCon(handle, powerSupplyConnected);
                consoleExample.Run();

                Imports.CloseUnit(handle);
            }
        }