*** empty log message ***
This commit is contained in:
parent
7e81bb94ff
commit
5e9df124b6
4 changed files with 147 additions and 94 deletions
|
@ -1,6 +1,8 @@
|
|||
var screenAirportMain = {
|
||||
pos: nil,
|
||||
apt_coord: nil,
|
||||
apt: nil,
|
||||
searched: 0,
|
||||
right : func {
|
||||
},
|
||||
apt_to_waypoint : func {
|
||||
|
@ -13,38 +15,56 @@ var screenAirportMain = {
|
|||
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(me.apt_coord.lat());
|
||||
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(me.apt_coord.lon());
|
||||
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(me.apt_coord.alt()*alt_conv[1][0]);
|
||||
gps_wp.getNode("wp[1]/ID",1).setValue(apt.id);
|
||||
gps_wp.getNode("wp[1]/name",1).setValue(apt.name);
|
||||
gps_wp.getNode("wp[1]/ID",1).setValue(me.apt.id);
|
||||
gps_wp.getNode("wp[1]/name",1).setValue(me.apt.name);
|
||||
mode = 2;
|
||||
page = 1;
|
||||
displayed_screen = 1; #screenNavigationMain
|
||||
},
|
||||
enter : func {
|
||||
me.apt_to_waypoint();
|
||||
enter : func { #add to route
|
||||
add_waypoint(me.apt.id, me.apt.name, "APT",
|
||||
[me.apt_coord.lat(), me.apt_coord.lon(),
|
||||
me.apt_coord.alt()*alt_conv[1][0]]);
|
||||
},
|
||||
escape : func {
|
||||
},
|
||||
start : func {
|
||||
me.apt_to_waypoint();
|
||||
start : func { #add bookmark, enter turnpoint mode
|
||||
add_bookmark(me.apt.id, me.apt.name, "APT",
|
||||
[me.apt_coord.lat(), me.apt_coord.lon(),
|
||||
me.apt_coord.alt()*alt_conv[1][0]]);
|
||||
screenTurnpointSelect.selected = screenTurnpointSelect.n - 1;
|
||||
screenTurnpointSelect.start();
|
||||
},
|
||||
lines : func (searched = nil) {
|
||||
if (searched != nil)
|
||||
apt = searched;
|
||||
lines : func {
|
||||
if (me.apt == nil) {
|
||||
me.apt = airportinfo();
|
||||
print("youpi ", me.count);
|
||||
me.searched = 0;
|
||||
}
|
||||
if (me.apt != nil) {
|
||||
glide_slope_tunnel.complement_runways(me.apt);
|
||||
var rwy = glide_slope_tunnel.best_runway(me.apt);
|
||||
me.pos = geo.Coord.new(geo.aircraft_position());
|
||||
me.apt_coord = geo.Coord.new().set_latlon(rwy.lat, rwy.lon);
|
||||
var ac_to_apt = [me.pos.distance_to(me.apt_coord), me.pos.course_to(me.apt_coord)];
|
||||
var ete = ac_to_apt[0] / getprop("instrumentation/gps/indicated-ground-speed-kt") * 3600 * 1852;
|
||||
print ("me.searched: ",me.searched);
|
||||
display([
|
||||
sprintf("%s APT: %s", me.searched != nil ? "SEARCHED" : "NEAREST", me.apt.id),
|
||||
sprintf("ELEV: %d %s", me.apt.elevation * alt_conv[1][alt_unit],alt_unit_short_name[alt_unit]),
|
||||
sprintf("DIST: %d %s",ac_to_apt[0] * dist_conv[2][dist_unit],dist_unit_short_name[dist_unit]),
|
||||
sprintf("BRG: %d° RWY: %02d",ac_to_apt[1], int(rwy.heading) / 10),
|
||||
sprintf("ETE: %s",seconds_to_string(ete))
|
||||
]);
|
||||
}
|
||||
else
|
||||
apt = airportinfo();
|
||||
glide_slope_tunnel.complement_runways(apt);
|
||||
var rwy = glide_slope_tunnel.best_runway(apt);
|
||||
me.pos = geo.Coord.new(geo.aircraft_position());
|
||||
me.apt_coord = geo.Coord.new().set_latlon(rwy.lat, rwy.lon);
|
||||
var ac_to_apt = [me.pos.distance_to(me.apt_coord), me.pos.course_to(me.apt_coord)];
|
||||
var ete = ac_to_apt[0] / getprop("instrumentation/gps/indicated-ground-speed-kt") * 3600 * 1852;
|
||||
display([
|
||||
sprintf("%s APT: %s", searched != nil ? "SEARCHED" : "NEAREST", apt.id),
|
||||
sprintf("ELEV: %d %s", apt.elevation * alt_conv[1][alt_unit],alt_unit_short_name[alt_unit]),
|
||||
sprintf("DIST: %d %s",ac_to_apt[0] * dist_conv[2][dist_unit],dist_unit_short_name[dist_unit]),
|
||||
sprintf("BRG: %d° RWY: %02d",ac_to_apt[1], int(rwy.heading) / 10),
|
||||
sprintf("ETE: %s",seconds_to_string(ete))
|
||||
]);
|
||||
display([
|
||||
"",
|
||||
"",
|
||||
"NO AIRPORT FOUND",
|
||||
"",
|
||||
""
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -85,42 +105,24 @@ var screenAirportInfos = {
|
|||
};
|
||||
|
||||
var screenSearchAirport = {
|
||||
oaci : ["-","-","-","-"],
|
||||
pointer: 0,
|
||||
value: 0,
|
||||
searched: nil,
|
||||
right : func {
|
||||
me.value = cycle(size(screenEdit.alphanum), me.value, arg[0]);
|
||||
me.oaci[me.pointer] = screenEdit.alphanum[me.value];
|
||||
},
|
||||
enter : func {
|
||||
if (me.pointer < 3) {
|
||||
me.pointer += 1;
|
||||
me.value = 0;
|
||||
}
|
||||
else
|
||||
me.searched = airportinfo(me.oaci[0]~me.oaci[1]~me.oaci[2]~me.oaci[3]);
|
||||
},
|
||||
escape : func {
|
||||
me.oaci = ["-","-","-","-"];
|
||||
me.pointer = 0;
|
||||
me.searched = nil;
|
||||
},
|
||||
start : func {
|
||||
var searched = airportinfo(arg[0]);
|
||||
if (searched != nil) {
|
||||
screenAirportMain.apt = searched;
|
||||
screenAirportMain.searched = 1;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
},
|
||||
lines : func {
|
||||
if (me.searched == nil)
|
||||
display([
|
||||
"SEARCH AIRPORT:",
|
||||
sprintf("%s%s%s%s",me.oaci[0],me.oaci[1],me.oaci[2],me.oaci[3]),
|
||||
"",
|
||||
"",
|
||||
""
|
||||
]);
|
||||
else {
|
||||
screenAirportMain.lines(me.searched);
|
||||
me.right();
|
||||
}
|
||||
EditMode(4, "AIRPORT CODE", "SEARCH");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -81,14 +81,21 @@ var screenModeAndSettings = { # screen for changing the GPS mode and settings
|
|||
};
|
||||
|
||||
var screenPositionMain = { # screens for POSITION mode
|
||||
coord : [0,0,0],
|
||||
right : func {
|
||||
},
|
||||
enter : func {
|
||||
GPSPositionEdit();
|
||||
var ac = geo.aircraft_position();
|
||||
me.coord = [ac.lat(), ac.lon(), ac.alt()];
|
||||
EditMode(6, "EDIT WAYPOINT ID", "SAVE");
|
||||
},
|
||||
escape : func {
|
||||
},
|
||||
start : func {
|
||||
if (mode == 5) {
|
||||
add_bookmark(arg[0], arg[0], "GPS", me.coord);
|
||||
return 1; #make gps quitting edition mode, back to previous mode and page
|
||||
}
|
||||
},
|
||||
lines : func {
|
||||
display ([
|
||||
|
@ -186,13 +193,11 @@ var screenNavigationMain = {
|
|||
gps_wp.getNode("wp/latitude-deg",1).setValue(gps_wp.getNode("wp[1]/latitude-deg",1).getValue());
|
||||
gps_wp.getNode("wp/altitude-ft",1).setValue(gps_wp.getNode("wp[1]/altitude-ft",1).getValue());
|
||||
gps_wp.getNode("wp/ID",1).setValue(gps_wp.getNode("wp[1]/ID",1).getValue());
|
||||
#gps_wp.getNode("wp/name",1).setValue(gps_wp.getNode("wp[1]/name",1).getValue());
|
||||
|
||||
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(next.getNode("longitude-deg",1).getValue());
|
||||
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(next.getNode("latitude-deg",1).getValue());
|
||||
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(next.getNode("altitude-ft",1).getValue());
|
||||
gps_wp.getNode("wp[1]/ID",1).setValue(next.getNode("ID",1).getValue());
|
||||
#gps_wp.getNode("wp[1]/name",1).setValue(next.getNode("name",1).getValue());
|
||||
}
|
||||
else {
|
||||
page = 0; #screenTaskSelect
|
||||
|
@ -202,11 +207,18 @@ var screenNavigationMain = {
|
|||
right : func {
|
||||
},
|
||||
enter : func {
|
||||
if (mode == 3) me.nextWaypoint();
|
||||
if (mode == 4) me.nextWaypoint();
|
||||
else add_waypoint(gps_wp.getNode("wp[1]/ID",1).getValue(),
|
||||
gps_wp.getNode("wp[1]/name",1).getValue(),
|
||||
gps_wp.getNode("wp[1]/waypoint-type",1).getValue(),
|
||||
[gps_wp.getNode("wp[1]/latitude-deg",1).getValue(),
|
||||
gps_wp.getNode("wp[1]/longitude-deg",1).getValue(),
|
||||
gps_wp.getNode("wp[1]/altitude-ft",1).getValue()]);
|
||||
},
|
||||
escape : func {
|
||||
},
|
||||
start : func {
|
||||
if (mode != 4) save_route();
|
||||
},
|
||||
lines : func {
|
||||
me.waypoint = gps_wp.getNode("wp[1]",1);
|
||||
|
@ -221,8 +233,9 @@ var screenNavigationMain = {
|
|||
me.graph = substr(me.graph,0, cursor) ~ "|" ~ substr(me.graph, cursor+1, size(me.graph));
|
||||
}
|
||||
display ([
|
||||
sprintf("ID: %s",
|
||||
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "WP NOT NAMED!"),
|
||||
sprintf("ID: %s [%s]",
|
||||
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "WP NOT NAMED!",
|
||||
me.waypoint.getNode("type",1).getValue() != nil ? me.waypoint.getNode("type").getValue() : "---"),
|
||||
sprintf("BRG: %d° DST: %d %s",
|
||||
me.waypoint.getNode("bearing-mag-deg",1).getValue(),
|
||||
me.waypoint.getNode("distance-nm",1).getValue() * dist_conv[0][dist_unit],
|
||||
|
@ -245,48 +258,58 @@ var screenEdit = {
|
|||
alphanum: ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
|
||||
"Q","R","S","T","U","V","W","X","Y","Z",
|
||||
"0","1","2","3","4","5","6","7","8","9"],
|
||||
numeric: ["0","1","2","3","4","5","6","7","8","9"],
|
||||
IDmap: ["-","-","-","-","-","-"],
|
||||
numeric: ["0","1","2","3","4","5","6","7","8","9","."],
|
||||
start_command: "",
|
||||
edit_zone: "",
|
||||
edit_title : "",
|
||||
carset: [],
|
||||
map: [],
|
||||
pointer: 0,
|
||||
value: 0,
|
||||
coord: [0,0,0],
|
||||
init: func (length, title, start_command, set = 0) {
|
||||
for (var i = 0; i < length; i += 1) append(me.map, "-");
|
||||
me.edit_title = title;
|
||||
me.start_command = start_command;
|
||||
me.carset = set != 0 ? me.numeric : me.alphanum;
|
||||
left_knob(0); # force display
|
||||
},
|
||||
right : func {
|
||||
me.value = cycle(size(me.alphanum), me.value, arg[0]);
|
||||
me.IDmap[me.pointer] = me.alphanum[me.value];
|
||||
me.value = cycle(size(me.carset), me.value, arg[0]);
|
||||
me.map[me.pointer] = me.carset[me.value];
|
||||
},
|
||||
enter : func {
|
||||
me.pointer = cycle(size(me.IDmap), me.pointer, 1);
|
||||
me.pointer = cycle(size(me.map), me.pointer, 1);
|
||||
me.value = 0;
|
||||
},
|
||||
escape : func {
|
||||
#save_bookmarks();
|
||||
me.IDmap = ["-","-","-","-","-","-"];
|
||||
me.map = [];
|
||||
me.pointer = 0;
|
||||
me.value = 0;
|
||||
me.start_command = "";
|
||||
me.edit_zone = "";
|
||||
me.edit_title = "";
|
||||
me.carset = [];
|
||||
me.map = [];
|
||||
mode = me.previous_mode;
|
||||
page = me.previous_page;
|
||||
left_knob(0);
|
||||
left_knob(0); # force new display
|
||||
},
|
||||
start : func {
|
||||
var ID = "";
|
||||
for (var i = 0; i < size(me.IDmap); i += 1)
|
||||
ID ~= me.IDmap[i] != "-" ? me.IDmap[i] : "";
|
||||
var bookmark = gps_data.getNode("bookmarks/bookmark["~screenTurnpointSelect.n~"]/",1);
|
||||
screenTurnpointSelect.n += 1;
|
||||
bookmark.getNode("ID",1).setValue(ID);
|
||||
bookmark.getNode("latitude-deg",1).setDoubleValue(me.coord[0]);
|
||||
bookmark.getNode("longitude-deg",1).setDoubleValue(me.coord[1]);
|
||||
bookmark.getNode("altitude-ft",1).setDoubleValue(me.coord[2]*alt_conv[1][0]);
|
||||
bookmark.getNode("infos",1).setValue("no infos");
|
||||
me.escape();
|
||||
var str = "";
|
||||
for (var i = 0; i < size(me.map); i += 1)
|
||||
str ~= me.map[i] != "-" ? me.map[i] : "";
|
||||
if (screen[page_list[me.previous_mode][me.previous_page]].start(str)) me.escape();
|
||||
},
|
||||
lines : func {
|
||||
me.right(0); #init car
|
||||
me.edit_zone = "";
|
||||
for (var i=0; i < size(me.map); i+=1) me.edit_zone ~= me.map[i];
|
||||
display([
|
||||
"ENTER POINT ID",
|
||||
sprintf("%s%s%s%s%s%s",me.IDmap[0],me.IDmap[1],me.IDmap[2],me.IDmap[3],me.IDmap[4],me.IDmap[5]),
|
||||
me.edit_title,
|
||||
me.edit_zone,
|
||||
"",
|
||||
"ESC -> AVOID",
|
||||
"START -> SAVE"
|
||||
sprintf("START -> %s", me.start_command)
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,12 +3,14 @@ var screenTurnpointSelect = {
|
|||
page: 0,
|
||||
pointer: 0,
|
||||
loaded: 0,
|
||||
selected: 0,
|
||||
right : func {
|
||||
me.loaded = 0;
|
||||
blocked = 1;
|
||||
var t = browse(me.n, me.pointer, me.page, arg[0]);
|
||||
me.pointer = t[0];
|
||||
me.page = t[1];
|
||||
me.selected = me.page*5 + me.pointer;
|
||||
},
|
||||
enter : func {
|
||||
},
|
||||
|
@ -21,7 +23,7 @@ var screenTurnpointSelect = {
|
|||
gps_wp.getNode("wp/altitude-ft",1).setValue(gps_data.getNode("indicated-altitude-ft",1).getValue());
|
||||
gps_wp.getNode("wp/ID").setValue("startpos");
|
||||
|
||||
var bookmark = gps_data.getNode("bookmarks/bookmark["~((me.page*5)+me.pointer)~"]/");
|
||||
var bookmark = gps_data.getNode("bookmarks/bookmark["~me.selected~"]/");
|
||||
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(bookmark.getNode("latitude-deg",1).getValue());
|
||||
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(bookmark.getNode("longitude-deg",1).getValue());
|
||||
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(bookmark.getNode("altitude-ft",1).getValue());
|
||||
|
|
|
@ -163,6 +163,28 @@ var list_routes = func {
|
|||
return size(routes);
|
||||
}
|
||||
|
||||
var add_waypoint = func (ID, name, type, coord) {
|
||||
var waypoint = gps_data.getNode("route/Waypoint["~screenWaypointsList.n~"]/",1);
|
||||
screenWaypointsList.n += 1;
|
||||
waypoint.getNode("ID",1).setValue(ID);
|
||||
waypoint.getNode("latitude-deg",1).setDoubleValue(coord[0]);
|
||||
waypoint.getNode("longitude-deg",1).setDoubleValue(coord[1]);
|
||||
waypoint.getNode("altitude-ft",1).setDoubleValue(coord[2]*alt_conv[1][0]);
|
||||
waypoint.getNode("name",1).setValue(name);
|
||||
waypoint.getNode("desc",1).setValue("no infos");
|
||||
waypoint.getNode("waypoint-type",1).setValue(type);
|
||||
}
|
||||
|
||||
var save_route = func {
|
||||
var first_id = gps_data.getNode("route/Waypoint/ID").getValue();
|
||||
var last_id = gps_data.getNode("route/Waypoint["~(screenWaypointsList.n - 1)~"]/ID").getValue();
|
||||
var path = getprop("/sim/fg-home") ~ "/Export/"~first_id~"-"~last_id~".xml";
|
||||
var args = props.Node.new({ filename : path });
|
||||
var export = args.getNode("data", 1);
|
||||
props.copy(gps_data.getNode("route"), export);
|
||||
fgcommand("savexml", args);
|
||||
}
|
||||
|
||||
var waypointAlert = func {
|
||||
mode > 0 or return;
|
||||
var ttw = gps_wp.getNode("wp[1]/TTW",1).getValue();
|
||||
|
@ -183,7 +205,7 @@ var waypointAlert = func {
|
|||
var load_bookmarks = func {
|
||||
var n = 0;
|
||||
gps_data.getNode("bookmarks",1).removeChildren("bookmark");
|
||||
var file = getprop("/sim/fg-home") ~ "/bookmarks.xml";
|
||||
var file = getprop("/sim/fg-home") ~ "/Export/bookmarks.xml";
|
||||
var s = io.stat(file);
|
||||
if (s != nil) {
|
||||
fgcommand("loadxml", props.Node.new({
|
||||
|
@ -198,26 +220,30 @@ var load_bookmarks = func {
|
|||
var save_bookmarks = func {
|
||||
var path = getprop("/sim/fg-home") ~ "/Export/bookmarks.xml";
|
||||
var args = props.Node.new({ filename : path });
|
||||
var export = args.getNode("/instrumentation/gps/bookmarks", 1);
|
||||
foreach (var c; gps_data.getNode("bookmarks").getChildren("bookmark")) {
|
||||
var b = export.getChild("bookmark",1);
|
||||
b.getNode("ID", 1).setValue(c.getNode("ID").getValue());
|
||||
b.getNode("latitude-deg", 1).setValue(c.getNode("latitude-deg").getValue());
|
||||
b.getNode("longitude-deg", 1).setValue(c.getNode("longitude-deg").getValue());
|
||||
b.getNode("altitude-ft", 1).setValue(c.getNode("altitude-ft").getValue());
|
||||
b.getNode("infos", 1).setValue(c.getNode("infos").getValue());
|
||||
}
|
||||
var export = args.getNode("data", 1);
|
||||
props.copy(gps_data.getNode("bookmarks"), export);
|
||||
fgcommand("savexml", args);
|
||||
}
|
||||
|
||||
var GPSPositionEdit = func {
|
||||
var add_bookmark = func (ID, name, type, coord) {
|
||||
var bookmark = gps_data.getNode("bookmarks/bookmark["~screenTurnpointSelect.n~"]/",1);
|
||||
screenTurnpointSelect.n += 1;
|
||||
bookmark.getNode("ID",1).setValue(ID);
|
||||
bookmark.getNode("latitude-deg",1).setDoubleValue(coord[0]);
|
||||
bookmark.getNode("longitude-deg",1).setDoubleValue(coord[1]);
|
||||
bookmark.getNode("altitude-ft",1).setDoubleValue(coord[2]*alt_conv[1][0]);
|
||||
bookmark.getNode("name",1).setValue(name);
|
||||
bookmark.getNode("desc",1).setValue("no infos");
|
||||
bookmark.getNode("waypoint-type",1).setValue(type);
|
||||
save_bookmarks();
|
||||
}
|
||||
|
||||
var EditMode = func (length, start_command, start_func, numcar = 0) {
|
||||
screenEdit.previous_mode = mode;
|
||||
screenEdit.previous_page = page;
|
||||
mode = 5; #ID edition
|
||||
page = 0;
|
||||
var ac = geo.aircraft_position();
|
||||
screenEdit.coord = [ac.lat(), ac.lon(), ac.alt()];
|
||||
left_knob(0);
|
||||
screenEdit.init(length, start_command, start_func, numcar = 0);
|
||||
}
|
||||
|
||||
### initialisation stuff ###################################################
|
||||
|
|
Loading…
Add table
Reference in a new issue