HamBook – Blame information for rev 7

Subversion Repositories:
Rev:
Rev Author Line No. Line
7 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;
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")]
15 public class ID : Generic.CAT.ID
16 {
17 private static readonly Regex readRegex = new Regex(@"^ID(?<id>[0-9]{4})$", RegexOptions.Compiled);
18  
19 public ID(SerialPort serialPort) : base(serialPort)
20 {
21 }
22  
23 public override bool Read()
24 {
25 SerialPort.Write($"{Name}{Generic.Constants.EOT}");
26 var result = SerialPort.ReadTo(Generic.Constants.EOT);
27 var match = readRegex.Match(result);
28 return int.Parse(match.Result("${id}")) == int.Parse(Constants.ID);
29 }
30 }
31 }