HamBook – Diff between revs 34 and 46

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 34 Rev 46
Line 22... Line 22...
22   22  
Line 23... Line 23...
23 public override CatLength CatLength => new CatLength { Set = 4, Answer = 4, Read = 3 }; 23 public override CatLength CatLength => new CatLength { Set = 4, Answer = 4, Read = 3 };
24   24  
25 public PS(SerialPortStream serialPort) : base(serialPort) 25 public PS(SerialPortStream serialPort) : base(serialPort)
26 { 26 {
Line 27... Line 27...
27 readRegex = new Regex($"^{Name}(?<state>[01]){Generic.Constants.EOT}$", RegexOptions.Compiled); 27 readRegex = new Regex($"^{Name}(?<state>[01]){Constants.EOT}$", RegexOptions.Compiled);
28 } 28 }
29   29  
Line 39... Line 39...
39 { 39 {
40 byte[] payload = null; 40 byte[] payload = null;
41 switch(state) 41 switch(state)
42 { 42 {
43 case PowerState.ON: 43 case PowerState.ON:
44 payload = Constants.Encoding.GetBytes($"{Name}1{Generic.Constants.EOT}"); 44 payload = Constants.Encoding.GetBytes($"{Name}1{Constants.EOT}");
45 await SerialPort.WriteAsync(payload, 0, payload.Length); 45 await SerialPort.WriteAsync(payload, 0, payload.Length);
46 Task.Delay(TIME_TO_WARM).ContinueWith(task2 => 46 Task.Delay(TIME_TO_WARM).ContinueWith(task2 =>
47 { 47 {
48 taskCompletionSource.TrySetResult(true); 48 taskCompletionSource.TrySetResult(true);
49 }); 49 });
50 return; 50 return;
51 case PowerState.OFF: 51 case PowerState.OFF:
52 payload = Constants.Encoding.GetBytes($"{Name}0{Generic.Constants.EOT}"); 52 payload = Constants.Encoding.GetBytes($"{Name}0{Constants.EOT}");
53 await SerialPort.WriteAsync(payload, 0, payload.Length); 53 await SerialPort.WriteAsync(payload, 0, payload.Length);
54 break; 54 break;
55 } 55 }
56 taskCompletionSource.TrySetResult(true); 56 taskCompletionSource.TrySetResult(true);
57 }); 57 });
Line 69... Line 69...
69 var taskCompletionSource = new TaskCompletionSource<int>(); 69 var taskCompletionSource = new TaskCompletionSource<int>();
Line 70... Line 70...
70   70  
71 #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed 71 #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
72 Task.Delay(POWER_ON_DELAY).ContinueWith(async _ => 72 Task.Delay(POWER_ON_DELAY).ContinueWith(async _ =>
73 { 73 {
Line 74... Line 74...
74 var payload = Constants.Encoding.GetBytes($"{Name}{Generic.Constants.EOT}"); 74 var payload = Constants.Encoding.GetBytes($"{Name}{Constants.EOT}");
Line 75... Line 75...
75   75  
76 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken); 76 await SerialPort.WriteAsync(payload, 0, payload.Length, cancellationToken);