Skip to content

Commit f5421f0

Browse files
committed
commandline options, fixed sr selection on winterhill variant
1 parent 52f4131 commit f5421f0

File tree

10 files changed

+232
-32
lines changed

10 files changed

+232
-32
lines changed

ExtraFeatures/DATVReporter/DATVReporter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void ShowSettings()
4141

4242
if (_settings_form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
4343
{
44-
_datv_reporter_settings.callsign = _settings_form.txtCallsign.Text;
44+
_datv_reporter_settings.callsign = _settings_form.txtCallsign.Text.ToUpper();
4545
_datv_reporter_settings.grid_locator = _settings_form.txtGridLocator.Text;
4646
_datv_reporter_settings.service_url = _settings_form.txtServiceUrl.Text;
4747

@@ -146,6 +146,7 @@ public bool Connect()
146146

147147
public void Close()
148148
{
149+
_timer?.Stop();
149150
_websocket?.Close();
150151
}
151152

MainForm.cs

Lines changed: 191 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public partial class MainForm : Form, IMessageFilter
5656
private MainSettings _settings;
5757
private SettingsManager<MainSettings> _settingsManager;
5858

59+
60+
5961
SettingsManager<List<StoredFrequency>> frequenciesManager;
6062

6163
List<StoredFrequency> stored_frequencies = new List<StoredFrequency>();
@@ -92,7 +94,180 @@ public void UpdateInfo(StreamInfoContainer info_object, OTSourceData info)
9294

9395
}
9496

95-
public MainForm()
97+
void ParseCommandLineOptions(string[] args)
98+
{
99+
int i = 0;
100+
101+
while ( i < args.Length )
102+
{
103+
switch (args[i])
104+
{
105+
case "--autoconnect":
106+
_settings.auto_connect = true;
107+
break;
108+
109+
case "--noconnect":
110+
_settings.auto_connect = false;
111+
break;
112+
113+
case "--enablebatcspectrum":
114+
_settings.enable_spectrum_checkbox = true;
115+
break;
116+
117+
case "--disablebatcspectrum":
118+
_settings.enable_spectrum_checkbox = false;
119+
break;
120+
121+
case "--enablebatcchat":
122+
_settings.enable_chatform_checkbox = true;
123+
break;
124+
125+
case "--disablebatcchat":
126+
_settings.enable_chatform_checkbox = false;
127+
break;
128+
129+
case "--enablemqtt":
130+
_settings.enable_mqtt_checkbox = true;
131+
break;
132+
133+
case "--disablemqtt":
134+
_settings.enable_mqtt_checkbox = false;
135+
break;
136+
137+
case "--enablequicktune":
138+
_settings.enable_quicktune_checkbox = true;
139+
break;
140+
141+
case "--disablequicktune":
142+
_settings.enable_quicktune_checkbox = false;
143+
break;
144+
145+
case "--enabledatvreporter":
146+
_settings.enable_datvreporter_checkbox = true;
147+
break;
148+
149+
case "--disabledatvreporter":
150+
_settings.enable_datvreporter_checkbox = false;
151+
break;
152+
153+
case "--hideproperties":
154+
_settings.hide_properties = true;
155+
break;
156+
157+
case "--showproperties":
158+
_settings.hide_properties = false;
159+
break;
160+
161+
case "--hidevideoinfo":
162+
_settings.show_video_overlay = false;
163+
break;
164+
165+
case "--showvideoinfo":
166+
_settings.show_video_overlay = true;
167+
break;
168+
169+
case "--windowwidth":
170+
171+
int new_window_width = 0;
172+
173+
if (int.TryParse(args[i+1], out new_window_width))
174+
{
175+
_settings.gui_window_width = new_window_width;
176+
}
177+
else
178+
{
179+
Log.Error(args[i + 1] + " is not a valid window width. Integer Expected");
180+
}
181+
182+
i += 1;
183+
184+
break;
185+
186+
case "--windowheight":
187+
188+
int new_window_height = 0;
189+
190+
if (int.TryParse(args[i + 1], out new_window_height))
191+
{
192+
_settings.gui_window_height = new_window_height;
193+
}
194+
else
195+
{
196+
Log.Error(args[i + 1] + " is not a valid window height. Integer Expected");
197+
}
198+
199+
i += 1;
200+
201+
break;
202+
203+
case "--windowx":
204+
int new_window_x = 0;
205+
206+
if (int.TryParse(args[i + 1], out new_window_x))
207+
{
208+
_settings.gui_window_x = new_window_x;
209+
}
210+
else
211+
{
212+
Log.Error(args[i + 1] + " is not a valid window x. Integer Expected");
213+
}
214+
215+
i += 1;
216+
217+
break;
218+
219+
case "--windowy":
220+
int new_window_y = 0;
221+
222+
if (int.TryParse(args[i + 1], out new_window_y))
223+
{
224+
_settings.gui_window_y = new_window_y;
225+
}
226+
else
227+
{
228+
Log.Error(args[i + 1] + " is not a valid window y. Integer Expected");
229+
}
230+
231+
i += 1;
232+
233+
break;
234+
235+
236+
case "--defaultsource":
237+
238+
int new_default_source = 0;
239+
240+
if (int.TryParse(args[i + 1], out new_default_source))
241+
{
242+
if (new_default_source < 3 && new_default_source >= 0)
243+
{
244+
_settings.default_source = new_default_source;
245+
}
246+
else
247+
{
248+
Log.Error(args[i + 1] + " is not a valid default source parameter. 0-2 Expected");
249+
}
250+
}
251+
else
252+
{
253+
Log.Error(args[i + 1] + " is not a valid default source parameter. 0-2 Expected");
254+
}
255+
256+
i += 1;
257+
258+
break;
259+
260+
default:
261+
Log.Warning("Unknown command line param: " + args[i]);
262+
break;
263+
}
264+
265+
// grab next param
266+
i += 1;
267+
}
268+
}
269+
270+
public MainForm(string[] args)
96271
{
97272
ThreadPool.GetMinThreads(out int workers, out int ports);
98273
ThreadPool.SetMinThreads(workers + 6, ports + 6);
@@ -105,6 +280,9 @@ public MainForm()
105280
_settingsManager = new SettingsManager<MainSettings>("open_tuner_settings");
106281
_settings = (_settingsManager.LoadSettings(_settings));
107282

283+
// parse command line options
284+
ParseCommandLineOptions(args);
285+
108286
//setup
109287
splitContainer2.Panel2Collapsed = true;
110288
splitContainer2.Panel2.Enabled = false;
@@ -426,22 +604,16 @@ private void Form1_Load(object sender, EventArgs e)
426604
}
427605

428606

429-
/*
430-
// mqtt client
431-
setting_enable_mqtt = false;
432-
if (setting_enable_mqtt)
607+
// auto connect if specified
608+
if (_settings.auto_connect)
433609
{
434-
mqtt_client = new MqttManager(setting_mqtt_broker_host, setting_mqtt_broker_port, setting_mqtt_parent_topic);
435-
mqtt_client.OnMqttMessageReceived += Mqtt_client_OnMqttMessageReceived;
436-
437-
// pluto - requires mqtt
438-
if (setting_enable_pluto)
439-
{
440-
pluto_client = new F5OEOPlutoControl(mqtt_client);
441-
plutoToolStripMenuItem.Visible = true;
442-
}
610+
source_connected = ConnectSelectedSource();
443611
}
444-
*/
612+
613+
614+
615+
// hide/show video overlay
616+
445617
}
446618

