pull/1960/head
Andi Kanzler 10 months ago
parent fdf84422dd
commit ce30cd4ff4

@ -4361,6 +4361,12 @@
"SafehomeSafeRadius": {
"message": "Safe Radius (m):"
},
"SafehomeFwAppraoch": {
"message": "FW Approach:"
},
"safehomeEdit": {
"message": "Edit Safehome"
},
"missionTitleHide": {
"message": "Hide"
},
@ -4402,7 +4408,7 @@
},
"missionTitleAdd": {
"message": "Add"
},
},
"missionTitleMoveToCenterView": {
"message": "move to center view"
},
@ -4415,6 +4421,60 @@
"missionTitlEditMission": {
"message": "Edit Mission"
},
"MissionPlannerFwLAndingAltitudeChangeReset": {
"message": "Altitude below min land altitude. Change ignored"
},
"missionWpType": {
"message": "Type:"
},
"missionWpLat": {
"message": "Lat:"
},
"missionWpLon": {
"message": "Lon:"
},
"missionSeaLevelRef": {
"message": "Sea level Ref: "
},
"missionElevation": {
"message": "Elevation (m):"
},
"missionNA": {
"message": "N/A"
},
"missionGroundDist": {
"message": "Grd Dist (m):"
},
"missionParameter1": {
"message": "Parameter 1:"
},
"missionParameter2": {
"message": "Parameter 2:"
},
"missionUserActions": {
"message": "User Actions:"
},
"missionFwLandingSettings": {
"message": "Fixed Wing landing settings:"
},
"missionFwApproachAlt": {
"message": "Approach Alt: (cm):"
},
"missionFwLandAlt": {
"message": "Land Alt: (cm):"
},
"missionFwApproachDir": {
"message": "Approach direction:"
},
"missionFwLandHeading1": {
"message": "Heading 1: (deg):"
},
"missionFwLandHeading2": {
"message": "Heading 2: (deg):"
},
"missionExclusive": {
"message": "Excl."
},
"missionRTHsettingsTitle": {
"message": "RTH settings"
},

