pull/1/head
John Hays 9 months ago
parent 0942260f61
commit bdaac4fa61

@ -2,27 +2,29 @@ body {
background-color : LightGrey; background-color : LightGrey;
font-family: sans-serif; font-family: sans-serif;
} }
td { td , caption , th {
text-align: center; text-align: center;
} }
#lhtable { #lhtable {
border: 1px solid black; border: 1px solid black;
background-color: PowderBlue; background-color: PowderBlue;
} }
#repeaters {
border: 1px solid black;
background-color: Yellow;
}
#linktable { #linktable {
border: 1px solid black; border: 1px solid black;
background-color: Lime; background-color: Lime;
} }
#lhtable caption , #linktable caption { #lhtable caption , #linktable caption , #repeaters caption {
font-weight : bold; font-weight : bold;
font-size : 2em; font-size : 2em;
color : white; color : white;
background-color : black; background-color : black;
width : 100%;
} }
#linktable { #linktable , #lhtable , #repeaters {
width: 100%;
}
#lhtable {
width: 100%; width: 100%;
} }

@ -17,11 +17,12 @@
</head> </head>
<body> <body>
<h1 id="intro">Hi from the Dashboard</h1> <h1 id="intro">Dashboard</h1>
<div> <div>
<div id="instruct"></div>
<div id="links"></div> <div id="links"></div>
<div id="lastheard"></div> <div id="lastheard"></div>
<div id="repeaters"></div>
<div id="instruct"></div>
</div> </div>
</body> </body>
</html> </html>

