HamBook – Diff between revs 24 and 46

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 24 Rev 46
Line 20... Line 20...
20   20  
Line 21... Line 21...
21 public override CatLength CatLength => new CatLength { Set = 7, Answer = 7, Read = 4 }; 21 public override CatLength CatLength => new CatLength { Set = 7, Answer = 7, Read = 4 };
22   22  
23 public SQ(SerialPortStream serialPort) : base(serialPort) 23 public SQ(SerialPortStream serialPort) : base(serialPort)
24 { 24 {
Line 25... Line 25...
25 readRegex = new Regex($"^{Name}0(?<squelch>[0-9]{{3}}){Generic.Constants.EOT}$", RegexOptions.Compiled); 25 readRegex = new Regex($"^{Name}0(?<squelch>[0-9]{{3}}){Constants.EOT}$", RegexOptions.Compiled);
26 } 26 }
27   27  
28 public override int GetDefault() 28 public override int GetDefault()
Line 29... Line 29...
29 { 29 {
30 return SQUELCH_MIN_STEP; 30 return SQUELCH_MIN_STEP;
31 } 31 }
32   32  
33 public override int Read() 33 public override int Read()
34 { 34 {
35 SerialPort.Write($"{Name}0{Generic.Constants.EOT}"); 35 SerialPort.Write($"{Name}0{Constants.EOT}");
36 var buffer = new byte[CatLength.Answer]; 36 var buffer = new byte[CatLength.Answer];
Line 49... Line 49...
49 return level; 49 return level;
50 } 50 }
Line 51... Line 51...
51   51  
52 public override async Task<int> ReadAsync(CancellationToken cancellationToken) 52 public override async Task<int> ReadAsync(CancellationToken cancellationToken)
53 { 53 {
54 var payload = Constants.Encoding.GetBytes($"{Name}0{Generic.Constants.EOT}"); 54 var payload = Constants.Encoding.GetBytes($"{Name}0{Constants.EOT}");
Line 55... Line 55...
55 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken); 55 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken);
56   56  
57 var buffer = new byte[CatLength.Answer]; 57 var buffer = new byte[CatLength.Answer];
Line 71... Line 71...
71 return level; 71 return level;
72 } 72 }
Line 73... Line 73...
73   73  
74 public override bool Set(int level) 74 public override bool Set(int level)
75 { 75 {
Line 76... Line 76...
76 SerialPort.Write($"{Name}0{level:000}{Generic.Constants.EOT}"); 76 SerialPort.Write($"{Name}0{level:000}{Constants.EOT}");
77   77  
Line 78... Line 78...
78 return Read() == level; 78 return Read() == level;
79 } 79 }
80   80  
81 public override async Task<bool> SetAsync(int level, CancellationToken cancellationToken) 81 public override async Task<bool> SetAsync(int level, CancellationToken cancellationToken)
Line 82... Line 82...
82 { 82 {
Line 83... Line 83...
83 var payload = Constants.Encoding.GetBytes($"{Name}0{level:000}{Generic.Constants.EOT}"); 83 var payload = Constants.Encoding.GetBytes($"{Name}0{level:000}{Constants.EOT}");
84 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken); 84 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken);
Line 85... Line 85...
85   85  
86 var result = await ReadAsync(cancellationToken); 86 var result = await ReadAsync(cancellationToken);
87   87  
88 return result == level; 88 return result == level;
Line 89... Line 89...
89 } 89 }
90   90  
91 public override void Write(int level) 91 public override void Write(int level)
Line 92... Line 92...
92 { 92 {
93 SerialPort.Write($"{Name}0{level:000}{Generic.Constants.EOT}"); 93 SerialPort.Write($"{Name}0{level:000}{Constants.EOT}");
94 } 94 }
95   95