@ -1281,7 +1281,7 @@ var FC = {
38: "Active MixerProfile",
39: "MixerTransition Active",
40: "Yaw [deg]",
38: "FW Land State"
41: "FW Land State"
}
},
3: {

@ -248,5 +248,5 @@ var MSPCodes = {
MSP2_INAV_EZ_TUNE: 0x2070,
MSP2_INAV_EZ_TUNE_SET: 0x2071,
MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080
MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080,
};

@ -76,7 +76,7 @@ let SafehomeCollection = function () {
buffer.push(specificByte(safehome.getLon(), 2));
buffer.push(specificByte(safehome.getLon(), 3));
} else {
buffer = Array(24).fill(0);
buffer = Array(10).fill(0);
buffer[0] = safehomeId;
}

@ -525,9 +525,6 @@
.tab-mission-control .textLegend{
margin:2px;
}
.tab-mission-control .valueLegend{
float:right;
}
.tab-mission-control .userActionContainer {
display: inline-block;

@ -193,33 +193,91 @@
</div>
</div>
<div class="spacer" id="SafehomeContent">
<div>
<div style="padding-bottom: 2px;">
<span class="i18n-replaced" data-i18n="missionSafehomeAvailableSafehomes">Available Safehomes:</span>
<span data-i18n="missionSafehomeAvailableSafehomes"></span>
<span id="availableSafehomes"></span>
</div>
<div id="SafehomeContentBox">
<div id="SafehomeContentBox" style="display: none;">
<div class="gui_box grey missionPlannerSafehomeBox">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="safehomeEdit"></div>
<div class="btnMenu btnMenuIcon">
<div class="btnMenu-danger">
<a id="deleteSafehome" class="ic_removeAll" href="#" title="Delete"></a>
</div>
</div>
</div>
<div class="spacer" id="safehomeSingelContent">
<div class="point">
<label class="point-label-safehome" for="safeHomeLatitude" data-i18n="gpsLat"></label>
<input type="number" id="safehomeLatitude"></input>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeLongitude" data-i18n="gpsLon"></label>
<input type="number" id="safehomeLongitude"></input>
</div>
<div class="point">
<span style="font-weight: bold" data-i18n="missionFwLandingSettings"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeSeaLevelRef" data-i18n="missionSeaLevelRef"></label>
<input id="safehomeSeaLevelRef" type="checkbox" value="0" class="togglemedium" required>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeApproachAlt" data-i18n="missionFwApproachAlt"></label>
<input type="number" id="safehomeApproachAlt"></input>
<span id="safehomeApproachAltM"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeLandAlt" data-i18n="missionFwLandAlt"></label>
<input type="number" id="safehomeLandAlt"></input>
<span id="safehomeLandAltM"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeElevation" data-i18n="missionElevation"></label>
<span id="safehomeElevation"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="geozoneApproachDirection" data-i18n="missionFwApproachDir"></label>
<select name="zoneAction" id="geozoneApproachDirection">
<option value="0">Left</option>
<option value="1">Right</option>
</select>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeLandHeading1" data-i18n="missionFwLandHeading1"></label>
<input type="number" id="safehomeLandHeading1"></input>
<input id="safehomeLandHeading1Excl" type="checkbox" value="0" class="togglemedium" required>
<span data-i18n="missionExclusive"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="safehomeLandHeading2" data-i18n="missionFwLandHeading2"></label>
<input type="number" id="safehomeLandHeading2"></input>
<input id="safehomeLandHeading2Excl" type="checkbox" value="0" class="togglemedium" required>
<span data-i18n="missionExclusive"></span>
</div>
</div>
</div>
</div>
<hr>
<div class="spacer" id="safehomeLegend">
<span><b data-i18n="SafehomeLegend"></b></span>
<div class="legendItem">
<span class="fill" style="border-bottom:5px dotted #900C3F;"></span>
<span class="textLegend">Max distance (m):</span>
<span class="textLegend" data-i18n="SafehomeMaxDistance"></span>
<span id="safeHomeMaxDistance"></span>
</div>
<div class="legendItem">
<span class="fill" style="border-bottom:5px dotted #88CC3E;"></span>
<span class="textLegend">Safe Radius (m):</span>
<span class="textLegend" data-i18n="SafehomeSafeRadius"></span>
<span id="SafeHomeSafeDistance"></span>
</div>
<div class="legendItem">
<span class="fill" style="border-bottom:5px solid #f78a05;border-top:5px solid #0025a1;"></span>
<span class="textLegend">FW Approach</span>
<span class="textLegend" data-i18n="SafehomeFwAppraoch"></span>
<span id="SafeHomeSafeDistance"></span>
</div>
</div>
</div>
</div>
</div>
@ -241,7 +299,7 @@
<div class="spacer" id="WPeditContent">
<input type="hidden" name="pointNumber" value="">
<div class="point">
<label class="point-label" for="pointType">Type: </label>
<label class="point-label" for="pointType" data-i18n="missionWpType"></label>
<select name="type" id="pointType">
<!--<option value="1">Home</option>-->
<option value="1">Waypoint</option>
@ -255,39 +313,39 @@
</select>
</div>
<div class="point">
<label class="point-label" for="pointLat">Lat: </label>
<label class="point-label" for="pointLat" data-i18n="missionWpLat"></label>
<input id="pointLat" type="text" value="0.0" required>
</div>
<div class="point">
<label class="point-label" for="pointLon">Lon: </label>
<label class="point-label" for="pointLon" data-i18n="missionWpLon"></label>
<input id="pointLon" type="text" value="0.0" required>
</div>
<div class="point">
<label class="point-label" for="pointAlt">Alt (cm): </label>
<label class="point-label" for="pointAlt" data-i18n="missionDefaultPointAlt"></label>
<input id="pointAlt" type="text" value="0" required><span id="altitudeInMeters"></span>
</div>
<div class="point" id="pointP3class" style="display: none">
<label class="point-label" for="pointP3Alt">Sea level Ref: </label>
<label class="point-label" for="pointP3Alt" data-i18n="missionSeaLevelRef"></label>
<input id="pointP3Alt" type="checkbox" value="0" class="togglemedium" checked required>
</div>
<div class="point" id="elevationAtWP" style="display: none">
<label class="point-label">Elevation (m): </label>
<span id="elevationValueAtWP">N/A</span>
<label class="point-label" data-i18n="missionElevation"></label>
<span id="elevationValueAtWP" data-i18n="missionNA"></span>
</div>
<div class="point" id="groundClearanceAtWP" style="display: none">
<label class="point-label">Grd Dist (m): </label>
<span id="groundClearanceValueAtWP">N/A</span>
<label class="point-label" data-i18n="missionGroundDist"></label>
<span id="groundClearanceValueAtWP" data-i18n="missionNA"></span>
</div>
<div class="point" id="pointP1class" style="display: none">
<label class="point-label" for="pointP1">Parameter 1: </label>
<label class="point-label" for="pointP1" data-i18n="missionParameter1"></label>
<input id="pointP1" type="text" value="0" required>
</div>
<div class="point" id="pointP2class" style="display: none">
<label class="point-label" for="pointP2">Parameter 2: </label>
<label class="point-label" for="pointP2" data-i18n="missionParameter1"></label>
<input id="pointP2" type="text" value="0" required>
</div>
<div class="point" id="pointP3UserActionClass" style="display: none">
<label class="point-label" for="pointP3UserAction">User Actions: </label>
<label class="point-label" for="pointP3UserAction" data-i18n="missionUserActions"></label>
<div class="userActionContainer">1 <input id="pointP3UserAction1" type="checkbox" value="0" class="togglemedium" checked required></div>
<div class="userActionContainer">2 <input id="pointP3UserAction2" type="checkbox" value="0" class="togglemedium" checked required></div>
<div class="userActionContainer">3 <input id="pointP3UserAction3" type="checkbox" value="0" class="togglemedium" checked required></div>
@ -313,38 +371,38 @@
</table>
<div id="wpFwLanding" style="display: none;">
<div class="point">
<span style="font-weight: bold">Fixed Wing landing settings:</span>
<span style="font-weight: bold" data-i18n="missionFwLandingSettings"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="wpApproachAlt">Approach Alt: (cm):</label>
<label class="point-label-safehome" for="wpApproachAlt" data-i18n="missionFwApproachAlt"></label>
<input type="number" id="wpApproachAlt"></input>
<span id="wpApproachAltM"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="wpLandAlt">Land Alt: (cm):</label>
<label class="point-label-safehome" for="wpLandAlt" data-i18n="missionFwLandAlt"></label>
<input type="number" id="wpLandAlt"></input>
<span id="wpLandAltM"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="wpApproachDirection">Approach direction:</label>
<label class="point-label-safehome" for="wpApproachDirection" data-i18n="missionFwApproachDir"></label>
<select name="wpApproachDirection" id="wpApproachDirection">
<option value="0">Left</option>
<option value="1">Right</option>
</select>
</div>
<div class="point">
<label class="point-label-safehome" for="wpLandHeading1">Heading 1: (deg):</label>
<label class="point-label-safehome" for="wpLandHeading1" data-i18n="missionFwLandHeading1"></label>
<input type="number" id="wpLandHeading1"></input>
<input id="wpLandHeading1Excl" type="checkbox" value="0" class="togglemedium" checked required> Excl.
<input id="wpLandHeading1Excl" type="checkbox" value="0" class="togglemedium" checked required>
<span data-i18n="missionExclusive"></span>
</div>
<div class="point">
<label class="point-label-safehome" for="wpLandHeading2">Heading 2: (deg):</label>
<label class="point-label-safehome" for="wpLandHeading2" data-i18n="missionFwLandHeading1"></label>
<input type="number" id="wpLandHeading2"></input>
<input id="wpLandHeading2Excl" type="checkbox" value="0" class="togglemedium" checked required> Excl.
<input id="wpLandHeading2Excl" type="checkbox" value="0" class="togglemedium" checked required>
<span data-i18n="missionExclusive"></span>
</div>
</div>
</div>
<!-- <div class="point-radio" id="pointOptionclass" style="display: none">
<div class="radio-line">
<input type="radio" id="Options_None" name="Options" value="None" checked>
@ -371,7 +429,6 @@
<input id="Options_HeadingHead" type="text" value="-1" required><br>
</div>
</div> -->
</div>
</div>
</div>

@ -10,6 +10,8 @@
// MultiWii NAV Protocol
var MWNP = MWNP || {};
var MAX_NEG_FW_LAND_ALT = -2000; // cm
// WayPoint type
MWNP.WPTYPE = {
WAYPOINT: 1,
@ -78,8 +80,7 @@ TABS.mission_control.initialize = function (callback) {
let textFeature;
var textGeom;
let isOffline = false;
let rthUpdateInterval = 0;
let selectedSafehome = -1;
let rthUpdateInterval = 0;
let settings = { speed: 0, alt: 5000, safeRadiusSH : 50, maxDistSH : 0, fwApproachLength: 0, fwApproachAlt: 60, fwLandAlt: 5};
if (GUI.active_tab != 'mission_control') {
@ -150,9 +151,10 @@ TABS.mission_control.initialize = function (callback) {
if (!isOffline) {
setTimeout(() => {
if (SAFEHOMES.safehomeCount() >= 1) {
selectedSafehome = 0;
updateSelectedShAndFwAp(0);
} else {
selectedSafehome = -1;
selectedSafehome = null;
selectedFwApproachSh = null;
}
renderSafehomesOnMap();
updateSafehomeInfo();
@ -397,6 +399,8 @@ TABS.mission_control.initialize = function (callback) {
var tempMarker = null;
var disableMarkerEdit = false;
var selectedFwApproachWp = null;
var selectedFwApproachSh = null;
//////////////////////////////////////////////////////////////////////////////////////////////
// define & init parameters for default Settings
@ -490,257 +494,23 @@ TABS.mission_control.initialize = function (callback) {
cleanSafehomeLayers();
}
function renderSafehomesTable() {
$safehomeContentBox.find("*").remove();
if (selectedSafehome < 0) {
return;
}
if (!$("#missionPlannerSafehome").is(":visible")) {
$("#missionPlannerSafehome").fadeIn(300);
$('#safeHomeMaxDistance').text(settings.maxDistSH);
$('#SafeHomeSafeDistance').text(settings.safeRadiusSH);
}
const safehome = SAFEHOMES.get()[selectedSafehome];
const fwApproach = FW_APPROACH.get()[selectedSafehome];
function checkApproachAltitude(altitude, isSeaLevelRef, sealevel) {
if (fwApproach.getLandHeading1() == 0 && fwApproach.getLandHeading1() == 0 && fwApproach.getApproachAltAsl() == 0 && fwApproach.getLandAltAsl() == 0) {
fwApproach.setApproachAltAsl(settings.fwApproachAlt * 100);
fwApproach.setLandAltAsl(settings.fwLandAlt * 100);
}
$safehomeContentBox.append('\
<div class="gui_box grey missionPlannerSafehomeBox"> \
<div class="gui_box_titlebar"> \
<div class="spacer_box_title">Edit Safehome </div> \
<div class="btnMenu btnMenuIcon"> \
<div class="btnMenu-danger"> \
<a id="deleteSafehome" class="ic_removeAll" href="#" title="Delete"></a> \
</div> \
</div> \
</div> \
<div class="spacer" id="safehomeSingelContent"> \
<div class="point"> \
<label class="point-label-safehome" for="safeHomeLatitude">Latitude:</label> \
<input type="number" id="safehomeLatitude"></input> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeLongitude">Longitude:</label> \
<input type="number" id="safehomeLongitude"></input> \
</div> \
<div class="point"> \
<span style="font-weight: bold">Fixed Wing landing settings:</span> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeSeaLEvelRef">Sea level ref:</label> \
<input id="safehomeSeaLevelRef" type="checkbox" value="0" class="togglemedium" required> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeApproachAlt">Approach Alt: (cm):</label> \
<input type="number" id="safehomeApproachAlt"></input> \
<span id="safehomeApproachAltM"></span> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeLandAlt">Land Alt: (cm):</label> \
<input type="number" id="safehomeLandAlt"></input> \
<span id="safehomeLandAltM"></span> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeElevation">Elevation: (m):</label> \
<span id="safehomeElevation"></span> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="geozoneApproachDirection">Approach direction:</label> \
<select name="zoneAction" id="geozoneApproachDirection"> \
<option value="0">Left</option> \
<option value="1">Right</option> \
</select> \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeLandHeading1">Heading 1: (deg):</label> \
<input type="number" id="safehomeLandHeading1"></input> \
<input id="safehomeLandHeading1Excl" type="checkbox" value="0" class="togglemedium" required> Excl. \
</div> \
<div class="point"> \
<label class="point-label-safehome" for="safehomeLandHeading2">Heading 2: (deg):</label> \
<input type="number" id="safehomeLandHeading2"></input> \
<input id="safehomeLandHeading2Excl" type="checkbox" value="0" class="togglemedium" required> Excl. \
</div> \
</div> \
</div> \
');
if (fwApproach.getElevation() == 0) {
(async () => {
const elevation = await fwApproach.getElevationFromServer(safehome.getLonMap(), safehome.getLatMap(), globalSettings) * 100;
fwApproach.setElevation(elevation);
$('#safehomeElevation').text(fwApproach.getElevation() / 100 + " m");
})();
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < 0) {
alert(chrome.i18n.getMessage('MissionPlannerAltitudeChangeReset'));
return false;
}
const $safehomeBox = $safehomeContentBox.find('.missionPlannerSafehomeBox:last-child');
$safehomeBox.find('.spacer_box_title').append(safehome.getNumber() + 1);
$safehomeBox.find('#deleteSafehome').on('click', () => {
var shNum = safehome.getNumber();
SAFEHOMES.drop(shNum);
FW_APPROACH.clean(shNum);
selectedSafehome = SAFEHOMES.safehomeCount() - 1;
cleanSafehomeLayers();
renderSafehomesOnMap();
renderSafehomesTable();
updateSafehomeInfo();
});
$safehomeBox.find('#safehomeLatitude').val(safehome.getLatMap()).on('change', event => {
safehome.setLat(Math.round(Number($(event.currentTarget).val()) * 1e7));
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find('#safehomeLongitude').val(safehome.getLonMap()).on('change', event => {
safehome.setLon(Math.round(Number($(event.currentTarget).val()) * 1e7));
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find($('#safehomeSeaLevelRef')).prop('checked', fwApproach.getIsSeaLevelRef()).change(event => {
let isChecked = $(event.currentTarget).prop('checked') ? 1 : 0;
fwApproach.setIsSeaLevelRef(isChecked);
(async () => {
const elevation = await fwApproach.getElevationFromServer(safehome.getLonMap(), safehome.getLatMap(), globalSettings) * 100;
fwApproach.setElevation(elevation);
$('#safehomeElevation').text(elevation / 100);
$approachAlt = $safehomeBox.find('#safehomeApproachAlt');
$landAlt = $safehomeBox.find('#safehomeLandAlt');
if (isChecked) {
fwApproach.setApproachAltAsl(fwApproach.getApproachAltAsl() + elevation);
fwApproach.setLandAltAsl(fwApproach.getLandAltAsl() + elevation);
} else {
fwApproach.setApproachAltAsl(fwApproach.getApproachAltAsl() - elevation);
fwApproach.setLandAltAsl(fwApproach.getLandAltAsl() - elevation);
}
$approachAlt.val(fwApproach.getApproachAltAsl());
$landAlt.val(fwApproach.getLandAltAsl());
$('#safehomeLandAltM').text(fwApproach.getLandAltAsl() / 100 + " m");
$('#safehomeApproachAltM').text( fwApproach.getApproachAltAsl() / 100 + " m");
})();
});
$safehomeBox.find('#safehomeApproachAlt').val(fwApproach.getApproachAltAsl()).on('change', event => {
let altitude = Number($(event.currentTarget).val());
if (checkLandingAltitude(altitude, $safehomeBox.find('#safehomeSeaLevelRef').prop('checked'), Number($('#safehomeElevation').text()))) {
fwApproach.setApproachAltAsl(Number($(event.currentTarget).val()));
$('#safehomeApproachAltM').text( fwApproach.getApproachAltAsl() / 100 + " m");
cleanSafehomeLayers();
renderSafehomesOnMap();
renderHomeTable();
}
$safehomeBox.find('#safehomeApproachAlt').val(fwApproach.getApproachAltAsl());
});
$safehomeBox.find('#safehomeLandAlt').val(fwApproach.getLandAltAsl()).on('change', event => {
let altitude = Number($(event.currentTarget).val());
if (checkLandingAltitude(altitude, $safehomeBox.find('#safehomeSeaLevelRef').prop('checked'), Number($('#safehomeElevation').text()))) {
fwApproach.setLandAltAsl(altitude);
$('#safehomeLandAltM').text(fwApproach.getLandAltAsl() / 100 + " m");
cleanSafehomeLayers();
renderSafehomesOnMap();
renderHomeTable();
} else {
$safehomeBox.find('#safehomeLandAlt').val(fwApproach.getLandAltAsl());
}
});
$safehomeBox.find('#geozoneApproachDirection').val(fwApproach.getApproachDirection()).on('change', event => {
fwApproach.setApproachDirection($(event.currentTarget).val());
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find('#safehomeLandHeading1Excl').prop('checked', fwApproach.getLandHeading1() < 0).change(event => {
fwApproach.setLandHeading1(fwApproach.getLandHeading1() * -1);
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find('#safehomeLandHeading1').val(Math.abs(fwApproach.getLandHeading1())).on('change', event => {
let val = Number($(event.currentTarget).val());
if (val < 0) {
val = 360;
$safehomeBox.find('#safehomeLandHeading1').val(360);
}
if (val > 360) {
val = 0;
$safehomeBox.find('#safehomeLandHeading1').val(0);
}
if ($safehomeBox.find('#safehomeLandHeading1Excl').prop('checked')) {
val *= -1;
}
fwApproach.setLandHeading1(val);
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find('#safehomeLandHeading2Excl').prop('checked', fwApproach.getLandHeading2() < 0).change(event => {
fwApproach.setLandHeading2(fwApproach.getLandHeading2() * -1);
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$safehomeBox.find('#safehomeLandHeading2').val(Math.abs(fwApproach.getLandHeading2())).on('change', event => {
let val = Number($(event.currentTarget).val());
if (val < 0) {
val = 360;
$safehomeBox.find('#safehomeLandHeading2').val(360);
}
if (val > 360) {
val = 0;
$safehomeBox.find('#safehomeLandHeading2').val(0);
}
if ($safehomeBox.find('#safehomeLandHeading2Excl').prop('checked')) {
val *= -1;
}
fwApproach.setLandHeading2(val);
cleanSafehomeLayers();
renderSafehomesOnMap();
});
$('#safehomeLandAltM').text(fwApproach.getLandAltAsl() / 100 + " m");
$('#safehomeApproachAltM').text(fwApproach.getApproachAltAsl() / 100 + " m");
if (fwApproach.getElevation() != NaN)
$('#safehomeElevation').text(fwApproach.getElevation() / 100 + " m");
GUI.switchery();
localize();
return true;
}
function checkLandingAltitude(altitude, isSeaLevelRef, sealevel) {
if (isSeaLevelRef && altitude - sealevel < 0) {
alert(chrome.i18n.getMessage('MissionPlannerAltitudeChangeReset'));
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < MAX_NEG_FW_LAND_ALT) {
alert(chrome.i18n.getMessage('MissionPlannerFwLAndingAltitudeChangeReset'));
return false;
}
return true;
}
@ -749,40 +519,20 @@ TABS.mission_control.initialize = function (callback) {
$('#availableSafehomes').text(freeSamehomes + '/' + SAFEHOMES.getMaxSafehomeCount());
}
function addSafehome(){
if (SAFEHOMES.safehomeCount() + 1 > SAFEHOMES.getMaxSafehomeCount()){
alert(chrome.i18n.getMessage('missionSafehomeMaxSafehomesReached'));
return;
}
let mapCenter = map.getView().getCenter();
let midLon = Math.round(ol.proj.toLonLat(mapCenter)[0] * 1e7);
let midLat = Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7);
SAFEHOMES.put(new Safehome(SAFEHOMES.safehomeCount(), 1, midLat, midLon));
selectedSafehome = SAFEHOMES.safehomeCount() - 1;
cleanSafehomeLayers();
renderSafehomesOnMap();
renderSafehomesTable();
updateSafehomeInfo();
}
function renderSafehomesOnMap() {
/*
* Process safehome on Map
*/
SAFEHOMES.get().forEach(safehome => {
addSafehomeCircles(safehome);
addSafeHomeMarker(safehome);
addFwApproach(safehome.getLonMap(), safehome.getLatMap(), FW_APPROACH.get()[safehome.getNumber()], safehomeMarkers);
});
SAFEHOMES.get().forEach(safehome => {
addFwApproach(safehome.getLonMap(), safehome.getLatMap(), FW_APPROACH.get()[safehome.getNumber()], safehomeMarkers);
addSafehomeCircles(safehome);
addSafeHomeMarker(safehome);
});
}
function cleanSafehomeLayers() {
for (var i in safehomeMarkers) {
map.removeLayer(safehomeMarkers[i]);
@ -1622,20 +1372,63 @@ TABS.mission_control.initialize = function (callback) {
function redrawLayers() {
if (!mission.isEmpty()) {
repaintLine4Waypoints(mission);
mission.get().forEach(function (element) {
if (!element.isAttached()) {
map.addLayer(addWaypointMarker(element));
}
});
repaintLine4Waypoints(mission);
}
}
function redrawLayer() {
repaintLine4Waypoints(mission);
if (selectedFeature && selectedMarker) {
selectedFeature.setStyle(getWaypointIcon(selectedMarker, true));
}
repaintLine4Waypoints(mission);
}
function renderSafeHomeOptions() {
if (selectedSafehome && selectedFwApproachSh) {
if (!$('#missionPlannerSafehome').is(':visible')) {
$('#missionPlannerSafehome').fadeIn(300);
}
$('#SafehomeContentBox').show();
if (selectedFwApproachSh.getLandHeading1() == 0 && selectedFwApproachSh.getLandHeading1() == 0 && selectedFwApproachSh.getApproachAltAsl() == 0 && selectedFwApproachSh.getLandAltAsl() == 0) {
selectedFwApproachSh.setApproachAltAsl(settings.fwApproachAlt * 100);
selectedFwApproachSh.setLandAltAsl(settings.fwLandAlt * 100);
}
if (selectedFwApproachSh.getElevation() == 0) {
(async () => {
const elevation = await selectedFwApproachSh.getElevationFromServer(selectedSafehome.getLonMap(), selectedSafehome.getLatMap(), globalSettings) * 100;
selectedFwApproachSh.setElevation(elevation);
$('#safehomeElevation').text(selectedFwApproachSh.getElevation() / 100 + " m");
})();
}
const $safehomeBox = $safehomeContentBox.find('.missionPlannerSafehomeBox:last-child');
$safehomeBox.find('.spacer_box_title').text(chrome.i18n.getMessage('safehomeEdit') + ' ' + (selectedSafehome.getNumber() + 1));
$('#safehomeLatitude').val(selectedSafehome.getLatMap());
$('#safehomeLongitude').val(selectedSafehome.getLonMap());
changeSwitchery($('#safehomeSeaLevelRef'), selectedFwApproachSh.getIsSeaLevelRef());
$('#safehomeApproachAlt').val(selectedFwApproachSh.getApproachAltAsl());
$('#safehomeLandAlt').val(selectedFwApproachSh.getLandAltAsl());
$('#geozoneApproachDirection').val(selectedFwApproachSh.getApproachDirection());
$('#safehomeLandHeading1').val(Math.abs(selectedFwApproachSh.getLandHeading1()));
changeSwitchery($('#safehomeLandHeading1Excl'), selectedFwApproachSh.getLandHeading1() < 0);
$('#safehomeLandHeading2').val(Math.abs(selectedFwApproachSh.getLandHeading2()));
changeSwitchery($('#safehomeLandHeading2Excl'), selectedFwApproachSh.getLandHeading2() < 0);
$('#safehomeLandAltM').text(selectedFwApproachSh.getLandAltAsl() / 100 + " m");
$('#safehomeApproachAltM').text(selectedFwApproachSh.getApproachAltAsl() / 100 + " m");
} else {
$('#SafehomeContentBox').hide();
}
}
function renderWaypointOptionsTable(waypoint) {
@ -1855,10 +1648,7 @@ TABS.mission_control.initialize = function (callback) {
var handleShowSafehome = function () {
$('#missionPlannerSafehome').fadeIn(300);
//SAFEHOMES.flush();
//mspHelper.loadSafehomes();
cleanSafehomeLayers();
renderSafehomesTable();
renderSafehomesOnMap();
$('#safeHomeMaxDistance').text(settings.maxDistSH);
$('#SafeHomeSafeDistance').text(settings.safeRadiusSH);
@ -2020,11 +1810,10 @@ TABS.mission_control.initialize = function (callback) {
$('#safeHomeLongitude').val(Math.round(coord[0] * 1e7));
$('#safeHomeLatitude').val(Math.round(coord[1] * 1e7));
selectedSafehome = tempMarker.number;
updateSelectedShAndFwAp(tempMarker.number);
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
renderSafehomesTable();
}
else if (tempMarker.kind == "home") {
HOME.setLon(Math.round(coord[0] * 10000000));
@ -2109,8 +1898,8 @@ TABS.mission_control.initialize = function (callback) {
approach.setLandAltAsl(approach.getLandAltAsl() - approach.getElevation() + elevation);
}
approach.setElevation(elevation);
renderSafehomesTable();
}
}
renderSafeHomeOptions();
})()
}
this.coordinate_ = null;
@ -2344,8 +2133,8 @@ TABS.mission_control.initialize = function (callback) {
}
}
else if (selectedFeature && tempMarker.kind == "safehome" && tempMarker.selection) {
selectedSafehome = tempMarker.number;
renderSafehomesTable();
updateSelectedShAndFwAp(tempMarker.number);
renderSafeHomeOptions();
}
else if (selectedFeature && tempMarker.kind == "home" && tempMarker.selection) {
selectedMarker = HOME;
@ -2726,7 +2515,7 @@ TABS.mission_control.initialize = function (callback) {
$('#wpApproachAlt').on('change', (event) => {
if (selectedMarker && selectedFwApproachWp) {
let altitude = Number($(event.currentTarget).val());
if (checkLandingAltitude(altitude, $('#pointP3Alt').prop('checked'), Number($('#elevationValueAtWP').text()))) {
if (checkApproachAltitude(altitude, $('#pointP3Alt').prop('checked'), Number($('#elevationValueAtWP').text()))) {
selectedFwApproachWp.setApproachAltAsl(Number($(event.currentTarget).val()));
$('#wpApproachAltM').text(selectedFwApproachWp.getApproachAltAsl() / 100 + " m");
}
@ -2856,23 +2645,25 @@ TABS.mission_control.initialize = function (callback) {
});
/////////////////////////////////////////////
// Callback for SAFEHOMES Table
// Callback for SAFEHOMES
/////////////////////////////////////////////
/*
$safehomesTableBody.on('click', "[data-role='safehome-center']", function (event) {
$('#addSafehome').on('click', () => {
if (SAFEHOMES.safehomeCount() + 1 > SAFEHOMES.getMaxSafehomeCount()){
alert(chrome.i18n.getMessage('missionSafehomeMaxSafehomesReached'));
return;
}
let mapCenter = map.getView().getCenter();
let tmpSH = SAFEHOMES.getSafehome($(event.currentTarget).attr("data-index"));
tmpSH.setLon(Math.round(ol.proj.toLonLat(mapCenter)[0] * 1e7));
tmpSH.setLat(Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7));
SAFEHOMES.updateSafehome(tmpSH);
renderSafehomesTable();
let midLon = Math.round(ol.proj.toLonLat(mapCenter)[0] * 1e7);
let midLat = Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7);
SAFEHOMES.put(new Safehome(SAFEHOMES.safehomeCount(), 1, midLat, midLon));
updateSelectedShAndFwAp(SAFEHOMES.safehomeCount() - 1);
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
});
*/
$('#addSafehome').on('click', () => {
addSafehome();
updateSafehomeInfo();
});
$('#cancelSafehome').on('click', function () {
@ -2882,16 +2673,26 @@ TABS.mission_control.initialize = function (callback) {
$('#loadEepromSafehomeButton').on('click', function () {
$(this).addClass('disabled');
GUI.log(chrome.i18n.getMessage('startGettingSafehomePoints'));
mspHelper.loadSafehomes(mspHelper.loadFwApproach);
setTimeout(function(){
renderSafehomesTable();
cleanSafehomeLayers();
renderSafehomesOnMap();
updateSafehomeInfo();
GUI.log('End of getting Safehome points');
$('#loadEepromSafehomeButton').removeClass('disabled');
}, 500);
var loadChainer = new MSPChainerClass();
loadChainer.setChain([
mspHelper.loadSafehomes,
mspHelper.loadFwApproach,
function() {
if (SAFEHOMES.safehomeCount() >= 1) {
updateSelectedShAndFwAp(0);
} else {
selectedSafehome = null;
selectedFwApproachSh = null;
}
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
updateSafehomeInfo();
GUI.log('End of getting Safehome points');
$('#loadEepromSafehomeButton').removeClass('disabled');
}
]);
loadChainer.execute();
});
$('#saveEepromSafehomeButton').on('click', function() {
@ -2911,6 +2712,176 @@ TABS.mission_control.initialize = function (callback) {
saveChainer.execute();
});
$('#deleteSafehome').on('click', () => {
if (selectedSafehome && selectedFwApproachSh) {
var shNum = selectedSafehome.getNumber();
SAFEHOMES.drop(shNum);
FW_APPROACH.clean(shNum);
if (SAFEHOMES.safehomeCount() > 0) {
updateSelectedShAndFwAp(SAFEHOMES.safehomeCount() - 1);
} else {
selectedSafehome = null;
selectedFwApproachSh = null;
}
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
updateSafehomeInfo();
}
});
$('#safehomeLatitude').on('change', event => {
if (selectedFwApproachSh) {
selectedFwApproachSh.setLat(Math.round(Number($(event.currentTarget).val()) * 1e7));
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeLongitude').on('change', event => {
if (selectedFwApproachSh) {
selectedFwApproachSh.setLon(Math.round(Number($(event.currentTarget).val()) * 1e7));
renderSafeHomeOptions();
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeSeaLevelRef').on('change', event => {
let isChecked = $(event.currentTarget).prop('checked') ? 1 : 0;
if (selectedSafehome && selectedFwApproachSh && isChecked != selectedFwApproachSh.getIsSeaLevelRef()) {
selectedFwApproachSh.setIsSeaLevelRef(isChecked);
(async () => {
const elevation = await selectedFwApproachSh.getElevationFromServer(selectedSafehome.getLonMap(), selectedSafehome.getLatMap(), globalSettings) * 100;
selectedFwApproachSh.setElevation(elevation);
if (isChecked) {
selectedFwApproachSh.setApproachAltAsl(selectedFwApproachSh.getApproachAltAsl() + elevation);
selectedFwApproachSh.setLandAltAsl(selectedFwApproachSh.getLandAltAsl() + elevation);
} else {
selectedFwApproachSh.setApproachAltAsl(selectedFwApproachSh.getApproachAltAsl() - elevation);
selectedFwApproachSh.setLandAltAsl(selectedFwApproachSh.getLandAltAsl() - elevation);
}
$('#safehomeElevation').text(elevation / 100);
$('#safehomeApproachAlt').val(selectedFwApproachSh.getApproachAltAsl());
$('#safehomeLandAlt').val(selectedFwApproachSh.getLandAltAsl());
$('#safehomeLandAltM').text(selectedFwApproachSh.getLandAltAsl() / 100 + " m");
$('#safehomeApproachAltM').text(selectedFwApproachSh.getApproachAltAsl() / 100 + " m");
renderSafeHomeOptions();
})();
}
});
$('#safehomeApproachAlt').on('change', event => {
if (selectedFwApproachSh) {
let altitude = Number($(event.currentTarget).val());
if (checkApproachAltitude(altitude, $('#safehomeSeaLevelRef').prop('checked'), Number($('#safehomeElevation').text()))) {
selectedFwApproachSh.setApproachAltAsl(Number($(event.currentTarget).val()));
$('#safehomeApproachAltM').text(selectedFwApproachSh.getApproachAltAsl() / 100 + " m");
cleanSafehomeLayers();
renderSafehomesOnMap();
renderHomeTable();
}
$('#safehomeApproachAlt').val(selectedFwApproachSh.getApproachAltAsl());
}
});
$('#safehomeLandAlt').on('change', event => {
if (selectedFwApproachSh) {
let altitude = Number($(event.currentTarget).val());
if (checkLandingAltitude(altitude, $('#safehomeSeaLevelRef').prop('checked'), Number($('#safehomeElevation').text()))) {
selectedFwApproachSh.setLandAltAsl(altitude);
$('#safehomeLandAltM').text(selectedFwApproachSh.getLandAltAsl() / 100 + " m");
cleanSafehomeLayers();
renderSafehomesOnMap();
renderHomeTable();
} else {
$('#safehomeLandAlt').val(selectedFwApproachSh.getLandAltAsl());
}
}
});
$('#geozoneApproachDirection').on('change', event => {
if (selectedFwApproachSh) {
selectedFwApproachSh.setApproachDirection($(event.currentTarget).val());
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeLandHeading1Excl').on('change', event => {
if (selectedFwApproachSh) {
selectedFwApproachSh.setLandHeading1(selectedFwApproachSh.getLandHeading1() * -1);
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeLandHeading1').on('change', event => {
if (selectedFwApproachSh) {
let val = Number($(event.currentTarget).val());
if (val < 0) {
val = 360;
$('#safehomeLandHeading1').val(360);
}
if (val > 360) {
val = 0;
$('#safehomeLandHeading1').val(0);
}
if ($('#safehomeLandHeading1Excl').prop('checked')) {
val *= -1;
}
selectedFwApproachSh.setLandHeading1(val);
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeLandHeading2Excl').on('change', event => {
if (selectedFwApproachSh) {
selectedFwApproachSh.setLandHeading2(selectedFwApproachSh.getLandHeading2() * -1);
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
$('#safehomeLandHeading2').on('change', event => {
if (selectedFwApproachSh) {
let val = Number($(event.currentTarget).val());
if (val < 0) {
val = 360;
$('#safehomeLandHeading2').val(360);
}
if (val > 360) {
val = 0;
$('#safehomeLandHeading2').val(0);
}
if ($('#safehomeLandHeading2Excl').prop('checked')) {
val *= -1;
}
selectedFwApproachSh.setLandHeading2(val);
cleanSafehomeLayers();
renderSafehomesOnMap();
}
});
/////////////////////////////////////////////
// Callback for HOME Table
/////////////////////////////////////////////
@ -3407,57 +3378,53 @@ TABS.mission_control.initialize = function (callback) {
// mission = configurator store, WP number indexed from 0, MISSION_PLANNER = FC NVM store, WP number indexed from 1
/////////////////////////////////////////////
function getWaypointsFromFC(loadEeprom) {
var loadChainer = new MSPChainerClass();
var chain = [mspHelper.loadFwApproach];
if (loadEeprom) {
MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], getFwApproach);
} else {
getFwApproach();
}
function getFwApproach()
{
mspHelper.loadFwApproach(getWaypointData);
chain.push(function(callback) {
MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], callback);
});
}
chain.push(mspHelper.loadWaypoints);
chain.push(function() {
GUI.log(chrome.i18n.getMessage('endGetPoint'));
if (loadEeprom) {
GUI.log(chrome.i18n.getMessage('eeprom_load_ok'));
$('#loadEepromMissionButton').removeClass('disabled');
} else {
$('#loadMissionButton').removeClass('disabled');
}
if (!MISSION_PLANNER.getCountBusyPoints()) {
alert(chrome.i18n.getMessage('no_waypoints_to_load'));
return;
}
mission.reinit();
mission.copy(MISSION_PLANNER);
mission.update(false, true);
function getWaypointData() {
mspHelper.loadWaypoints(function() {
GUI.log(chrome.i18n.getMessage('endGetPoint'));
if (loadEeprom) {
GUI.log(chrome.i18n.getMessage('eeprom_load_ok'));
$('#loadEepromMissionButton').removeClass('disabled');
} else {
$('#loadMissionButton').removeClass('disabled');
}
if (!MISSION_PLANNER.getCountBusyPoints()) {
alert(chrome.i18n.getMessage('no_waypoints_to_load'));
return;
}
mission.reinit();
mission.copy(MISSION_PLANNER);
mission.update(false, true);
/* check multimissions */
multimissionCount = 0;
mission.get().forEach(function (element) {
if (element.getEndMission() == 0xA5) {
element.setMultiMissionIdx(multimissionCount);
multimissionCount ++;
}
});
multimissionCount = multimissionCount > 1 ? multimissionCount : 0;
multimission.reinit();
if (multimissionCount > 1) {
multimission.copy(mission);
$('#missionPlannerMultiMission').fadeIn(300);
/* check multimissions */
multimissionCount = 0;
mission.get().forEach(function (element) {
if (element.getEndMission() == 0xA5) {
element.setMultiMissionIdx(multimissionCount);
multimissionCount++;
}
renderMultimissionTable();
setView(16);
redrawLayers();
updateTotalInfo();
});
};
multimissionCount = multimissionCount > 1 ? multimissionCount : 0;
multimission.reinit();
if (multimissionCount > 1) {
multimission.copy(mission);
$('#missionPlannerMultiMission').fadeIn(300);
}
renderMultimissionTable();
setView(16);
redrawLayers();
updateTotalInfo();
});
loadChainer.setChain(chain);
loadChainer.execute();
}
function sendWaypointsToFC(saveEeprom) {
@ -3523,6 +3490,11 @@ TABS.mission_control.initialize = function (callback) {
}
}
function updateSelectedShAndFwAp(index) {
selectedSafehome = SAFEHOMES.get()[index];
selectedFwApproachSh = FW_APPROACH.get()[index];
}
/* resetAltitude = true : For selected WPs only. Changes WP Altitude value back to previous value if setting below ground level.
^ resetAltitude = false : changes WP Altitude to value required to give ground clearance = default Altitude setting
^ AbsAltCheck : check value for whether or not to use absolute altitude. This can be the P3 bitset or excplicitly set to true or false */

@ -701,7 +701,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$('#platform-type').parent('.select').addClass('no-bottom-border');
}
if (!updateEzTuneTabVisibility(false)) {
if (updateEzTuneTabVisibility(false)) {
EZ_TUNE.enabled = 0;
mspHelper.saveEzTune();
}

Loading…
Cancel
Save