HamBook – Blame information for rev 7
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using HamBook.Radios.Generic; |
3 | office | 2 | using HamBook.Radios.Generic.CAT; |
1 | office | 3 | using System; |
4 | using System.Collections.Generic; |
||
5 | using System.IO.Ports; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Text.RegularExpressions; |
||
9 | using System.Threading.Tasks; |
||
10 | using static HamBook.Radios.Yaesu.FT_891.Constants; |
||
11 | |||
12 | namespace HamBook.Radios.Yaesu.FT_891 |
||
13 | { |
||
14 | [Radio("Yaesu FT-891")] |
||
3 | office | 15 | public class SC : HamBook.Radios.Generic.CAT.SC |
1 | office | 16 | { |
17 | private static readonly Regex readRegex = new Regex(@"^SC(?<state>[0,1,2])$", RegexOptions.Compiled); |
||
18 | |||
19 | public SC(SerialPort serialPort) : base(serialPort) |
||
20 | { |
||
21 | } |
||
22 | |||
23 | public override ScanState Read() |
||
24 | { |
||
3 | office | 25 | SerialPort.Write($"{Name}{Generic.Constants.EOT}"); |
26 | var result = SerialPort.ReadTo(Generic.Constants.EOT); |
||
1 | office | 27 | var match = readRegex.Match(result); |
28 | var state = char.Parse(match.Result("${state}")); |
||
29 | switch(state) |
||
30 | { |
||
31 | case '0': |
||
32 | return ScanState.OFF; |
||
33 | case '1': |
||
34 | return ScanState.UP; |
||
35 | case '2': |
||
36 | return ScanState.DOWN; |
||
37 | } |
||
38 | |||
39 | return ScanState.NONE; |
||
40 | } |
||
41 | |||
7 | office | 42 | public override bool Set(ScanState state) |
1 | office | 43 | { |
44 | switch(state) |
||
45 | { |
||
46 | case ScanState.OFF: |
||
3 | office | 47 | SerialPort.Write($"{Name}0{Generic.Constants.EOT}"); |
1 | office | 48 | break; |
49 | case ScanState.UP: |
||
3 | office | 50 | SerialPort.Write($"{Name}1{Generic.Constants.EOT}"); |
1 | office | 51 | break; |
52 | case ScanState.DOWN: |
||
3 | office | 53 | SerialPort.Write($"{Name}2{Generic.Constants.EOT}"); |
1 | office | 54 | break; |
55 | } |
||
7 | office | 56 | |
57 | return Read() == state; |
||
1 | office | 58 | } |
59 | |||
60 | |||
61 | } |
||
62 | } |