HamBook – Diff between revs 16 and 46
?pathlinks?
Rev 16 | Rev 46 | |||
---|---|---|---|---|
Line 5... | Line 5... | |||
5 | using System.Text; |
5 | using System.Text; |
|
6 | using System.Threading.Tasks; |
6 | using System.Threading.Tasks; |
|
Line 7... | Line 7... | |||
7 | |
7 | |
|
8 | namespace HamBook.Radios.Generic |
8 | namespace HamBook.Radios.Generic |
|
9 | { |
9 | { |
|
10 | public class RadioPhase |
10 | public class Phase |
|
11 | { |
11 | { |
|
Line 12... | Line 12... | |||
12 | public int Phase { get; set; } |
12 | public PhaseMode Mode { get; set; } |
|
13 | |
13 | |
|
14 | public RadioPhase(string phase) : this() |
14 | public Phase(string phase) : this() |
|
15 | { |
15 | { |
|
Line 16... | Line 16... | |||
16 | Phase = Parse(phase); |
16 | Mode = Parse(phase); |
|
17 | } |
17 | } |
|
18 | |
18 | |
|
19 | public RadioPhase(int phase) : this() |
19 | public Phase(int phase) : this() |
|
Line 20... | Line 20... | |||
20 | { |
20 | { |
|
21 | Phase = Parse(phase); |
21 | Mode = Parse(phase); |
|
Line 22... | Line 22... | |||
22 | } |
22 | } |
|
Line 23... | Line 23... | |||
23 | |
23 | |
|
24 | public RadioPhase() |
24 | public Phase() |
|
25 | { |
25 | { |
|
26 | |
- | ||
27 | } |
- | ||
28 | |
- | ||
29 | public static bool TryParse(string phase, out RadioPhase radioPhase) |
- | ||
30 | { |
- | ||
31 | switch (phase) |
- | ||
32 | { |
- | ||
33 | |
- | ||
34 | case "Simplex": |
- | ||
35 | case "Plus Shift": |
- | ||
36 | case "Minus Shift": |
- | ||
37 | radioPhase = new RadioPhase(phase); |
26 | |
|
Line 38... | Line -... | |||
38 | return true; |
- | ||
39 | default: |
- | ||
40 | radioPhase = null; |
- | ||
41 | return false; |
- | ||
42 | } |
- | ||
43 | } |
- | ||
44 | |
- | ||
45 | public static bool TryParse(int phase, out RadioPhase radioPhase) |
- | ||
46 | { |
- | ||
47 | switch (phase) |
- | ||
48 | { |
- | ||
49 | case 0: |
- | ||
50 | case 1: |
- | ||
51 | case 2: |
- | ||
52 | radioPhase = new RadioPhase(phase); |
- | ||
53 | return true; |
27 | } |
|
54 | default: |
28 | |
|
55 | radioPhase = null; |
29 | public Phase(PhaseMode mode) |
|
56 | return false; |
30 | { |
|
57 | } |
31 | Mode = mode; |
|
58 | } |
32 | } |
|
59 | |
33 | |
|
60 | private int Parse(string mode) |
34 | public static PhaseMode Parse(string mode) |
|
61 | { |
35 | { |
|
62 | switch (mode) |
36 | switch (mode) |
|
63 | { |
37 | { |
|
64 | case "Simplex": |
38 | case "Simplex": |
|
65 | return 0; |
39 | return PhaseMode.Simplex; |
|
66 | case "Plus Shift": |
40 | case "Plus Shift": |
|
Line 67... | Line 41... | |||
67 | return 1; |
41 | return PhaseMode.PlusShift; |
|
68 | case "Minus Shift": |
42 | case "Minus Shift": |
|
69 | return 2; |
43 | return PhaseMode.MinusShift; |
|
70 | default: |
44 | default: |
|
71 | throw new ArgumentException(); |
45 | throw new ArgumentException(); |
|
- | 46 | } |
||
72 | } |
47 | } |
|
- | 48 | |
||
73 | } |
49 | public static PhaseMode Parse(int phase) |
|
74 | |
50 | { |
|
75 | private int Parse(int phase) |
51 | switch (phase) |
|
76 | { |
52 | { |
|
77 | switch (phase) |
53 | case 0: |
|
78 | { |
54 | return PhaseMode.Simplex; |
|
Line 79... | Line -... | |||
79 | case 0: |
- | ||
80 | case 1: |
- | ||
81 | case 2: |
- | ||
82 | return phase; |
- | ||
83 | default: |
- | ||
84 | throw new ArgumentException(); |
55 | case 1: |
|
85 | } |
56 | return PhaseMode.PlusShift; |
|
86 | } |
57 | case 2: |
|
87 | |
58 | return PhaseMode.MinusShift; |
|
88 | public static implicit operator RadioPhase(string phase) |
59 | default: |
|
89 | { |
60 | throw new ArgumentException(); |
|
90 | return new RadioPhase(phase); |
61 | } |
|
91 | } |
62 | } |
|
92 | |
63 | |
|
93 | public static implicit operator string(RadioPhase radioPhase) |
64 | public static implicit operator string(Phase phase) |
|
94 | { |
65 | { |
|
95 | switch (radioPhase.Phase) |
66 | switch (phase.Mode) |
|
96 | { |
- | ||
97 | case 0: |
- | ||
Line 98... | Line -... | |||
98 | return "Simplex"; |
- | ||
99 | case 1: |
- | ||
100 | return "Plus Shift"; |
- | ||
101 | case 2: |
67 | { |
|
102 | return "Minus Shift"; |
- | ||
103 | default: |
- | ||
104 | throw new ArgumentException(); |
- | ||
105 | } |
- | ||
106 | } |
68 | case PhaseMode.Simplex: |
|
107 | |
69 | return "Simplex"; |
|
108 | public static implicit operator RadioPhase(int phase) |
70 | case PhaseMode.PlusShift: |