HamBook – Diff between revs 39 and 41

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 39 Rev 41
Line 39... Line 39...
39 public partial class Form1 : Form 39 public partial class Form1 : Form
40 { 40 {
41 private ScheduledContinuation _changedConfigurationContinuation; 41 private ScheduledContinuation _changedConfigurationContinuation;
42 private ScheduledContinuation _squelchScheduledContinuation; 42 private ScheduledContinuation _squelchScheduledContinuation;
43 private ScheduledContinuation _powerScheduledContinuation; 43 private ScheduledContinuation _powerScheduledContinuation;
-   44 private MemoryBanks _memoryBanks;
Line 44... Line 45...
44   45  
45 private Configuration.Configuration Configuration { get; set; } 46 private Configuration.Configuration Configuration { get; set; }
46 private SerialPortStream _serialPort; 47 private SerialPortStream _serialPort;
47 private LogMemorySink _memorySink; 48 private LogMemorySink _memorySink;
Line 62... Line 63...
62 private string _storedMemoryChannelLocation; 63 private string _storedMemoryChannelLocation;
63 private MemoryChannel _tickerTextMemoryChannel; 64 private MemoryChannel _tickerTextMemoryChannel;
64 private Task _tickerTask; 65 private Task _tickerTask;
65 private volatile bool _tickerTaskRunning; 66 private volatile bool _tickerTaskRunning;
Line 66... Line 67...
66   67  
67 private ConcurrentDictionary<int, MemoryChannel> _memoryChannelStore = new ConcurrentDictionary<int, MemoryChannel>(); 68 private ConcurrentDictionary<string, MemoryChannel> _memoryChannelStore = new ConcurrentDictionary<string, MemoryChannel>();
Line 68... Line 69...
68 private MemoryTune _memoryTune; 69 private MemoryTune _memoryTune;
Line 69... Line 70...
69   70  
Line 77... Line 78...
77 _changedConfigurationContinuation = new ScheduledContinuation(); 78 _changedConfigurationContinuation = new ScheduledContinuation();
Line 78... Line 79...
78   79  
79 _squelchScheduledContinuation = new ScheduledContinuation(); 80 _squelchScheduledContinuation = new ScheduledContinuation();
Line -... Line 81...
-   81 _powerScheduledContinuation = new ScheduledContinuation();
80 _powerScheduledContinuation = new ScheduledContinuation(); 82  
Line 81... Line 83...
81   83 _memoryBanks = MemoryBanks.Create("Yaesu FT-891");
82 } 84 }
83   85  
Line 134... Line 136...
134 catch(Exception exception) 136 catch(Exception exception)
135 { 137 {
136 Log.Error(exception, Resources.Failed_to_read_power_state); 138 Log.Error(exception, Resources.Failed_to_read_power_state);
137 } 139 }
Line 138... Line 140...
138   140  
139 var memoryBankQueue = new ConcurrentQueue<int>(); 141 var memoryBankQueue = new ConcurrentQueue<string>();
Line 140... Line 142...
140 var memoryBankTaskCompletionSource = new TaskCompletionSource<bool>(); 142 var memoryBankTaskCompletionSource = new TaskCompletionSource<bool>();
141   143  
142 async void IdleHandler(object idleHandlerSender, EventArgs idleHandlerArgs) 144 async void IdleHandler(object idleHandlerSender, EventArgs idleHandlerArgs)
Line 150... Line 152...
150 System.Windows.Forms.Application.Idle -= IdleHandler; 152 System.Windows.Forms.Application.Idle -= IdleHandler;
Line 151... Line 153...
151   153  
152 return; 154 return;
Line 153... Line -...
153 } -  
154   -  
155 var location = $"{memoryBank:000}"; 155 }
Line 156... Line 156...
156   156  
Line 157... Line 157...
157 scrollableToolStripComboBox12.Items.Add(location); 157 scrollableToolStripComboBox12.Items.Add(memoryBank);
158   158  
159 MemoryChannel memoryChannel = new MemoryChannel(); 159 MemoryChannel memoryChannel = new MemoryChannel();
Line 160... Line 160...
160   160  
Line 161... Line 161...
161 try 161 try
162 { 162 {
163 memoryChannel = await _catAssemblies.CatReadAsync<MemoryChannel>("MT", new object[] { location }, _cancellationToken); 163 memoryChannel = await _catAssemblies.CatReadAsync<MemoryChannel>("MT", new object[] { memoryBank }, _cancellationToken);
164 164
Line 182... Line 182...
182 } 182 }
Line 183... Line 183...
183   183  
184 System.Windows.Forms.Application.Idle += IdleHandler; 184 System.Windows.Forms.Application.Idle += IdleHandler;
185 try 185 try
186 { 186 {
187 foreach (var memoryBank in Enumerable.Range(1, 99)) 187 foreach (var memoryBank in _memoryBanks.GetMemoryBanks())
188 { 188 {
189 memoryBankQueue.Enqueue(memoryBank); 189 memoryBankQueue.Enqueue(memoryBank);
Line 190... Line 190...
190 } 190 }
Line 668... Line 668...
668 Log.Error(exception, Resources.Failed_to_read_VFO_B); 668 Log.Error(exception, Resources.Failed_to_read_VFO_B);
669 } 669 }
Line 670... Line 670...
670   670  
671 try 671 try
672 { 672 {
Line 673... Line 673...
673 var mc = await _catAssemblies.CatReadAsync<int>("MC", new object[] { }, _cancellationToken); 673 var mc = await _catAssemblies.CatReadAsync<string>("MC", new object[] { }, _cancellationToken);
674   674  
675 contextMenuStrip1.InvokeIfRequired(contextMenuStrip => 675 contextMenuStrip1.InvokeIfRequired(contextMenuStrip =>
Line 676... Line 676...
676 { 676 {
677 scrollableToolStripComboBox5.Text = $"{mc:000}"; 677 scrollableToolStripComboBox5.Text = mc;
678   678  
679 if (_memoryChannelStore.TryGetValue(mc, out var memoryChannel)) 679 if (_memoryChannelStore.TryGetValue(mc, out var memoryChannel))
Line 900... Line 900...
900   900  
901 private async void scrollableToolStripComboBox5_SelectedIndexChanged(object sender, EventArgs e) 901 private async void scrollableToolStripComboBox5_SelectedIndexChanged(object sender, EventArgs e)
902 { 902 {
Line 903... Line 903...
903 var toolStripComboBox = (ScrollableToolStripComboBox)sender; 903 var toolStripComboBox = (ScrollableToolStripComboBox)sender;
-   904  
-   905 var channel = toolStripComboBox.Text;
904   906  
905 if (int.TryParse(toolStripComboBox.Text, out var channel)) 907 if (!string.IsNullOrEmpty(channel))
906 { 908 {
907 if (_memoryChannelStore.TryGetValue(channel, out var memoryChannel)) 909 if (_memoryChannelStore.TryGetValue(channel, out var memoryChannel))
908 { 910 {
909 try 911 try
910 { 912 {
911 using (var soundPlayer = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("HamBook.Effects.pot.wav"))) 913 using (var soundPlayer = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("HamBook.Effects.pot.wav")))
Line 912... Line 914...
912 { 914 {
Line 913... Line 915...
913 await _catAssemblies.CatWriteAsync<int>("MC", new object[] { channel }, _cancellationToken); 915 await _catAssemblies.CatWriteAsync<string>("MC", new object[] { channel }, _cancellationToken);
Line 1384... Line 1386...
1384   1386  
1385 private async void toolStripMenuItem35_Click(object sender, EventArgs e) 1387 private async void toolStripMenuItem35_Click(object sender, EventArgs e)
1386 { 1388 {
Line 1387... Line 1389...
1387 var scrollableToolStripComboBox = scrollableToolStripComboBox12; 1389 var scrollableToolStripComboBox = scrollableToolStripComboBox12;
-   1390  
1388   1391 var channel = scrollableToolStripComboBox.Text;
1389 if (int.TryParse(scrollableToolStripComboBox.Text, out var channel)) 1392 if (!string.IsNullOrEmpty(channel))
1390 { 1393 {
1391 if (!_memoryChannelStore.TryGetValue(channel, out var memoryChannel)) 1394 if (!_memoryChannelStore.TryGetValue(channel, out var memoryChannel))
1392 { 1395 {
1393 memoryChannel = new MemoryChannel(); 1396 memoryChannel = new MemoryChannel();
1394 memoryChannel.CurrentLocation = $"{channel:000}"; 1397 memoryChannel.CurrentLocation = channel;
Line 1395... Line 1398...
1395 memoryChannel.MemoryRadioMode = toolStripComboBox1.Text; 1398 memoryChannel.MemoryRadioMode = toolStripComboBox1.Text;
1396 } 1399 }
Line 1421... Line 1424...
1421   1424  
1422 private void scrollableToolStripComboBox12_SelectedIndexChanged(object sender, EventArgs e) 1425 private void scrollableToolStripComboBox12_SelectedIndexChanged(object sender, EventArgs e)
1423 { 1426 {
Line 1424... Line 1427...
1424 var toolStripComboBox = (ScrollableToolStripComboBox)sender; 1427 var toolStripComboBox = (ScrollableToolStripComboBox)sender;
-   1428  
1425   1429 var channel = toolStripComboBox.Text;
1426 if (int.TryParse(toolStripComboBox.Text, out var channel)) 1430 if (!string.IsNullOrEmpty(channel))
1427 { 1431 {
1428 if (_memoryChannelStore.TryGetValue(channel, out var memoryChannel)) 1432 if (_memoryChannelStore.TryGetValue(channel, out var memoryChannel))
1429 { 1433 {