Skip to content

Commit

Permalink
Merge pull request #8 from BarbourSmith/Add-heartbeat-detection
Browse files Browse the repository at this point in the history
Add detection of the heartbeat
  • Loading branch information
BarbourSmith authored Mar 24, 2024
2 parents 981c8df + 399a613 commit f84f20f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Binary file modified index.html.gz
Binary file not shown.
20 changes: 20 additions & 0 deletions www/js/tablet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var gCodeDisplayable = false
var snd = null
var sndok = true

var lastHeartBeatTime = new Date().getTime();

var versionNumber = 0.65

function beep(vol, freq, duration) {
Expand Down Expand Up @@ -238,6 +240,18 @@ sendMove = function (cmd) {

fn && fn()
}
setInterval(checkOnHeartbeat, 500);
function checkOnHeartbeat() {
if (new Date().getTime() - lastHeartBeatTime > 10000) {
let msgWindow = document.getElementById('messages')
let text = msgWindow.textContent
text = text + '\n' + "No heartbeat from machine in 10 seconds. Please check connection."
msgWindow.textContent = text
msgWindow.scrollTop = msgWindow.scrollHeight
lastHeartBeatTime = new Date().getTime();
}
}

function tabletShowMessage(msg, collecting) {
if (
collecting ||
Expand All @@ -250,6 +264,12 @@ function tabletShowMessage(msg, collecting) {
return
}

//This keeps track of when we saw the last heartbeat from the machine
if(msg.startsWith('[MSG:INFO: Heartbeat')){
lastHeartBeatTime = new Date().getTime();
return
}

let msgWindow = document.getElementById('messages')
let text = msgWindow.textContent
text = text + '\n' + msg
Expand Down

0 comments on commit f84f20f

Please sign in to comment.