From 538b9212380b1c8bc6567c54cd31556b9da1a159 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 8 Jul 2024 20:41:37 +0200 Subject: [PATCH 01/98] Update WinterhillProperties.cs Fixed compile error: Use new variable "_current_offset" instead of old "_settings.Offset" --- MediaSources/Winterhill/WinterhillProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 54bd9bb..79b9c17 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -678,7 +678,7 @@ public override Dictionary GetSignalData(int device) data.Add("dbMargin", last_dbm[device]); data.Add("Mer", last_mer[device]); data.Add("SR", _current_sr[device].ToString()); - data.Add("Frequency", ((float)(_current_frequency[device] + _settings.Offset[device])/1000.0f).ToString("F", nfi)); + data.Add("Frequency", ((float)(_current_frequency[device] + _current_offset[device])/1000.0f).ToString("F", nfi)); return data; } From 6658ca7519343a9e137ccda597dd41a4541fdfc8 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 2 Nov 2024 19:55:58 +0100 Subject: [PATCH 02/98] Fixed: third bandplan row was no longer visible The size of the picture box is reduced due to layout changes. To make the third bandplan line visible again the "height" of the bandplan is changed from 255 to 246. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index e1a29d9..717c514 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -24,7 +24,7 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); - static int height = 255; //makes things easier + static int height = 246; //makes things easier static int bandplan_height = 30; Bitmap bmp; @@ -414,7 +414,7 @@ private void drawspectrum(UInt16[] fft_data) tmp.FillPolygon(linGrBrush, points); - tmp.DrawImage(bmp2, 0, 255 - bandplan_height); //bandplan + tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan y = 0; From 561602e36cc1ced8c95d5709dbbe17e78c8810b9 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 09:29:54 +0100 Subject: [PATCH 03/98] Update MainForm.cs Flickering of callsign in BATC spectrum fixed. --- MainForm.cs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 618e3c1..bbe9def 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -382,32 +382,29 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str Log.Error("info_display count does not fit video_nr"); } - if (datv_reporter != null) + if (datv_reporter != null && properties.demod_locked) { - if (properties.demod_locked) + bool result = datv_reporter.SendISawMessage(new ISawMessage( + properties.service_name, + properties.db_margin, + properties.mer, + properties.frequency, + properties.symbol_rate, + videoSource.GetDeviceName() + )); + + /* + if (!result) { - bool result = datv_reporter.SendISawMessage(new ISawMessage( - properties.service_name, - properties.db_margin, - properties.mer, - properties.frequency, - properties.symbol_rate, - videoSource.GetDeviceName() - )); - - /* - if (!result) + if (!datv_reporter.Connected) { - if (!datv_reporter.Connected) - { - datv_reporter.Connect(); - } + datv_reporter.Connect(); } - */ } + */ } - if (batc_spectrum != null) + if (batc_spectrum != null && properties.demod_locked) { float freq = properties.frequency; float sr = properties.symbol_rate; From 05bb0ec969519abe71aceab879c4c986eab4e262 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 19:33:57 +0100 Subject: [PATCH 04/98] Update BATCSpectrum.cs Spectrum display did not scale to PictureBox size. All hard coded 255 "height" values exchanged with "height" variable which contains the real size of the Picturebox. Actual 246. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 717c514..9f131d6 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -24,8 +24,8 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); - static int height = 246; //makes things easier - static int bandplan_height = 30; + static readonly int height = 246; //makes things easier + static readonly int bandplan_height = 30; Bitmap bmp; static Bitmap bmp2; @@ -388,12 +388,12 @@ private void drawspectrum(UInt16[] fft_data) for (i = 1; i < fft_data.Length - 3; i++) //ignore padding? { - PointF point = new PointF(i * spectrum_wScale, 255 - fft_data[i] / 255); + PointF point = new PointF(i * spectrum_wScale, height - fft_data[i] / height); points[i] = point; } - points[0] = new PointF(0, 255); - points[points.Length - 1] = new PointF(spectrum_w, 255); + points[0] = new PointF(0, height); + points[points.Length - 1] = new PointF(spectrum_w, height); if (spectrumTunerHighlight > -1) { @@ -408,7 +408,7 @@ private void drawspectrum(UInt16[] fft_data) LinearGradientBrush linGrBrush = new LinearGradientBrush( new Point(0, 0), - new Point(0, 255), + new Point(0, height), Color.FromArgb(255, 255, 99, 132), // Opaque red Color.FromArgb(255, 54, 162, 235)); // Opaque blue @@ -440,7 +440,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), (255) - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } From 31f2736a23f6dfb770237dd7bb6fe6b464b7ba44 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 19:41:05 +0100 Subject: [PATCH 05/98] Update signal.cs Changed to use real fft_strength value. --- ExtraFeatures/BATCSpectrum/signal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 8dd24c4..e16d074 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -506,7 +506,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal / 255, signal_freq, signal_bw, false, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0)); } else { @@ -515,7 +515,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal / 255, signal_freq, signal_bw, overpower, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, 0)); } } From f060be97281085337c4a3a12f0e75386c9fb64e4 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 19:43:29 +0100 Subject: [PATCH 06/98] Update signal.cs be compatible with QO-100 wideband spectrum code at website. --- ExtraFeatures/BATCSpectrum/signal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index e16d074..841ed75 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -535,7 +535,7 @@ public float align_symbolrate(float width) { return 0; } - else if (width < 0.065) + else if (width < 0.060) { return 0.035f; } @@ -543,7 +543,7 @@ public float align_symbolrate(float width) { return 0.066f; } - else if (width < 0.195) + else if (width < 0.185) { return 0.125f; } From 183d1ac8e5edd2b26559f83176cc655cee37a05a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 20:31:21 +0100 Subject: [PATCH 07/98] show dBb values in BATC Spectrum code added to calculate and show the dBb values. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 18 ++++++++++++- ExtraFeatures/BATCSpectrum/signal.cs | 30 +++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 9f131d6..5083e5e 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -351,7 +351,14 @@ private void drawspectrum_signals(List signals) //draw the text for each signal found foreach (signal.Sig s in signals) { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (25)), (255 - Convert.ToSingle(s.fft_strength + 50)))); + if (s.frequency > 10492.000) + { + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + } + else + { + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (25)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + } } } @@ -442,6 +449,15 @@ private void drawspectrum(UInt16[] fft_data) { tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } + // Test code to demonstrate how to draw the rectangle to the spectrum. + // It is indended to only show the rectangle if mouse is within the rectangle boundaries. + // + //if (sig.frequency > 10492.000) + //{ + // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_start * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height)); + // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_start * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_start * spectrum_wScale), height); + // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_stop * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale), height); + //} } for (i = 0; i < _tuners; i++) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 841ed75..0d228f0 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -511,11 +511,39 @@ public List detect_signals(UInt16[] fft_data) else { bool overpower = false; + // + // The original dBb calculation code used at the QO-100 wideband spectrum web site is complicated: + // + // ------------------------------- + // + // canvasHeight = 542; + // var db_per_pixel; + // var beacon_strength_pixel; + // + // db_per_pixel = ((canvasHeight * 7/8) - (canvasHeight / 12)) / 15; // 15dB screen window + // beacon_strength_pixel = canvasHeight - ((beacon_strength / 65536) * canvasHeight); + // + // signal[x].top = (canvasHeight-((strength_signal/65536) * canvasHeight); + // dBb = ((beacon_strength_pixel - signal[x].top) / db_per_pixel).toFixed(1); + // + // ------------------------------- + // + // I (DL1RF) have simplified the calculation by eliminating the 'canvasHeight' dependency. + // With canvasHeight = 1 the db_per_pixel will calculate as ((1 * 7/8) - (1 / 12)) / 15 = 0.0527777... + // + // Life comparing the dBb values calculated here with the values at QO-100 wideband spectrum + // show sometimes a diviation of -0.1dB. + // + // But this is the same while using the original calculation. + // + // Additional tests may be necessary to enshure that the simplified calcualtion is right. + // + float dBb = -1.0f * (((float)(beacon_strength - strength_signal) / 65536.0f) / 0.052778f); if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, dBb)); } } From 6071788dd2cf61c8cd0ef3a06590c0dd977f8790 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 4 Nov 2024 21:19:16 +0100 Subject: [PATCH 08/98] revert commit "Changed to use real fft_strength value." uses BATCSpectrum.height for correct calculation. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 6 +++--- ExtraFeatures/BATCSpectrum/signal.cs | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 5083e5e..bdb4e2d 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -24,7 +24,7 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); - static readonly int height = 246; //makes things easier + public static readonly int height = 246; //makes things easier static readonly int bandplan_height = 30; Bitmap bmp; @@ -353,11 +353,11 @@ private void drawspectrum_signals(List signals) { if (s.frequency > 10492.000) { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); } else { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (25)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); } } } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 0d228f0..ded7510 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using opentuner.ExtraFeatures.BATCSpectrum; namespace opentuner { @@ -506,7 +507,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0)); } else { @@ -543,7 +544,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, dBb)); } } From 01517f0f9720528d517f961399485f1959a3794b Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 11:06:21 +0100 Subject: [PATCH 09/98] Update BATCSpectrum.cs Draw a white signal rectangle and print dBb value if mouse is moved over a signal. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 78 +++++++++++++++------- 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index bdb4e2d..9cbadf6 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -31,6 +31,7 @@ public class BATCSpectrum static Bitmap bmp2; Pen greyPen = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); + Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -69,6 +70,9 @@ public class BATCSpectrum int connect_retries = 5; int connect_retry_count = 0; + private int mousePos_x = 0; + private int mousePos_y = 0; + public void updateSignalCallsign(string callsign, double freq, float sr) { sigs.updateCurrentSignal(callsign, freq, sr); @@ -351,8 +355,11 @@ private void drawspectrum_signals(List signals) //draw the text for each signal found foreach (signal.Sig s in signals) { - if (s.frequency > 10492.000) + if (check_mouse_over_signal(s)) { + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); } else @@ -443,21 +450,15 @@ private void drawspectrum(UInt16[] fft_data) sigs.detect_signals(fft_data); // draw over power - foreach (var sig in sigs.signalsData) + lock (list_lock) { - if (sig.overpower) + foreach (var sig in sigs.signalsData) { - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + if (sig.overpower) + { + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + } } - // Test code to demonstrate how to draw the rectangle to the spectrum. - // It is indended to only show the rectangle if mouse is within the rectangle boundaries. - // - //if (sig.frequency > 10492.000) - //{ - // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_start * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height)); - // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_start * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_start * spectrum_wScale), height); - // tmp.DrawLine(whitePen, Convert.ToInt16(sig.fft_stop * spectrum_wScale), height - Convert.ToInt16(sig.fft_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale), height); - //} } for (i = 0; i < _tuners; i++) @@ -531,36 +532,65 @@ private void selectSignal(int X, int Y) try { - foreach (signal.Sig s in sigs.signals) + lock (list_lock) { - if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) + foreach (signal.Sig s in sigs.signals) { + if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) + { - sigs.set_tuned(s, rx); - rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); - rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); - UInt32 freq = Convert.ToUInt32((s.frequency) * 1000); - UInt32 sr = Convert.ToUInt32((s.sr * 1000.0)); + sigs.set_tuned(s, rx); + rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); + rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); + UInt32 freq = Convert.ToUInt32((s.frequency) * 1000); + UInt32 sr = Convert.ToUInt32((s.sr * 1000.0)); - debug("Freq: " + freq.ToString()); - debug("SR: " + sr.ToString()); + debug("Freq: " + freq.ToString()); + debug("SR: " + sr.ToString()); - OnSignalSelected?.Invoke(rx, freq, sr); + OnSignalSelected?.Invoke(rx, freq, sr); + } } } } catch (Exception Ex) { - + MessageBox.Show(Ex.Message); } } int spectrumTunerHighlight = -1; + private bool check_mouse_over_signal(signal.Sig s) + { + int spectrum_h = _spectrum.Height - bandplan_height; + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / 922; + + if (mousePos_y < spectrum_h) + { + if ((mousePos_x > (s.fft_start * spectrum_wScale)) && (mousePos_x < (s.fft_stop * spectrum_wScale)) && (mousePos_y > (_spectrum.Height - s.fft_strength))) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + public void spectrum_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { get_bandplan_TX_freq(e.X, e.Y); // dh3cs + // save mouse position for rendering signal box + mousePos_x = e.X; + mousePos_y = e.Y; spectrumTunerHighlight = determine_rx(e.Y); From e8854d038e1a9180150dbef583e0e50afb650c63 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 11:48:13 +0100 Subject: [PATCH 10/98] private build version string --- GlobalDefines.cs | 2 +- MainForm.cs | 2 +- Resources/BuildDate.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GlobalDefines.cs b/GlobalDefines.cs index 078cf6b..ef9a259 100644 --- a/GlobalDefines.cs +++ b/GlobalDefines.cs @@ -9,6 +9,6 @@ namespace opentuner public static class GlobalDefines { public const int CircularBufferStartingCapacity = 250000; - public const string Version = "0.B"; + public const string Version = "0.C"; } } diff --git a/MainForm.cs b/MainForm.cs index bbe9def..e68c384 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -320,7 +320,7 @@ public MainForm(string[] args) frequenciesManager = new SettingsManager>("frequency_presets"); stored_frequencies = frequenciesManager.LoadSettings(stored_frequencies); - Text = "Open Tuner (ZR6TG) - Version " + GlobalDefines.Version + " - Build: " + opentuner.Properties.Resources.BuildDate; + Text = "Open Tuner (ZR6TG) - Version " + GlobalDefines.Version + " (modified by DL1RF) - Build: " + opentuner.Properties.Resources.BuildDate; } /// diff --git a/Resources/BuildDate.txt b/Resources/BuildDate.txt index 1b1c30a..5319b57 100644 --- a/Resources/BuildDate.txt +++ b/Resources/BuildDate.txt @@ -1 +1 @@ -2024/07/14 13:06:17.88 +05.11.2024 11:43:33,65 From 07355b86a54bc219e28daf1dfcf3f8b17ee95b58 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 13:07:06 +0100 Subject: [PATCH 11/98] Update BATCSpectrum.cs Display of channel info fixed. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 9cbadf6..7539124 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -257,6 +257,9 @@ private void debug(string msg) private void spectrum_MouseLeave(object sender, EventArgs e) { + get_bandplan_TX_freq(0, 0); // dh3cs + mousePos_x = 0; + mousePos_y = 0; spectrumTunerHighlight = -1; } @@ -585,7 +588,7 @@ private bool check_mouse_over_signal(signal.Sig s) } } - public void spectrum_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) + public void spectrum_MouseMove(object sender, MouseEventArgs e) { get_bandplan_TX_freq(e.X, e.Y); // dh3cs // save mouse position for rendering signal box @@ -601,7 +604,7 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro { int n = 0; string tx_freq_MHz = ""; - if (x > (_spectrum.Height - bandplan_height)) + if (y > (_spectrum.Height - bandplan_height)) { if (channels != null) { @@ -614,6 +617,14 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; InfoText = " Dn: " + indexedbandplan[n].Element("x-freq").Value + " SR: " + indexedbandplan[n].Element("name").Value + Environment.NewLine + " Up: " + tx_freq_MHz; + break; + } + else + { + if (InfoText != "") + { + InfoText = ""; + } } } n++; From a84b626377e5e9490c5b6376ed6b097ff5ee06d0 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 13:07:06 +0100 Subject: [PATCH 12/98] Update BATCSpectrum.cs Display of channel info fixed. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 9cbadf6..7539124 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -257,6 +257,9 @@ private void debug(string msg) private void spectrum_MouseLeave(object sender, EventArgs e) { + get_bandplan_TX_freq(0, 0); // dh3cs + mousePos_x = 0; + mousePos_y = 0; spectrumTunerHighlight = -1; } @@ -585,7 +588,7 @@ private bool check_mouse_over_signal(signal.Sig s) } } - public void spectrum_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) + public void spectrum_MouseMove(object sender, MouseEventArgs e) { get_bandplan_TX_freq(e.X, e.Y); // dh3cs // save mouse position for rendering signal box @@ -601,7 +604,7 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro { int n = 0; string tx_freq_MHz = ""; - if (x > (_spectrum.Height - bandplan_height)) + if (y > (_spectrum.Height - bandplan_height)) { if (channels != null) { @@ -614,6 +617,14 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; InfoText = " Dn: " + indexedbandplan[n].Element("x-freq").Value + " SR: " + indexedbandplan[n].Element("name").Value + Environment.NewLine + " Up: " + tx_freq_MHz; + break; + } + else + { + if (InfoText != "") + { + InfoText = ""; + } } } n++; From 23a03e04cdbd2016fb7dd851209a5d3ae9a2e2be Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 14:01:58 +0100 Subject: [PATCH 13/98] Right Click to spectrum bandplan fixed Don't tune to BEACON. check for TX frequency only if in bandplan segment. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 32 +++++++++++++--------- MainForm.Designer.cs | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 7539124..6a87c53 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -480,28 +480,31 @@ private void spectrum_Click(object sender, EventArgs e) float spectrum_w = _spectrum.Width; float spectrum_wScale = spectrum_w / 922; - System.Windows.Forms.MouseEventArgs me = (System.Windows.Forms.MouseEventArgs)e; + MouseEventArgs me = (MouseEventArgs)e; var pos = me.Location; - int X = pos.X; int Y = pos.Y; if (me.Button == MouseButtons.Right) { - int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); - //UpdateTextBox(txtFreq, freq.ToString()); + int spectrum_h = _spectrum.Height - bandplan_height; - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) + if (Y > spectrum_h) { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; - } + int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); + //UpdateTextBox(txtFreq, freq.ToString()); + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + } } else { @@ -614,7 +617,10 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro { if (y - (_spectrum.Height - bandplan_height) >= ch.Location.Y - (ch.Height / 2) + 3 & y - (_spectrum.Height - bandplan_height) <= ch.Location.Y + (ch.Height / 2) + 3) { - tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; + if (indexedbandplan[n].Element("name").Value != "BEACON") + { + tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; + } InfoText = " Dn: " + indexedbandplan[n].Element("x-freq").Value + " SR: " + indexedbandplan[n].Element("name").Value + Environment.NewLine + " Up: " + tx_freq_MHz; break; diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 002271d..ad6b0b5 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -541,7 +541,6 @@ private void InitializeComponent() // spectrum // this.spectrum.BackColor = System.Drawing.Color.Black; - this.spectrum.ContextMenuStrip = this.contextSpectrumMenu; resources.ApplyResources(this.spectrum, "spectrum"); this.spectrum.Name = "spectrum"; this.spectrum.TabStop = false; From 65b0694760e97c2f16ea1663744548eb2442b79a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 14:01:58 +0100 Subject: [PATCH 14/98] Right Click to spectrum bandplan fixed Don't tune to BEACON. check for TX frequency only if in bandplan segment. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 32 +++++++++++++--------- MainForm.Designer.cs | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 7539124..6a87c53 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -480,28 +480,31 @@ private void spectrum_Click(object sender, EventArgs e) float spectrum_w = _spectrum.Width; float spectrum_wScale = spectrum_w / 922; - System.Windows.Forms.MouseEventArgs me = (System.Windows.Forms.MouseEventArgs)e; + MouseEventArgs me = (MouseEventArgs)e; var pos = me.Location; - int X = pos.X; int Y = pos.Y; if (me.Button == MouseButtons.Right) { - int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); - //UpdateTextBox(txtFreq, freq.ToString()); + int spectrum_h = _spectrum.Height - bandplan_height; - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) + if (Y > spectrum_h) { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; - } + int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); + //UpdateTextBox(txtFreq, freq.ToString()); + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + } } else { @@ -614,7 +617,10 @@ private string get_bandplan_TX_freq(int x, int y) // returns TX-Freq in MHz fro { if (y - (_spectrum.Height - bandplan_height) >= ch.Location.Y - (ch.Height / 2) + 3 & y - (_spectrum.Height - bandplan_height) <= ch.Location.Y + (ch.Height / 2) + 3) { - tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; + if (indexedbandplan[n].Element("name").Value != "BEACON") + { + tx_freq_MHz = indexedbandplan[n].Element("s-freq").Value; + } InfoText = " Dn: " + indexedbandplan[n].Element("x-freq").Value + " SR: " + indexedbandplan[n].Element("name").Value + Environment.NewLine + " Up: " + tx_freq_MHz; break; diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 002271d..ad6b0b5 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -541,7 +541,6 @@ private void InitializeComponent() // spectrum // this.spectrum.BackColor = System.Drawing.Color.Black; - this.spectrum.ContextMenuStrip = this.contextSpectrumMenu; resources.ApplyResources(this.spectrum, "spectrum"); this.spectrum.Name = "spectrum"; this.spectrum.TabStop = false; From 6f4259c118a5f74a9f6c711cdfb821caa017745d Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 15:02:50 +0100 Subject: [PATCH 15/98] Update BATCSpectrum.cs Show exception message box. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 6a87c53..f6f7374 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -279,7 +279,7 @@ private void spectrum_SizeChanged(object sender, EventArgs e) } catch (Exception Ex) { - + MessageBox.Show(Ex.Message); } } @@ -383,7 +383,7 @@ private void UpdateDrawing() } catch (Exception Ex) { - + MessageBox.Show(Ex.Message); } } From 6955a4bde6f689b723f8d843d45493947e8d91f3 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 19:31:57 +0100 Subject: [PATCH 16/98] Symbol Rate selection Form added. --- ExtraFeatures/BATCSpectrum/SRForm.Designer.cs | 63 ++++ ExtraFeatures/BATCSpectrum/SRForm.cs | 296 ++++++++++++++++++ ExtraFeatures/BATCSpectrum/SRForm.resx | 120 +++++++ opentuner.csproj | 13 + 4 files changed, 492 insertions(+) create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.resx diff --git a/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs new file mode 100644 index 0000000..81e4ef3 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace opentuner.ExtraFeatures.BATCSpectrum { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class SRForm { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SRForm() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("opentuner.ExtraFeatures.BATCSpectrum.SRForm", typeof(SRForm).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs new file mode 100644 index 0000000..06bb871 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.cs @@ -0,0 +1,296 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner +{ + internal class SRForm : Form + { + private Button button1; + private Button button2; + private Button button4; + private Button button5; + private Button button6; + private Button button7; + private Button button8; + private Button button9; + private Button button10; + private Label label1; + private Label label2; + private Label label3; + private Button button3; + uint qrg = 0; + uint SR = 0; + + public SRForm(uint _qrg) + { + qrg = _qrg; + InitializeComponent(); + label3.Text = (qrg / 1000.0f).ToString() + " MHz"; + + } + + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); + this.button10 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(143, 14); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(32, 23); + this.button1.TabIndex = 0; + this.button1.Text = "X"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button2.Location = new System.Drawing.Point(13, 43); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(50, 23); + this.button2.TabIndex = 1; + this.button2.Text = "25"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button3.Location = new System.Drawing.Point(69, 42); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(50, 23); + this.button3.TabIndex = 2; + this.button3.Text = "33"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button4 + // + this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button4.Location = new System.Drawing.Point(125, 42); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(50, 23); + this.button4.TabIndex = 3; + this.button4.Text = "66"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button5 + // + this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button5.Location = new System.Drawing.Point(13, 72); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(50, 23); + this.button5.TabIndex = 4; + this.button5.Text = "125"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // button6 + // + this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button6.Location = new System.Drawing.Point(69, 71); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(50, 23); + this.button6.TabIndex = 5; + this.button6.Text = "250"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // button7 + // + this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button7.Location = new System.Drawing.Point(125, 71); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(50, 23); + this.button7.TabIndex = 6; + this.button7.Text = "333"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button7_Click); + // + // button8 + // + this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button8.Location = new System.Drawing.Point(13, 101); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(50, 23); + this.button8.TabIndex = 7; + this.button8.Text = "500"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button8_Click); + // + // button9 + // + this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button9.Location = new System.Drawing.Point(69, 100); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(50, 23); + this.button9.TabIndex = 8; + this.button9.Text = "1000"; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.button9_Click); + // + // button10 + // + this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button10.Location = new System.Drawing.Point(125, 100); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(50, 23); + this.button10.TabIndex = 9; + this.button10.Text = "1500"; + this.button10.UseVisualStyleBackColor = true; + this.button10.Click += new System.EventHandler(this.button10_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(29, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 20); + this.label1.TabIndex = 10; + this.label1.Text = "Select SR"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(13, 137); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(50, 20); + this.label2.TabIndex = 11; + this.label2.Text = "QRG:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(65, 137); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(122, 20); + this.label3.TabIndex = 12; + this.label3.Text = "10491.500 MHz"; + // + // SRForm + // + this.ClientSize = new System.Drawing.Size(188, 175); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button3); + this.Controls.Add(this.button4); + this.Controls.Add(this.button5); + this.Controls.Add(this.button6); + this.Controls.Add(this.button7); + this.Controls.Add(this.button8); + this.Controls.Add(this.button9); + this.Controls.Add(this.button10); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SRForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + public uint getsr() + { + return SR; + } + + private void button1_Click(object sender, EventArgs e) + { + SR = 0; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button3_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button4_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button5_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button6_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button7_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button8_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button9_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button10_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.resx b/ExtraFeatures/BATCSpectrum/SRForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 09cd735..2e4011f 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,14 @@ + + Form + + + True + True + SRForm.resx + @@ -464,6 +472,11 @@ externalToolsManager.cs + + SRForm.cs + ResXFileCodeGenerator + SRForm.Designer.cs + WebChatSettngsForm.cs From 83ccf446f14c54c0c6f435ed1197661f4787af3d Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 19:39:10 +0100 Subject: [PATCH 17/98] Update signal.cs max_strength added show a line in signal which represents max. allowed strength. Some small name changes. --- ExtraFeatures/BATCSpectrum/signal.cs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index ded7510..cc90c77 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -26,8 +26,9 @@ public struct Sig public float sr; public string callsign; public bool overpower; + public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool overpower, float _dbb) + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; @@ -36,11 +37,12 @@ public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, do this.frequency = _frequency; this.sr = _sr; this.callsign = ""; - this.overpower = overpower; + this.overpower = _overpower; + this.max_strength = _max_strength; this.dbb = _dbb; } - public Sig(Sig old, string callsign) + public Sig(Sig old, string _callsign) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; @@ -48,28 +50,30 @@ public Sig(Sig old, string callsign) this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; - this.callsign = callsign; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public Sig(Sig old, string callsign, float sr) + public Sig(Sig old, string _callsign, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; this.frequency = old.frequency; - this.sr = sr; - this.callsign = callsign; + this.sr = _sr; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public void updateCallsign(string callsign) + public void updateCallsign(string _callsign) { - this.callsign = callsign; + this.callsign = _callsign; } } @@ -507,11 +511,12 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); } else { bool overpower = false; + int max_strength = (int)(beacon_strength - (0.75 * 3276.8)); // // The original dBb calculation code used at the QO-100 wideband spectrum web site is complicated: // @@ -543,8 +548,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); } } From 556f3c178574a233ca8e3fd516596d288f9d1d81 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 19:58:22 +0100 Subject: [PATCH 18/98] Update BATCSpectrum.cs Red overpower box changed. Red overpower line added. Manual RX symbolrate selection added. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 59 +++++++++++++++------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index f6f7374..1ccf345 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -32,6 +32,7 @@ public class BATCSpectrum Pen greyPen = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); + Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -459,7 +460,8 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 10), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 10), height - Convert.ToInt16(sig.max_strength)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } } @@ -476,7 +478,7 @@ private void drawspectrum(UInt16[] fft_data) private void spectrum_Click(object sender, EventArgs e) { - + int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; float spectrum_wScale = spectrum_w / 922; @@ -486,29 +488,48 @@ private void spectrum_Click(object sender, EventArgs e) int X = pos.X; int Y = pos.Y; - if (me.Button == MouseButtons.Right) + if (Y > spectrum_h) { - int spectrum_h = _spectrum.Height - bandplan_height; - - if (Y > spectrum_h) + switch (me.Button) { - int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); - //UpdateTextBox(txtFreq, freq.ToString()); - - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) - { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; - } + case MouseButtons.Left: + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + break; + default: + break; } } else { - selectSignal(X, Y); + switch (me.Button) + { + case MouseButtons.Left: + selectSignal(X, Y); + break; + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form + { + srForm.StartPosition = FormStartPosition.CenterParent; + DialogResult result = srForm.ShowDialog(); + if (result == DialogResult.OK) + { + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); + } + } + break; + default: + break; + } } } From cac6dafdf0d4c8e096a84b4bbf4c1dad5be813c2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Tue, 5 Nov 2024 21:44:25 +0100 Subject: [PATCH 19/98] Update BATCSpectrum.cs locate SRForm dynamically to BATC spectrum window. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 1ccf345..ae1b7a6 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -519,7 +519,18 @@ private void spectrum_Click(object sender, EventArgs e) using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form { - srForm.StartPosition = FormStartPosition.CenterParent; + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_srForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int srForm_width = srForm.Size.Width; + + if (X > (srForm_width/2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width/2; + if (X > (spectrum_width - srForm.Size.Width/2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); + + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; DialogResult result = srForm.ShowDialog(); if (result == DialogResult.OK) { From f2149cef981139f627f8549791d4d26b462b4ce2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 13:53:42 +0100 Subject: [PATCH 20/98] bandplan.xml added to source control and project --- bandplan.xml | 321 +++++++++++++++++++++++++++++++++++++++++++++++ opentuner.csproj | 3 + 2 files changed, 324 insertions(+) create mode 100644 bandplan.xml diff --git a/bandplan.xml b/bandplan.xml new file mode 100644 index 0000000..f0625f5 --- /dev/null +++ b/bandplan.xml @@ -0,0 +1,321 @@ + + + + 10491.5 + 2402 + 1500 + BEACON + A + + + 10493.25 + 2403.75 + 1000 + 1500/1000 + A + + + 10494.75 + 2405.25 + 1000 + 1500/1000 + A + + + 10496.25 + 2406.75 + 1000 + 1500/1000 + A + + + 10492.75 + 2403.25 + 333 + 500/333/250 + B + + + 10493.25 + 2403.75 + 333 + 500/333/250 + B + + + 10493.75 + 2404.25 + 333 + 500/333/250 + B + + + 10494.25 + 2404.75 + 333 + 500/333/250 + B + + + 10494.75 + 2405.25 + 333 + 500/333/250 + B + + + 10495.25 + 2405.75 + 333 + 500/333/250 + B + + + 10495.75 + 2406.25 + 333 + 500/333/250 + B + + + 10496.25 + 2406.75 + 333 + 500/333/250 + B + + + 10496.75 + 2407.25 + 333 + 500/333/250 + B + + + 10497.25 + 2407.75 + 333 + 333/250 + B + + + 10497.75 + 2408.25 + 333 + 333/250 + B + + + 10498.25 + 2408.75 + 333 + 333/250 + B + + + 10498.75 + 2409.25 + 333 + 333/250 + B + + + 10499.25 + 2409.75 + 333 + 333/250 + B + + + 10492.75 + 2403.25 + 125 + 125/66/33 + C + + + 10493 + 2403.5 + 125 + 125/66/33 + C + + + 10493.25 + 2403.75 + 125 + 125/66/33 + C + + + 10493.5 + 2404 + 125 + 125/66/33 + C + + + 10493.75 + 2404.25 + 125 + 125/66/33 + C + + + 10494 + 2404.5 + 125 + 125/66/33 + C + + + 10494.25 + 2404.75 + 125 + 125/66/33 + C + + + 10494.5 + 2405 + 125 + 125/66/33 + C + + + 10494.75 + 2405.25 + 125 + 125/66/33 + C + + + 10495 + 2405.5 + 125 + 125/66/33 + C + + + 10495.25 + 2405.75 + 125 + 125/66/33 + C + + + 10495.5 + 2406 + 125 + 125/66/33 + C + + + 10495.75 + 2406.25 + 125 + 125/66/33 + C + + + 10496 + 2406.5 + 125 + 125/66/33 + C + + + 10496.25 + 2406.75 + 125 + 125/66/33 + C + + + 10496.5 + 2407 + 125 + 125/66/33 + C + + + 10496.75 + 2407.25 + 125 + 125/66/33 + C + + + 10497 + 2407.5 + 125 + 125/66/33 + C + + + 10497.25 + 2407.75 + 125 + 125/66/33 + C + + + 10497.5 + 2408 + 125 + 125/66/33 + C + + + 10497.75 + 2408.25 + 125 + 125/66/33 + C + + + 10498 + 2408.5 + 125 + 125/66/33 + C + + + 10498.25 + 2408.75 + 125 + 125/66/33 + C + + + 10498.5 + 2409 + 125 + 125/66/33 + C + + + 10498.75 + 2409.25 + 125 + 125/66/33 + C + + + 10499 + 2409.5 + 125 + 125/66/33 + C + + + 10499.25 + 2409.75 + 125 + 125/66/33 + C + + + + + \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 2e4011f..1a546ee 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -625,6 +625,9 @@ + + PreserveNewest + From 3594bfb874b32d588c920a4b079a47188ad19910 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 13:55:11 +0100 Subject: [PATCH 21/98] "Tuning Mode" and "Avoid Beacon" checkbox added. --- .../QuickTuneControlSettings.cs | 2 + .../QuickTuneControlSettingsForm.Designer.cs | 167 ++++++++++++++++-- .../QuickTuneControlSettingsForm.cs | 21 +++ 3 files changed, 174 insertions(+), 16 deletions(-) diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs index 229a116..5a22b23 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs @@ -9,5 +9,7 @@ namespace opentuner.ExtraFeatures.QuickTuneControl public class QuickTuneControlSettings { public int[] UDPListenPorts = { 6789, 6790, 6791, 6792 }; + public int[] TuningMode = { 0, 0, 0, 0 }; + public bool[] AvoidBeacon = { true, true, true, true }; } } diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs index 7fe756c..5df9813 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs @@ -39,7 +39,17 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.btnSave = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.Tuner4TuningMode = new System.Windows.Forms.ComboBox(); + this.Tuner3TuningMode = new System.Windows.Forms.ComboBox(); + this.Tuner2TuningMode = new System.Windows.Forms.ComboBox(); + this.Tuner1TuningMode = new System.Windows.Forms.ComboBox(); + this.AvoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.AvoidBeacon2 = new System.Windows.Forms.CheckBox(); + this.AvoidBeacon3 = new System.Windows.Forms.CheckBox(); + this.AvoidBeacon4 = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -56,23 +66,23 @@ private void InitializeComponent() this.groupBox1.Margin = new System.Windows.Forms.Padding(4); this.groupBox1.Name = "groupBox1"; this.groupBox1.Padding = new System.Windows.Forms.Padding(4); - this.groupBox1.Size = new System.Drawing.Size(320, 204); + this.groupBox1.Size = new System.Drawing.Size(198, 181); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Quick Tune UDP Settings"; // // txtUdp4 // - this.txtUdp4.Location = new System.Drawing.Point(161, 145); + this.txtUdp4.Location = new System.Drawing.Point(130, 145); this.txtUdp4.Margin = new System.Windows.Forms.Padding(4); this.txtUdp4.Name = "txtUdp4"; - this.txtUdp4.Size = new System.Drawing.Size(132, 22); + this.txtUdp4.Size = new System.Drawing.Size(53, 22); this.txtUdp4.TabIndex = 7; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(27, 149); + this.label4.Location = new System.Drawing.Point(8, 148); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(114, 16); @@ -81,16 +91,16 @@ private void InitializeComponent() // // txtUdp3 // - this.txtUdp3.Location = new System.Drawing.Point(161, 113); + this.txtUdp3.Location = new System.Drawing.Point(130, 113); this.txtUdp3.Margin = new System.Windows.Forms.Padding(4); this.txtUdp3.Name = "txtUdp3"; - this.txtUdp3.Size = new System.Drawing.Size(132, 22); + this.txtUdp3.Size = new System.Drawing.Size(53, 22); this.txtUdp3.TabIndex = 5; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(27, 117); + this.label3.Location = new System.Drawing.Point(8, 116); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(114, 16); @@ -99,16 +109,16 @@ private void InitializeComponent() // // txtUdp2 // - this.txtUdp2.Location = new System.Drawing.Point(161, 81); + this.txtUdp2.Location = new System.Drawing.Point(130, 81); this.txtUdp2.Margin = new System.Windows.Forms.Padding(4); this.txtUdp2.Name = "txtUdp2"; - this.txtUdp2.Size = new System.Drawing.Size(132, 22); + this.txtUdp2.Size = new System.Drawing.Size(53, 22); this.txtUdp2.TabIndex = 3; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(27, 85); + this.label2.Location = new System.Drawing.Point(8, 84); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(114, 16); @@ -117,16 +127,16 @@ private void InitializeComponent() // // txtUdp1 // - this.txtUdp1.Location = new System.Drawing.Point(161, 49); + this.txtUdp1.Location = new System.Drawing.Point(130, 49); this.txtUdp1.Margin = new System.Windows.Forms.Padding(4); this.txtUdp1.Name = "txtUdp1"; - this.txtUdp1.Size = new System.Drawing.Size(132, 22); + this.txtUdp1.Size = new System.Drawing.Size(53, 22); this.txtUdp1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(27, 53); + this.label1.Location = new System.Drawing.Point(8, 52); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(114, 16); @@ -135,7 +145,7 @@ private void InitializeComponent() // // btnSave // - this.btnSave.Location = new System.Drawing.Point(236, 226); + this.btnSave.Location = new System.Drawing.Point(377, 203); this.btnSave.Margin = new System.Windows.Forms.Padding(4); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(100, 28); @@ -147,7 +157,7 @@ private void InitializeComponent() // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(128, 226); + this.btnCancel.Location = new System.Drawing.Point(269, 203); this.btnCancel.Margin = new System.Windows.Forms.Padding(4); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(100, 28); @@ -156,17 +166,131 @@ private void InitializeComponent() this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // + // groupBox2 + // + this.groupBox2.Controls.Add(this.AvoidBeacon4); + this.groupBox2.Controls.Add(this.AvoidBeacon3); + this.groupBox2.Controls.Add(this.AvoidBeacon2); + this.groupBox2.Controls.Add(this.AvoidBeacon1); + this.groupBox2.Controls.Add(this.Tuner4TuningMode); + this.groupBox2.Controls.Add(this.Tuner3TuningMode); + this.groupBox2.Controls.Add(this.Tuner2TuningMode); + this.groupBox2.Controls.Add(this.Tuner1TuningMode); + this.groupBox2.Location = new System.Drawing.Point(221, 15); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(256, 181); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Tuning Mode"; + // + // Tuner4TuningMode + // + this.Tuner4TuningMode.FormattingEnabled = true; + this.Tuner4TuningMode.Items.AddRange(new object[] { + "Manual", + "Auto (Hold)", + "Auto (Timed)"}); + this.Tuner4TuningMode.Location = new System.Drawing.Point(6, 145); + this.Tuner4TuningMode.Name = "Tuner4TuningMode"; + this.Tuner4TuningMode.Size = new System.Drawing.Size(121, 24); + this.Tuner4TuningMode.TabIndex = 3; + // + // Tuner3TuningMode + // + this.Tuner3TuningMode.FormattingEnabled = true; + this.Tuner3TuningMode.Items.AddRange(new object[] { + "Manual", + "Auto (Hold)", + "Auto (Timed)"}); + this.Tuner3TuningMode.Location = new System.Drawing.Point(6, 113); + this.Tuner3TuningMode.Name = "Tuner3TuningMode"; + this.Tuner3TuningMode.Size = new System.Drawing.Size(121, 24); + this.Tuner3TuningMode.TabIndex = 2; + // + // Tuner2TuningMode + // + this.Tuner2TuningMode.FormattingEnabled = true; + this.Tuner2TuningMode.Items.AddRange(new object[] { + "Manual", + "Auto (Hold)", + "Auto (Timed)"}); + this.Tuner2TuningMode.Location = new System.Drawing.Point(6, 81); + this.Tuner2TuningMode.Name = "Tuner2TuningMode"; + this.Tuner2TuningMode.Size = new System.Drawing.Size(121, 24); + this.Tuner2TuningMode.TabIndex = 1; + // + // Tuner1TuningMode + // + this.Tuner1TuningMode.FormattingEnabled = true; + this.Tuner1TuningMode.Items.AddRange(new object[] { + "Manual", + "Auto (Hold)", + "Auto (Timed)"}); + this.Tuner1TuningMode.Location = new System.Drawing.Point(6, 49); + this.Tuner1TuningMode.Name = "Tuner1TuningMode"; + this.Tuner1TuningMode.Size = new System.Drawing.Size(121, 24); + this.Tuner1TuningMode.TabIndex = 0; + // + // AvoidBeacon1 + // + this.AvoidBeacon1.AutoSize = true; + this.AvoidBeacon1.Checked = true; + this.AvoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.AvoidBeacon1.Location = new System.Drawing.Point(133, 51); + this.AvoidBeacon1.Name = "AvoidBeacon1"; + this.AvoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.AvoidBeacon1.TabIndex = 4; + this.AvoidBeacon1.Text = "Avoid Beacon"; + this.AvoidBeacon1.UseVisualStyleBackColor = true; + // + // AvoidBeacon2 + // + this.AvoidBeacon2.AutoSize = true; + this.AvoidBeacon2.Checked = true; + this.AvoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; + this.AvoidBeacon2.Location = new System.Drawing.Point(133, 83); + this.AvoidBeacon2.Name = "AvoidBeacon2"; + this.AvoidBeacon2.Size = new System.Drawing.Size(111, 20); + this.AvoidBeacon2.TabIndex = 5; + this.AvoidBeacon2.Text = "Avoid Beacon"; + this.AvoidBeacon2.UseVisualStyleBackColor = true; + // + // AvoidBeacon3 + // + this.AvoidBeacon3.AutoSize = true; + this.AvoidBeacon3.Checked = true; + this.AvoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; + this.AvoidBeacon3.Location = new System.Drawing.Point(133, 115); + this.AvoidBeacon3.Name = "AvoidBeacon3"; + this.AvoidBeacon3.Size = new System.Drawing.Size(111, 20); + this.AvoidBeacon3.TabIndex = 6; + this.AvoidBeacon3.Text = "Avoid Beacon"; + this.AvoidBeacon3.UseVisualStyleBackColor = true; + // + // AvoidBeacon4 + // + this.AvoidBeacon4.AutoSize = true; + this.AvoidBeacon4.Checked = true; + this.AvoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; + this.AvoidBeacon4.Location = new System.Drawing.Point(133, 147); + this.AvoidBeacon4.Name = "AvoidBeacon4"; + this.AvoidBeacon4.Size = new System.Drawing.Size(111, 20); + this.AvoidBeacon4.TabIndex = 7; + this.AvoidBeacon4.Text = "Avoid Beacon"; + this.AvoidBeacon4.UseVisualStyleBackColor = true; + // // QuickTuneControlSettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(360, 273); + this.ClientSize = new System.Drawing.Size(489, 243); this.ControlBox = false; this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnSave); this.Controls.Add(this.groupBox1); + this.Controls.Add(this.groupBox2); this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(4); @@ -175,6 +299,8 @@ private void InitializeComponent() this.Text = "Quick Tune Listener Settings"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); } @@ -190,6 +316,15 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtUdp1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.ComboBox Tuner1TuningMode; + private System.Windows.Forms.ComboBox Tuner2TuningMode; + private System.Windows.Forms.ComboBox Tuner3TuningMode; + private System.Windows.Forms.ComboBox Tuner4TuningMode; + private System.Windows.Forms.CheckBox AvoidBeacon1; + private System.Windows.Forms.CheckBox AvoidBeacon2; + private System.Windows.Forms.CheckBox AvoidBeacon3; + private System.Windows.Forms.CheckBox AvoidBeacon4; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnCancel; } diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs index d301496..6d53535 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs @@ -23,6 +23,14 @@ public QuickTuneControlSettingsForm(ref QuickTuneControlSettings Settings) txtUdp2.Text = _settings.UDPListenPorts[1].ToString(); txtUdp3.Text = _settings.UDPListenPorts[2].ToString(); txtUdp4.Text = _settings.UDPListenPorts[3].ToString(); + Tuner1TuningMode.SelectedIndex = _settings.TuningMode[0]; + Tuner2TuningMode.SelectedIndex = _settings.TuningMode[1]; + Tuner3TuningMode.SelectedIndex = _settings.TuningMode[2]; + Tuner4TuningMode.SelectedIndex = _settings.TuningMode[3]; + AvoidBeacon1.Checked = _settings.AvoidBeacon[0]; + AvoidBeacon2.Checked = _settings.AvoidBeacon[1]; + AvoidBeacon3.Checked = _settings.AvoidBeacon[2]; + AvoidBeacon4.Checked = _settings.AvoidBeacon[3]; } private void btnCancel_Click(object sender, EventArgs e) @@ -66,9 +74,22 @@ private void btnSave_Click(object sender, EventArgs e) _settings.UDPListenPorts[1] = udp2; _settings.UDPListenPorts[2] = udp3; _settings.UDPListenPorts[3] = udp4; + _settings.TuningMode[0] = Tuner1TuningMode.SelectedIndex; + _settings.TuningMode[1] = Tuner2TuningMode.SelectedIndex; + _settings.TuningMode[2] = Tuner3TuningMode.SelectedIndex; + _settings.TuningMode[3] = Tuner4TuningMode.SelectedIndex; + _settings.AvoidBeacon[0] = AvoidBeacon1.Checked; + _settings.AvoidBeacon[1] = AvoidBeacon2.Checked; + _settings.AvoidBeacon[2] = AvoidBeacon3.Checked; + _settings.AvoidBeacon[3] = AvoidBeacon4.Checked; DialogResult = DialogResult.OK; Close(); } + + private void button1_Click(object sender, EventArgs e) + { + + } } } From 55bf2adb27897a1436898c5d62751ab43ed822c0 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 13:57:56 +0100 Subject: [PATCH 22/98] Update BATCSpectrum.cs New pluto_control_enabled and quicktune_enabled flags added to avoid actions in spectrum if feature is not available. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 126 +++++++++++---------- 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index ae1b7a6..f9dda4f 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -74,6 +74,9 @@ public class BATCSpectrum private int mousePos_x = 0; private int mousePos_y = 0; + public bool quicktune_enabled = false; + public bool pluto_control_enabled = false; + public void updateSignalCallsign(string callsign, double freq, float sr) { sigs.updateCurrentSignal(callsign, freq, sr); @@ -413,10 +416,10 @@ private void drawspectrum(UInt16[] fft_data) points[0] = new PointF(0, height); points[points.Length - 1] = new PointF(spectrum_w, height); - if (spectrumTunerHighlight > -1) + if (spectrumTunerHighlight > -1 && quicktune_enabled) { y = spectrumTunerHighlight * (spectrum_h / _tuners); - tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h/_tuners))); + tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); } //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); @@ -435,15 +438,17 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan y = 0; - - for (int tuner = 0; tuner < _tuners; tuner++) + if (quicktune_enabled) { - y = tuner * (spectrum_h / _tuners); - - //draw block showing signal selected - if (rx_blocks[tuner, 0] > 0) + for (int tuner = 0; tuner < _tuners; tuner++) { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale)/2) , y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + y = tuner * (spectrum_h / _tuners); + + //draw block showing signal selected + if (rx_blocks[tuner, 0] > 0) + { + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + } } } @@ -465,14 +470,16 @@ private void drawspectrum(UInt16[] fft_data) } } } - - for (i = 0; i < _tuners; i++) + + if (quicktune_enabled) { - y = i * (spectrum_h / _tuners); - tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + for (i = 0; i < _tuners; i++) + { + y = i * (spectrum_h / _tuners); + tmp.DrawLine(greyPen, 10, y, spectrum_w, y); + tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + } } - drawspectrum_signals(sigs.signalsData); } @@ -490,59 +497,64 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - switch (me.Button) + if (pluto_control_enabled) { - case MouseButtons.Left: - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) - { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; - } - break; - default: - break; + switch (me.Button) + { + case MouseButtons.Left: + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + break; + default: + break; + } } } else { - switch (me.Button) + if (quicktune_enabled) { - case MouseButtons.Left: - selectSignal(X, Y); - break; - case MouseButtons.Right: - uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + switch (me.Button) + { + case MouseButtons.Left: + selectSignal(X, Y); + break; + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); - using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form - { - Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); - Point new_srForm_location = spectrum_screen_location; - int spectrum_width = _spectrum.Size.Width; - int srForm_width = srForm.Size.Width; - - if (X > (srForm_width/2)) - new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width/2; - if (X > (spectrum_width - srForm.Size.Width/2)) - new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); - - srForm.StartPosition = FormStartPosition.Manual; - srForm.Location = new_srForm_location; - DialogResult result = srForm.ShowDialog(); - if (result == DialogResult.OK) + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form { - OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_srForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int srForm_width = srForm.Size.Width; + + if (X > (srForm_width / 2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; + if (X > (spectrum_width - srForm.Size.Width / 2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); + + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; + DialogResult result = srForm.ShowDialog(); + if (result == DialogResult.OK) + { + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); + } } - } - break; - default: - break; + break; + default: + break; + } } } - } From 15e5efaa5f6b7bf1b5666aed35f4817602cfa8c5 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 13:59:09 +0100 Subject: [PATCH 23/98] Update MainForm.cs New quicktune_enabled flags added to avoid actions in spectrum if quicktune feature is not available. --- MainForm.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MainForm.cs b/MainForm.cs index e68c384..ff107ba 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -921,6 +921,7 @@ private bool ConnectSelectedSource() this.DoubleBuffered = true; batc_spectrum = new BATCSpectrum(spectrum, videoSource.GetVideoSourceCount()); batc_spectrum.OnSignalSelected += Batc_spectrum_OnSignalSelected; + batc_spectrum.quicktune_enabled = _settings.enable_quicktune_checkbox; } if (checkBatcChat.Checked) From 01fd0228a802e8b47cf974ff320c7975eb2b684d Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 14:19:57 +0100 Subject: [PATCH 24/98] Update BATCSpectrum.cs show Tuner lines and text always. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index f9dda4f..654e6d4 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -471,14 +471,11 @@ private void drawspectrum(UInt16[] fft_data) } } - if (quicktune_enabled) + for (i = 0; i < _tuners; i++) { - for (i = 0; i < _tuners; i++) - { - y = i * (spectrum_h / _tuners); - tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); - } + y = i * (spectrum_h / _tuners); + tmp.DrawLine(greyPen, 10, y, spectrum_w, y); + tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } drawspectrum_signals(sigs.signalsData); } From 75ac3346e5340ab56639e0845828a5125a246e96 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 14:34:02 +0100 Subject: [PATCH 25/98] Update BATCSpectrum.cs show Tuner lines and text always. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 654e6d4..a0ecbf9 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -438,17 +438,14 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan y = 0; - if (quicktune_enabled) + for (int tuner = 0; tuner < _tuners; tuner++) { - for (int tuner = 0; tuner < _tuners; tuner++) - { - y = tuner * (spectrum_h / _tuners); + y = tuner * (spectrum_h / _tuners); - //draw block showing signal selected - if (rx_blocks[tuner, 0] > 0) - { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); - } + //draw block showing signal selected + if (rx_blocks[tuner, 0] > 0) + { + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } } From 31e711f6ff5b85c3830fa41856c77d5f279e50c2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 15:33:32 +0100 Subject: [PATCH 26/98] no longer used tool strip menus removed. --- MainForm.Designer.cs | 29 ----------------------------- MainForm.cs | 23 ----------------------- MainForm.resx | 24 ------------------------ 3 files changed, 76 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index ad6b0b5..fe98cc0 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -552,35 +552,6 @@ private void InitializeComponent() this.contextSpectrumMenu.Name = "contextSpectrumMenu"; resources.ApplyResources(this.contextSpectrumMenu, "contextSpectrumMenu"); // - // autoTuneToolStripMenuItem - // - this.autoTuneToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.manualToolStripMenuItem, - this.autoTimedToolStripMenuItem, - this.autoHoldToolStripMenuItem}); - this.autoTuneToolStripMenuItem.Name = "autoTuneToolStripMenuItem"; - resources.ApplyResources(this.autoTuneToolStripMenuItem, "autoTuneToolStripMenuItem"); - // - // manualToolStripMenuItem - // - this.manualToolStripMenuItem.Checked = true; - this.manualToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.manualToolStripMenuItem.Name = "manualToolStripMenuItem"; - resources.ApplyResources(this.manualToolStripMenuItem, "manualToolStripMenuItem"); - this.manualToolStripMenuItem.Click += new System.EventHandler(this.manualToolStripMenuItem_Click); - // - // autoTimedToolStripMenuItem - // - this.autoTimedToolStripMenuItem.Name = "autoTimedToolStripMenuItem"; - resources.ApplyResources(this.autoTimedToolStripMenuItem, "autoTimedToolStripMenuItem"); - this.autoTimedToolStripMenuItem.Click += new System.EventHandler(this.autoTimedToolStripMenuItem_Click); - // - // autoHoldToolStripMenuItem - // - this.autoHoldToolStripMenuItem.Name = "autoHoldToolStripMenuItem"; - resources.ApplyResources(this.autoHoldToolStripMenuItem, "autoHoldToolStripMenuItem"); - this.autoHoldToolStripMenuItem.Click += new System.EventHandler(this.autoHoldToolStripMenuItem_Click); - // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { diff --git a/MainForm.cs b/MainForm.cs index ff107ba..2948ca9 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -649,29 +649,6 @@ private void qO100WidebandChatToolStripMenuItem_Click(object sender, EventArgs e batc_chat.Show(); } - private void manualToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(0); - manualToolStripMenuItem.Checked = true; - autoHoldToolStripMenuItem.Checked = false; - autoTimedToolStripMenuItem.Checked = false; - } - - private void autoTimedToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(2); - manualToolStripMenuItem.Checked = false; - autoHoldToolStripMenuItem.Checked = false; - autoTimedToolStripMenuItem.Checked = true; - } - - private void autoHoldToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(3); - manualToolStripMenuItem.Checked = false; - autoHoldToolStripMenuItem.Checked = true; - autoTimedToolStripMenuItem.Checked = false; - } private void configureCallsignToolStripMenuItem_Click(object sender, EventArgs e) { diff --git a/MainForm.resx b/MainForm.resx index 5eb08f2..19659b5 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -1539,30 +1539,6 @@ 437, 14 - - 144, 22 - - - &Manual - - - 144, 22 - - - Auto (Timed) - - - 144, 22 - - - Auto (Hold) - - - 157, 22 - - - AutoTune (RX1) - 158, 26 From 414364f0b6426c80e193f7506ffef20020c7ca9a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 15:37:05 +0100 Subject: [PATCH 27/98] Update WinterhillProperties.cs cosmetic --- MediaSources/Winterhill/WinterhillProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 7b60fd9..360d4d6 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -535,7 +535,7 @@ private void UpdateInfo(monitorMessage mm) { if (rx.scanstate == 2 || rx.scanstate == 3) { - Log.Information("Playing" + c.ToString()); + Log.Information("Playing " + c.ToString()); VideoChangeCB?.Invoke(c + 1, true); playing[c] = true; _tuner_properties[c].UpdateColor("demodstate", Color.PaleGreen); From 79db337d0f39526ed143f27e3f3f05c0a64f89de Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 15:38:22 +0100 Subject: [PATCH 28/98] Update signal.cs cosmetic --- ExtraFeatures/BATCSpectrum/signal.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index cc90c77..daab905 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -191,8 +191,6 @@ public Tuple tune(int mode, int time, int rx) } } - - // Log.Information("Count3:" + signals.Count().ToString()); if (change) { last_sig[rx] = next_sig[rx]; From 0fc49c5a00b4d29cabfc2b8698ae9ae183430e13 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 18:42:24 +0100 Subject: [PATCH 29/98] Update signal.cs prepare for tuner based avoid beacon function --- ExtraFeatures/BATCSpectrum/signal.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index daab905..eee09ad 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -99,18 +99,11 @@ public signal(object _list_lock) } - bool avoid_beacon = false; - private Sig[] last_sig = new Sig[8]; //last tune signal - detail private Sig[] next_sig = new Sig[8]; //last tune signal - detail private DateTime[] last_tuned_time = new DateTime[8]; //time the last signal was tuned - public void set_avoidbeacon(bool b) - { - avoid_beacon = b; - } - public void set_tuned(Sig s, int rx) { last_sig[rx] = s; @@ -158,7 +151,7 @@ public Tuple tune(int mode, int time, int rx) if ((t.Minutes * 60) + t.Seconds > time) { // Log.Information("elapsed: "+rx.ToString()); - next_sig[rx] = find_next(rx); + next_sig[rx] = find_next(rx, true); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -169,7 +162,7 @@ public Tuple tune(int mode, int time, int rx) { if (!find_signal(last_sig[rx], rx)) //if the selected signal goes off then find another one to tune to { - next_sig[rx] = find_next(rx); + next_sig[rx] = find_next(rx, true); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -182,7 +175,7 @@ public Tuple tune(int mode, int time, int rx) { if (!find_signal(last_sig[rx], rx)) //if the selected signal goes off then find another one to tune to { - next_sig[rx] = find_next(rx); + next_sig[rx] = find_next(rx, true); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -323,7 +316,7 @@ public void updateSignalList() } - private Sig find_next(int rx) + private Sig find_next(int rx, bool avoid_beacon) { Sig newsig = new Sig(); @@ -335,7 +328,7 @@ private Sig find_next(int rx) } else { - startfreq = startfreq = 10490; ; + startfreq = startfreq = 10490.5f; } // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); From 7b0256b116f0bedde6ee7b8667ea5fd5f7e4c54b Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 18:44:55 +0100 Subject: [PATCH 30/98] show tuned gray box in BATC Spectrum on tuner frequency and status. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 15 ++++++++++----- MainForm.cs | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index a0ecbf9..0363aa4 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -33,7 +33,7 @@ public class BATCSpectrum Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); - SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); + SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(200, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -43,7 +43,7 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; - int[,] rx_blocks = new int[4, 3]; + int[,] rx_blocks = new int[4, 3]; // first index: Tuner; second index: 0 := center, 1 := width double start_freq = 10490.5f; @@ -82,6 +82,13 @@ public void updateSignalCallsign(string callsign, double freq, float sr) sigs.updateCurrentSignal(callsign, freq, sr); } + public void updateTuner(int tuner, double freq, float sr) + { + double fft_factor = 922.0f / 9.0f; + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_factor); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_factor); + } + public BATCSpectrum(PictureBox Spectrum, int Tuners) { _spectrum = Spectrum; @@ -132,8 +139,6 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) sigs.set_num_rx_scan(num_rxs_to_scan); sigs.set_num_rx(1); - sigs.set_avoidbeacon(true); - SpectrumTuneTimer = new Timer(); SpectrumTuneTimer.Enabled = false; SpectrumTuneTimer.Interval = 1500; @@ -445,7 +450,7 @@ private void drawspectrum(UInt16[] fft_data) //draw block showing signal selected if (rx_blocks[tuner, 0] > 0) { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + tmp.FillRectangle(shadowBrush, new RectangleF((rx_blocks[tuner, 0] * spectrum_wScale) - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } } diff --git a/MainForm.cs b/MainForm.cs index 2948ca9..91bdc96 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -404,15 +404,25 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str */ } - if (batc_spectrum != null && properties.demod_locked) + if (batc_spectrum != null) { - float freq = properties.frequency; - float sr = properties.symbol_rate; - string callsign = properties.service_name; + int tuner = properties.video_number; - //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); + if (properties.demod_locked) + { + float freq = properties.frequency; + float sr = properties.symbol_rate; + string callsign = properties.service_name; + + //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); - batc_spectrum.updateSignalCallsign(callsign, freq/1000, sr/1000); + batc_spectrum.updateSignalCallsign(callsign, freq / 1000, sr / 1000); + batc_spectrum.updateTuner(tuner, freq / 1000, sr / 1000); + } + else + { + batc_spectrum.updateTuner(tuner, 0, 0); + } } From ac8f9e1daa20dcafcc35de7da0197ba226fbee36 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 6 Nov 2024 20:06:45 +0100 Subject: [PATCH 31/98] manual tuning improved --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 20 ++++++++++++++++++-- MainForm.cs | 16 +++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0363aa4..ff40ecd 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -43,7 +43,7 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; - int[,] rx_blocks = new int[4, 3]; // first index: Tuner; second index: 0 := center, 1 := width + int[,] rx_blocks = new int[4, 4]; // first index: Tuner; second index: 0 := center, 1 := width, 2 := demod_locked, 3 := switching double start_freq = 10490.5f; @@ -82,11 +82,25 @@ public void updateSignalCallsign(string callsign, double freq, float sr) sigs.updateCurrentSignal(callsign, freq, sr); } - public void updateTuner(int tuner, double freq, float sr) + public void updateTuner(int tuner, double freq, float sr, bool demod_locked) + { + double fft_factor = 922.0f / 9.0f; + if (demod_locked) + { + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_factor); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_factor); + rx_blocks[tuner, 2] = demod_locked ? 1 : 0; + rx_blocks[tuner, 3] = 0; + } + } + + public void switchTuner(int tuner, double freq, float sr) { double fft_factor = 922.0f / 9.0f; rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_factor); rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_factor); + rx_blocks[tuner, 2] = 0; + rx_blocks[tuner, 3] = 1; } public BATCSpectrum(PictureBox Spectrum, int Tuners) @@ -591,6 +605,8 @@ private void selectSignal(int X, int Y) sigs.set_tuned(s, rx); rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); + rx_blocks[rx, 2] = 0; + rx_blocks[rx, 3] = 1; UInt32 freq = Convert.ToUInt32((s.frequency) * 1000); UInt32 sr = Convert.ToUInt32((s.sr * 1000.0)); diff --git a/MainForm.cs b/MainForm.cs index 91bdc96..f6fc618 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -407,21 +407,14 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str if (batc_spectrum != null) { int tuner = properties.video_number; + float freq = properties.frequency; + float sr = properties.symbol_rate; + string callsign = properties.service_name; + batc_spectrum.updateTuner(tuner, freq / 1000, sr / 1000, properties.demod_locked); if (properties.demod_locked) { - float freq = properties.frequency; - float sr = properties.symbol_rate; - string callsign = properties.service_name; - - //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); - batc_spectrum.updateSignalCallsign(callsign, freq / 1000, sr / 1000); - batc_spectrum.updateTuner(tuner, freq / 1000, sr / 1000); - } - else - { - batc_spectrum.updateTuner(tuner, 0, 0); } } @@ -635,6 +628,7 @@ private void Form1_Load(object sender, EventArgs e) private void Batc_spectrum_OnSignalSelected(int Receiver, uint Freq, uint SymbolRate) { videoSource.SetFrequency(Receiver, Freq, SymbolRate, true); + batc_spectrum.switchTuner(Receiver, Convert.ToDouble(Freq) / 1000.0f, SymbolRate / 1000.0f); } From 669ec9b1ed1ec0b1bcf472c6736540cd396d368f Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 10:07:04 +0100 Subject: [PATCH 32/98] Update WinterhillSource.cs Tuner 1 often do not set frequency at startup. Added a delay and wait for websockets to connect. Show message after 500mSec delay if the sockets still not connected and wait again --- MediaSources/Winterhill/WinterhillSource.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MediaSources/Winterhill/WinterhillSource.cs b/MediaSources/Winterhill/WinterhillSource.cs index 7972527..a0a0cdc 100644 --- a/MediaSources/Winterhill/WinterhillSource.cs +++ b/MediaSources/Winterhill/WinterhillSource.cs @@ -120,6 +120,15 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent break; } + while (!_connected) + { + Thread.Sleep(500); + if (!_connected) + { + Log.Information("Waiting on websockets to connect"); + } + } + for (int c = 0; c < ts_devices; c++) SetFrequency(c, _settings.DefaultFrequency[c], _settings.DefaultSR[c], true); From 9fb2a39234fb6c8b2064282db807d6b44e9cb008 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 10:07:04 +0100 Subject: [PATCH 33/98] Update WinterhillSource.cs Tuner 1 often do not set frequency at startup. Added a delay and wait for websockets to connect. Show message after 500mSec delay if the sockets still not connected and wait again --- MediaSources/Winterhill/WinterhillSource.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MediaSources/Winterhill/WinterhillSource.cs b/MediaSources/Winterhill/WinterhillSource.cs index 7972527..a0a0cdc 100644 --- a/MediaSources/Winterhill/WinterhillSource.cs +++ b/MediaSources/Winterhill/WinterhillSource.cs @@ -120,6 +120,15 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent break; } + while (!_connected) + { + Thread.Sleep(500); + if (!_connected) + { + Log.Information("Waiting on websockets to connect"); + } + } + for (int c = 0; c < ts_devices; c++) SetFrequency(c, _settings.DefaultFrequency[c], _settings.DefaultSR[c], true); From 5073ac2d61f755ea879b4c00b22e4163f48f7b08 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 12:35:12 +0100 Subject: [PATCH 34/98] Update SRForm.cs no control box --- ExtraFeatures/BATCSpectrum/SRForm.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs index 06bb871..89fb272 100644 --- a/ExtraFeatures/BATCSpectrum/SRForm.cs +++ b/ExtraFeatures/BATCSpectrum/SRForm.cs @@ -193,6 +193,7 @@ private void InitializeComponent() // SRForm // this.ClientSize = new System.Drawing.Size(188, 175); + this.ControlBox = false; this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); From 70cc17c17921aa9d451376665d3b1d52db17bf8f Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 12:36:30 +0100 Subject: [PATCH 35/98] Update BATCSpectrum.cs Spectrum Timer temporarily removed. Small optimizations. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 319 ++++++++++----------- 1 file changed, 159 insertions(+), 160 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index ff40ecd..81f8b05 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -25,7 +25,10 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); public static readonly int height = 246; //makes things easier - static readonly int bandplan_height = 30; + private static readonly int bandplan_height = 30; + private static double start_freq = 10490.5f; + private static double fft_scaling_factor = 922.0f / 9.0f; + Bitmap bmp; static Bitmap bmp2; @@ -43,9 +46,7 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; - int[,] rx_blocks = new int[4, 4]; // first index: Tuner; second index: 0 := center, 1 := width, 2 := demod_locked, 3 := switching - - double start_freq = 10490.5f; + int[,] rx_blocks = new int[4, 4]; // first index: Tuner; second index: 0 := center, 1 := width, 2 := demode locked state, 3 := switching flag XElement bandplan; Rectangle[] channels; @@ -63,7 +64,7 @@ public class BATCSpectrum private PictureBox _spectrum; private int _tuners; - Timer SpectrumTuneTimer; + //Timer SpectrumTuneTimer; Timer websocketTimer; private int _autoTuneMode = 0; @@ -84,23 +85,90 @@ public void updateSignalCallsign(string callsign, double freq, float sr) public void updateTuner(int tuner, double freq, float sr, bool demod_locked) { - double fft_factor = 922.0f / 9.0f; if (demod_locked) { - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_factor); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_factor); - rx_blocks[tuner, 2] = demod_locked ? 1 : 0; - rx_blocks[tuner, 3] = 0; + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_scaling_factor); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_scaling_factor); + rx_blocks[tuner, 2] = 1; // locked + rx_blocks[tuner, 3] = 0; // switching finished } } public void switchTuner(int tuner, double freq, float sr) { - double fft_factor = 922.0f / 9.0f; - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_factor); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_factor); - rx_blocks[tuner, 2] = 0; - rx_blocks[tuner, 3] = 1; + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_scaling_factor); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_scaling_factor); + rx_blocks[tuner, 2] = 0; // not locked + rx_blocks[tuner, 3] = 1; // switching started + } + + private void debug(string msg) + { + Log.Information(msg); + } + + // quicktune functions + private void drawspectrum_bandplan() + { + int span = 9; + int count = 0; + + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / 922; + + List blocks = new List(); + + //count blocks ('layers' of bandplan) + foreach (var channel in bandplan.Elements("channel")) + { + count++; + if (!blocks.Contains(channel.Element("block").Value)) + { + blocks.Add(channel.Element("block").Value); + } + } + + channels = new Rectangle[count]; + + int n = 0; + + //create rectangle blocks to display bandplan + foreach (var channel in bandplan.Elements("channel")) + { + int w = 0; + int offset = 0; + float rolloff = 1.35f; + string xval = channel.Element("x-freq").Value; + + float freq; + int sr; + + freq = Convert.ToSingle(xval, CultureInfo.InvariantCulture); + sr = Convert.ToInt32(channel.Element("sr").Value, CultureInfo.InvariantCulture); + + int pos = Convert.ToInt16((922.0 / span) * (freq - start_freq)); + w = Convert.ToInt32(sr / (span * 1000.0) * 922 * rolloff); + w = Convert.ToInt32(w * spectrum_wScale); + + int split = bandplan_height / blocks.Count(); + int b = blocks.Count(); + foreach (string blk in blocks) + { + if (channel.Element("block").Value == blk) + { + offset = b * split; + } + b--; + } + channels[n] = new Rectangle(Convert.ToInt32(pos * spectrum_wScale) - (w / 2), offset - (split / 2) - 3, w, split - 2); + n++; + } + + //draw blocks + for (int i = 0; i < count; i++) + { + tmp2.FillRectangles(bandplanBrush, new RectangleF[] { channels[i] }); //x,y,w,h + } } public BATCSpectrum(PictureBox Spectrum, int Tuners) @@ -153,10 +221,10 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) sigs.set_num_rx_scan(num_rxs_to_scan); sigs.set_num_rx(1); - SpectrumTuneTimer = new Timer(); - SpectrumTuneTimer.Enabled = false; - SpectrumTuneTimer.Interval = 1500; - SpectrumTuneTimer.Tick += new System.EventHandler(this.SpectrumTuneTimer_Tick); + //SpectrumTuneTimer = new Timer(); + //SpectrumTuneTimer.Enabled = false; + //SpectrumTuneTimer.Interval = 1500; + //SpectrumTuneTimer.Tick += new System.EventHandler(this.SpectrumTuneTimer_Tick); websocketTimer = new Timer(); websocketTimer.Interval = 2000; @@ -190,13 +258,13 @@ private void Web_socket_ConnectionStatusChanged(object sender, bool connection_s connect_retry_count = 0; } - else - { + //else + //{ // if we lost connection then disable autotune - _autoTuneMode = 0; - SpectrumTuneTimer.Enabled = false; - } - + //_autoTuneMode = 0; + //if (SpectrumTuneTimer != null) + // SpectrumTuneTimer.Enabled = false; + //} } public void Close() @@ -204,8 +272,8 @@ public void Close() websocketTimer?.Stop(); websocketTimer?.Dispose(); - SpectrumTuneTimer?.Stop(); - SpectrumTuneTimer?.Dispose(); + //SpectrumTuneTimer?.Stop(); + //SpectrumTuneTimer?.Dispose(); // stop socket web_socket?.stop(); @@ -238,45 +306,40 @@ private void websocketTimer_Tick(object sender, EventArgs e) } } - public void changeTuneMode(int mode) - { - _autoTuneMode = mode; - - if (mode == 0) - { - SpectrumTuneTimer?.Stop(); - } - else - { - SpectrumTuneTimer?.Start(); - } - - } - - private void SpectrumTuneTimer_Tick(object sender, EventArgs e) - { - int mode = _autoTuneMode; - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; - - ushort autotuneWait = 30; - - Tuple ret = sigs.tune(mode, Convert.ToInt16(autotuneWait), 0); - if (ret.Item1.frequency > 0) //above 0 is a change in signal - { - System.Threading.Thread.Sleep(100); - selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), 0); - sigs.set_tuned(ret.Item1, 0); - rx_blocks[0, 0] = Convert.ToInt16(ret.Item1.fft_centre); - rx_blocks[0, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); - } - - } - - private void debug(string msg) - { - Log.Information(msg); - } + //public void changeTuneMode(int mode) + //{ + // _autoTuneMode = mode; + // + // if (mode == 0) + // { + // SpectrumTuneTimer?.Stop(); + // } + // else + // { + // SpectrumTuneTimer?.Start(); + // } + // + //} + + //private void SpectrumTuneTimer_Tick(object sender, EventArgs e) + //{ + // int mode = _autoTuneMode; + // float spectrum_w = _spectrum.Width; + // float spectrum_wScale = spectrum_w / 922; + // + // ushort autotuneWait = 30; + // + // Tuple ret = sigs.tune(mode, Convert.ToInt16(autotuneWait), 0); + // if (ret.Item1.frequency > 0) //above 0 is a change in signal + // { + // System.Threading.Thread.Sleep(100); + // selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), 0); + // sigs.set_tuned(ret.Item1, 0); + // rx_blocks[0, 0] = Convert.ToInt16(ret.Item1.fft_centre); + // rx_blocks[0, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + // } + // + //} private void spectrum_MouseLeave(object sender, EventArgs e) { @@ -306,98 +369,6 @@ private void spectrum_SizeChanged(object sender, EventArgs e) } } - - // quicktune functions - private void drawspectrum_bandplan() - { - int span = 9; - int count = 0; - - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; - - List blocks = new List(); - - //count blocks ('layers' of bandplan) - foreach (var channel in bandplan.Elements("channel")) - { - count++; - if (!blocks.Contains(channel.Element("block").Value)) - { - blocks.Add(channel.Element("block").Value); - } - } - - channels = new Rectangle[count]; - - int n = 0; - - //create rectangle blocks to display bandplan - foreach (var channel in bandplan.Elements("channel")) - { - int w = 0; - int offset = 0; - float rolloff = 1.35f; - string xval = channel.Element("x-freq").Value; - - float freq; - int sr; - - freq = Convert.ToSingle(xval, CultureInfo.InvariantCulture); - sr = Convert.ToInt32(channel.Element("sr").Value, CultureInfo.InvariantCulture); - - int pos = Convert.ToInt16((922.0 / span) * (freq - start_freq)); - w = Convert.ToInt32(sr / (span * 1000.0) * 922 * rolloff); - w = Convert.ToInt32(w * spectrum_wScale); - - int split = bandplan_height / blocks.Count(); - int b = blocks.Count(); - foreach (string blk in blocks) - { - if (channel.Element("block").Value == blk) - { - offset = b * split; - } - b--; - } - channels[n] = new Rectangle(Convert.ToInt32(pos * spectrum_wScale) - (w / 2), offset - (split / 2) - 3, w, split - 2); - n++; - } - - //draw blocks - for (int i = 0; i < count; i++) - { - tmp2.FillRectangles(bandplanBrush, new RectangleF[] { channels[i] }); //x,y,w,h - } - } - - private void drawspectrum_signals(List signals) - { - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; - - lock (list_lock) //hopefully lock signals list while drawing - { - //draw the text for each signal found - foreach (signal.Sig s in signals) - { - if (check_mouse_over_signal(s)) - { - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); - } - else - { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); - } - } - } - - UpdateDrawing(); - } - private void UpdateDrawing() { try @@ -411,6 +382,7 @@ private void UpdateDrawing() } + // Entrypoint with new fft_data from websocket private void drawspectrum(UInt16[] fft_data) { tmp.Clear(Color.Black); //clear canvas @@ -493,7 +465,27 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawLine(greyPen, 10, y, spectrum_w, y); tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } - drawspectrum_signals(sigs.signalsData); + + lock (list_lock) //hopefully lock signals list while drawing + { + //draw the text for each signal found + foreach (var s in sigs.signalsData) + { + if (check_mouse_over_signal(s)) + { + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + } + else + { + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + } + } + } + + UpdateDrawing(); } private void spectrum_Click(object sender, EventArgs e) @@ -537,7 +529,14 @@ private void spectrum_Click(object sender, EventArgs e) switch (me.Button) { case MouseButtons.Left: - selectSignal(X, Y); + if (Control.ModifierKeys == Keys.Shift) + { + + } + else + { + selectSignal(X, Y); + } break; case MouseButtons.Right: uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); From b4528e72321dacae8bd243ca5a3e32cfd22c59f9 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 13:05:14 +0100 Subject: [PATCH 36/98] Adding Tune Mode Form --- .../QuickTuneTunerModeSettings.Designer.cs | 121 ++++++++++++++++++ .../QuickTuneTunerModeSettings.cs | 20 +++ .../QuickTuneTunerModeSettings.resx | 120 +++++++++++++++++ opentuner.csproj | 9 ++ 4 files changed, 270 insertions(+) create mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs create mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs create mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs new file mode 100644 index 0000000..52bb0cd --- /dev/null +++ b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs @@ -0,0 +1,121 @@ +namespace opentuner.ExtraFeatures.QuickTuneControl +{ + partial class QuickTuneTunerModeSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.Tuner1TuningMode = new System.Windows.Forms.ComboBox(); + this.AvoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.AvoidBeacon1); + this.groupBox2.Controls.Add(this.Tuner1TuningMode); + this.groupBox2.Location = new System.Drawing.Point(8, 12); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(229, 55); + this.groupBox2.TabIndex = 8; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Tuning Mode"; + // + // Tuner1TuningMode + // + this.Tuner1TuningMode.FormattingEnabled = true; + this.Tuner1TuningMode.Items.AddRange(new object[] { + "Manual", + "Auto (Hold)", + "Auto (Timed)"}); + this.Tuner1TuningMode.Location = new System.Drawing.Point(6, 19); + this.Tuner1TuningMode.Name = "Tuner1TuningMode"; + this.Tuner1TuningMode.Size = new System.Drawing.Size(121, 21); + this.Tuner1TuningMode.TabIndex = 0; + // + // AvoidBeacon1 + // + this.AvoidBeacon1.AutoSize = true; + this.AvoidBeacon1.Checked = true; + this.AvoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.AvoidBeacon1.Location = new System.Drawing.Point(133, 23); + this.AvoidBeacon1.Name = "AvoidBeacon1"; + this.AvoidBeacon1.Size = new System.Drawing.Size(93, 17); + this.AvoidBeacon1.TabIndex = 4; + this.AvoidBeacon1.Text = "Avoid Beacon"; + this.AvoidBeacon1.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(30, 74); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 28); + this.btnCancel.TabIndex = 9; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(138, 74); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 10; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + // + // QuickTuneTunerModeSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(249, 110); + this.ControlBox = false; + this.Controls.Add(this.btnSave); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.groupBox2); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "QuickTuneTunerModeSettings"; + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.CheckBox AvoidBeacon1; + private System.Windows.Forms.ComboBox Tuner1TuningMode; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs new file mode 100644 index 0000000..cddc523 --- /dev/null +++ b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.QuickTuneControl +{ + public partial class QuickTuneTunerModeSettings : Form + { + public QuickTuneTunerModeSettings() + { + InitializeComponent(); + } + } +} diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 1a546ee..238467e 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -275,6 +275,12 @@ QuickTuneControlSettingsForm.cs + + Form + + + QuickTuneTunerModeSettings.cs + @@ -489,6 +495,9 @@ QuickTuneControlSettingsForm.cs + + QuickTuneTunerModeSettings.cs + MainForm.cs From 2ff6d065dd7e4756424bda077416cb1679381828 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 15:08:36 +0100 Subject: [PATCH 37/98] Revert "Adding Tune Mode Form" This reverts commit b4528e72321dacae8bd243ca5a3e32cfd22c59f9. --- .../QuickTuneTunerModeSettings.Designer.cs | 121 ------------------ .../QuickTuneTunerModeSettings.cs | 20 --- .../QuickTuneTunerModeSettings.resx | 120 ----------------- opentuner.csproj | 9 -- 4 files changed, 270 deletions(-) delete mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs delete mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs delete mode 100644 ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs deleted file mode 100644 index 52bb0cd..0000000 --- a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.Designer.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace opentuner.ExtraFeatures.QuickTuneControl -{ - partial class QuickTuneTunerModeSettings - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.Tuner1TuningMode = new System.Windows.Forms.ComboBox(); - this.AvoidBeacon1 = new System.Windows.Forms.CheckBox(); - this.btnCancel = new System.Windows.Forms.Button(); - this.btnSave = new System.Windows.Forms.Button(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.AvoidBeacon1); - this.groupBox2.Controls.Add(this.Tuner1TuningMode); - this.groupBox2.Location = new System.Drawing.Point(8, 12); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(229, 55); - this.groupBox2.TabIndex = 8; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Tuning Mode"; - // - // Tuner1TuningMode - // - this.Tuner1TuningMode.FormattingEnabled = true; - this.Tuner1TuningMode.Items.AddRange(new object[] { - "Manual", - "Auto (Hold)", - "Auto (Timed)"}); - this.Tuner1TuningMode.Location = new System.Drawing.Point(6, 19); - this.Tuner1TuningMode.Name = "Tuner1TuningMode"; - this.Tuner1TuningMode.Size = new System.Drawing.Size(121, 21); - this.Tuner1TuningMode.TabIndex = 0; - // - // AvoidBeacon1 - // - this.AvoidBeacon1.AutoSize = true; - this.AvoidBeacon1.Checked = true; - this.AvoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; - this.AvoidBeacon1.Location = new System.Drawing.Point(133, 23); - this.AvoidBeacon1.Name = "AvoidBeacon1"; - this.AvoidBeacon1.Size = new System.Drawing.Size(93, 17); - this.AvoidBeacon1.TabIndex = 4; - this.AvoidBeacon1.Text = "Avoid Beacon"; - this.AvoidBeacon1.UseVisualStyleBackColor = true; - // - // btnCancel - // - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(30, 74); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 28); - this.btnCancel.TabIndex = 9; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - // - // btnSave - // - this.btnSave.Location = new System.Drawing.Point(138, 74); - this.btnSave.Margin = new System.Windows.Forms.Padding(4); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(100, 28); - this.btnSave.TabIndex = 10; - this.btnSave.Text = "Save"; - this.btnSave.UseVisualStyleBackColor = true; - // - // QuickTuneTunerModeSettings - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(249, 110); - this.ControlBox = false; - this.Controls.Add(this.btnSave); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.groupBox2); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "QuickTuneTunerModeSettings"; - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.CheckBox AvoidBeacon1; - private System.Windows.Forms.ComboBox Tuner1TuningMode; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Button btnSave; - } -} \ No newline at end of file diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs deleted file mode 100644 index cddc523..0000000 --- a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace opentuner.ExtraFeatures.QuickTuneControl -{ - public partial class QuickTuneTunerModeSettings : Form - { - public QuickTuneTunerModeSettings() - { - InitializeComponent(); - } - } -} diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx b/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ExtraFeatures/QuickTuneControl/QuickTuneTunerModeSettings.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 238467e..1a546ee 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -275,12 +275,6 @@ QuickTuneControlSettingsForm.cs - - Form - - - QuickTuneTunerModeSettings.cs - @@ -495,9 +489,6 @@ QuickTuneControlSettingsForm.cs - - QuickTuneTunerModeSettings.cs - MainForm.cs From 73de09befb8d2d95d1907182937d060db5eed7eb Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 15:17:49 +0100 Subject: [PATCH 38/98] "quicktune_enabled" removed BATC Spectrum has actual no dependency with quicktune feature. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 74 +++++++++++----------- MainForm.cs | 1 - 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 81f8b05..3e82700 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -75,7 +75,7 @@ public class BATCSpectrum private int mousePos_x = 0; private int mousePos_y = 0; - public bool quicktune_enabled = false; + //public bool quicktune_enabled = false; public bool pluto_control_enabled = false; public void updateSignalCallsign(string callsign, double freq, float sr) @@ -407,7 +407,8 @@ private void drawspectrum(UInt16[] fft_data) points[0] = new PointF(0, height); points[points.Length - 1] = new PointF(spectrum_w, height); - if (spectrumTunerHighlight > -1 && quicktune_enabled) + //if (spectrumTunerHighlight > -1 && quicktune_enabled) + if (spectrumTunerHighlight > -1) { y = spectrumTunerHighlight * (spectrum_h / _tuners); tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); @@ -524,47 +525,44 @@ private void spectrum_Click(object sender, EventArgs e) } else { - if (quicktune_enabled) + switch (me.Button) { - switch (me.Button) - { - case MouseButtons.Left: - if (Control.ModifierKeys == Keys.Shift) - { + case MouseButtons.Left: + if (Control.ModifierKeys == Keys.Shift) + { - } - else - { - selectSignal(X, Y); - } - break; - case MouseButtons.Right: - uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + } + else + { + selectSignal(X, Y); + } + break; + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); - using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_srForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int srForm_width = srForm.Size.Width; + + if (X > (srForm_width / 2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; + if (X > (spectrum_width - srForm.Size.Width / 2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); + + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; + DialogResult result = srForm.ShowDialog(); + if (result == DialogResult.OK) { - Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); - Point new_srForm_location = spectrum_screen_location; - int spectrum_width = _spectrum.Size.Width; - int srForm_width = srForm.Size.Width; - - if (X > (srForm_width / 2)) - new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; - if (X > (spectrum_width - srForm.Size.Width / 2)) - new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); - - srForm.StartPosition = FormStartPosition.Manual; - srForm.Location = new_srForm_location; - DialogResult result = srForm.ShowDialog(); - if (result == DialogResult.OK) - { - OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); - } + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); } - break; - default: - break; - } + } + break; + default: + break; } } } diff --git a/MainForm.cs b/MainForm.cs index f6fc618..4d9ae4b 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -902,7 +902,6 @@ private bool ConnectSelectedSource() this.DoubleBuffered = true; batc_spectrum = new BATCSpectrum(spectrum, videoSource.GetVideoSourceCount()); batc_spectrum.OnSignalSelected += Batc_spectrum_OnSignalSelected; - batc_spectrum.quicktune_enabled = _settings.enable_quicktune_checkbox; } if (checkBatcChat.Checked) From f9b17bd091c806d23866ca3fa55b198fd70c0acc Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 15:27:02 +0100 Subject: [PATCH 39/98] revert QuicktuneControlSettings --- .../QuickTuneControlSettings.cs | 2 - .../QuickTuneControlSettingsForm.Designer.cs | 167 ++---------------- .../QuickTuneControlSettingsForm.cs | 21 --- 3 files changed, 16 insertions(+), 174 deletions(-) diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs index 5a22b23..229a116 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettings.cs @@ -9,7 +9,5 @@ namespace opentuner.ExtraFeatures.QuickTuneControl public class QuickTuneControlSettings { public int[] UDPListenPorts = { 6789, 6790, 6791, 6792 }; - public int[] TuningMode = { 0, 0, 0, 0 }; - public bool[] AvoidBeacon = { true, true, true, true }; } } diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs index 5df9813..7fe756c 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.Designer.cs @@ -39,17 +39,7 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.btnSave = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.Tuner4TuningMode = new System.Windows.Forms.ComboBox(); - this.Tuner3TuningMode = new System.Windows.Forms.ComboBox(); - this.Tuner2TuningMode = new System.Windows.Forms.ComboBox(); - this.Tuner1TuningMode = new System.Windows.Forms.ComboBox(); - this.AvoidBeacon1 = new System.Windows.Forms.CheckBox(); - this.AvoidBeacon2 = new System.Windows.Forms.CheckBox(); - this.AvoidBeacon3 = new System.Windows.Forms.CheckBox(); - this.AvoidBeacon4 = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); - this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -66,23 +56,23 @@ private void InitializeComponent() this.groupBox1.Margin = new System.Windows.Forms.Padding(4); this.groupBox1.Name = "groupBox1"; this.groupBox1.Padding = new System.Windows.Forms.Padding(4); - this.groupBox1.Size = new System.Drawing.Size(198, 181); + this.groupBox1.Size = new System.Drawing.Size(320, 204); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Quick Tune UDP Settings"; // // txtUdp4 // - this.txtUdp4.Location = new System.Drawing.Point(130, 145); + this.txtUdp4.Location = new System.Drawing.Point(161, 145); this.txtUdp4.Margin = new System.Windows.Forms.Padding(4); this.txtUdp4.Name = "txtUdp4"; - this.txtUdp4.Size = new System.Drawing.Size(53, 22); + this.txtUdp4.Size = new System.Drawing.Size(132, 22); this.txtUdp4.TabIndex = 7; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(8, 148); + this.label4.Location = new System.Drawing.Point(27, 149); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(114, 16); @@ -91,16 +81,16 @@ private void InitializeComponent() // // txtUdp3 // - this.txtUdp3.Location = new System.Drawing.Point(130, 113); + this.txtUdp3.Location = new System.Drawing.Point(161, 113); this.txtUdp3.Margin = new System.Windows.Forms.Padding(4); this.txtUdp3.Name = "txtUdp3"; - this.txtUdp3.Size = new System.Drawing.Size(53, 22); + this.txtUdp3.Size = new System.Drawing.Size(132, 22); this.txtUdp3.TabIndex = 5; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(8, 116); + this.label3.Location = new System.Drawing.Point(27, 117); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(114, 16); @@ -109,16 +99,16 @@ private void InitializeComponent() // // txtUdp2 // - this.txtUdp2.Location = new System.Drawing.Point(130, 81); + this.txtUdp2.Location = new System.Drawing.Point(161, 81); this.txtUdp2.Margin = new System.Windows.Forms.Padding(4); this.txtUdp2.Name = "txtUdp2"; - this.txtUdp2.Size = new System.Drawing.Size(53, 22); + this.txtUdp2.Size = new System.Drawing.Size(132, 22); this.txtUdp2.TabIndex = 3; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(8, 84); + this.label2.Location = new System.Drawing.Point(27, 85); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(114, 16); @@ -127,16 +117,16 @@ private void InitializeComponent() // // txtUdp1 // - this.txtUdp1.Location = new System.Drawing.Point(130, 49); + this.txtUdp1.Location = new System.Drawing.Point(161, 49); this.txtUdp1.Margin = new System.Windows.Forms.Padding(4); this.txtUdp1.Name = "txtUdp1"; - this.txtUdp1.Size = new System.Drawing.Size(53, 22); + this.txtUdp1.Size = new System.Drawing.Size(132, 22); this.txtUdp1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(8, 52); + this.label1.Location = new System.Drawing.Point(27, 53); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(114, 16); @@ -145,7 +135,7 @@ private void InitializeComponent() // // btnSave // - this.btnSave.Location = new System.Drawing.Point(377, 203); + this.btnSave.Location = new System.Drawing.Point(236, 226); this.btnSave.Margin = new System.Windows.Forms.Padding(4); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(100, 28); @@ -157,7 +147,7 @@ private void InitializeComponent() // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(269, 203); + this.btnCancel.Location = new System.Drawing.Point(128, 226); this.btnCancel.Margin = new System.Windows.Forms.Padding(4); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(100, 28); @@ -166,131 +156,17 @@ private void InitializeComponent() this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // - // groupBox2 - // - this.groupBox2.Controls.Add(this.AvoidBeacon4); - this.groupBox2.Controls.Add(this.AvoidBeacon3); - this.groupBox2.Controls.Add(this.AvoidBeacon2); - this.groupBox2.Controls.Add(this.AvoidBeacon1); - this.groupBox2.Controls.Add(this.Tuner4TuningMode); - this.groupBox2.Controls.Add(this.Tuner3TuningMode); - this.groupBox2.Controls.Add(this.Tuner2TuningMode); - this.groupBox2.Controls.Add(this.Tuner1TuningMode); - this.groupBox2.Location = new System.Drawing.Point(221, 15); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(256, 181); - this.groupBox2.TabIndex = 7; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Tuning Mode"; - // - // Tuner4TuningMode - // - this.Tuner4TuningMode.FormattingEnabled = true; - this.Tuner4TuningMode.Items.AddRange(new object[] { - "Manual", - "Auto (Hold)", - "Auto (Timed)"}); - this.Tuner4TuningMode.Location = new System.Drawing.Point(6, 145); - this.Tuner4TuningMode.Name = "Tuner4TuningMode"; - this.Tuner4TuningMode.Size = new System.Drawing.Size(121, 24); - this.Tuner4TuningMode.TabIndex = 3; - // - // Tuner3TuningMode - // - this.Tuner3TuningMode.FormattingEnabled = true; - this.Tuner3TuningMode.Items.AddRange(new object[] { - "Manual", - "Auto (Hold)", - "Auto (Timed)"}); - this.Tuner3TuningMode.Location = new System.Drawing.Point(6, 113); - this.Tuner3TuningMode.Name = "Tuner3TuningMode"; - this.Tuner3TuningMode.Size = new System.Drawing.Size(121, 24); - this.Tuner3TuningMode.TabIndex = 2; - // - // Tuner2TuningMode - // - this.Tuner2TuningMode.FormattingEnabled = true; - this.Tuner2TuningMode.Items.AddRange(new object[] { - "Manual", - "Auto (Hold)", - "Auto (Timed)"}); - this.Tuner2TuningMode.Location = new System.Drawing.Point(6, 81); - this.Tuner2TuningMode.Name = "Tuner2TuningMode"; - this.Tuner2TuningMode.Size = new System.Drawing.Size(121, 24); - this.Tuner2TuningMode.TabIndex = 1; - // - // Tuner1TuningMode - // - this.Tuner1TuningMode.FormattingEnabled = true; - this.Tuner1TuningMode.Items.AddRange(new object[] { - "Manual", - "Auto (Hold)", - "Auto (Timed)"}); - this.Tuner1TuningMode.Location = new System.Drawing.Point(6, 49); - this.Tuner1TuningMode.Name = "Tuner1TuningMode"; - this.Tuner1TuningMode.Size = new System.Drawing.Size(121, 24); - this.Tuner1TuningMode.TabIndex = 0; - // - // AvoidBeacon1 - // - this.AvoidBeacon1.AutoSize = true; - this.AvoidBeacon1.Checked = true; - this.AvoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; - this.AvoidBeacon1.Location = new System.Drawing.Point(133, 51); - this.AvoidBeacon1.Name = "AvoidBeacon1"; - this.AvoidBeacon1.Size = new System.Drawing.Size(111, 20); - this.AvoidBeacon1.TabIndex = 4; - this.AvoidBeacon1.Text = "Avoid Beacon"; - this.AvoidBeacon1.UseVisualStyleBackColor = true; - // - // AvoidBeacon2 - // - this.AvoidBeacon2.AutoSize = true; - this.AvoidBeacon2.Checked = true; - this.AvoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; - this.AvoidBeacon2.Location = new System.Drawing.Point(133, 83); - this.AvoidBeacon2.Name = "AvoidBeacon2"; - this.AvoidBeacon2.Size = new System.Drawing.Size(111, 20); - this.AvoidBeacon2.TabIndex = 5; - this.AvoidBeacon2.Text = "Avoid Beacon"; - this.AvoidBeacon2.UseVisualStyleBackColor = true; - // - // AvoidBeacon3 - // - this.AvoidBeacon3.AutoSize = true; - this.AvoidBeacon3.Checked = true; - this.AvoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; - this.AvoidBeacon3.Location = new System.Drawing.Point(133, 115); - this.AvoidBeacon3.Name = "AvoidBeacon3"; - this.AvoidBeacon3.Size = new System.Drawing.Size(111, 20); - this.AvoidBeacon3.TabIndex = 6; - this.AvoidBeacon3.Text = "Avoid Beacon"; - this.AvoidBeacon3.UseVisualStyleBackColor = true; - // - // AvoidBeacon4 - // - this.AvoidBeacon4.AutoSize = true; - this.AvoidBeacon4.Checked = true; - this.AvoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; - this.AvoidBeacon4.Location = new System.Drawing.Point(133, 147); - this.AvoidBeacon4.Name = "AvoidBeacon4"; - this.AvoidBeacon4.Size = new System.Drawing.Size(111, 20); - this.AvoidBeacon4.TabIndex = 7; - this.AvoidBeacon4.Text = "Avoid Beacon"; - this.AvoidBeacon4.UseVisualStyleBackColor = true; - // // QuickTuneControlSettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(489, 243); + this.ClientSize = new System.Drawing.Size(360, 273); this.ControlBox = false; this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnSave); this.Controls.Add(this.groupBox1); - this.Controls.Add(this.groupBox2); this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(4); @@ -299,8 +175,6 @@ private void InitializeComponent() this.Text = "Quick Tune Listener Settings"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); this.ResumeLayout(false); } @@ -316,15 +190,6 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtUdp1; private System.Windows.Forms.Label label1; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.ComboBox Tuner1TuningMode; - private System.Windows.Forms.ComboBox Tuner2TuningMode; - private System.Windows.Forms.ComboBox Tuner3TuningMode; - private System.Windows.Forms.ComboBox Tuner4TuningMode; - private System.Windows.Forms.CheckBox AvoidBeacon1; - private System.Windows.Forms.CheckBox AvoidBeacon2; - private System.Windows.Forms.CheckBox AvoidBeacon3; - private System.Windows.Forms.CheckBox AvoidBeacon4; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnCancel; } diff --git a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs index 6d53535..d301496 100644 --- a/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs +++ b/ExtraFeatures/QuickTuneControl/QuickTuneControlSettingsForm.cs @@ -23,14 +23,6 @@ public QuickTuneControlSettingsForm(ref QuickTuneControlSettings Settings) txtUdp2.Text = _settings.UDPListenPorts[1].ToString(); txtUdp3.Text = _settings.UDPListenPorts[2].ToString(); txtUdp4.Text = _settings.UDPListenPorts[3].ToString(); - Tuner1TuningMode.SelectedIndex = _settings.TuningMode[0]; - Tuner2TuningMode.SelectedIndex = _settings.TuningMode[1]; - Tuner3TuningMode.SelectedIndex = _settings.TuningMode[2]; - Tuner4TuningMode.SelectedIndex = _settings.TuningMode[3]; - AvoidBeacon1.Checked = _settings.AvoidBeacon[0]; - AvoidBeacon2.Checked = _settings.AvoidBeacon[1]; - AvoidBeacon3.Checked = _settings.AvoidBeacon[2]; - AvoidBeacon4.Checked = _settings.AvoidBeacon[3]; } private void btnCancel_Click(object sender, EventArgs e) @@ -74,22 +66,9 @@ private void btnSave_Click(object sender, EventArgs e) _settings.UDPListenPorts[1] = udp2; _settings.UDPListenPorts[2] = udp3; _settings.UDPListenPorts[3] = udp4; - _settings.TuningMode[0] = Tuner1TuningMode.SelectedIndex; - _settings.TuningMode[1] = Tuner2TuningMode.SelectedIndex; - _settings.TuningMode[2] = Tuner3TuningMode.SelectedIndex; - _settings.TuningMode[3] = Tuner4TuningMode.SelectedIndex; - _settings.AvoidBeacon[0] = AvoidBeacon1.Checked; - _settings.AvoidBeacon[1] = AvoidBeacon2.Checked; - _settings.AvoidBeacon[2] = AvoidBeacon3.Checked; - _settings.AvoidBeacon[3] = AvoidBeacon4.Checked; DialogResult = DialogResult.OK; Close(); } - - private void button1_Click(object sender, EventArgs e) - { - - } } } From 0943daa890c1026a2fb66d933394af91da07a290 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:09:15 +0100 Subject: [PATCH 40/98] Update SRForm.cs show controlbox again. --- ExtraFeatures/BATCSpectrum/SRForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs index 89fb272..b2d76f2 100644 --- a/ExtraFeatures/BATCSpectrum/SRForm.cs +++ b/ExtraFeatures/BATCSpectrum/SRForm.cs @@ -193,7 +193,6 @@ private void InitializeComponent() // SRForm // this.ClientSize = new System.Drawing.Size(188, 175); - this.ControlBox = false; this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); @@ -214,6 +213,7 @@ private void InitializeComponent() this.ShowIcon = false; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.ResumeLayout(false); this.PerformLayout(); From 331d6de2b206af110e78abf4dcacf0149af15c0e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:10:33 +0100 Subject: [PATCH 41/98] adding tuneMode settings. --- .../BATCSpectrum/TuneModeSettings.cs | 14 + .../TuneModeSettingsForm.Designer.cs | 268 ++++++++++++++++++ .../BATCSpectrum/TuneModeSettingsForm.cs | 55 ++++ .../BATCSpectrum/TuneModeSettingsForm.resx | 120 ++++++++ .../oneTunerTuneModeForm.Designer.cs | 123 ++++++++ .../BATCSpectrum/oneTunerTuneModeForm.cs | 54 ++++ .../BATCSpectrum/oneTunerTuneModeForm.resx | 120 ++++++++ 7 files changed, 754 insertions(+) create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettings.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs new file mode 100644 index 0000000..3edba7e --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public class tuneModeSettings + { + public int[] tuneMode = { 1, 1, 1, 1 }; + public bool[] avoidBeacon = { true, true, true, true }; + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs new file mode 100644 index 0000000..b930338 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs @@ -0,0 +1,268 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class tuneModeSettingsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon4 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon3 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon2 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode4 = new System.Windows.Forms.ComboBox(); + this.tuneMode3 = new System.Windows.Forms.ComboBox(); + this.tuneMode2 = new System.Windows.Forms.ComboBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon4); + this.groupBox1.Controls.Add(this.avoidBeacon3); + this.groupBox1.Controls.Add(this.avoidBeacon2); + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode4); + this.groupBox1.Controls.Add(this.tuneMode3); + this.groupBox1.Controls.Add(this.tuneMode2); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 15); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 151); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon4 + // + this.avoidBeacon4.AutoSize = true; + this.avoidBeacon4.Checked = true; + this.avoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon4.Location = new System.Drawing.Point(177, 121); + this.avoidBeacon4.Name = "avoidBeacon4"; + this.avoidBeacon4.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon4.TabIndex = 11; + this.avoidBeacon4.Text = "Avoid Beacon"; + this.avoidBeacon4.UseVisualStyleBackColor = true; + // + // avoidBeacon3 + // + this.avoidBeacon3.AutoSize = true; + this.avoidBeacon3.Checked = true; + this.avoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon3.Location = new System.Drawing.Point(177, 91); + this.avoidBeacon3.Name = "avoidBeacon3"; + this.avoidBeacon3.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon3.TabIndex = 10; + this.avoidBeacon3.Text = "Avoid Beacon"; + this.avoidBeacon3.UseVisualStyleBackColor = true; + // + // avoidBeacon2 + // + this.avoidBeacon2.AutoSize = true; + this.avoidBeacon2.Checked = true; + this.avoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon2.Location = new System.Drawing.Point(177, 61); + this.avoidBeacon2.Name = "avoidBeacon2"; + this.avoidBeacon2.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon2.TabIndex = 9; + this.avoidBeacon2.Text = "Avoid Beacon"; + this.avoidBeacon2.UseVisualStyleBackColor = true; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 31); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode4 + // + this.tuneMode4.FormattingEnabled = true; + this.tuneMode4.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode4.Location = new System.Drawing.Point(50, 120); + this.tuneMode4.Name = "tuneMode4"; + this.tuneMode4.Size = new System.Drawing.Size(121, 21); + this.tuneMode4.TabIndex = 7; + // + // tuneMode3 + // + this.tuneMode3.FormattingEnabled = true; + this.tuneMode3.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode3.Location = new System.Drawing.Point(50, 90); + this.tuneMode3.Name = "tuneMode3"; + this.tuneMode3.Size = new System.Drawing.Size(121, 21); + this.tuneMode3.TabIndex = 6; + // + // tuneMode2 + // + this.tuneMode2.FormattingEnabled = true; + this.tuneMode2.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode2.Location = new System.Drawing.Point(50, 60); + this.tuneMode2.Name = "tuneMode2"; + this.tuneMode2.Size = new System.Drawing.Size(121, 21); + this.tuneMode2.TabIndex = 5; + // + // tuneMode1 + // + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 30); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label4.Location = new System.Drawing.Point(6, 123); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(38, 16); + this.label4.TabIndex = 3; + this.label4.Text = "RX 4:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label3.Location = new System.Drawing.Point(6, 93); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 16); + this.label3.TabIndex = 2; + this.label3.Text = "RX 3:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label2.Location = new System.Drawing.Point(6, 63); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 16); + this.label2.TabIndex = 1; + this.label2.Text = "RX 2:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 33); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(111, 173); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 28); + this.btnCancel.TabIndex = 3; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 173); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 2; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // tuneModeSettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(335, 210); + this.ControlBox = false; + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSave); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "tuneModeSettingsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "tuneModeSettings"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.ComboBox tuneMode2; + private System.Windows.Forms.ComboBox tuneMode3; + private System.Windows.Forms.ComboBox tuneMode4; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.CheckBox avoidBeacon2; + private System.Windows.Forms.CheckBox avoidBeacon3; + private System.Windows.Forms.CheckBox avoidBeacon4; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs new file mode 100644 index 0000000..89b495f --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class tuneModeSettingsForm : Form + { + private tuneModeSettings tuneModeSettings; + + public tuneModeSettingsForm(ref tuneModeSettings _tuneModeSettings) + { + tuneModeSettings = _tuneModeSettings; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneModeSettings.tuneMode[0]; + tuneMode2.SelectedIndex = tuneModeSettings.tuneMode[1]; + tuneMode3.SelectedIndex = tuneModeSettings.tuneMode[2]; + tuneMode4.SelectedIndex = tuneModeSettings.tuneMode[3]; + + avoidBeacon1.Checked = tuneModeSettings.avoidBeacon[0]; + avoidBeacon2.Checked = tuneModeSettings.avoidBeacon[1]; + avoidBeacon3.Checked = tuneModeSettings.avoidBeacon[2]; + avoidBeacon4.Checked = tuneModeSettings.avoidBeacon[3]; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneModeSettings.tuneMode[0] = tuneMode1.SelectedIndex; + tuneModeSettings.tuneMode[1] = tuneMode2.SelectedIndex; + tuneModeSettings.tuneMode[2] = tuneMode3.SelectedIndex; + tuneModeSettings.tuneMode[3] = tuneMode4.SelectedIndex; + + tuneModeSettings.avoidBeacon[0] = avoidBeacon1.Checked; + tuneModeSettings.avoidBeacon[1] = avoidBeacon2.Checked; + tuneModeSettings.avoidBeacon[2] = avoidBeacon3.Checked; + tuneModeSettings.avoidBeacon[3] = avoidBeacon4.Checked; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs new file mode 100644 index 0000000..89ef2bc --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs @@ -0,0 +1,123 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class oneTunerTuneModeForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 54); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 21); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode1 + // + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 20); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 61); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 7; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // oneTunerTuneModeForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(331, 99); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.groupBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "oneTunerTuneModeForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs new file mode 100644 index 0000000..8c5d859 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class oneTunerTuneModeForm : Form + { + private int tuneMode = 1; + private bool avoidBeacon = true; + + public oneTunerTuneModeForm(int _tuner, int _tuneMode, bool _avoidBeacon) + { + tuneMode = _tuneMode; + avoidBeacon = _avoidBeacon; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneMode; + avoidBeacon1.Checked = avoidBeacon; + label1.Text = "RX " + _tuner.ToString() + ":"; + } + + public int getTuneMode() + { + return tuneMode; + } + + public bool getAvoidBeacon() + { + return avoidBeacon; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneMode = tuneMode1.SelectedIndex; + avoidBeacon = avoidBeacon1.Checked; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From 55bb674a388d0cd1e803e1c029f659cb7e8d0c08 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:12:10 +0100 Subject: [PATCH 42/98] Update MainForm.cs function linkBatcSpectrumSettings_Click added. --- MainForm.cs | 77 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 4d9ae4b..805a589 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -968,16 +968,61 @@ private void checkMqttClient_CheckedChanged(object sender, EventArgs e) _settings.enable_mqtt_checkbox = checkMqttClient.Checked; } + private void linkMqttSettings_Click(object sender, EventArgs e) + { + // mqtt settings + MqttManagerSettings mqtt_settings = new MqttManagerSettings(); + SettingsManager mqtt_settingsManager = new SettingsManager("mqttclient_settings"); + mqtt_settings = mqtt_settingsManager.LoadSettings(mqtt_settings); + + MqttSettingsForm mqtt_settings_form = new MqttSettingsForm(ref mqtt_settings); + + if (mqtt_settings_form.ShowDialog() == DialogResult.OK) + { + mqtt_settingsManager.SaveSettings(mqtt_settings); + } + } + private void checkQuicktune_CheckedChanged(object sender, EventArgs e) { _settings.enable_quicktune_checkbox = checkQuicktune.Checked; } + private void linkQuickTuneSettings_Click(object sender, EventArgs e) + { + // quick tune settings + QuickTuneControlSettings quicktune_settings = new QuickTuneControlSettings(); + SettingsManager quicktune_settingsManager = new SettingsManager("quicktune_settings"); + quicktune_settings = quicktune_settingsManager.LoadSettings(quicktune_settings); + + QuickTuneControlSettingsForm quicktune_settings_form = new QuickTuneControlSettingsForm(ref quicktune_settings); + + if (quicktune_settings_form.ShowDialog() == DialogResult.OK) + { + quicktune_settingsManager.SaveSettings(quicktune_settings); + } + } + private void checkBatcSpectrum_CheckedChanged(object sender, EventArgs e) { _settings.enable_spectrum_checkbox = checkBatcSpectrum.Checked; } + private void linkBatcSpectrumSettings_Click(object sender, EventArgs e) + { + // BATC tune settings + tuneModeSettings batc_settings = new tuneModeSettings(); + SettingsManager batc_settingsManager = new SettingsManager("tunemode_settings"); + batc_settings = batc_settingsManager.LoadSettings(batc_settings); + + tuneModeSettingsForm batc_settings_form = new tuneModeSettingsForm(ref batc_settings); + + if (batc_settings_form.ShowDialog() == DialogResult.OK) + { + batc_settingsManager.SaveSettings(batc_settings); + } + } + private void checkBatcChat_CheckedChanged(object sender, EventArgs e) { _settings.enable_chatform_checkbox = checkBatcChat.Checked; @@ -1004,36 +1049,6 @@ private void linkDocumentation_Click(object sender, EventArgs e) System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-documentation/"); } - private void linkMqttSettings_Click(object sender, EventArgs e) - { - // mqtt settings - MqttManagerSettings mqtt_settings = new MqttManagerSettings(); - SettingsManager mqtt_settingsManager = new SettingsManager("mqttclient_settings"); - mqtt_settings = mqtt_settingsManager.LoadSettings(mqtt_settings); - - MqttSettingsForm mqtt_settings_form = new MqttSettingsForm(ref mqtt_settings); - - if (mqtt_settings_form.ShowDialog() == DialogResult.OK) - { - mqtt_settingsManager.SaveSettings(mqtt_settings); - } - } - - private void linkQuickTuneSettings_Click(object sender, EventArgs e) - { - // quick tune settings - QuickTuneControlSettings quicktune_settings = new QuickTuneControlSettings(); - SettingsManager quicktune_settingsManager = new SettingsManager("quicktune_settings"); - quicktune_settings = quicktune_settingsManager.LoadSettings(quicktune_settings); - - QuickTuneControlSettingsForm quicktune_settings_form = new QuickTuneControlSettingsForm(ref quicktune_settings); - - if (quicktune_settings_form.ShowDialog() == DialogResult.OK) - { - quicktune_settingsManager.SaveSettings(quicktune_settings); - } - } - private void linkSpectrumDocumentation_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-spectrum/"); @@ -1169,6 +1184,4 @@ private void LinkDatvReportMoreInfo_Click(object sender, EventArgs e) System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-datv-reporter/"); } } - - } From e76933a7b4286d89109d39c611790986714388cf Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:31:01 +0100 Subject: [PATCH 43/98] Update MainForm.resx make linkBatcSpectrumSettings visible. --- MainForm.resx | 3 --- 1 file changed, 3 deletions(-) diff --git a/MainForm.resx b/MainForm.resx index 19659b5..43bf50a 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -696,9 +696,6 @@ Settings ... - - False - linkBatcSpectrumSettings From 9a1d8e40f3e58ee7fcc32ffb9b99dde5a8dfe211 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:31:31 +0100 Subject: [PATCH 44/98] Update MainForm.Designer.cs linkBatcSpectrumSettings.Click added. --- MainForm.Designer.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index fe98cc0..49b4705 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -79,10 +79,6 @@ private void InitializeComponent() this.ExtraSpectrumTab = new System.Windows.Forms.TabPage(); this.spectrum = new System.Windows.Forms.PictureBox(); this.contextSpectrumMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.autoTuneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.manualToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoTimedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoHoldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.openTunerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolstripConnectToggle = new System.Windows.Forms.ToolStripMenuItem(); @@ -324,6 +320,7 @@ private void InitializeComponent() this.linkBatcSpectrumSettings.Cursor = System.Windows.Forms.Cursors.Hand; this.linkBatcSpectrumSettings.ForeColor = System.Drawing.Color.RoyalBlue; this.linkBatcSpectrumSettings.Name = "linkBatcSpectrumSettings"; + this.linkBatcSpectrumSettings.Click += new System.EventHandler(this.linkBatcSpectrumSettings_Click); // // linkMqttSettings // From 7cffb28354091f4a09c9c7a86f512367a716556c Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 7 Nov 2024 20:32:14 +0100 Subject: [PATCH 45/98] Update opentuner.csproj tuneModeSettings forms added. --- opentuner.csproj | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/opentuner.csproj b/opentuner.csproj index 1a546ee..2785760 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,12 @@ + + Form + + + oneTunerTuneModeForm.cs + Form @@ -241,6 +247,13 @@ True SRForm.resx + + + Form + + + TuneModeSettingsForm.cs + @@ -472,11 +485,17 @@ externalToolsManager.cs + + oneTunerTuneModeForm.cs + SRForm.cs ResXFileCodeGenerator SRForm.Designer.cs + + TuneModeSettingsForm.cs + WebChatSettngsForm.cs From 2968dbc3ca9bee7ff6881b02f5e6c55e7b993e54 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 08:52:28 +0100 Subject: [PATCH 46/98] bandplan.xml added to project bandplan.xml will be copied to the right directory during build process. --- bandplan.xml | 321 +++++++++++++++++++++++++++++++++++++++++++++++ opentuner.csproj | 3 + 2 files changed, 324 insertions(+) create mode 100644 bandplan.xml diff --git a/bandplan.xml b/bandplan.xml new file mode 100644 index 0000000..f0625f5 --- /dev/null +++ b/bandplan.xml @@ -0,0 +1,321 @@ + + + + 10491.5 + 2402 + 1500 + BEACON + A + + + 10493.25 + 2403.75 + 1000 + 1500/1000 + A + + + 10494.75 + 2405.25 + 1000 + 1500/1000 + A + + + 10496.25 + 2406.75 + 1000 + 1500/1000 + A + + + 10492.75 + 2403.25 + 333 + 500/333/250 + B + + + 10493.25 + 2403.75 + 333 + 500/333/250 + B + + + 10493.75 + 2404.25 + 333 + 500/333/250 + B + + + 10494.25 + 2404.75 + 333 + 500/333/250 + B + + + 10494.75 + 2405.25 + 333 + 500/333/250 + B + + + 10495.25 + 2405.75 + 333 + 500/333/250 + B + + + 10495.75 + 2406.25 + 333 + 500/333/250 + B + + + 10496.25 + 2406.75 + 333 + 500/333/250 + B + + + 10496.75 + 2407.25 + 333 + 500/333/250 + B + + + 10497.25 + 2407.75 + 333 + 333/250 + B + + + 10497.75 + 2408.25 + 333 + 333/250 + B + + + 10498.25 + 2408.75 + 333 + 333/250 + B + + + 10498.75 + 2409.25 + 333 + 333/250 + B + + + 10499.25 + 2409.75 + 333 + 333/250 + B + + + 10492.75 + 2403.25 + 125 + 125/66/33 + C + + + 10493 + 2403.5 + 125 + 125/66/33 + C + + + 10493.25 + 2403.75 + 125 + 125/66/33 + C + + + 10493.5 + 2404 + 125 + 125/66/33 + C + + + 10493.75 + 2404.25 + 125 + 125/66/33 + C + + + 10494 + 2404.5 + 125 + 125/66/33 + C + + + 10494.25 + 2404.75 + 125 + 125/66/33 + C + + + 10494.5 + 2405 + 125 + 125/66/33 + C + + + 10494.75 + 2405.25 + 125 + 125/66/33 + C + + + 10495 + 2405.5 + 125 + 125/66/33 + C + + + 10495.25 + 2405.75 + 125 + 125/66/33 + C + + + 10495.5 + 2406 + 125 + 125/66/33 + C + + + 10495.75 + 2406.25 + 125 + 125/66/33 + C + + + 10496 + 2406.5 + 125 + 125/66/33 + C + + + 10496.25 + 2406.75 + 125 + 125/66/33 + C + + + 10496.5 + 2407 + 125 + 125/66/33 + C + + + 10496.75 + 2407.25 + 125 + 125/66/33 + C + + + 10497 + 2407.5 + 125 + 125/66/33 + C + + + 10497.25 + 2407.75 + 125 + 125/66/33 + C + + + 10497.5 + 2408 + 125 + 125/66/33 + C + + + 10497.75 + 2408.25 + 125 + 125/66/33 + C + + + 10498 + 2408.5 + 125 + 125/66/33 + C + + + 10498.25 + 2408.75 + 125 + 125/66/33 + C + + + 10498.5 + 2409 + 125 + 125/66/33 + C + + + 10498.75 + 2409.25 + 125 + 125/66/33 + C + + + 10499 + 2409.5 + 125 + 125/66/33 + C + + + 10499.25 + 2409.75 + 125 + 125/66/33 + C + + + + + \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 09cd735..7c2e260 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -612,6 +612,9 @@ + + PreserveNewest + From a112453efbdacb9c27ed1a39ada14de3046f4c1e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 08:59:37 +0100 Subject: [PATCH 47/98] autoTuneToolStripMenu removed --- MainForm.Designer.cs | 41 ------------------------- MainForm.resx | 72 ++++++++------------------------------------ 2 files changed, 12 insertions(+), 101 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index ad6b0b5..a9f36e3 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -79,10 +79,6 @@ private void InitializeComponent() this.ExtraSpectrumTab = new System.Windows.Forms.TabPage(); this.spectrum = new System.Windows.Forms.PictureBox(); this.contextSpectrumMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.autoTuneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.manualToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoTimedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoHoldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.openTunerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolstripConnectToggle = new System.Windows.Forms.ToolStripMenuItem(); @@ -123,7 +119,6 @@ private void InitializeComponent() this.ExtraToolsTab.SuspendLayout(); this.ExtraSpectrumTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.spectrum)).BeginInit(); - this.contextSpectrumMenu.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -547,40 +542,9 @@ private void InitializeComponent() // // contextSpectrumMenu // - this.contextSpectrumMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.autoTuneToolStripMenuItem}); this.contextSpectrumMenu.Name = "contextSpectrumMenu"; resources.ApplyResources(this.contextSpectrumMenu, "contextSpectrumMenu"); // - // autoTuneToolStripMenuItem - // - this.autoTuneToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.manualToolStripMenuItem, - this.autoTimedToolStripMenuItem, - this.autoHoldToolStripMenuItem}); - this.autoTuneToolStripMenuItem.Name = "autoTuneToolStripMenuItem"; - resources.ApplyResources(this.autoTuneToolStripMenuItem, "autoTuneToolStripMenuItem"); - // - // manualToolStripMenuItem - // - this.manualToolStripMenuItem.Checked = true; - this.manualToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.manualToolStripMenuItem.Name = "manualToolStripMenuItem"; - resources.ApplyResources(this.manualToolStripMenuItem, "manualToolStripMenuItem"); - this.manualToolStripMenuItem.Click += new System.EventHandler(this.manualToolStripMenuItem_Click); - // - // autoTimedToolStripMenuItem - // - this.autoTimedToolStripMenuItem.Name = "autoTimedToolStripMenuItem"; - resources.ApplyResources(this.autoTimedToolStripMenuItem, "autoTimedToolStripMenuItem"); - this.autoTimedToolStripMenuItem.Click += new System.EventHandler(this.autoTimedToolStripMenuItem_Click); - // - // autoHoldToolStripMenuItem - // - this.autoHoldToolStripMenuItem.Name = "autoHoldToolStripMenuItem"; - resources.ApplyResources(this.autoHoldToolStripMenuItem, "autoHoldToolStripMenuItem"); - this.autoHoldToolStripMenuItem.Click += new System.EventHandler(this.autoHoldToolStripMenuItem_Click); - // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -720,7 +684,6 @@ private void InitializeComponent() this.ExtraToolsTab.ResumeLayout(false); this.ExtraSpectrumTab.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.spectrum)).EndInit(); - this.contextSpectrumMenu.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); @@ -741,10 +704,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem qO100WidebandChatToolStripMenuItem; private System.Windows.Forms.ContextMenuStrip contextSpectrumMenu; - private System.Windows.Forms.ToolStripMenuItem autoTuneToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem manualToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem autoTimedToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem autoHoldToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem plutoToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem commandsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem systemFunctionsToolStripMenuItem; diff --git a/MainForm.resx b/MainForm.resx index 5eb08f2..414c9e2 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -1536,42 +1536,6 @@ 0 - - 437, 14 - - - 144, 22 - - - &Manual - - - 144, 22 - - - Auto (Timed) - - - 144, 22 - - - Auto (Hold) - - - 157, 22 - - - AutoTune (RX1) - - - 158, 26 - - - contextSpectrumMenu - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Fill @@ -1716,6 +1680,18 @@ 1 + + 437, 14 + + + 61, 4 + + + contextSpectrumMenu + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 157, 17 @@ -2370,30 +2346,6 @@ Open Tuner (ZR6TG) - 0.B Version - 2024/07/09 - - autoTuneToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - manualToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - autoTimedToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - autoHoldToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - openTunerToolStripMenuItem From f6c6b94df633a3e803d2567b4b85ac0ac16dde99 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 09:07:47 +0100 Subject: [PATCH 48/98] autoTuneToolStripMenu removed --- MainForm.cs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index bbe9def..266df7f 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -649,30 +649,6 @@ private void qO100WidebandChatToolStripMenuItem_Click(object sender, EventArgs e batc_chat.Show(); } - private void manualToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(0); - manualToolStripMenuItem.Checked = true; - autoHoldToolStripMenuItem.Checked = false; - autoTimedToolStripMenuItem.Checked = false; - } - - private void autoTimedToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(2); - manualToolStripMenuItem.Checked = false; - autoHoldToolStripMenuItem.Checked = false; - autoTimedToolStripMenuItem.Checked = true; - } - - private void autoHoldToolStripMenuItem_Click(object sender, EventArgs e) - { - batc_spectrum.changeTuneMode(3); - manualToolStripMenuItem.Checked = false; - autoHoldToolStripMenuItem.Checked = true; - autoTimedToolStripMenuItem.Checked = false; - } - private void configureCallsignToolStripMenuItem_Click(object sender, EventArgs e) { pluto_client.ConfigureCallsignAndReboot("ZR6TG"); From 3742bbc63830528dd75ae5f5daf65be7bac59be4 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 09:26:39 +0100 Subject: [PATCH 49/98] path to bandplan.xml corrected bandplan was already under "extra" directory. So use this file and copy it to executable path. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 2 +- bandplan.xml | 321 --------------------- opentuner.csproj | 2 +- 3 files changed, 2 insertions(+), 323 deletions(-) delete mode 100644 bandplan.xml diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 6a87c53..ac27526 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -99,7 +99,7 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) try { - bandplan = XElement.Load(Path.GetDirectoryName(Application.ExecutablePath) + @"\bandplan.xml"); + bandplan = XElement.Load(Path.GetDirectoryName(Application.ExecutablePath) + @"\extra\bandplan.xml"); drawspectrum_bandplan(); indexedbandplan = bandplan.Elements().ToList(); foreach (var channel in bandplan.Elements("channel")) diff --git a/bandplan.xml b/bandplan.xml deleted file mode 100644 index f0625f5..0000000 --- a/bandplan.xml +++ /dev/null @@ -1,321 +0,0 @@ - - - - 10491.5 - 2402 - 1500 - BEACON - A - - - 10493.25 - 2403.75 - 1000 - 1500/1000 - A - - - 10494.75 - 2405.25 - 1000 - 1500/1000 - A - - - 10496.25 - 2406.75 - 1000 - 1500/1000 - A - - - 10492.75 - 2403.25 - 333 - 500/333/250 - B - - - 10493.25 - 2403.75 - 333 - 500/333/250 - B - - - 10493.75 - 2404.25 - 333 - 500/333/250 - B - - - 10494.25 - 2404.75 - 333 - 500/333/250 - B - - - 10494.75 - 2405.25 - 333 - 500/333/250 - B - - - 10495.25 - 2405.75 - 333 - 500/333/250 - B - - - 10495.75 - 2406.25 - 333 - 500/333/250 - B - - - 10496.25 - 2406.75 - 333 - 500/333/250 - B - - - 10496.75 - 2407.25 - 333 - 500/333/250 - B - - - 10497.25 - 2407.75 - 333 - 333/250 - B - - - 10497.75 - 2408.25 - 333 - 333/250 - B - - - 10498.25 - 2408.75 - 333 - 333/250 - B - - - 10498.75 - 2409.25 - 333 - 333/250 - B - - - 10499.25 - 2409.75 - 333 - 333/250 - B - - - 10492.75 - 2403.25 - 125 - 125/66/33 - C - - - 10493 - 2403.5 - 125 - 125/66/33 - C - - - 10493.25 - 2403.75 - 125 - 125/66/33 - C - - - 10493.5 - 2404 - 125 - 125/66/33 - C - - - 10493.75 - 2404.25 - 125 - 125/66/33 - C - - - 10494 - 2404.5 - 125 - 125/66/33 - C - - - 10494.25 - 2404.75 - 125 - 125/66/33 - C - - - 10494.5 - 2405 - 125 - 125/66/33 - C - - - 10494.75 - 2405.25 - 125 - 125/66/33 - C - - - 10495 - 2405.5 - 125 - 125/66/33 - C - - - 10495.25 - 2405.75 - 125 - 125/66/33 - C - - - 10495.5 - 2406 - 125 - 125/66/33 - C - - - 10495.75 - 2406.25 - 125 - 125/66/33 - C - - - 10496 - 2406.5 - 125 - 125/66/33 - C - - - 10496.25 - 2406.75 - 125 - 125/66/33 - C - - - 10496.5 - 2407 - 125 - 125/66/33 - C - - - 10496.75 - 2407.25 - 125 - 125/66/33 - C - - - 10497 - 2407.5 - 125 - 125/66/33 - C - - - 10497.25 - 2407.75 - 125 - 125/66/33 - C - - - 10497.5 - 2408 - 125 - 125/66/33 - C - - - 10497.75 - 2408.25 - 125 - 125/66/33 - C - - - 10498 - 2408.5 - 125 - 125/66/33 - C - - - 10498.25 - 2408.75 - 125 - 125/66/33 - C - - - 10498.5 - 2409 - 125 - 125/66/33 - C - - - 10498.75 - 2409.25 - 125 - 125/66/33 - C - - - 10499 - 2409.5 - 125 - 125/66/33 - C - - - 10499.25 - 2409.75 - 125 - 125/66/33 - C - - - - - \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 7c2e260..4effc91 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -612,7 +612,7 @@ - + PreserveNewest From 78a5cf7380fb16e7c9ec53e2ddb5afc60f9d0e52 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 09:29:43 +0100 Subject: [PATCH 50/98] Update WinterhillProperties.cs cosmetic --- MediaSources/Winterhill/WinterhillProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 7b60fd9..360d4d6 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -535,7 +535,7 @@ private void UpdateInfo(monitorMessage mm) { if (rx.scanstate == 2 || rx.scanstate == 3) { - Log.Information("Playing" + c.ToString()); + Log.Information("Playing " + c.ToString()); VideoChangeCB?.Invoke(c + 1, true); playing[c] = true; _tuner_properties[c].UpdateColor("demodstate", Color.PaleGreen); From 82fbc69bd53f9b5f8b8f4952ea4561f1203e3108 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:01:13 +0100 Subject: [PATCH 51/98] Update socket.cs add padding constant to remove useless bytes from data stream. --- ExtraFeatures/BATCSpectrum/socket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/socket.cs b/ExtraFeatures/BATCSpectrum/socket.cs index c860785..76ceaf6 100644 --- a/ExtraFeatures/BATCSpectrum/socket.cs +++ b/ExtraFeatures/BATCSpectrum/socket.cs @@ -12,6 +12,8 @@ namespace opentuner { class socket { + private const int padding = 8; // useless bytes to remove at the end of the socket data package + public Action callback; private WebSocket ws; //websocket client @@ -84,13 +86,14 @@ private void NewData(byte[] data) { lastdata = DateTime.Now; - fft_data = new UInt16[data.Length / 2]; + int data_length = data.Length - padding; // data length to process + fft_data = new UInt16[data_length / 2]; //unpack bytes to unsigned short int values int n = 0; byte[] buf = new byte[2]; - for (int i = 0; i < data.Length; i += 2) + for (int i = 0; i < data_length; i += 2) { buf[0] = data[i]; buf[1] = data[i + 1]; From 5970c1afb45b38edf1e7f23271d29c14e8f2ee96 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:02:29 +0100 Subject: [PATCH 52/98] Update signal.cs use more precise start frequency of spectrum. --- ExtraFeatures/BATCSpectrum/signal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index ded7510..36ee59b 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -80,7 +80,7 @@ public void updateCallsign(string callsign) Object list_lock; public List signals = new List(); //list of signals found: public List signalsData = new List(); - double start_freq = 10490.5f; + const double start_freq = 10490.466f; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; @@ -333,7 +333,7 @@ private Sig find_next(int rx) } else { - startfreq = startfreq = 10490; ; + startfreq = startfreq = 10490; } // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); From 5901e3fe3534ea81fc5d6a17be04bc64c7fc585a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:04:01 +0100 Subject: [PATCH 53/98] Update BATCSpectrum.cs Use more precise start frequency of spectrum. Use real fft data size for calculation. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index ac27526..406afb6 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -44,7 +44,7 @@ public class BATCSpectrum int[,] rx_blocks = new int[4, 3]; - double start_freq = 10490.5f; + const double start_freq = 10490.466f; XElement bandplan; Rectangle[] channels; @@ -73,6 +73,8 @@ public class BATCSpectrum private int mousePos_x = 0; private int mousePos_y = 0; + private int fft_data_length = 918; + public void updateSignalCallsign(string callsign, double freq, float sr) { sigs.updateCurrentSignal(callsign, freq, sr); @@ -234,7 +236,7 @@ private void SpectrumTuneTimer_Tick(object sender, EventArgs e) { int mode = _autoTuneMode; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; ushort autotuneWait = 30; @@ -291,7 +293,7 @@ private void drawspectrum_bandplan() int count = 0; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; List blocks = new List(); @@ -323,8 +325,8 @@ private void drawspectrum_bandplan() freq = Convert.ToSingle(xval, CultureInfo.InvariantCulture); sr = Convert.ToInt32(channel.Element("sr").Value, CultureInfo.InvariantCulture); - int pos = Convert.ToInt16((922.0 / span) * (freq - start_freq)); - w = Convert.ToInt32(sr / (span * 1000.0) * 922 * rolloff); + int pos = Convert.ToInt16((fft_data_length / span) * (freq - start_freq)); + w = Convert.ToInt32(sr / (span * 1000.0) * fft_data_length * rolloff); w = Convert.ToInt32(w * spectrum_wScale); int split = bandplan_height / blocks.Count(); @@ -351,7 +353,7 @@ private void drawspectrum_bandplan() private void drawspectrum_signals(List signals) { float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; lock (list_lock) //hopefully lock signals list while drawing { @@ -390,20 +392,20 @@ private void UpdateDrawing() private void drawspectrum(UInt16[] fft_data) { + fft_data_length = fft_data.Length; tmp.Clear(Color.Black); //clear canvas - int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; int i = 1; int y = 0; - PointF[] points = new PointF[fft_data.Length - 2]; + PointF[] points = new PointF[fft_data.Length]; - for (i = 1; i < fft_data.Length - 3; i++) //ignore padding? + for (i = 1; i < fft_data.Length; i++) //ignore padding? { PointF point = new PointF(i * spectrum_wScale, height - fft_data[i] / height); points[i] = point; @@ -478,7 +480,7 @@ private void spectrum_Click(object sender, EventArgs e) { float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; MouseEventArgs me = (MouseEventArgs)e; var pos = me.Location; @@ -492,7 +494,7 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - int freq = Convert.ToInt32((10490.5 + ((X / spectrum_wScale) / 922.0) * 9.0) * 1000.0); + int freq = Convert.ToInt32((10490.466 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); //UpdateTextBox(txtFreq, freq.ToString()); string tx_freq = get_bandplan_TX_freq(X, Y); @@ -529,7 +531,7 @@ private void selectSignal(int X, int Y) { float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; int spectrum_h = _spectrum.Height - bandplan_height; int rx = determine_rx(Y); @@ -572,7 +574,7 @@ private bool check_mouse_over_signal(signal.Sig s) { int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; if (mousePos_y < spectrum_h) { From 78514598523cc6261022889202c1102b7e95bae5 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:19:49 +0100 Subject: [PATCH 54/98] back to main trunk versions --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 426 ++++++++---------- ExtraFeatures/BATCSpectrum/SRForm.Designer.cs | 63 --- ExtraFeatures/BATCSpectrum/SRForm.cs | 297 ------------ ExtraFeatures/BATCSpectrum/SRForm.resx | 120 ----- .../BATCSpectrum/TuneModeSettings.cs | 14 - .../TuneModeSettingsForm.Designer.cs | 268 ----------- .../BATCSpectrum/TuneModeSettingsForm.cs | 55 --- .../BATCSpectrum/TuneModeSettingsForm.resx | 120 ----- .../oneTunerTuneModeForm.Designer.cs | 123 ----- .../BATCSpectrum/oneTunerTuneModeForm.cs | 54 --- .../BATCSpectrum/oneTunerTuneModeForm.resx | 120 ----- ExtraFeatures/BATCSpectrum/signal.cs | 49 +- ExtraFeatures/BATCSpectrum/socket.cs | 7 +- GlobalDefines.cs | 2 +- MainForm.Designer.cs | 9 - MainForm.cs | 90 ++-- MainForm.resx | 51 +-- bandplan.xml | 321 ------------- opentuner.csproj | 34 +- 19 files changed, 271 insertions(+), 1952 deletions(-) delete mode 100644 ExtraFeatures/BATCSpectrum/SRForm.Designer.cs delete mode 100644 ExtraFeatures/BATCSpectrum/SRForm.cs delete mode 100644 ExtraFeatures/BATCSpectrum/SRForm.resx delete mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettings.cs delete mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs delete mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs delete mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx delete mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs delete mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs delete mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx delete mode 100644 bandplan.xml diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 3e82700..406afb6 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -25,18 +25,14 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); public static readonly int height = 246; //makes things easier - private static readonly int bandplan_height = 30; - private static double start_freq = 10490.5f; - private static double fft_scaling_factor = 922.0f / 9.0f; - + static readonly int bandplan_height = 30; Bitmap bmp; static Bitmap bmp2; Pen greyPen = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); - Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); - SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(200, Color.Gray)); + SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -46,7 +42,9 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; - int[,] rx_blocks = new int[4, 4]; // first index: Tuner; second index: 0 := center, 1 := width, 2 := demode locked state, 3 := switching flag + int[,] rx_blocks = new int[4, 3]; + + const double start_freq = 10490.466f; XElement bandplan; Rectangle[] channels; @@ -64,7 +62,7 @@ public class BATCSpectrum private PictureBox _spectrum; private int _tuners; - //Timer SpectrumTuneTimer; + Timer SpectrumTuneTimer; Timer websocketTimer; private int _autoTuneMode = 0; @@ -75,102 +73,13 @@ public class BATCSpectrum private int mousePos_x = 0; private int mousePos_y = 0; - //public bool quicktune_enabled = false; - public bool pluto_control_enabled = false; + private int fft_data_length = 918; public void updateSignalCallsign(string callsign, double freq, float sr) { sigs.updateCurrentSignal(callsign, freq, sr); } - public void updateTuner(int tuner, double freq, float sr, bool demod_locked) - { - if (demod_locked) - { - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_scaling_factor); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_scaling_factor); - rx_blocks[tuner, 2] = 1; // locked - rx_blocks[tuner, 3] = 0; // switching finished - } - } - - public void switchTuner(int tuner, double freq, float sr) - { - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_scaling_factor); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_scaling_factor); - rx_blocks[tuner, 2] = 0; // not locked - rx_blocks[tuner, 3] = 1; // switching started - } - - private void debug(string msg) - { - Log.Information(msg); - } - - // quicktune functions - private void drawspectrum_bandplan() - { - int span = 9; - int count = 0; - - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; - - List blocks = new List(); - - //count blocks ('layers' of bandplan) - foreach (var channel in bandplan.Elements("channel")) - { - count++; - if (!blocks.Contains(channel.Element("block").Value)) - { - blocks.Add(channel.Element("block").Value); - } - } - - channels = new Rectangle[count]; - - int n = 0; - - //create rectangle blocks to display bandplan - foreach (var channel in bandplan.Elements("channel")) - { - int w = 0; - int offset = 0; - float rolloff = 1.35f; - string xval = channel.Element("x-freq").Value; - - float freq; - int sr; - - freq = Convert.ToSingle(xval, CultureInfo.InvariantCulture); - sr = Convert.ToInt32(channel.Element("sr").Value, CultureInfo.InvariantCulture); - - int pos = Convert.ToInt16((922.0 / span) * (freq - start_freq)); - w = Convert.ToInt32(sr / (span * 1000.0) * 922 * rolloff); - w = Convert.ToInt32(w * spectrum_wScale); - - int split = bandplan_height / blocks.Count(); - int b = blocks.Count(); - foreach (string blk in blocks) - { - if (channel.Element("block").Value == blk) - { - offset = b * split; - } - b--; - } - channels[n] = new Rectangle(Convert.ToInt32(pos * spectrum_wScale) - (w / 2), offset - (split / 2) - 3, w, split - 2); - n++; - } - - //draw blocks - for (int i = 0; i < count; i++) - { - tmp2.FillRectangles(bandplanBrush, new RectangleF[] { channels[i] }); //x,y,w,h - } - } - public BATCSpectrum(PictureBox Spectrum, int Tuners) { _spectrum = Spectrum; @@ -192,7 +101,7 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) try { - bandplan = XElement.Load(Path.GetDirectoryName(Application.ExecutablePath) + @"\bandplan.xml"); + bandplan = XElement.Load(Path.GetDirectoryName(Application.ExecutablePath) + @"\extra\bandplan.xml"); drawspectrum_bandplan(); indexedbandplan = bandplan.Elements().ToList(); foreach (var channel in bandplan.Elements("channel")) @@ -221,10 +130,12 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) sigs.set_num_rx_scan(num_rxs_to_scan); sigs.set_num_rx(1); - //SpectrumTuneTimer = new Timer(); - //SpectrumTuneTimer.Enabled = false; - //SpectrumTuneTimer.Interval = 1500; - //SpectrumTuneTimer.Tick += new System.EventHandler(this.SpectrumTuneTimer_Tick); + sigs.set_avoidbeacon(true); + + SpectrumTuneTimer = new Timer(); + SpectrumTuneTimer.Enabled = false; + SpectrumTuneTimer.Interval = 1500; + SpectrumTuneTimer.Tick += new System.EventHandler(this.SpectrumTuneTimer_Tick); websocketTimer = new Timer(); websocketTimer.Interval = 2000; @@ -258,13 +169,13 @@ private void Web_socket_ConnectionStatusChanged(object sender, bool connection_s connect_retry_count = 0; } - //else - //{ + else + { // if we lost connection then disable autotune - //_autoTuneMode = 0; - //if (SpectrumTuneTimer != null) - // SpectrumTuneTimer.Enabled = false; - //} + _autoTuneMode = 0; + SpectrumTuneTimer.Enabled = false; + } + } public void Close() @@ -272,8 +183,8 @@ public void Close() websocketTimer?.Stop(); websocketTimer?.Dispose(); - //SpectrumTuneTimer?.Stop(); - //SpectrumTuneTimer?.Dispose(); + SpectrumTuneTimer?.Stop(); + SpectrumTuneTimer?.Dispose(); // stop socket web_socket?.stop(); @@ -306,40 +217,45 @@ private void websocketTimer_Tick(object sender, EventArgs e) } } - //public void changeTuneMode(int mode) - //{ - // _autoTuneMode = mode; - // - // if (mode == 0) - // { - // SpectrumTuneTimer?.Stop(); - // } - // else - // { - // SpectrumTuneTimer?.Start(); - // } - // - //} - - //private void SpectrumTuneTimer_Tick(object sender, EventArgs e) - //{ - // int mode = _autoTuneMode; - // float spectrum_w = _spectrum.Width; - // float spectrum_wScale = spectrum_w / 922; - // - // ushort autotuneWait = 30; - // - // Tuple ret = sigs.tune(mode, Convert.ToInt16(autotuneWait), 0); - // if (ret.Item1.frequency > 0) //above 0 is a change in signal - // { - // System.Threading.Thread.Sleep(100); - // selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), 0); - // sigs.set_tuned(ret.Item1, 0); - // rx_blocks[0, 0] = Convert.ToInt16(ret.Item1.fft_centre); - // rx_blocks[0, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); - // } - // - //} + public void changeTuneMode(int mode) + { + _autoTuneMode = mode; + + if (mode == 0) + { + SpectrumTuneTimer?.Stop(); + } + else + { + SpectrumTuneTimer?.Start(); + } + + } + + private void SpectrumTuneTimer_Tick(object sender, EventArgs e) + { + int mode = _autoTuneMode; + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / fft_data_length; + + ushort autotuneWait = 30; + + Tuple ret = sigs.tune(mode, Convert.ToInt16(autotuneWait), 0); + if (ret.Item1.frequency > 0) //above 0 is a change in signal + { + System.Threading.Thread.Sleep(100); + selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), 0); + sigs.set_tuned(ret.Item1, 0); + rx_blocks[0, 0] = Convert.ToInt16(ret.Item1.fft_centre); + rx_blocks[0, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + } + + } + + private void debug(string msg) + { + Log.Information(msg); + } private void spectrum_MouseLeave(object sender, EventArgs e) { @@ -365,8 +281,100 @@ private void spectrum_SizeChanged(object sender, EventArgs e) } catch (Exception Ex) { - MessageBox.Show(Ex.Message); + + } + } + + + // quicktune functions + private void drawspectrum_bandplan() + { + int span = 9; + int count = 0; + + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / fft_data_length; + + List blocks = new List(); + + //count blocks ('layers' of bandplan) + foreach (var channel in bandplan.Elements("channel")) + { + count++; + if (!blocks.Contains(channel.Element("block").Value)) + { + blocks.Add(channel.Element("block").Value); + } + } + + channels = new Rectangle[count]; + + int n = 0; + + //create rectangle blocks to display bandplan + foreach (var channel in bandplan.Elements("channel")) + { + int w = 0; + int offset = 0; + float rolloff = 1.35f; + string xval = channel.Element("x-freq").Value; + + float freq; + int sr; + + freq = Convert.ToSingle(xval, CultureInfo.InvariantCulture); + sr = Convert.ToInt32(channel.Element("sr").Value, CultureInfo.InvariantCulture); + + int pos = Convert.ToInt16((fft_data_length / span) * (freq - start_freq)); + w = Convert.ToInt32(sr / (span * 1000.0) * fft_data_length * rolloff); + w = Convert.ToInt32(w * spectrum_wScale); + + int split = bandplan_height / blocks.Count(); + int b = blocks.Count(); + foreach (string blk in blocks) + { + if (channel.Element("block").Value == blk) + { + offset = b * split; + } + b--; + } + channels[n] = new Rectangle(Convert.ToInt32(pos * spectrum_wScale) - (w / 2), offset - (split / 2) - 3, w, split - 2); + n++; + } + + //draw blocks + for (int i = 0; i < count; i++) + { + tmp2.FillRectangles(bandplanBrush, new RectangleF[] { channels[i] }); //x,y,w,h + } + } + + private void drawspectrum_signals(List signals) + { + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / fft_data_length; + + lock (list_lock) //hopefully lock signals list while drawing + { + //draw the text for each signal found + foreach (signal.Sig s in signals) + { + if (check_mouse_over_signal(s)) + { + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + } + else + { + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + } + } } + + UpdateDrawing(); } private void UpdateDrawing() @@ -377,28 +385,27 @@ private void UpdateDrawing() } catch (Exception Ex) { - MessageBox.Show(Ex.Message); + } } - // Entrypoint with new fft_data from websocket private void drawspectrum(UInt16[] fft_data) { + fft_data_length = fft_data.Length; tmp.Clear(Color.Black); //clear canvas - int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; int i = 1; int y = 0; - PointF[] points = new PointF[fft_data.Length - 2]; + PointF[] points = new PointF[fft_data.Length]; - for (i = 1; i < fft_data.Length - 3; i++) //ignore padding? + for (i = 1; i < fft_data.Length; i++) //ignore padding? { PointF point = new PointF(i * spectrum_wScale, height - fft_data[i] / height); points[i] = point; @@ -407,11 +414,10 @@ private void drawspectrum(UInt16[] fft_data) points[0] = new PointF(0, height); points[points.Length - 1] = new PointF(spectrum_w, height); - //if (spectrumTunerHighlight > -1 && quicktune_enabled) if (spectrumTunerHighlight > -1) { y = spectrumTunerHighlight * (spectrum_h / _tuners); - tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); + tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h/_tuners))); } //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); @@ -430,6 +436,7 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan y = 0; + for (int tuner = 0; tuner < _tuners; tuner++) { y = tuner * (spectrum_h / _tuners); @@ -437,7 +444,7 @@ private void drawspectrum(UInt16[] fft_data) //draw block showing signal selected if (rx_blocks[tuner, 0] > 0) { - tmp.FillRectangle(shadowBrush, new RectangleF((rx_blocks[tuner, 0] * spectrum_wScale) - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale)/2) , y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } } @@ -454,46 +461,26 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 10), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 10), height - Convert.ToInt16(sig.max_strength)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } } - + for (i = 0; i < _tuners; i++) { y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } - lock (list_lock) //hopefully lock signals list while drawing - { - //draw the text for each signal found - foreach (var s in sigs.signalsData) - { - if (check_mouse_over_signal(s)) - { - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); - } - else - { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); - } - } - } - - UpdateDrawing(); + drawspectrum_signals(sigs.signalsData); } private void spectrum_Click(object sender, EventArgs e) { - int spectrum_h = _spectrum.Height - bandplan_height; + float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; MouseEventArgs me = (MouseEventArgs)e; var pos = me.Location; @@ -501,70 +488,31 @@ private void spectrum_Click(object sender, EventArgs e) int X = pos.X; int Y = pos.Y; - if (Y > spectrum_h) + if (me.Button == MouseButtons.Right) { - if (pluto_control_enabled) + int spectrum_h = _spectrum.Height - bandplan_height; + + if (Y > spectrum_h) { - switch (me.Button) + int freq = Convert.ToInt32((10490.466 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); + //UpdateTextBox(txtFreq, freq.ToString()); + + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) { - case MouseButtons.Left: - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) - { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; - } - break; - default: - break; + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; } } } else { - switch (me.Button) - { - case MouseButtons.Left: - if (Control.ModifierKeys == Keys.Shift) - { - - } - else - { - selectSignal(X, Y); - } - break; - case MouseButtons.Right: - uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); - - using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form - { - Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); - Point new_srForm_location = spectrum_screen_location; - int spectrum_width = _spectrum.Size.Width; - int srForm_width = srForm.Size.Width; - - if (X > (srForm_width / 2)) - new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; - if (X > (spectrum_width - srForm.Size.Width / 2)) - new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); - - srForm.StartPosition = FormStartPosition.Manual; - srForm.Location = new_srForm_location; - DialogResult result = srForm.ShowDialog(); - if (result == DialogResult.OK) - { - OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); - } - } - break; - default: - break; - } + selectSignal(X, Y); } + } @@ -583,7 +531,7 @@ private void selectSignal(int X, int Y) { float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; int spectrum_h = _spectrum.Height - bandplan_height; int rx = determine_rx(Y); @@ -602,8 +550,6 @@ private void selectSignal(int X, int Y) sigs.set_tuned(s, rx); rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); - rx_blocks[rx, 2] = 0; - rx_blocks[rx, 3] = 1; UInt32 freq = Convert.ToUInt32((s.frequency) * 1000); UInt32 sr = Convert.ToUInt32((s.sr * 1000.0)); @@ -628,7 +574,7 @@ private bool check_mouse_over_signal(signal.Sig s) { int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / 922; + float spectrum_wScale = spectrum_w / fft_data_length; if (mousePos_y < spectrum_h) { diff --git a/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs deleted file mode 100644 index 81e4ef3..0000000 --- a/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace opentuner.ExtraFeatures.BATCSpectrum { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SRForm { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SRForm() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("opentuner.ExtraFeatures.BATCSpectrum.SRForm", typeof(SRForm).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs deleted file mode 100644 index b2d76f2..0000000 --- a/ExtraFeatures/BATCSpectrum/SRForm.cs +++ /dev/null @@ -1,297 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace opentuner -{ - internal class SRForm : Form - { - private Button button1; - private Button button2; - private Button button4; - private Button button5; - private Button button6; - private Button button7; - private Button button8; - private Button button9; - private Button button10; - private Label label1; - private Label label2; - private Label label3; - private Button button3; - uint qrg = 0; - uint SR = 0; - - public SRForm(uint _qrg) - { - qrg = _qrg; - InitializeComponent(); - label3.Text = (qrg / 1000.0f).ToString() + " MHz"; - - } - - private void InitializeComponent() - { - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); - this.button4 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); - this.button6 = new System.Windows.Forms.Button(); - this.button7 = new System.Windows.Forms.Button(); - this.button8 = new System.Windows.Forms.Button(); - this.button9 = new System.Windows.Forms.Button(); - this.button10 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(143, 14); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(32, 23); - this.button1.TabIndex = 0; - this.button1.Text = "X"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button2.Location = new System.Drawing.Point(13, 43); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(50, 23); - this.button2.TabIndex = 1; - this.button2.Text = "25"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // button3 - // - this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button3.Location = new System.Drawing.Point(69, 42); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(50, 23); - this.button3.TabIndex = 2; - this.button3.Text = "33"; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.button3_Click); - // - // button4 - // - this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button4.Location = new System.Drawing.Point(125, 42); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(50, 23); - this.button4.TabIndex = 3; - this.button4.Text = "66"; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.button4_Click); - // - // button5 - // - this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button5.Location = new System.Drawing.Point(13, 72); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(50, 23); - this.button5.TabIndex = 4; - this.button5.Text = "125"; - this.button5.UseVisualStyleBackColor = true; - this.button5.Click += new System.EventHandler(this.button5_Click); - // - // button6 - // - this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button6.Location = new System.Drawing.Point(69, 71); - this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(50, 23); - this.button6.TabIndex = 5; - this.button6.Text = "250"; - this.button6.UseVisualStyleBackColor = true; - this.button6.Click += new System.EventHandler(this.button6_Click); - // - // button7 - // - this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button7.Location = new System.Drawing.Point(125, 71); - this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(50, 23); - this.button7.TabIndex = 6; - this.button7.Text = "333"; - this.button7.UseVisualStyleBackColor = true; - this.button7.Click += new System.EventHandler(this.button7_Click); - // - // button8 - // - this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button8.Location = new System.Drawing.Point(13, 101); - this.button8.Name = "button8"; - this.button8.Size = new System.Drawing.Size(50, 23); - this.button8.TabIndex = 7; - this.button8.Text = "500"; - this.button8.UseVisualStyleBackColor = true; - this.button8.Click += new System.EventHandler(this.button8_Click); - // - // button9 - // - this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button9.Location = new System.Drawing.Point(69, 100); - this.button9.Name = "button9"; - this.button9.Size = new System.Drawing.Size(50, 23); - this.button9.TabIndex = 8; - this.button9.Text = "1000"; - this.button9.UseVisualStyleBackColor = true; - this.button9.Click += new System.EventHandler(this.button9_Click); - // - // button10 - // - this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button10.Location = new System.Drawing.Point(125, 100); - this.button10.Name = "button10"; - this.button10.Size = new System.Drawing.Size(50, 23); - this.button10.TabIndex = 9; - this.button10.Text = "1500"; - this.button10.UseVisualStyleBackColor = true; - this.button10.Click += new System.EventHandler(this.button10_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(29, 14); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(90, 20); - this.label1.TabIndex = 10; - this.label1.Text = "Select SR"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(13, 137); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(50, 20); - this.label2.TabIndex = 11; - this.label2.Text = "QRG:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(65, 137); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(122, 20); - this.label3.TabIndex = 12; - this.label3.Text = "10491.500 MHz"; - // - // SRForm - // - this.ClientSize = new System.Drawing.Size(188, 175); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.button1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button3); - this.Controls.Add(this.button4); - this.Controls.Add(this.button5); - this.Controls.Add(this.button6); - this.Controls.Add(this.button7); - this.Controls.Add(this.button8); - this.Controls.Add(this.button9); - this.Controls.Add(this.button10); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SRForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - public uint getsr() - { - return SR; - } - - private void button1_Click(object sender, EventArgs e) - { - SR = 0; - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button2_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button3_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button4_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button5_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button6_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button7_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button8_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button9_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - - private void button10_Click(object sender, EventArgs e) - { - SR = Convert.ToUInt16((sender as Button).Text); - this.DialogResult = DialogResult.OK; - this.Close(); - } - } -} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.resx b/ExtraFeatures/BATCSpectrum/SRForm.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ExtraFeatures/BATCSpectrum/SRForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs deleted file mode 100644 index 3edba7e..0000000 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - public class tuneModeSettings - { - public int[] tuneMode = { 1, 1, 1, 1 }; - public bool[] avoidBeacon = { true, true, true, true }; - } -} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs deleted file mode 100644 index b930338..0000000 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs +++ /dev/null @@ -1,268 +0,0 @@ -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - partial class tuneModeSettingsForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.avoidBeacon4 = new System.Windows.Forms.CheckBox(); - this.avoidBeacon3 = new System.Windows.Forms.CheckBox(); - this.avoidBeacon2 = new System.Windows.Forms.CheckBox(); - this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); - this.tuneMode4 = new System.Windows.Forms.ComboBox(); - this.tuneMode3 = new System.Windows.Forms.ComboBox(); - this.tuneMode2 = new System.Windows.Forms.ComboBox(); - this.tuneMode1 = new System.Windows.Forms.ComboBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.btnCancel = new System.Windows.Forms.Button(); - this.btnSave = new System.Windows.Forms.Button(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.avoidBeacon4); - this.groupBox1.Controls.Add(this.avoidBeacon3); - this.groupBox1.Controls.Add(this.avoidBeacon2); - this.groupBox1.Controls.Add(this.avoidBeacon1); - this.groupBox1.Controls.Add(this.tuneMode4); - this.groupBox1.Controls.Add(this.tuneMode3); - this.groupBox1.Controls.Add(this.tuneMode2); - this.groupBox1.Controls.Add(this.tuneMode1); - this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Location = new System.Drawing.Point(15, 15); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(304, 151); - this.groupBox1.TabIndex = 4; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Tuning Mode"; - // - // avoidBeacon4 - // - this.avoidBeacon4.AutoSize = true; - this.avoidBeacon4.Checked = true; - this.avoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; - this.avoidBeacon4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.avoidBeacon4.Location = new System.Drawing.Point(177, 121); - this.avoidBeacon4.Name = "avoidBeacon4"; - this.avoidBeacon4.Size = new System.Drawing.Size(111, 20); - this.avoidBeacon4.TabIndex = 11; - this.avoidBeacon4.Text = "Avoid Beacon"; - this.avoidBeacon4.UseVisualStyleBackColor = true; - // - // avoidBeacon3 - // - this.avoidBeacon3.AutoSize = true; - this.avoidBeacon3.Checked = true; - this.avoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; - this.avoidBeacon3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.avoidBeacon3.Location = new System.Drawing.Point(177, 91); - this.avoidBeacon3.Name = "avoidBeacon3"; - this.avoidBeacon3.Size = new System.Drawing.Size(111, 20); - this.avoidBeacon3.TabIndex = 10; - this.avoidBeacon3.Text = "Avoid Beacon"; - this.avoidBeacon3.UseVisualStyleBackColor = true; - // - // avoidBeacon2 - // - this.avoidBeacon2.AutoSize = true; - this.avoidBeacon2.Checked = true; - this.avoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; - this.avoidBeacon2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.avoidBeacon2.Location = new System.Drawing.Point(177, 61); - this.avoidBeacon2.Name = "avoidBeacon2"; - this.avoidBeacon2.Size = new System.Drawing.Size(111, 20); - this.avoidBeacon2.TabIndex = 9; - this.avoidBeacon2.Text = "Avoid Beacon"; - this.avoidBeacon2.UseVisualStyleBackColor = true; - // - // avoidBeacon1 - // - this.avoidBeacon1.AutoSize = true; - this.avoidBeacon1.Checked = true; - this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; - this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.avoidBeacon1.Location = new System.Drawing.Point(177, 31); - this.avoidBeacon1.Name = "avoidBeacon1"; - this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); - this.avoidBeacon1.TabIndex = 8; - this.avoidBeacon1.Text = "Avoid Beacon"; - this.avoidBeacon1.UseVisualStyleBackColor = true; - // - // tuneMode4 - // - this.tuneMode4.FormattingEnabled = true; - this.tuneMode4.Items.AddRange(new object[] { - "Manual", - "Auto"}); - this.tuneMode4.Location = new System.Drawing.Point(50, 120); - this.tuneMode4.Name = "tuneMode4"; - this.tuneMode4.Size = new System.Drawing.Size(121, 21); - this.tuneMode4.TabIndex = 7; - // - // tuneMode3 - // - this.tuneMode3.FormattingEnabled = true; - this.tuneMode3.Items.AddRange(new object[] { - "Manual", - "Auto"}); - this.tuneMode3.Location = new System.Drawing.Point(50, 90); - this.tuneMode3.Name = "tuneMode3"; - this.tuneMode3.Size = new System.Drawing.Size(121, 21); - this.tuneMode3.TabIndex = 6; - // - // tuneMode2 - // - this.tuneMode2.FormattingEnabled = true; - this.tuneMode2.Items.AddRange(new object[] { - "Manual", - "Auto"}); - this.tuneMode2.Location = new System.Drawing.Point(50, 60); - this.tuneMode2.Name = "tuneMode2"; - this.tuneMode2.Size = new System.Drawing.Size(121, 21); - this.tuneMode2.TabIndex = 5; - // - // tuneMode1 - // - this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tuneMode1.FormattingEnabled = true; - this.tuneMode1.Items.AddRange(new object[] { - "Manual", - "Auto"}); - this.tuneMode1.Location = new System.Drawing.Point(50, 30); - this.tuneMode1.Name = "tuneMode1"; - this.tuneMode1.Size = new System.Drawing.Size(121, 21); - this.tuneMode1.TabIndex = 4; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.label4.Location = new System.Drawing.Point(6, 123); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(38, 16); - this.label4.TabIndex = 3; - this.label4.Text = "RX 4:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.label3.Location = new System.Drawing.Point(6, 93); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 16); - this.label3.TabIndex = 2; - this.label3.Text = "RX 3:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.label2.Location = new System.Drawing.Point(6, 63); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(38, 16); - this.label2.TabIndex = 1; - this.label2.Text = "RX 2:"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.label1.Location = new System.Drawing.Point(6, 33); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 16); - this.label1.TabIndex = 0; - this.label1.Text = "RX 1:"; - // - // btnCancel - // - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(111, 173); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 28); - this.btnCancel.TabIndex = 3; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); - // - // btnSave - // - this.btnSave.Location = new System.Drawing.Point(219, 173); - this.btnSave.Margin = new System.Windows.Forms.Padding(4); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(100, 28); - this.btnSave.TabIndex = 2; - this.btnSave.Text = "Save"; - this.btnSave.UseVisualStyleBackColor = true; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // tuneModeSettingsForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(335, 210); - this.ControlBox = false; - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.btnSave); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "tuneModeSettingsForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "tuneModeSettings"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.ComboBox tuneMode1; - private System.Windows.Forms.ComboBox tuneMode2; - private System.Windows.Forms.ComboBox tuneMode3; - private System.Windows.Forms.ComboBox tuneMode4; - private System.Windows.Forms.CheckBox avoidBeacon1; - private System.Windows.Forms.CheckBox avoidBeacon2; - private System.Windows.Forms.CheckBox avoidBeacon3; - private System.Windows.Forms.CheckBox avoidBeacon4; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Button btnSave; - } -} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs deleted file mode 100644 index 89b495f..0000000 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - public partial class tuneModeSettingsForm : Form - { - private tuneModeSettings tuneModeSettings; - - public tuneModeSettingsForm(ref tuneModeSettings _tuneModeSettings) - { - tuneModeSettings = _tuneModeSettings; - InitializeComponent(); - - tuneMode1.SelectedIndex = tuneModeSettings.tuneMode[0]; - tuneMode2.SelectedIndex = tuneModeSettings.tuneMode[1]; - tuneMode3.SelectedIndex = tuneModeSettings.tuneMode[2]; - tuneMode4.SelectedIndex = tuneModeSettings.tuneMode[3]; - - avoidBeacon1.Checked = tuneModeSettings.avoidBeacon[0]; - avoidBeacon2.Checked = tuneModeSettings.avoidBeacon[1]; - avoidBeacon3.Checked = tuneModeSettings.avoidBeacon[2]; - avoidBeacon4.Checked = tuneModeSettings.avoidBeacon[3]; - } - - private void btnCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - - private void btnSave_Click(object sender, EventArgs e) - { - tuneModeSettings.tuneMode[0] = tuneMode1.SelectedIndex; - tuneModeSettings.tuneMode[1] = tuneMode2.SelectedIndex; - tuneModeSettings.tuneMode[2] = tuneMode3.SelectedIndex; - tuneModeSettings.tuneMode[3] = tuneMode4.SelectedIndex; - - tuneModeSettings.avoidBeacon[0] = avoidBeacon1.Checked; - tuneModeSettings.avoidBeacon[1] = avoidBeacon2.Checked; - tuneModeSettings.avoidBeacon[2] = avoidBeacon3.Checked; - tuneModeSettings.avoidBeacon[3] = avoidBeacon4.Checked; - - DialogResult = DialogResult.OK; - Close(); - } - } -} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs deleted file mode 100644 index 89ef2bc..0000000 --- a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs +++ /dev/null @@ -1,123 +0,0 @@ -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - partial class oneTunerTuneModeForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); - this.tuneMode1 = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.btnSave = new System.Windows.Forms.Button(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.avoidBeacon1); - this.groupBox1.Controls.Add(this.tuneMode1); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Location = new System.Drawing.Point(15, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(304, 54); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Tuning Mode"; - // - // avoidBeacon1 - // - this.avoidBeacon1.AutoSize = true; - this.avoidBeacon1.Checked = true; - this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; - this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.avoidBeacon1.Location = new System.Drawing.Point(177, 21); - this.avoidBeacon1.Name = "avoidBeacon1"; - this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); - this.avoidBeacon1.TabIndex = 8; - this.avoidBeacon1.Text = "Avoid Beacon"; - this.avoidBeacon1.UseVisualStyleBackColor = true; - // - // tuneMode1 - // - this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tuneMode1.FormattingEnabled = true; - this.tuneMode1.Items.AddRange(new object[] { - "Manual", - "Auto"}); - this.tuneMode1.Location = new System.Drawing.Point(50, 20); - this.tuneMode1.Name = "tuneMode1"; - this.tuneMode1.Size = new System.Drawing.Size(121, 21); - this.tuneMode1.TabIndex = 4; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); - this.label1.Location = new System.Drawing.Point(6, 23); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 16); - this.label1.TabIndex = 0; - this.label1.Text = "RX 1:"; - // - // btnSave - // - this.btnSave.Location = new System.Drawing.Point(219, 61); - this.btnSave.Margin = new System.Windows.Forms.Padding(4); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(100, 28); - this.btnSave.TabIndex = 7; - this.btnSave.Text = "Save"; - this.btnSave.UseVisualStyleBackColor = true; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // oneTunerTuneModeForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(331, 99); - this.Controls.Add(this.btnSave); - this.Controls.Add(this.groupBox1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "oneTunerTuneModeForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox tuneMode1; - private System.Windows.Forms.CheckBox avoidBeacon1; - private System.Windows.Forms.Button btnSave; - } -} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs deleted file mode 100644 index 8c5d859..0000000 --- a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - public partial class oneTunerTuneModeForm : Form - { - private int tuneMode = 1; - private bool avoidBeacon = true; - - public oneTunerTuneModeForm(int _tuner, int _tuneMode, bool _avoidBeacon) - { - tuneMode = _tuneMode; - avoidBeacon = _avoidBeacon; - InitializeComponent(); - - tuneMode1.SelectedIndex = tuneMode; - avoidBeacon1.Checked = avoidBeacon; - label1.Text = "RX " + _tuner.ToString() + ":"; - } - - public int getTuneMode() - { - return tuneMode; - } - - public bool getAvoidBeacon() - { - return avoidBeacon; - } - - private void btnCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - - private void btnSave_Click(object sender, EventArgs e) - { - tuneMode = tuneMode1.SelectedIndex; - avoidBeacon = avoidBeacon1.Checked; - - DialogResult = DialogResult.OK; - Close(); - } - } -} diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index eee09ad..36ee59b 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -26,9 +26,8 @@ public struct Sig public float sr; public string callsign; public bool overpower; - public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool overpower, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; @@ -37,12 +36,11 @@ public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, do this.frequency = _frequency; this.sr = _sr; this.callsign = ""; - this.overpower = _overpower; - this.max_strength = _max_strength; + this.overpower = overpower; this.dbb = _dbb; } - public Sig(Sig old, string _callsign) + public Sig(Sig old, string callsign) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; @@ -50,30 +48,28 @@ public Sig(Sig old, string _callsign) this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; - this.callsign = _callsign; + this.callsign = callsign; this.overpower = old.overpower; - this.max_strength = old.max_strength; this.dbb = old.dbb; } - public Sig(Sig old, string _callsign, float _sr) + public Sig(Sig old, string callsign, float sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; this.frequency = old.frequency; - this.sr = _sr; - this.callsign = _callsign; + this.sr = sr; + this.callsign = callsign; this.overpower = old.overpower; - this.max_strength = old.max_strength; this.dbb = old.dbb; } - public void updateCallsign(string _callsign) + public void updateCallsign(string callsign) { - this.callsign = _callsign; + this.callsign = callsign; } } @@ -84,7 +80,7 @@ public void updateCallsign(string _callsign) Object list_lock; public List signals = new List(); //list of signals found: public List signalsData = new List(); - double start_freq = 10490.5f; + const double start_freq = 10490.466f; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; @@ -99,11 +95,18 @@ public signal(object _list_lock) } + bool avoid_beacon = false; + private Sig[] last_sig = new Sig[8]; //last tune signal - detail private Sig[] next_sig = new Sig[8]; //last tune signal - detail private DateTime[] last_tuned_time = new DateTime[8]; //time the last signal was tuned + public void set_avoidbeacon(bool b) + { + avoid_beacon = b; + } + public void set_tuned(Sig s, int rx) { last_sig[rx] = s; @@ -151,7 +154,7 @@ public Tuple tune(int mode, int time, int rx) if ((t.Minutes * 60) + t.Seconds > time) { // Log.Information("elapsed: "+rx.ToString()); - next_sig[rx] = find_next(rx, true); + next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -162,7 +165,7 @@ public Tuple tune(int mode, int time, int rx) { if (!find_signal(last_sig[rx], rx)) //if the selected signal goes off then find another one to tune to { - next_sig[rx] = find_next(rx, true); + next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -175,7 +178,7 @@ public Tuple tune(int mode, int time, int rx) { if (!find_signal(last_sig[rx], rx)) //if the selected signal goes off then find another one to tune to { - next_sig[rx] = find_next(rx, true); + next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current { @@ -184,6 +187,8 @@ public Tuple tune(int mode, int time, int rx) } } + + // Log.Information("Count3:" + signals.Count().ToString()); if (change) { last_sig[rx] = next_sig[rx]; @@ -316,7 +321,7 @@ public void updateSignalList() } - private Sig find_next(int rx, bool avoid_beacon) + private Sig find_next(int rx) { Sig newsig = new Sig(); @@ -328,7 +333,7 @@ private Sig find_next(int rx, bool avoid_beacon) } else { - startfreq = startfreq = 10490.5f; + startfreq = startfreq = 10490; } // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); @@ -502,12 +507,11 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0)); } else { bool overpower = false; - int max_strength = (int)(beacon_strength - (0.75 * 3276.8)); // // The original dBb calculation code used at the QO-100 wideband spectrum web site is complicated: // @@ -539,7 +543,8 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); + + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, dBb)); } } diff --git a/ExtraFeatures/BATCSpectrum/socket.cs b/ExtraFeatures/BATCSpectrum/socket.cs index c860785..76ceaf6 100644 --- a/ExtraFeatures/BATCSpectrum/socket.cs +++ b/ExtraFeatures/BATCSpectrum/socket.cs @@ -12,6 +12,8 @@ namespace opentuner { class socket { + private const int padding = 8; // useless bytes to remove at the end of the socket data package + public Action callback; private WebSocket ws; //websocket client @@ -84,13 +86,14 @@ private void NewData(byte[] data) { lastdata = DateTime.Now; - fft_data = new UInt16[data.Length / 2]; + int data_length = data.Length - padding; // data length to process + fft_data = new UInt16[data_length / 2]; //unpack bytes to unsigned short int values int n = 0; byte[] buf = new byte[2]; - for (int i = 0; i < data.Length; i += 2) + for (int i = 0; i < data_length; i += 2) { buf[0] = data[i]; buf[1] = data[i + 1]; diff --git a/GlobalDefines.cs b/GlobalDefines.cs index ef9a259..078cf6b 100644 --- a/GlobalDefines.cs +++ b/GlobalDefines.cs @@ -9,6 +9,6 @@ namespace opentuner public static class GlobalDefines { public const int CircularBufferStartingCapacity = 250000; - public const string Version = "0.C"; + public const string Version = "0.B"; } } diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 49b4705..a9f36e3 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -119,7 +119,6 @@ private void InitializeComponent() this.ExtraToolsTab.SuspendLayout(); this.ExtraSpectrumTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.spectrum)).BeginInit(); - this.contextSpectrumMenu.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -320,7 +319,6 @@ private void InitializeComponent() this.linkBatcSpectrumSettings.Cursor = System.Windows.Forms.Cursors.Hand; this.linkBatcSpectrumSettings.ForeColor = System.Drawing.Color.RoyalBlue; this.linkBatcSpectrumSettings.Name = "linkBatcSpectrumSettings"; - this.linkBatcSpectrumSettings.Click += new System.EventHandler(this.linkBatcSpectrumSettings_Click); // // linkMqttSettings // @@ -544,8 +542,6 @@ private void InitializeComponent() // // contextSpectrumMenu // - this.contextSpectrumMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.autoTuneToolStripMenuItem}); this.contextSpectrumMenu.Name = "contextSpectrumMenu"; resources.ApplyResources(this.contextSpectrumMenu, "contextSpectrumMenu"); // @@ -688,7 +684,6 @@ private void InitializeComponent() this.ExtraToolsTab.ResumeLayout(false); this.ExtraSpectrumTab.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.spectrum)).EndInit(); - this.contextSpectrumMenu.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); @@ -709,10 +704,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem qO100WidebandChatToolStripMenuItem; private System.Windows.Forms.ContextMenuStrip contextSpectrumMenu; - private System.Windows.Forms.ToolStripMenuItem autoTuneToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem manualToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem autoTimedToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem autoHoldToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem plutoToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem commandsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem systemFunctionsToolStripMenuItem; diff --git a/MainForm.cs b/MainForm.cs index 805a589..295f7fe 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -404,18 +404,15 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str */ } - if (batc_spectrum != null) + if (batc_spectrum != null && properties.demod_locked) { - int tuner = properties.video_number; float freq = properties.frequency; float sr = properties.symbol_rate; string callsign = properties.service_name; - batc_spectrum.updateTuner(tuner, freq / 1000, sr / 1000, properties.demod_locked); - if (properties.demod_locked) - { - batc_spectrum.updateSignalCallsign(callsign, freq / 1000, sr / 1000); - } + //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); + + batc_spectrum.updateSignalCallsign(callsign, freq/1000, sr/1000); } @@ -628,7 +625,6 @@ private void Form1_Load(object sender, EventArgs e) private void Batc_spectrum_OnSignalSelected(int Receiver, uint Freq, uint SymbolRate) { videoSource.SetFrequency(Receiver, Freq, SymbolRate, true); - batc_spectrum.switchTuner(Receiver, Convert.ToDouble(Freq) / 1000.0f, SymbolRate / 1000.0f); } @@ -653,7 +649,6 @@ private void qO100WidebandChatToolStripMenuItem_Click(object sender, EventArgs e batc_chat.Show(); } - private void configureCallsignToolStripMenuItem_Click(object sender, EventArgs e) { pluto_client.ConfigureCallsignAndReboot("ZR6TG"); @@ -968,61 +963,16 @@ private void checkMqttClient_CheckedChanged(object sender, EventArgs e) _settings.enable_mqtt_checkbox = checkMqttClient.Checked; } - private void linkMqttSettings_Click(object sender, EventArgs e) - { - // mqtt settings - MqttManagerSettings mqtt_settings = new MqttManagerSettings(); - SettingsManager mqtt_settingsManager = new SettingsManager("mqttclient_settings"); - mqtt_settings = mqtt_settingsManager.LoadSettings(mqtt_settings); - - MqttSettingsForm mqtt_settings_form = new MqttSettingsForm(ref mqtt_settings); - - if (mqtt_settings_form.ShowDialog() == DialogResult.OK) - { - mqtt_settingsManager.SaveSettings(mqtt_settings); - } - } - private void checkQuicktune_CheckedChanged(object sender, EventArgs e) { _settings.enable_quicktune_checkbox = checkQuicktune.Checked; } - private void linkQuickTuneSettings_Click(object sender, EventArgs e) - { - // quick tune settings - QuickTuneControlSettings quicktune_settings = new QuickTuneControlSettings(); - SettingsManager quicktune_settingsManager = new SettingsManager("quicktune_settings"); - quicktune_settings = quicktune_settingsManager.LoadSettings(quicktune_settings); - - QuickTuneControlSettingsForm quicktune_settings_form = new QuickTuneControlSettingsForm(ref quicktune_settings); - - if (quicktune_settings_form.ShowDialog() == DialogResult.OK) - { - quicktune_settingsManager.SaveSettings(quicktune_settings); - } - } - private void checkBatcSpectrum_CheckedChanged(object sender, EventArgs e) { _settings.enable_spectrum_checkbox = checkBatcSpectrum.Checked; } - private void linkBatcSpectrumSettings_Click(object sender, EventArgs e) - { - // BATC tune settings - tuneModeSettings batc_settings = new tuneModeSettings(); - SettingsManager batc_settingsManager = new SettingsManager("tunemode_settings"); - batc_settings = batc_settingsManager.LoadSettings(batc_settings); - - tuneModeSettingsForm batc_settings_form = new tuneModeSettingsForm(ref batc_settings); - - if (batc_settings_form.ShowDialog() == DialogResult.OK) - { - batc_settingsManager.SaveSettings(batc_settings); - } - } - private void checkBatcChat_CheckedChanged(object sender, EventArgs e) { _settings.enable_chatform_checkbox = checkBatcChat.Checked; @@ -1049,6 +999,36 @@ private void linkDocumentation_Click(object sender, EventArgs e) System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-documentation/"); } + private void linkMqttSettings_Click(object sender, EventArgs e) + { + // mqtt settings + MqttManagerSettings mqtt_settings = new MqttManagerSettings(); + SettingsManager mqtt_settingsManager = new SettingsManager("mqttclient_settings"); + mqtt_settings = mqtt_settingsManager.LoadSettings(mqtt_settings); + + MqttSettingsForm mqtt_settings_form = new MqttSettingsForm(ref mqtt_settings); + + if (mqtt_settings_form.ShowDialog() == DialogResult.OK) + { + mqtt_settingsManager.SaveSettings(mqtt_settings); + } + } + + private void linkQuickTuneSettings_Click(object sender, EventArgs e) + { + // quick tune settings + QuickTuneControlSettings quicktune_settings = new QuickTuneControlSettings(); + SettingsManager quicktune_settingsManager = new SettingsManager("quicktune_settings"); + quicktune_settings = quicktune_settingsManager.LoadSettings(quicktune_settings); + + QuickTuneControlSettingsForm quicktune_settings_form = new QuickTuneControlSettingsForm(ref quicktune_settings); + + if (quicktune_settings_form.ShowDialog() == DialogResult.OK) + { + quicktune_settingsManager.SaveSettings(quicktune_settings); + } + } + private void linkSpectrumDocumentation_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-spectrum/"); @@ -1184,4 +1164,6 @@ private void LinkDatvReportMoreInfo_Click(object sender, EventArgs e) System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-datv-reporter/"); } } + + } diff --git a/MainForm.resx b/MainForm.resx index 43bf50a..414c9e2 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -696,6 +696,9 @@ Settings ... + + False + linkBatcSpectrumSettings @@ -1533,18 +1536,6 @@ 0 - - 437, 14 - - - 158, 26 - - - contextSpectrumMenu - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Fill @@ -1689,6 +1680,18 @@ 1 + + 437, 14 + + + 61, 4 + + + contextSpectrumMenu + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 157, 17 @@ -2343,30 +2346,6 @@ Open Tuner (ZR6TG) - 0.B Version - 2024/07/09 - - autoTuneToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - manualToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - autoTimedToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - autoHoldToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - openTunerToolStripMenuItem diff --git a/bandplan.xml b/bandplan.xml deleted file mode 100644 index f0625f5..0000000 --- a/bandplan.xml +++ /dev/null @@ -1,321 +0,0 @@ - - - - 10491.5 - 2402 - 1500 - BEACON - A - - - 10493.25 - 2403.75 - 1000 - 1500/1000 - A - - - 10494.75 - 2405.25 - 1000 - 1500/1000 - A - - - 10496.25 - 2406.75 - 1000 - 1500/1000 - A - - - 10492.75 - 2403.25 - 333 - 500/333/250 - B - - - 10493.25 - 2403.75 - 333 - 500/333/250 - B - - - 10493.75 - 2404.25 - 333 - 500/333/250 - B - - - 10494.25 - 2404.75 - 333 - 500/333/250 - B - - - 10494.75 - 2405.25 - 333 - 500/333/250 - B - - - 10495.25 - 2405.75 - 333 - 500/333/250 - B - - - 10495.75 - 2406.25 - 333 - 500/333/250 - B - - - 10496.25 - 2406.75 - 333 - 500/333/250 - B - - - 10496.75 - 2407.25 - 333 - 500/333/250 - B - - - 10497.25 - 2407.75 - 333 - 333/250 - B - - - 10497.75 - 2408.25 - 333 - 333/250 - B - - - 10498.25 - 2408.75 - 333 - 333/250 - B - - - 10498.75 - 2409.25 - 333 - 333/250 - B - - - 10499.25 - 2409.75 - 333 - 333/250 - B - - - 10492.75 - 2403.25 - 125 - 125/66/33 - C - - - 10493 - 2403.5 - 125 - 125/66/33 - C - - - 10493.25 - 2403.75 - 125 - 125/66/33 - C - - - 10493.5 - 2404 - 125 - 125/66/33 - C - - - 10493.75 - 2404.25 - 125 - 125/66/33 - C - - - 10494 - 2404.5 - 125 - 125/66/33 - C - - - 10494.25 - 2404.75 - 125 - 125/66/33 - C - - - 10494.5 - 2405 - 125 - 125/66/33 - C - - - 10494.75 - 2405.25 - 125 - 125/66/33 - C - - - 10495 - 2405.5 - 125 - 125/66/33 - C - - - 10495.25 - 2405.75 - 125 - 125/66/33 - C - - - 10495.5 - 2406 - 125 - 125/66/33 - C - - - 10495.75 - 2406.25 - 125 - 125/66/33 - C - - - 10496 - 2406.5 - 125 - 125/66/33 - C - - - 10496.25 - 2406.75 - 125 - 125/66/33 - C - - - 10496.5 - 2407 - 125 - 125/66/33 - C - - - 10496.75 - 2407.25 - 125 - 125/66/33 - C - - - 10497 - 2407.5 - 125 - 125/66/33 - C - - - 10497.25 - 2407.75 - 125 - 125/66/33 - C - - - 10497.5 - 2408 - 125 - 125/66/33 - C - - - 10497.75 - 2408.25 - 125 - 125/66/33 - C - - - 10498 - 2408.5 - 125 - 125/66/33 - C - - - 10498.25 - 2408.75 - 125 - 125/66/33 - C - - - 10498.5 - 2409 - 125 - 125/66/33 - C - - - 10498.75 - 2409.25 - 125 - 125/66/33 - C - - - 10499 - 2409.5 - 125 - 125/66/33 - C - - - 10499.25 - 2409.75 - 125 - 125/66/33 - C - - - - - \ No newline at end of file diff --git a/opentuner.csproj b/opentuner.csproj index 2785760..4effc91 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,27 +233,6 @@ - - Form - - - oneTunerTuneModeForm.cs - - - Form - - - True - True - SRForm.resx - - - - Form - - - TuneModeSettingsForm.cs - @@ -485,17 +464,6 @@ externalToolsManager.cs - - oneTunerTuneModeForm.cs - - - SRForm.cs - ResXFileCodeGenerator - SRForm.Designer.cs - - - TuneModeSettingsForm.cs - WebChatSettngsForm.cs @@ -644,7 +612,7 @@ - + PreserveNewest From 1f6e6a41e86a7b761f5e4312a268e3faffae68f8 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:58:44 +0100 Subject: [PATCH 55/98] adding overpower level line to spectrum --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 5 ++-- ExtraFeatures/BATCSpectrum/signal.cs | 29 +++++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 406afb6..d061004 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -26,12 +26,14 @@ public class BATCSpectrum public static readonly int height = 246; //makes things easier static readonly int bandplan_height = 30; + private const double start_freq = 10490.466f; Bitmap bmp; static Bitmap bmp2; Pen greyPen = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); + Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -44,8 +46,6 @@ public class BATCSpectrum int[,] rx_blocks = new int[4, 3]; - const double start_freq = 10490.466f; - XElement bandplan; Rectangle[] channels; IList indexedbandplan; @@ -461,6 +461,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength)); tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 36ee59b..bb79295 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -26,8 +26,9 @@ public struct Sig public float sr; public string callsign; public bool overpower; + public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool overpower, float _dbb) + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; @@ -36,11 +37,12 @@ public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, do this.frequency = _frequency; this.sr = _sr; this.callsign = ""; - this.overpower = overpower; + this.overpower = _overpower; + this.max_strength = _max_strength; this.dbb = _dbb; } - public Sig(Sig old, string callsign) + public Sig(Sig old, string _callsign) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; @@ -48,28 +50,30 @@ public Sig(Sig old, string callsign) this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; - this.callsign = callsign; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public Sig(Sig old, string callsign, float sr) + public Sig(Sig old, string _callsign, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; this.frequency = old.frequency; - this.sr = sr; - this.callsign = callsign; + this.sr = _sr; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public void updateCallsign(string callsign) + public void updateCallsign(string _callsign) { - this.callsign = callsign; + this.callsign = _callsign; } } @@ -333,7 +337,7 @@ private Sig find_next(int rx) } else { - startfreq = startfreq = 10490; + startfreq = 10490.466f; } // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); @@ -507,11 +511,12 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); } else { bool overpower = false; + int max_strength = (int)(beacon_strength - (0.75 * 3276.8)); // // The original dBb calculation code used at the QO-100 wideband spectrum web site is complicated: // @@ -544,7 +549,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); } } From 5015a8c9a358551cb92489341ad66024d5517fdb Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 12:58:44 +0100 Subject: [PATCH 56/98] adding overpower level line to spectrum --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 5 ++-- ExtraFeatures/BATCSpectrum/signal.cs | 29 +++++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 406afb6..d061004 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -26,12 +26,14 @@ public class BATCSpectrum public static readonly int height = 246; //makes things easier static readonly int bandplan_height = 30; + private const double start_freq = 10490.466f; Bitmap bmp; static Bitmap bmp2; Pen greyPen = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); + Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -44,8 +46,6 @@ public class BATCSpectrum int[,] rx_blocks = new int[4, 3]; - const double start_freq = 10490.466f; - XElement bandplan; Rectangle[] channels; IList indexedbandplan; @@ -461,6 +461,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength)); tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 36ee59b..bb79295 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -26,8 +26,9 @@ public struct Sig public float sr; public string callsign; public bool overpower; + public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool overpower, float _dbb) + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; @@ -36,11 +37,12 @@ public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, do this.frequency = _frequency; this.sr = _sr; this.callsign = ""; - this.overpower = overpower; + this.overpower = _overpower; + this.max_strength = _max_strength; this.dbb = _dbb; } - public Sig(Sig old, string callsign) + public Sig(Sig old, string _callsign) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; @@ -48,28 +50,30 @@ public Sig(Sig old, string callsign) this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; - this.callsign = callsign; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public Sig(Sig old, string callsign, float sr) + public Sig(Sig old, string _callsign, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; this.frequency = old.frequency; - this.sr = sr; - this.callsign = callsign; + this.sr = _sr; + this.callsign = _callsign; this.overpower = old.overpower; + this.max_strength = old.max_strength; this.dbb = old.dbb; } - public void updateCallsign(string callsign) + public void updateCallsign(string _callsign) { - this.callsign = callsign; + this.callsign = _callsign; } } @@ -333,7 +337,7 @@ private Sig find_next(int rx) } else { - startfreq = startfreq = 10490; + startfreq = 10490.466f; } // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); @@ -507,11 +511,12 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000 && signal_bw > 1.0) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); } else { bool overpower = false; + int max_strength = (int)(beacon_strength - (0.75 * 3276.8)); // // The original dBb calculation code used at the QO-100 wideband spectrum web site is complicated: // @@ -544,7 +549,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); } } From 27688028a3ea95d755b74134e700f48bfee50c3a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 8 Nov 2024 21:48:54 +0100 Subject: [PATCH 57/98] Calculations optimized. The changes give more precise frequency calculation over the whole spectrum span. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 16 +-- ExtraFeatures/BATCSpectrum/signal.cs | 117 ++++++++++----------- 2 files changed, 61 insertions(+), 72 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index d061004..30ccff3 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -6,7 +6,6 @@ using System.Runtime.Remoting.Channels; using System.Text; using System.Threading.Tasks; -using static opentuner.signal; using System.Windows.Forms; using System.Xml.Linq; using System.Diagnostics; @@ -26,7 +25,7 @@ public class BATCSpectrum public static readonly int height = 246; //makes things easier static readonly int bandplan_height = 30; - private const double start_freq = 10490.466f; + private const double start_freq = 10490.475; Bitmap bmp; static Bitmap bmp2; @@ -34,7 +33,7 @@ public class BATCSpectrum Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); - SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); + SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(200, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -362,14 +361,14 @@ private void drawspectrum_signals(List signals) { if (check_mouse_over_signal(s)) { - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } else { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } } } @@ -390,6 +389,7 @@ private void UpdateDrawing() } + // Entrypoint with new fft_data from websocket private void drawspectrum(UInt16[] fft_data) { fft_data_length = fft_data.Length; diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index bb79295..2519f5d 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -6,9 +6,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using opentuner.ExtraFeatures.BATCSpectrum; -namespace opentuner + +namespace opentuner.ExtraFeatures.BATCSpectrum { class signal { @@ -28,6 +28,7 @@ public struct Sig public bool overpower; public int max_strength; public float dbb; + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; @@ -84,7 +85,7 @@ public void updateCallsign(string _callsign) Object list_lock; public List signals = new List(); //list of signals found: public List signalsData = new List(); - const double start_freq = 10490.466f; + private const double start_freq = 10490.475; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; @@ -135,7 +136,6 @@ public void clear(int rx) last_sig[rx] = new Sig(); } - //function to find out whether to change tuning and which signal to tune to - auto tune mode public Tuple tune(int mode, int time, int rx) { @@ -148,16 +148,14 @@ public Tuple tune(int mode, int time, int rx) //Log.Information(rx); TimeSpan t = DateTime.Now - last_tuned_time[rx]; - lock (list_lock) { - if (mode == 2) //auto timed { //Log.Information(t.Seconds); if ((t.Minutes * 60) + t.Seconds > time) { - // Log.Information("elapsed: "+rx.ToString()); + //Log.Information("elapsed: "+rx.ToString()); next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current @@ -191,7 +189,6 @@ public Tuple tune(int mode, int time, int rx) } } - // Log.Information("Count3:" + signals.Count().ToString()); if (change) { @@ -206,8 +203,6 @@ public Tuple tune(int mode, int time, int rx) } } - - public bool find_signal(Sig lastsig, int rx) { float span; @@ -216,7 +211,7 @@ public bool find_signal(Sig lastsig, int rx) foreach (Sig s in signals) { - if (s.sr < 0.070) + if (s.sr < 0.070f) { span = 0.01f; } @@ -238,7 +233,7 @@ public bool diff_signals(Sig lastsig, Sig next) // Log.Information(lastsig.frequency-next.frequency); float span; bool diff = true; - if (lastsig.sr < 0.070 | next.sr < 0.070) + if (lastsig.sr < 0.070f | next.sr < 0.070f) { span = 0.01f; } @@ -256,10 +251,10 @@ public bool diff_signals(Sig lastsig, Sig next) public bool diff_signals(Sig sig, double frequency, float sr) { //debug(sig.frequency.ToString() + "," + frequency.ToString()); - // Log.Information(lastsig.frequency-next.frequency); + //Log.Information(lastsig.frequency-next.frequency); float span; bool diff = true; - if (sig.sr < 0.070 | sr < 0.070) + if (sig.sr < 0.070f | sr < 0.070f) { span = 0.01f; } @@ -319,31 +314,26 @@ public void updateSignalList() signalsData.Add(s); } } - - - - } private Sig find_next(int rx) { - Sig newsig = new Sig(); int n = 0; - float startfreq; + double startfreq; if (avoid_beacon) { - startfreq = 10492; + startfreq = 10492.0; } else { - startfreq = 10490.466f; + startfreq = 10490.5; } - // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); + //Log.Information("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency); foreach (Sig s in signals) { - // Console.Write("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()+" "); + //Log.Information("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()); bool newfreq = true; for (int i = 0; i < num_rx; i++) { @@ -352,7 +342,7 @@ private Sig find_next(int rx) newfreq = false; } } - // Console.Write("Available=" + newfreq.ToString() + " \n"); + //Log.Information("Available=" + newfreq.ToString()); if (s.frequency > startfreq && s.frequency > (last_sig[rx].frequency + 0.05) && s.sr >= minsr && newfreq) // +/- span, signal freq varies! { newsig = s; @@ -367,7 +357,7 @@ private Sig find_next(int rx) { foreach (Sig s in signals) { - // Console.Write("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()+" "); + //Log.Information("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()); bool newfreq = true; for (int i = 0; i < num_rx; i++) { @@ -376,17 +366,16 @@ private Sig find_next(int rx) newfreq = false; } } - // Console.Write("Available="+newfreq.ToString()+" \n"); + //Log.Information("Available="+newfreq.ToString()); if (s.frequency > startfreq && s.frequency < (last_sig[rx].frequency - 0.05) && s.sr >= minsr && newfreq) { newsig = s; - break; } } } - // Log.Information("new=:" + newsig.frequency.ToString()+"\n"); + //Log.Information("new=:" + newsig.frequency.ToString()); return newsig; } @@ -411,12 +400,12 @@ public bool isOverPower(int beacon_strength, int signal_strength, float signal_b { if (beacon_strength != 0) { - if (signal_bw < 0.4) + if (signal_bw < 0.4f) { return false; } - if (signal_strength > (beacon_strength - (0.75 * 3276.8))) + if (signal_strength > Math.Round(beacon_strength - (0.75 * 3276.8))) { return true; } @@ -425,11 +414,10 @@ public bool isOverPower(int beacon_strength, int signal_strength, float signal_b { Log.Information("Beacon Strength = 0"); } - - return false; } + // Entrypoint with new fft_data from drawspectrum public List detect_signals(UInt16[] fft_data) { lock (list_lock) @@ -444,7 +432,7 @@ public List detect_signals(UInt16[] fft_data) Boolean in_signal = false; int start_signal = 0; int end_signal; - float mid_signal; + double mid_signal; int strength_signal; float signal_bw; double signal_freq; @@ -455,7 +443,7 @@ public List detect_signals(UInt16[] fft_data) { if (!in_signal) { - if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0 > signal_threshold) + if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0f > signal_threshold) { in_signal = true; start_signal = i; @@ -464,7 +452,7 @@ public List detect_signals(UInt16[] fft_data) } else /* in_signal == true */ { - if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0 < signal_threshold) + if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0f < signal_threshold) { in_signal = false; @@ -472,46 +460,48 @@ public List detect_signals(UInt16[] fft_data) acc = 0; acc_i = 0; - // Log.Information(Convert.ToInt16(start_signal + (0.3 * (end_signal - start_signal)))); - // Log.Information( start_signal + (0.7 * (end_signal - start_signal))); + //Log.Information(Math.Round((start_signal + (0.3f * (end_signal - start_signal)))).ToString()); + //Log.Information(Math.Round((start_signal + (0.8f * (end_signal - start_signal)))).ToString()); - for (j = Convert.ToInt16(start_signal + (0.3 * (end_signal - start_signal))) | 0; j < start_signal + (0.8 * (end_signal - start_signal)); j++) + for (j = Convert.ToInt16(Math.Round(start_signal + (0.3f * (end_signal - start_signal)))) | 0; j < Math.Round(start_signal + (0.8f * (end_signal - start_signal))); j++) { acc = acc + fft_data[j]; acc_i = acc_i + 1; } - strength_signal = acc / acc_i; /* Find real start of top of signal */ - for (j = start_signal; (fft_data[j] - noise_level) < 0.75 * (strength_signal - noise_level); j++) + for (j = start_signal; (fft_data[j] - noise_level) < 0.75f * (strength_signal - noise_level); j++) { start_signal = j; } - /* Find real end of the top of signal */ - for (j = end_signal; (fft_data[j] - noise_level) < 0.75 * (strength_signal - noise_level); j--) + for (j = end_signal; (fft_data[j] - noise_level) < 0.75f * (strength_signal - noise_level); j--) { end_signal = j; } - // Log.Information("Start:" + start_signal.ToString()); - // Log.Information("End:" + end_signal.ToString()); - // Log.Information("Strength:" + strength_signal.ToString()); - mid_signal = Convert.ToSingle(start_signal + ((end_signal - start_signal) / 2.0)); - signal_bw = align_symbolrate(Convert.ToSingle((end_signal - start_signal) * (9.0 / (fft_data.Length)))); - signal_freq = Convert.ToDouble(start_freq + (((mid_signal + 1) / (fft_data.Length)) * 9.0)); + mid_signal = start_signal + ((end_signal - start_signal) / 2.0); + signal_bw = align_symbolrate((end_signal - start_signal) * 8.9995f / fft_data.Length); + signal_freq = Math.Round((start_freq + mid_signal / fft_data.Length * 8.9995),3); + + //Log.Information("Start :" + start_signal.ToString()); + //Log.Information("Middle :" + mid_signal.ToString()); + //Log.Information("End :" + end_signal.ToString()); + //Log.Information("Strength:" + strength_signal.ToString()); + //Log.Information("QRG :" + signal_freq.ToString()); + //Log.Information("BW :" + signal_bw.ToString()); // Exclude signals in beacon band if (signal_bw >= 0.033) { - if (signal_freq < 10492000 && signal_bw > 1.0) + if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -549,7 +539,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } @@ -558,56 +548,55 @@ public List detect_signals(UInt16[] fft_data) } } updateSignalList(); - } return signals; } public float align_symbolrate(float width) { - if (width < 0.022) + if (width < 0.022f) { return 0; } - else if (width < 0.060) + else if (width < 0.060f) { return 0.035f; } - else if (width < 0.086) + else if (width < 0.086f) { return 0.066f; } - else if (width < 0.185) + else if (width < 0.185f) { return 0.125f; } - else if (width < 0.277) + else if (width < 0.277f) { return 0.250f; } - else if (width < 0.388) + else if (width < 0.388f) { return 0.333f; } - else if (width < 0.700) + else if (width < 0.700f) { return 0.500f; } - else if (width < 1.2) + else if (width < 1.2f) { return 1.000f; } - else if (width < 1.6) + else if (width < 1.6f) { return 1.500f; } - else if (width < 2.2) + else if (width < 2.2f) { return 2.000f; } else { - return Convert.ToSingle(Math.Round(width * 5) / 5.0); + return Convert.ToSingle(Math.Round(width * 5.0) / 5.0); } } } From e6d9ac357ff82a0a66f63376038a1253da84fc3c Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 13:59:05 +0100 Subject: [PATCH 58/98] Calculations optimized --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 10 +++++----- ExtraFeatures/BATCSpectrum/signal.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 30ccff3..9ce7316 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -23,9 +23,9 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); - public static readonly int height = 246; //makes things easier + private const int height = 246; //makes things easier static readonly int bandplan_height = 30; - private const double start_freq = 10490.475; + private const double start_freq = 10490.4754901; Bitmap bmp; static Bitmap bmp2; @@ -364,11 +364,11 @@ private void drawspectrum_signals(List signals) tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } else { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } } } @@ -565,7 +565,7 @@ private void selectSignal(int X, int Y) } catch (Exception Ex) { - MessageBox.Show(Ex.Message); + Log.Error(Ex.Message); } } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 2519f5d..9788ae8 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -85,7 +85,7 @@ public void updateCallsign(string _callsign) Object list_lock; public List signals = new List(); //list of signals found: public List signalsData = new List(); - private const double start_freq = 10490.475; + private const double start_freq = 10490.4754901; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; From 60419e883a921fdcb41007baf274c64a2b7f0e35 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 14:04:09 +0100 Subject: [PATCH 59/98] Calculation optimized --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 20 ++-- ExtraFeatures/BATCSpectrum/signal.cs | 117 ++++++++++----------- 2 files changed, 63 insertions(+), 74 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index d061004..9ce7316 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -6,7 +6,6 @@ using System.Runtime.Remoting.Channels; using System.Text; using System.Threading.Tasks; -using static opentuner.signal; using System.Windows.Forms; using System.Xml.Linq; using System.Diagnostics; @@ -24,9 +23,9 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); - public static readonly int height = 246; //makes things easier + private const int height = 246; //makes things easier static readonly int bandplan_height = 30; - private const double start_freq = 10490.466f; + private const double start_freq = 10490.4754901; Bitmap bmp; static Bitmap bmp2; @@ -34,7 +33,7 @@ public class BATCSpectrum Pen greyPen2 = new Pen(Color.FromArgb(200, 123, 123, 123)); Pen whitePen = new Pen(Color.FromArgb(200, 255, 255, 255)); Pen overpowerPen = new Pen(Color.FromArgb(200, Color.Red)); - SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); + SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(200, Color.Gray)); SolidBrush bandplanBrush = new SolidBrush(Color.FromArgb(180, 250, 250, 255)); SolidBrush overpowerBrush = new SolidBrush(Color.FromArgb(128, Color.Red)); @@ -362,14 +361,14 @@ private void drawspectrum_signals(List signals) { if (check_mouse_over_signal(s)) { - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength)); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_start * spectrum_wScale), height); - tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); + tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } else { - tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); } } } @@ -390,6 +389,7 @@ private void UpdateDrawing() } + // Entrypoint with new fft_data from websocket private void drawspectrum(UInt16[] fft_data) { fft_data_length = fft_data.Length; @@ -565,7 +565,7 @@ private void selectSignal(int X, int Y) } catch (Exception Ex) { - MessageBox.Show(Ex.Message); + Log.Error(Ex.Message); } } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index bb79295..9788ae8 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -6,9 +6,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using opentuner.ExtraFeatures.BATCSpectrum; -namespace opentuner + +namespace opentuner.ExtraFeatures.BATCSpectrum { class signal { @@ -28,6 +28,7 @@ public struct Sig public bool overpower; public int max_strength; public float dbb; + public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; @@ -84,7 +85,7 @@ public void updateCallsign(string _callsign) Object list_lock; public List signals = new List(); //list of signals found: public List signalsData = new List(); - const double start_freq = 10490.466f; + private const double start_freq = 10490.4754901; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; @@ -135,7 +136,6 @@ public void clear(int rx) last_sig[rx] = new Sig(); } - //function to find out whether to change tuning and which signal to tune to - auto tune mode public Tuple tune(int mode, int time, int rx) { @@ -148,16 +148,14 @@ public Tuple tune(int mode, int time, int rx) //Log.Information(rx); TimeSpan t = DateTime.Now - last_tuned_time[rx]; - lock (list_lock) { - if (mode == 2) //auto timed { //Log.Information(t.Seconds); if ((t.Minutes * 60) + t.Seconds > time) { - // Log.Information("elapsed: "+rx.ToString()); + //Log.Information("elapsed: "+rx.ToString()); next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current @@ -191,7 +189,6 @@ public Tuple tune(int mode, int time, int rx) } } - // Log.Information("Count3:" + signals.Count().ToString()); if (change) { @@ -206,8 +203,6 @@ public Tuple tune(int mode, int time, int rx) } } - - public bool find_signal(Sig lastsig, int rx) { float span; @@ -216,7 +211,7 @@ public bool find_signal(Sig lastsig, int rx) foreach (Sig s in signals) { - if (s.sr < 0.070) + if (s.sr < 0.070f) { span = 0.01f; } @@ -238,7 +233,7 @@ public bool diff_signals(Sig lastsig, Sig next) // Log.Information(lastsig.frequency-next.frequency); float span; bool diff = true; - if (lastsig.sr < 0.070 | next.sr < 0.070) + if (lastsig.sr < 0.070f | next.sr < 0.070f) { span = 0.01f; } @@ -256,10 +251,10 @@ public bool diff_signals(Sig lastsig, Sig next) public bool diff_signals(Sig sig, double frequency, float sr) { //debug(sig.frequency.ToString() + "," + frequency.ToString()); - // Log.Information(lastsig.frequency-next.frequency); + //Log.Information(lastsig.frequency-next.frequency); float span; bool diff = true; - if (sig.sr < 0.070 | sr < 0.070) + if (sig.sr < 0.070f | sr < 0.070f) { span = 0.01f; } @@ -319,31 +314,26 @@ public void updateSignalList() signalsData.Add(s); } } - - - - } private Sig find_next(int rx) { - Sig newsig = new Sig(); int n = 0; - float startfreq; + double startfreq; if (avoid_beacon) { - startfreq = 10492; + startfreq = 10492.0; } else { - startfreq = 10490.466f; + startfreq = 10490.5; } - // Console.Write("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency+"\n"); + //Log.Information("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency); foreach (Sig s in signals) { - // Console.Write("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()+" "); + //Log.Information("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()); bool newfreq = true; for (int i = 0; i < num_rx; i++) { @@ -352,7 +342,7 @@ private Sig find_next(int rx) newfreq = false; } } - // Console.Write("Available=" + newfreq.ToString() + " \n"); + //Log.Information("Available=" + newfreq.ToString()); if (s.frequency > startfreq && s.frequency > (last_sig[rx].frequency + 0.05) && s.sr >= minsr && newfreq) // +/- span, signal freq varies! { newsig = s; @@ -367,7 +357,7 @@ private Sig find_next(int rx) { foreach (Sig s in signals) { - // Console.Write("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()+" "); + //Log.Information("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()); bool newfreq = true; for (int i = 0; i < num_rx; i++) { @@ -376,17 +366,16 @@ private Sig find_next(int rx) newfreq = false; } } - // Console.Write("Available="+newfreq.ToString()+" \n"); + //Log.Information("Available="+newfreq.ToString()); if (s.frequency > startfreq && s.frequency < (last_sig[rx].frequency - 0.05) && s.sr >= minsr && newfreq) { newsig = s; - break; } } } - // Log.Information("new=:" + newsig.frequency.ToString()+"\n"); + //Log.Information("new=:" + newsig.frequency.ToString()); return newsig; } @@ -411,12 +400,12 @@ public bool isOverPower(int beacon_strength, int signal_strength, float signal_b { if (beacon_strength != 0) { - if (signal_bw < 0.4) + if (signal_bw < 0.4f) { return false; } - if (signal_strength > (beacon_strength - (0.75 * 3276.8))) + if (signal_strength > Math.Round(beacon_strength - (0.75 * 3276.8))) { return true; } @@ -425,11 +414,10 @@ public bool isOverPower(int beacon_strength, int signal_strength, float signal_b { Log.Information("Beacon Strength = 0"); } - - return false; } + // Entrypoint with new fft_data from drawspectrum public List detect_signals(UInt16[] fft_data) { lock (list_lock) @@ -444,7 +432,7 @@ public List detect_signals(UInt16[] fft_data) Boolean in_signal = false; int start_signal = 0; int end_signal; - float mid_signal; + double mid_signal; int strength_signal; float signal_bw; double signal_freq; @@ -455,7 +443,7 @@ public List detect_signals(UInt16[] fft_data) { if (!in_signal) { - if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0 > signal_threshold) + if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0f > signal_threshold) { in_signal = true; start_signal = i; @@ -464,7 +452,7 @@ public List detect_signals(UInt16[] fft_data) } else /* in_signal == true */ { - if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0 < signal_threshold) + if ((fft_data[i] + fft_data[i - 1] + fft_data[i - 2]) / 3.0f < signal_threshold) { in_signal = false; @@ -472,46 +460,48 @@ public List detect_signals(UInt16[] fft_data) acc = 0; acc_i = 0; - // Log.Information(Convert.ToInt16(start_signal + (0.3 * (end_signal - start_signal)))); - // Log.Information( start_signal + (0.7 * (end_signal - start_signal))); + //Log.Information(Math.Round((start_signal + (0.3f * (end_signal - start_signal)))).ToString()); + //Log.Information(Math.Round((start_signal + (0.8f * (end_signal - start_signal)))).ToString()); - for (j = Convert.ToInt16(start_signal + (0.3 * (end_signal - start_signal))) | 0; j < start_signal + (0.8 * (end_signal - start_signal)); j++) + for (j = Convert.ToInt16(Math.Round(start_signal + (0.3f * (end_signal - start_signal)))) | 0; j < Math.Round(start_signal + (0.8f * (end_signal - start_signal))); j++) { acc = acc + fft_data[j]; acc_i = acc_i + 1; } - strength_signal = acc / acc_i; /* Find real start of top of signal */ - for (j = start_signal; (fft_data[j] - noise_level) < 0.75 * (strength_signal - noise_level); j++) + for (j = start_signal; (fft_data[j] - noise_level) < 0.75f * (strength_signal - noise_level); j++) { start_signal = j; } - /* Find real end of the top of signal */ - for (j = end_signal; (fft_data[j] - noise_level) < 0.75 * (strength_signal - noise_level); j--) + for (j = end_signal; (fft_data[j] - noise_level) < 0.75f * (strength_signal - noise_level); j--) { end_signal = j; } - // Log.Information("Start:" + start_signal.ToString()); - // Log.Information("End:" + end_signal.ToString()); - // Log.Information("Strength:" + strength_signal.ToString()); - mid_signal = Convert.ToSingle(start_signal + ((end_signal - start_signal) / 2.0)); - signal_bw = align_symbolrate(Convert.ToSingle((end_signal - start_signal) * (9.0 / (fft_data.Length)))); - signal_freq = Convert.ToDouble(start_freq + (((mid_signal + 1) / (fft_data.Length)) * 9.0)); + mid_signal = start_signal + ((end_signal - start_signal) / 2.0); + signal_bw = align_symbolrate((end_signal - start_signal) * 8.9995f / fft_data.Length); + signal_freq = Math.Round((start_freq + mid_signal / fft_data.Length * 8.9995),3); + + //Log.Information("Start :" + start_signal.ToString()); + //Log.Information("Middle :" + mid_signal.ToString()); + //Log.Information("End :" + end_signal.ToString()); + //Log.Information("Strength:" + strength_signal.ToString()); + //Log.Information("QRG :" + signal_freq.ToString()); + //Log.Information("BW :" + signal_bw.ToString()); // Exclude signals in beacon band if (signal_bw >= 0.033) { - if (signal_freq < 10492000 && signal_bw > 1.0) + if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, false, 0, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -549,7 +539,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), (strength_signal / BATCSpectrum.height), signal_freq, signal_bw, overpower, (max_strength / BATCSpectrum.height), dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } @@ -558,56 +548,55 @@ public List detect_signals(UInt16[] fft_data) } } updateSignalList(); - } return signals; } public float align_symbolrate(float width) { - if (width < 0.022) + if (width < 0.022f) { return 0; } - else if (width < 0.060) + else if (width < 0.060f) { return 0.035f; } - else if (width < 0.086) + else if (width < 0.086f) { return 0.066f; } - else if (width < 0.185) + else if (width < 0.185f) { return 0.125f; } - else if (width < 0.277) + else if (width < 0.277f) { return 0.250f; } - else if (width < 0.388) + else if (width < 0.388f) { return 0.333f; } - else if (width < 0.700) + else if (width < 0.700f) { return 0.500f; } - else if (width < 1.2) + else if (width < 1.2f) { return 1.000f; } - else if (width < 1.6) + else if (width < 1.6f) { return 1.500f; } - else if (width < 2.2) + else if (width < 2.2f) { return 2.000f; } else { - return Convert.ToSingle(Math.Round(width * 5) / 5.0); + return Convert.ToSingle(Math.Round(width * 5.0) / 5.0); } } } From 1755a94836a50c59648022271755a58a34a030c9 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 14:18:24 +0100 Subject: [PATCH 60/98] Update BATCSpectrum.cs Calculations optimized. + Cosmetic --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 9ce7316..0c144fe 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -166,7 +166,6 @@ private void Web_socket_ConnectionStatusChanged(object sender, bool connection_s { // reset retry count connect_retry_count = 0; - } else { @@ -402,7 +401,6 @@ private void drawspectrum(UInt16[] fft_data) int i = 1; int y = 0; - PointF[] points = new PointF[fft_data.Length]; for (i = 1; i < fft_data.Length; i++) //ignore padding? @@ -417,7 +415,7 @@ private void drawspectrum(UInt16[] fft_data) if (spectrumTunerHighlight > -1) { y = spectrumTunerHighlight * (spectrum_h / _tuners); - tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h/_tuners))); + tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); } //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); @@ -495,7 +493,7 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - int freq = Convert.ToInt32((10490.466 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); + int freq = Convert.ToInt32((10490.4754901 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); //UpdateTextBox(txtFreq, freq.ToString()); string tx_freq = get_bandplan_TX_freq(X, Y); @@ -547,7 +545,6 @@ private void selectSignal(int X, int Y) { if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) { - sigs.set_tuned(s, rx); rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); @@ -558,7 +555,6 @@ private void selectSignal(int X, int Y) debug("SR: " + sr.ToString()); OnSignalSelected?.Invoke(rx, freq, sr); - } } } From 34a56e9b16c2d78ded586d1abe37f73b9b05cb3f Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 14:20:58 +0100 Subject: [PATCH 61/98] Update BATCSpectrum.cs Calculation optimized. + Cosmetic --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 9ce7316..0c144fe 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -166,7 +166,6 @@ private void Web_socket_ConnectionStatusChanged(object sender, bool connection_s { // reset retry count connect_retry_count = 0; - } else { @@ -402,7 +401,6 @@ private void drawspectrum(UInt16[] fft_data) int i = 1; int y = 0; - PointF[] points = new PointF[fft_data.Length]; for (i = 1; i < fft_data.Length; i++) //ignore padding? @@ -417,7 +415,7 @@ private void drawspectrum(UInt16[] fft_data) if (spectrumTunerHighlight > -1) { y = spectrumTunerHighlight * (spectrum_h / _tuners); - tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h/_tuners))); + tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); } //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); @@ -495,7 +493,7 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - int freq = Convert.ToInt32((10490.466 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); + int freq = Convert.ToInt32((10490.4754901 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); //UpdateTextBox(txtFreq, freq.ToString()); string tx_freq = get_bandplan_TX_freq(X, Y); @@ -547,7 +545,6 @@ private void selectSignal(int X, int Y) { if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) { - sigs.set_tuned(s, rx); rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); @@ -558,7 +555,6 @@ private void selectSignal(int X, int Y) debug("SR: " + sr.ToString()); OnSignalSelected?.Invoke(rx, freq, sr); - } } } From c67b3cae65bc7fc8b28757d9ff9d029845a5c747 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 15:02:18 +0100 Subject: [PATCH 62/98] show tuned box if receiver has tuned and locked. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 19 +++++++++++++++++-- ExtraFeatures/BATCSpectrum/signal.cs | 12 ++++++------ MainForm.cs | 12 +++++++++--- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0c144fe..b042575 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -113,7 +113,7 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) } catch (Exception ex) { - MessageBox.Show(ex.Message); + Log.Error(ex.Message); } web_socket = new socket(); @@ -459,7 +459,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength)); + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } @@ -517,6 +517,21 @@ private void spectrum_Click(object sender, EventArgs e) // quick tune functions - From https://github.com/m0dts/QO-100-WB-Live-Tune - Rob Swinbank + public void updateTuner(int tuner, double freq, float sr, bool demod_locked) + { + if (demod_locked) + { + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + } + } + + public void switchTuner(int tuner, double freq, float sr) + { + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + } + private int determine_rx(int pos) { int rx = 0; diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 9788ae8..22ccdc5 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -57,13 +57,13 @@ public Sig(Sig old, string _callsign) this.dbb = old.dbb; } - public Sig(Sig old, string _callsign, float _sr) + public Sig(Sig old, string _callsign, double _frequency, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; - this.frequency = old.frequency; + this.frequency = _frequency; this.sr = _sr; this.callsign = _callsign; this.overpower = old.overpower; @@ -281,7 +281,7 @@ public void updateSignalList() { if (diff_signals(signalsData[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].callsign); + signalsData[x] = new Sig(sl, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); found = true; break; } @@ -387,8 +387,8 @@ public void updateCurrentSignal(string callsign, double freq, float sr) { if (diff_signals(signalsData[x], freq, sr) == false) { - //debug("found - updating callsign"); - signalsData[x] = new Sig(signalsData[x], callsign, sr); + //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); + signalsData[x] = new Sig(signalsData[x], callsign, freq, sr); break; } @@ -493,7 +493,7 @@ public List detect_signals(UInt16[] fft_data) //Log.Information("End :" + end_signal.ToString()); //Log.Information("Strength:" + strength_signal.ToString()); //Log.Information("QRG :" + signal_freq.ToString()); - //Log.Information("BW :" + signal_bw.ToString()); + //Log.Information("BW :" + signal_bw.ToString() + "\n"); // Exclude signals in beacon band if (signal_bw >= 0.033) diff --git a/MainForm.cs b/MainForm.cs index 295f7fe..d642bc2 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -404,15 +404,20 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str */ } - if (batc_spectrum != null && properties.demod_locked) + if (batc_spectrum != null) { + int tuner = properties.video_number; float freq = properties.frequency; float sr = properties.symbol_rate; string callsign = properties.service_name; - //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); + batc_spectrum.updateTuner(tuner, Math.Round(freq / 1000.0f,3), sr / 1000, properties.demod_locked); + if (properties.demod_locked) + { + //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); - batc_spectrum.updateSignalCallsign(callsign, freq/1000, sr/1000); + batc_spectrum.updateSignalCallsign(callsign, Math.Round(freq / 1000.0f,3), sr / 1000); + } } @@ -625,6 +630,7 @@ private void Form1_Load(object sender, EventArgs e) private void Batc_spectrum_OnSignalSelected(int Receiver, uint Freq, uint SymbolRate) { videoSource.SetFrequency(Receiver, Freq, SymbolRate, true); + batc_spectrum.switchTuner(Receiver, Convert.ToDouble(Freq) / 1000.0f, SymbolRate / 1000.0f); } From d2f9f440903049d324b156109bae9d299d57eb82 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 15:05:15 +0100 Subject: [PATCH 63/98] show tuned box if receiver has tuned and locked. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 19 +++++++++++++++++-- ExtraFeatures/BATCSpectrum/signal.cs | 12 ++++++------ MainForm.cs | 12 +++++++++--- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0c144fe..b042575 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -113,7 +113,7 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) } catch (Exception ex) { - MessageBox.Show(ex.Message); + Log.Error(ex.Message); } web_socket = new socket(); @@ -459,7 +459,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength)); + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } @@ -517,6 +517,21 @@ private void spectrum_Click(object sender, EventArgs e) // quick tune functions - From https://github.com/m0dts/QO-100-WB-Live-Tune - Rob Swinbank + public void updateTuner(int tuner, double freq, float sr, bool demod_locked) + { + if (demod_locked) + { + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + } + } + + public void switchTuner(int tuner, double freq, float sr) + { + rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + } + private int determine_rx(int pos) { int rx = 0; diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 9788ae8..22ccdc5 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -57,13 +57,13 @@ public Sig(Sig old, string _callsign) this.dbb = old.dbb; } - public Sig(Sig old, string _callsign, float _sr) + public Sig(Sig old, string _callsign, double _frequency, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; this.fft_strength = old.fft_strength; - this.frequency = old.frequency; + this.frequency = _frequency; this.sr = _sr; this.callsign = _callsign; this.overpower = old.overpower; @@ -281,7 +281,7 @@ public void updateSignalList() { if (diff_signals(signalsData[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].callsign); + signalsData[x] = new Sig(sl, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); found = true; break; } @@ -387,8 +387,8 @@ public void updateCurrentSignal(string callsign, double freq, float sr) { if (diff_signals(signalsData[x], freq, sr) == false) { - //debug("found - updating callsign"); - signalsData[x] = new Sig(signalsData[x], callsign, sr); + //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); + signalsData[x] = new Sig(signalsData[x], callsign, freq, sr); break; } @@ -493,7 +493,7 @@ public List detect_signals(UInt16[] fft_data) //Log.Information("End :" + end_signal.ToString()); //Log.Information("Strength:" + strength_signal.ToString()); //Log.Information("QRG :" + signal_freq.ToString()); - //Log.Information("BW :" + signal_bw.ToString()); + //Log.Information("BW :" + signal_bw.ToString() + "\n"); // Exclude signals in beacon band if (signal_bw >= 0.033) diff --git a/MainForm.cs b/MainForm.cs index 266df7f..15bba1e 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -404,15 +404,20 @@ private void VideoSource_OnSourceData(int video_nr, OTSourceData properties, str */ } - if (batc_spectrum != null && properties.demod_locked) + if (batc_spectrum != null) { + int tuner = properties.video_number; float freq = properties.frequency; float sr = properties.symbol_rate; string callsign = properties.service_name; - //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); + batc_spectrum.updateTuner(tuner, Math.Round(freq / 1000.0f,3), sr / 1000, properties.demod_locked); + if (properties.demod_locked) + { + //Log.Information(callsign.ToString() + "," + freq.ToString() + "," + sr.ToString()); - batc_spectrum.updateSignalCallsign(callsign, freq/1000, sr/1000); + batc_spectrum.updateSignalCallsign(callsign, Math.Round(freq / 1000.0f,3), sr / 1000); + } } @@ -625,6 +630,7 @@ private void Form1_Load(object sender, EventArgs e) private void Batc_spectrum_OnSignalSelected(int Receiver, uint Freq, uint SymbolRate) { videoSource.SetFrequency(Receiver, Freq, SymbolRate, true); + batc_spectrum.switchTuner(Receiver, Convert.ToDouble(Freq) / 1000.0f, SymbolRate / 1000.0f); } From e793364fef952d017a737738ede0d6fc1cdb9c02 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 17:00:24 +0100 Subject: [PATCH 64/98] reduce side wobbling of text in spectrum display. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 +++--- ExtraFeatures/BATCSpectrum/signal.cs | 33 ++++++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index b042575..2ffabec 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -363,11 +363,11 @@ private void drawspectrum_signals(List signals) tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } else { - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } } } @@ -460,7 +460,7 @@ private void drawspectrum(UInt16[] fft_data) if (sig.overpower) { tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } } @@ -493,7 +493,7 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - int freq = Convert.ToInt32((10490.4754901 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); + int freq = Convert.ToInt32(start_freq + X / (double)spectrum_wScale / fft_data_length * 9.0 * 1000.0); //UpdateTextBox(txtFreq, freq.ToString()); string tx_freq = get_bandplan_TX_freq(X, Y); diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 22ccdc5..9011288 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -20,7 +20,8 @@ public struct Sig { public int fft_start; public int fft_stop; - public int fft_centre; + public float fft_centre; + public float text_pos; // not wobbling position for showing the text message. (derived from fft_centre) public int fft_strength; public double frequency; public float sr; @@ -29,11 +30,12 @@ public struct Sig public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) + public Sig(int _fft_start, int _fft_stop, float _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; this.fft_centre = _fft_centre; + this.text_pos = _fft_centre; this.fft_strength = _fft_strength; this.frequency = _frequency; this.sr = _sr; @@ -48,6 +50,7 @@ public Sig(Sig old, string _callsign) this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; + this.text_pos = old.text_pos; this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; @@ -57,11 +60,27 @@ public Sig(Sig old, string _callsign) this.dbb = old.dbb; } + public Sig(Sig old, float _text_pos, string _callsign, double _frequency, float _sr) + { + this.fft_start = old.fft_start; + this.fft_stop = old.fft_stop; + this.fft_centre = old.fft_centre; + this.text_pos = _text_pos; + this.fft_strength = old.fft_strength; + this.frequency = _frequency; + this.sr = _sr; + this.callsign = _callsign; + this.overpower = old.overpower; + this.max_strength = old.max_strength; + this.dbb = old.dbb; + } + public Sig(Sig old, string _callsign, double _frequency, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; + this.text_pos = old.text_pos; this.fft_strength = old.fft_strength; this.frequency = _frequency; this.sr = _sr; @@ -281,7 +300,7 @@ public void updateSignalList() { if (diff_signals(signalsData[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); + signalsData[x] = new Sig(sl, signalsData[x].text_pos, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); found = true; break; } @@ -388,8 +407,7 @@ public void updateCurrentSignal(string callsign, double freq, float sr) if (diff_signals(signalsData[x], freq, sr) == false) { //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); - signalsData[x] = new Sig(signalsData[x], callsign, freq, sr); - + signalsData[x] = new Sig(signalsData[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); break; } } @@ -447,7 +465,6 @@ public List detect_signals(UInt16[] fft_data) { in_signal = true; start_signal = i; - } } else /* in_signal == true */ @@ -501,7 +518,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -539,7 +556,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } From cf02d9a292f90467ea20e67f9c849142e3ed3f20 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 17:19:41 +0100 Subject: [PATCH 65/98] reduce side wobbling of text in spectrum display --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 +++--- ExtraFeatures/BATCSpectrum/signal.cs | 33 ++++++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index b042575..2ffabec 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -363,11 +363,11 @@ private void drawspectrum_signals(List signals) tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } else { - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(Convert.ToSingle((s.fft_centre * spectrum_wScale) - (30)), (height - Convert.ToSingle(s.fft_strength / height + 50)))); + tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } } } @@ -460,7 +460,7 @@ private void drawspectrum(UInt16[] fft_data) if (sig.overpower) { tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.fft_centre * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); } } } @@ -493,7 +493,7 @@ private void spectrum_Click(object sender, EventArgs e) if (Y > spectrum_h) { - int freq = Convert.ToInt32((10490.4754901 + ((X / spectrum_wScale) / fft_data_length) * 9.0) * 1000.0); + int freq = Convert.ToInt32(start_freq + X / (double)spectrum_wScale / fft_data_length * 9.0 * 1000.0); //UpdateTextBox(txtFreq, freq.ToString()); string tx_freq = get_bandplan_TX_freq(X, Y); diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 22ccdc5..9011288 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -20,7 +20,8 @@ public struct Sig { public int fft_start; public int fft_stop; - public int fft_centre; + public float fft_centre; + public float text_pos; // not wobbling position for showing the text message. (derived from fft_centre) public int fft_strength; public double frequency; public float sr; @@ -29,11 +30,12 @@ public struct Sig public int max_strength; public float dbb; - public Sig(int _fft_start, int _fft_stop, int _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) + public Sig(int _fft_start, int _fft_stop, float _fft_centre, int _fft_strength, double _frequency, float _sr, bool _overpower, int _max_strength, float _dbb) { this.fft_start = _fft_start; this.fft_stop = _fft_stop; this.fft_centre = _fft_centre; + this.text_pos = _fft_centre; this.fft_strength = _fft_strength; this.frequency = _frequency; this.sr = _sr; @@ -48,6 +50,7 @@ public Sig(Sig old, string _callsign) this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; + this.text_pos = old.text_pos; this.fft_strength = old.fft_strength; this.frequency = old.frequency; this.sr = old.sr; @@ -57,11 +60,27 @@ public Sig(Sig old, string _callsign) this.dbb = old.dbb; } + public Sig(Sig old, float _text_pos, string _callsign, double _frequency, float _sr) + { + this.fft_start = old.fft_start; + this.fft_stop = old.fft_stop; + this.fft_centre = old.fft_centre; + this.text_pos = _text_pos; + this.fft_strength = old.fft_strength; + this.frequency = _frequency; + this.sr = _sr; + this.callsign = _callsign; + this.overpower = old.overpower; + this.max_strength = old.max_strength; + this.dbb = old.dbb; + } + public Sig(Sig old, string _callsign, double _frequency, float _sr) { this.fft_start = old.fft_start; this.fft_stop = old.fft_stop; this.fft_centre = old.fft_centre; + this.text_pos = old.text_pos; this.fft_strength = old.fft_strength; this.frequency = _frequency; this.sr = _sr; @@ -281,7 +300,7 @@ public void updateSignalList() { if (diff_signals(signalsData[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); + signalsData[x] = new Sig(sl, signalsData[x].text_pos, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); found = true; break; } @@ -388,8 +407,7 @@ public void updateCurrentSignal(string callsign, double freq, float sr) if (diff_signals(signalsData[x], freq, sr) == false) { //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); - signalsData[x] = new Sig(signalsData[x], callsign, freq, sr); - + signalsData[x] = new Sig(signalsData[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); break; } } @@ -447,7 +465,6 @@ public List detect_signals(UInt16[] fft_data) { in_signal = true; start_signal = i; - } } else /* in_signal == true */ @@ -501,7 +518,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -539,7 +556,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToInt32(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); + signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } From 99121bb01b3c4adc082fbd68293358730fe338ba Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 17:45:42 +0100 Subject: [PATCH 66/98] Signal lists renamed to make them more clear to me. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 ++-- ExtraFeatures/BATCSpectrum/signal.cs | 53 ++++++++++------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 2ffabec..38055ac 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -455,7 +455,7 @@ private void drawspectrum(UInt16[] fft_data) // draw over power lock (list_lock) { - foreach (var sig in sigs.signalsData) + foreach (var sig in sigs.signals) { if (sig.overpower) { @@ -472,7 +472,7 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } - drawspectrum_signals(sigs.signalsData); + drawspectrum_signals(sigs.signals); } private void spectrum_Click(object sender, EventArgs e) @@ -556,7 +556,7 @@ private void selectSignal(int X, int Y) { lock (list_lock) { - foreach (signal.Sig s in sigs.signals) + foreach (signal.Sig s in sigs.newSignals) { if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) { @@ -590,7 +590,7 @@ private bool check_mouse_over_signal(signal.Sig s) if (mousePos_y < spectrum_h) { - if ((mousePos_x > (s.fft_start * spectrum_wScale)) && (mousePos_x < (s.fft_stop * spectrum_wScale)) && (mousePos_y > (_spectrum.Height - s.fft_strength))) + if ((mousePos_x > (s.fft_start * spectrum_wScale)) && (mousePos_x < (s.fft_stop * spectrum_wScale)) && (mousePos_y > (_spectrum.Height - s.fft_strength / height))) { return true; } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 9011288..eba5604 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -7,7 +7,6 @@ using System.Text; using System.Threading.Tasks; - namespace opentuner.ExtraFeatures.BATCSpectrum { class signal @@ -90,7 +89,6 @@ public Sig(Sig old, string _callsign, double _frequency, float _sr) this.dbb = old.dbb; } - public void updateCallsign(string _callsign) { this.callsign = _callsign; @@ -100,23 +98,17 @@ public void updateCallsign(string _callsign) public Action debug; - Object list_lock; - public List signals = new List(); //list of signals found: - public List signalsData = new List(); + public List newSignals = new List(); // list of signals new arrived from websocket + public List signals = new List(); // actual list of signals (processed) private const double start_freq = 10490.4754901; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; - Random rnd = new Random(); - public signal(object _list_lock) { list_lock = _list_lock; - //init nothing! - - } bool avoid_beacon = false; @@ -145,6 +137,7 @@ public void set_num_rx(int _num_rx) { num_rx = _num_rx; } + public void set_num_rx_scan(int _num_rx_scan) { num_rx_scan = _num_rx_scan; @@ -208,7 +201,7 @@ public Tuple tune(int mode, int time, int rx) } } - // Log.Information("Count3:" + signals.Count().ToString()); + // Log.Information("Count3:" + newSignals.Count().ToString()); if (change) { last_sig[rx] = next_sig[rx]; @@ -228,7 +221,7 @@ public bool find_signal(Sig lastsig, int rx) bool found = false; int n = 0; - foreach (Sig s in signals) + foreach (Sig s in newSignals) { if (s.sr < 0.070f) { @@ -291,16 +284,16 @@ public bool diff_signals(Sig sig, double frequency, float sr) public void updateSignalList() { // check current signal list - //foreach (Sig s in signalsData.ToList()) - for (int x = 0; x < signalsData.Count; x++) + //foreach (Sig s in signals.ToList()) + for (int x = 0; x < signals.Count; x++) { bool found = false; - foreach (Sig sl in signals) + foreach (Sig sl in newSignals) { - if (diff_signals(signalsData[x], sl) == false) // same sig + if (diff_signals(signals[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].text_pos, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); + signals[x] = new Sig(sl, signals[x].text_pos, signals[x].callsign, signals[x].frequency, signals[x].sr); found = true; break; } @@ -309,16 +302,16 @@ public void updateSignalList() if (!found) { //debug("Removing a signal"); - signalsData.Remove(signalsData[x]); + signals.Remove(signals[x]); } } // check new signal list - foreach (Sig s in signals) + foreach (Sig s in newSignals) { bool found = false; - foreach (Sig sl in signalsData) + foreach (Sig sl in signals) { if (diff_signals(s, sl) == false) // same sig { @@ -330,7 +323,7 @@ public void updateSignalList() if (!found) { //debug("Adding a signal"); - signalsData.Add(s); + signals.Add(s); } } } @@ -350,7 +343,7 @@ private Sig find_next(int rx) } //Log.Information("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency); - foreach (Sig s in signals) + foreach (Sig s in newSignals) { //Log.Information("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()); bool newfreq = true; @@ -374,7 +367,7 @@ private Sig find_next(int rx) } if (newsig.frequency < 1) //nothing available above last freq, return to bottom and start again until orig signal freq { - foreach (Sig s in signals) + foreach (Sig s in newSignals) { //Log.Information("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()); bool newfreq = true; @@ -402,12 +395,12 @@ public void updateCurrentSignal(string callsign, double freq, float sr) { lock (list_lock) { - for (int x = 0; x < signalsData.Count; x++) + for (int x = 0; x < signals.Count; x++) { - if (diff_signals(signalsData[x], freq, sr) == false) + if (diff_signals(signals[x], freq, sr) == false) { //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); - signalsData[x] = new Sig(signalsData[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); + signals[x] = new Sig(signals[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); break; } } @@ -440,7 +433,7 @@ public List detect_signals(UInt16[] fft_data) { lock (list_lock) { - signals.Clear(); + newSignals.Clear(); int i; int j; @@ -518,7 +511,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); + newSignals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -556,7 +549,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); + newSignals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } @@ -566,7 +559,7 @@ public List detect_signals(UInt16[] fft_data) } updateSignalList(); } - return signals; + return newSignals; } public float align_symbolrate(float width) From 6ef6b26318872b2af954896ac2c7b6327b462f94 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 17:53:51 +0100 Subject: [PATCH 67/98] Signal lists renamed to make them more clear to me. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 ++-- ExtraFeatures/BATCSpectrum/signal.cs | 53 ++++++++++------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 2ffabec..38055ac 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -455,7 +455,7 @@ private void drawspectrum(UInt16[] fft_data) // draw over power lock (list_lock) { - foreach (var sig in sigs.signalsData) + foreach (var sig in sigs.signals) { if (sig.overpower) { @@ -472,7 +472,7 @@ private void drawspectrum(UInt16[] fft_data) tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } - drawspectrum_signals(sigs.signalsData); + drawspectrum_signals(sigs.signals); } private void spectrum_Click(object sender, EventArgs e) @@ -556,7 +556,7 @@ private void selectSignal(int X, int Y) { lock (list_lock) { - foreach (signal.Sig s in sigs.signals) + foreach (signal.Sig s in sigs.newSignals) { if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) { @@ -590,7 +590,7 @@ private bool check_mouse_over_signal(signal.Sig s) if (mousePos_y < spectrum_h) { - if ((mousePos_x > (s.fft_start * spectrum_wScale)) && (mousePos_x < (s.fft_stop * spectrum_wScale)) && (mousePos_y > (_spectrum.Height - s.fft_strength))) + if ((mousePos_x > (s.fft_start * spectrum_wScale)) && (mousePos_x < (s.fft_stop * spectrum_wScale)) && (mousePos_y > (_spectrum.Height - s.fft_strength / height))) { return true; } diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 9011288..eba5604 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -7,7 +7,6 @@ using System.Text; using System.Threading.Tasks; - namespace opentuner.ExtraFeatures.BATCSpectrum { class signal @@ -90,7 +89,6 @@ public Sig(Sig old, string _callsign, double _frequency, float _sr) this.dbb = old.dbb; } - public void updateCallsign(string _callsign) { this.callsign = _callsign; @@ -100,23 +98,17 @@ public void updateCallsign(string _callsign) public Action debug; - Object list_lock; - public List signals = new List(); //list of signals found: - public List signalsData = new List(); + public List newSignals = new List(); // list of signals new arrived from websocket + public List signals = new List(); // actual list of signals (processed) private const double start_freq = 10490.4754901; float minsr = 0.065f; int num_rx_scan = 1; int num_rx = 1; - Random rnd = new Random(); - public signal(object _list_lock) { list_lock = _list_lock; - //init nothing! - - } bool avoid_beacon = false; @@ -145,6 +137,7 @@ public void set_num_rx(int _num_rx) { num_rx = _num_rx; } + public void set_num_rx_scan(int _num_rx_scan) { num_rx_scan = _num_rx_scan; @@ -208,7 +201,7 @@ public Tuple tune(int mode, int time, int rx) } } - // Log.Information("Count3:" + signals.Count().ToString()); + // Log.Information("Count3:" + newSignals.Count().ToString()); if (change) { last_sig[rx] = next_sig[rx]; @@ -228,7 +221,7 @@ public bool find_signal(Sig lastsig, int rx) bool found = false; int n = 0; - foreach (Sig s in signals) + foreach (Sig s in newSignals) { if (s.sr < 0.070f) { @@ -291,16 +284,16 @@ public bool diff_signals(Sig sig, double frequency, float sr) public void updateSignalList() { // check current signal list - //foreach (Sig s in signalsData.ToList()) - for (int x = 0; x < signalsData.Count; x++) + //foreach (Sig s in signals.ToList()) + for (int x = 0; x < signals.Count; x++) { bool found = false; - foreach (Sig sl in signals) + foreach (Sig sl in newSignals) { - if (diff_signals(signalsData[x], sl) == false) // same sig + if (diff_signals(signals[x], sl) == false) // same sig { - signalsData[x] = new Sig(sl, signalsData[x].text_pos, signalsData[x].callsign, signalsData[x].frequency, signalsData[x].sr); + signals[x] = new Sig(sl, signals[x].text_pos, signals[x].callsign, signals[x].frequency, signals[x].sr); found = true; break; } @@ -309,16 +302,16 @@ public void updateSignalList() if (!found) { //debug("Removing a signal"); - signalsData.Remove(signalsData[x]); + signals.Remove(signals[x]); } } // check new signal list - foreach (Sig s in signals) + foreach (Sig s in newSignals) { bool found = false; - foreach (Sig sl in signalsData) + foreach (Sig sl in signals) { if (diff_signals(s, sl) == false) // same sig { @@ -330,7 +323,7 @@ public void updateSignalList() if (!found) { //debug("Adding a signal"); - signalsData.Add(s); + signals.Add(s); } } } @@ -350,7 +343,7 @@ private Sig find_next(int rx) } //Log.Information("Rx:" + rx.ToString() + " Current Tuned:" + last_sig[rx].frequency); - foreach (Sig s in signals) + foreach (Sig s in newSignals) { //Log.Information("Rx:" + rx.ToString() + " 1st Try:" + s.frequency.ToString()); bool newfreq = true; @@ -374,7 +367,7 @@ private Sig find_next(int rx) } if (newsig.frequency < 1) //nothing available above last freq, return to bottom and start again until orig signal freq { - foreach (Sig s in signals) + foreach (Sig s in newSignals) { //Log.Information("Rx:"+rx.ToString()+" 2nd Try:" + s.frequency.ToString()); bool newfreq = true; @@ -402,12 +395,12 @@ public void updateCurrentSignal(string callsign, double freq, float sr) { lock (list_lock) { - for (int x = 0; x < signalsData.Count; x++) + for (int x = 0; x < signals.Count; x++) { - if (diff_signals(signalsData[x], freq, sr) == false) + if (diff_signals(signals[x], freq, sr) == false) { //debug("updateCurrentSignal: found! x: " + x.ToString() +", Call: " + callsign + "QRG: " + freq.ToString() + ", SR: " + sr.ToString()); - signalsData[x] = new Sig(signalsData[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); + signals[x] = new Sig(signals[x], Convert.ToSingle(Math.Round((freq - start_freq) * 102.0f, 1)), callsign, freq, sr); break; } } @@ -440,7 +433,7 @@ public List detect_signals(UInt16[] fft_data) { lock (list_lock) { - signals.Clear(); + newSignals.Clear(); int i; int j; @@ -518,7 +511,7 @@ public List detect_signals(UInt16[] fft_data) if (signal_freq < 10492000.0 && signal_bw > 1.0f) { beacon_strength = strength_signal; - signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); + newSignals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, false, 0, 0)); } else { @@ -556,7 +549,7 @@ public List detect_signals(UInt16[] fft_data) if (isOverPower(beacon_strength, strength_signal, signal_bw)) overpower = true; - signals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); + newSignals.Add(new Sig(start_signal, end_signal, Convert.ToSingle(mid_signal), strength_signal, signal_freq, signal_bw, overpower, max_strength, dBb)); } } @@ -566,7 +559,7 @@ public List detect_signals(UInt16[] fft_data) } updateSignalList(); } - return signals; + return newSignals; } public float align_symbolrate(float width) From 86397ceb0409c86b902a05f88cf93fbd931e2b33 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 18:53:03 +0100 Subject: [PATCH 68/98] Symbol rate form and functionality added Symbol Rate Form added. It is used when the right Mouse button is pressed within a tuner field. This will force a new tuning with selected symbol rate. Function is as within QO100 WB Live Tune program. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 85 ++++-- ExtraFeatures/BATCSpectrum/SRForm.Designer.cs | 63 ++++ ExtraFeatures/BATCSpectrum/SRForm.cs | 281 ++++++++++++++++++ ExtraFeatures/BATCSpectrum/SRForm.resx | 120 ++++++++ ExtraFeatures/BATCSpectrum/signal.cs | 2 +- opentuner.csproj | 13 + 6 files changed, 540 insertions(+), 24 deletions(-) create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.resx diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 38055ac..0ccafd1 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -73,6 +73,7 @@ public class BATCSpectrum private int mousePos_y = 0; private int fft_data_length = 918; + public bool pluto_control_enabled = false; public void updateSignalCallsign(string callsign, double freq, float sr) { @@ -279,7 +280,7 @@ private void spectrum_SizeChanged(object sender, EventArgs e) } catch (Exception Ex) { - + Log.Error(Ex.Message); } } @@ -363,11 +364,11 @@ private void drawspectrum_signals(List signals) tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.000") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } else { - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.000") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } } } @@ -383,7 +384,7 @@ private void UpdateDrawing() } catch (Exception Ex) { - + Log.Error(Ex.Message); } } @@ -469,7 +470,7 @@ private void drawspectrum(UInt16[] fft_data) { y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } drawspectrum_signals(sigs.signals); @@ -477,7 +478,7 @@ private void drawspectrum(UInt16[] fft_data) private void spectrum_Click(object sender, EventArgs e) { - + int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; float spectrum_wScale = spectrum_w / fft_data_length; @@ -487,33 +488,71 @@ private void spectrum_Click(object sender, EventArgs e) int X = pos.X; int Y = pos.Y; - if (me.Button == MouseButtons.Right) + if (Y > spectrum_h) { - int spectrum_h = _spectrum.Height - bandplan_height; - - if (Y > spectrum_h) + if (pluto_control_enabled) { - int freq = Convert.ToInt32(start_freq + X / (double)spectrum_wScale / fft_data_length * 9.0 * 1000.0); - //UpdateTextBox(txtFreq, freq.ToString()); - - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) + switch (me.Button) { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; + case MouseButtons.Left: + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + break; + default: + break; } } } else { - selectSignal(X, Y); - } + switch (me.Button) + { + case MouseButtons.Left: + if (Control.ModifierKeys == Keys.Shift) + { - } + } + else + { + selectSignal(X, Y); + } + break; + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_srForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int srForm_width = srForm.Size.Width; + + if (X > (srForm_width / 2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; + if (X > (spectrum_width - srForm.Size.Width / 2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); + + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; + DialogResult result = srForm.ShowDialog(); + if (result == DialogResult.OK) + { + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); + } + } + break; + default: + break; + } + } + } // quick tune functions - From https://github.com/m0dts/QO-100-WB-Live-Tune - Rob Swinbank diff --git a/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs new file mode 100644 index 0000000..81e4ef3 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace opentuner.ExtraFeatures.BATCSpectrum { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class SRForm { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SRForm() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("opentuner.ExtraFeatures.BATCSpectrum.SRForm", typeof(SRForm).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs new file mode 100644 index 0000000..beba1b7 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.cs @@ -0,0 +1,281 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner +{ + internal class SRForm : Form + { + private Button button25; + private Button button33; + private Button button66; + private Button button125; + private Button button250; + private Button button333; + private Button button500; + private Button button1000; + private Button button1500; + private Label label1; + private Label label2; + private Label label3; + uint qrg = 0; + uint SR = 0; + + public SRForm(uint _qrg) + { + qrg = _qrg; + InitializeComponent(); + label3.Text = (qrg / 1000.0f).ToString() + " MHz"; + + } + + private void InitializeComponent() + { + this.button25 = new System.Windows.Forms.Button(); + this.button33 = new System.Windows.Forms.Button(); + this.button66 = new System.Windows.Forms.Button(); + this.button125 = new System.Windows.Forms.Button(); + this.button250 = new System.Windows.Forms.Button(); + this.button333 = new System.Windows.Forms.Button(); + this.button500 = new System.Windows.Forms.Button(); + this.button1000 = new System.Windows.Forms.Button(); + this.button1500 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button25 + // + this.button25.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button25.Location = new System.Drawing.Point(13, 43); + this.button25.Name = "button25"; + this.button25.Size = new System.Drawing.Size(50, 23); + this.button25.TabIndex = 1; + this.button25.Text = "25"; + this.button25.UseVisualStyleBackColor = true; + this.button25.Click += new System.EventHandler(this.button2_Click); + // + // button33 + // + this.button33.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button33.Location = new System.Drawing.Point(69, 42); + this.button33.Name = "button33"; + this.button33.Size = new System.Drawing.Size(50, 23); + this.button33.TabIndex = 2; + this.button33.Text = "33"; + this.button33.UseVisualStyleBackColor = true; + this.button33.Click += new System.EventHandler(this.button3_Click); + // + // button66 + // + this.button66.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button66.Location = new System.Drawing.Point(125, 42); + this.button66.Name = "button66"; + this.button66.Size = new System.Drawing.Size(50, 23); + this.button66.TabIndex = 3; + this.button66.Text = "66"; + this.button66.UseVisualStyleBackColor = true; + this.button66.Click += new System.EventHandler(this.button4_Click); + // + // button125 + // + this.button125.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button125.Location = new System.Drawing.Point(13, 72); + this.button125.Name = "button125"; + this.button125.Size = new System.Drawing.Size(50, 23); + this.button125.TabIndex = 4; + this.button125.Text = "125"; + this.button125.UseVisualStyleBackColor = true; + this.button125.Click += new System.EventHandler(this.button5_Click); + // + // button250 + // + this.button250.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button250.Location = new System.Drawing.Point(69, 71); + this.button250.Name = "button250"; + this.button250.Size = new System.Drawing.Size(50, 23); + this.button250.TabIndex = 5; + this.button250.Text = "250"; + this.button250.UseVisualStyleBackColor = true; + this.button250.Click += new System.EventHandler(this.button6_Click); + // + // button333 + // + this.button333.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button333.Location = new System.Drawing.Point(125, 71); + this.button333.Name = "button333"; + this.button333.Size = new System.Drawing.Size(50, 23); + this.button333.TabIndex = 6; + this.button333.Text = "333"; + this.button333.UseVisualStyleBackColor = true; + this.button333.Click += new System.EventHandler(this.button7_Click); + // + // button500 + // + this.button500.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button500.Location = new System.Drawing.Point(13, 101); + this.button500.Name = "button500"; + this.button500.Size = new System.Drawing.Size(50, 23); + this.button500.TabIndex = 7; + this.button500.Text = "500"; + this.button500.UseVisualStyleBackColor = true; + this.button500.Click += new System.EventHandler(this.button8_Click); + // + // button1000 + // + this.button1000.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1000.Location = new System.Drawing.Point(69, 100); + this.button1000.Name = "button1000"; + this.button1000.Size = new System.Drawing.Size(50, 23); + this.button1000.TabIndex = 8; + this.button1000.Text = "1000"; + this.button1000.UseVisualStyleBackColor = true; + this.button1000.Click += new System.EventHandler(this.button9_Click); + // + // button1500 + // + this.button1500.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1500.Location = new System.Drawing.Point(125, 100); + this.button1500.Name = "button1500"; + this.button1500.Size = new System.Drawing.Size(50, 23); + this.button1500.TabIndex = 9; + this.button1500.Text = "1500"; + this.button1500.UseVisualStyleBackColor = true; + this.button1500.Click += new System.EventHandler(this.button10_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(29, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 20); + this.label1.TabIndex = 10; + this.label1.Text = "Select SR"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(13, 137); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(50, 20); + this.label2.TabIndex = 11; + this.label2.Text = "QRG:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(65, 137); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(0, 20); + this.label3.TabIndex = 12; + // + // SRForm + // + this.ClientSize = new System.Drawing.Size(188, 175); + this.Controls.Add(this.label1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label3); + this.Controls.Add(this.button25); + this.Controls.Add(this.button33); + this.Controls.Add(this.button66); + this.Controls.Add(this.button125); + this.Controls.Add(this.button250); + this.Controls.Add(this.button333); + this.Controls.Add(this.button500); + this.Controls.Add(this.button1000); + this.Controls.Add(this.button1500); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SRForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + public uint getsr() + { + return SR; + } + + private void button1_Click(object sender, EventArgs e) + { + SR = 0; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button3_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button4_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button5_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button6_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button7_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button8_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button9_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button10_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.resx b/ExtraFeatures/BATCSpectrum/SRForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index eba5604..6f7c1d8 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -167,7 +167,7 @@ public Tuple tune(int mode, int time, int rx) //Log.Information(t.Seconds); if ((t.Minutes * 60) + t.Seconds > time) { - //Log.Information("elapsed: "+rx.ToString()); + //Log.Information("elapsed: " + rx.ToString()); next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current diff --git a/opentuner.csproj b/opentuner.csproj index 4effc91..0ca3ee0 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,14 @@ + + Form + + + True + True + SRForm.resx + @@ -464,6 +472,11 @@ externalToolsManager.cs + + SRForm.cs + ResXFileCodeGenerator + SRForm.Designer.cs + WebChatSettngsForm.cs From de31142c7cdb66167c16440e925196662e8893c2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 18:53:03 +0100 Subject: [PATCH 69/98] Symbol rate form and functionality added Symbol Rate Form added. It is used when the right Mouse button is pressed within a tuner field. This will force a new tuning with selected symbol rate. Function is as within QO100 WB Live Tune program. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 85 ++++-- ExtraFeatures/BATCSpectrum/SRForm.Designer.cs | 63 ++++ ExtraFeatures/BATCSpectrum/SRForm.cs | 281 ++++++++++++++++++ ExtraFeatures/BATCSpectrum/SRForm.resx | 120 ++++++++ ExtraFeatures/BATCSpectrum/signal.cs | 2 +- opentuner.csproj | 13 + 6 files changed, 540 insertions(+), 24 deletions(-) create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/SRForm.resx diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 38055ac..0ccafd1 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -73,6 +73,7 @@ public class BATCSpectrum private int mousePos_y = 0; private int fft_data_length = 918; + public bool pluto_control_enabled = false; public void updateSignalCallsign(string callsign, double freq, float sr) { @@ -279,7 +280,7 @@ private void spectrum_SizeChanged(object sender, EventArgs e) } catch (Exception Ex) { - + Log.Error(Ex.Message); } } @@ -363,11 +364,11 @@ private void drawspectrum_signals(List signals) tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height)); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_start * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_start * spectrum_wScale), height); tmp.DrawLine(whitePen, Convert.ToInt16(s.fft_stop * spectrum_wScale), height - Convert.ToInt16(s.fft_strength / height), Convert.ToInt16(s.fft_stop * spectrum_wScale), height); - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency, 2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.000") + "\n " + (s.sr * 1000).ToString("#Ks") + "\n " + s.dbb.ToString("#0.0dBb"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } else { - tmp.DrawString(s.callsign + "\n" + Math.Round(s.frequency,2).ToString("#0.00") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); + tmp.DrawString(s.callsign + "\n" + s.frequency.ToString("#0.000") + "\n " + (s.sr * 1000).ToString("#Ks"), new Font("Tahoma", 10), Brushes.White, new PointF(s.text_pos * spectrum_wScale - 30.0f, height - Convert.ToSingle(s.fft_strength / height + 50))); } } } @@ -383,7 +384,7 @@ private void UpdateDrawing() } catch (Exception Ex) { - + Log.Error(Ex.Message); } } @@ -469,7 +470,7 @@ private void drawspectrum(UInt16[] fft_data) { y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i+1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); } drawspectrum_signals(sigs.signals); @@ -477,7 +478,7 @@ private void drawspectrum(UInt16[] fft_data) private void spectrum_Click(object sender, EventArgs e) { - + int spectrum_h = _spectrum.Height - bandplan_height; float spectrum_w = _spectrum.Width; float spectrum_wScale = spectrum_w / fft_data_length; @@ -487,33 +488,71 @@ private void spectrum_Click(object sender, EventArgs e) int X = pos.X; int Y = pos.Y; - if (me.Button == MouseButtons.Right) + if (Y > spectrum_h) { - int spectrum_h = _spectrum.Height - bandplan_height; - - if (Y > spectrum_h) + if (pluto_control_enabled) { - int freq = Convert.ToInt32(start_freq + X / (double)spectrum_wScale / fft_data_length * 9.0 * 1000.0); - //UpdateTextBox(txtFreq, freq.ToString()); - - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) + switch (me.Button) { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; + case MouseButtons.Left: + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + break; + default: + break; } } } else { - selectSignal(X, Y); - } + switch (me.Button) + { + case MouseButtons.Left: + if (Control.ModifierKeys == Keys.Shift) + { - } + } + else + { + selectSignal(X, Y); + } + break; + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_srForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int srForm_width = srForm.Size.Width; + + if (X > (srForm_width / 2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; + if (X > (spectrum_width - srForm.Size.Width / 2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); + + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; + DialogResult result = srForm.ShowDialog(); + if (result == DialogResult.OK) + { + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); + } + } + break; + default: + break; + } + } + } // quick tune functions - From https://github.com/m0dts/QO-100-WB-Live-Tune - Rob Swinbank diff --git a/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs new file mode 100644 index 0000000..81e4ef3 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace opentuner.ExtraFeatures.BATCSpectrum { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class SRForm { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SRForm() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("opentuner.ExtraFeatures.BATCSpectrum.SRForm", typeof(SRForm).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.cs b/ExtraFeatures/BATCSpectrum/SRForm.cs new file mode 100644 index 0000000..beba1b7 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.cs @@ -0,0 +1,281 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner +{ + internal class SRForm : Form + { + private Button button25; + private Button button33; + private Button button66; + private Button button125; + private Button button250; + private Button button333; + private Button button500; + private Button button1000; + private Button button1500; + private Label label1; + private Label label2; + private Label label3; + uint qrg = 0; + uint SR = 0; + + public SRForm(uint _qrg) + { + qrg = _qrg; + InitializeComponent(); + label3.Text = (qrg / 1000.0f).ToString() + " MHz"; + + } + + private void InitializeComponent() + { + this.button25 = new System.Windows.Forms.Button(); + this.button33 = new System.Windows.Forms.Button(); + this.button66 = new System.Windows.Forms.Button(); + this.button125 = new System.Windows.Forms.Button(); + this.button250 = new System.Windows.Forms.Button(); + this.button333 = new System.Windows.Forms.Button(); + this.button500 = new System.Windows.Forms.Button(); + this.button1000 = new System.Windows.Forms.Button(); + this.button1500 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button25 + // + this.button25.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button25.Location = new System.Drawing.Point(13, 43); + this.button25.Name = "button25"; + this.button25.Size = new System.Drawing.Size(50, 23); + this.button25.TabIndex = 1; + this.button25.Text = "25"; + this.button25.UseVisualStyleBackColor = true; + this.button25.Click += new System.EventHandler(this.button2_Click); + // + // button33 + // + this.button33.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button33.Location = new System.Drawing.Point(69, 42); + this.button33.Name = "button33"; + this.button33.Size = new System.Drawing.Size(50, 23); + this.button33.TabIndex = 2; + this.button33.Text = "33"; + this.button33.UseVisualStyleBackColor = true; + this.button33.Click += new System.EventHandler(this.button3_Click); + // + // button66 + // + this.button66.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button66.Location = new System.Drawing.Point(125, 42); + this.button66.Name = "button66"; + this.button66.Size = new System.Drawing.Size(50, 23); + this.button66.TabIndex = 3; + this.button66.Text = "66"; + this.button66.UseVisualStyleBackColor = true; + this.button66.Click += new System.EventHandler(this.button4_Click); + // + // button125 + // + this.button125.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button125.Location = new System.Drawing.Point(13, 72); + this.button125.Name = "button125"; + this.button125.Size = new System.Drawing.Size(50, 23); + this.button125.TabIndex = 4; + this.button125.Text = "125"; + this.button125.UseVisualStyleBackColor = true; + this.button125.Click += new System.EventHandler(this.button5_Click); + // + // button250 + // + this.button250.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button250.Location = new System.Drawing.Point(69, 71); + this.button250.Name = "button250"; + this.button250.Size = new System.Drawing.Size(50, 23); + this.button250.TabIndex = 5; + this.button250.Text = "250"; + this.button250.UseVisualStyleBackColor = true; + this.button250.Click += new System.EventHandler(this.button6_Click); + // + // button333 + // + this.button333.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button333.Location = new System.Drawing.Point(125, 71); + this.button333.Name = "button333"; + this.button333.Size = new System.Drawing.Size(50, 23); + this.button333.TabIndex = 6; + this.button333.Text = "333"; + this.button333.UseVisualStyleBackColor = true; + this.button333.Click += new System.EventHandler(this.button7_Click); + // + // button500 + // + this.button500.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button500.Location = new System.Drawing.Point(13, 101); + this.button500.Name = "button500"; + this.button500.Size = new System.Drawing.Size(50, 23); + this.button500.TabIndex = 7; + this.button500.Text = "500"; + this.button500.UseVisualStyleBackColor = true; + this.button500.Click += new System.EventHandler(this.button8_Click); + // + // button1000 + // + this.button1000.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1000.Location = new System.Drawing.Point(69, 100); + this.button1000.Name = "button1000"; + this.button1000.Size = new System.Drawing.Size(50, 23); + this.button1000.TabIndex = 8; + this.button1000.Text = "1000"; + this.button1000.UseVisualStyleBackColor = true; + this.button1000.Click += new System.EventHandler(this.button9_Click); + // + // button1500 + // + this.button1500.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1500.Location = new System.Drawing.Point(125, 100); + this.button1500.Name = "button1500"; + this.button1500.Size = new System.Drawing.Size(50, 23); + this.button1500.TabIndex = 9; + this.button1500.Text = "1500"; + this.button1500.UseVisualStyleBackColor = true; + this.button1500.Click += new System.EventHandler(this.button10_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(29, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 20); + this.label1.TabIndex = 10; + this.label1.Text = "Select SR"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(13, 137); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(50, 20); + this.label2.TabIndex = 11; + this.label2.Text = "QRG:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(65, 137); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(0, 20); + this.label3.TabIndex = 12; + // + // SRForm + // + this.ClientSize = new System.Drawing.Size(188, 175); + this.Controls.Add(this.label1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label3); + this.Controls.Add(this.button25); + this.Controls.Add(this.button33); + this.Controls.Add(this.button66); + this.Controls.Add(this.button125); + this.Controls.Add(this.button250); + this.Controls.Add(this.button333); + this.Controls.Add(this.button500); + this.Controls.Add(this.button1000); + this.Controls.Add(this.button1500); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SRForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + public uint getsr() + { + return SR; + } + + private void button1_Click(object sender, EventArgs e) + { + SR = 0; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button3_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button4_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button5_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button6_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button7_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button8_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button9_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button10_Click(object sender, EventArgs e) + { + SR = Convert.ToUInt16((sender as Button).Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/SRForm.resx b/ExtraFeatures/BATCSpectrum/SRForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/SRForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index eba5604..6f7c1d8 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -167,7 +167,7 @@ public Tuple tune(int mode, int time, int rx) //Log.Information(t.Seconds); if ((t.Minutes * 60) + t.Seconds > time) { - //Log.Information("elapsed: "+rx.ToString()); + //Log.Information("elapsed: " + rx.ToString()); next_sig[rx] = find_next(rx); if (diff_signals(last_sig[rx], next_sig[rx]) && next_sig[rx].frequency > 0) //check if next is not the same as current diff --git a/opentuner.csproj b/opentuner.csproj index 4effc91..0ca3ee0 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,14 @@ + + Form + + + True + True + SRForm.resx + @@ -464,6 +472,11 @@ externalToolsManager.cs + + SRForm.cs + ResXFileCodeGenerator + SRForm.Designer.cs + WebChatSettngsForm.cs From a61f2a2d5dbd703b2f48f2a01a2197e5f9058e8e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 21:10:56 +0100 Subject: [PATCH 70/98] selectable overpower indication + preparation for auto tune functions New BATC Spectrum settings forms added. One option allow to select the layout of the over power indication. The other options are disabled till auto tune function is working. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 87 ++++- .../BATCSpectrum/TuneModeSettings.cs | 15 + .../TuneModeSettingsForm.Designer.cs | 308 ++++++++++++++++++ .../BATCSpectrum/TuneModeSettingsForm.cs | 59 ++++ .../BATCSpectrum/TuneModeSettingsForm.resx | 120 +++++++ .../oneTunerTuneModeForm.Designer.cs | 125 +++++++ .../BATCSpectrum/oneTunerTuneModeForm.cs | 54 +++ .../BATCSpectrum/oneTunerTuneModeForm.resx | 120 +++++++ MainForm.Designer.cs | 1 + MainForm.cs | 15 + MainForm.resx | 3 - opentuner.csproj | 19 ++ 12 files changed, 919 insertions(+), 7 deletions(-) create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettings.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0ccafd1..7527133 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -12,11 +12,15 @@ using System.IO; using System.Drawing.Drawing2D; using Serilog; +using opentuner.Utilities; namespace opentuner.ExtraFeatures.BATCSpectrum { public class BATCSpectrum { + private tuneModeSettings _tuneModeSettings; + private SettingsManager _settingsManager; + public delegate void SignalSelected(int Receiver, uint Freq, uint SymbolRate); public event SignalSelected OnSignalSelected; @@ -24,7 +28,7 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); private const int height = 246; //makes things easier - static readonly int bandplan_height = 30; + private static readonly int bandplan_height = 30; private const double start_freq = 10490.4754901; Bitmap bmp; @@ -82,6 +86,11 @@ public void updateSignalCallsign(string callsign, double freq, float sr) public BATCSpectrum(PictureBox Spectrum, int Tuners) { + _tuneModeSettings = new tuneModeSettings(); + _settingsManager = new SettingsManager("tunemode_settings"); + + _tuneModeSettings = _settingsManager.LoadSettings(_tuneModeSettings); + _spectrum = Spectrum; _tuners = Tuners; @@ -443,7 +452,7 @@ private void drawspectrum(UInt16[] fft_data) //draw block showing signal selected if (rx_blocks[tuner, 0] > 0) { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale)/2) , y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } } @@ -460,17 +469,62 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + switch (_tuneModeSettings.overPowerIndicatorLayout) + { + case 0: // classic + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 1: // classic + line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 2: // box from top to line + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - Convert.ToInt16(sig.max_strength / height)) }); + break; + case 3: // box from line to bottom + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 4: // line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + break; + default: // no indication + break; + } } } } for (i = 0; i < _tuners; i++) { + if (_tuneModeSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0) + { + Tuple ret = sigs.tune(_tuneModeSettings.tuneMode[i], 30, i); + if (ret.Item1.frequency > 0) //above 0 is a change in signal + { + System.Threading.Thread.Sleep(100); + selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), y); + sigs.set_tuned(ret.Item1, i); + rx_blocks[i, 0] = Convert.ToInt16(ret.Item1.fft_centre); + rx_blocks[i, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + } + } + y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + switch (_tuneModeSettings.tuneMode[i]) + { + case 0: + tmp.DrawString("Manual", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + case 1: + tmp.DrawString("Auto", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + default: + break; + } } drawspectrum_signals(sigs.signals); @@ -517,6 +571,31 @@ private void spectrum_Click(object sender, EventArgs e) case MouseButtons.Left: if (Control.ModifierKeys == Keys.Shift) { + int tuner = determine_rx(Y); + using (oneTunerTuneModeForm oTTMForm = new oneTunerTuneModeForm( + tuner + 1, + _tuneModeSettings.tuneMode[tuner], + _tuneModeSettings.avoidBeacon[tuner])) //open up the single tune mode select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_oTTMForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int oTTMForm_width = oTTMForm.Size.Width; + + if (X > (oTTMForm_width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + X - oTTMForm.Size.Width / 2; + if (X > (spectrum_width - oTTMForm.Size.Width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + (spectrum_width - oTTMForm.Size.Width); + + oTTMForm.StartPosition = FormStartPosition.Manual; + oTTMForm.Location = new_oTTMForm_location; + DialogResult result = oTTMForm.ShowDialog(); + if (result == DialogResult.OK) + { + _tuneModeSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); + _tuneModeSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); + } + } } else diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs new file mode 100644 index 0000000..d289c2f --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public class tuneModeSettings + { + public int[] tuneMode = { 0, 0, 0, 0 }; + public bool[] avoidBeacon = { false, false, false, false }; + public int overPowerIndicatorLayout = 0; + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs new file mode 100644 index 0000000..61708a3 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs @@ -0,0 +1,308 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class tuneModeSettingsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon4 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon3 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon2 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode4 = new System.Windows.Forms.ComboBox(); + this.tuneMode3 = new System.Windows.Forms.ComboBox(); + this.tuneMode2 = new System.Windows.Forms.ComboBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.overPowerIndicatorLayout = new System.Windows.Forms.ComboBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon4); + this.groupBox1.Controls.Add(this.avoidBeacon3); + this.groupBox1.Controls.Add(this.avoidBeacon2); + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode4); + this.groupBox1.Controls.Add(this.tuneMode3); + this.groupBox1.Controls.Add(this.tuneMode2); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 15); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 151); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon4 + // + this.avoidBeacon4.AutoSize = true; + this.avoidBeacon4.Checked = true; + this.avoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon4.Enabled = false; + this.avoidBeacon4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon4.Location = new System.Drawing.Point(177, 121); + this.avoidBeacon4.Name = "avoidBeacon4"; + this.avoidBeacon4.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon4.TabIndex = 11; + this.avoidBeacon4.Text = "Avoid Beacon"; + this.avoidBeacon4.UseVisualStyleBackColor = true; + // + // avoidBeacon3 + // + this.avoidBeacon3.AutoSize = true; + this.avoidBeacon3.Checked = true; + this.avoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon3.Enabled = false; + this.avoidBeacon3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon3.Location = new System.Drawing.Point(177, 91); + this.avoidBeacon3.Name = "avoidBeacon3"; + this.avoidBeacon3.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon3.TabIndex = 10; + this.avoidBeacon3.Text = "Avoid Beacon"; + this.avoidBeacon3.UseVisualStyleBackColor = true; + // + // avoidBeacon2 + // + this.avoidBeacon2.AutoSize = true; + this.avoidBeacon2.Checked = true; + this.avoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon2.Enabled = false; + this.avoidBeacon2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon2.Location = new System.Drawing.Point(177, 61); + this.avoidBeacon2.Name = "avoidBeacon2"; + this.avoidBeacon2.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon2.TabIndex = 9; + this.avoidBeacon2.Text = "Avoid Beacon"; + this.avoidBeacon2.UseVisualStyleBackColor = true; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Enabled = false; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 31); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode4 + // + this.tuneMode4.Enabled = false; + this.tuneMode4.FormattingEnabled = true; + this.tuneMode4.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode4.Location = new System.Drawing.Point(50, 120); + this.tuneMode4.Name = "tuneMode4"; + this.tuneMode4.Size = new System.Drawing.Size(121, 21); + this.tuneMode4.TabIndex = 7; + // + // tuneMode3 + // + this.tuneMode3.Enabled = false; + this.tuneMode3.FormattingEnabled = true; + this.tuneMode3.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode3.Location = new System.Drawing.Point(50, 90); + this.tuneMode3.Name = "tuneMode3"; + this.tuneMode3.Size = new System.Drawing.Size(121, 21); + this.tuneMode3.TabIndex = 6; + // + // tuneMode2 + // + this.tuneMode2.Enabled = false; + this.tuneMode2.FormattingEnabled = true; + this.tuneMode2.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode2.Location = new System.Drawing.Point(50, 60); + this.tuneMode2.Name = "tuneMode2"; + this.tuneMode2.Size = new System.Drawing.Size(121, 21); + this.tuneMode2.TabIndex = 5; + // + // tuneMode1 + // + this.tuneMode1.Enabled = false; + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 30); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label4.Location = new System.Drawing.Point(6, 123); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(38, 16); + this.label4.TabIndex = 3; + this.label4.Text = "RX 4:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label3.Location = new System.Drawing.Point(6, 93); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 16); + this.label3.TabIndex = 2; + this.label3.Text = "RX 3:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label2.Location = new System.Drawing.Point(6, 63); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 16); + this.label2.TabIndex = 1; + this.label2.Text = "RX 2:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 33); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(111, 239); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 28); + this.btnCancel.TabIndex = 3; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 239); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 2; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.overPowerIndicatorLayout); + this.groupBox2.Location = new System.Drawing.Point(15, 172); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(304, 60); + this.groupBox2.TabIndex = 5; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Overpower Indicator Layout"; + // + // overPowerIndicatorLayout + // + this.overPowerIndicatorLayout.FormattingEnabled = true; + this.overPowerIndicatorLayout.Items.AddRange(new object[] { + "classic", + "classic + line", + "box from top to line", + "box from line to bottom", + "line", + "off"}); + this.overPowerIndicatorLayout.Location = new System.Drawing.Point(9, 28); + this.overPowerIndicatorLayout.Name = "overPowerIndicatorLayout"; + this.overPowerIndicatorLayout.Size = new System.Drawing.Size(162, 21); + this.overPowerIndicatorLayout.TabIndex = 0; + // + // tuneModeSettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(335, 275); + this.ControlBox = false; + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSave); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "tuneModeSettingsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "tuneModeSettings"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.ComboBox tuneMode2; + private System.Windows.Forms.ComboBox tuneMode3; + private System.Windows.Forms.ComboBox tuneMode4; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.CheckBox avoidBeacon2; + private System.Windows.Forms.CheckBox avoidBeacon3; + private System.Windows.Forms.CheckBox avoidBeacon4; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.ComboBox overPowerIndicatorLayout; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs new file mode 100644 index 0000000..c43a359 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class tuneModeSettingsForm : Form + { + private tuneModeSettings tuneModeSettings; + + public tuneModeSettingsForm(ref tuneModeSettings _tuneModeSettings) + { + tuneModeSettings = _tuneModeSettings; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneModeSettings.tuneMode[0]; + tuneMode2.SelectedIndex = tuneModeSettings.tuneMode[1]; + tuneMode3.SelectedIndex = tuneModeSettings.tuneMode[2]; + tuneMode4.SelectedIndex = tuneModeSettings.tuneMode[3]; + + avoidBeacon1.Checked = tuneModeSettings.avoidBeacon[0]; + avoidBeacon2.Checked = tuneModeSettings.avoidBeacon[1]; + avoidBeacon3.Checked = tuneModeSettings.avoidBeacon[2]; + avoidBeacon4.Checked = tuneModeSettings.avoidBeacon[3]; + + overPowerIndicatorLayout.SelectedIndex = tuneModeSettings.overPowerIndicatorLayout; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneModeSettings.tuneMode[0] = tuneMode1.SelectedIndex; + tuneModeSettings.tuneMode[1] = tuneMode2.SelectedIndex; + tuneModeSettings.tuneMode[2] = tuneMode3.SelectedIndex; + tuneModeSettings.tuneMode[3] = tuneMode4.SelectedIndex; + + tuneModeSettings.avoidBeacon[0] = avoidBeacon1.Checked; + tuneModeSettings.avoidBeacon[1] = avoidBeacon2.Checked; + tuneModeSettings.avoidBeacon[2] = avoidBeacon3.Checked; + tuneModeSettings.avoidBeacon[3] = avoidBeacon4.Checked; + + tuneModeSettings.overPowerIndicatorLayout = overPowerIndicatorLayout.SelectedIndex; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs new file mode 100644 index 0000000..6373adc --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs @@ -0,0 +1,125 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class oneTunerTuneModeForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 54); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Enabled = false; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 21); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode1 + // + this.tuneMode1.Enabled = false; + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 20); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 61); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 7; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // oneTunerTuneModeForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(331, 99); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.groupBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "oneTunerTuneModeForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs new file mode 100644 index 0000000..8c5d859 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class oneTunerTuneModeForm : Form + { + private int tuneMode = 1; + private bool avoidBeacon = true; + + public oneTunerTuneModeForm(int _tuner, int _tuneMode, bool _avoidBeacon) + { + tuneMode = _tuneMode; + avoidBeacon = _avoidBeacon; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneMode; + avoidBeacon1.Checked = avoidBeacon; + label1.Text = "RX " + _tuner.ToString() + ":"; + } + + public int getTuneMode() + { + return tuneMode; + } + + public bool getAvoidBeacon() + { + return avoidBeacon; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneMode = tuneMode1.SelectedIndex; + avoidBeacon = avoidBeacon1.Checked; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index a9f36e3..aaaab16 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -319,6 +319,7 @@ private void InitializeComponent() this.linkBatcSpectrumSettings.Cursor = System.Windows.Forms.Cursors.Hand; this.linkBatcSpectrumSettings.ForeColor = System.Drawing.Color.RoyalBlue; this.linkBatcSpectrumSettings.Name = "linkBatcSpectrumSettings"; + this.linkBatcSpectrumSettings.Click += new System.EventHandler(this.linkBatcSpectrumSettings_Click); // // linkMqttSettings // diff --git a/MainForm.cs b/MainForm.cs index d642bc2..70a617c 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -979,6 +979,21 @@ private void checkBatcSpectrum_CheckedChanged(object sender, EventArgs e) _settings.enable_spectrum_checkbox = checkBatcSpectrum.Checked; } + private void linkBatcSpectrumSettings_Click(object sender, EventArgs e) + { + // BATC tune settings + tuneModeSettings batc_settings = new tuneModeSettings(); + SettingsManager batc_settingsManager = new SettingsManager("tunemode_settings"); + batc_settings = batc_settingsManager.LoadSettings(batc_settings); + + tuneModeSettingsForm batc_settings_form = new tuneModeSettingsForm(ref batc_settings); + + if (batc_settings_form.ShowDialog() == DialogResult.OK) + { + batc_settingsManager.SaveSettings(batc_settings); + } + } + private void checkBatcChat_CheckedChanged(object sender, EventArgs e) { _settings.enable_chatform_checkbox = checkBatcChat.Checked; diff --git a/MainForm.resx b/MainForm.resx index 414c9e2..be016b4 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -696,9 +696,6 @@ Settings ... - - False - linkBatcSpectrumSettings diff --git a/opentuner.csproj b/opentuner.csproj index 0ca3ee0..c43b2b5 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,12 @@ + + Form + + + oneTunerTuneModeForm.cs + Form @@ -241,6 +247,13 @@ True SRForm.resx + + + Form + + + TuneModeSettingsForm.cs + @@ -472,11 +485,17 @@ externalToolsManager.cs + + oneTunerTuneModeForm.cs + SRForm.cs ResXFileCodeGenerator SRForm.Designer.cs + + TuneModeSettingsForm.cs + WebChatSettngsForm.cs From 7ece39e261bf29118c057a5271b5a35fe00dfc55 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 21:10:56 +0100 Subject: [PATCH 71/98] selectable overpower indication + preparation for auto tune functions New BATC Spectrum settings forms added. One option allow to select the layout of the over power indication. The other options are disabled till auto tune function is working. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 87 ++++- .../BATCSpectrum/TuneModeSettings.cs | 15 + .../TuneModeSettingsForm.Designer.cs | 308 ++++++++++++++++++ .../BATCSpectrum/TuneModeSettingsForm.cs | 59 ++++ .../BATCSpectrum/TuneModeSettingsForm.resx | 120 +++++++ .../oneTunerTuneModeForm.Designer.cs | 125 +++++++ .../BATCSpectrum/oneTunerTuneModeForm.cs | 54 +++ .../BATCSpectrum/oneTunerTuneModeForm.resx | 120 +++++++ MainForm.Designer.cs | 1 + MainForm.cs | 15 + MainForm.resx | 3 - opentuner.csproj | 19 ++ 12 files changed, 919 insertions(+), 7 deletions(-) create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettings.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs create mode 100644 ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0ccafd1..7527133 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -12,11 +12,15 @@ using System.IO; using System.Drawing.Drawing2D; using Serilog; +using opentuner.Utilities; namespace opentuner.ExtraFeatures.BATCSpectrum { public class BATCSpectrum { + private tuneModeSettings _tuneModeSettings; + private SettingsManager _settingsManager; + public delegate void SignalSelected(int Receiver, uint Freq, uint SymbolRate); public event SignalSelected OnSignalSelected; @@ -24,7 +28,7 @@ public class BATCSpectrum private static readonly Object list_lock = new Object(); private const int height = 246; //makes things easier - static readonly int bandplan_height = 30; + private static readonly int bandplan_height = 30; private const double start_freq = 10490.4754901; Bitmap bmp; @@ -82,6 +86,11 @@ public void updateSignalCallsign(string callsign, double freq, float sr) public BATCSpectrum(PictureBox Spectrum, int Tuners) { + _tuneModeSettings = new tuneModeSettings(); + _settingsManager = new SettingsManager("tunemode_settings"); + + _tuneModeSettings = _settingsManager.LoadSettings(_tuneModeSettings); + _spectrum = Spectrum; _tuners = Tuners; @@ -443,7 +452,7 @@ private void drawspectrum(UInt16[] fft_data) //draw block showing signal selected if (rx_blocks[tuner, 0] > 0) { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale)/2) , y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } } @@ -460,17 +469,62 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + switch (_tuneModeSettings.overPowerIndicatorLayout) + { + case 0: // classic + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 1: // classic + line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 2: // box from top to line + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - Convert.ToInt16(sig.max_strength / height)) }); + break; + case 3: // box from line to bottom + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + break; + case 4: // line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + break; + default: // no indication + break; + } } } } for (i = 0; i < _tuners; i++) { + if (_tuneModeSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0) + { + Tuple ret = sigs.tune(_tuneModeSettings.tuneMode[i], 30, i); + if (ret.Item1.frequency > 0) //above 0 is a change in signal + { + System.Threading.Thread.Sleep(100); + selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), y); + sigs.set_tuned(ret.Item1, i); + rx_blocks[i, 0] = Convert.ToInt16(ret.Item1.fft_centre); + rx_blocks[i, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + } + } + y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + switch (_tuneModeSettings.tuneMode[i]) + { + case 0: + tmp.DrawString("Manual", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + case 1: + tmp.DrawString("Auto", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + default: + break; + } } drawspectrum_signals(sigs.signals); @@ -517,6 +571,31 @@ private void spectrum_Click(object sender, EventArgs e) case MouseButtons.Left: if (Control.ModifierKeys == Keys.Shift) { + int tuner = determine_rx(Y); + using (oneTunerTuneModeForm oTTMForm = new oneTunerTuneModeForm( + tuner + 1, + _tuneModeSettings.tuneMode[tuner], + _tuneModeSettings.avoidBeacon[tuner])) //open up the single tune mode select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_oTTMForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int oTTMForm_width = oTTMForm.Size.Width; + + if (X > (oTTMForm_width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + X - oTTMForm.Size.Width / 2; + if (X > (spectrum_width - oTTMForm.Size.Width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + (spectrum_width - oTTMForm.Size.Width); + + oTTMForm.StartPosition = FormStartPosition.Manual; + oTTMForm.Location = new_oTTMForm_location; + DialogResult result = oTTMForm.ShowDialog(); + if (result == DialogResult.OK) + { + _tuneModeSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); + _tuneModeSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); + } + } } else diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs new file mode 100644 index 0000000..d289c2f --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public class tuneModeSettings + { + public int[] tuneMode = { 0, 0, 0, 0 }; + public bool[] avoidBeacon = { false, false, false, false }; + public int overPowerIndicatorLayout = 0; + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs new file mode 100644 index 0000000..61708a3 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs @@ -0,0 +1,308 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class tuneModeSettingsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon4 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon3 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon2 = new System.Windows.Forms.CheckBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode4 = new System.Windows.Forms.ComboBox(); + this.tuneMode3 = new System.Windows.Forms.ComboBox(); + this.tuneMode2 = new System.Windows.Forms.ComboBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.overPowerIndicatorLayout = new System.Windows.Forms.ComboBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon4); + this.groupBox1.Controls.Add(this.avoidBeacon3); + this.groupBox1.Controls.Add(this.avoidBeacon2); + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode4); + this.groupBox1.Controls.Add(this.tuneMode3); + this.groupBox1.Controls.Add(this.tuneMode2); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 15); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 151); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon4 + // + this.avoidBeacon4.AutoSize = true; + this.avoidBeacon4.Checked = true; + this.avoidBeacon4.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon4.Enabled = false; + this.avoidBeacon4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon4.Location = new System.Drawing.Point(177, 121); + this.avoidBeacon4.Name = "avoidBeacon4"; + this.avoidBeacon4.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon4.TabIndex = 11; + this.avoidBeacon4.Text = "Avoid Beacon"; + this.avoidBeacon4.UseVisualStyleBackColor = true; + // + // avoidBeacon3 + // + this.avoidBeacon3.AutoSize = true; + this.avoidBeacon3.Checked = true; + this.avoidBeacon3.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon3.Enabled = false; + this.avoidBeacon3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon3.Location = new System.Drawing.Point(177, 91); + this.avoidBeacon3.Name = "avoidBeacon3"; + this.avoidBeacon3.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon3.TabIndex = 10; + this.avoidBeacon3.Text = "Avoid Beacon"; + this.avoidBeacon3.UseVisualStyleBackColor = true; + // + // avoidBeacon2 + // + this.avoidBeacon2.AutoSize = true; + this.avoidBeacon2.Checked = true; + this.avoidBeacon2.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon2.Enabled = false; + this.avoidBeacon2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon2.Location = new System.Drawing.Point(177, 61); + this.avoidBeacon2.Name = "avoidBeacon2"; + this.avoidBeacon2.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon2.TabIndex = 9; + this.avoidBeacon2.Text = "Avoid Beacon"; + this.avoidBeacon2.UseVisualStyleBackColor = true; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Enabled = false; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 31); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode4 + // + this.tuneMode4.Enabled = false; + this.tuneMode4.FormattingEnabled = true; + this.tuneMode4.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode4.Location = new System.Drawing.Point(50, 120); + this.tuneMode4.Name = "tuneMode4"; + this.tuneMode4.Size = new System.Drawing.Size(121, 21); + this.tuneMode4.TabIndex = 7; + // + // tuneMode3 + // + this.tuneMode3.Enabled = false; + this.tuneMode3.FormattingEnabled = true; + this.tuneMode3.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode3.Location = new System.Drawing.Point(50, 90); + this.tuneMode3.Name = "tuneMode3"; + this.tuneMode3.Size = new System.Drawing.Size(121, 21); + this.tuneMode3.TabIndex = 6; + // + // tuneMode2 + // + this.tuneMode2.Enabled = false; + this.tuneMode2.FormattingEnabled = true; + this.tuneMode2.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode2.Location = new System.Drawing.Point(50, 60); + this.tuneMode2.Name = "tuneMode2"; + this.tuneMode2.Size = new System.Drawing.Size(121, 21); + this.tuneMode2.TabIndex = 5; + // + // tuneMode1 + // + this.tuneMode1.Enabled = false; + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 30); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label4.Location = new System.Drawing.Point(6, 123); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(38, 16); + this.label4.TabIndex = 3; + this.label4.Text = "RX 4:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label3.Location = new System.Drawing.Point(6, 93); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 16); + this.label3.TabIndex = 2; + this.label3.Text = "RX 3:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label2.Location = new System.Drawing.Point(6, 63); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 16); + this.label2.TabIndex = 1; + this.label2.Text = "RX 2:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 33); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(111, 239); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 28); + this.btnCancel.TabIndex = 3; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 239); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 2; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.overPowerIndicatorLayout); + this.groupBox2.Location = new System.Drawing.Point(15, 172); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(304, 60); + this.groupBox2.TabIndex = 5; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Overpower Indicator Layout"; + // + // overPowerIndicatorLayout + // + this.overPowerIndicatorLayout.FormattingEnabled = true; + this.overPowerIndicatorLayout.Items.AddRange(new object[] { + "classic", + "classic + line", + "box from top to line", + "box from line to bottom", + "line", + "off"}); + this.overPowerIndicatorLayout.Location = new System.Drawing.Point(9, 28); + this.overPowerIndicatorLayout.Name = "overPowerIndicatorLayout"; + this.overPowerIndicatorLayout.Size = new System.Drawing.Size(162, 21); + this.overPowerIndicatorLayout.TabIndex = 0; + // + // tuneModeSettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(335, 275); + this.ControlBox = false; + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSave); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "tuneModeSettingsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "tuneModeSettings"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.ComboBox tuneMode2; + private System.Windows.Forms.ComboBox tuneMode3; + private System.Windows.Forms.ComboBox tuneMode4; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.CheckBox avoidBeacon2; + private System.Windows.Forms.CheckBox avoidBeacon3; + private System.Windows.Forms.CheckBox avoidBeacon4; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.ComboBox overPowerIndicatorLayout; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs new file mode 100644 index 0000000..c43a359 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class tuneModeSettingsForm : Form + { + private tuneModeSettings tuneModeSettings; + + public tuneModeSettingsForm(ref tuneModeSettings _tuneModeSettings) + { + tuneModeSettings = _tuneModeSettings; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneModeSettings.tuneMode[0]; + tuneMode2.SelectedIndex = tuneModeSettings.tuneMode[1]; + tuneMode3.SelectedIndex = tuneModeSettings.tuneMode[2]; + tuneMode4.SelectedIndex = tuneModeSettings.tuneMode[3]; + + avoidBeacon1.Checked = tuneModeSettings.avoidBeacon[0]; + avoidBeacon2.Checked = tuneModeSettings.avoidBeacon[1]; + avoidBeacon3.Checked = tuneModeSettings.avoidBeacon[2]; + avoidBeacon4.Checked = tuneModeSettings.avoidBeacon[3]; + + overPowerIndicatorLayout.SelectedIndex = tuneModeSettings.overPowerIndicatorLayout; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneModeSettings.tuneMode[0] = tuneMode1.SelectedIndex; + tuneModeSettings.tuneMode[1] = tuneMode2.SelectedIndex; + tuneModeSettings.tuneMode[2] = tuneMode3.SelectedIndex; + tuneModeSettings.tuneMode[3] = tuneMode4.SelectedIndex; + + tuneModeSettings.avoidBeacon[0] = avoidBeacon1.Checked; + tuneModeSettings.avoidBeacon[1] = avoidBeacon2.Checked; + tuneModeSettings.avoidBeacon[2] = avoidBeacon3.Checked; + tuneModeSettings.avoidBeacon[3] = avoidBeacon4.Checked; + + tuneModeSettings.overPowerIndicatorLayout = overPowerIndicatorLayout.SelectedIndex; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs new file mode 100644 index 0000000..6373adc --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.Designer.cs @@ -0,0 +1,125 @@ +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + partial class oneTunerTuneModeForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.avoidBeacon1 = new System.Windows.Forms.CheckBox(); + this.tuneMode1 = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnSave = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.avoidBeacon1); + this.groupBox1.Controls.Add(this.tuneMode1); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(15, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(304, 54); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Tuning Mode"; + // + // avoidBeacon1 + // + this.avoidBeacon1.AutoSize = true; + this.avoidBeacon1.Checked = true; + this.avoidBeacon1.CheckState = System.Windows.Forms.CheckState.Checked; + this.avoidBeacon1.Enabled = false; + this.avoidBeacon1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.avoidBeacon1.Location = new System.Drawing.Point(177, 21); + this.avoidBeacon1.Name = "avoidBeacon1"; + this.avoidBeacon1.Size = new System.Drawing.Size(111, 20); + this.avoidBeacon1.TabIndex = 8; + this.avoidBeacon1.Text = "Avoid Beacon"; + this.avoidBeacon1.UseVisualStyleBackColor = true; + // + // tuneMode1 + // + this.tuneMode1.Enabled = false; + this.tuneMode1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.tuneMode1.FormattingEnabled = true; + this.tuneMode1.Items.AddRange(new object[] { + "Manual", + "Auto"}); + this.tuneMode1.Location = new System.Drawing.Point(50, 20); + this.tuneMode1.Name = "tuneMode1"; + this.tuneMode1.Size = new System.Drawing.Size(121, 21); + this.tuneMode1.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.label1.Location = new System.Drawing.Point(6, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 16); + this.label1.TabIndex = 0; + this.label1.Text = "RX 1:"; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(219, 61); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(100, 28); + this.btnSave.TabIndex = 7; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // oneTunerTuneModeForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(331, 99); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.groupBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "oneTunerTuneModeForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox tuneMode1; + private System.Windows.Forms.CheckBox avoidBeacon1; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs new file mode 100644 index 0000000..8c5d859 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class oneTunerTuneModeForm : Form + { + private int tuneMode = 1; + private bool avoidBeacon = true; + + public oneTunerTuneModeForm(int _tuner, int _tuneMode, bool _avoidBeacon) + { + tuneMode = _tuneMode; + avoidBeacon = _avoidBeacon; + InitializeComponent(); + + tuneMode1.SelectedIndex = tuneMode; + avoidBeacon1.Checked = avoidBeacon; + label1.Text = "RX " + _tuner.ToString() + ":"; + } + + public int getTuneMode() + { + return tuneMode; + } + + public bool getAvoidBeacon() + { + return avoidBeacon; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + tuneMode = tuneMode1.SelectedIndex; + avoidBeacon = avoidBeacon1.Checked; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/oneTunerTuneModeForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index a9f36e3..aaaab16 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -319,6 +319,7 @@ private void InitializeComponent() this.linkBatcSpectrumSettings.Cursor = System.Windows.Forms.Cursors.Hand; this.linkBatcSpectrumSettings.ForeColor = System.Drawing.Color.RoyalBlue; this.linkBatcSpectrumSettings.Name = "linkBatcSpectrumSettings"; + this.linkBatcSpectrumSettings.Click += new System.EventHandler(this.linkBatcSpectrumSettings_Click); // // linkMqttSettings // diff --git a/MainForm.cs b/MainForm.cs index 15bba1e..76718c3 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -979,6 +979,21 @@ private void checkBatcSpectrum_CheckedChanged(object sender, EventArgs e) _settings.enable_spectrum_checkbox = checkBatcSpectrum.Checked; } + private void linkBatcSpectrumSettings_Click(object sender, EventArgs e) + { + // BATC tune settings + tuneModeSettings batc_settings = new tuneModeSettings(); + SettingsManager batc_settingsManager = new SettingsManager("tunemode_settings"); + batc_settings = batc_settingsManager.LoadSettings(batc_settings); + + tuneModeSettingsForm batc_settings_form = new tuneModeSettingsForm(ref batc_settings); + + if (batc_settings_form.ShowDialog() == DialogResult.OK) + { + batc_settingsManager.SaveSettings(batc_settings); + } + } + private void checkBatcChat_CheckedChanged(object sender, EventArgs e) { _settings.enable_chatform_checkbox = checkBatcChat.Checked; diff --git a/MainForm.resx b/MainForm.resx index 414c9e2..be016b4 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -696,9 +696,6 @@ Settings ... - - False - linkBatcSpectrumSettings diff --git a/opentuner.csproj b/opentuner.csproj index 0ca3ee0..c43b2b5 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -233,6 +233,12 @@ + + Form + + + oneTunerTuneModeForm.cs + Form @@ -241,6 +247,13 @@ True SRForm.resx + + + Form + + + TuneModeSettingsForm.cs + @@ -472,11 +485,17 @@ externalToolsManager.cs + + oneTunerTuneModeForm.cs + SRForm.cs ResXFileCodeGenerator SRForm.Designer.cs + + TuneModeSettingsForm.cs + WebChatSettngsForm.cs From c2ab5d92c6a208e987f55b229f712deba0376de5 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 9 Nov 2024 21:37:10 +0100 Subject: [PATCH 72/98] restore original versions --- MainForm.cs | 2 +- Resources/BuildDate.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 70a617c..76718c3 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -320,7 +320,7 @@ public MainForm(string[] args) frequenciesManager = new SettingsManager>("frequency_presets"); stored_frequencies = frequenciesManager.LoadSettings(stored_frequencies); - Text = "Open Tuner (ZR6TG) - Version " + GlobalDefines.Version + " (modified by DL1RF) - Build: " + opentuner.Properties.Resources.BuildDate; + Text = "Open Tuner (ZR6TG) - Version " + GlobalDefines.Version + " - Build: " + opentuner.Properties.Resources.BuildDate; } /// diff --git a/Resources/BuildDate.txt b/Resources/BuildDate.txt index 5319b57..1b1c30a 100644 --- a/Resources/BuildDate.txt +++ b/Resources/BuildDate.txt @@ -1 +1 @@ -05.11.2024 11:43:33,65 +2024/07/14 13:06:17.88 From 46e405d0568a290304a93570fe3febf3691d74b8 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 09:23:32 +0100 Subject: [PATCH 73/98] Update BATCSpectrum.cs use float in rx_blocks for higher accuracy. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 7527133..bfeabe3 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -47,7 +47,7 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; - int[,] rx_blocks = new int[4, 3]; + float[,] rx_blocks = new float[4, 3]; XElement bandplan; Rectangle[] channels; @@ -252,10 +252,10 @@ private void SpectrumTuneTimer_Tick(object sender, EventArgs e) if (ret.Item1.frequency > 0) //above 0 is a change in signal { System.Threading.Thread.Sleep(100); - selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), 0); + selectSignal(Convert.ToInt32(ret.Item1.text_pos * spectrum_wScale), 0); sigs.set_tuned(ret.Item1, 0); - rx_blocks[0, 0] = Convert.ToInt16(ret.Item1.fft_centre); - rx_blocks[0, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + rx_blocks[0, 0] = ret.Item1.text_pos; + rx_blocks[0, 1] = ret.Item1.sr * 100.0f / fft_data_length / 9.0f; } } @@ -450,7 +450,7 @@ private void drawspectrum(UInt16[] fft_data) y = tuner * (spectrum_h / _tuners); //draw block showing signal selected - if (rx_blocks[tuner, 0] > 0) + if (rx_blocks[tuner, 0] > 0.0f) { tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); } @@ -498,16 +498,16 @@ private void drawspectrum(UInt16[] fft_data) for (i = 0; i < _tuners; i++) { - if (_tuneModeSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0) + if (_tuneModeSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0.0f) { Tuple ret = sigs.tune(_tuneModeSettings.tuneMode[i], 30, i); if (ret.Item1.frequency > 0) //above 0 is a change in signal { System.Threading.Thread.Sleep(100); - selectSignal(Convert.ToInt32(ret.Item1.fft_centre * spectrum_wScale), y); + selectSignal(Convert.ToInt32(ret.Item1.text_pos * spectrum_wScale), y); sigs.set_tuned(ret.Item1, i); - rx_blocks[i, 0] = Convert.ToInt16(ret.Item1.fft_centre); - rx_blocks[i, 1] = Convert.ToInt16(ret.Item1.fft_stop - ret.Item1.fft_start); + rx_blocks[i, 0] = ret.Item1.text_pos; + rx_blocks[i, 1] = ret.Item1.sr * 100.0f / fft_data_length / 9.0f; } } @@ -639,15 +639,15 @@ public void updateTuner(int tuner, double freq, float sr, bool demod_locked) { if (demod_locked) { - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + rx_blocks[tuner, 0] = Convert.ToSingle((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = sr * fft_data_length / 9.0f; } } public void switchTuner(int tuner, double freq, float sr) { - rx_blocks[tuner, 0] = Convert.ToInt32((freq - start_freq) * fft_data_length / 9.0f); - rx_blocks[tuner, 1] = Convert.ToInt32(sr * fft_data_length / 9.0f); + rx_blocks[tuner, 0] = Convert.ToSingle((freq - start_freq) * fft_data_length / 9.0f); + rx_blocks[tuner, 1] = sr * fft_data_length / 9.0f; } private int determine_rx(int pos) @@ -679,8 +679,8 @@ private void selectSignal(int X, int Y) if ((X / spectrum_wScale) > s.fft_start & (X / spectrum_wScale) < s.fft_stop) { sigs.set_tuned(s, rx); - rx_blocks[rx, 0] = Convert.ToInt16(s.fft_centre); - rx_blocks[rx, 1] = Convert.ToInt16((s.fft_stop) - (s.fft_start)); + rx_blocks[rx, 0] = s.text_pos; + rx_blocks[rx, 1] = s.sr * 100.0f / fft_data_length / 9.0f; UInt32 freq = Convert.ToUInt32((s.frequency) * 1000); UInt32 sr = Convert.ToUInt32((s.sr * 1000.0)); From d80d593ac3ae99b3a68ff82518ca7493e0afb68a Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 09:46:18 +0100 Subject: [PATCH 74/98] Update BATCSpectrum.cs use RectangleF higher accuracy. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index bfeabe3..103712d 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -472,19 +472,19 @@ private void drawspectrum(UInt16[] fft_data) switch (_tuneModeSettings.overPowerIndicatorLayout) { case 0: // classic - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); break; case 1: // classic + line only tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); break; case 2: // box from top to line tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), 1, Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - Convert.ToInt16(sig.max_strength / height)) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - Convert.ToInt16(sig.max_strength / height)) }); break; case 3: // box from line to bottom tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.Rectangle(Convert.ToInt16(sig.text_pos * spectrum_wScale) - (Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale) / 2), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16((sig.fft_stop - sig.fft_start) * spectrum_wScale), height - 4) }); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), height - sig.max_strength / height, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); break; case 4: // line only tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); From 60857ad7ba123d6315301a886c71629f008a8cc4 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 14:37:01 +0100 Subject: [PATCH 75/98] Display volume % at top of bar --- Utilities/VolumeInfoContainer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/VolumeInfoContainer.cs b/Utilities/VolumeInfoContainer.cs index e973a1b..b8c6f38 100644 --- a/Utilities/VolumeInfoContainer.cs +++ b/Utilities/VolumeInfoContainer.cs @@ -49,8 +49,6 @@ public void UpdateVolume(int volume) protected override void OnPaint(PaintEventArgs pe) { - - base.OnPaint(pe); pe.Graphics.FillRectangle(Brushes.Black, 0, 0, Width, Height); @@ -60,6 +58,7 @@ protected override void OnPaint(PaintEventArgs pe) Rectangle barRect = new Rectangle(4, Height - 3 - bar_size, Width - 7, bar_size); pe.Graphics.FillRectangle(Brushes.White, barRect); + pe.Graphics.DrawString(_last_volume.ToString() + "%", new Font("Tahoma", 7), Brushes.White, new PointF(0, 2)); } } From 054864eeaa8dc92bdfa0f8f24b301e8600570ff0 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 14:39:35 +0100 Subject: [PATCH 76/98] 750kS symbol rate alignment added 750kS symbol rate added. Several OM's use this symbol rate. So allow tuning to this rate. --- ExtraFeatures/BATCSpectrum/signal.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 6f7c1d8..4b94412 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -495,8 +495,8 @@ public List detect_signals(UInt16[] fft_data) mid_signal = start_signal + ((end_signal - start_signal) / 2.0); - signal_bw = align_symbolrate((end_signal - start_signal) * 8.9995f / fft_data.Length); - signal_freq = Math.Round((start_freq + mid_signal / fft_data.Length * 8.9995),3); + signal_bw = align_symbolrate((end_signal - start_signal) * 9.0f / fft_data.Length); + signal_freq = Math.Round((start_freq + mid_signal / fft_data.Length * 9.0f),3); //Log.Information("Start :" + start_signal.ToString()); //Log.Information("Middle :" + mid_signal.ToString()); @@ -588,10 +588,14 @@ public float align_symbolrate(float width) { return 0.333f; } - else if (width < 0.700f) + else if (width < 0.7f) { return 0.500f; } + else if (width < 0.85f) + { + return 0.750f; + } else if (width < 1.2f) { return 1.000f; From 74eb512dc2a8af6a4570dfa71dc1ceb40b5cd91e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 14:40:36 +0100 Subject: [PATCH 77/98] Added function GetMuteState. ToggleMute function filled with action. --- MediaSources/Longmynd/LongmyndProperties.cs | 37 ++++---- .../Minitiouner/MinitiounerProperties.cs | 85 ++++++++++--------- MediaSources/OTSource.cs | 1 + .../Winterhill/WinterhillProperties.cs | 39 +++++---- 4 files changed, 88 insertions(+), 74 deletions(-) diff --git a/MediaSources/Longmynd/LongmyndProperties.cs b/MediaSources/Longmynd/LongmyndProperties.cs index e14a296..9eb7c63 100644 --- a/MediaSources/Longmynd/LongmyndProperties.cs +++ b/MediaSources/Longmynd/LongmyndProperties.cs @@ -139,22 +139,7 @@ private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function) switch (function) { case 0: // mute - if (!muted) - { - preMute = _media_player.GetVolume(); - _media_player.SetVolume(0); - _tuner1_properties.UpdateValue("volume_slider_1", "0"); - _settings.DefaultVolume = (byte)preMute; - _settings.DefaultMuted = muted = true; - _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.PaleVioletRed); - } - else - { - _media_player.SetVolume(preMute); - _tuner1_properties.UpdateValue("volume_slider_1", preMute.ToString()); - _settings.DefaultMuted = muted = false; - _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.Transparent); - } + ToggleMute(0); break; case 1: // snapshot Log.Information("Snapshot"); @@ -377,7 +362,27 @@ public override void UpdateVolume(int device, int volume) public override void ToggleMute(int device) { + if (!muted) + { + preMute = _media_player.GetVolume(); + _media_player.SetVolume(0); + _tuner1_properties.UpdateValue("volume_slider_1", "0"); + _settings.DefaultVolume = (byte)preMute; + _settings.DefaultMuted = muted = true; + _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.PaleVioletRed); + } + else + { + _media_player.SetVolume(preMute); + _tuner1_properties.UpdateValue("volume_slider_1", preMute.ToString()); + _settings.DefaultMuted = muted = false; + _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.Transparent); + } + } + public override bool GetMuteState(int device) + { + return muted; } public override int GetVolume(int device) diff --git a/MediaSources/Minitiouner/MinitiounerProperties.cs b/MediaSources/Minitiouner/MinitiounerProperties.cs index 9a27007..c051248 100644 --- a/MediaSources/Minitiouner/MinitiounerProperties.cs +++ b/MediaSources/Minitiouner/MinitiounerProperties.cs @@ -179,46 +179,7 @@ private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function) switch (function) { case 0: // mute - if (tuner == 0) - { - if (!muted[0]) - { - preMute[0] = _media_player[0].GetVolume(); - UpdateVolume(0, 0); - _tuner1_properties.UpdateValue("volume_slider_1", "0"); - _settings.DefaultVolume[0] = (byte)preMute[0]; - _settings.DefaultMuted[0] = muted[0] = true; - _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.PaleVioletRed); - } - else - { - _media_player[0].SetVolume(preMute[0]); - _tuner1_properties.UpdateValue("volume_slider_1", preMute[0].ToString()); - _settings.DefaultMuted[0] = muted[0] = false; - _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.Transparent); - } - } - else - { - if (!muted[1]) - { - preMute[1] = _media_player[1].GetVolume(); - _media_player[1].SetVolume(0); - _tuner2_properties.UpdateValue("volume_slider_2", "0"); - _settings.DefaultVolume[1] = (byte)preMute[1]; - _settings.DefaultMuted[1] = muted[1] = true; - _tuner2_properties.UpdateMuteButtonColor("media_controls_2", Color.PaleVioletRed); - } - else - { - _media_player[1].SetVolume(preMute[1]); - _tuner2_properties.UpdateValue("volume_slider_2", preMute[1].ToString()); - _settings.DefaultMuted[1] = muted[1] = false; - _tuner2_properties.UpdateMuteButtonColor("media_controls_2", Color.Transparent); - } - - } - + ToggleMute(tuner); break; case 1: // snaphost Log.Information("Snapshot: " + tuner.ToString()); @@ -871,7 +832,49 @@ public override void UpdateVolume(int device, int volume) public override void ToggleMute(int device) { - throw new NotImplementedException(); + if (device == 0) + { + if (!muted[0]) + { + preMute[0] = _media_player[0].GetVolume(); + _media_player[0].SetVolume(0); + _tuner1_properties.UpdateValue("volume_slider_1", "0"); + _settings.DefaultVolume[0] = (byte)preMute[0]; + _settings.DefaultMuted[0] = muted[0] = true; + _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.PaleVioletRed); + } + else + { + _media_player[0].SetVolume(preMute[0]); + _tuner1_properties.UpdateValue("volume_slider_1", preMute[0].ToString()); + _settings.DefaultMuted[0] = muted[0] = false; + _tuner1_properties.UpdateMuteButtonColor("media_controls_1", Color.Transparent); + } + } + else + { + if (!muted[1]) + { + preMute[1] = _media_player[1].GetVolume(); + _media_player[1].SetVolume(0); + _tuner2_properties.UpdateValue("volume_slider_2", "0"); + _settings.DefaultVolume[1] = (byte)preMute[1]; + _settings.DefaultMuted[1] = muted[1] = true; + _tuner2_properties.UpdateMuteButtonColor("media_controls_2", Color.PaleVioletRed); + } + else + { + _media_player[1].SetVolume(preMute[1]); + _tuner2_properties.UpdateValue("volume_slider_2", preMute[1].ToString()); + _settings.DefaultMuted[1] = muted[1] = false; + _tuner2_properties.UpdateMuteButtonColor("media_controls_2", Color.Transparent); + } + } + } + + public override bool GetMuteState(int device) + { + return muted[device]; } public override int GetVolume(int device) diff --git a/MediaSources/OTSource.cs b/MediaSources/OTSource.cs index 43dc3f0..2565452 100644 --- a/MediaSources/OTSource.cs +++ b/MediaSources/OTSource.cs @@ -36,6 +36,7 @@ public abstract class OTSource public abstract int GetVolume(int device); public abstract void UpdateVolume(int device, int volume_delta); public abstract void ToggleMute(int device); + public abstract bool GetMuteState(int device); public abstract Dictionary GetSignalData(int device); diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 360d4d6..10e835c 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -354,23 +354,7 @@ private void MediaControlsHandler(int tuner, int function) switch (function) { case 0: // mute - if (!muted[tuner]) - { - preMute[tuner] = _media_player[tuner].GetVolume(); - _media_player[tuner].SetVolume(0); - _tuner_properties[tuner].UpdateValue("volume_slider_" + tuner.ToString(), "0"); - _settings.DefaultVolume[tuner] = (byte)preMute[tuner]; - _settings.DefaultMuted[tuner] = muted[tuner] = true; - _tuner_properties[tuner].UpdateMuteButtonColor("media_controls_" + tuner.ToString(), Color.PaleVioletRed); - } - else - { - _media_player[tuner].SetVolume(preMute[tuner]); - _tuner_properties[tuner].UpdateValue("volume_slider_" + tuner.ToString(), preMute[tuner].ToString()); - _settings.DefaultMuted[tuner] = muted[tuner] = false; - _tuner_properties[tuner].UpdateMuteButtonColor("media_controls_" + tuner.ToString(), Color.Transparent); - } - + ToggleMute(tuner); break; case 1: // snapshot if (playing[tuner]) @@ -769,6 +753,27 @@ public override void UpdateVolume(int device, int volume) public override void ToggleMute(int device) { + if (!muted[device]) + { + preMute[device] = _media_player[device].GetVolume(); + _media_player[device].SetVolume(0); + _tuner_properties[device].UpdateValue("volume_slider_" + device.ToString(), "0"); + _settings.DefaultVolume[device] = (byte)preMute[device]; + _settings.DefaultMuted[device] = muted[device] = true; + _tuner_properties[device].UpdateMuteButtonColor("media_controls_" + device.ToString(), Color.PaleVioletRed); + } + else + { + _media_player[device].SetVolume(preMute[device]); + _tuner_properties[device].UpdateValue("volume_slider_" + device.ToString(), preMute[device].ToString()); + _settings.DefaultMuted[device] = muted[device] = false; + _tuner_properties[device].UpdateMuteButtonColor("media_controls_" + device.ToString(), Color.Transparent); + } + } + + public override bool GetMuteState(int device) + { + return muted[device]; } public override int GetVolume(int device) From efc98fa78d4318d3cca90c1af48e99adcad8aace Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sun, 10 Nov 2024 14:41:03 +0100 Subject: [PATCH 78/98] Right click to video window will mute/unmute audio --- MainForm.cs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 76718c3..2d187a3 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -772,13 +772,21 @@ private void video_player_MouseWheel(object sender, MouseEventArgs e) int video_nr = (int)((Control)sender).Tag; - if (e.Delta < 0) + //if muted: unmute and restore last volume value with first wheel action. + if (videoSource.GetMuteState(video_nr)) { - videoSource.UpdateVolume(video_nr, -1 * wheel_volume_rate); + videoSource.ToggleMute(video_nr); } - if (e.Delta > 0) + else { - videoSource.UpdateVolume(video_nr, wheel_volume_rate); + if (e.Delta < 0) + { + videoSource.UpdateVolume(video_nr, -1 * wheel_volume_rate); + } + if (e.Delta > 0) + { + videoSource.UpdateVolume(video_nr, wheel_volume_rate); + } } if (volume_display.Count > video_nr) @@ -791,10 +799,24 @@ private void video_player_MouseClick(object sender, MouseEventArgs e) { int video_nr = (int)((Control)sender).Tag; - if (info_display.Count > video_nr) + if (e.Button == MouseButtons.Left) { - if (info_display[video_nr] != null) - info_display[video_nr].Visible = !info_display[video_nr].Visible; + if (info_display.Count > video_nr) + { + if (info_display[video_nr] != null) + info_display[video_nr].Visible = !info_display[video_nr].Visible; + } + } + else if (e.Button == MouseButtons.Right) + { + if (info_display.Count > video_nr) + { + videoSource.ToggleMute(video_nr); + if (volume_display.Count > video_nr) + { + volume_display[video_nr].UpdateVolume(videoSource.GetVolume(video_nr)); + } + } } } From 14b369688e7e5cc2bd95eb6fe5a3e4d5b64bfae2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 11 Nov 2024 14:30:55 +0100 Subject: [PATCH 79/98] num_rx need to be initialized with tuner count. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 103712d..6834ec0 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -137,7 +137,7 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) web_socket.start(); sigs.set_num_rx_scan(num_rxs_to_scan); - sigs.set_num_rx(1); + sigs.set_num_rx(Tuners); sigs.set_avoidbeacon(true); From 35faf17749e2d359e619ca72f67d9b47120b7d5e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 11 Nov 2024 15:10:23 +0100 Subject: [PATCH 80/98] tuneMode... names changed to BATCSpectrum... --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 26 ++++---- ...odeSettings.cs => BATCSpectrumSettings.cs} | 2 +- ...s => BATCSpectrumSettingsForm.Designer.cs} | 8 +-- .../BATCSpectrum/BATCSpectrumSettingsForm.cs | 59 +++++++++++++++++++ ...orm.resx => BATCSpectrumSettingsForm.resx} | 0 .../BATCSpectrum/TuneModeSettingsForm.cs | 59 ------------------- MainForm.cs | 6 +- opentuner.csproj | 12 ++-- 8 files changed, 86 insertions(+), 86 deletions(-) rename ExtraFeatures/BATCSpectrum/{TuneModeSettings.cs => BATCSpectrumSettings.cs} (90%) rename ExtraFeatures/BATCSpectrum/{TuneModeSettingsForm.Designer.cs => BATCSpectrumSettingsForm.Designer.cs} (98%) create mode 100644 ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.cs rename ExtraFeatures/BATCSpectrum/{TuneModeSettingsForm.resx => BATCSpectrumSettingsForm.resx} (100%) delete mode 100644 ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 6834ec0..3e841db 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -18,8 +18,8 @@ namespace opentuner.ExtraFeatures.BATCSpectrum { public class BATCSpectrum { - private tuneModeSettings _tuneModeSettings; - private SettingsManager _settingsManager; + private BATCSpectrumSettings spectrumSettings; + private SettingsManager batc_settingsManager; public delegate void SignalSelected(int Receiver, uint Freq, uint SymbolRate); @@ -86,10 +86,10 @@ public void updateSignalCallsign(string callsign, double freq, float sr) public BATCSpectrum(PictureBox Spectrum, int Tuners) { - _tuneModeSettings = new tuneModeSettings(); - _settingsManager = new SettingsManager("tunemode_settings"); + spectrumSettings = new BATCSpectrumSettings(); + batc_settingsManager = new SettingsManager("tunemode_settings"); - _tuneModeSettings = _settingsManager.LoadSettings(_tuneModeSettings); + spectrumSettings = batc_settingsManager.LoadSettings(spectrumSettings); _spectrum = Spectrum; @@ -469,7 +469,7 @@ private void drawspectrum(UInt16[] fft_data) { if (sig.overpower) { - switch (_tuneModeSettings.overPowerIndicatorLayout) + switch (spectrumSettings.overPowerIndicatorLayout) { case 0: // classic tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); @@ -498,9 +498,9 @@ private void drawspectrum(UInt16[] fft_data) for (i = 0; i < _tuners; i++) { - if (_tuneModeSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0.0f) + if (spectrumSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0.0f) { - Tuple ret = sigs.tune(_tuneModeSettings.tuneMode[i], 30, i); + Tuple ret = sigs.tune(spectrumSettings.tuneMode[i], 30, i); if (ret.Item1.frequency > 0) //above 0 is a change in signal { System.Threading.Thread.Sleep(100); @@ -514,7 +514,7 @@ private void drawspectrum(UInt16[] fft_data) y = i * (spectrum_h / _tuners); tmp.DrawLine(greyPen, 10, y, spectrum_w, y); tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); - switch (_tuneModeSettings.tuneMode[i]) + switch (spectrumSettings.tuneMode[i]) { case 0: tmp.DrawString("Manual", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); @@ -574,8 +574,8 @@ private void spectrum_Click(object sender, EventArgs e) int tuner = determine_rx(Y); using (oneTunerTuneModeForm oTTMForm = new oneTunerTuneModeForm( tuner + 1, - _tuneModeSettings.tuneMode[tuner], - _tuneModeSettings.avoidBeacon[tuner])) //open up the single tune mode select form + spectrumSettings.tuneMode[tuner], + spectrumSettings.avoidBeacon[tuner])) //open up the single tune mode select form { Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); Point new_oTTMForm_location = spectrum_screen_location; @@ -592,8 +592,8 @@ private void spectrum_Click(object sender, EventArgs e) DialogResult result = oTTMForm.ShowDialog(); if (result == DialogResult.OK) { - _tuneModeSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); - _tuneModeSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); + spectrumSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); + spectrumSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); } } diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettings.cs similarity index 90% rename from ExtraFeatures/BATCSpectrum/TuneModeSettings.cs rename to ExtraFeatures/BATCSpectrum/BATCSpectrumSettings.cs index d289c2f..8ba2cae 100644 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettings.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettings.cs @@ -6,7 +6,7 @@ namespace opentuner.ExtraFeatures.BATCSpectrum { - public class tuneModeSettings + public class BATCSpectrumSettings { public int[] tuneMode = { 0, 0, 0, 0 }; public bool[] avoidBeacon = { false, false, false, false }; diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.Designer.cs similarity index 98% rename from ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs rename to ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.Designer.cs index 61708a3..1002fa9 100644 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.Designer.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.Designer.cs @@ -1,6 +1,6 @@ namespace opentuner.ExtraFeatures.BATCSpectrum { - partial class tuneModeSettingsForm + partial class BATCSpectrumSettingsForm { /// /// Required designer variable. @@ -263,7 +263,7 @@ private void InitializeComponent() this.overPowerIndicatorLayout.Size = new System.Drawing.Size(162, 21); this.overPowerIndicatorLayout.TabIndex = 0; // - // tuneModeSettingsForm + // BATCSpectrumSettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -275,9 +275,9 @@ private void InitializeComponent() this.Controls.Add(this.btnSave); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "tuneModeSettingsForm"; + this.Name = "BATCSpectrumSettingsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "tuneModeSettings"; + this.Text = "BATCSpectrumSettings"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.cs new file mode 100644 index 0000000..81915d6 --- /dev/null +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace opentuner.ExtraFeatures.BATCSpectrum +{ + public partial class BATCSpectrumSettingsForm : Form + { + private BATCSpectrumSettings spectrumSettings; + + public BATCSpectrumSettingsForm(ref BATCSpectrumSettings _spectrumSettings) + { + spectrumSettings = _spectrumSettings; + InitializeComponent(); + + tuneMode1.SelectedIndex = spectrumSettings.tuneMode[0]; + tuneMode2.SelectedIndex = spectrumSettings.tuneMode[1]; + tuneMode3.SelectedIndex = spectrumSettings.tuneMode[2]; + tuneMode4.SelectedIndex = spectrumSettings.tuneMode[3]; + + avoidBeacon1.Checked = spectrumSettings.avoidBeacon[0]; + avoidBeacon2.Checked = spectrumSettings.avoidBeacon[1]; + avoidBeacon3.Checked = spectrumSettings.avoidBeacon[2]; + avoidBeacon4.Checked = spectrumSettings.avoidBeacon[3]; + + overPowerIndicatorLayout.SelectedIndex = spectrumSettings.overPowerIndicatorLayout; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + spectrumSettings.tuneMode[0] = tuneMode1.SelectedIndex; + spectrumSettings.tuneMode[1] = tuneMode2.SelectedIndex; + spectrumSettings.tuneMode[2] = tuneMode3.SelectedIndex; + spectrumSettings.tuneMode[3] = tuneMode4.SelectedIndex; + + spectrumSettings.avoidBeacon[0] = avoidBeacon1.Checked; + spectrumSettings.avoidBeacon[1] = avoidBeacon2.Checked; + spectrumSettings.avoidBeacon[2] = avoidBeacon3.Checked; + spectrumSettings.avoidBeacon[3] = avoidBeacon4.Checked; + + spectrumSettings.overPowerIndicatorLayout = overPowerIndicatorLayout.SelectedIndex; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx b/ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.resx similarity index 100% rename from ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.resx rename to ExtraFeatures/BATCSpectrum/BATCSpectrumSettingsForm.resx diff --git a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs b/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs deleted file mode 100644 index c43a359..0000000 --- a/ExtraFeatures/BATCSpectrum/TuneModeSettingsForm.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace opentuner.ExtraFeatures.BATCSpectrum -{ - public partial class tuneModeSettingsForm : Form - { - private tuneModeSettings tuneModeSettings; - - public tuneModeSettingsForm(ref tuneModeSettings _tuneModeSettings) - { - tuneModeSettings = _tuneModeSettings; - InitializeComponent(); - - tuneMode1.SelectedIndex = tuneModeSettings.tuneMode[0]; - tuneMode2.SelectedIndex = tuneModeSettings.tuneMode[1]; - tuneMode3.SelectedIndex = tuneModeSettings.tuneMode[2]; - tuneMode4.SelectedIndex = tuneModeSettings.tuneMode[3]; - - avoidBeacon1.Checked = tuneModeSettings.avoidBeacon[0]; - avoidBeacon2.Checked = tuneModeSettings.avoidBeacon[1]; - avoidBeacon3.Checked = tuneModeSettings.avoidBeacon[2]; - avoidBeacon4.Checked = tuneModeSettings.avoidBeacon[3]; - - overPowerIndicatorLayout.SelectedIndex = tuneModeSettings.overPowerIndicatorLayout; - } - - private void btnCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - - private void btnSave_Click(object sender, EventArgs e) - { - tuneModeSettings.tuneMode[0] = tuneMode1.SelectedIndex; - tuneModeSettings.tuneMode[1] = tuneMode2.SelectedIndex; - tuneModeSettings.tuneMode[2] = tuneMode3.SelectedIndex; - tuneModeSettings.tuneMode[3] = tuneMode4.SelectedIndex; - - tuneModeSettings.avoidBeacon[0] = avoidBeacon1.Checked; - tuneModeSettings.avoidBeacon[1] = avoidBeacon2.Checked; - tuneModeSettings.avoidBeacon[2] = avoidBeacon3.Checked; - tuneModeSettings.avoidBeacon[3] = avoidBeacon4.Checked; - - tuneModeSettings.overPowerIndicatorLayout = overPowerIndicatorLayout.SelectedIndex; - - DialogResult = DialogResult.OK; - Close(); - } - } -} diff --git a/MainForm.cs b/MainForm.cs index 2d187a3..f186916 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1004,11 +1004,11 @@ private void checkBatcSpectrum_CheckedChanged(object sender, EventArgs e) private void linkBatcSpectrumSettings_Click(object sender, EventArgs e) { // BATC tune settings - tuneModeSettings batc_settings = new tuneModeSettings(); - SettingsManager batc_settingsManager = new SettingsManager("tunemode_settings"); + BATCSpectrumSettings batc_settings = new BATCSpectrumSettings(); + SettingsManager batc_settingsManager = new SettingsManager("spectrumSettings"); batc_settings = batc_settingsManager.LoadSettings(batc_settings); - tuneModeSettingsForm batc_settings_form = new tuneModeSettingsForm(ref batc_settings); + BATCSpectrumSettingsForm batc_settings_form = new BATCSpectrumSettingsForm(ref batc_settings); if (batc_settings_form.ShowDialog() == DialogResult.OK) { diff --git a/opentuner.csproj b/opentuner.csproj index c43b2b5..c4abb6c 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -247,12 +247,12 @@ True SRForm.resx - - + + Form - - TuneModeSettingsForm.cs + + BATCSpectrumSettingsForm.cs @@ -493,8 +493,8 @@ ResXFileCodeGenerator SRForm.Designer.cs - - TuneModeSettingsForm.cs + + BATCSpectrumSettingsForm.cs WebChatSettngsForm.cs From 2a913d6479b030e0f8211d9cd7e5d4f2d727ecda Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Mon, 11 Nov 2024 22:03:27 +0100 Subject: [PATCH 81/98] do not stop streaming if we lost lock This is not necessary and annoying. I introduced it some time ago and revert this change now. --- MediaSources/Longmynd/LongmyndWS.cs | 9 --------- .../Minitiouner/MinitiounerProperties.cs | 20 ------------------- .../Winterhill/WinterhillProperties.cs | 7 ------- 3 files changed, 36 deletions(-) diff --git a/MediaSources/Longmynd/LongmyndWS.cs b/MediaSources/Longmynd/LongmyndWS.cs index e1eab0c..125b83c 100644 --- a/MediaSources/Longmynd/LongmyndWS.cs +++ b/MediaSources/Longmynd/LongmyndWS.cs @@ -204,15 +204,6 @@ private void UpdatePropertiesWs(monitorMessage monitor_message) _tuner1_properties.UpdateValue("media_controls", indicatorStatus.ToString()); } - // stop streaming if we lost lock - if (_streamer.stream) - { - _streamer.stream = false; -// ClearIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator); - _tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent); - _tuner1_properties.UpdateValue("media_controls", indicatorStatus.ToString()); - } - } } diff --git a/MediaSources/Minitiouner/MinitiounerProperties.cs b/MediaSources/Minitiouner/MinitiounerProperties.cs index c051248..0a1d87f 100644 --- a/MediaSources/Minitiouner/MinitiounerProperties.cs +++ b/MediaSources/Minitiouner/MinitiounerProperties.cs @@ -415,16 +415,6 @@ private void UpdateTunerProperties(TunerStatus new_status) // _tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString()); } - // stop streaming - if (_ts_streamers[0].stream) - { -// ClearIndicator(ref indicatorStatus1, PropertyIndicators.StreamingIndicator); - _ts_streamers[0].stream = false; // stop streaming - _tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent); -// _tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString()); - } - - } // db margin / modcod @@ -530,16 +520,6 @@ private void UpdateTunerProperties(TunerStatus new_status) // _tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString()); } - // stop streaming - if (_ts_streamers[1].stream) - { -// ClearIndicator(ref indicatorStatus2, PropertyIndicators.StreamingIndicator); - _ts_streamers[1].stream = false; // stop streaming - _tuner2_properties.UpdateStreamButtonColor("media_controls_2", Color.Transparent); -// _tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString()); - } - - } // db margin / modcod diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 10e835c..002e1aa 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -538,13 +538,6 @@ private void UpdateInfo(monitorMessage mm) _recorders[c].record = false; _tuner_properties[c].UpdateRecordButtonColor("media_controls_" + c.ToString(), Color.Transparent); } - if (_streamer[c].stream) - { - _streamer[c].stream = false; - _tuner_properties[c].UpdateStreamButtonColor("media_controls_" + c.ToString(), Color.Transparent); - } - - } demodstate[c] = rx.scanstate; From 0082100f8103a942ee7e2822d23a93c67e83e2ed Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 18:07:50 +0100 Subject: [PATCH 82/98] introduce Thread.ResetAbort(); better exception handling --- MediaSources/Minitiouner/NimThread.cs | 3 ++- Transport/Consumers/TSParserThread.cs | 15 ++------------- Transport/Consumers/TSRecorder.cs | 9 ++------- Transport/Consumers/TSUdpStreamer.cs | 8 ++------ Transport/TSThread.cs | 8 ++------ 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/MediaSources/Minitiouner/NimThread.cs b/MediaSources/Minitiouner/NimThread.cs index f160510..9bc82a7 100644 --- a/MediaSources/Minitiouner/NimThread.cs +++ b/MediaSources/Minitiouner/NimThread.cs @@ -471,7 +471,8 @@ public void worker_thread() } catch (ThreadAbortException) { - Log.Information("Nim Thread: Closing"); + Log.Information("Nim Thread: Closed"); + Thread.ResetAbort(); } } diff --git a/Transport/Consumers/TSParserThread.cs b/Transport/Consumers/TSParserThread.cs index 17b16dd..ad979c0 100644 --- a/Transport/Consumers/TSParserThread.cs +++ b/Transport/Consumers/TSParserThread.cs @@ -135,7 +135,6 @@ public void worker_thread() Log.Warning("TS_TABLE_SDT Exception : " + Ex.Message); } - UInt32 ts_payload_section_length = ((UInt32)(ts_packet[ts_payload_offset + 1] & 0x0F) << 8) | (UInt32)ts_packet[ts_payload_offset + 2]; if (ts_payload_section_length < 1) @@ -183,7 +182,6 @@ public void worker_thread() prevServiceProvider = service_provider; } - if (ts_data_callback != null) { TSStatus new_status = new TSStatus(); @@ -198,9 +196,7 @@ public void worker_thread() ts_data_callback(new_status); } - } - } else { @@ -215,20 +211,13 @@ public void worker_thread() { Thread.Sleep(100); } - - } - } catch (ThreadAbortException) { - Log.Information("TS Thread: Closing "); + Log.Information("TS Parser Thread Closed"); + Thread.ResetAbort(); } - finally - { - Log.Information("Closing TS"); - } - } } } \ No newline at end of file diff --git a/Transport/Consumers/TSRecorder.cs b/Transport/Consumers/TSRecorder.cs index 83c8d57..34ff81c 100644 --- a/Transport/Consumers/TSRecorder.cs +++ b/Transport/Consumers/TSRecorder.cs @@ -148,14 +148,9 @@ public void worker_thread() } catch (ThreadAbortException) { - Log.Information("TS Recorder Thread: Closing "); + Log.Information("TS Recorder Thread: Closed"); + Thread.ResetAbort(); } - finally - { - Log.Information("Closing TS Recorder"); - } - - Log.Information("TS Recorder Thread Closed"); } } } diff --git a/Transport/Consumers/TSUdpStreamer.cs b/Transport/Consumers/TSUdpStreamer.cs index a9e5ccb..79635b1 100644 --- a/Transport/Consumers/TSUdpStreamer.cs +++ b/Transport/Consumers/TSUdpStreamer.cs @@ -68,7 +68,6 @@ public void Close() _StreamThread?.Abort(); } - public void worker_thread() { byte data; @@ -167,11 +166,8 @@ public void worker_thread() } catch (ThreadAbortException) { - Log.Information("TS UDP Thread: Closing "); - } - finally - { - Log.Information("Closing TS UDP"); + Log.Information("TS UDP Thread Closed"); + Thread.ResetAbort(); } } } diff --git a/Transport/TSThread.cs b/Transport/TSThread.cs index c8df60b..9c28ee7 100644 --- a/Transport/TSThread.cs +++ b/Transport/TSThread.cs @@ -120,13 +120,9 @@ public void worker_thread() } catch (ThreadAbortException) { - Log.Information("TS Thread: Closing "); + Log.Information("TS Thread: Closed"); + Thread.ResetAbort(); } - finally - { - } - - Log.Information("TS Thread Closed"); } } } From e231343e02f08858542dd15c35ed036559ae5fa4 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 18:08:53 +0100 Subject: [PATCH 83/98] better controlled shutdown of web sockets --- MediaSources/Winterhill/WinterhillWS.cs | 38 ++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/MediaSources/Winterhill/WinterhillWS.cs b/MediaSources/Winterhill/WinterhillWS.cs index 6b4f571..9333493 100644 --- a/MediaSources/Winterhill/WinterhillWS.cs +++ b/MediaSources/Winterhill/WinterhillWS.cs @@ -16,6 +16,8 @@ public partial class WinterhillSource // ws interface private WebSocket controlWS; // longmynd control ws websocket private WebSocket monitorWS; // longmynd monitor ws websocket + private bool controlDisconnect; + private bool monitorDisconnect; private void WSSetFrequency(int device, int freq, int sr) { @@ -40,6 +42,7 @@ private void connectWebsockets() monitorWS.OnClose += Monitorws_OnClose; monitorWS.OnError += MonitorWS_OnError; monitorWS.ConnectAsync(); + monitorDisconnect = false; controlWS = new WebSocket(url, "control"); controlWS.OnClose += Controlws_OnClose; @@ -47,7 +50,7 @@ private void connectWebsockets() controlWS.OnOpen += Controlws_OnOpen; controlWS.OnError += ControlWS_OnError; controlWS.ConnectAsync(); - + controlDisconnect = false; } private void ControlWS_OnError(object sender, ErrorEventArgs e) @@ -102,16 +105,30 @@ private void Controlws_OnMessage(object sender, MessageEventArgs e) private void Controlws_OnClose(object sender, CloseEventArgs e) { - debug("Error: Control WS Closed - Check WS IP"); - debug("Attempting to reconnect..."); - controlWS.ConnectAsync(); + if (!controlDisconnect) + { + debug("Error: Control WS Closed - Check WS IP"); + debug("Attempting to reconnect..."); + controlWS.ConnectAsync(); + } + else + { + debug("Control WS Closed"); + } } private void Monitorws_OnClose(object sender, CloseEventArgs e) { - debug("Error: Monitor WS Closed - Check WS IP"); - debug("Attempting to reconnect..."); - monitorWS.ConnectAsync(); + if (!monitorDisconnect) + { + debug("Error: Monitor WS Closed - Check WS IP"); + debug("Attempting to reconnect..."); + monitorWS.ConnectAsync(); + } + else + { + debug("Monitor WS Closed"); + } } private void Monitorws_OnMessage(object sender, MessageEventArgs e) @@ -127,13 +144,20 @@ public void DisconnectWebsockets() if (monitorWS != null) { if (monitorWS.IsAlive) + { + debug("Attempting to reconnect..."); + monitorDisconnect = true; monitorWS?.Close(); + } } if (controlWS != null) { if (controlWS.IsAlive) + { + controlDisconnect = true; controlWS?.Close(); + } } } } From d82aea58dc9f8d48831a226e50a65512434de7ef Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 18:09:47 +0100 Subject: [PATCH 84/98] better controlled udpclient close --- Utilities/UDPClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Utilities/UDPClient.cs b/Utilities/UDPClient.cs index b4eb471..116e046 100644 --- a/Utilities/UDPClient.cs +++ b/Utilities/UDPClient.cs @@ -16,6 +16,7 @@ public class UDPClient private UdpClient udpClient; private int port; private bool isListening; + private bool isStopped; private Thread listenThread; private int _id; @@ -54,6 +55,7 @@ public void Connect() if (!isListening) { isListening = true; + isStopped = false; listenThread.Start(); OnConnectionStatusChanged(true); @@ -65,8 +67,11 @@ public void Disconnect() if (isListening) { isListening = false; + for (int i = 0; (i < 50) && !isStopped; i++) // wait till thread is stopped. max. 0.5 Seconds + { + Thread.Sleep(100); + } // listenThread.Join(); // Wait for the thread to finish - udpClient.Close(); OnConnectionStatusChanged(false); @@ -79,7 +84,6 @@ private void ListenForData() try { - while (isListening) { byte[] receivedBytes = udpClient.Receive(ref remoteEndPoint); @@ -93,11 +97,13 @@ private void ListenForData() Log.Information("OnDataReceived event failed: " + ex.Message); } } + isStopped = true; } catch (Exception ex) { Log.Information("Listen for UDP Data Exception: " + this.port.ToString() + " : "+ ex.Message); OnConnectionStatusChanged(false); + isStopped = true; } } From de7f70e0f9ffca0ea158fdefadeb3b20cd9d7920 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 20:32:34 +0100 Subject: [PATCH 85/98] settings filename changed --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 3e841db..b0fb8d0 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -87,7 +87,7 @@ public void updateSignalCallsign(string callsign, double freq, float sr) public BATCSpectrum(PictureBox Spectrum, int Tuners) { spectrumSettings = new BATCSpectrumSettings(); - batc_settingsManager = new SettingsManager("tunemode_settings"); + batc_settingsManager = new SettingsManager("spectrumSettings"); spectrumSettings = batc_settingsManager.LoadSettings(spectrumSettings); From ed35f7c8add9813b79d469f5e0d75639e7b31c63 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 20:47:41 +0100 Subject: [PATCH 86/98] added: allow mouse click to reconnect the socket --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 173 +++++++++++---------- 1 file changed, 91 insertions(+), 82 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index b0fb8d0..0735f85 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -161,11 +161,11 @@ private void draw_disconnect() if (connect_retry_count < connect_retries) { - tmp.DrawString("Retrying ...." + connect_retry_count.ToString() + "/" + connect_retries.ToString(), new Font("Tahoma", 10), Brushes.Red, new PointF(10, 30)); + tmp.DrawString("Retrying ...." + (connect_retry_count + 1).ToString() + "/" + connect_retries.ToString(), new Font("Tahoma", 10), Brushes.Red, new PointF(10, 30)); } else { - tmp.DrawString("", new Font("Tahoma", 10), Brushes.Red, new PointF(10, 30)); + tmp.DrawString("Click with mouse to reconnect", new Font("Tahoma", 10), Brushes.Red, new PointF(10, 30)); } UpdateDrawing(); } @@ -183,7 +183,6 @@ private void Web_socket_ConnectionStatusChanged(object sender, bool connection_s _autoTuneMode = 0; SpectrumTuneTimer.Enabled = false; } - } public void Close() @@ -213,10 +212,10 @@ private void websocketTimer_Tick(object sender, EventArgs e) if (!web_socket.connected) { draw_disconnect(); - connect_retry_count += 1; if (connect_retry_count < connect_retries) { + connect_retry_count += 1; debug("Websocket Not Connected: Retrying " + connect_retry_count.ToString() + "/" + connect_retries.ToString()); web_socket.start(); } @@ -532,103 +531,113 @@ private void drawspectrum(UInt16[] fft_data) private void spectrum_Click(object sender, EventArgs e) { - int spectrum_h = _spectrum.Height - bandplan_height; - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / fft_data_length; + if (web_socket.connected) + { + int spectrum_h = _spectrum.Height - bandplan_height; + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / fft_data_length; - MouseEventArgs me = (MouseEventArgs)e; - var pos = me.Location; + MouseEventArgs me = (MouseEventArgs)e; + var pos = me.Location; - int X = pos.X; - int Y = pos.Y; + int X = pos.X; + int Y = pos.Y; - if (Y > spectrum_h) - { - if (pluto_control_enabled) + if (Y > spectrum_h) + { + if (pluto_control_enabled) + { + switch (me.Button) + { + case MouseButtons.Left: + string tx_freq = get_bandplan_TX_freq(X, Y); + debug("TX-Freq: " + tx_freq + " MHz"); + // dh3cs + if (!string.IsNullOrEmpty(tx_freq)) + { + //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz + Clipboard.SetText(tx_freq); //DATV-Easy in MHz + TX_Text = " TX: " + tx_freq; + } + break; + default: + break; + } + } + } + else { switch (me.Button) { case MouseButtons.Left: - string tx_freq = get_bandplan_TX_freq(X, Y); - debug("TX-Freq: " + tx_freq + " MHz"); - // dh3cs - if (!string.IsNullOrEmpty(tx_freq)) + if (Control.ModifierKeys == Keys.Shift) { - //Clipboard.SetText((Convert.ToDecimal(tx_freq) * 1000).ToString()); //DATV Express in Hz - Clipboard.SetText(tx_freq); //DATV-Easy in MHz - TX_Text = " TX: " + tx_freq; + int tuner = determine_rx(Y); + using (oneTunerTuneModeForm oTTMForm = new oneTunerTuneModeForm( + tuner + 1, + spectrumSettings.tuneMode[tuner], + spectrumSettings.avoidBeacon[tuner])) //open up the single tune mode select form + { + Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); + Point new_oTTMForm_location = spectrum_screen_location; + int spectrum_width = _spectrum.Size.Width; + int oTTMForm_width = oTTMForm.Size.Width; + + if (X > (oTTMForm_width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + X - oTTMForm.Size.Width / 2; + if (X > (spectrum_width - oTTMForm.Size.Width / 2)) + new_oTTMForm_location.X = spectrum_screen_location.X + (spectrum_width - oTTMForm.Size.Width); + + oTTMForm.StartPosition = FormStartPosition.Manual; + oTTMForm.Location = new_oTTMForm_location; + DialogResult result = oTTMForm.ShowDialog(); + if (result == DialogResult.OK) + { + spectrumSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); + spectrumSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); + } + } + + } + else + { + selectSignal(X, Y); } break; - default: - break; - } - } - } - else - { - switch (me.Button) - { - case MouseButtons.Left: - if (Control.ModifierKeys == Keys.Shift) - { - int tuner = determine_rx(Y); - using (oneTunerTuneModeForm oTTMForm = new oneTunerTuneModeForm( - tuner + 1, - spectrumSettings.tuneMode[tuner], - spectrumSettings.avoidBeacon[tuner])) //open up the single tune mode select form + case MouseButtons.Right: + uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); + + using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form { Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); - Point new_oTTMForm_location = spectrum_screen_location; + Point new_srForm_location = spectrum_screen_location; int spectrum_width = _spectrum.Size.Width; - int oTTMForm_width = oTTMForm.Size.Width; + int srForm_width = srForm.Size.Width; - if (X > (oTTMForm_width / 2)) - new_oTTMForm_location.X = spectrum_screen_location.X + X - oTTMForm.Size.Width / 2; - if (X > (spectrum_width - oTTMForm.Size.Width / 2)) - new_oTTMForm_location.X = spectrum_screen_location.X + (spectrum_width - oTTMForm.Size.Width); + if (X > (srForm_width / 2)) + new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; + if (X > (spectrum_width - srForm.Size.Width / 2)) + new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); - oTTMForm.StartPosition = FormStartPosition.Manual; - oTTMForm.Location = new_oTTMForm_location; - DialogResult result = oTTMForm.ShowDialog(); + srForm.StartPosition = FormStartPosition.Manual; + srForm.Location = new_srForm_location; + DialogResult result = srForm.ShowDialog(); if (result == DialogResult.OK) { - spectrumSettings.tuneMode[tuner] = oTTMForm.getTuneMode(); - spectrumSettings.avoidBeacon[tuner] = oTTMForm.getAvoidBeacon(); + OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); } } - - } - else - { - selectSignal(X, Y); - } - break; - case MouseButtons.Right: - uint freq = Convert.ToUInt32((10490.5 + (X / spectrum_wScale / 922.0) * 9.0) * 1000.0); - - using (opentuner.SRForm srForm = new opentuner.SRForm(freq)) //open up the manual sr select form - { - Point spectrum_screen_location = _spectrum.PointToScreen(_spectrum.Location); - Point new_srForm_location = spectrum_screen_location; - int spectrum_width = _spectrum.Size.Width; - int srForm_width = srForm.Size.Width; - - if (X > (srForm_width / 2)) - new_srForm_location.X = spectrum_screen_location.X + X - srForm.Size.Width / 2; - if (X > (spectrum_width - srForm.Size.Width / 2)) - new_srForm_location.X = spectrum_screen_location.X + (spectrum_width - srForm.Size.Width); - - srForm.StartPosition = FormStartPosition.Manual; - srForm.Location = new_srForm_location; - DialogResult result = srForm.ShowDialog(); - if (result == DialogResult.OK) - { - OnSignalSelected?.Invoke(determine_rx(Y), freq, srForm.getsr()); - } - } - break; - default: - break; + break; + default: + break; + } + } + } + else + { + if (connect_retry_count >= connect_retries) + { + connect_retry_count = 0; } } } From 5f72b9c3def6332726db80a8c521ee7e2080c5b2 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 20:47:47 +0100 Subject: [PATCH 87/98] Update socket.cs --- ExtraFeatures/BATCSpectrum/socket.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ExtraFeatures/BATCSpectrum/socket.cs b/ExtraFeatures/BATCSpectrum/socket.cs index 76ceaf6..eb578d2 100644 --- a/ExtraFeatures/BATCSpectrum/socket.cs +++ b/ExtraFeatures/BATCSpectrum/socket.cs @@ -35,7 +35,6 @@ public void start() { if (!connected) { - Log.Information(connected.ToString()); Log.Information("Websocket: QO_Spectrum: Try connect..\n"); ws = new WebSocket("wss://eshail.batc.org.uk/wb/fft", "fft_m0dtslivetune"); From 1a802aaba09a70492db1fa0ce4b29778641829bf Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 20:49:49 +0100 Subject: [PATCH 88/98] added: spectrum drawing lock prevent exceptions --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 150 +++++++++++---------- 1 file changed, 81 insertions(+), 69 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 0735f85..911cf40 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -47,6 +47,8 @@ public class BATCSpectrum Graphics tmp; Graphics tmp2; + private static readonly Object drawing_lock = new Object(); + float[,] rx_blocks = new float[4, 3]; XElement bandplan; @@ -151,7 +153,10 @@ public BATCSpectrum(PictureBox Spectrum, int Tuners) websocketTimer.Tick += new System.EventHandler(this.websocketTimer_Tick); websocketTimer.Enabled = true; - draw_disconnect(); + lock (drawing_lock) + { + draw_disconnect(); + } } private void draw_disconnect() @@ -211,7 +216,10 @@ private void websocketTimer_Tick(object sender, EventArgs e) if (!web_socket.connected) { - draw_disconnect(); + lock (drawing_lock) + { + draw_disconnect(); + } if (connect_retry_count < connect_retries) { @@ -438,95 +446,99 @@ private void drawspectrum(UInt16[] fft_data) Color.FromArgb(255, 255, 99, 132), // Opaque red Color.FromArgb(255, 54, 162, 235)); // Opaque blue - tmp.FillPolygon(linGrBrush, points); + lock (drawing_lock) + { - tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan + tmp.FillPolygon(linGrBrush, points); - y = 0; + tmp.DrawImage(bmp2, 0, height - bandplan_height); //bandplan - for (int tuner = 0; tuner < _tuners; tuner++) - { - y = tuner * (spectrum_h / _tuners); + y = 0; - //draw block showing signal selected - if (rx_blocks[tuner, 0] > 0.0f) + for (int tuner = 0; tuner < _tuners; tuner++) { - tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + y = tuner * (spectrum_h / _tuners); + + //draw block showing signal selected + if (rx_blocks[tuner, 0] > 0.0f) + { + tmp.FillRectangle(shadowBrush, new RectangleF(rx_blocks[tuner, 0] * spectrum_wScale - ((rx_blocks[tuner, 1] * spectrum_wScale) / 2), y, rx_blocks[tuner, 1] * spectrum_wScale, (spectrum_h / _tuners))); + } } - } - tmp.DrawString(InfoText, new Font("Tahoma", 15), Brushes.White, new PointF(10, 10)); - tmp.DrawString(TX_Text, new Font("Tahoma", 15), Brushes.Red, new PointF(70, _spectrum.Height - 50)); //dh3cs + tmp.DrawString(InfoText, new Font("Tahoma", 15), Brushes.White, new PointF(10, 10)); + tmp.DrawString(TX_Text, new Font("Tahoma", 15), Brushes.Red, new PointF(70, _spectrum.Height - 50)); //dh3cs - //drawspectrum_signals(sigs.detect_signals(fft_data)); - sigs.detect_signals(fft_data); + //drawspectrum_signals(sigs.detect_signals(fft_data)); + sigs.detect_signals(fft_data); - // draw over power - lock (list_lock) - { - foreach (var sig in sigs.signals) + // draw over power + lock (list_lock) { - if (sig.overpower) + foreach (var sig in sigs.signals) { - switch (spectrumSettings.overPowerIndicatorLayout) + if (sig.overpower) { - case 0: // classic - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); - break; - case 1: // classic + line only - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); - break; - case 2: // box from top to line - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - Convert.ToInt16(sig.max_strength / height)) }); - break; - case 3: // box from line to bottom - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), height - sig.max_strength / height, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); - break; - case 4: // line only - tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); - break; - default: // no indication - break; + switch (spectrumSettings.overPowerIndicatorLayout) + { + case 0: // classic + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); + break; + case 1: // classic + line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); + break; + case 2: // box from top to line + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), 1, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - Convert.ToInt16(sig.max_strength / height)) }); + break; + case 3: // box from line to bottom + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + tmp.FillRectangles(overpowerBrush, new RectangleF[] { new System.Drawing.RectangleF(sig.text_pos * spectrum_wScale - ((sig.fft_stop - sig.fft_start) * spectrum_wScale / 2), height - sig.max_strength / height, (sig.fft_stop - sig.fft_start) * spectrum_wScale, height - 4) }); + break; + case 4: // line only + tmp.DrawLine(overpowerPen, Convert.ToInt16(sig.fft_start * spectrum_wScale - 15), height - Convert.ToInt16(sig.max_strength / height), Convert.ToInt16(sig.fft_stop * spectrum_wScale + 15), height - Convert.ToInt16(sig.max_strength / height)); + break; + default: // no indication + break; + } } } } - } - for (i = 0; i < _tuners; i++) - { - if (spectrumSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0.0f) + for (i = 0; i < _tuners; i++) { - Tuple ret = sigs.tune(spectrumSettings.tuneMode[i], 30, i); - if (ret.Item1.frequency > 0) //above 0 is a change in signal + if (spectrumSettings.tuneMode[i] == 1 && rx_blocks[0, 2] == 0.0f) { - System.Threading.Thread.Sleep(100); - selectSignal(Convert.ToInt32(ret.Item1.text_pos * spectrum_wScale), y); - sigs.set_tuned(ret.Item1, i); - rx_blocks[i, 0] = ret.Item1.text_pos; - rx_blocks[i, 1] = ret.Item1.sr * 100.0f / fft_data_length / 9.0f; + Tuple ret = sigs.tune(spectrumSettings.tuneMode[i], 30, i); + if (ret.Item1.frequency > 0) //above 0 is a change in signal + { + //System.Threading.Thread.Sleep(100); + selectSignal(Convert.ToInt32(ret.Item1.text_pos * spectrum_wScale), y); + sigs.set_tuned(ret.Item1, i); + rx_blocks[i, 0] = ret.Item1.text_pos; + rx_blocks[i, 1] = ret.Item1.sr * 100.0f / fft_data_length / 9.0f; + } } - } - y = i * (spectrum_h / _tuners); - tmp.DrawLine(greyPen, 10, y, spectrum_w, y); - tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); - switch (spectrumSettings.tuneMode[i]) - { - case 0: - tmp.DrawString("Manual", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); - break; - case 1: - tmp.DrawString("Auto", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); - break; - default: - break; + y = i * (spectrum_h / _tuners); + tmp.DrawLine(greyPen, 10, y, spectrum_w, y); + tmp.DrawString("RX " + (i + 1).ToString(), new Font("Tahoma", 10), Brushes.White, new PointF(5, y)); + switch (spectrumSettings.tuneMode[i]) + { + case 0: + tmp.DrawString("Manual", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + case 1: + tmp.DrawString("Auto", new Font("Tahoma", 10), Brushes.White, new PointF(5, y + 14)); + break; + default: + break; + } } - } - drawspectrum_signals(sigs.signals); + drawspectrum_signals(sigs.signals); + } } private void spectrum_Click(object sender, EventArgs e) From 20bbea6cb00abb2d3ceabb152fb6898c554c4dd3 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 20:57:31 +0100 Subject: [PATCH 89/98] Update BATCSpectrum.cs drawing lock position in code fixed. --- ExtraFeatures/BATCSpectrum/BATCSpectrum.cs | 61 +++++++++++----------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs index 911cf40..ed65fb0 100644 --- a/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs +++ b/ExtraFeatures/BATCSpectrum/BATCSpectrum.cs @@ -408,46 +408,47 @@ private void UpdateDrawing() // Entrypoint with new fft_data from websocket private void drawspectrum(UInt16[] fft_data) { - fft_data_length = fft_data.Length; - tmp.Clear(Color.Black); //clear canvas + lock (drawing_lock) + { - int spectrum_h = _spectrum.Height - bandplan_height; - float spectrum_w = _spectrum.Width; - float spectrum_wScale = spectrum_w / fft_data_length; + fft_data_length = fft_data.Length; - int i = 1; - int y = 0; + tmp.Clear(Color.Black); //clear canvas - PointF[] points = new PointF[fft_data.Length]; + int spectrum_h = _spectrum.Height - bandplan_height; + float spectrum_w = _spectrum.Width; + float spectrum_wScale = spectrum_w / fft_data_length; - for (i = 1; i < fft_data.Length; i++) //ignore padding? - { - PointF point = new PointF(i * spectrum_wScale, height - fft_data[i] / height); - points[i] = point; - } + int i = 1; + int y = 0; - points[0] = new PointF(0, height); - points[points.Length - 1] = new PointF(spectrum_w, height); + PointF[] points = new PointF[fft_data.Length]; - if (spectrumTunerHighlight > -1) - { - y = spectrumTunerHighlight * (spectrum_h / _tuners); - tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); - } + for (i = 1; i < fft_data.Length; i++) //ignore padding? + { + PointF point = new PointF(i * spectrum_wScale, height - fft_data[i] / height); + points[i] = point; + } - //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); + points[0] = new PointF(0, height); + points[points.Length - 1] = new PointF(spectrum_w, height); - //tmp.DrawPolygon(greenpen, points); - SolidBrush spectrumBrush = new SolidBrush(Color.Blue); + if (spectrumTunerHighlight > -1) + { + y = spectrumTunerHighlight * (spectrum_h / _tuners); + tmp.FillRectangle(tuner1Brush, new RectangleF(0, y, spectrum_w, (spectrum_h / _tuners))); + } - LinearGradientBrush linGrBrush = new LinearGradientBrush( - new Point(0, 0), - new Point(0, height), - Color.FromArgb(255, 255, 99, 132), // Opaque red - Color.FromArgb(255, 54, 162, 235)); // Opaque blue + //tmp.FillRectangle((spectrumTunerHighlight == 1 ? tuner1Brush : tuner2Brush), new RectangleF(0, (spectrumTunerHighlight == 1 ? 0 : spectrum_h / 2), spectrum_w, _tuners == 1 ? spectrum_h : spectrum_h / 2)); - lock (drawing_lock) - { + //tmp.DrawPolygon(greenpen, points); + SolidBrush spectrumBrush = new SolidBrush(Color.Blue); + + LinearGradientBrush linGrBrush = new LinearGradientBrush( + new Point(0, 0), + new Point(0, height), + Color.FromArgb(255, 255, 99, 132), // Opaque red + Color.FromArgb(255, 54, 162, 235)); // Opaque blue tmp.FillPolygon(linGrBrush, points); From fd7a2a18605f389572242c6e30fe8d02af936131 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 21:01:12 +0100 Subject: [PATCH 90/98] wrong debug message removed --- MediaSources/Winterhill/WinterhillWS.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/MediaSources/Winterhill/WinterhillWS.cs b/MediaSources/Winterhill/WinterhillWS.cs index 9333493..015b20e 100644 --- a/MediaSources/Winterhill/WinterhillWS.cs +++ b/MediaSources/Winterhill/WinterhillWS.cs @@ -145,7 +145,6 @@ public void DisconnectWebsockets() { if (monitorWS.IsAlive) { - debug("Attempting to reconnect..."); monitorDisconnect = true; monitorWS?.Close(); } From 1d5866d847dcbb09745be3c0647d9d85f89d2690 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Wed, 13 Nov 2024 22:10:53 +0100 Subject: [PATCH 91/98] allow udp streaming even if not locked --- MediaSources/Winterhill/WinterhillProperties.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 002e1aa..06d7861 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -187,7 +187,6 @@ private void _genericContextStrip_Opening(object sender, System.ComponentModel.C } break; case "ts_addr": - // get local ip's if (_LocalIp.Length == 0) { @@ -401,16 +400,9 @@ private void MediaControlsHandler(int tuner, int function) } else { - if (demodstate[tuner] == 3 || demodstate[tuner] == 2) - { - _streamer[tuner].stream = true; -// SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator); - _tuner_properties[tuner].UpdateStreamButtonColor("media_controls_" + tuner.ToString(), Color.PaleTurquoise); - } - else - { - Log.Error("Can't stream, not locked to a signal"); - } + _streamer[tuner].stream = true; +// SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator); + _tuner_properties[tuner].UpdateStreamButtonColor("media_controls_" + tuner.ToString(), Color.PaleTurquoise); } _tuner_properties[tuner].UpdateValue("media_controls_" + tuner.ToString(), indicatorStatus[tuner].ToString()); From 51027b9c3a8145642988bf22d21dc8529fd6cdb6 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 14 Nov 2024 16:08:17 +0100 Subject: [PATCH 92/98] function "mute_at_startup" fixed --- MainForm.cs | 12 +++--------- MediaSources/Longmynd/LongmyndProperties.cs | 7 ++++++- MediaSources/Longmynd/LongmyndSource.cs | 4 ++-- MediaSources/Minitiouner/MinitiounerProperties.cs | 10 +++++++++- MediaSources/Minitiouner/MinitiounerSource.cs | 8 ++++---- MediaSources/OTSource.cs | 2 +- MediaSources/Winterhill/WinterhillProperties.cs | 7 ++++++- MediaSources/Winterhill/WinterhillSource.cs | 4 ++-- 8 files changed, 33 insertions(+), 21 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index f186916..c3a5072 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -327,13 +327,13 @@ public MainForm(string[] args) /// Connect to Media Source and configure Media Players + extra's based on Media Source initialization. /// /// - private bool SourceConnect(OTSource MediaSource) + private bool SourceConnect(OTSource MediaSource, bool mute_at_startup) { Log.Information("Connecting to " + MediaSource.GetName()); videoSource = MediaSource; - int video_players_required = videoSource.Initialize(ChangeVideo, PropertiesPage); + int video_players_required = videoSource.Initialize(ChangeVideo, PropertiesPage, mute_at_startup); if (video_players_required < 0) { @@ -913,7 +913,7 @@ private void DisconnectCurrentSource() private bool ConnectSelectedSource() { - if (!SourceConnect(_availableSources[comboAvailableSources.SelectedIndex])) + if (!SourceConnect(_availableSources[comboAvailableSources.SelectedIndex], _settings.mute_at_startup)) return false; if (checkBatcSpectrum.Checked) @@ -951,12 +951,6 @@ private bool ConnectSelectedSource() } } - if (_settings.mute_at_startup) - { - _availableSources[comboAvailableSources.SelectedIndex].OverrideDefaultMuted(_settings.mute_at_startup); - } - - splitContainer1.SplitterDistance = _settings.gui_main_splitter_position; videoSource.UpdateFrequencyPresets(stored_frequencies); diff --git a/MediaSources/Longmynd/LongmyndProperties.cs b/MediaSources/Longmynd/LongmyndProperties.cs index 9eb7c63..fc6e311 100644 --- a/MediaSources/Longmynd/LongmyndProperties.cs +++ b/MediaSources/Longmynd/LongmyndProperties.cs @@ -49,7 +49,7 @@ public partial class LongmyndSource private List _frequency_presets = null; - private bool BuildSourceProperties() + private bool BuildSourceProperties(bool mute_at_startup) { if (_parent == null) { @@ -63,6 +63,11 @@ private bool BuildSourceProperties() _tuner1_properties = ConfigureTunerProperties(1); + if (mute_at_startup) + { + _settings.DefaultMuted = true; + } + muted = _settings.DefaultMuted; preMute = (int)_settings.DefaultVolume; diff --git a/MediaSources/Longmynd/LongmyndSource.cs b/MediaSources/Longmynd/LongmyndSource.cs index 36ad746..f5dba0a 100644 --- a/MediaSources/Longmynd/LongmyndSource.cs +++ b/MediaSources/Longmynd/LongmyndSource.cs @@ -181,7 +181,7 @@ private void Udp_client_ConnectionStatusChanged(object sender, bool connection_s - public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent) + public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent, bool mute_at_startup) { _parent = Parent; @@ -208,7 +208,7 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent ts_thread_t = new Thread(ts_thread.worker_thread); ts_thread_t.Start(); - BuildSourceProperties(); + BuildSourceProperties(mute_at_startup); switch(_settings.DefaultInterface) { diff --git a/MediaSources/Minitiouner/MinitiounerProperties.cs b/MediaSources/Minitiouner/MinitiounerProperties.cs index 0a1d87f..a30c444 100644 --- a/MediaSources/Minitiouner/MinitiounerProperties.cs +++ b/MediaSources/Minitiouner/MinitiounerProperties.cs @@ -51,7 +51,7 @@ public partial class MinitiounerSource public override event SourceDataChange OnSourceData; private List _frequency_presets = null; - private bool BuildSourceProperties() + private bool BuildSourceProperties(bool mute_at_startup) { if (_parent == null) { @@ -66,6 +66,10 @@ private bool BuildSourceProperties() if (ts_devices == 2) { _tuner2_properties = ConfigureTunerProperties(2); + if (mute_at_startup) + { + _settings.DefaultMuted[1] = true; + } muted[1] = _settings.DefaultMuted[1]; preMute[1] = (int)_settings.DefaultVolume[1]; @@ -84,6 +88,10 @@ private bool BuildSourceProperties() } _tuner1_properties = ConfigureTunerProperties(1); + if (mute_at_startup) + { + _settings.DefaultMuted[0] = true; + } muted[0] = _settings.DefaultMuted[0]; preMute[0] = (int)_settings.DefaultVolume[0]; diff --git a/MediaSources/Minitiouner/MinitiounerSource.cs b/MediaSources/Minitiouner/MinitiounerSource.cs index 0d1c074..d01c63c 100644 --- a/MediaSources/Minitiouner/MinitiounerSource.cs +++ b/MediaSources/Minitiouner/MinitiounerSource.cs @@ -273,7 +273,7 @@ public void change_frequency(byte device, UInt32 freq, UInt32 sr, uint rf_input // return hardware_interface.hw_set_polarization_supply(lnb_num, supply_enable, supply_horizontal); //} - public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent) + public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent, bool mute_at_startup) { switch (_settings.DefaultInterface) { @@ -296,7 +296,7 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent } - return Initialize(VideoChangeCB, SourceStatusCB, false, "", "", "", Parent); + return Initialize(VideoChangeCB, SourceStatusCB, false, "", "", "", Parent, mute_at_startup); } public void nim_status_feedback(TunerStatus nim_status) @@ -415,7 +415,7 @@ private void ChangeOffset(byte Tuner, int offset) } - private int Initialize(VideoChangeCallback VideoChangeCB, SourceStatusCallback SourceStatusCB, bool manual, string i2c_serial, string ts_serial, string ts2_serial, Control Parent) + private int Initialize(VideoChangeCallback VideoChangeCB, SourceStatusCallback SourceStatusCB, bool manual, string i2c_serial, string ts_serial, string ts2_serial, Control Parent, bool mute_at_startup) { this.VideoChangeCB = VideoChangeCB; @@ -431,7 +431,7 @@ private int Initialize(VideoChangeCallback VideoChangeCB, SourceStatusCallback S // build properties _parent = Parent; - BuildSourceProperties(); + BuildSourceProperties(mute_at_startup); _source_properties.UpdateValue("source_hw_interface", hardware_interface.GetName); diff --git a/MediaSources/OTSource.cs b/MediaSources/OTSource.cs index 2565452..6917bff 100644 --- a/MediaSources/OTSource.cs +++ b/MediaSources/OTSource.cs @@ -49,7 +49,7 @@ public abstract class OTSource public abstract void Close(); // initialize returns how many video players it need - public abstract int Initialize(VideoChangeCallback VideoChangeCB, Control Parent); + public abstract int Initialize(VideoChangeCallback VideoChangeCB, Control Parent, bool mute_at_startup); public abstract void ConfigureVideoPlayers(List MediaPlayers); diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 06d7861..0188069 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -39,7 +39,7 @@ public partial class WinterhillSource }; - private bool BuildSourceProperties() + private bool BuildSourceProperties(bool mute_at_startup) { if (_parent == null) { @@ -82,6 +82,11 @@ private bool BuildSourceProperties() _tuner_properties[c].AddSlider("volume_slider_" + c.ToString(), "Volume", 0, 200); _tuner_properties[c].AddMediaControls("media_controls_" + c.ToString(), "Media Controls"); + if (mute_at_startup) + { + _settings.DefaultMuted[c] = true; + } + muted[c] = _settings.DefaultMuted[c]; preMute[c] = (int)_settings.DefaultVolume[c]; diff --git a/MediaSources/Winterhill/WinterhillSource.cs b/MediaSources/Winterhill/WinterhillSource.cs index a0a0cdc..915e9ff 100644 --- a/MediaSources/Winterhill/WinterhillSource.cs +++ b/MediaSources/Winterhill/WinterhillSource.cs @@ -72,7 +72,7 @@ public WinterhillSource() } - public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent) + public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent, bool mute_at_startup) { _parent = Parent; @@ -171,7 +171,7 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent } - BuildSourceProperties(); + BuildSourceProperties(mute_at_startup); this.VideoChangeCB = VideoChangeCB; From 08a5337b954755d5f334342476a7683d6b2f55ee Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 14 Nov 2024 18:01:09 +0100 Subject: [PATCH 93/98] Windows Exception prevented If usb ftdi was not found and program was closed an windows exception was thrown. Closing the usbDeviceCollection and usbContext before leaving the program solve the problem. --- .../HardwareInterfaces/FTDI/FTDIInterface.cs | 4 ++++ .../HardwareInterfaces/MTHardwareInterface.cs | 2 ++ .../PicoTuner/PicoTunerInterface.cs | 13 +++++++++++-- MediaSources/Minitiouner/MinitiounerSource.cs | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MediaSources/Minitiouner/HardwareInterfaces/FTDI/FTDIInterface.cs b/MediaSources/Minitiouner/HardwareInterfaces/FTDI/FTDIInterface.cs index 5050cef..6035c47 100644 --- a/MediaSources/Minitiouner/HardwareInterfaces/FTDI/FTDIInterface.cs +++ b/MediaSources/Minitiouner/HardwareInterfaces/FTDI/FTDIInterface.cs @@ -903,6 +903,10 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) return err; } + public override void hw_close() + { + } + byte ftdi_gpio_write_lowbyte(byte pin_id, bool pin_value) { Log.Information("Flow: FTDI GPIO Write: pin {0} -> value {1}", pin_id, pin_value); diff --git a/MediaSources/Minitiouner/HardwareInterfaces/MTHardwareInterface.cs b/MediaSources/Minitiouner/HardwareInterfaces/MTHardwareInterface.cs index 2f73566..9e25f01 100644 --- a/MediaSources/Minitiouner/HardwareInterfaces/MTHardwareInterface.cs +++ b/MediaSources/Minitiouner/HardwareInterfaces/MTHardwareInterface.cs @@ -21,6 +21,8 @@ public MTHardwareInterface() { } // TODO: change to more generic init public abstract byte hw_init(uint i2c_device, uint ts_device, uint ts_device2); + public abstract void hw_close(); + public abstract byte hw_set_polarization_supply(byte lnb_num, bool supply_enable, bool supply_horizontal); public abstract byte hw_ts_led(int led, bool setting); diff --git a/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs b/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs index 7090c46..3308153 100644 --- a/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs +++ b/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs @@ -91,6 +91,9 @@ public class PicoTunerInterface : MTHardwareInterface public override string GetName => "PicoTuner"; + private UsbContext usbContext; + private UsbDeviceCollection usbDeviceCollection; + private byte Receive_Data_i2c(uint BytesToRead) { uint QueueTimeOut = 0; @@ -650,8 +653,8 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) byte err = 0; - UsbContext usbContext = new UsbContext(); - var usbDeviceCollection = usbContext.List(); + usbContext = new UsbContext(); + usbDeviceCollection = usbContext.List(); i2c_pt_device = null; @@ -709,6 +712,12 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) return err; } + public override void hw_close() + { + usbDeviceCollection.Dispose(); + usbContext.Dispose(); + } + byte gpio_write(byte pin_id, bool pin_value) { Log.Information("Flow: GPIO Write: pin {0} -> value {1}", pin_id, pin_value); diff --git a/MediaSources/Minitiouner/MinitiounerSource.cs b/MediaSources/Minitiouner/MinitiounerSource.cs index d01c63c..6fa4c0a 100644 --- a/MediaSources/Minitiouner/MinitiounerSource.cs +++ b/MediaSources/Minitiouner/MinitiounerSource.cs @@ -778,6 +778,7 @@ public override void Close() ts_thread_t?.Abort(); ts_thread_2_t?.Abort(); nim_thread_t?.Abort(); + hardware_interface.hw_close(); } public override void ShowSettings() From c13b46417755d0eb90e061b375ef076e177dfd21 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Thu, 14 Nov 2024 18:10:32 +0100 Subject: [PATCH 94/98] Update MinitiounerSource.cs --- MediaSources/Minitiouner/MinitiounerSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaSources/Minitiouner/MinitiounerSource.cs b/MediaSources/Minitiouner/MinitiounerSource.cs index 6fa4c0a..5a9a90a 100644 --- a/MediaSources/Minitiouner/MinitiounerSource.cs +++ b/MediaSources/Minitiouner/MinitiounerSource.cs @@ -778,7 +778,7 @@ public override void Close() ts_thread_t?.Abort(); ts_thread_2_t?.Abort(); nim_thread_t?.Abort(); - hardware_interface.hw_close(); + hardware_interface?.hw_close(); } public override void ShowSettings() From 5f1271b6f67b91c2618f1d69eb36c9dac75bc7a3 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 15 Nov 2024 10:14:54 +0100 Subject: [PATCH 95/98] exception fixed. --- .../PicoTuner/PicoTunerInterface.cs | 18 ++++++++++++------ MediaSources/Minitiouner/MinitiounerSource.cs | 10 +++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs b/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs index 3308153..13df1fc 100644 --- a/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs +++ b/MediaSources/Minitiouner/HardwareInterfaces/PicoTuner/PicoTunerInterface.cs @@ -91,8 +91,8 @@ public class PicoTunerInterface : MTHardwareInterface public override string GetName => "PicoTuner"; - private UsbContext usbContext; - private UsbDeviceCollection usbDeviceCollection; + private UsbContext usbContext = null; + private UsbDeviceCollection usbDeviceCollection = null; private byte Receive_Data_i2c(uint BytesToRead) { @@ -670,7 +670,9 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) if (i2c_pt_device == null) { - Log.Information("pt device is null"); + Log.Error("pt device is null"); + usbDeviceCollection?.Dispose(); + usbContext?.Dispose(); return 1; } @@ -680,7 +682,10 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) } else { - Log.Information("Error o2c Device Open"); + Log.Error("Error o2c Device Open"); + i2c_pt_device?.Dispose(); + usbDeviceCollection?.Dispose(); + usbContext?.Dispose(); return 1; } @@ -714,8 +719,9 @@ public override byte hw_init(uint i2c_device, uint ts_device, uint ts_device2) public override void hw_close() { - usbDeviceCollection.Dispose(); - usbContext.Dispose(); + i2c_pt_device?.Dispose(); + usbDeviceCollection?.Dispose(); + usbContext?.Dispose(); } byte gpio_write(byte pin_id, bool pin_value) diff --git a/MediaSources/Minitiouner/MinitiounerSource.cs b/MediaSources/Minitiouner/MinitiounerSource.cs index 5a9a90a..ca81e1f 100644 --- a/MediaSources/Minitiouner/MinitiounerSource.cs +++ b/MediaSources/Minitiouner/MinitiounerSource.cs @@ -295,8 +295,12 @@ public override int Initialize(VideoChangeCallback VideoChangeCB, Control Parent case 2: hardware_interface = new PicoTunerInterface(); break; } - - return Initialize(VideoChangeCB, SourceStatusCB, false, "", "", "", Parent, mute_at_startup); + int retCode = Initialize(VideoChangeCB, SourceStatusCB, false, "", "", "", Parent, mute_at_startup); + if(retCode == -1) + { + hardware_interface = null; + } + return retCode; } public void nim_status_feedback(TunerStatus nim_status) @@ -672,7 +676,7 @@ private void hardware_init(bool manual, string i2c_serial, string ts_serial, str if (err != 0) { - Log.Information("Main: Error: FTDI Failed " + err.ToString()); + Log.Error("Main: Error: FTDI Failed " + err.ToString()); hardware_connected = false; return; } From 2db7f06aedfdf3cae4a0c5648d5df467a4f70ea1 Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Fri, 15 Nov 2024 10:25:54 +0100 Subject: [PATCH 96/98] show streaming and recording indicator on request of an OM I implemented streaming and recording indicator at streaminfo. --- MediaSources/Minitiouner/MinitiounerProperties.cs | 7 ++++++- MediaSources/OTSourceData.cs | 2 ++ MediaSources/Winterhill/WinterhillProperties.cs | 3 +++ Utilities/StreamInfoContainer.cs | 11 +++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/MediaSources/Minitiouner/MinitiounerProperties.cs b/MediaSources/Minitiouner/MinitiounerProperties.cs index a30c444..cab2e08 100644 --- a/MediaSources/Minitiouner/MinitiounerProperties.cs +++ b/MediaSources/Minitiouner/MinitiounerProperties.cs @@ -464,6 +464,7 @@ private void UpdateTunerProperties(TunerStatus new_status) source_data.mer = mer; source_data.db_margin = dbmargin; source_data.service_name = _tuner1_properties.GetValue("service_name"); + source_data.demod_locked = (new_status.T1P2_demod_status > 1); source_data.symbol_rate = (int)(new_status.T1P2_symbol_rate / 1000); if (_media_player.Count > 0) @@ -472,7 +473,8 @@ private void UpdateTunerProperties(TunerStatus new_status) source_data.volume = _media_player[0].GetVolume(); } - source_data.demod_locked = (new_status.T1P2_demod_status > 1); + source_data.streaming = _ts_streamers[0].stream; + source_data.recording = _ts_recorders[0].record; OnSourceData?.Invoke(0, source_data, "Tuner 1"); @@ -578,6 +580,9 @@ private void UpdateTunerProperties(TunerStatus new_status) source_data_2.volume = _media_player[1].GetVolume(); } + source_data_2.streaming = _ts_streamers[1].stream; + source_data_2.recording = _ts_recorders[1].record; + OnSourceData?.Invoke(1, source_data_2, "Tuner 2"); } diff --git a/MediaSources/OTSourceData.cs b/MediaSources/OTSourceData.cs index 4256a76..270f7c3 100644 --- a/MediaSources/OTSourceData.cs +++ b/MediaSources/OTSourceData.cs @@ -16,5 +16,7 @@ public class OTSourceData public int symbol_rate = 0; public string service_name = ""; public int volume = 0; + public bool streaming = false; + public bool recording = false; } } diff --git a/MediaSources/Winterhill/WinterhillProperties.cs b/MediaSources/Winterhill/WinterhillProperties.cs index 0188069..d235cbb 100644 --- a/MediaSources/Winterhill/WinterhillProperties.cs +++ b/MediaSources/Winterhill/WinterhillProperties.cs @@ -646,6 +646,9 @@ private void UpdateInfo(monitorMessage mm) source_data.volume = _media_player[c].GetVolume(); } + source_data.streaming = _streamer[c].stream; + source_data.recording = _recorders[c].record; + OnSourceData?.Invoke(c, source_data, "Tuner " + c.ToString()); } } diff --git a/Utilities/StreamInfoContainer.cs b/Utilities/StreamInfoContainer.cs index dba464a..d79eaea 100644 --- a/Utilities/StreamInfoContainer.cs +++ b/Utilities/StreamInfoContainer.cs @@ -87,9 +87,20 @@ protected override void OnPaint(PaintEventArgs pe) pe.Graphics.DrawString(audio_icon_high, emojiFont, Brushes.LimeGreen, new PointF(x_pos -5, 2)); else pe.Graphics.DrawString(audio_icon_mute, emojiFont, Brushes.IndianRed, new PointF(x_pos -5, 2)); + + x_pos += (int)pe.Graphics.MeasureString(audio_icon_mute, emojiFont).Width; } + if (last_info_data.streaming) + { + pe.Graphics.DrawString("U", font, Brushes.PaleTurquoise, new PointF(x_pos, y_pos)); + x_pos += (int)pe.Graphics.MeasureString("U ", font).Width; + } + if (last_info_data.recording) + { + pe.Graphics.DrawString("R", font, Brushes.PaleVioletRed, new PointF(x_pos, y_pos)); + } } From fed5de8d4af984d14b63878a484846dcfcdadeda Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 16 Nov 2024 14:49:56 +0100 Subject: [PATCH 97/98] align symbolrate to stop flickering of callsign --- ExtraFeatures/BATCSpectrum/signal.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ExtraFeatures/BATCSpectrum/signal.cs b/ExtraFeatures/BATCSpectrum/signal.cs index 4b94412..5c83fdd 100644 --- a/ExtraFeatures/BATCSpectrum/signal.cs +++ b/ExtraFeatures/BATCSpectrum/signal.cs @@ -114,7 +114,7 @@ public signal(object _list_lock) bool avoid_beacon = false; private Sig[] last_sig = new Sig[8]; //last tune signal - detail - private Sig[] next_sig = new Sig[8]; //last tune signal - detail + private Sig[] next_sig = new Sig[8]; //next tune signal - detail private DateTime[] last_tuned_time = new DateTime[8]; //time the last signal was tuned @@ -164,7 +164,7 @@ public Tuple tune(int mode, int time, int rx) { if (mode == 2) //auto timed { - //Log.Information(t.Seconds); + //Log.Information(t.Seconds.ToString()); if ((t.Minutes * 60) + t.Seconds > time) { //Log.Information("elapsed: " + rx.ToString()); @@ -201,7 +201,7 @@ public Tuple tune(int mode, int time, int rx) } } - // Log.Information("Count3:" + newSignals.Count().ToString()); + //Log.Information("Count3:" + newSignals.Count().ToString()); if (change) { last_sig[rx] = next_sig[rx]; @@ -242,7 +242,9 @@ public bool find_signal(Sig lastsig, int rx) public bool diff_signals(Sig lastsig, Sig next) { - // Log.Information(lastsig.frequency-next.frequency); + //Log.Information("diff_signals(): last QRG: " + lastsig.frequency.ToString() + ", next QRG: " + next.frequency.ToString()); + //Log.Information("diff_signals(): last SR: " + lastsig.sr.ToString() + ", next SR: " + next.sr.ToString()); + float span; bool diff = true; if (lastsig.sr < 0.070f | next.sr < 0.070f) @@ -253,7 +255,7 @@ public bool diff_signals(Sig lastsig, Sig next) { span = 0.075f; } - if (next.frequency > (lastsig.frequency - span) && next.frequency < (lastsig.frequency + span) && next.sr == lastsig.sr) // +/- span, signal freq varies! + if (next.frequency > (lastsig.frequency - span) && next.frequency < (lastsig.frequency + span) && align_symbolrate(next.sr) == lastsig.sr) // +/- span, signal freq varies! align_symbol new SR as it may vary! { diff = false; } @@ -263,7 +265,7 @@ public bool diff_signals(Sig lastsig, Sig next) public bool diff_signals(Sig sig, double frequency, float sr) { //debug(sig.frequency.ToString() + "," + frequency.ToString()); - //Log.Information(lastsig.frequency-next.frequency); + //Log.Information((sig.frequency - frequency).ToString()); float span; bool diff = true; if (sig.sr < 0.070f | sr < 0.070f) @@ -315,6 +317,7 @@ public void updateSignalList() { if (diff_signals(s, sl) == false) // same sig { + //debug("same signal"); found = true; break; } @@ -391,8 +394,9 @@ private Sig find_next(int rx) return newsig; } - public void updateCurrentSignal(string callsign, double freq, float sr) + public void updateCurrentSignal(string callsign, double freq, float _sr) { + float sr = align_symbolrate(_sr); lock (list_lock) { for (int x = 0; x < signals.Count; x++) From 912c9b1858508c6e9fc721a908179334bd7c8c8e Mon Sep 17 00:00:00 2001 From: "Martin, DL1RF" Date: Sat, 16 Nov 2024 15:19:35 +0100 Subject: [PATCH 98/98] use beacon QRG - offset to setup first tuning QRG This will respect a changed default offset in settings. --- MediaSources/Minitiouner/MinitiounerSource.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaSources/Minitiouner/MinitiounerSource.cs b/MediaSources/Minitiouner/MinitiounerSource.cs index ca81e1f..910dd32 100644 --- a/MediaSources/Minitiouner/MinitiounerSource.cs +++ b/MediaSources/Minitiouner/MinitiounerSource.cs @@ -521,12 +521,12 @@ private int Initialize(VideoChangeCallback VideoChangeCB, SourceStatusCallback S break; } - current_frequency_0 = 741525; - current_frequency_1 = 741525; - current_offset_0 = _settings.Offset1; current_offset_1 = _settings.Offset2; + current_frequency_0 = 10491500 - current_offset_0; + current_frequency_1 = 10491500 - current_offset_1; + current_sr_0 = 1500; current_sr_1 = 1500;