void Tuner_FilterRateChanged(object sender, EventArgs e) { /* update UI */ if (InvokeRequired) { BeginInvoke(new Action(() => { Tuner_FilterRateChanged(sender, e); })); } else { txtFilterRate.Text = FrequencyFormatter.FreqToStringAccurate(SamplingRate); /* set sample source frequency */ //_SampleSource.ForceInputRate(SamplingRate); /* update related parameters */ SamplesPerBlock = SamplesPerBlock; /* inform listeners */ if (SamplingRateChanged != null) { SamplingRateChanged(this, null); } } }
private void UpdateMarkerList() { FrequencyMarker[] markers = MarkerList.Markers.ToArray(); /* sort the list */ List <FrequencyMarker> list = new List <FrequencyMarker>(markers); list.Sort(delegate(FrequencyMarker p1, FrequencyMarker p2) { return((int)(p1.Frequency - p2.Frequency)); }); markers = list.ToArray(); if (ListItems == null || ListItems.Length != markers.Length) { ListItems = new ListViewItem[markers.Length]; for (int pos = 0; pos < ListItems.Length; pos++) { ListItems[pos] = new ListViewItem(new string[2]); } lstMarkers.Items.Clear(); lstMarkers.Items.AddRange(ListItems); } for (int pos = 0; pos < ListItems.Length; pos++) { ListItems[pos].Tag = markers[pos]; ListItems[pos].SubItems[0].Text = FrequencyFormatter.FreqToStringAccurate(markers[pos].Frequency); ListItems[pos].SubItems[1].Text = markers[pos].Label; } }
void SampleSource_SamplingRateChanged(object sender, EventArgs e) { Log.AddMessage("Sampling rate changed: " + FrequencyFormatter.FreqToStringAccurate(SampleSource.SamplingRate)); if (Demodulator != null) { Demodulator.SamplingRate = SampleSource.SamplingRate; } }
public override void Render() { if (State == eDockState.Hidden || State == eDockState.Collapsed) { return; } int xPos = XPosition; int yPos = YPosition; if (PositionUpdated) { PositionUpdated = false; BodyVertexesUsed = 0; /* dark background */ BodyVertexesUsed = BuildFilledRectangle(BodyVertexes, BodyVertexesUsed, xPos, (int)(xPos + Width), yPos, yPos + Height, 0xBF000000); } if (BodyVertexesUsed - 2 > 0) { Panel.MainPlot.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, BodyVertexesUsed - 2, BodyVertexes); } TextRect.X = XPosition + 10; TextRect.Y = YPosition + 3; TextRect.Width = (int)Width; TextRect.Height = (int)Height; TextShadowRect.X = TextRect.X + 1; TextShadowRect.Y = TextRect.Y + 1; TextShadowRect.Width = (int)Width; TextShadowRect.Height = (int)Height; AddLine("Selected"); AddLine(" from " + FrequencyFormatter.FreqToStringAccurate(Selection.FreqStart)); AddLine(" to " + FrequencyFormatter.FreqToStringAccurate(Selection.FreqEnd)); AddLine(" width " + FrequencyFormatter.FreqToStringAccurate(Selection.FreqWidth)); if (Selection.Carriers > 0) { AddLine(""); AddLine("Carriers"); AddLine(" count " + Selection.Carriers); if (Selection.Carriers > 1) { AddLine(" delta " + FrequencyFormatter.FreqToStringAccurate(Selection.CarrierWidth)); } } }
private void UpdateDemodInformation() { lock (DemodState.SoundSinkInfos) { foreach (SoundSinkInfo info in DemodState.SoundSinkInfos) { string desc = ""; if (DemodState.Description != null) { desc = DemodState.Description; } else { desc = FrequencyFormatter.FreqToStringAccurate(DemodState.DemodulationFrequency); } desc += " (" + FrequencyFormatter.FreqToStringAccurate(DemodState.InputRate) + ")"; if (DemodState.SquelchEnabled) { if (DemodState.SquelchState == DemodulationState.eSquelchState.Closed) { desc += "SQ: OPEN"; } else { desc += "SQ: idle"; } } info.Sink.Description = desc; /* update squelch state */ if (DemodState.SquelchEnabled) { info.Sink.SquelchState = DemodState.SquelchState; } else { info.Sink.SquelchState = DemodulationState.eSquelchState.Open; } } } }
public FilterDetailDialog(FilterInformation filter) { if (filter.SourceDevice is Atmel) { Atmel = (Atmel)filter.SourceDevice; } FilterInfo = filter; InitializeComponent(); txtFilterRate.Text = FrequencyFormatter.FreqToStringAccurate(filter.Rate); txtFilterWidth.Text = FrequencyFormatter.FreqToStringAccurate(filter.Width); txtFilterLocation.Text = filter.Location; txtFilterOffset.ValueChanged += new EventHandler(txtFilterOffset_ValueChanged); txtFilterGain.ValueChanged += new EventHandler(txtFilterGain_ValueChanged); ReadFilterDetails(); }
void Tuner_FilterWidthChanged(object sender, EventArgs e) { if (InvokeRequired) { BeginInvoke(new Action(() => { Tuner_FilterWidthChanged(sender, e); })); } else { txtFilterWidth.Text = FrequencyFormatter.FreqToStringAccurate(FilterWidth); /* inform listeners */ if (FilterWidthChanged != null) { FilterWidthChanged(this, null); } } }
public void Init() { AlignmentCheckDone = false; AlignmentBufferPos = 0; AlignmentBuffer = new double[SymbolsToCheck * SamplesPerSymbol]; SampleNum = 0; if (SamplingRate == 0) { Log.AddMessage("GMSKDemodulator", "Idle"); State = eLearningState.Idle; return; } State = eLearningState.Learn; Log.AddMessage("GMSKDemodulator", "SamplingRate: " + FrequencyFormatter.FreqToStringAccurate(SamplingRate)); Log.AddMessage("GMSKDemodulator", "SymbolsPerSecond: " + SymbolsPerSecond); Log.AddMessage("GMSKDemodulator", "SamplesPerSymbol: " + SamplesPerSymbol); Log.AddMessage("GMSKDemodulator", "Symbols for alignchk: " + SymbolsToCheck); Log.AddMessage("GMSKDemodulator", ""); Log.AddMessage("GMSKDemodulator", "State: Learn"); }
public void UserEventCallbackFunc(eUserEvent evt, double param) { switch (evt) { /* when mouse is moved into a plot and we are in foreground, update focus to hovered plot */ case eUserEvent.MouseEnter: FocusHovered(); break; /* bring up popup menu. has to be improved */ case eUserEvent.MouseClickRight: { long freq = GetHovered().CursorFrequency; ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem("Frequency: " + FrequencyFormatter.FreqToStringAccurate(freq)); MenuItem menuItem2 = new MenuItem("-"); MenuItem menuItem3 = new MenuItem("FFT 512"); MenuItem menuItem4 = new MenuItem("FFT 1024"); MenuItem menuItem5 = new MenuItem("FFT 2048"); MenuItem menuItem6 = new MenuItem("FFT 4096"); MenuItem menuItem7 = new MenuItem("-"); MenuItem menuItem8 = new MenuItem("Show decimated [Filtered]"); menuItem1.Enabled = false; contextMenu.MenuItems.AddRange(new MenuItem[] { menuItem1, menuItem2, menuItem3, menuItem4, menuItem5, menuItem6, menuItem7, menuItem8 }); switch (FFTSize) { case 512: menuItem3.Checked = true; break; case 1024: menuItem4.Checked = true; break; case 2048: menuItem5.Checked = true; break; case 4096: menuItem6.Checked = true; break; } menuItem3.Click += new EventHandler(delegate(object sender, EventArgs e) { FFTSize = 512; }); menuItem4.Click += new EventHandler(delegate(object sender, EventArgs e) { FFTSize = 1024; }); menuItem5.Click += new EventHandler(delegate(object sender, EventArgs e) { FFTSize = 2048; }); menuItem6.Click += new EventHandler(delegate(object sender, EventArgs e) { FFTSize = 4096; }); menuItem8.Click += new EventHandler(delegate(object sender, EventArgs e) { DecimateFiltered ^= true; }); System.Drawing.Point popupPos = this.PointToClient(MousePosition); popupPos.X -= 20; popupPos.Y -= 20; contextMenu.Show(this, popupPos); } break; } }
private void UpdateInformationInternal(bool notify) { lblDebugText.Text = "In: " + FrequencyFormatter.FreqToStringAccurate(DemodState.InputRate); lblDebugText.Text += " Limiter: /" + DemodState.BandwidthLimiterFract + " (" + (DemodState.BandwidthLimiter?"ON":"OFF") + ")"; lblDebugText.Text += " Demod: /" + DemodState.DemodulatorFiltering; lblDebugText.Text += " Decim: /" + DemodState.AudioDecimation; lblDebugText.Text += " => Output: " + DemodState.AudioRate; lblDebugText.Text += " (rate in: " + DemodState.InputRateMeter.Rate + ")"; txtDemodRate.Text = FrequencyFormatter.FreqToString(DemodState.AudioRate); txtDecim.Value = DemodState.AudioDecimation; /* update title bar */ if (DemodState.Description != null) { Text = "Demodulation: " + DemodState.Description; } /* colorize frequency */ if (DemodState.DemodulationPossible) { frequencySelector.ForeColor = Color.Cyan; } else { frequencySelector.ForeColor = Color.Red; } if (DemodState.SoundSinkInfos.Count == 0) { txtStatus.Text = "No output opened"; } else { txtStatus.Text = ""; lock (DemodState.SoundSinkInfos) { foreach (SoundSinkInfo info in DemodState.SoundSinkInfos) { txtStatus.Text += info.Sink.Status + " "; } } } if (!DemodState.SquelchEnabled) { DemodState.SquelchAverage = -50; } /* * if (Demod.SoundDevice == null) * { * txtSamplingRate.Text = FrequencyFormatter.FreqToString(Demod.InputRate / Demod.InputSignalDecimation / Demod.AudioDecimation); * } * else * { * txtSamplingRate.Text = FrequencyFormatter.FreqToString(Demod.SoundDevice.Rate); * } */ if (DemodState.InputRate != 0) { radioFilter2.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 2); radioFilter4.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 4); radioFilter8.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 8); radioFilter16.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 16); radioFilter32.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 32); radioFilter64.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 64); radioFilter128.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 128); radioFilter256.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 256); } else { radioFilter2.Text = "/2"; radioFilter4.Text = "/4"; radioFilter8.Text = "/8"; radioFilter16.Text = "/16"; radioFilter32.Text = "/32"; radioFilter64.Text = "/64"; radioFilter128.Text = "/128"; radioFilter256.Text = "/256"; } if (DemodState.InputRate != 0) { radioLowPass2.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 2 / DemodState.InputSignalDecimation); radioLowPass4.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 4 / DemodState.InputSignalDecimation); radioLowPass8.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 8 / DemodState.InputSignalDecimation); radioLowPass16.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 16 / DemodState.InputSignalDecimation); radioLowPass32.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 32 / DemodState.InputSignalDecimation); radioLowPass64.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 64 / DemodState.InputSignalDecimation); radioLowPass128.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 128 / DemodState.InputSignalDecimation); radioLowPass256.Text = FrequencyFormatter.FreqToString(DemodState.InputRate / 256 / DemodState.InputSignalDecimation); } else { radioLowPass2.Text = "/2"; radioLowPass4.Text = "/4"; radioLowPass8.Text = "/8"; radioLowPass16.Text = "/16"; radioLowPass32.Text = "/32"; radioLowPass64.Text = "/64"; radioLowPass128.Text = "/128"; radioLowPass256.Text = "/256"; } txtSquelchAvg.Text = String.Format("{0:0.00}", DemodState.SquelchAverage); txtSquelchMax.Text = String.Format("{0:0.00}", DemodState.SquelchMax); if (notify) { DemodState.UpdateListeners(); } }
public virtual bool OpenTuner() { /* display the wait message */ #if false WaitDialog waitDlg = new WaitDialog(); waitDlg.Show(); waitDlg.Refresh(); #endif USBRX = new USBRXDevice(); //USBRX.ShowConsole(true); USBRX.TunerCombination = TunerCombination; try { if (!USBRX.Init()) { ErrorMessage = "Could not find USB-RX on USB."; #if false waitDlg.Close(); #endif base.Close(); return(false); } } catch (BadImageFormatException e) { ErrorMessage = "Unsupported architecture."; #if false waitDlg.Close(); #endif base.Close(); return(false); } catch (Exception e) { ErrorMessage = "Unhandled exception." + Environment.NewLine + e; #if false waitDlg.Close(); #endif base.Close(); return(false); } ErrorMessage = ""; FilterList.NCOFreq = USBRX.Atmel.TCXOFreq; FilterList.UpdateFilters("Filter"); FilterList.AddFilters("..\\..\\..\\Filter"); FilterList.FilterSelected += new EventHandler(FilterList_FilterSelected); USBRX.Tuner.SamplingRateChanged += new EventHandler(Tuner_FilterRateChanged); USBRX.Tuner.FilterWidthChanged += new EventHandler(Tuner_FilterWidthChanged); USBRX.Tuner.InvertedSpectrumChanged += new EventHandler(Tuner_InvertedSpectrumChanged); USBRX.Tuner.DeviceDisappeared += new EventHandler(Tuner_DeviceDisappeared); frequencySelector1.UpperLimit = USBRX.Tuner.HighestFrequency; frequencySelector1.LowerLimit = USBRX.Tuner.LowestFrequency; CurrentFrequency = USBRX.Tuner.GetFrequency(); SetFreqTextbox(CurrentFrequency); _SampleSource = new ShmemSampleSource("USB-RX Device Control", USBRX.ShmemChannel, 1, 0); _SampleSource.InvertedSpectrum = InvertedSpectrum; _SampleSource.DataFormat = ByteUtil.eSampleFormat.Direct16BitIQFixedPointLE; ToolTip ttFreq = new ToolTip(); ttFreq.SetToolTip(frequencySelector1, "Min Freq: " + FrequencyFormatter.FreqToStringAccurate(USBRX.Tuner.LowestFrequency) + Environment.NewLine + "Max Freq: " + FrequencyFormatter.FreqToStringAccurate(USBRX.Tuner.HighestFrequency)); ttFreq.AutomaticDelay = 500; UpdateAtmelFilters(); SelectFiles(true); Connected = true; /* small hack to select first (widest) filter */ FilterList.FilterSelect(FilterList.FirstFilter); /* close wait dialog and show ours */ #if false waitDlg.Close(); #endif Show(); radioAcqOff.Checked = true; radioTunerInt.Checked = true; radioAgcOff.Checked = true; chkAtt.Checked = false; chkPreAmp.Checked = false; radioTunerInt_CheckedChanged(null, null); chkAtt_CheckedChanged(null, null); chkPreAmp_CheckedChanged(null, null); radioAgcOff_CheckedChanged(null, null); radioAcqBlock.Checked = true; DeviceOpened?.Invoke(this, EventArgs.Empty); return(true); }