447619
private void Batc_spectrum_OnSignalSelected(int Receiver, uint Freq, uint SymbolRate)
@@ -516,7 +688,7 @@ private OTMediaPlayer ConfigureVideoPlayer(int nr, int preference, bool seperate
516688
video_volume_display = new VolumeInfoContainer();
517689
video_volume_display.Tag = nr;
518690

519-
video_info_display = new StreamInfoContainer();
691+
video_info_display = new StreamInfoContainer(_settings.show_video_overlay);
520692
video_info_display.Tag = nr;
521693

522694

@@ -782,6 +954,9 @@ private bool ConnectSelectedSource()
782954
//toolstripConnectToggle.Text = "Disconnect Source";
783955
toolstripConnectToggle.Visible = false;
784956

957+
// hide/show panel
958+
TogglePropertiesPanel(_settings.hide_properties);
959+
785960
return true;
786961
}
787962

MainSettings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public class MainSettings
2222
public int default_source = 0;
2323
public bool mute_at_startup = true;
2424

25-
// future
2625
public bool auto_connect = false;
2726

27+
public bool hide_properties = false; // can also be toggled with CTRL-P
28+
public bool show_video_overlay = true;
29+
2830
public int[] mediaplayer_preferences = { 0, 1, 1, 1 };
2931
public bool[] mediaplayer_windowed = { false, false, false, false };
3032
public string[] streamer_udp_hosts = { "127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1" };

MediaSources/Longmynd/LongmyndProperties.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public enum LongmyndPropertyCommands
3030
LNBB_OFF,
3131
LNBB_VERTICAL,
3232
LNBB_HORIZONTAL,
33-
SETOFFSET
33+
SETOFFSET,
34+
SETSYMBOLRATE
3435
}
3536

3637
public partial class LongmyndSource

