configuration updates

max
Max 5 years ago
parent 384c8c28d0
commit 94a34dc4df
  1. 37
      op25/gr-op25_repeater/apps/http.py
  2. 66
      op25/gr-op25_repeater/www/config/default.json
  3. 2
      op25/gr-op25_repeater/www/www-static/index.html
  4. 33
      op25/gr-op25_repeater/www/www-static/main.js

@ -35,6 +35,7 @@ from gnuradio import gr
from waitress.server import create_server
from optparse import OptionParser
from multi_rx import byteify
from tsvfile import load_tsv, make_config
my_input_q = None
my_output_q = None
@ -42,6 +43,7 @@ my_recv_q = None
my_port = None
my_backend = None
CFG_DIR = '../www/config/'
TSV_DIR = './'
"""
fake http and ajax server module
@ -80,18 +82,49 @@ def valid_tsv(filename):
return False
return True
def tsv_config(filename):
DEFAULT_CFG = '../www/config/default.json'
filename = '%s%s' % (TSV_DIR, filename)
filename = filename.replace('[TSV]', '.tsv')
if not valid_tsv(filename):
return None
cfg = make_config(load_tsv(filename))
default_cfg = json.loads(open(DEFAULT_CFG).read())
result = default_cfg
channels = [ {'active': True,
'blacklist': cfg[nac]['blacklist'],
'whitelist': cfg[nac]['whitelist'],
'cclist': cfg[nac]['cclist'],
'demod_type': 'cqpsk',
'destination': 'udp://127.0.0.1:23456',
'filter_type': 'rc',
'frequency': 500000000,
'if_rate': 24000,
'nac': nac,
'name': cfg[nac]['sysname'],
'phase2_tdma': False,
'plot': "",
'tgids': cfg[nac]['tgid_map'],
'trunked': True
}
for nac in cfg.keys() ]
result['channels'] = channels
return {'json_type':'config_data', 'data': result}
def do_request(d):
global my_backend
TSV_DIR = './'
if d['command'].startswith('rx-'):
msg = gr.message().make_from_string(json.dumps(d), -2, 0, 0)
if not my_backend.input_q.full_p():
my_backend.input_q.insert_tail(msg)
return None
elif d['command'] == 'config-load':
if '[TSV]' in d['data']:
return tsv_config(d['data'])
filename = '%s%s.json' % (CFG_DIR, d['data'])
if not os.access(filename, os.R_OK):
return
return None
js_msg = json.loads(open(filename).read())
return {'json_type':'config_data', 'data': js_msg}
elif d['command'] == 'config-list':

@ -0,0 +1,66 @@
{
"backend-rx":{
"antenna":"",
"audio":false,
"audio-if":false,
"audio-input":"",
"audio-output":"default",
"calibration":0,
"costas-alpha":0.04,
"decim-amt":1,
"excess-bw":0.2,
"fine-tune":0,
"gain":null,
"gain-mu":0.025,
"gains":"",
"hamlib-model":null,
"ifile":"",
"input":"",
"logfile-workers":null,
"pause":false,
"raw-symbols":"",
"seek":0,
"tone-detect":false,
"udp-player":false,
"vocoder":false,
"wireshark":false,
"wireshark-host":"127.0.0.1"
},
"channels":[
{
"active":true,
"blacklist":[
""
],
"cclist":[
0
],
"demod_type":"cqpsk",
"destination":"udp://127.0.0.1:23456",
"filter_type":"rc",
"frequency":500000000,
"if_rate":24000,
"nac":null,
"name":"Channel1",
"phase2_tdma":false,
"plot":"",
"tgids":[],
"trunked":false,
"whitelist":[
""
]
}
],
"devices":[
{
"active":true,
"args":"rtl",
"frequency":500000000,
"gains":"lna:45",
"name":"Device1",
"offset":0,
"ppm":0,
"rate":1000000
}
]
}

@ -328,7 +328,6 @@
<th colspan=2 class="boxtitle-th"><span class="boxtitle">Tags</span></th>
<th>TG ID</th>
<th>TG Text</th>
<th>Priority</th>
<th colspan=2>&nbsp</th>
<th><input type=button name="add_tag" value="New" onclick="javascript:f_command(this, &quot;new&quot;);"</th>
</tr>
@ -336,7 +335,6 @@
<td colspan=2>&nbsp;</td>
<td><input type="text" name="tg_id" value="None"></input></td>
<td><input type="text" name="tg_tag" value=""> </td>
<td><input type="text" name="tg_priority" value=""> </td>
<td colspan=3>&nbsp</td>
</tr>
</table>

@ -117,7 +117,10 @@ function edit_d(d, to_ui) {
}
new_d[k] = new_l.join(",");
} else {
new_d[k] = d[k].join(",");
if ((!d[k]) || (!d[k].length))
new_d[k] = [];
else
new_d[k] = d[k].join(",");
}
} else if (k in freqs) {
new_d[k] = edit_freq(d[k], to_ui);
@ -596,35 +599,25 @@ function read_write_sel(sel_node, def) {
function read_write(elist, def) {
var result = {};
var s = "len: " + elist.length + "; ";
for (var e in elist) {
s += elist[e].tagName + "; ";
}
for (var e in elist) {
var ele = elist[e];
if (ele.nodeName == 'INPUT') {
if (ele.type == 'text')
if (def) {
if (def)
ele.value = def[ele.name];
s += ele.name + "=" + ele.value + "; ";
} else
else
result[ele.name] = ele.value;
else if (ele.type == 'checkbox')
if (def) {
if (def)
ele.checked = def[ele.name];
s += "checkbox " + ele.name + "; ";
}
else
result[ele.name] = ele.checked;
} else if (ele.nodeName == 'SELECT') {
if (def) {
if (def)
read_write_sel(ele, def);
s += "select " + ele.name + "; ";
}
else
result[ele.name] = read_write_sel(ele, def);
}
}
if (!def)
return result;
@ -648,19 +641,21 @@ function rollup_row(which, row, def) {
var tgtable = trrow.querySelector("table.tgtable");
var tgrow = trrow.querySelector("tr.tgrow");
if (def) {
for (var i=0; i<def["tgids"].length; i++) {
for (var k in def["tgids"]) {
var val = def["tgids"][k];
var newrow = amend_d(tgrow, tgtable, "new");
var inputs = newrow.querySelectorAll("input");
read_write(inputs, def["tgids"][i]);
read_write(inputs, {"tg_id": k, "tg_tag": val});
}
} else {
var tgids = [];
var tgids = {};
var rows = tgtable.querySelectorAll("tr.tgrow");
for (var i=0; i<rows.length; i++) {
if (rows[i].id == null || rows[i].id.substring(0,3) != "tg_")
continue;
var inputs = rows[i].querySelectorAll("input");
tgids.push(read_write(inputs, null));
var vals = read_write(inputs, null);
tgids[vals["tg_id"]] = vals["tg_tag"];
}
result['tgids'] = tgids;
}

Loading…
Cancel
Save