当前提交
895ea9b0fa
共有 2 个文件被更改,包括 170 次插入 和 144 次删除
|
|
@ -78,82 +78,95 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function json($id)
|
function json($id) {
|
||||||
{
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
$this->load->model('user_model');
|
||||||
|
|
||||||
$this->load->model('cat');
|
// Check if users logged in
|
||||||
|
|
||||||
$query = $this->cat->radio_status($id);
|
if($this->user_model->validate_session() == 0) {
|
||||||
|
// user is not logged in
|
||||||
|
// Return Json data
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(array(
|
||||||
|
"error" => "not_logged_in"
|
||||||
|
), JSON_PRETTY_PRINT);
|
||||||
|
} else {
|
||||||
|
|
||||||
if ($query->num_rows() > 0)
|
header('Content-Type: application/json');
|
||||||
{
|
|
||||||
foreach ($query->result() as $row)
|
$this->load->model('cat');
|
||||||
|
|
||||||
|
$query = $this->cat->radio_status($id);
|
||||||
|
|
||||||
|
if ($query->num_rows() > 0)
|
||||||
{
|
{
|
||||||
|
foreach ($query->result() as $row)
|
||||||
|
{
|
||||||
|
|
||||||
$frequency = $row->frequency;
|
$frequency = $row->frequency;
|
||||||
|
|
||||||
$frequency_rx = $row->frequency_rx;
|
$frequency_rx = $row->frequency_rx;
|
||||||
|
|
||||||
$power = $row->power;
|
$power = $row->power;
|
||||||
|
|
||||||
$prop_mode = $row->prop_mode;
|
$prop_mode = $row->prop_mode;
|
||||||
|
|
||||||
// Check Mode
|
// Check Mode
|
||||||
$mode = strtoupper($row->mode);
|
$mode = strtoupper($row->mode);
|
||||||
if ($mode == "FMN") {
|
if ($mode == "FMN") {
|
||||||
$mode = "FM";
|
$mode = "FM";
|
||||||
}
|
|
||||||
|
|
||||||
if ($row->prop_mode == "SAT") {
|
|
||||||
// Get Satellite Name
|
|
||||||
if ($row->sat_name == "AO-07") {
|
|
||||||
$sat_name = "AO-7";
|
|
||||||
} elseif ($row->sat_name == "LILACSAT") {
|
|
||||||
$sat_name = "CAS-3H";
|
|
||||||
} else {
|
|
||||||
$sat_name = strtoupper($row->sat_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Satellite Mode
|
if ($row->prop_mode == "SAT") {
|
||||||
$sat_mode_uplink = $this->get_mode_designator($row->frequency);
|
// Get Satellite Name
|
||||||
$sat_mode_downlink = $this->get_mode_designator($row->frequency_rx);
|
if ($row->sat_name == "AO-07") {
|
||||||
|
$sat_name = "AO-7";
|
||||||
|
} elseif ($row->sat_name == "LILACSAT") {
|
||||||
|
$sat_name = "CAS-3H";
|
||||||
|
} else {
|
||||||
|
$sat_name = strtoupper($row->sat_name);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($sat_mode_uplink)) {
|
// Get Satellite Mode
|
||||||
|
$sat_mode_uplink = $this->get_mode_designator($row->frequency);
|
||||||
|
$sat_mode_downlink = $this->get_mode_designator($row->frequency_rx);
|
||||||
|
|
||||||
|
if (empty($sat_mode_uplink)) {
|
||||||
|
$sat_mode = "";
|
||||||
|
} elseif ($sat_mode_uplink !== $sat_mode_downlink) {
|
||||||
|
$sat_mode = $sat_mode_uplink."/".$sat_mode_downlink;
|
||||||
|
} else {
|
||||||
|
$sat_mode = $sat_mode_uplink;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sat_name = "";
|
||||||
$sat_mode = "";
|
$sat_mode = "";
|
||||||
} elseif ($sat_mode_uplink !== $sat_mode_downlink) {
|
|
||||||
$sat_mode = $sat_mode_uplink."/".$sat_mode_downlink;
|
|
||||||
} else {
|
|
||||||
$sat_mode = $sat_mode_uplink;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$sat_name = "";
|
// Calculate how old the data is in minutes
|
||||||
$sat_mode = "";
|
$datetime1 = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time
|
||||||
|
$datetime2 = new DateTime($row->timestamp, new DateTimeZone('UTC'));
|
||||||
|
$interval = $datetime1->diff($datetime2);
|
||||||
|
|
||||||
|
$minutes = $interval->days * 24 * 60;
|
||||||
|
$minutes += $interval->h * 60;
|
||||||
|
$minutes += $interval->i;
|
||||||
|
|
||||||
|
$updated_at = $minutes;
|
||||||
|
|
||||||
|
// Return Json data
|
||||||
|
echo json_encode(array(
|
||||||
|
"frequency" => $frequency,
|
||||||
|
"frequency_rx" => $frequency_rx,
|
||||||
|
"mode" => $mode,
|
||||||
|
"satmode" => $sat_mode,
|
||||||
|
"satname" => $sat_name,
|
||||||
|
"power" => $power,
|
||||||
|
"prop_mode" => $prop_mode,
|
||||||
|
"updated_minutes_ago" => $updated_at,
|
||||||
|
), JSON_PRETTY_PRINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate how old the data is in minutes
|
|
||||||
$datetime1 = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time
|
|
||||||
$datetime2 = new DateTime($row->timestamp, new DateTimeZone('UTC'));
|
|
||||||
$interval = $datetime1->diff($datetime2);
|
|
||||||
|
|
||||||
$minutes = $interval->days * 24 * 60;
|
|
||||||
$minutes += $interval->h * 60;
|
|
||||||
$minutes += $interval->i;
|
|
||||||
|
|
||||||
$updated_at = $minutes;
|
|
||||||
|
|
||||||
// Return Json data
|
|
||||||
echo json_encode(array(
|
|
||||||
"frequency" => $frequency,
|
|
||||||
"frequency_rx" => $frequency_rx,
|
|
||||||
"mode" => $mode,
|
|
||||||
"satmode" => $sat_mode,
|
|
||||||
"satname" => $sat_name,
|
|
||||||
"power" => $power,
|
|
||||||
"prop_mode" => $prop_mode,
|
|
||||||
"updated_minutes_ago" => $updated_at,
|
|
||||||
), JSON_PRETTY_PRINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1235,97 +1235,110 @@ $(document).on('keypress',function(e) {
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Javascript for controlling rig frequency.
|
// Javascript for controlling rig frequency.
|
||||||
var updateFromCAT = function() {
|
var updateFromCAT = function() {
|
||||||
if($('select.radios option:selected').val() != '0') {
|
if($('select.radios option:selected').val() != '0') {
|
||||||
radioID = $('select.radios option:selected').val();
|
radioID = $('select.radios option:selected').val();
|
||||||
$.getJSON( "radio/json/" + radioID, function( data ) {
|
$.getJSON( "radio/json/" + radioID, function( data ) {
|
||||||
/* {
|
/* {
|
||||||
"frequency": "2400210000",
|
"frequency": "2400210000",
|
||||||
"frequency_rx": "10489710000",
|
"frequency_rx": "10489710000",
|
||||||
"mode": "SSB",
|
"mode": "SSB",
|
||||||
"satmode": "S/X",
|
"satmode": "S/X",
|
||||||
"satname": "QO-100"
|
"satname": "QO-100"
|
||||||
"power": "20"
|
"power": "20"
|
||||||
"prop_mode": "SAT"
|
"prop_mode": "SAT",
|
||||||
} */
|
"error": "not_logged_id" // optional, reserved for errors
|
||||||
$('#frequency').val(data.frequency);
|
} */
|
||||||
$("#band").val(frequencyToBand(data.frequency));
|
if (data.error) {
|
||||||
if (data.frequency_rx != "") {
|
if (data.error == 'not_logged_in') {
|
||||||
$('#frequency_rx').val(data.frequency_rx);
|
$(".radio_cat_state" ).remove();
|
||||||
$("#band_rx").val(frequencyToBand(data.frequency_rx));
|
if($('.radio_login_error').length == 0) {
|
||||||
}
|
$('.qso_panel').prepend('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="<?php echo base_url();?>">login</a></div>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Put future Errorhandling here
|
||||||
|
} else {
|
||||||
|
if($('.radio_login_error').length != 0) {
|
||||||
|
$(".radio_login_error" ).remove();
|
||||||
|
}
|
||||||
|
$('#frequency').val(data.frequency);
|
||||||
|
$("#band").val(frequencyToBand(data.frequency));
|
||||||
|
if (data.frequency_rx != "") {
|
||||||
|
$('#frequency_rx').val(data.frequency_rx);
|
||||||
|
$("#band_rx").val(frequencyToBand(data.frequency_rx));
|
||||||
|
}
|
||||||
|
|
||||||
old_mode = $(".mode").val();
|
old_mode = $(".mode").val();
|
||||||
$(".mode").val(data.mode);
|
$(".mode").val(data.mode);
|
||||||
|
|
||||||
if (old_mode !== $(".mode").val()) {
|
if (old_mode !== $(".mode").val()) {
|
||||||
// Update RST on mode change via CAT
|
// Update RST on mode change via CAT
|
||||||
setRst($(".mode").val());
|
setRst($(".mode").val());
|
||||||
}
|
}
|
||||||
$("#sat_name").val(data.satname);
|
$("#sat_name").val(data.satname);
|
||||||
$("#sat_mode").val(data.satmode);
|
$("#sat_mode").val(data.satmode);
|
||||||
if(data.power != null && data.power != 0) {
|
if(data.power != null && data.power != 0) {
|
||||||
$("#transmit_power").val(data.power);
|
$("#transmit_power").val(data.power);
|
||||||
}
|
}
|
||||||
$("#selectPropagation").val(data.prop_mode);
|
$("#selectPropagation").val(data.prop_mode);
|
||||||
|
|
||||||
// Display CAT Timeout warning based on the figure given in the config file
|
// Display CAT Timeout warning based on the figure given in the config file
|
||||||
var minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
var minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
||||||
|
|
||||||
if(data.updated_minutes_ago > minutes) {
|
if(data.updated_minutes_ago > minutes) {
|
||||||
$(".radio_cat_state" ).remove();
|
$(".radio_cat_state" ).remove();
|
||||||
if($('.radio_timeout_error').length == 0) {
|
if($('.radio_timeout_error').length == 0) {
|
||||||
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
|
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
|
||||||
} else {
|
} else {
|
||||||
$('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
|
$('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(".radio_timeout_error" ).remove();
|
$(".radio_timeout_error" ).remove();
|
||||||
text = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz';
|
text = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz';
|
||||||
if(data.mode != null) {
|
if(data.mode != null) {
|
||||||
text = text+'<span style="margin-left:10px"></span>'+data.mode;
|
text = text+'<span style="margin-left:10px"></span>'+data.mode;
|
||||||
}
|
}
|
||||||
if(data.power != null && data.power != 0) {
|
if(data.power != null && data.power != 0) {
|
||||||
text = text+'<span style="margin-left:10px"></span>'+data.power+' W';
|
text = text+'<span style="margin-left:10px"></span>'+data.power+' W';
|
||||||
}
|
}
|
||||||
if(data.prop_mode != null && data.prop_mode != '') {
|
if(data.prop_mode != null && data.prop_mode != '') {
|
||||||
text = text+'<span style="margin-left:10px"></span>('+data.prop_mode;
|
text = text+'<span style="margin-left:10px"></span>('+data.prop_mode;
|
||||||
if (data.prop_mode == 'SAT') {
|
if (data.prop_mode == 'SAT') {
|
||||||
text = text+' '+data.satname;
|
text = text+' '+data.satname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.frequency_rx != null && data.frequency_rx != 0) {
|
if(data.frequency_rx != null && data.frequency_rx != 0) {
|
||||||
text = text+'<span style="margin-left:10px"></span><b>RX:</b> '+(Math.round(parseInt(data.frequency_rx)/1000)/1000).toFixed(3)+' MHz)';
|
text = text+'<span style="margin-left:10px"></span><b>RX:</b> '+(Math.round(parseInt(data.frequency_rx)/1000)/1000).toFixed(3)+' MHz)';
|
||||||
}
|
}
|
||||||
if (! $('#radio_cat_state').length) {
|
if (! $('#radio_cat_state').length) {
|
||||||
$('.qso_panel').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div></div>');
|
$('.qso_panel').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div></div>');
|
||||||
} else {
|
} else {
|
||||||
$('#radio_cat_state').html(text);
|
$('#radio_cat_state').html(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
});
|
// Update frequency every three second
|
||||||
}
|
setInterval(updateFromCAT, 3000);
|
||||||
};
|
|
||||||
|
|
||||||
// Update frequency every three second
|
// If a radios selected from drop down select radio update.
|
||||||
setInterval(updateFromCAT, 3000);
|
$('.radios').change(updateFromCAT);
|
||||||
|
|
||||||
// If a radios selected from drop down select radio update.
|
// If no radio is selected clear data
|
||||||
$('.radios').change(updateFromCAT);
|
$( ".radios" ).change(function() {
|
||||||
|
if ($(".radios option:selected").val() == 0) {
|
||||||
// If no radio is selected clear data
|
$("#sat_name").val("");
|
||||||
$( ".radios" ).change(function() {
|
$("#sat_mode").val("");
|
||||||
if ($(".radios option:selected").val() == 0) {
|
$("#frequency").val("");
|
||||||
$("#sat_name").val("");
|
$("#frequency_rx").val("");
|
||||||
$("#sat_mode").val("");
|
$("#band_rx").val("");
|
||||||
$("#frequency").val("");
|
$("#selectPropagation").val($("#selectPropagation option:first").val());
|
||||||
$("#frequency_rx").val("");
|
$(".radio_timeout_error" ).remove();
|
||||||
$("#band_rx").val("");
|
}
|
||||||
$("#selectPropagation").val($("#selectPropagation option:first").val());
|
});
|
||||||
$(".radio_timeout_error" ).remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用