2020-08-01 13:04:33 +00:00
|
|
|
# A3XX Simbrief Parser
|
|
|
|
# Copyright (c) 2020 Jonathan Redpath (legoboyvdlp)
|
|
|
|
|
|
|
|
var SimbriefParser = {
|
|
|
|
node: nil,
|
2020-08-01 14:04:54 +00:00
|
|
|
inhibit: 0,
|
2020-08-01 13:04:33 +00:00
|
|
|
fetch: func(username, i) {
|
2020-08-01 14:04:54 +00:00
|
|
|
me.inhibit = 1;
|
2020-08-01 13:04:33 +00:00
|
|
|
var stamp = systime();
|
|
|
|
http.save("https://www.simbrief.com/api/xml.fetcher.php?username=" ~ username, getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml")
|
|
|
|
.fail(func mcdu.mcdu_message(i, "SIMBRIEF FAILED"))
|
2020-08-01 14:04:54 +00:00
|
|
|
.done(func me.read(getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml"), 1);
|
2020-08-01 13:04:33 +00:00
|
|
|
},
|
2020-08-01 14:04:54 +00:00
|
|
|
read: func(xml, i) {
|
2020-08-01 13:04:33 +00:00
|
|
|
var data = io.readxml(xml);
|
|
|
|
if (data != nil) {
|
|
|
|
if (data.getChild("OFP") == nil) {
|
|
|
|
print("XML file " ~ xml ~ " not a valid Simbrief file");
|
|
|
|
} else {
|
|
|
|
me.node = data;
|
2020-08-01 14:04:54 +00:00
|
|
|
mcdu.mcdu_message(i, "AOC ACT F-PLN UPLINK");
|
2020-08-01 13:04:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print("Error reading " ~ xml);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|