Updates
This commit is contained in:
parent
0942260f61
commit
bdaac4fa61
5 changed files with 58 additions and 22 deletions
|
@ -2,27 +2,29 @@ body {
|
|||
background-color : LightGrey;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
td {
|
||||
td , caption , th {
|
||||
text-align: center;
|
||||
}
|
||||
#lhtable {
|
||||
border: 1px solid black;
|
||||
background-color: PowderBlue;
|
||||
}
|
||||
#repeaters {
|
||||
border: 1px solid black;
|
||||
background-color: Yellow;
|
||||
}
|
||||
#linktable {
|
||||
border: 1px solid black;
|
||||
background-color: Lime;
|
||||
}
|
||||
#lhtable caption , #linktable caption {
|
||||
#lhtable caption , #linktable caption , #repeaters caption {
|
||||
font-weight : bold;
|
||||
font-size : 2em;
|
||||
color : white;
|
||||
background-color : black;
|
||||
width : 100%;
|
||||
}
|
||||
|
||||
#linktable {
|
||||
width: 100%;
|
||||
}
|
||||
#lhtable {
|
||||
#linktable , #lhtable , #repeaters {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="intro">Hi from the Dashboard</h1>
|
||||
<h1 id="intro">Dashboard</h1>
|
||||
<div>
|
||||
<div id="instruct"></div>
|
||||
<div id="links"></div>
|
||||
<div id="lastheard"></div>
|
||||
<div id="repeaters"></div>
|
||||
<div id="instruct"></div>
|
||||
</div>
|
||||
</body>
|
||||
</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 => {
|
||||
// console.log("lastheard " + data);
|
||||
$("#lastheard").empty();
|
||||
|
|
|
@ -3,7 +3,7 @@ headers=/var/log/dstargateway/Headers.log
|
|||
links=/var/log/dstargateway/Links.log
|
||||
[config]
|
||||
dgwconfig=/usr/local/etc/dstargateway.cfg
|
||||
host=nw7dr.ampr.org
|
||||
host=kf7ufz.ampr.org
|
||||
port=443
|
||||
[urls]
|
||||
sponsor=https://groups.io/g/gkrc
|
||||
|
|
49
index.js
49
index.js
|
@ -20,6 +20,7 @@ const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8'));
|
|||
const app = express();
|
||||
const buf = new CircularBuffer(heardqueue);
|
||||
const linklist = new CircularBuffer(linkqueue);
|
||||
var repeaterlist = [];
|
||||
|
||||
linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none',
|
||||
'repeater': 'none', 'reflector': 'none' , 'direction' : '' });
|
||||
|
@ -47,28 +48,48 @@ app.use(express.static(path.resolve(__dirname, 'client')));
|
|||
const io = socketio(server);
|
||||
|
||||
function senddata(dest,data,socket) {
|
||||
console.log("Enter Senddata -> " + dest);
|
||||
//console.log("Enter Senddata -> " + dest);
|
||||
socket.emit(dest,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() {
|
||||
console.log("Entering updatelinks");
|
||||
// console.log("Entering updatelinks");
|
||||
const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/;
|
||||
const linkfile = fs.readFileSync(links).toString();
|
||||
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) {
|
||||
linklist.deq();
|
||||
};
|
||||
console.log("Queue Size out: " + linklist.size());
|
||||
console.log("File Length: " + lines.length);
|
||||
// console.log("Queue Size out: " + linklist.size());
|
||||
// console.log("File Length: " + lines.length);
|
||||
let i = 0;
|
||||
while (i < lines.length) {
|
||||
if(lines[i] != "") {
|
||||
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],
|
||||
'repeater':mylinks[5] , 'reflector':mylinks[6] , 'direction' : mylinks[7] };
|
||||
linklist.push(linkrec);
|
||||
|
@ -77,17 +98,19 @@ function updatelinks() {
|
|||
}
|
||||
// console.log("From updatelinks() " + JSON.stringify(linklist.toarray()));
|
||||
// senddata("links",linklist.toarray(),io);
|
||||
console.log("Leaving updatelinks");
|
||||
// console.log("Leaving updatelinks");
|
||||
}
|
||||
|
||||
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
console.log('WS New connection');
|
||||
// console.log('WS New connection');
|
||||
buildrepeaters();
|
||||
senddata("lastheard",buf.toarray(),socket);
|
||||
senddata("links",linklist.toarray(),socket);
|
||||
senddata("title",host + " Dashboard",socket);
|
||||
console.log("leaving connection");
|
||||
senddata("repeaters",repeaterlist,socket);
|
||||
// console.log("leaving connection");
|
||||
});
|
||||
|
||||
// io.on('message', (socket) => {
|
||||
|
@ -95,18 +118,18 @@ io.on('connection', (socket) => {
|
|||
//});
|
||||
|
||||
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()));
|
||||
senddata("lastheard",buf.toarray(),io);
|
||||
});
|
||||
|
||||
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()));
|
||||
updatelinks();
|
||||
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
|
||||
senddata("links",linklist.toarray(),io);
|
||||
console.log("Leaving links watch");
|
||||
// console.log("Leaving links watch");
|
||||
});
|
||||
|
||||
const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
|
||||
|
|
Loading…
Reference in a new issue