forked from ArduPilot/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoftwareConfig.cs
209 lines (181 loc) · 8.21 KB
/
SoftwareConfig.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using log4net;
using MissionPlanner.ArduPilot;
using MissionPlanner.Controls;
using MissionPlanner.Controls.BackstageView;
using MissionPlanner.GCSViews.ConfigurationView;
using MissionPlanner.Utilities;
using System;
using System.Reflection;
using System.Windows.Forms;
namespace MissionPlanner.GCSViews
{
public partial class SoftwareConfig : MyUserControl, IActivate
{
internal static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string lastpagename = "";
public bool gotAllParams
{
get
{
log.InfoFormat("TotalReceived {0} TotalReported {1}", MainV2.comPort.MAV.param.TotalReceived,
MainV2.comPort.MAV.param.TotalReported);
if (MainV2.comPort.MAV.param.TotalReceived < MainV2.comPort.MAV.param.TotalReported)
{
return false;
}
return true;
}
}
public SoftwareConfig()
{
InitializeComponent();
}
public void Activate()
{
}
private BackstageViewPage AddBackstageViewPage(Type userControl, string headerText,
BackstageViewPage Parent = null, bool advanced = false)
{
try
{
return backstageView.AddPage(userControl, headerText, Parent, advanced);
}
catch (Exception ex)
{
log.Error(ex);
return null;
}
}
private void SoftwareConfig_Load(object sender, EventArgs e)
{
try
{
BackstageViewPage start = null;
if (gotAllParams)
{
if (MainV2.comPort.BaseStream.IsOpen)
{
if (MainV2.DisplayConfiguration.displayFlightModes)
{
start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
}
if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2)
AddBackstageViewPage(typeof(ConfigAC_Fence), Strings.GeoFence);
if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2)
{
if (MainV2.DisplayConfiguration.displayBasicTuning)
{
start = AddBackstageViewPage(typeof(ConfigSimplePids), Strings.BasicTuning);
}
if (MainV2.DisplayConfiguration.displayExtendedTuning)
{
AddBackstageViewPage(typeof(ConfigArducopter), Strings.ExtendedTuning);
}
}
if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduPlane)
{
start = AddBackstageViewPage(typeof(ConfigArduplane), Strings.BasicTuning);
AddBackstageViewPage(typeof(ConfigArducopter), "QP " + Strings.ExtendedTuning);
}
if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduRover)
{
start = AddBackstageViewPage(typeof(ConfigArdurover), Strings.BasicTuning);
}
if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduTracker)
{
start = AddBackstageViewPage(typeof(ConfigAntennaTracker), Strings.ExtendedTuning);
}
if (MainV2.DisplayConfiguration.displayBasicTuning)
{
AddBackstageViewPage(typeof(ConfigFriendlyParams), Strings.StandardParams);
}
if (MainV2.DisplayConfiguration.displayAdvancedParams)
{
AddBackstageViewPage(typeof(ConfigFriendlyParamsAdv), Strings.AdvancedParams, null, true);
}
if (!Program.MONO && ConfigOSD.IsApplicable() && MainV2.DisplayConfiguration.displayOSD)
{
AddBackstageViewPage(typeof(ConfigOSD), Strings.OnboardOSD);
}
if ((MainV2.comPort.MAV.cs.capabilities & (int) MAVLink.MAV_PROTOCOL_CAPABILITY.FTP) > 0)
AddBackstageViewPage(typeof(MavFTPUI), Strings.MAVFtp);
if (MainV2.DisplayConfiguration.displayUserParam)
{
AddBackstageViewPage(typeof(ConfigUserDefined), Strings.User_Params);
}
}
}
if (MainV2.DisplayConfiguration.displayFullParamList)
{
if(!MainV2.comPort.BaseStream.IsOpen || gotAllParams)
AddBackstageViewPage(typeof(ConfigRawParams), Strings.FullParameterList, null, true);
}
if (MainV2.DisplayConfiguration.displayFullParamTree && !Program.MONO)
{
if (!MainV2.comPort.BaseStream.IsOpen || gotAllParams)
AddBackstageViewPage(typeof(ConfigRawParamsTree), Strings.FullParameterTree, null, true);
}
if (MainV2.comPort.BaseStream.IsOpen)
{
if (MainV2.comPort.MAV.cs.firmware == Firmwares.Ateryx)
{
start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
AddBackstageViewPage(typeof(ConfigAteryxSensors), "Ateryx Zero Sensors");
AddBackstageViewPage(typeof(ConfigAteryx), "Ateryx Pids");
}
if (!gotAllParams)
{
if (start == null)
start = AddBackstageViewPage(typeof(ConfigParamLoading), Strings.Loading);
else
AddBackstageViewPage(typeof(ConfigParamLoading), Strings.Loading);
}
if (MainV2.DisplayConfiguration.displayPlannerSettings)
{
AddBackstageViewPage(typeof(ConfigPlanner), Strings.Planner);
}
}
else
{
if (MainV2.DisplayConfiguration.displayPlannerSettings)
{
start = AddBackstageViewPage(typeof(ConfigPlanner), Strings.Planner);
}
}
// apply theme before trying to display it
ThemeManager.ApplyThemeTo(this);
// remeber last page accessed
foreach (BackstageViewPage page in backstageView.Pages)
{
if (page.LinkText == lastpagename)
{
backstageView.ActivatePage(page);
break;
}
}
if (backstageView.SelectedPage == null && start != null)
this.BeginInvoke((Action) delegate
{
try
{
backstageView.ActivatePage(start);
}
catch (Exception ex)
{
log.Error(ex);
}
});
}
catch (Exception ex)
{
log.Error(ex);
}
}
private void SoftwareConfig_FormClosing(object sender, FormClosingEventArgs e)
{
if (backstageView.SelectedPage != null)
lastpagename = backstageView.SelectedPage.LinkText;
backstageView.Close();
}
}
}