Exemple #1
0
 public static extern StandardDriverStatusCode RunBlock(short handle,
                                                        ulong noOfPreTriggerSamples,
                                                        ulong noOfPostTriggerSamples,
                                                        uint timebase,
                                                        out double timeIndisposedMs,
                                                        ulong segmentIndex,
                                                        DefinitionBlockReady lpPs6000aBlockReady,
                                                        IntPtr pVoid);
        /// <summary>
        /// Captures 1000 samples on Channel A and the data is written to Output.csv
        /// </summary>
        public StandardDriverStatusCode RunBlockModeCallbackExample(short handle, DeviceResolution resolution, int numChannels)
        {
            var    channel           = Channel.ChannelA;
            ulong  numSamples        = 1000;
            double idealTimeInterval = 0.0000001; //100ns

            var status = ps6000aDevice.InitializeChannels(handle, new List <Channel>()
            {
                channel
            }, numChannels);

            if (status != StandardDriverStatusCode.Ok)
            {
                return(status);
            }

            _callback = BlockReadyCallback;
            status    = ps6000aDevice.RunBlock(handle, resolution, numSamples, channel, idealTimeInterval, _callback);
            if (status != StandardDriverStatusCode.Ok)
            {
                return(status);
            }

            status = WaitForDataToBeCaptured(handle, channel);
            if (status != StandardDriverStatusCode.Ok)
            {
                return(status);
            }

            var      data = new short[numSamples];
            GCHandle gch  = GCHandle.Alloc(data);

            try
            {
                status = ps6000aDevice.ReadDataFromDevice(handle, channel, numSamples, ref data);
                if (status != StandardDriverStatusCode.Ok)
                {
                    return(status);
                }

                ps6000aDevice.WriteDataToFile(data);
            }
            finally
            {
                gch.Free();
            }

            return(status);
        }
Exemple #3
0
    /// <summary>
    /// Calls Runblock on the device
    /// </summary>
    public static StandardDriverStatusCode RunBlock(short handle, DeviceResolution resolution, ulong numSamples, Channel channel,
                                                    double idealTimeInterval, DefinitionBlockReady callback = null)
    {
        double actualTimeInterval;
        double timeIndisposedMS;
        uint   timebase;

        var status = DriverImports.PS6000a.NearestSampleIntervalStateless(handle, GetChannelFlag(channel),
                                                                          idealTimeInterval, resolution, out timebase, out actualTimeInterval);

        if (status != StandardDriverStatusCode.Ok)
        {
            return(status);
        }

        //Set the number of pre and post trigger samples to half the number of samples.
        //Thus the middle sample should be the trigger point.
        return(DriverImports.PS6000a.RunBlock(handle, numSamples / 2, numSamples / 2, timebase,
                                              out timeIndisposedMS, 0, callback, IntPtr.Zero));
    }