mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 08:15:19 +03:00
waypoint OOP version 1.8
This commit is contained in:
parent
30c3b043a3
commit
3265158791
7 changed files with 193 additions and 175 deletions
8
js/fc.js
8
js/fc.js
|
@ -548,14 +548,6 @@ var FC = {
|
|||
|
||||
SETTINGS = {};
|
||||
|
||||
/* SAFEHOME = {
|
||||
bufferPoint : {
|
||||
number: 0,
|
||||
enabled: 0,
|
||||
lon: 0,
|
||||
lat: 0
|
||||
}
|
||||
}; */
|
||||
SAFEHOMES = new SafehomeCollection();
|
||||
},
|
||||
getOutputUsages: function() {
|
||||
|
|
|
@ -440,7 +440,6 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
break;
|
||||
case MSPCodes.MSP_WP:
|
||||
console.log("data : ", data);
|
||||
MISSION_PLANER.put(new Waypoint(
|
||||
data.getUint8(0),
|
||||
data.getUint8(1),
|
||||
|
@ -1467,9 +1466,12 @@ var mspHelper = (function (gui) {
|
|||
SAFEHOMES.put(new Safehome(
|
||||
data.getUint8(0),
|
||||
data.getUint8(1),
|
||||
data.getInt32(2, true) / 1e7,
|
||||
data.getInt32(6, true) / 1e7
|
||||
data.getInt32(2, true),
|
||||
data.getInt32(6, true)
|
||||
));
|
||||
break;
|
||||
case MSPCodes.MSP2_INAV_SET_SAFEHOME:
|
||||
console.log('Safehome points saved');
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2148,13 +2150,6 @@ var mspHelper = (function (gui) {
|
|||
|
||||
buffer.push(BRAKING_CONFIG.bankAngle);
|
||||
break;
|
||||
|
||||
/* case MSPCodes.MSP2_INAV_SAFEHOME:
|
||||
console.log("SAFEHOME.bufferPoint.number : ",SAFEHOME.bufferPoint.number);
|
||||
buffer.push(SAFEHOME.bufferPoint.number+1);
|
||||
break;
|
||||
case MSPCodes.MSP2_INAV_SET_SAFEHOME:
|
||||
break; */
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -2925,33 +2920,36 @@ var mspHelper = (function (gui) {
|
|||
|
||||
self.loadWaypoints = function (callback) {
|
||||
MISSION_PLANER.reinit();
|
||||
mspHelper.getMissionInfo();
|
||||
console.log("MISSION_PLANER.getCountBusyPoints() ", MISSION_PLANER.getCountBusyPoints());
|
||||
let waypointId = 0;
|
||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
|
||||
let waypointId = 1;
|
||||
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, getFirstWP);
|
||||
|
||||
function getFirstWP() {
|
||||
console.log("MISSION_PLANER.getCountBusyPoints() ", MISSION_PLANER.getCountBusyPoints());
|
||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint)
|
||||
};
|
||||
|
||||
function nextWaypoint() {
|
||||
waypointId++;
|
||||
console.log("Display for LoadInternal");
|
||||
MISSION_PLANER.missionDisplayDebug();
|
||||
if (waypointId < MISSION_PLANER.get().length-1) {
|
||||
console.log("waypointId if ", waypointId);
|
||||
if (waypointId < MISSION_PLANER.getCountBusyPoints()) {
|
||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
|
||||
}
|
||||
else {
|
||||
console.log("waypointId else ", waypointId);
|
||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, callback);
|
||||
}
|
||||
};
|
||||
|
||||
function endMission() {
|
||||
console.log("End");
|
||||
};
|
||||
};
|
||||
|
||||
self.saveWaypoints = function (callback) {
|
||||
let waypointId = 0;
|
||||
let waypointId = 1;
|
||||
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint)
|
||||
|
||||
function nextWaypoint() {
|
||||
waypointId++;
|
||||
if (waypointId < MISSION_PLANER.get().length-1) {
|
||||
if (waypointId < MISSION_PLANER.get().length) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint);
|
||||
}
|
||||
else {
|
||||
|
@ -2960,7 +2958,6 @@ var mspHelper = (function (gui) {
|
|||
};
|
||||
|
||||
function endMission() {
|
||||
GUI.log('End send point');
|
||||
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, callback);
|
||||
}
|
||||
};
|
||||
|
@ -2980,6 +2977,25 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
};
|
||||
};
|
||||
|
||||
self.saveSafehomes = function (callback) {
|
||||
let safehomeId = 0;
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_SAFEHOME, SAFEHOMES.extractBuffer(safehomeId), false, nextSendSafehome);
|
||||
|
||||
function nextSendSafehome() {
|
||||
safehomeId++;
|
||||
if (safehomeId < SAFEHOMES.getMaxSafehomeCount()-1) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_SAFEHOME, SAFEHOMES.extractBuffer(safehomeId), false, nextSendSafehome);
|
||||
}
|
||||
else {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_SAFEHOME, SAFEHOMES.extractBuffer(safehomeId), false, callback);
|
||||
}
|
||||
};
|
||||
|
||||
function endSendSafehome() {
|
||||
console.log("end sending safehome");
|
||||
};
|
||||
};
|
||||
|
||||
self._getSetting = function (name) {
|
||||
if (SETTINGS[name]) {
|
||||
|
|
|
@ -21,14 +21,10 @@ let Safehome = function (number, enabled, lat, lon) {
|
|||
lon = data;
|
||||
};
|
||||
|
||||
self.getLonToMap = function () {
|
||||
self.getLonMap = function () {
|
||||
return lon / 1e7;
|
||||
};
|
||||
|
||||
self.setLonFromMap = function (data) {
|
||||
lon = data * 1e7;
|
||||
};
|
||||
|
||||
self.getLat = function () {
|
||||
return lat;
|
||||
};
|
||||
|
@ -37,14 +33,10 @@ let Safehome = function (number, enabled, lat, lon) {
|
|||
lat = data;
|
||||
};
|
||||
|
||||
self.getLatToMap = function () {
|
||||
self.getLatMap = function () {
|
||||
return lat / 1e7;
|
||||
};
|
||||
|
||||
self.setLatFromMap = function (data) {
|
||||
lat = data * 1e7;
|
||||
};
|
||||
|
||||
self.isUsed = function () {
|
||||
return enabled == 1;
|
||||
};
|
||||
|
|
|
@ -96,6 +96,38 @@ let SafehomeCollection = function () {
|
|||
data[newSafehome.getNumber()] = newSafehome;
|
||||
};
|
||||
|
||||
self.extractBuffer = function(safehomeId) {
|
||||
let buffer = [];
|
||||
let safehome = self.getSafehome(safehomeId);
|
||||
buffer.push(safehome.getNumber()); // sbufReadU8(src); // number
|
||||
buffer.push(safehome.getEnabled()); // sbufReadU8(src); // action
|
||||
buffer.push(specificByte(safehome.getLat(), 0)); // sbufReadU32(src); // lat
|
||||
buffer.push(specificByte(safehome.getLat(), 1));
|
||||
buffer.push(specificByte(safehome.getLat(), 2));
|
||||
buffer.push(specificByte(safehome.getLat(), 3));
|
||||
buffer.push(specificByte(safehome.getLon(), 0)); // sbufReadU32(src); // lon
|
||||
buffer.push(specificByte(safehome.getLon(), 1));
|
||||
buffer.push(specificByte(safehome.getLon(), 2));
|
||||
buffer.push(specificByte(safehome.getLon(), 3));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
self.safehomeDisplayDebug = function() {
|
||||
if (data && data.length != 0) {
|
||||
data.forEach(function (element) {
|
||||
console.log("N° : ", element.getNumber(),
|
||||
"Enabled : ", element.getEnabled(),
|
||||
"Lon : ", element.getLon(),
|
||||
"Lat : ", element.getLat(),
|
||||
);
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("Data empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
};
|
|
@ -46,6 +46,10 @@ let WaypointCollection = function () {
|
|||
self.getCenter = function () {
|
||||
return center;
|
||||
};
|
||||
|
||||
self.setCenter = function (data) {
|
||||
center = data;
|
||||
};
|
||||
|
||||
self.setCenterZoom = function (data) {
|
||||
center.zoom = data;
|
||||
|
@ -145,18 +149,25 @@ let WaypointCollection = function () {
|
|||
data = tmpData;
|
||||
};
|
||||
|
||||
self.update = function (bMWPfile=false) {
|
||||
self.update = function (bMWPfile=false, bReverse=false) {
|
||||
let oldWPNumber = 0;
|
||||
let optionIdx = 0;
|
||||
let idx = 0;
|
||||
data.forEach(function (element) {
|
||||
if (element.isUsed()) {
|
||||
if (bMWPfile) {
|
||||
if (bMWPfile && !bReverse) {
|
||||
element.setNumber(element.getNumber()-1);
|
||||
if (element.getAction() == MWNP.WPTYPE.JUMP) {
|
||||
element.setP1(element.getP1()-1);
|
||||
}
|
||||
}
|
||||
else if (bMWPfile && bReverse) {
|
||||
element.setNumber(element.getNumber()+1);
|
||||
if (element.getAction() == MWNP.WPTYPE.JUMP) {
|
||||
element.setP1(element.getP1()+1);
|
||||
}
|
||||
}
|
||||
|
||||
if ([MWNP.WPTYPE.JUMP,MWNP.WPTYPE.SET_HEAD,MWNP.WPTYPE.RTH].includes(element.getAction())) {
|
||||
element.setAttachedId(oldWPNumber);
|
||||
element.setAttachedNumber(optionIdx);
|
||||
|
@ -169,7 +180,8 @@ let WaypointCollection = function () {
|
|||
optionIdx = 0;
|
||||
idx++;
|
||||
}
|
||||
if (element.getNumber() == self.get().length-1) {
|
||||
console.log(((bMWPfile && bReverse) ? self.get().length : self.get().length-1));
|
||||
if (element.getNumber() == ((bMWPfile && bReverse) ? self.get().length : self.get().length-1)) {
|
||||
element.setEndMission(0xA5);
|
||||
}
|
||||
else {
|
||||
|
@ -255,17 +267,30 @@ let WaypointCollection = function () {
|
|||
}
|
||||
|
||||
self.missionDisplayDebug = function() {
|
||||
data.forEach(function (element) {
|
||||
console.log("N° : ", element.getNumber(),
|
||||
"Action : ", element.getAction(),
|
||||
"Lon : ", element.getLon(),
|
||||
"Lat : ", element.getLat(),
|
||||
"Alt : ", element.getAlt(),
|
||||
"P1 : ", element.getP1(),
|
||||
"P2 : ", element.getP2(),
|
||||
"P3 : ", element.getP3(),
|
||||
"EndMission : ", element.getEndMission());
|
||||
if (data && data.length != 0) {
|
||||
data.forEach(function (element) {
|
||||
console.log("N° : ", element.getNumber(),
|
||||
"Action : ", element.getAction(),
|
||||
"Lon : ", element.getLon(),
|
||||
"Lat : ", element.getLat(),
|
||||
"Alt : ", element.getAlt(),
|
||||
"P1 : ", element.getP1(),
|
||||
"P2 : ", element.getP2(),
|
||||
"P3 : ", element.getP3(),
|
||||
"EndMission : ", element.getEndMission());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
self.copy = function(mission){
|
||||
mission.get().forEach(function (element) {
|
||||
self.put(element);
|
||||
});
|
||||
self.setMaxWaypoints(mission.getMaxWaypoints());
|
||||
self.setValidMission(mission.getValidMission());
|
||||
self.setCountBusyPoints(mission.getCountBusyPoints());
|
||||
self.setVersion(mission.getVersion());
|
||||
self.setCenter(mission.getCenter());
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
@ -86,6 +86,8 @@
|
|||
<a class="ic_hide" href="#" title="Hide"></a>
|
||||
</div>
|
||||
<a id="cancelSafehome" class="ic_cancel" href="#" title="Cancel"></a>
|
||||
<a id="saveEepromSafehomeButton" class="ic_save2Eprom" href="#" title="Save Eeprom Safehome"></a>
|
||||
<a id="loadEepromSafehomeButton" class="ic_loadFromEprom" href="#" title="Load Eeprom Safehome"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer" id="SafehomeContent">
|
||||
|
|
|
@ -82,7 +82,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
loadChainer.setChain([
|
||||
mspHelper.getMissionInfo,
|
||||
//mspHelper.loadWaypoints,
|
||||
mspHelper.loadSafehomes
|
||||
//mspHelper.loadSafehomes
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
|
@ -379,8 +379,8 @@ TABS.mission_control.initialize = function (callback) {
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// define & init Safehome parameters
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
var SAFEHOMES = new SafehomeCollection(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
SAFEHOMES.inflate(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
//var SAFEHOMES = new SafehomeCollection(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
//SAFEHOMES.inflate(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
var safehomeRangeRadius = 200; //meters
|
||||
var safehomeSafeRadius = 50; //meters
|
||||
|
||||
|
@ -466,27 +466,26 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$row.find(".safehome-number").text(safehome.getNumber()+1);
|
||||
|
||||
$row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).change(function () {
|
||||
safehome.setEnabled((($(this).prop('checked')) ? true : false));
|
||||
safehome.setEnabled((($(this).prop('checked')) ? 1 : 0));
|
||||
SAFEHOMES.updateSafehome(safehome);
|
||||
cleanSafehomeLayers();
|
||||
renderSafehomesOnMap();
|
||||
});
|
||||
|
||||
$row.find(".safehome-lon").val(safehome.getLon()).change(function () {
|
||||
$row.find(".safehome-lon").val(safehome.getLonMap()).change(function () {
|
||||
safehome.setLon(Math.round(Number($(this).val()) * 10000000));
|
||||
SAFEHOMES.updateSafehome(safehome);
|
||||
cleanSafehomeLayers();
|
||||
renderSafehomesOnMap();
|
||||
});
|
||||
|
||||
$row.find(".safehome-lat").val(safehome.getLat()).change(function () {
|
||||
$row.find(".safehome-lat").val(safehome.getLatMap()).change(function () {
|
||||
safehome.setLat(Math.round(Number($(this).val()) * 10000000));
|
||||
SAFEHOMES.updateSafehome(safehome);
|
||||
cleanSafehomeLayers();
|
||||
renderSafehomesOnMap();
|
||||
});
|
||||
|
||||
$row.find("[data-role='safehome-view']").attr("data-index", safehomeIndex);
|
||||
$row.find("[data-role='safehome-center']").attr("data-index", safehomeIndex);
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +540,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
/*
|
||||
* add safehome on Map
|
||||
*/
|
||||
let coord = ol.proj.fromLonLat([safehome.getLon(), safehome.getLat()]);
|
||||
let coord = ol.proj.fromLonLat([safehome.getLonMap(), safehome.getLatMap()]);
|
||||
var iconFeature = new ol.Feature({
|
||||
geometry: new ol.geom.Point(coord),
|
||||
name: 'Null Island',
|
||||
|
@ -549,16 +548,9 @@ TABS.mission_control.initialize = function (callback) {
|
|||
rainfall: 500
|
||||
});
|
||||
|
||||
iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
|
||||
//iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
|
||||
|
||||
var circleFeature = new ol.Feature({
|
||||
geometry: new ol.geom.Circle(coord, safehomeRangeRadius),
|
||||
name: 'circleFeature',
|
||||
population: 4000,
|
||||
rainfall: 500
|
||||
});
|
||||
|
||||
circleFeature.setStyle(new ol.style.Style({
|
||||
let circleStyle = new ol.style.Style({
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(255, 163, 46, 1)',
|
||||
width: 3,
|
||||
|
@ -567,16 +559,9 @@ TABS.mission_control.initialize = function (callback) {
|
|||
// fill: new ol.style.Fill({
|
||||
// color: 'rgba(251, 225, 155, 0.1)'
|
||||
// })
|
||||
}));
|
||||
|
||||
var circleSafeFeature = new ol.Feature({
|
||||
geometry: new ol.geom.Circle(coord, safehomeSafeRadius),
|
||||
name: 'circleSafeFeature',
|
||||
population: 4000,
|
||||
rainfall: 500
|
||||
});
|
||||
|
||||
circleSafeFeature.setStyle(new ol.style.Style({
|
||||
let circleSafeStyle = new ol.style.Style({
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(136, 204, 62, 1)',
|
||||
width: 3,
|
||||
|
@ -585,21 +570,22 @@ TABS.mission_control.initialize = function (callback) {
|
|||
/* fill: new ol.style.Fill({
|
||||
color: 'rgba(136, 204, 62, 0.1)'
|
||||
}) */
|
||||
}));
|
||||
});
|
||||
|
||||
if (safehome.isUsed()) {
|
||||
var vectorSource = new ol.source.Vector({
|
||||
features: [iconFeature]//, circleFeature, circleSafeFeature]
|
||||
});
|
||||
}
|
||||
else {
|
||||
var vectorSource = new ol.source.Vector({
|
||||
features: [iconFeature]
|
||||
});
|
||||
}
|
||||
|
||||
var vectorLayer = new ol.layer.Vector({
|
||||
source: vectorSource
|
||||
source: new ol.source.Vector({
|
||||
features: [iconFeature]
|
||||
}),
|
||||
style : function(iconFeature) {
|
||||
let styles = [getSafehomeIcon(safehome)];
|
||||
/* console.log(iconFeature.getGeometry().getType());
|
||||
if (safehome.isUsed()) {
|
||||
circleStyle.setGeometry(new ol.geom.Circle(iconFeature.getGeometry().getCoordinates(), safehomeRangeRadius));
|
||||
//circleSafeStyle.setGeometry(new ol.geom.Circle(iconFeature.getGeometry().getCenter(), safehomeSafeRadius));
|
||||
styles.push(circleStyle);
|
||||
} */
|
||||
return styles;
|
||||
}
|
||||
});
|
||||
|
||||
vectorLayer.kind = "safehome";
|
||||
|
@ -996,7 +982,6 @@ TABS.mission_control.initialize = function (callback) {
|
|||
button.style = 'background: url(\'../images/CF_settings_white.svg\') no-repeat 1px -1px;background-color: rgba(0,60,136,.5);';
|
||||
|
||||
var handleShowSettings = function () {
|
||||
$('#MPeditPoint, #missionPlanerTotalInfo','#missionPlanerTemplate', '#missionPlanerSafehome').hide();
|
||||
$('#missionPlanerSettings').fadeIn(300);
|
||||
};
|
||||
|
||||
|
@ -1030,8 +1015,9 @@ TABS.mission_control.initialize = function (callback) {
|
|||
button.style = 'background: url(\'../images/icons/cf_icon_safehome_white.svg\') no-repeat 1px -1px;background-color: rgba(0,60,136,.5);';
|
||||
|
||||
var handleShowSafehome = function () {
|
||||
$('#MPeditPoint, #missionPlanerTotalInfo','#missionPlanerTemplate', '#missionPlanerSettings').hide();
|
||||
$('#missionPlanerSafehome').fadeIn(300);
|
||||
//SAFEHOMES.flush();
|
||||
//mspHelper.loadSafehomes();
|
||||
cleanSafehomeLayers();
|
||||
renderSafehomesTable();
|
||||
renderSafehomesOnMap();
|
||||
|
@ -1115,10 +1101,6 @@ TABS.mission_control.initialize = function (callback) {
|
|||
tempSH.setLon(Math.round(coord[0] * 10000000));
|
||||
tempSH.setLat(Math.round(coord[1] * 10000000));
|
||||
SAFEHOMES.updateSafehome(tempSH);
|
||||
/* if (tempSH.isUsed()) {
|
||||
this.layer_.getSource().getFeatures()[1].getGeometry().translate(deltaX, deltaY);
|
||||
this.layer_.getSource().getFeatures()[0].getGeometry().translate(deltaX, deltaY);
|
||||
} */
|
||||
$safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lon').val(Math.round(coord[0] * 10000000) / 10000000);
|
||||
$safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lat').val(Math.round(coord[1] * 10000000) / 10000000);
|
||||
}
|
||||
|
@ -1187,7 +1169,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
else {
|
||||
control_list = [
|
||||
new app.PlannerSettingsControl(),
|
||||
new app.PlannerSafehomeControl() // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
//new app.PlannerSafehomeControl() // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1314,7 +1296,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
cleanLayers();
|
||||
redrawLayers();
|
||||
}
|
||||
mission.missionDisplayDebug();
|
||||
//mission.missionDisplayDebug();
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1502,8 +1484,8 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$safehomesTableBody.on('click', "[data-role='safehome-center']", function (event) {
|
||||
let mapCenter = map.getView().getCenter();
|
||||
let tmpSH = SAFEHOMES.getSafehome($(event.currentTarget).attr("data-index"));
|
||||
tmpSH.setLon(ol.proj.toLonLat(Math.round(mapCenter)[0] * 10000000));
|
||||
tmpSH.setLat(ol.proj.toLonLat(Math.round(mapCenter)[1] * 10000000));
|
||||
tmpSH.setLon(Math.round(ol.proj.toLonLat(mapCenter)[0] * 1e7));
|
||||
tmpSH.setLat(Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7));
|
||||
SAFEHOMES.updateSafehome(tmpSH);
|
||||
renderSafehomesTable();
|
||||
cleanSafehomeLayers();
|
||||
|
@ -1513,6 +1495,31 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$('#cancelSafehome').on('click', function () {
|
||||
closeSafehomePanel();
|
||||
});
|
||||
|
||||
$('#loadEepromSafehomeButton').on('click', function () {
|
||||
$(this).addClass('disabled');
|
||||
GUI.log('Start of getting Safehome points');
|
||||
mspHelper.loadSafehomes();
|
||||
setTimeout(function(){
|
||||
console.log("debug Safehome after loading");
|
||||
SAFEHOMES.safehomeDisplayDebug();
|
||||
renderSafehomesTable();
|
||||
cleanSafehomeLayers();
|
||||
renderSafehomesOnMap();
|
||||
GUI.log('End of getting Safehome points');
|
||||
$('#loadEepromSafehomeButton').removeClass('disabled');
|
||||
}, 500);
|
||||
|
||||
});
|
||||
|
||||
$('#saveEepromSafehomeButton').on('click', function () {
|
||||
$(this).addClass('disabled');
|
||||
GUI.log('Start of sending Safehome points');
|
||||
mspHelper.saveSafehomes();
|
||||
GUI.log('End of sending Safehome points');
|
||||
$('#saveEepromSafehomeButton').removeClass('disabled');
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Callback for Remove buttons
|
||||
/////////////////////////////////////////////
|
||||
|
@ -1558,51 +1565,33 @@ TABS.mission_control.initialize = function (callback) {
|
|||
removeAllWaypoints();
|
||||
$(this).addClass('disabled');
|
||||
GUI.log('Start get point');
|
||||
// Reinit some internal parameters
|
||||
/* pointForSend = 0;
|
||||
actionPointForSend = 0;
|
||||
nonMarkerPoint = [];
|
||||
nonMarkerPointListRead = [];
|
||||
var isOptions = false;
|
||||
var oldMarkers = null; */
|
||||
//getNextPoint();
|
||||
mspHelper.loadWaypoints();
|
||||
mission = MISSION_PLANER
|
||||
mission.update();
|
||||
console.log("Display for Load");
|
||||
mission.missionDisplayDebug();
|
||||
redrawLayers();
|
||||
getWaypoints();
|
||||
GUI.log('End get point');
|
||||
$('#loadMissionButton').removeClass('disabled');
|
||||
updateTotalInfo();
|
||||
});
|
||||
|
||||
$('#saveMissionButton').on('click', function () {
|
||||
$(this).addClass('disabled');
|
||||
MISSION_PLANER = mission ;
|
||||
GUI.log('Start send point');
|
||||
MISSION_PLANER.reinit();
|
||||
MISSION_PLANER.copy(mission);
|
||||
MISSION_PLANER.update(true, true);
|
||||
mspHelper.saveWaypoints();
|
||||
console.log("MISSION_PLANER.isValidMission ",MISSION_PLANER.getValidMission());
|
||||
mission = MISSION_PLANER;
|
||||
console.log("Display for save");
|
||||
mission.missionDisplayDebug();
|
||||
$('#saveMissionButton').removeClass('disabled');
|
||||
updateTotalInfo();
|
||||
// Reinit some internal parameters
|
||||
/* pointForSend = 0;
|
||||
actionPointForSend = 0;
|
||||
nonMarkerPoint = [];
|
||||
nonMarkerPointListRead = [];
|
||||
var isOptions = false;
|
||||
var oldMarkers = null; */
|
||||
//sendNextPoint();
|
||||
setTimeout(function(){
|
||||
GUI.log('End send point');
|
||||
$('#saveMissionButton').removeClass('disabled');
|
||||
mission.setMaxWaypoints(MISSION_PLANER.getMaxWaypoints());
|
||||
mission.setValidMission(MISSION_PLANER.getValidMission());
|
||||
mission.setCountBusyPoints(MISSION_PLANER.getCountBusyPoints());
|
||||
updateTotalInfo();
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
$('#loadEepromMissionButton').on('click', function () {
|
||||
if (markers.length && !confirm(chrome.i18n.getMessage('confirm_delete_all_points'))) return;
|
||||
removeAllWaypoints();
|
||||
GUI.log(chrome.i18n.getMessage('eeprom_load_ok'));
|
||||
MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], getPointsFromEprom);
|
||||
MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], getWaypoints);
|
||||
});
|
||||
|
||||
$('#saveEepromMissionButton').on('click', function () {
|
||||
|
@ -1786,51 +1775,21 @@ TABS.mission_control.initialize = function (callback) {
|
|||
// Load/Save FC mission Toolbox
|
||||
//
|
||||
/////////////////////////////////////////////
|
||||
// New: function to get number of Non Marker points such as JUMP, SET_HEAD and RTH
|
||||
function getNumberOfNonMarkerForJump2(nonMarkerPointList, numTargetMarker) {
|
||||
for (i = 1; i < nonMarkerPointList.length; i++) {
|
||||
if (numTargetMarker>=nonMarkerPointList[i-1]) {
|
||||
numTargetMarker++;
|
||||
}
|
||||
else {
|
||||
return numTargetMarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New: Reversed function to get number of Non Marker points such as JUMP, SET_HEAD and RTH
|
||||
function getNumberOfNonMarkerForJumpReversed(nonMarkerPointList, numTargetMarker) {
|
||||
var numTargetMarkerOut = 0;
|
||||
for (i = 1; i < nonMarkerPointList.length; i++) {
|
||||
if (numTargetMarker>=nonMarkerPointList[i-1]) {
|
||||
numTargetMarkerOut++;
|
||||
}
|
||||
else {
|
||||
return numTargetMarker-numTargetMarkerOut;
|
||||
}
|
||||
}
|
||||
function getWaypoints() {
|
||||
mspHelper.loadWaypoints();
|
||||
setTimeout(function(){
|
||||
console.log("getWaypoint MISSION_PLANER 0 ");
|
||||
console.log(MISSION_PLANER.missionDisplayDebug());
|
||||
mission.reinit();
|
||||
mission.copy(MISSION_PLANER);
|
||||
mission.update(true);
|
||||
console.log("getWaypoint 0 ");
|
||||
console.log(mission.missionDisplayDebug());
|
||||
redrawLayers();
|
||||
updateTotalInfo();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function getPointsFromEprom() {
|
||||
/* pointForSend = 0;
|
||||
actionPointForSend = 0;
|
||||
nonMarkerPoint = [];
|
||||
nonMarkerPointListRead = [];
|
||||
isOptions = false;
|
||||
oldMarkers = null;
|
||||
pointFromBuffer = {}; */
|
||||
//MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, getNextPoint);
|
||||
mspHelper.getMissionInfo();
|
||||
mspHelper.loadWaypoints();
|
||||
mission = MISSION_PLANER
|
||||
mission.update();
|
||||
console.log("Display for getfromEprom");
|
||||
mission.missionDisplayDebug();
|
||||
redrawLayers();
|
||||
GUI.log('End get point');
|
||||
$('#loadMissionButton').removeClass('disabled');
|
||||
updateTotalInfo();
|
||||
}
|
||||
|
||||
function endGetPoint() {
|
||||
GUI.log('End get point');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue