コード例 #1
0
        /// <summary>
        /// Creates and initalizes a SamplePlot object
        /// </summary>
        /// <param name="Samples">Raw sampled data from the input device</param>
        /// <param name="Channels">The number of channels being sampled (when 4 or fewer, sample data is 'stacked')</param>
        /// <param name="StackedSamples">'true' if more than one sample is stacked in each byte</param>
        public SamplePlot(byte[] Samples, int Channels, bool StackedSamples)
        {
            if (StackedSamples)
            {
                // When the number of channels is 4 or fewer, samples are 'stacked'. So here
                // we define the number of samples per byte and shift needed to get to the next
                // sample.
                switch (Channels)
                {
                case 1:
                    samplesPerByte = 8;
                    sampleShift    = 1;
                    break;

                case 2:
                    samplesPerByte = 4;
                    sampleShift    = 2;
                    break;

                case 3:
                case 4:
                    samplesPerByte = 2;
                    sampleShift    = 4;
                    break;

                default:
                    if (Channels < 1 || Channels > 8)
                    {
                        throw new Exception("Channels must be in the range 1 - 8");
                    }
                    samplesPerByte = 1;
                    sampleShift    = 0;
                    break;
                }
            }
            else
            {
                samplesPerByte = 1;
                sampleShift    = 0;
            }

            this.Channels        = Channels;
            this.SampleSignals   = new List <SampleSignal> [Channels];
            currentChannelSignal = new SampleSignal[Channels];

            for (int c = 0; c < Channels; c++)
            {
                // Initialize each channel low, 0 duration.
                currentChannelSignal[c] = new SampleSignal(SampleSignal.State.Low, 0);
                this.SampleSignals[c]   = new List <SampleSignal>(2048);
            }

            // Build the sample arrays...
            buildSampleSignals(Samples);
        }
コード例 #2
0
        /// <summary>
        /// Add a signal to the Channel's list.
        /// </summary>
        /// <param name="channel"></param>
        private void addSignal(int channel)
        {
            SampleSignal ss = currentChannelSignal[channel];

            if (ss.Duration > 0)
            {
                SampleSignals[channel].Add(ss);

                // Create a new current signal on this channel with the opposite flavor.
                // Duration = 1.
                currentChannelSignal[channel] = new SampleSignal(ss.SampleState == SampleSignal.State.High ? SampleSignal.State.Low : SampleSignal.State.High, 1);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates and initalizes a SamplePlot object
        /// </summary>
        /// <param name="Samples">Raw sampled data from the input device</param>
        /// <param name="Channels">The number of channels being sampled (when 4 or fewer, sample data is 'stacked')</param>
        /// <param name="StackedSamples">'true' if more than one sample is stacked in each byte</param>
        public SamplePlot(byte[] Samples, int Channels, bool StackedSamples)
        {
            if (StackedSamples)
            {
                // When the number of channels is 4 or fewer, samples are 'stacked'. So here
                // we define the number of samples per byte and shift needed to get to the next
                // sample.
                switch (Channels)
                {
                    case 1:
                        samplesPerByte = 8;
                        sampleShift = 1;
                        break;
                    case 2:
                        samplesPerByte = 4;
                        sampleShift = 2;
                        break;
                    case 3:
                    case 4:
                        samplesPerByte = 2;
                        sampleShift = 4;
                        break;
                    default:
                        if (Channels < 1 || Channels > 8)
                            throw new Exception("Channels must be in the range 1 - 8");
                        samplesPerByte = 1;
                        sampleShift = 0;
                        break;
                }
            }
            else
            {
                samplesPerByte = 1;
                sampleShift = 0;
            }

            this.Channels = Channels;
            this.SampleSignals = new List<SampleSignal>[Channels];
            currentChannelSignal = new SampleSignal[Channels];

            for (int c = 0; c < Channels; c++)
            {
                // Initialize each channel low, 0 duration.
                currentChannelSignal[c] = new SampleSignal(SampleSignal.State.Low, 0);
                this.SampleSignals[c] = new List<SampleSignal>(2048);
            }

            // Build the sample arrays...
            buildSampleSignals(Samples);
        }
コード例 #4
0
        /// <summary>
        /// Add a signal to the Channel's list.
        /// </summary>
        /// <param name="channel"></param>
        private void addSignal(int channel)
        {
            SampleSignal ss = currentChannelSignal[channel];

            if (ss.Duration > 0)
            {
                SampleSignals[channel].Add(ss);

                // Create a new current signal on this channel with the opposite flavor.
                // Duration = 1.
                currentChannelSignal[channel] = new SampleSignal(ss.SampleState == SampleSignal.State.High ? SampleSignal.State.Low : SampleSignal.State.High, 1);
            }
        }