2017-11-21 02:04:19 +00:00
|
|
|
# A3XX ND Canvas
|
|
|
|
# Joshua Davidson (it0uchpods)
|
|
|
|
# Based on work by artix
|
|
|
|
|
|
|
|
##############################################
|
|
|
|
# Copyright (c) Joshua Davidson (it0uchpods) #
|
|
|
|
##############################################
|
|
|
|
|
2017-06-19 00:14:41 +00:00
|
|
|
canvas.RouteDriver = {
|
|
|
|
new: func(){
|
|
|
|
var m = {
|
|
|
|
parents: [canvas.RouteDriver],
|
|
|
|
};
|
|
|
|
m.init();
|
|
|
|
return m;
|
|
|
|
},
|
|
|
|
init: func(){
|
|
|
|
me.update();
|
|
|
|
},
|
|
|
|
update: func(){
|
|
|
|
me.flightplan = flightplan();
|
|
|
|
},
|
|
|
|
getNumberOfFlightPlans: func(){1},
|
2017-11-20 22:03:07 +00:00
|
|
|
getFlightPlanType: func(fpNum){"active"},
|
2017-06-19 00:14:41 +00:00
|
|
|
getFlightPlan: func(fpNum){me.flightplan},
|
|
|
|
getPlanSize: func(fpNum){me.flightplan.getPlanSize()},
|
|
|
|
getWP: func(fpNum, idx){me.flightplan.getWP(idx)},
|
|
|
|
getListeners: func(){[]},
|
|
|
|
getPlanModeWP: func(plan_wp_idx){me.flightplan.getWP(plan_wp_idx)},
|
|
|
|
hasDiscontinuity: func(fpNum, wpt){0},
|
|
|
|
getHoldPattern: func(fpNum, wpt){nil},
|
|
|
|
getHoldPatterns: func(fpNum){[]},
|
|
|
|
shouldUpdate: func 1,
|
|
|
|
shouldDisplayWP: func(fpNum, idx) 1,
|
2017-11-20 22:03:07 +00:00
|
|
|
getCurrentWPIdx: func(fpNum) getprop("autopilot/route-manager/current-wp"),
|
2017-06-19 00:14:41 +00:00
|
|
|
getTimeConstraint: func (fpNum, wp_idx) {nil}
|
|
|
|
};
|
|
|
|
|
|
|
|
canvas.MultiRouteDriver = {
|
|
|
|
parents: [canvas.RouteDriver],
|
|
|
|
new: func(){
|
|
|
|
var m = {
|
|
|
|
parents: [MultiRouteDriver],
|
|
|
|
_flightplans: [],
|
|
|
|
currentFlightPlan: 0
|
|
|
|
};
|
|
|
|
m.init();
|
|
|
|
return m;
|
|
|
|
},
|
|
|
|
addFlightPlan: func(type, plan){
|
|
|
|
append(me._flightplans, {
|
|
|
|
type: type,
|
|
|
|
flightplan: plan
|
|
|
|
});
|
|
|
|
},
|
|
|
|
removeFlightPlanAtIndex: func(idx){
|
|
|
|
var sz = size(me._flightplans);
|
|
|
|
if(idx < sz){
|
|
|
|
if(sz == 1)
|
|
|
|
me._flightplans = [];
|
|
|
|
elsif(sz == 2 and idx == 0)
|
|
|
|
me._flightplans = [me._flightplans[1]];
|
|
|
|
elsif(sz == 2 and idx == 1)
|
|
|
|
pop(me._flightplans);
|
|
|
|
else {
|
|
|
|
var subv_l = subvec(me._flightplans, 0, idx);
|
|
|
|
var subv_r = subvec(me._flightplans, idx + 1);
|
|
|
|
me._flightplans = subv_l ~ subv_r;
|
|
|
|
}
|
|
|
|
}
|
2017-11-20 22:03:07 +00:00
|
|
|
me.triggerSignal("fp-added");
|
2017-06-19 00:14:41 +00:00
|
|
|
},
|
|
|
|
removeFlightPlanOfType: func(type){
|
|
|
|
var new_vec = [];
|
|
|
|
foreach(var fp; me._flightplans){
|
2017-11-20 22:03:07 +00:00
|
|
|
if(fp["type"] != type)
|
2017-06-19 00:14:41 +00:00
|
|
|
append(new_vec, fp);
|
|
|
|
}
|
|
|
|
me._flightplans = new_vec;
|
2017-11-20 22:03:07 +00:00
|
|
|
me.triggerSignal("fp-removed");
|
2017-06-19 00:14:41 +00:00
|
|
|
},
|
|
|
|
getNumberOfFlightPlans: func(){
|
|
|
|
size(me._flightplans);
|
|
|
|
},
|
|
|
|
getFlightPlanType: func(fpNum){
|
|
|
|
if(fpNum >= size(me._flightplans)) return nil;
|
|
|
|
var fp = me._flightplans[fpNum];
|
|
|
|
return fp.type;
|
|
|
|
},
|
|
|
|
getFlightPlan: func(fpNum){
|
|
|
|
if(fpNum >= size(me._flightplans)) return nil;
|
|
|
|
return me._flightplans[fpNum];
|
|
|
|
},
|
|
|
|
getPlanSize: func(fpNum){
|
|
|
|
if(fpNum >= size(me._flightplans)) return 0;
|
|
|
|
return me._flightplans[fpNum].getPlanSize();
|
|
|
|
},
|
|
|
|
getWP: func(fpNum, idx){
|
|
|
|
if(fpNum >= size(me._flightplans)) return nil;
|
|
|
|
var fp = me._flightplans[fpNum];
|
|
|
|
return fp.getWP(idx);
|
|
|
|
},
|
|
|
|
getPlanModeWP: func(idx){
|
|
|
|
if(me.currentFlightPlan >= size(me._flightplans)) return nil;
|
|
|
|
var fp = me._flightplans[me.currentFlightPlan];
|
|
|
|
return fp.getWP(idx);
|
|
|
|
},
|
|
|
|
triggerSignal: func(signal){
|
|
|
|
setprop(me.signalPath(signal));
|
|
|
|
},
|
|
|
|
signalPath: func(signal){
|
2017-11-20 22:03:07 +00:00
|
|
|
"autopilot/route-manager/signals/rd-"~ signal;
|
2017-06-19 00:14:41 +00:00
|
|
|
},
|
|
|
|
getListeners: func(){[
|
2017-11-20 22:03:07 +00:00
|
|
|
me.getSignal("fp-added"),
|
|
|
|
me.getSignal("fp-removed")
|
2017-06-19 00:14:41 +00:00
|
|
|
]},
|
|
|
|
getCurrentWPIdx: func(fpNum) {
|
|
|
|
var fp = me.getFlightPlan(fpNum);
|
|
|
|
var wp = fp.getWP();
|
|
|
|
if (wp == nil) return -1;
|
|
|
|
return wp.index;
|
|
|
|
}
|
|
|
|
};
|