Skip to content

Commit

Permalink
ParameterMetaDataRepositoryAPMpdef: add version specific pdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Nov 18, 2024
1 parent 53cb45b commit 2016d3b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
45 changes: 44 additions & 1 deletion ExtLibs/Utilities/ParameterMetaDataRepositoryAPMpdef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ public static class ParameterMetaDataRepositoryAPMpdef
private static string[] vehicles = new[]
{
"SITL", "AP_Periph", "ArduSub", "Rover", "ArduCopter",
"ArduPlane", "AntennaTracker", "Blimp", "Heli"
"ArduPlane", "AntennaTracker", "Blimp", "Heli"
};

private static string[] vehicles_versioned = new[]
{
"Copter", "Plane", "Rover", "Sub", "Tracker"
};

static string url = "https://autotest.ardupilot.org/Parameters/{0}/apm.pdef.xml.gz";

static string urlversioned = "https://autotest.ardupilot.org/Parameters/versioned/{0}/stable-{1}/apm.pdef.xml";

static ParameterMetaDataRepositoryAPMpdef()
{
GetMetaData();
Expand All @@ -42,6 +49,42 @@ public static void CheckLoad(string vehicle = "")
Reload(vehicle);
}

public static async Task GetMetaDataVersioned(Version version)
{
List<Task> tlist = new List<Task>();

vehicles_versioned.ForEach(a =>
{
try
{
var newurl = String.Format(urlversioned, a, version.ToString());
var file = Path.Combine(Settings.GetDataDirectory(), a + version.ToString() + ".apm.pdef.xml");
if (File.Exists(file))
if (new FileInfo(file).LastWriteTime.AddDays(7) > DateTime.Now)
return;
var dltask = Download.getFilefromNetAsync(newurl, file);
tlist.Add(dltask);
}
catch (Exception ex) { log.Error(ex); }
});

await Task.WhenAll(tlist);

vehicles_versioned.ForEach(a =>
{
try
{
Reload(a + version.ToString());
var veh = vehicles.First(b => b.Contains(a));
if(_parameterMetaDataXML.ContainsKey(a + version.ToString()))
_parameterMetaDataXML[veh] = _parameterMetaDataXML[a + version.ToString()];
}
catch (Exception ex) { log.Error(ex); }
});
}

public static async Task GetMetaData(bool force = false)
{
List<Task> tlist = new List<Task>();
Expand Down
11 changes: 7 additions & 4 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,8 +1677,8 @@ public void doConnect(MAVLinkInterface comPort, string portname, string baud, bo
foreach (var item in softwares)
{
// check primare firmware type. ie arudplane, arducopter
if (fields1[0].ToLower().Contains(item.VehicleType.ToLower()))
// check primare firmware type. ie arudplane, arducopter
if (fields1[0].ToLower().Contains(item.VehicleType.ToLower()))
{
Version ver1 = VersionDetection.GetVersion(comPort.MAV.VersionString);
Version ver2 = item.MavFirmwareVersion;
Expand All @@ -1691,10 +1691,13 @@ public void doConnect(MAVLinkInterface comPort, string portname, string baud, bo
break;
}
// check the first hit only
break;
// check the first hit only
break;
}
}
// load version specific config
ParameterMetaDataRepositoryAPMpdef.GetMetaDataVersioned(VersionDetection.GetVersion(comPort.MAV.VersionString));
}
catch (Exception ex)
{
Expand Down

0 comments on commit 2016d3b

Please sign in to comment.