1
0
Fork 0

Simbrief initial downloader

This commit is contained in:
legoboyvdlp R 2020-08-01 14:04:33 +01:00
parent e1ce34148e
commit 31e8269996
7 changed files with 121 additions and 1 deletions

View file

@ -269,6 +269,15 @@
</script>
</binding>
</item>
<item>
<label>Simbrief</label>
<binding>
<command>nasal</command>
<script>
acconfig.simbrief_dlg.open();
</script>
</binding>
</item>
</menu>
<menu n="103">
<label>DU</label>
@ -635,6 +644,7 @@
<cost-index type="int">0</cost-index>
<to-state type="bool">0</to-state>
</internal>
<simbrief-username type="string"></simbrief-username>
</FMGC>
<controls>
@ -4336,6 +4346,9 @@
<save>
<file>Aircraft/A320-family/Nasal/Systems/save.nas</file>
</save>
<Simbrief>
<file>Aircraft/A320-family/Nasal/FMGC/SimbriefParser.nas</file>
</Simbrief>
</nasal>
<maintainance>

View file

@ -102,6 +102,7 @@ var error_mismatch = gui.Dialog.new("/sim/gui/dialogs/acconfig/error/mismatch/di
var fuel_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/fuel/dialog", "Aircraft/A320-family/AircraftConfig/fuel.xml");
var groundservices_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/groundsrvc/dialog", "Aircraft/A320-family/AircraftConfig/groundservices.xml");
var loadflightplan_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/loadfpln/dialog","Aircraft/A320-family/AircraftConfig/load-flightplan.xml");
var simbrief_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/loadfpln/dialog","Aircraft/A320-family/AircraftConfig/simbrief.xml");
var du_quality = gui.Dialog.new("/sim/gui/dialogs/acconfig/du-quality/dialog", "Aircraft/A320-family/AircraftConfig/du-quality.xml");
var rendering_dlg = gui.Dialog.new("/sim/gui/dialogs/rendering/dialog", "Aircraft/A320-family/AircraftConfig/rendering.xml");
spinning.start();
@ -112,6 +113,7 @@ var current_revision = io.readfile(revisionFile);
print("A320-family Revision: " ~ current_revision);
setprop("/systems/acconfig/revision", current_revision);
setprop("/systems/acconfig/options/fo-view", 0);
setprop("/systems/acconfig/options/simbrief-username", "");
setlistener("/systems/acconfig/new-revision", func {
if (getprop("/systems/acconfig/new-revision") > current_revision) {
@ -228,6 +230,7 @@ var readSettings = func {
setprop("/sim/model/autopush/route/show", getprop("/systems/acconfig/options/autopush/show-route"));
setprop("/sim/model/autopush/route/show-wingtip", getprop("/systems/acconfig/options/autopush/show-wingtip"));
setprop("/options/system/fo-view", getprop("/systems/acconfig/options/fo-view"));
setprop("/FMGC/internal/simbrief-username", getprop("/systems/acconfig/options/simbrief-username"));
}
var writeSettings = func {
@ -239,6 +242,7 @@ var writeSettings = func {
setprop("/systems/acconfig/options/autopush/show-route", getprop("/sim/model/autopush/route/show"));
setprop("/systems/acconfig/options/autopush/show-wingtip", getprop("/sim/model/autopush/route/show-wingtip"));
setprop("/systems/acconfig/options/fo-view", getprop("/options/system/fo-view"));
setprop("/systems/acconfig/options/simbrief-username", getprop("/FMGC/simbrief-username"));
io.write_properties(getprop("/sim/fg-home") ~ "/Export/A320-family-config.xml", "/systems/acconfig/options");
}

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright (c) 2020 Josh Davidson (Octal450) -->
<!-- A3XX Load Flightplans -->
<PropertyList>
<name>simbrief</name>
<layout>vbox</layout>
<group>
<layout>hbox</layout>
<text>
<halign>left</halign>
<label>Simbrief API</label>
</text>
<button>
<halign>right</halign>
<pref-width>20</pref-width>
<pref-height>20</pref-height>
<legend>X</legend>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<group>
<layout>vbox</layout>
<text>
<halign>left</halign>
<label>This dialog allows users to pull their flightplan from simbrief.</label>
</text>
<text>
<halign>left</halign>
<label>1. ACARS is only available if VHF3 is not in voice mode, and the appropriate electrical power is available.</label>
</text>
<text>
<halign>left</halign>
<label>2. Flightplan uplink is only available before engine start, if a flightplan is not yet entered in the MCDU</label>
</text>
<text>
<halign>left</halign>
<label>3. Please enter your username in the following dialog box (not case sensitive)</label>
</text>
<group>
<layout>hbox</layout>
<text>
<halign>left</halign>
<label>Username: </label>
</text>
<input>
<width>200</width>
<height>25</height>
<property>/FMGC/simbrief-username</property>
<binding>
<command>dialog-apply</command>
</binding>
<live>true</live>
</input>
</group>
</group>
</PropertyList>

View file

@ -0,0 +1,25 @@
# A3XX Simbrief Parser
# Copyright (c) 2020 Jonathan Redpath (legoboyvdlp)
var SimbriefParser = {
node: nil,
fetch: func(username, i) {
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"))
.done(func me.read(getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml"));
},
read: func(xml) {
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;
debug.dump(me.node.getChild("OFP").getChild("fetch").getChild("status"));
}
} else {
print("Error reading " ~ xml);
}
},
};

View file

@ -172,6 +172,7 @@ var MessageController = {
TypeIMessage.new("TMPY F-PLN EXISTS", 1),TypeIMessage.new("SELECT DESIRED SYSTEM"),TypeIMessage.new("SELECT HDG/TRK FIRST"),
TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"),TypeIMessage.new("RWY/LS MISMATCH"),
TypeIMessage.new("VHF3 VOICE MSG NOT GEN"),TypeIMessage.new("NO COMM MSG NOT GEN"),TypeIMessage.new("WX UPLINK"),
TypeIMessage.new("SIMBRIEF FAILED"),TypeIMessage.new("MISSING USERNAME"),
]),
typeIIMessages: std.Vector.new([
TypeIIMessage.new("LAT DISCONT AHEAD", "amb", 0),TypeIIMessage.new("MORE DRAG"),TypeIIMessage.new("RWY/LS MISMATCH", "amb", 0),TypeIIMessage.new("STEP DELETED"),

View file

@ -240,6 +240,12 @@ var initInputA = func(key, i) {
mcdu_message(i, "TMPY F-PLN EXISTS");
}
}
} else if (key == "R2") {
if (getprop("/FMGC/simbrief-username") == "") {
mcdu.mcdu_message(i, "MISSING USERNAME")
} else {
Simbrief.SimbriefParser.fetch(getprop("/FMGC/simbrief-username"), i);
}
} else if (key == "R3") {
setprop("MCDU[" ~ i ~ "]/page", "IRSINIT");
} else if (key == "R4") {

View file

@ -658,7 +658,9 @@ var rskbutton = func(btn, i) {
mcdu_message(i, "NOT ALLOWED");
}
} else if (btn == "2") {
if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") {
if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") {
initInputA("R2",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") {
initInputB("R2",i);
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") {
perfAPPRInput("R2",i);