@ -29,6 +29,16 @@ socket.addEventListener("links", data => {
}); });
}); });
socket.addEventListener("repeaters", data => {
$("#repeaters").empty();
$("#repeaters").append("<table id=\"rptrtable\"><caption>Repeaters</caption>");
$("#rptrtable").append("<tr><th>Callsign</th><th>Frequency</th><th>Offset</th></tr>");
$.each(data, function(index,val){
$("#rptrtable").append("<tr><td>" + val.callsign + "</td><td>" + val.frequency +
" Mhz.</td><td>" + val.offset + " Mhz.</td></tr>");
});
});
socket.addEventListener("lastheard", data => { socket.addEventListener("lastheard", data => {
// console.log("lastheard " + data); // console.log("lastheard " + data);
$("#lastheard").empty(); $("#lastheard").empty();

@ -3,7 +3,7 @@ headers=/var/log/dstargateway/Headers.log
links=/var/log/dstargateway/Links.log links=/var/log/dstargateway/Links.log
[config] [config]
dgwconfig=/usr/local/etc/dstargateway.cfg dgwconfig=/usr/local/etc/dstargateway.cfg
host=nw7dr.ampr.org host=kf7ufz.ampr.org
port=443 port=443
[urls] [urls]
sponsor=https://groups.io/g/gkrc sponsor=https://groups.io/g/gkrc

@ -20,6 +20,7 @@ const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8'));
const app = express(); const app = express();
const buf = new CircularBuffer(heardqueue); const buf = new CircularBuffer(heardqueue);
const linklist = new CircularBuffer(linkqueue); const linklist = new CircularBuffer(linkqueue);
var repeaterlist = [];
linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none', linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none',
'repeater': 'none', 'reflector': 'none' , 'direction' : '' }); 'repeater': 'none', 'reflector': 'none' , 'direction' : '' });
@ -47,28 +48,48 @@ app.use(express.static(path.resolve(__dirname, 'client')));
const io = socketio(server); const io = socketio(server);
function senddata(dest,data,socket) { function senddata(dest,data,socket) {
console.log("Enter Senddata -> " + dest); //console.log("Enter Senddata -> " + dest);
socket.emit(dest,data); socket.emit(dest,data);
// console.log(dest,JSON.stringify(data)); // console.log(dest,JSON.stringify(data));
console.log("Leave Senddata -> " + dest); // console.log("Leave Senddata -> " + dest);
}
function buildrepeaters(){
repeaterlist = [];
for (i=1;i < 5;i++) {
let rptr = eval("dgwconfig.Repeater_"+i);
if (rptr.enabled) {
let callsign = dgwconfig.Gateway.callsign;
if (rptr.callsign !== ""){
callsign = rptr.callsign;
}
callsign += " " + rptr.band;
repeaterlist.push({'callsign':callsign,'frequency':rptr.frequency,
'offset':rptr.offset,'type':rptr.type});
}
}
// console.log(JSON.stringify(repeaterlist));
} }
function updatelinks() { function updatelinks() {
console.log("Entering updatelinks"); // console.log("Entering updatelinks");
const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/; const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/;
const linkfile = fs.readFileSync(links).toString(); const linkfile = fs.readFileSync(links).toString();
const lines = linkfile.split(/\n|\r\n/); const lines = linkfile.split(/\n|\r\n/);
console.log("Queue Size in: " + linklist.size()); // console.log("Queue Size in: " + linklist.size());
while (linklist.size() > 0) { while (linklist.size() > 0) {
linklist.deq(); linklist.deq();
}; };
console.log("Queue Size out: " + linklist.size()); // console.log("Queue Size out: " + linklist.size());
console.log("File Length: " + lines.length); // console.log("File Length: " + lines.length);
let i = 0; let i = 0;
while (i < lines.length) { while (i < lines.length) {
if(lines[i] != "") { if(lines[i] != "") {
var mylinks = lines[i].match(linksregex); var mylinks = lines[i].match(linksregex);
console.log(JSON.stringify(lines[i])); // console.log(JSON.stringify(lines[i]));
var linkrec = {'timestamp':mylinks[1].substr(0,19) , 'protocol':mylinks[2] , 'device':mylinks[4], var linkrec = {'timestamp':mylinks[1].substr(0,19) , 'protocol':mylinks[2] , 'device':mylinks[4],
'repeater':mylinks[5] , 'reflector':mylinks[6] , 'direction' : mylinks[7] }; 'repeater':mylinks[5] , 'reflector':mylinks[6] , 'direction' : mylinks[7] };
linklist.push(linkrec); linklist.push(linkrec);
@ -77,17 +98,19 @@ function updatelinks() {
} }
// console.log("From updatelinks() " + JSON.stringify(linklist.toarray())); // console.log("From updatelinks() " + JSON.stringify(linklist.toarray()));
// senddata("links",linklist.toarray(),io); // senddata("links",linklist.toarray(),io);
console.log("Leaving updatelinks"); // console.log("Leaving updatelinks");
} }
io.on('connection', (socket) => { io.on('connection', (socket) => {
console.log('WS New connection'); // console.log('WS New connection');
buildrepeaters();
senddata("lastheard",buf.toarray(),socket); senddata("lastheard",buf.toarray(),socket);
senddata("links",linklist.toarray(),socket); senddata("links",linklist.toarray(),socket);
senddata("title",host + " Dashboard",socket); senddata("title",host + " Dashboard",socket);
console.log("leaving connection"); senddata("repeaters",repeaterlist,socket);
// console.log("leaving connection");
}); });
// io.on('message', (socket) => { // io.on('message', (socket) => {
@ -95,18 +118,18 @@ io.on('connection', (socket) => {
//}); //});
fs.watch(headers, (curr, prev)=>{ fs.watch(headers, (curr, prev)=>{
console.log(headers + ' file changed'); // console.log(headers + ' file changed');
// console.log("from fs.watch headers " + JSON.stringify(buf.toarray())); // console.log("from fs.watch headers " + JSON.stringify(buf.toarray()));
senddata("lastheard",buf.toarray(),io); senddata("lastheard",buf.toarray(),io);
}); });
fs.watch(links, (curr, prev)=>{ fs.watch(links, (curr, prev)=>{
console.log(links + ' file changed'); // console.log(links + ' file changed');
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray())); // console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
updatelinks(); updatelinks();
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray())); // console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
senddata("links",linklist.toarray(),io); senddata("links",linklist.toarray(),io);
console.log("Leaving links watch"); // console.log("Leaving links watch");
}); });
const tailheaders = new Tail(headers, {startPos : 'end'}, line => { const tailheaders = new Tail(headers, {startPos : 'end'}, line => {

Loading…
Cancel
Save