- Sebastien Marque: Changes to fit the new route-manager system.
This commit is contained in:
parent
98f75bed75
commit
f72f1b3cd6
6 changed files with 66 additions and 64 deletions
|
@ -178,27 +178,10 @@ var screenWindInfos = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var screenNavigationMain = {
|
var screenNavigationMain = {
|
||||||
nextWaypoint : func {
|
|
||||||
waypointindex += 1;
|
|
||||||
next = gps_data.getNode("route/Waypoint[" ~ waypointindex ~ "]/",1);
|
|
||||||
if (next != nil) {
|
|
||||||
var scratch = gps_data.getNode("scratch");
|
|
||||||
scratch.getNode("longitude-deg",1).setValue(next.getNode("longitude-deg",1).getValue());
|
|
||||||
scratch.getNode("latitude-deg",1).setValue(next.getNode("latitude-deg",1).getValue());
|
|
||||||
scratch.getNode("altitude-ft",1).setValue(next.getNode("altitude-ft",1).getValue());
|
|
||||||
scratch.getNode("type",1).setValue(next.getNode("waypoint-type",1).getValue());
|
|
||||||
scratch.getNode("ident",1).setValue(next.getNode("ID",1).getValue());
|
|
||||||
gps_data.getNode("command").setValue("obs");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
page = 0; #screenTaskSelect
|
|
||||||
refresh_display();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
right : func {
|
right : func {
|
||||||
},
|
},
|
||||||
enter : func {
|
enter : func {
|
||||||
if (mode == 4) me.nextWaypoint();
|
if (mode == 4) apply_command("next");
|
||||||
else add_waypoint(gps_wp.getNode("wp[1]/ID",1).getValue(),
|
else add_waypoint(gps_wp.getNode("wp[1]/ID",1).getValue(),
|
||||||
gps_wp.getNode("wp[1]/name",1).getValue(),
|
gps_wp.getNode("wp[1]/name",1).getValue(),
|
||||||
gps_wp.getNode("wp[1]/waypoint-type",1).getValue(),
|
gps_wp.getNode("wp[1]/waypoint-type",1).getValue(),
|
||||||
|
@ -213,7 +196,10 @@ var screenNavigationMain = {
|
||||||
},
|
},
|
||||||
lines : func {
|
lines : func {
|
||||||
me.waypoint = gps_wp.getNode("wp[1]");
|
me.waypoint = gps_wp.getNode("wp[1]");
|
||||||
crs_deviation = me.waypoint.getNode("course-deviation-deg").getValue();
|
var crs_deviation = me.waypoint.getNode("course-error-nm").getValue();
|
||||||
|
var dist = me.waypoint.getNode("course-error-nm").getValue();
|
||||||
|
if (dist < 5) crs_deviation *= 5;
|
||||||
|
else crs_deviation *= 2.5;
|
||||||
if (crs_deviation > 5)
|
if (crs_deviation > 5)
|
||||||
me.graph = "[- - - - - ^ > > > > >]";
|
me.graph = "[- - - - - ^ > > > > >]";
|
||||||
elsif (crs_deviation < -5)
|
elsif (crs_deviation < -5)
|
||||||
|
@ -223,13 +209,18 @@ var screenNavigationMain = {
|
||||||
cursor = int((crs_deviation * 2) + 11);
|
cursor = int((crs_deviation * 2) + 11);
|
||||||
me.graph = substr(me.graph,0, cursor) ~ "|" ~ substr(me.graph, cursor+1, size(me.graph));
|
me.graph = substr(me.graph,0, cursor) ~ "|" ~ substr(me.graph, cursor+1, size(me.graph));
|
||||||
}
|
}
|
||||||
|
var ID = me.waypoint.getNode("ID");
|
||||||
|
var current_wp = getprop("/autopilot/route-manager/current-wp") - 1;
|
||||||
|
var type = nil;
|
||||||
|
if (current_wp > -1)
|
||||||
|
type = gps_data.getNode("route/Waypoint[" ~ current_wp ~ "]/waypoint-type");
|
||||||
display ([
|
display ([
|
||||||
sprintf("ID: %s [%s]",
|
sprintf("ID: %s [%s]",
|
||||||
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "-----",
|
ID != nil ? ID.getValue() : "-----",
|
||||||
me.waypoint.getNode("waypoint-type",1).getValue() != nil ? me.waypoint.getNode("waypoint-type").getValue() : "---"),
|
type != nil ? type.getValue() : "---"),
|
||||||
sprintf("BRG: %d° DST: %d %s",
|
sprintf("BRG: %d° DST: %d %s",
|
||||||
me.waypoint.getNode("bearing-mag-deg",1).getValue(),
|
me.waypoint.getNode("bearing-mag-deg",1).getValue(),
|
||||||
me.waypoint.getNode("distance-nm",1).getValue() * dist_conv[0][dist_unit],
|
dist * dist_conv[0][dist_unit],
|
||||||
dist_unit_short_name[dist_unit]),
|
dist_unit_short_name[dist_unit]),
|
||||||
sprintf("XCRS: %d* (%.1f %s)",
|
sprintf("XCRS: %d* (%.1f %s)",
|
||||||
me.waypoint.getNode("course-deviation-deg").getValue(),
|
me.waypoint.getNode("course-deviation-deg").getValue(),
|
||||||
|
@ -237,9 +228,7 @@ var screenNavigationMain = {
|
||||||
dist_unit_short_name[dist_unit]),
|
dist_unit_short_name[dist_unit]),
|
||||||
sprintf("TTW: %s",
|
sprintf("TTW: %s",
|
||||||
me.waypoint.getNode("TTW").getValue()),
|
me.waypoint.getNode("TTW").getValue()),
|
||||||
me.graph
|
me.graph]);
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,24 @@ var screenTaskSelect = {
|
||||||
me.page = t[1];
|
me.page = t[1];
|
||||||
},
|
},
|
||||||
load : func {
|
load : func {
|
||||||
screenWaypointsList.n = 0;
|
setprop("/autopilot/route-manager/active", 0);
|
||||||
gps_data.getNode("route",1).removeChildren("Waypoint");
|
gps_data.getNode("route",1).removeChildren("Waypoint");
|
||||||
|
getprop("/autopilot/route-manager/route/num") == 0 or apply_command("route-delete");
|
||||||
fgcommand("loadxml", props.Node.new({
|
fgcommand("loadxml", props.Node.new({
|
||||||
"filename": getprop("/sim/fg-home") ~ "/Routes/" ~ routes[(me.page * 5) + me.pointer],
|
"filename": getprop("/sim/fg-home") ~ "/Routes/" ~ routes[(me.page * 5) + me.pointer],
|
||||||
"targetnode": "/instrumentation/gps/route"
|
"targetnode": "/instrumentation/gps/route"
|
||||||
}));
|
}));
|
||||||
foreach (var c; gps_data.getNode("route").getChildren("Waypoint"))
|
var n = 0;
|
||||||
screenWaypointsList.n += 1;
|
scratch.getNode("index").setIntValue(-1);
|
||||||
waypointindex = -1;
|
apply_command("route-insert-after");
|
||||||
screenNavigationMain.nextWaypoint();
|
foreach (var c; gps_data.getNode("route").getChildren("Waypoint")) n += 1;
|
||||||
|
for (var i = 0; i < n; i += 1) {
|
||||||
|
scratch.getNode("index").setIntValue(-1);
|
||||||
|
Waypoint_to_scratch(gps_data.getNode("route/Waypoint[" ~ i ~ "]"));
|
||||||
|
apply_command("route-insert-after");
|
||||||
|
}
|
||||||
|
apply_command("leg");
|
||||||
|
setprop("/autopilot/route-manager/active", 1);
|
||||||
me.loaded = 1;
|
me.loaded = 1;
|
||||||
},
|
},
|
||||||
enter : func {
|
enter : func {
|
||||||
|
|
|
@ -18,21 +18,8 @@ var screenTurnpointSelect = {
|
||||||
},
|
},
|
||||||
start : func {
|
start : func {
|
||||||
me.n > 0 or return;
|
me.n > 0 or return;
|
||||||
var bookmark = gps_data.getNode("bookmarks/bookmark["~me.selected~"]/");
|
Waypoint_to_scratch(gps_data.getNode("bookmarks/bookmark["~me.selected~"]/"));
|
||||||
var scratch = gps_data.getNode("scratch");
|
apply_command("obs");
|
||||||
scratch.getNode("latitude-deg",1).setValue(bookmark.getNode("latitude-deg").getValue());
|
|
||||||
scratch.getNode("longitude-deg",1).setValue(bookmark.getNode("longitude-deg").getValue());
|
|
||||||
scratch.getNode("altitude-ft",1).setValue(bookmark.getNode("altitude-ft").getValue());
|
|
||||||
scratch.getNode("ident").setValue(bookmark.getNode("ID").getValue());
|
|
||||||
if (bookmark.getNode("name") != nil)
|
|
||||||
scratch.getNode("name",1).setValue(bookmark.getNode("name").getValue());
|
|
||||||
else
|
|
||||||
scratch.getNode("name",1).setValue("");
|
|
||||||
if (bookmark.getNode("type") != nil)
|
|
||||||
scratch.getNode("type",1).setValue(bookmark.getNode("waypoint-type").getValue());
|
|
||||||
else
|
|
||||||
scratch.getNode("type",1).setValue("");
|
|
||||||
gps_data.getNode("command").setValue("obs");
|
|
||||||
blocked = 0;
|
blocked = 0;
|
||||||
me.loaded = 1;
|
me.loaded = 1;
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|
|
@ -49,7 +49,9 @@ var dist_conv = [[1.00000 ,1.852, 1852], #from nm
|
||||||
[0.00053996,0.001, 1.00]]; #from m
|
[0.00053996,0.001, 1.00]]; #from m
|
||||||
|
|
||||||
var gps_data = props.globals.getNode("/instrumentation/gps",1);
|
var gps_data = props.globals.getNode("/instrumentation/gps",1);
|
||||||
|
var scratch = gps_data.getNode("scratch",1);
|
||||||
var gps_wp = gps_data.getNode("wp",1);
|
var gps_wp = gps_data.getNode("wp",1);
|
||||||
|
var route = props.globals.getNode("/autopilot/route-manager/route",1);
|
||||||
|
|
||||||
#### warps for buttons and knobs ########################################"
|
#### warps for buttons and knobs ########################################"
|
||||||
var right_knob = func(dir) { #manage right knob, depends of displayed screen
|
var right_knob = func(dir) { #manage right knob, depends of displayed screen
|
||||||
|
@ -119,9 +121,13 @@ var display = func () { #display the array line[]
|
||||||
for (var i = 0; i < LINES; i += 1) line[i].setValue(arg[0][i]);
|
for (var i = 0; i < LINES; i += 1) line[i].setValue(arg[0][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var apply_command = func (command) {
|
||||||
|
gps_data.getNode("command").setValue(command);
|
||||||
|
}
|
||||||
|
|
||||||
var browse = func (entries_nbr, index_pointer, index_page,dir) {
|
var browse = func (entries_nbr, index_pointer, index_page,dir) {
|
||||||
#browse multipaged entries, returns [pointer in page, page]
|
#browse multipaged entries, returns [pointer in page, page]
|
||||||
nl = entries_nbr - (index_page * LINES) > LINES ? LINES : math.mod(entries_nbr - (index_page * LINES), LINES);
|
nl = entries_nbr - (index_page * LINES) >= LINES ? LINES : math.mod(entries_nbr - (index_page * LINES), LINES);
|
||||||
if (index_pointer + 1 == nl) {
|
if (index_pointer + 1 == nl) {
|
||||||
np = int(entries_nbr / LINES) + (math.mod(entries_nbr,LINES) ? 1 : 0);
|
np = int(entries_nbr / LINES) + (math.mod(entries_nbr,LINES) ? 1 : 0);
|
||||||
index_page = cycle(np, index_page, dir);
|
index_page = cycle(np, index_page, dir);
|
||||||
|
@ -145,6 +151,7 @@ var refresh_display = func(forced = 1) { #refresh displayed lines, settimer if n
|
||||||
refresh_timer += 1;
|
refresh_timer += 1;
|
||||||
settimer(func { refresh_display(0); }, freq, 1);
|
settimer(func { refresh_display(0); }, freq, 1);
|
||||||
}
|
}
|
||||||
|
waypointAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
var seconds_to_string = func (time) { #converts secs (double) in string "hh:mm:ss"
|
var seconds_to_string = func (time) { #converts secs (double) in string "hh:mm:ss"
|
||||||
|
@ -196,20 +203,30 @@ var save_route = func { #save the route
|
||||||
fgcommand("savexml", args);
|
fgcommand("savexml", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
var waypointAlert = func { #alert pilot about waypoint approach
|
var Waypoint_to_scratch = func (node) {
|
||||||
mode > 0 or return;
|
scratch.getNode("latitude-deg",1).setValue(node.getNode("latitude-deg").getValue());
|
||||||
var ttw = gps_wp.getNode("wp[1]/TTW",1).getValue();
|
scratch.getNode("longitude-deg",1).setValue(node.getNode("longitude-deg").getValue());
|
||||||
var ttw_secs = 9999;
|
scratch.getNode("altitude-ft",1).setValue(node.getNode("altitude-ft").getValue());
|
||||||
if (string.isdigit(ttw[0]))
|
scratch.getNode("ident").setValue(node.getNode("ID").getValue());
|
||||||
ttw_secs = num(substr(ttw,0,2))*3600 + num(substr(ttw,3,2))*60 + num(substr(ttw,6,2));
|
if (node.getNode("name") != nil)
|
||||||
|
scratch.getNode("name",1).setValue(node.getNode("name").getValue());
|
||||||
if (ttw_secs < thresold_alert[thresold_alert_index])
|
|
||||||
gps_data.getNode("waypoint-alert",1).setBoolValue(1);
|
|
||||||
else
|
else
|
||||||
gps_data.getNode("waypoint-alert",1).setBoolValue(0);
|
scratch.getNode("name",1).setValue("");
|
||||||
|
if (node.getNode("type") != nil)
|
||||||
if (mode == 4 and ttw_secs < thresold_next_waypoint)
|
scratch.getNode("type",1).setValue(node.getNode("waypoint-type").getValue());
|
||||||
screenNavigationMain.nextWaypoint();
|
else
|
||||||
|
scratch.getNode("type",1).setValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
var waypointAlert = func { #alert pilot about waypoint approach
|
||||||
|
if (mode) {
|
||||||
|
var ttw = getprop("/instrumentation/gps/wp/wp[1]/TTW-sec");
|
||||||
|
ttw > -1 or return;
|
||||||
|
if (ttw < thresold_alert[thresold_alert_index])
|
||||||
|
gps_data.getNode("waypoint-alert",1).setBoolValue(1);
|
||||||
|
else
|
||||||
|
gps_data.getNode("waypoint-alert",1).setBoolValue(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
### turnpoints management ######################################################
|
### turnpoints management ######################################################
|
||||||
|
@ -308,7 +325,6 @@ var init_gps_props = func {
|
||||||
aircraft.light.new("/sim/model/gps/greenled", [0.6, 0.3], "/instrumentation/gps/message-alert");
|
aircraft.light.new("/sim/model/gps/greenled", [0.6, 0.3], "/instrumentation/gps/message-alert");
|
||||||
startpos = geo.Coord.new(geo.aircraft_position());
|
startpos = geo.Coord.new(geo.aircraft_position());
|
||||||
screenPositionMain.begin_time = props.globals.getNode("/sim/time/elapsed-sec",1).getValue();
|
screenPositionMain.begin_time = props.globals.getNode("/sim/time/elapsed-sec",1).getValue();
|
||||||
setlistener("/instrumentation/gps/wp/wp[1]/TTW", waypointAlert, 0, 0);
|
|
||||||
setlistener("/instrumentation/gps/serviceable", func {
|
setlistener("/instrumentation/gps/serviceable", func {
|
||||||
if (getprop("/instrumentation/gps/serviceable") == 0)
|
if (getprop("/instrumentation/gps/serviceable") == 0)
|
||||||
setprop("/instrumentation/zkv500/retro-light", 0);
|
setprop("/instrumentation/zkv500/retro-light", 0);
|
||||||
|
|
|
@ -252,7 +252,9 @@ route. It is only available in TURNPOINT and TASK modes.
|
||||||
DST: remaining distance
|
DST: remaining distance
|
||||||
XCRS: course error in degree (in distance unit)
|
XCRS: course error in degree (in distance unit)
|
||||||
TTW: remaining estimated time
|
TTW: remaining estimated time
|
||||||
The graph represent the position of the aircraft along the leg. Each + means 1°,
|
The graph represents the position in nautic miles, of the aircraft on the leg.
|
||||||
|
The precision depends on the remaining distance before the waypoint. If less than
|
||||||
|
5 nm, each + means 0.1 nm, if greater than 5nm each + means 0.5 nm.
|
||||||
the | symbol represents the route, the little aircraft represents... the aircraft.
|
the | symbol represents the route, the little aircraft represents... the aircraft.
|
||||||
|
|
||||||
*** AirportMain ***
|
*** AirportMain ***
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
<key n="101">
|
<key n="101">
|
||||||
<name>e</name>
|
<name>e</name>
|
||||||
<desc>Enter button</desc>
|
<desc>Enter button</desc>
|
||||||
<exit/>
|
<no-exit/>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>zkv500.enter_button()</script>
|
<script>zkv500.enter_button()</script>
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
<key n="120">
|
<key n="120">
|
||||||
<name>x</name>
|
<name>x</name>
|
||||||
<desc>Escape button</desc>
|
<desc>Escape button</desc>
|
||||||
<exit/>
|
<no-exit/>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>zkv500.escape_button()</script>
|
<script>zkv500.escape_button()</script>
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
<key n="115">
|
<key n="115">
|
||||||
<name>s</name>
|
<name>s</name>
|
||||||
<desc>Start button</desc>
|
<desc>Start button</desc>
|
||||||
<exit/>
|
<no-exit/>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>zkv500.start_button()</script>
|
<script>zkv500.start_button()</script>
|
||||||
|
|
Loading…
Reference in a new issue