MediaSources/Winterhill/WinterhillProperties.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Globalization;
1313
using System.Timers;
1414
using System.Runtime.ConstrainedExecution;
15+
using opentuner.MediaSources.Minitiouner;
1516

1617
namespace opentuner.MediaSources.Winterhill
1718
{
@@ -67,7 +68,7 @@ private bool BuildSourceProperties()
6768
_tuner_properties[c].AddItem("frequency", "Frequency" ,_genericContextStrip);
6869
_tuner_properties[c].AddItem("offset", "Freq Offset", _genericContextStrip);
6970
_tuner_properties[c].AddItem("nim_frequency", "Nim Frequency");
70-
_tuner_properties[c].AddItem("symbol_rate", "Symbol Rate / Modcod");
71+
_tuner_properties[c].AddItem("symbol_rate", "Symbol Rate / Modcod", _genericContextStrip);
7172
_tuner_properties[c].AddItem("modcod", "Modcod");
7273
_tuner_properties[c].AddItem("service_name", "Service Name");
7374
_tuner_properties[c].AddItem("service_name_provider", "Service Name Provider");
@@ -143,6 +144,12 @@ private void _genericContextStrip_Opening(object sender, System.ComponentModel.C
143144

144145
switch (contextMenuStrip.SourceControl.Name)
145146
{
147+
case "symbol_rate":
148+
uint[] symbol_rates = new uint[] { 2000, 1500, 1000, 500, 333, 250, 125, 66 };
149+
foreach (uint rate in symbol_rates)
150+
contextMenuStrip.Items.Add(ConfigureMenuItem(rate.ToString(), LongmyndPropertyCommands.SETSYMBOLRATE, new int[] { (int)contextMenuStrip.SourceControl.Tag, (int)rate }));
151+
break;
152+
146153
case "hw_lnba":
147154
contextMenuStrip.Items.Add(ConfigureMenuItem("OFF", LongmyndPropertyCommands.LNBA_OFF, new int[] { 0, 0 }));
148155
contextMenuStrip.Items.Add(ConfigureMenuItem("Switch Vertical", LongmyndPropertyCommands.LNBA_VERTICAL, new int[] { 0, 0 }));
@@ -268,6 +275,12 @@ private void properties_OnPropertyMenuSelect(LongmyndPropertyCommands command, i
268275
SetFrequency(tuner, (uint)_current_frequency[tuner], (uint)_current_sr[tuner], false);
269276
break;
270277

278+
case LongmyndPropertyCommands.SETSYMBOLRATE:
279+
tuner = option[0];
280+
var new_rate = option[1];
281+
SetFrequency(tuner, (uint)_current_frequency[option[0]], (uint)new_rate, false);
282+
break;
283+
271284
case LongmyndPropertyCommands.SETFREQUENCY:
272285
tuner = option[0];
273286
_tuner_forms[tuner].ShowTuner(_current_frequency[tuner], _current_sr[tuner], (int)_current_offset[tuner]);

MediaSources/Winterhill/WinterhillWS.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,18 @@ private void Monitorws_OnMessage(object sender, MessageEventArgs e)
123123
public void DisconnectWebsockets()
124124
{
125125
_connected = false;
126-
if (monitorWS.IsAlive)
127-
monitorWS.Close();
128-
if (controlWS.IsAlive)
129-
controlWS.Close();
126+
127+
if (monitorWS != null)
128+
{
129+
if (monitorWS.IsAlive)
130+
monitorWS?.Close();
131+
}
132+
133+
if (controlWS != null)
134+
{
135+
if (controlWS.IsAlive)
136+
controlWS?.Close();
137+
}
130138
}
131139
}
132140

Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static class Program
1414
/// The main entry point for the application.
1515
/// </summary>
1616
[STAThread]
17-
static void Main()
17+
static void Main(string[] args)
1818
{
1919

2020
Log.Logger = new LoggerConfiguration()
@@ -44,7 +44,7 @@ static void Main()
4444

4545
Application.EnableVisualStyles();
4646
Application.SetCompatibleTextRenderingDefault(false);
47-
Application.Run(new MainForm());
47+
Application.Run(new MainForm(args));
4848
}
4949
catch (Exception ex)
5050
{

Resources/BuildDate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024/07/12 7:11:35.25
1+
2024/07/13 10:05:36.10

Utilities/StreamInfoContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class StreamInfoContainer : Label
1414
{
1515
OTSourceData last_info_data = null;
1616

17-
public StreamInfoContainer()
17+
public StreamInfoContainer(bool show)
1818
{
1919
BackColor = Color.Black;
2020
Dock = DockStyle.Top;
2121
Height = 30;
22-
Visible = false;
22+
Visible = show;
2323
}
2424

2525
public void UpdateInfo(OTSourceData info_data)

0 commit comments

Comments
 (0)