HamBook – Diff between revs 10 and 11
?pathlinks?
Rev 10 | Rev 11 | |||
---|---|---|---|---|
Line 86... | Line 86... | |||
86 | |
86 | |
|
Line 87... | Line 87... | |||
87 | _catAssemblies = InitializeAssemblies(_serialPort); |
87 | _catAssemblies = InitializeAssemblies(_serialPort); |
|
88 | |
88 | |
|
89 | try |
- | ||
90 | { |
- | ||
91 | await _catAssemblies.CatWriteAsync<InformationState>("AI", new object[] { InformationState.OFF }, _cancellationToken); |
- | ||
92 | } |
- | ||
93 | finally |
- | ||
94 | { |
- | ||
95 | |
- | ||
96 | } |
- | ||
97 | |
- | ||
98 | try |
89 | try |
|
99 | { |
90 | { |
|
100 | switch (await _catAssemblies.CatReadAsync<PowerState>("PS", new object[] { }, _cancellationToken)) |
91 | switch (await _catAssemblies.CatReadAsync<PowerState>("PS", new object[] { }, _cancellationToken)) |
|
101 | { |
92 | { |
|
102 | case PowerState.ON: |
93 | case PowerState.ON: |
|
Line 198... | Line 189... | |||
198 | // Commit the configuration. |
189 | // Commit the configuration. |
|
199 | _changedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1), |
190 | _changedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1), |
|
200 | async () => { |
191 | async () => { |
|
201 | await SaveConfiguration(); |
192 | await SaveConfiguration(); |
|
Line -... | Line 193... | |||
- | 193 | |
||
- | 194 | if(_bandScan != null) |
||
- | 195 | { |
||
- | 196 | await _bandScan.Stop(); |
||
- | 197 | _bandScan = null; |
||
- | 198 | } |
||
- | 199 | |
||
202 | |
200 | |
|
Line 203... | Line 201... | |||
203 | Miscellaneous.LaunchOnBootSet(Configuration.LaunchOnBoot); |
201 | Miscellaneous.LaunchOnBootSet(Configuration.LaunchOnBoot); |
|
Line 204... | Line 202... | |||
204 | |
202 | |
|
Line 205... | Line 203... | |||
205 | _serialPort = InitializeSerialPort(Configuration); |
203 | _serialPort = InitializeSerialPort(Configuration); |
|
206 | |
204 | |
|
207 | _catAssemblies = InitializeAssemblies(_serialPort); |
- | ||
208 | |
- | ||
209 | try |
- | ||
210 | { |
- | ||
211 | await _catAssemblies.CatWriteAsync<InformationState>("AI", new object[] { InformationState.OFF }, _cancellationToken); |
- | ||
212 | } |
- | ||
213 | finally |
- | ||
214 | { |
- | ||
215 | |
- | ||
216 | } |
205 | _catAssemblies = InitializeAssemblies(_serialPort); |
|
217 | |
206 | |
|
218 | try |
207 | try |
|
219 | { |
208 | { |
|
220 | switch (await _catAssemblies.CatReadAsync<PowerState>("PS", new object[] { }, _cancellationToken)) |
209 | switch (await _catAssemblies.CatReadAsync<PowerState>("PS", new object[] { }, _cancellationToken)) |
|
Line 288... | Line 277... | |||
288 | { |
277 | { |
|
289 | try |
278 | try |
|
290 | { |
279 | { |
|
291 | await _catAssemblies.CatWriteAsync<InformationState>("AI", new object[] { InformationState.OFF }, _cancellationToken); |
280 | await _catAssemblies.CatWriteAsync<InformationState>("AI", new object[] { InformationState.OFF }, _cancellationToken); |
|
Line 292... | Line 281... | |||
292 | |
281 | |
|
293 | if (!_catAssemblies.CatRead<bool>("ID", new object[] { })) |
- | ||
294 | { |
- | ||
295 | return false; |
- | ||
296 | } |
282 | return await _catAssemblies.CatReadAsync<bool>("ID", new object[] { }, _cancellationToken); |
|
297 | } |
283 | } |
|
298 | catch(Exception exception) |
284 | catch(Exception exception) |
|
299 | { |
285 | { |
|
- | 286 | Log.Error(exception, Resources.Unable_to_initialize_radio); |
||
300 | Log.Error(exception, Resources.Unable_to_initialize_radio); |
287 | |
|
301 | return false; |
288 | return false; |
|
302 | } |
- | ||
303 | |
- | ||
304 | return true; |
289 | } |
|
Line 305... | Line 290... | |||
305 | } |
290 | } |
|
306 | |
291 | |
|
307 | private CatAssemblies InitializeAssemblies(SerialPortStream serialPort) |
292 | private CatAssemblies InitializeAssemblies(SerialPortStream serialPort) |
|
Line 540... | Line 525... | |||
540 | #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
525 | #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
|
541 | _bandScan.Start(step, pause, Configuration.ScanDetectPause); |
526 | _bandScan.Start(step, pause, Configuration.ScanDetectPause); |
|
542 | #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
527 | #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
|
543 | } |
528 | } |
|
Line 544... | Line 529... | |||
544 | |
529 | |
|
545 | private async void modeToolStripMenuItem_DropDownOpened(object sender, EventArgs e) |
530 | private void modeToolStripMenuItem_DropDownOpened(object sender, EventArgs e) |
|
546 | { |
531 | { |
|
547 | try |
532 | Task.Delay(TimeSpan.FromSeconds(1), _cancellationToken).ContinueWith(async task => |
|
548 | { |
- | ||
549 | var mode = await _catAssemblies.CatReadAsync<RadioMode>("MD", new object[] { }, _cancellationToken); |
- | ||
550 | toolStripComboBox1.Text = mode; |
533 | { |
|
551 | } |
- | ||
552 | catch (Exception exception) |
534 | try |
|
553 | { |
535 | { |
|
554 | Log.Error(exception, Resources.Failed_to_read_radio_mode); |
- | ||
Line 555... | Line 536... | |||
555 | } |
536 | var mode = await _catAssemblies.CatReadAsync<RadioMode>("MD", new object[] { }, _cancellationToken); |
|
556 | |
537 | |
|
557 | try |
538 | contextMenuStrip1.InvokeIfRequired(contextMenuStrip => |
|
558 | { |
539 | { |
|
559 | var fa = await _catAssemblies.CatReadAsync<int>("FA", new object[] { }, _cancellationToken); |
540 | toolStripComboBox1.Text = mode; |
|
560 | scrollableToolStripComboBox1.Text = $"{fa}"; |
541 | }); |
|
561 | } |
542 | } |
|
562 | catch (Exception exception) |
543 | catch (Exception exception) |
|
563 | { |
544 | { |
|
Line 564... | Line 545... | |||
564 | Log.Error(exception, Resources.Failed_to_read_VFO_A); |
545 | Log.Error(exception, Resources.Failed_to_read_radio_mode); |
|
565 | } |
546 | } |
|
566 | |
547 | |
|
567 | try |
- | ||
568 | { |
- | ||
569 | var fb = await _catAssemblies.CatReadAsync<int>("FB", new object[] { }, _cancellationToken); |
- | ||
570 | scrollableToolStripComboBox2.Text = $"{fb}"; |
- | ||
571 | } |
- | ||
572 | catch (Exception exception) |
- | ||
Line -... | Line 548... | |||
- | 548 | try |
||
- | 549 | { |
||
- | 550 | var fa = await _catAssemblies.CatReadAsync<int>("FA", new object[] { }, _cancellationToken); |
||
- | 551 | |
||
- | 552 | contextMenuStrip1.InvokeIfRequired(contextMenuStrip => |
||
- | 553 | { |
||
- | 554 | scrollableToolStripComboBox1.Text = $"{fa}"; |
||
- | 555 | |
||
- | 556 | }); |
||
- | 557 | |
||
- | 558 | } |
||
- | 559 | catch (Exception exception) |
||
- | 560 | { |
||
- | 561 | Log.Error(exception, Resources.Failed_to_read_VFO_A); |
||
- | 562 | } |
||
- | 563 | |
||
- | 564 | try |
||
- | 565 | { |
||
- | 566 | var fb = await _catAssemblies.CatReadAsync<int>("FB", new object[] { }, _cancellationToken); |
||
- | 567 | |
||
- | 568 | contextMenuStrip1.InvokeIfRequired(contextMenuStrip => |
||
- | 569 | { |
||
- | 570 | scrollableToolStripComboBox2.Text = $"{fb}"; |
||
- | 571 | |
||
- | 572 | }); |
||
- | 573 | } |
||
- | 574 | catch (Exception exception) |
||
573 | { |
575 | { |
|
Line 574... | Line 576... | |||
574 | Log.Error(exception, Resources.Failed_to_read_VFO_B); |
576 | Log.Error(exception, Resources.Failed_to_read_VFO_B); |
|
575 | } |
577 | } |
|
576 | |
578 | }, _cancellationToken); |