HamBook – Blame information for rev 7

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