private void btStart_Click(object sender, EventArgs e) { if (!File.Exists(tbDataFilePath.Text)) { MessageBox.Show("File not found."); return; } _streamFile = new FixFrequencyStreamFile(); try { _streamFile.Open(tbDataFilePath.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read, true); _playBackLength = _streamFile.NumberOfSamples; _playbackStartPosition = 0; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } _playedSampleCount = 0; _playBackLength = _streamFile.NumberOfSamples; _playbackStartPosition = 0; _elapsedMax = 0; _elapsedMin = double.MaxValue; btStart.Enabled = false; btStop.Enabled = true; _overflowCount = 0; _swTotalTime.Reset(); _swTotalTime.Start(); timer1.Enabled = true; new Thread(ThreadReadFile).Start(); new Thread(ThreadGetData).Start(); }
private void button1_Click(object sender, EventArgs e) { FixFrequencyStreamFile _streamFile; string fileName = Directory.GetCurrentDirectory() + @"\testFile.iq"; Console.WriteLine("Dummy File Path:{0}", fileName); _streamFile = new FixFrequencyStreamFile(); Console.WriteLine("Initialization done"); _streamFile.Open(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, true); _streamFile.Sampling.SampleRate = 2000000; _streamFile.Storage.FileFormat = FileFormat.FixFrequencyStream; _streamFile.Storage.DataType = DataType.RealI16; _streamFile.Storage.NumberOfChannels = 2; for (int i = 0; i < 2; i++) { _streamFile.Sampling.Channels.Add(new BaseChannelSamplingInfo() { RFFrequency = 2400000000, Bandwidth = _streamFile.Sampling.SampleRate * 0.8, RFScaleFactor = 0.5, DigitizerScaleFactor = 0.00001, }); } _streamFile.WriteFileHeader(); Console.WriteLine("Configuration done"); short[] data = new short[8 * 1024 * 1024]; int iteration = 256; Console.WriteLine("BlockData (size is {0}Bytes) is ready", data.Length); for (int i = 0; i < iteration; i++) { _streamFile.Write(data); Console.WriteLine("{0}/{1} cycle is done", i + 1, iteration); } _streamFile.Close(); Console.WriteLine("Dummy file generation is done"); MessageBox.Show("Generation Done!"); }