HamBook – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Collections.Generic;
3 using System.Drawing;
4 using System.IO.Ports;
5 using System.Linq;
6 using System.Text;
7 using System.Text.RegularExpressions;
8 using System.Threading.Tasks;
9 using static HamBook.Radios.Yaesu.FT_891.Constants;
10  
11 namespace HamBook.Radios.Yaesu.FT_891
12 {
13 [Radio("Yaesu FT-891")]
14 public class FA : Generic.CAT.FA
15 {
16 private static readonly Regex readRegex = new Regex(@"^FA(?<frequency>[0-9]{9})$", RegexOptions.Compiled);
17  
18 public FA(SerialPort serialPort) : base(serialPort)
19 {
20 }
21  
22 public override void Set(int param)
23 {
24 var frequency = param.ToString("000000000");
25  
26 SerialPort.Write($"{Name}{frequency}{EOT}");
27 }
28  
29 public override int Read()
30 {
31 SerialPort.Write($"{Name}{EOT}");
32 var result = SerialPort.ReadTo(EOT);
33 var match = readRegex.Match(result);
34 return int.Parse(match.Result("${frequency}"));
35 }
36 }
37 }