Skip to content

Commit 4ab70e7

Browse files
committed
Add initial shot at payload recovered code. Needs API
1 parent 5b9d228 commit 4ab70e7

File tree

7 files changed

+438
-3
lines changed

7 files changed

+438
-3
lines changed

css/main.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,95 @@ header .search form input[type='submit'] {
640640
top: 3px;
641641
}
642642

643+
.switchyn {
644+
position: absolute;
645+
right: 0px;
646+
height: 28px;
647+
width: 77px;
648+
border: 1px solid #979797;
649+
border-radius: 20px;
650+
box-shadow: inset 0 1px 3px #BABABA, inset 0 12px 3px 2px rgba(232, 232, 232, 0.5);
651+
cursor: pointer;
652+
overflow: hidden;
653+
}
654+
.switchyn input[type=checkbox] {
655+
display: none;
656+
}
657+
.switchyn:before {
658+
content: "";
659+
display: block;
660+
height: 28px;
661+
width: 0px;
662+
position: absolute;
663+
border-radius: 20px;
664+
-webkit-box-shadow: inset 0 1px 2px #33B5E5, inset 0 12px 3px 2px #00A3D3;
665+
box-shadow: inset 0 1px 2px #33B5E5, inset 0 12px 3px 2px #00A3D3;
666+
background-color: #33B5E5;
667+
}
668+
.switchyn.on:before {
669+
width: 77px;
670+
}
671+
.switchyn > .thumb {
672+
display: block;
673+
width: 26px;
674+
height: 26px;
675+
position: relative;
676+
top: 0;
677+
z-index: 51;
678+
border: solid 1px #919191;
679+
border-radius: 28px;
680+
box-shadow: inset 0 2px 1px white, inset 0 -2px 1px white;
681+
background-color: #CECECE;
682+
background-image: -webkit-linear-gradient(#CECECE, #FBFBFB);
683+
background-image: -moz-linear-gradient(#CECECE, #FBFBFB);
684+
background-image: -o-linear-gradient(#CECECE, #FBFBFB);
685+
-webkit-transition: all 0.125s ease-in-out;
686+
-moz-transition: all 0.125s ease-in-out;
687+
-ms-transition: all 0.125s ease-in-out;
688+
-o-transition: all 0.125s ease-in-out;
689+
transition: all 0.125s ease-in-out;
690+
-webkit-transform: translate3d(0,0,0);
691+
-moz-transform: translateX(0px);
692+
-ms-transform: translateX(0px);
693+
-o-transform: translateX(0px);
694+
transform: translateX(0px);
695+
}
696+
.switchyn.on > .thumb {
697+
-webkit-transform: translate3d(49px,0,0);
698+
-moz-transform: translateX(49px);
699+
-ms-transform: translateX(49px);
700+
-o-transform: translateX(49px);
701+
transform: translateX(49px);
702+
}
703+
.switchyn:hover > .thumb {
704+
box-shadow: inset 0 2px 1px #fff, inset 0 -2px 1px #fff;
705+
background-image: none;
706+
}
707+
.switchyn > .thumb:before {
708+
font-weight: bold;
709+
font-size: 14px;
710+
color: #fff;
711+
content: "Yes";
712+
display: block;
713+
height: 14px;
714+
width: 14px;
715+
border: none;
716+
position: absolute;
717+
top: 3px;
718+
left: -30px;
719+
}
720+
.switchyn > .thumb:after {
721+
font-weight: bold;
722+
font-size: 14px;
723+
content: "No";
724+
display: block;
725+
height: 14px;
726+
width: 14px;
727+
position: absolute;
728+
right: -28px;
729+
top: 3px;
730+
}
731+
643732
#telemetry_graph {
644733
display: none;
645734
}
628 Bytes
Loading

img/markers/payload-recovered.png

243 Bytes
Loading

index.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ <h2><i class="icon-settings rfloat"></i>Settings</h2>
184184
<input type="checkbox" id="opt_hide_receivers">
185185
</div>
186186
</div>
187+
<div class="row option">
188+
<span><b>Hide recovered sondes from the map</b></span>
189+
<div class="switch off" id="sw_hide_recoveries">
190+
<span class="thumb"></span>
191+
<input type="checkbox" id="opt_hide_recoveries">
192+
</div>
193+
</div>
187194
<div class="row option">
188195
<span><b>Highlight selected vehicle</b></span>
189196
<div class="switch off" id="sw_hilight_vehicle">
@@ -298,6 +305,44 @@ <h2>Chase car mode</h2>
298305
<span>Speed</span>
299306
<span class="r" id="cc_speed">none</span>
300307
</div>
308+
<h3>Payload Recovery</h3>
309+
<hr>
310+
<div class="row">
311+
<span><b>Under Testing - Not Yet Functional!</b></span>
312+
</div>
313+
<div class="row">
314+
<span>You can mark a sonde as recovered using the following fields. Enter the serial number (manually, as a check), tick recovered/not recovered, and add some notes. You must have location enabled and be within 5km of the radiosonde position.</span>
315+
</div>
316+
<div class="row">
317+
<span><b>Serial</b></span>
318+
<span class="r"><input type="text" id="pr_serial" style="width: 140px;"/></span>
319+
</div>
320+
<div class="row option">
321+
<span><b>Recovery Success</b></span>
322+
<div class="switchyn on" id="sw_recovery_ok">
323+
<span class="thumb"></span>
324+
<input type="checkbox" id="recovery_ok">
325+
</div>
326+
</div>
327+
<div class="row option">
328+
<span><b>Use Car Position</b></span>
329+
<div class="switch off" id="sw_use_car_pos">
330+
<span class="thumb"></span>
331+
<input type="checkbox" id="use_car_pos">
332+
</div>
333+
</div>
334+
<div class="row">
335+
<span><b>Notes</b></span>
336+
<span class="r"><input type="text" id="pr_notes" style="width: 140px;"/></span>
337+
</div>
338+
<div class="row">
339+
<span><b>Report Success</b></span>
340+
<span class="r" id="pr_last_report">none</span>
341+
</div>
342+
<div class="row">
343+
<span class="r"><input type="button" value="Submit" id="pr_submit" onclick="ChaseCar.markRecovered();"/></span>
344+
</div>
345+
301346
</div>
302347
</div>
303348
<div id="homebox" style="width:0px;height:0px"></div>

js/app.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,32 @@ $(window).ready(function() {
766766
}
767767
});
768768

769+
// Functions for the payload recovery feature
770+
// Logic to switch the recovery OK button
771+
$("#sw_recovery_ok").click(function() {
772+
var e = $(this);
773+
774+
// turning the switch off
775+
if(e.hasClass('on')) {
776+
e.removeClass('on').addClass('off');
777+
// turning the switch on
778+
} else {
779+
e.removeClass('off').addClass('on');
780+
}
781+
});
782+
// Logic to switch the use car position button
783+
$("#sw_use_car_pos").click(function() {
784+
var e = $(this);
785+
786+
// turning the switch off
787+
if(e.hasClass('on')) {
788+
e.removeClass('on').addClass('off');
789+
// turning the switch on
790+
} else {
791+
e.removeClass('off').addClass('on');
792+
}
793+
});
794+
769795
// remember callsign as a cookie
770796
$("#cc_callsign").on('change keyup', function() {
771797
callsign = $(this).val().trim();
@@ -788,6 +814,7 @@ $(window).ready(function() {
788814
"#sw_haxis_hours",
789815
"#sw_daylight",
790816
"#sw_hide_receivers",
817+
"#sw_hide_recoveries",
791818
"#sw_hide_timebox",
792819
"#sw_hilight_vehicle",
793820
'#sw_hide_horizon',
@@ -841,6 +868,15 @@ $(window).ready(function() {
841868
refreshReceivers();
842869
}
843870
break;
871+
case "opt_hide_recoveries":
872+
if(on) {
873+
updateRecoveries([]);
874+
clearTimeout(periodical_recoveries);
875+
}
876+
else {
877+
refreshRecoveries();
878+
}
879+
break;
844880
case "opt_hide_timebox":
845881
var elm = $("#timebox");
846882
if(on) {

js/chasecar.lib.js

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
ChaseCar = {
1111
db_uri: "https://api.v2.sondehub.org/listeners", // Sondehub API
12+
recovery_uri: "https://api.v2.sondehub.org/recovered",
1213
};
1314

1415
// Updated SondeHub position upload function.
@@ -39,4 +40,84 @@ ChaseCar.updatePosition = function(callsign, position) {
3940
dataType: "json",
4041
data: JSON.stringify(_doc),
4142
});
42-
};
43+
};
44+
45+
46+
ChaseCar.markRecovered = function(){
47+
48+
_run_checks = false;//true;
49+
_range_limit = 5000; // Metres
50+
51+
// Get the serial number to be marked recovered
52+
_serial = $("#pr_serial").val().trim();
53+
54+
// Check it exists.
55+
if(_serial.includes("chase") && _run_checks){
56+
$('#pr_last_report').text("Invalid sonde callsign.");
57+
return;
58+
}
59+
if(!vehicles.hasOwnProperty(_serial) && _run_checks){
60+
$('#pr_last_report').text("Invalid sonde callsign.");
61+
return;
62+
}
63+
64+
// Now get the last position of the sonde.
65+
_sonde = {
66+
'lat':vehicles[_serial].curr_position['gps_lat'],
67+
'lon':vehicles[_serial].curr_position['gps_lon'],
68+
'alt':0.0
69+
};
70+
71+
// Now get the chaser position.
72+
_chaser = {
73+
'lat': parseFloat($('#cc_lat').text()),
74+
'lon': parseFloat($('#cc_lon').text()),
75+
'alt': 0.0
76+
};
77+
78+
// Calculate the distance from the sonde
79+
_lookangles = calculate_lookangles(_chaser, _sonde);
80+
81+
if( (_lookangles.range > _range_limit ) && _run_checks){
82+
$('#pr_last_report').text("Outside distance limit.");
83+
return;
84+
}
85+
86+
// We are close enough!
87+
_callsign = $("#cc_callsign").val().trim();
88+
_notes = $("#pr_notes").val().trim();
89+
90+
if($("#sw_use_car_pos").hasClass('on')){
91+
_recov_lat = parseFloat($('#cc_lat').text());
92+
_recov_lon = parseFloat($('#cc_lon').text());
93+
} else {
94+
_recov_lat = vehicles[_serial].curr_position['gps_lat'];
95+
_recov_lon = vehicles[_serial].curr_position['gps_lon'];
96+
}
97+
98+
var _doc = {
99+
"serial": _serial,
100+
"lat": _recov_lat,
101+
"lon": _recov_lon,
102+
"alt": vehicles[_serial].curr_position['gps_alt'],
103+
"recovered": $("#sw_recovery_ok").hasClass('on'),
104+
"recovered_by": _callsign,
105+
"description": _notes
106+
};
107+
108+
console.log(_doc);
109+
110+
$.ajax({
111+
type: "PUT",
112+
url: ChaseCar.recovery_uri,
113+
contentType: "application/json; charset=utf-8",
114+
dataType: "json",
115+
data: JSON.stringify(_doc),
116+
}).done(function() {
117+
$('#pr_last_report').text("Reported OK!");
118+
})
119+
.fail(function() {
120+
$('#pr_last_report').text("Failed to report.");
121+
})
122+
123+
}

0 commit comments

Comments
 (0)