コード例 #1
0
ファイル: Main.cs プロジェクト: MartinWeigel/PeakToPeakoscope
        public void Run()
        {
            osc = new OSC("127.0.0.1", 5500);

            // setup devices
            _channelSettings = new ChannelSettings[MAX_CHANNELS];
            for (int i = 0; i < MAX_CHANNELS; i++)
            {
                _channelSettings[i].enabled = (i < ENABLED_CHANNELS);
                _channelSettings[i].DCcoupled = Imports.PS6000Coupling.PS6000_DC_1M;
                _channelSettings[i].range = VOLTAGE_RANGE;
            }
            SetDefaults();

            Console.WriteLine("Press a key to start.");
            WaitForKey();

            // Allocate storage for buffers
            uint sampleCount = BUFFER_SIZE * 100; /*  *100 is to make sure buffer large enough */
            for (int i = 0; i < ENABLED_CHANNELS; i++) // create data buffers
            {
                minBuffers[i] = new short[sampleCount];
                maxBuffers[i] = new short[sampleCount];
                minPinned[i] = new PinnedArray<short>(minBuffers[i]);
                maxPinned[i] = new PinnedArray<short>(maxBuffers[i]);
                Imports.SetDataBuffers(
                    _handle,
                    (Imports.Channel)i,
                    minBuffers[i],
                    maxBuffers[i],
                    (int)sampleCount,
                    Imports.PS6000DownSampleRatioMode.PS6000_RATIO_MODE_AGGREGATE
                );
            }

            // main loop - read key and call routine
            char ch = ' ';
            while (ch != 'X')
            {
                BlockDataHandler();
                if (Console.KeyAvailable)
                    ch = char.ToUpper(Console.ReadKey(true).KeyChar);
            }

            // Deallocate storage for buffers
            foreach (PinnedArray<short> p in minPinned)
            {
                if (p != null)
                    p.Dispose();
            }
            foreach (PinnedArray<short> p in maxPinned)
            {
                if (p != null)
                    p.Dispose();
            }
        }
コード例 #2
0
        public void Run()
        {
            osc = new OSC("127.0.0.1", 5500);

            // setup devices
            _channelSettings = new ChannelSettings[MAX_CHANNELS];
            for (int i = 0; i < MAX_CHANNELS; i++)
            {
                _channelSettings[i].enabled   = (i < ENABLED_CHANNELS);
                _channelSettings[i].DCcoupled = Imports.PS6000Coupling.PS6000_DC_1M;
                _channelSettings[i].range     = VOLTAGE_RANGE;
            }
            SetDefaults();

            Console.WriteLine("Press a key to start.");
            WaitForKey();

            // Allocate storage for buffers
            uint sampleCount = BUFFER_SIZE * 100;      /*  *100 is to make sure buffer large enough */

            for (int i = 0; i < ENABLED_CHANNELS; i++) // create data buffers
            {
                minBuffers[i] = new short[sampleCount];
                maxBuffers[i] = new short[sampleCount];
                minPinned[i]  = new PinnedArray <short>(minBuffers[i]);
                maxPinned[i]  = new PinnedArray <short>(maxBuffers[i]);
                Imports.SetDataBuffers(
                    _handle,
                    (Imports.Channel)i,
                    minBuffers[i],
                    maxBuffers[i],
                    (int)sampleCount,
                    Imports.PS6000DownSampleRatioMode.PS6000_RATIO_MODE_AGGREGATE
                    );
            }


            // main loop - read key and call routine
            char ch = ' ';

            while (ch != 'X')
            {
                BlockDataHandler();
                if (Console.KeyAvailable)
                {
                    ch = char.ToUpper(Console.ReadKey(true).KeyChar);
                }
            }

            // Deallocate storage for buffers
            foreach (PinnedArray <short> p in minPinned)
            {
                if (p != null)
                {
                    p.Dispose();
                }
            }
            foreach (PinnedArray <short> p in maxPinned)
            {
                if (p != null)
                {
                    p.Dispose();
                }
            }
        }