mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 00:05: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 = {};
|
SETTINGS = {};
|
||||||
|
|
||||||
/* SAFEHOME = {
|
|
||||||
bufferPoint : {
|
|
||||||
number: 0,
|
|
||||||
enabled: 0,
|
|
||||||
lon: 0,
|
|
||||||
lat: 0
|
|
||||||
}
|
|
||||||
}; */
|
|
||||||
SAFEHOMES = new SafehomeCollection();
|
SAFEHOMES = new SafehomeCollection();
|
||||||
},
|
},
|
||||||
getOutputUsages: function() {
|
getOutputUsages: function() {
|
||||||
|
|
|
@ -440,7 +440,6 @@ var mspHelper = (function (gui) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSP_WP:
|
case MSPCodes.MSP_WP:
|
||||||
console.log("data : ", data);
|
|
||||||
MISSION_PLANER.put(new Waypoint(
|
MISSION_PLANER.put(new Waypoint(
|
||||||
data.getUint8(0),
|
data.getUint8(0),
|
||||||
data.getUint8(1),
|
data.getUint8(1),
|
||||||
|
@ -1467,9 +1466,12 @@ var mspHelper = (function (gui) {
|
||||||
SAFEHOMES.put(new Safehome(
|
SAFEHOMES.put(new Safehome(
|
||||||
data.getUint8(0),
|
data.getUint8(0),
|
||||||
data.getUint8(1),
|
data.getUint8(1),
|
||||||
data.getInt32(2, true) / 1e7,
|
data.getInt32(2, true),
|
||||||
data.getInt32(6, true) / 1e7
|
data.getInt32(6, true)
|
||||||
));
|
));
|
||||||
|
break;
|
||||||
|
case MSPCodes.MSP2_INAV_SET_SAFEHOME:
|
||||||
|
console.log('Safehome points saved');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2148,13 +2150,6 @@ var mspHelper = (function (gui) {
|
||||||
|
|
||||||
buffer.push(BRAKING_CONFIG.bankAngle);
|
buffer.push(BRAKING_CONFIG.bankAngle);
|
||||||
break;
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -2925,33 +2920,36 @@ var mspHelper = (function (gui) {
|
||||||
|
|
||||||
self.loadWaypoints = function (callback) {
|
self.loadWaypoints = function (callback) {
|
||||||
MISSION_PLANER.reinit();
|
MISSION_PLANER.reinit();
|
||||||
mspHelper.getMissionInfo();
|
let waypointId = 1;
|
||||||
console.log("MISSION_PLANER.getCountBusyPoints() ", MISSION_PLANER.getCountBusyPoints());
|
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, getFirstWP);
|
||||||
let waypointId = 0;
|
|
||||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
|
function getFirstWP() {
|
||||||
|
console.log("MISSION_PLANER.getCountBusyPoints() ", MISSION_PLANER.getCountBusyPoints());
|
||||||
|
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint)
|
||||||
|
};
|
||||||
|
|
||||||
function nextWaypoint() {
|
function nextWaypoint() {
|
||||||
waypointId++;
|
waypointId++;
|
||||||
console.log("Display for LoadInternal");
|
if (waypointId < MISSION_PLANER.getCountBusyPoints()) {
|
||||||
MISSION_PLANER.missionDisplayDebug();
|
|
||||||
if (waypointId < MISSION_PLANER.get().length-1) {
|
|
||||||
console.log("waypointId if ", waypointId);
|
|
||||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
|
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("waypointId else ", waypointId);
|
|
||||||
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, callback);
|
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function endMission() {
|
||||||
|
console.log("End");
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
self.saveWaypoints = function (callback) {
|
self.saveWaypoints = function (callback) {
|
||||||
let waypointId = 0;
|
let waypointId = 1;
|
||||||
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint)
|
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint)
|
||||||
|
|
||||||
function nextWaypoint() {
|
function nextWaypoint() {
|
||||||
waypointId++;
|
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);
|
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2960,7 +2958,6 @@ var mspHelper = (function (gui) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function endMission() {
|
function endMission() {
|
||||||
GUI.log('End send point');
|
|
||||||
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, callback);
|
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) {
|
self._getSetting = function (name) {
|
||||||
if (SETTINGS[name]) {
|
if (SETTINGS[name]) {
|
||||||
|
|
|
@ -21,14 +21,10 @@ let Safehome = function (number, enabled, lat, lon) {
|
||||||
lon = data;
|
lon = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getLonToMap = function () {
|
self.getLonMap = function () {
|
||||||
return lon / 1e7;
|
return lon / 1e7;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setLonFromMap = function (data) {
|
|
||||||
lon = data * 1e7;
|
|
||||||
};
|
|
||||||
|
|
||||||
self.getLat = function () {
|
self.getLat = function () {
|
||||||
return lat;
|
return lat;
|
||||||
};
|
};
|
||||||
|
@ -37,14 +33,10 @@ let Safehome = function (number, enabled, lat, lon) {
|
||||||
lat = data;
|
lat = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getLatToMap = function () {
|
self.getLatMap = function () {
|
||||||
return lat / 1e7;
|
return lat / 1e7;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setLatFromMap = function (data) {
|
|
||||||
lat = data * 1e7;
|
|
||||||
};
|
|
||||||
|
|
||||||
self.isUsed = function () {
|
self.isUsed = function () {
|
||||||
return enabled == 1;
|
return enabled == 1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,6 +96,38 @@ let SafehomeCollection = function () {
|
||||||
data[newSafehome.getNumber()] = newSafehome;
|
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;
|
return self;
|
||||||
};
|
};
|
|
@ -46,6 +46,10 @@ let WaypointCollection = function () {
|
||||||
self.getCenter = function () {
|
self.getCenter = function () {
|
||||||
return center;
|
return center;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.setCenter = function (data) {
|
||||||
|
center = data;
|
||||||
|
};
|
||||||
|
|
||||||
self.setCenterZoom = function (data) {
|
self.setCenterZoom = function (data) {
|
||||||
center.zoom = data;
|
center.zoom = data;
|
||||||
|
@ -145,18 +149,25 @@ let WaypointCollection = function () {
|
||||||
data = tmpData;
|
data = tmpData;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.update = function (bMWPfile=false) {
|
self.update = function (bMWPfile=false, bReverse=false) {
|
||||||
let oldWPNumber = 0;
|
let oldWPNumber = 0;
|
||||||
let optionIdx = 0;
|
let optionIdx = 0;
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
data.forEach(function (element) {
|
data.forEach(function (element) {
|
||||||
if (element.isUsed()) {
|
if (element.isUsed()) {
|
||||||
if (bMWPfile) {
|
if (bMWPfile && !bReverse) {
|
||||||
element.setNumber(element.getNumber()-1);
|
element.setNumber(element.getNumber()-1);
|
||||||
if (element.getAction() == MWNP.WPTYPE.JUMP) {
|
if (element.getAction() == MWNP.WPTYPE.JUMP) {
|
||||||
element.setP1(element.getP1()-1);
|
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())) {
|
if ([MWNP.WPTYPE.JUMP,MWNP.WPTYPE.SET_HEAD,MWNP.WPTYPE.RTH].includes(element.getAction())) {
|
||||||
element.setAttachedId(oldWPNumber);
|
element.setAttachedId(oldWPNumber);
|
||||||
element.setAttachedNumber(optionIdx);
|
element.setAttachedNumber(optionIdx);
|
||||||
|
@ -169,7 +180,8 @@ let WaypointCollection = function () {
|
||||||
optionIdx = 0;
|
optionIdx = 0;
|
||||||
idx++;
|
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);
|
element.setEndMission(0xA5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -255,17 +267,30 @@ let WaypointCollection = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.missionDisplayDebug = function() {
|
self.missionDisplayDebug = function() {
|
||||||
data.forEach(function (element) {
|
if (data && data.length != 0) {
|
||||||
console.log("N° : ", element.getNumber(),
|
data.forEach(function (element) {
|
||||||
"Action : ", element.getAction(),
|
console.log("N° : ", element.getNumber(),
|
||||||
"Lon : ", element.getLon(),
|
"Action : ", element.getAction(),
|
||||||
"Lat : ", element.getLat(),
|
"Lon : ", element.getLon(),
|
||||||
"Alt : ", element.getAlt(),
|
"Lat : ", element.getLat(),
|
||||||
"P1 : ", element.getP1(),
|
"Alt : ", element.getAlt(),
|
||||||
"P2 : ", element.getP2(),
|
"P1 : ", element.getP1(),
|
||||||
"P3 : ", element.getP3(),
|
"P2 : ", element.getP2(),
|
||||||
"EndMission : ", element.getEndMission());
|
"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;
|
return self;
|
||||||
|
|
|
@ -86,6 +86,8 @@
|
||||||
<a class="ic_hide" href="#" title="Hide"></a>
|
<a class="ic_hide" href="#" title="Hide"></a>
|
||||||
</div>
|
</div>
|
||||||
<a id="cancelSafehome" class="ic_cancel" href="#" title="Cancel"></a>
|
<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>
|
</div>
|
||||||
<div class="spacer" id="SafehomeContent">
|
<div class="spacer" id="SafehomeContent">
|
||||||
|
|
|
@ -82,7 +82,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
loadChainer.setChain([
|
loadChainer.setChain([
|
||||||
mspHelper.getMissionInfo,
|
mspHelper.getMissionInfo,
|
||||||
//mspHelper.loadWaypoints,
|
//mspHelper.loadWaypoints,
|
||||||
mspHelper.loadSafehomes
|
//mspHelper.loadSafehomes
|
||||||
]);
|
]);
|
||||||
loadChainer.setExitPoint(loadHtml);
|
loadChainer.setExitPoint(loadHtml);
|
||||||
loadChainer.execute();
|
loadChainer.execute();
|
||||||
|
@ -379,8 +379,8 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// define & init Safehome parameters
|
// define & init Safehome parameters
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
var SAFEHOMES = new SafehomeCollection(); // 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
|
//SAFEHOMES.inflate(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
|
||||||
var safehomeRangeRadius = 200; //meters
|
var safehomeRangeRadius = 200; //meters
|
||||||
var safehomeSafeRadius = 50; //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-number").text(safehome.getNumber()+1);
|
||||||
|
|
||||||
$row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).change(function () {
|
$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);
|
SAFEHOMES.updateSafehome(safehome);
|
||||||
cleanSafehomeLayers();
|
cleanSafehomeLayers();
|
||||||
renderSafehomesOnMap();
|
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));
|
safehome.setLon(Math.round(Number($(this).val()) * 10000000));
|
||||||
SAFEHOMES.updateSafehome(safehome);
|
SAFEHOMES.updateSafehome(safehome);
|
||||||
cleanSafehomeLayers();
|
cleanSafehomeLayers();
|
||||||
renderSafehomesOnMap();
|
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));
|
safehome.setLat(Math.round(Number($(this).val()) * 10000000));
|
||||||
SAFEHOMES.updateSafehome(safehome);
|
SAFEHOMES.updateSafehome(safehome);
|
||||||
cleanSafehomeLayers();
|
cleanSafehomeLayers();
|
||||||
renderSafehomesOnMap();
|
renderSafehomesOnMap();
|
||||||
});
|
});
|
||||||
|
|
||||||
$row.find("[data-role='safehome-view']").attr("data-index", safehomeIndex);
|
|
||||||
$row.find("[data-role='safehome-center']").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
|
* 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({
|
var iconFeature = new ol.Feature({
|
||||||
geometry: new ol.geom.Point(coord),
|
geometry: new ol.geom.Point(coord),
|
||||||
name: 'Null Island',
|
name: 'Null Island',
|
||||||
|
@ -549,16 +548,9 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
rainfall: 500
|
rainfall: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
|
//iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
|
||||||
|
|
||||||
var circleFeature = new ol.Feature({
|
let circleStyle = new ol.style.Style({
|
||||||
geometry: new ol.geom.Circle(coord, safehomeRangeRadius),
|
|
||||||
name: 'circleFeature',
|
|
||||||
population: 4000,
|
|
||||||
rainfall: 500
|
|
||||||
});
|
|
||||||
|
|
||||||
circleFeature.setStyle(new ol.style.Style({
|
|
||||||
stroke: new ol.style.Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(255, 163, 46, 1)',
|
color: 'rgba(255, 163, 46, 1)',
|
||||||
width: 3,
|
width: 3,
|
||||||
|
@ -567,16 +559,9 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
// fill: new ol.style.Fill({
|
// fill: new ol.style.Fill({
|
||||||
// color: 'rgba(251, 225, 155, 0.1)'
|
// 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({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(136, 204, 62, 1)',
|
color: 'rgba(136, 204, 62, 1)',
|
||||||
width: 3,
|
width: 3,
|
||||||
|
@ -585,21 +570,22 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
/* fill: new ol.style.Fill({
|
/* fill: new ol.style.Fill({
|
||||||
color: 'rgba(136, 204, 62, 0.1)'
|
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({
|
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";
|
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);';
|
button.style = 'background: url(\'../images/CF_settings_white.svg\') no-repeat 1px -1px;background-color: rgba(0,60,136,.5);';
|
||||||
|
|
||||||
var handleShowSettings = function () {
|
var handleShowSettings = function () {
|
||||||
$('#MPeditPoint, #missionPlanerTotalInfo','#missionPlanerTemplate', '#missionPlanerSafehome').hide();
|
|
||||||
$('#missionPlanerSettings').fadeIn(300);
|
$('#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);';
|
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 () {
|
var handleShowSafehome = function () {
|
||||||
$('#MPeditPoint, #missionPlanerTotalInfo','#missionPlanerTemplate', '#missionPlanerSettings').hide();
|
|
||||||
$('#missionPlanerSafehome').fadeIn(300);
|
$('#missionPlanerSafehome').fadeIn(300);
|
||||||
|
//SAFEHOMES.flush();
|
||||||
|
//mspHelper.loadSafehomes();
|
||||||
cleanSafehomeLayers();
|
cleanSafehomeLayers();
|
||||||
renderSafehomesTable();
|
renderSafehomesTable();
|
||||||
renderSafehomesOnMap();
|
renderSafehomesOnMap();
|
||||||
|
@ -1115,10 +1101,6 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
tempSH.setLon(Math.round(coord[0] * 10000000));
|
tempSH.setLon(Math.round(coord[0] * 10000000));
|
||||||
tempSH.setLat(Math.round(coord[1] * 10000000));
|
tempSH.setLat(Math.round(coord[1] * 10000000));
|
||||||
SAFEHOMES.updateSafehome(tempSH);
|
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-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);
|
$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 {
|
else {
|
||||||
control_list = [
|
control_list = [
|
||||||
new app.PlannerSettingsControl(),
|
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();
|
cleanLayers();
|
||||||
redrawLayers();
|
redrawLayers();
|
||||||
}
|
}
|
||||||
mission.missionDisplayDebug();
|
//mission.missionDisplayDebug();
|
||||||
});
|
});
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1502,8 +1484,8 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
$safehomesTableBody.on('click', "[data-role='safehome-center']", function (event) {
|
$safehomesTableBody.on('click', "[data-role='safehome-center']", function (event) {
|
||||||
let mapCenter = map.getView().getCenter();
|
let mapCenter = map.getView().getCenter();
|
||||||
let tmpSH = SAFEHOMES.getSafehome($(event.currentTarget).attr("data-index"));
|
let tmpSH = SAFEHOMES.getSafehome($(event.currentTarget).attr("data-index"));
|
||||||
tmpSH.setLon(ol.proj.toLonLat(Math.round(mapCenter)[0] * 10000000));
|
tmpSH.setLon(Math.round(ol.proj.toLonLat(mapCenter)[0] * 1e7));
|
||||||
tmpSH.setLat(ol.proj.toLonLat(Math.round(mapCenter)[1] * 10000000));
|
tmpSH.setLat(Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7));
|
||||||
SAFEHOMES.updateSafehome(tmpSH);
|
SAFEHOMES.updateSafehome(tmpSH);
|
||||||
renderSafehomesTable();
|
renderSafehomesTable();
|
||||||
cleanSafehomeLayers();
|
cleanSafehomeLayers();
|
||||||
|
@ -1513,6 +1495,31 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
$('#cancelSafehome').on('click', function () {
|
$('#cancelSafehome').on('click', function () {
|
||||||
closeSafehomePanel();
|
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
|
// Callback for Remove buttons
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
|
@ -1558,51 +1565,33 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
removeAllWaypoints();
|
removeAllWaypoints();
|
||||||
$(this).addClass('disabled');
|
$(this).addClass('disabled');
|
||||||
GUI.log('Start get point');
|
GUI.log('Start get point');
|
||||||
// Reinit some internal parameters
|
getWaypoints();
|
||||||
/* 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();
|
|
||||||
GUI.log('End get point');
|
GUI.log('End get point');
|
||||||
$('#loadMissionButton').removeClass('disabled');
|
$('#loadMissionButton').removeClass('disabled');
|
||||||
updateTotalInfo();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#saveMissionButton').on('click', function () {
|
$('#saveMissionButton').on('click', function () {
|
||||||
$(this).addClass('disabled');
|
$(this).addClass('disabled');
|
||||||
MISSION_PLANER = mission ;
|
|
||||||
GUI.log('Start send point');
|
GUI.log('Start send point');
|
||||||
|
MISSION_PLANER.reinit();
|
||||||
|
MISSION_PLANER.copy(mission);
|
||||||
|
MISSION_PLANER.update(true, true);
|
||||||
mspHelper.saveWaypoints();
|
mspHelper.saveWaypoints();
|
||||||
console.log("MISSION_PLANER.isValidMission ",MISSION_PLANER.getValidMission());
|
setTimeout(function(){
|
||||||
mission = MISSION_PLANER;
|
GUI.log('End send point');
|
||||||
console.log("Display for save");
|
$('#saveMissionButton').removeClass('disabled');
|
||||||
mission.missionDisplayDebug();
|
mission.setMaxWaypoints(MISSION_PLANER.getMaxWaypoints());
|
||||||
$('#saveMissionButton').removeClass('disabled');
|
mission.setValidMission(MISSION_PLANER.getValidMission());
|
||||||
updateTotalInfo();
|
mission.setCountBusyPoints(MISSION_PLANER.getCountBusyPoints());
|
||||||
// Reinit some internal parameters
|
updateTotalInfo();
|
||||||
/* pointForSend = 0;
|
}, 2000);
|
||||||
actionPointForSend = 0;
|
|
||||||
nonMarkerPoint = [];
|
|
||||||
nonMarkerPointListRead = [];
|
|
||||||
var isOptions = false;
|
|
||||||
var oldMarkers = null; */
|
|
||||||
//sendNextPoint();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#loadEepromMissionButton').on('click', function () {
|
$('#loadEepromMissionButton').on('click', function () {
|
||||||
if (markers.length && !confirm(chrome.i18n.getMessage('confirm_delete_all_points'))) return;
|
if (markers.length && !confirm(chrome.i18n.getMessage('confirm_delete_all_points'))) return;
|
||||||
removeAllWaypoints();
|
removeAllWaypoints();
|
||||||
GUI.log(chrome.i18n.getMessage('eeprom_load_ok'));
|
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 () {
|
$('#saveEepromMissionButton').on('click', function () {
|
||||||
|
@ -1786,51 +1775,21 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
// Load/Save FC mission Toolbox
|
// Load/Save FC mission Toolbox
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// New: function to get number of Non Marker points such as JUMP, SET_HEAD and RTH
|
function getWaypoints() {
|
||||||
function getNumberOfNonMarkerForJump2(nonMarkerPointList, numTargetMarker) {
|
mspHelper.loadWaypoints();
|
||||||
for (i = 1; i < nonMarkerPointList.length; i++) {
|
setTimeout(function(){
|
||||||
if (numTargetMarker>=nonMarkerPointList[i-1]) {
|
console.log("getWaypoint MISSION_PLANER 0 ");
|
||||||
numTargetMarker++;
|
console.log(MISSION_PLANER.missionDisplayDebug());
|
||||||
}
|
mission.reinit();
|
||||||
else {
|
mission.copy(MISSION_PLANER);
|
||||||
return numTargetMarker;
|
mission.update(true);
|
||||||
}
|
console.log("getWaypoint 0 ");
|
||||||
}
|
console.log(mission.missionDisplayDebug());
|
||||||
}
|
redrawLayers();
|
||||||
|
updateTotalInfo();
|
||||||
// New: Reversed function to get number of Non Marker points such as JUMP, SET_HEAD and RTH
|
}, 2000);
|
||||||
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 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() {
|
function endGetPoint() {
|
||||||
GUI.log('End get point');
|
GUI.log('End get point');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue