-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRigControlProcess.cs
143 lines (116 loc) · 3.44 KB
/
RigControlProcess.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OmniRig;
using System.Timers;
using SDRSharp.Common;
using System.Xml;
using System.IO;
using System.Configuration;
namespace SDRSharp.Plugin.SatControl
{
public class RigInfo
{
public long frequency { get; set; }
public string mode { get; set; }
public string status { get; set; }
public string rigName { get; set; }
public string ctts { get; set; }
}
public class SatInfo
{
public long frequency { get; set; }
public string mode { get; set; } = "";
}
public class RigControlProcess
{
private OmniRigX omniRig;
private IRigX rig = null;
ISharpControl _control;
private Timer timer;
public RigInfo rigInfo;
public SatInfo satInfo;
public event Action rigStatus;
// App setting;
AppSettingsSection config = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location).AppSettings;
public RigControlProcess(ISharpControl control)
{
_control = control;
omniRig = new OmniRigX();
rig = omniRig.Rig1;
timer = new Timer();
timer.Interval = 1000;
timer.Elapsed += Timer_Elapsed;
rigInfo = new RigInfo();
satInfo = new SatInfo();
}
public void OmniRigConfig()
{
omniRig.DialogVisible = true;
}
public void connectRig(string rigSelect)
{
if (rigSelect == "Rig1")
{
rig = omniRig.Rig1;
}
else if(rigSelect == "Rig2")
{
rig = omniRig.Rig2;
}
timer.Start();
}
public void disConnectRig()
{
timer.Stop();
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Set Rig Frequency
rig.FreqA = Convert.ToInt32(satInfo.frequency);
// read Rig Info
rigInfo.status = rig.StatusStr;
rigInfo.frequency = rig.FreqA;
switch (rig.Mode)
{
case RigParamX.PM_AM:
rigInfo.mode = "AM"; break;
case RigParamX.PM_CW_L:
rigInfo.mode = "CW-L"; break;
case RigParamX.PM_CW_U:
rigInfo.mode = "CW-U"; break;
case RigParamX.PM_SSB_L:
rigInfo.mode = "LSB"; break;
case RigParamX.PM_SSB_U:
rigInfo.mode = "USB"; break;
case RigParamX.PM_FM:
rigInfo.mode = "FM"; break;
}
rigInfo.rigName = rig.RigType;
rigStatus?.Invoke();
}
public string getTxOffsetFromConfig()
{
string txOffset = config.Settings["TxOffset"].Value;
return txOffset;
}
public void setModeFM()
{
rig.Mode = RigParamX.PM_FM;
}
public void setModeLSB()
{
rig.Mode = RigParamX.PM_SSB_L;
}
public void setModeUSB()
{
rig.Mode = RigParamX.PM_SSB_U;
}
public void setModeCW()
{
rig.Mode = RigParamX.PM_CW_L;
}
}
}