Esempio n. 1
0
        public double[] Generate(bool[] srcBits)
        {
            double[] samples      = Sampler.Resample(srcBits);
            double[] gaussSamples = Filter.Process(samples, Oversampling);

            return(gaussSamples);
        }
Esempio n. 2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string srcBits = txtSequence.Text;

            double BT           = 0;
            double Oversampling = 0;

            try
            {
                BT           = double.Parse(txtBT.Text);
                Oversampling = double.Parse(txtOversampling.Text);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Invalid parameter. Either BT or Oversampling value is wrong.");
                return;
            }


            double[] srcData = new double[srcBits.Length];

            for (int pos = 0; pos < srcBits.Length; pos++)
            {
                if (srcBits.Substring(pos, 1) == "1")
                {
                    srcData[pos] = 1.0;
                }
                else if (srcBits.Substring(pos, 1) == "0")
                {
                    srcData[pos] = -1.0;
                }
                else
                {
                    MessageBox.Show("Invalid binary sequence.");
                    return;
                }
            }

            //            byte[] srcData = new byte[] {0xB9, 0x62, 0x04, 0x0F, 0x2D, 0x45, 0x76, 0x1B};
            //            srcData = DifferenceCode.Encode(srcData);

            Resampler sampler = new Resampler((decimal)Oversampling);

            double[] samples = sampler.Resample(srcData);

            GaussFilter filter = new GaussFilter(BT);

            double[] gaussSamples = filter.Process(samples, Oversampling);

            waveformDisplay.Clear();
            waveformDisplay.XAxisUnit = Oversampling;

            waveformDisplay.XAxisGridOffset = 128;
            waveformDisplay.ProcessData(new double[128]);

            waveformDisplay.ProcessData(gaussSamples);

            if (ShmemChannel != null)
            {
                double[] diffSamples = Differenciator.Differenciate(gaussSamples);
                ShmemChannel.Write(ByteUtil.convertToBytesInterleaved(gaussSamples, diffSamples));
            }
        }