scan control bugfix, js debug
This commit is contained in:
parent
69f2091f02
commit
c17443d9ac
|
@ -67,7 +67,8 @@ def post_req(environ, start_response, postdata):
|
|||
global my_input_q, my_output_q, my_recv_q, my_port
|
||||
try:
|
||||
data = json.loads(postdata)
|
||||
msg = gr.message().make_from_string(str(data['command']), -2, data['data'], 0)
|
||||
for d in data:
|
||||
msg = gr.message().make_from_string(str(d['command']), -2, d['data'], 0)
|
||||
my_output_q.insert_tail(msg)
|
||||
time.sleep(0.2)
|
||||
except:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
<div id="div_debug" style="display: none;">
|
||||
<br>
|
||||
</div>
|
||||
<!-- control buttons -->
|
||||
|
||||
<div id="controls" class="flex-container">
|
||||
|
|
|
@ -18,6 +18,22 @@
|
|||
// Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
// 02110-1301, USA.
|
||||
|
||||
var d_debug = 1;
|
||||
|
||||
var http_req = new XMLHttpRequest();
|
||||
var counter1 = 0;
|
||||
var error_val = null;
|
||||
var current_tgid = null;
|
||||
var send_busy = 0;
|
||||
var send_qfull = 0;
|
||||
var send_queue = [];
|
||||
var req_cb_count = 0;
|
||||
var request_count = 0;
|
||||
var nfinal_count = 0;
|
||||
var n200_count = 0;
|
||||
var r200_count = 0;
|
||||
var SEND_QLIMIT = 5;
|
||||
|
||||
function find_parent(ele, tagname) {
|
||||
while (ele) {
|
||||
if (ele.nodeName == tagname)
|
||||
|
@ -85,12 +101,6 @@ function f_select(command) {
|
|||
nav_update(command);
|
||||
}
|
||||
|
||||
var http_req = new XMLHttpRequest();
|
||||
|
||||
var counter1 = 0;
|
||||
var error_val = null;
|
||||
var current_tgid = null;
|
||||
|
||||
function is_digit(s) {
|
||||
if (s >= "0" && s <= "9")
|
||||
return true;
|
||||
|
@ -188,7 +198,7 @@ function trunk_update(d) {
|
|||
html += "</span><br>";
|
||||
}
|
||||
if (error_val != null) {
|
||||
html += "<span class=\"label\">Frequency error: </span><span class=\"value\">" + error_val + " Hz. (approx) </span>";
|
||||
html += "<span class=\"label\">Frequency error: </span><span class=\"value\">" + error_val + " Hz. (approx) </span><br>";
|
||||
}
|
||||
|
||||
// system frequencies table
|
||||
|
@ -220,11 +230,17 @@ function trunk_update(d) {
|
|||
|
||||
|
||||
function http_req_cb() {
|
||||
req_cb_count += 1;
|
||||
s = http_req.readyState;
|
||||
if (s != 4)
|
||||
if (s != 4) {
|
||||
nfinal_count += 1;
|
||||
return;
|
||||
if (http_req.status != 200)
|
||||
}
|
||||
if (http_req.status != 200) {
|
||||
n200_count += 1;
|
||||
return;
|
||||
}
|
||||
r200_count += 1;
|
||||
var dl = JSON.parse(http_req.responseText);
|
||||
var dispatch = {'trunk_update': trunk_update, 'change_freq': change_freq, 'rx_update': rx_update}
|
||||
for (var i=0; i<dl.length; i++) {
|
||||
|
@ -247,17 +263,30 @@ function do_onload() {
|
|||
|
||||
function do_update() {
|
||||
send_command("update", 0);
|
||||
f_debug();
|
||||
}
|
||||
|
||||
function send_command(command, data) {
|
||||
request_count += 1;
|
||||
if (send_queue.length >= SEND_QLIMIT) {
|
||||
send_qfull += 1;
|
||||
send_queue.unshift();
|
||||
}
|
||||
send_queue.push( {"command": command, "data": data} );
|
||||
send_process();
|
||||
}
|
||||
|
||||
function send_process() {
|
||||
s = http_req.readyState;
|
||||
if (s != 0 && s != 4) {
|
||||
send_busy += 1;
|
||||
return;
|
||||
}
|
||||
http_req.open("POST", "/");
|
||||
http_req.onreadystatechange = http_req_cb;
|
||||
http_req.setRequestHeader("Content-type", "application/json");
|
||||
cmd = JSON.stringify( {"command": command, "data": data} );
|
||||
cmd = JSON.stringify( send_queue );
|
||||
send_queue = [];
|
||||
http_req.send(cmd);
|
||||
}
|
||||
|
||||
|
@ -267,3 +296,19 @@ function f_scan_button(command) {
|
|||
else
|
||||
send_command(command, current_tgid);
|
||||
}
|
||||
|
||||
function f_debug() {
|
||||
if (!d_debug) return;
|
||||
var html = "busy " + send_busy;
|
||||
html += " qfull " + send_qfull;
|
||||
html += " sendq size " + send_queue.length;
|
||||
html += " requests " + request_count;
|
||||
html += "<br>callbacks:";
|
||||
html += " total=" + req_cb_count;
|
||||
html += " incomplete=" + nfinal_count;
|
||||
html += " error=" + n200_count;
|
||||
html += " OK=" + r200_count;
|
||||
html += "<br>";
|
||||
var div_debug = document.getElementById("div_debug");
|
||||
div_debug.innerHTML = html;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue