1
0
Fork 0

Save server selection. Improve parser to remove any lowercase char or comma (invalid)

This commit is contained in:
legoboyvdlp R 2020-10-24 15:07:23 +01:00
parent 0e71418a38
commit a867cfc4c9
5 changed files with 35 additions and 29 deletions

View file

@ -1085,6 +1085,10 @@
<transponder-code type="string">2000</transponder-code>
<failed type="bool">0</failed>
</atc>
<atsu>
<atis-server type="string">faa</atis-server>
<wxr-server type="string">faa</wxr-server>
</atsu>
<apu>
<oil>
<level-l type="double">5.4</level-l>

View file

@ -76,6 +76,8 @@ setprop("/systems/acconfig/options/keyboard-mode", 0);
setprop("/systems/acconfig/options/weight-kgs", 0);
setprop("/systems/acconfig/options/adirs-skip", 0);
setprop("/systems/acconfig/options/allow-oil-consumption", 0);
setprop("/systems/acconfig/options/atis-server", "faa");
setprop("/systems/acconfig/options/wxr-server", "noaa");
setprop("/systems/acconfig/options/welcome-skip", 0);
setprop("/systems/acconfig/options/no-rendering-warn", 0);
setprop("/systems/acconfig/options/save-state", 0);
@ -231,6 +233,8 @@ var readSettings = func {
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/simbrief-username", getprop("/systems/acconfig/options/simbrief-username"));
setprop("/systems/atsu/atis-server", getprop("/systems/acconfig/options/atis-server"));
setprop("/systems/atsu/wxr-server", getprop("/systems/acconfig/options/wxr-server"));
}
var writeSettings = func {
@ -243,6 +247,8 @@ var writeSettings = func {
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"));
setprop("/systems/acconfig/options/atis-server", getprop("/systems/atsu/atis-server"));
setprop("/systems/acconfig/options/wxr-server", getprop("/systems/atsu/wxr-server"));
io.write_properties(getprop("/sim/fg-home") ~ "/Export/A320-family-config.xml", "/systems/acconfig/options");
}

View file

@ -988,7 +988,6 @@ var canvas_MCDU_base = {
if (myAtis[i].getNumPages() > 1) {
me["Simple_PageNum"].show();
me["ATISArrows"].show();
print(myAtis[i].page);
me["Simple_PageNum"].setText(myAtis[i].page ~ "/" ~ myAtis[i].getNumPages());
} else {
me["Simple_PageNum"].hide();
@ -1459,21 +1458,21 @@ var canvas_MCDU_base = {
pageSwitch[i].setBoolValue(1);
}
if (atsu.AOC.server == 1) {
if (atsu.AOC.server.getValue() == "vatsim") {
me["Simple_R1"].setText("VATSIM ");
me["Simple_R2_Arrow"].show();
me["Simple_R3_Arrow"].hide();
} elsif (atsu.AOC.server == 0) {
} elsif (atsu.AOC.server.getValue() == "noaa") {
me["Simple_R1"].setText("NOAA ");
me["Simple_R2_Arrow"].hide();
me["Simple_R3_Arrow"].show();
}
if (atsu.ATIS.serverSel == 1) {
if (atsu.ATIS.serverSel.getValue() == "vatsim") {
me["Simple_L1"].setText(" VATSIM");
me["Simple_L2_Arrow"].show();
me["Simple_L3_Arrow"].hide();
} elsif (atsu.ATIS.serverSel == 0) {
} elsif (atsu.ATIS.serverSel.getValue() == "faa") {
me["Simple_L1"].setText(" FAA");
me["Simple_L2_Arrow"].hide();
me["Simple_L3_Arrow"].show();

View file

@ -425,7 +425,8 @@ var lskbutton = func(btn, i) {
} else if (page == "RECEIVEDMSGS") {
canvas_mcdu.myReceivedMessages[i].leftKey(2);
} else if (page == "DATAMODE") {
atsu.ATIS.serverSel = 0;
atsu.ATIS.serverSel.setValue("faa");
acconfig.writeSettings();
} else if (page == "ATIS") {
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
if (scratchpad == "CLR") {
@ -548,7 +549,8 @@ var lskbutton = func(btn, i) {
} else if (page == "RECEIVEDMSGS") {
canvas_mcdu.myReceivedMessages[i].leftKey(3);
} else if (page == "DATAMODE") {
atsu.ATIS.serverSel = 1;
atsu.ATIS.serverSel.setValue("vatsim");
acconfig.writeSettings();
} else if (page == "ATIS") {
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
if (scratchpad == "CLR") {
@ -979,7 +981,8 @@ var rskbutton = func(btn, i) {
} else if (page == "AOCMENU") {
pageNode[i].setValue("WEATHERREQ");
} else if (page == "DATAMODE") {
atsu.AOC.server = 0;
atsu.AOC.server.setValue("noaa");
acconfig.writeSettings();
} else if (page == "ATIS") {
if (atsu.ATISInstances[1].station != nil and atsu.ATISInstances[1].sent != 1) {
atsu.ATISInstances[1].sendReq(i);
@ -1024,7 +1027,8 @@ var rskbutton = func(btn, i) {
canvas_mcdu.myReceivedMessages[i] = receivedMessagesPage.new(i);
pageNode[i].setValue("RECEIVEDMSGS");
} else if (page == "DATAMODE") {
atsu.AOC.server = 1;
atsu.AOC.server.setValue("vatsim");
acconfig.writeSettings();
} else if (page == "ATIS") {
if (atsu.ATISInstances[2].station != nil and atsu.ATISInstances[2].sent != 1) {
atsu.ATISInstances[2].sendReq(i);

View file

@ -3,7 +3,6 @@
# Copyright (c) 2020 Josh Davidson (Octal450)
var defaultServer = "https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&mostRecent=true&hoursBeforeNow=12&stationString=";
var serverString = "";
var result = nil;
var ATSU = {
@ -104,7 +103,7 @@ var AOC = {
sentTime: nil,
received: 0,
receivedTime: nil,
server: 0, # 0 = noaa, 1 = vatsim
server: props.globals.getNode("/systems/atsu/wxr-server"),
newStation: func(airport) {
if (size(airport) == 3 or size(airport) == 4) {
me.station = airport;
@ -167,13 +166,10 @@ var AOC = {
return 1;
}
serverString = "";
if (me.server == 0) {
serverString = defaultServer;
} elsif (me.server == 1) {
var serverString = "";
if (me.server.getValue() == "vatsim") {
serverString = "https://api.flybywiresim.com/metar?source=vatsim&icao=";
} else { # fall back to NOAA silently
} else {
serverString = defaultServer;
}
@ -198,8 +194,10 @@ var AOC = {
},
processMETAR: func(r, i) {
var raw = r.response;
raw = split("<raw_text>", raw)[1];
raw = split("</raw_text>", raw)[0];
if (find("<raw_text>", raw) != -1) {
raw = split("<raw_text>", raw)[1];
raw = split("</raw_text>", raw)[0];
}
me.lastMETAR = raw;
settimer(func() {
me.received = 1;
@ -229,7 +227,7 @@ var AOC = {
};
var ATIS = {
serverSel: 0,
serverSel: props.globals.getNode("/systems/atsu/atis-server"),
new: func() {
var ATIS = { parents: [ATIS] };
ATIS.station = nil;
@ -281,15 +279,7 @@ var ATIS = {
return 1;
}
serverString = "";
if (me.serverSel == 0) {
serverString = "https://api.flybywiresim.com/atis?source=faa&icao=";
} elsif (me.serverSel == 1) {
serverString = "https://api.flybywiresim.com/atis?source=vatsim&icao=";
} else { # fall back to FAA silently
serverString = "https://api.flybywiresim.com/atis?source=faa&icao=";
}
var serverString = "https://api.flybywiresim.com/atis?source=" ~ me.serverSel.getValue() ~ "&icao=";
http.load(serverString ~ airport)
.fail(func(r) return 3)
@ -384,6 +374,9 @@ var ATIS = {
time ~= " ";
}
raw = string.uc(raw);
raw = string.replace(raw, ",", "");
settimer(func() {
me.sent = 0;
me.received = 1;