Change number timestamp to seconds age
This commit is contained in:
parent
178d279b9b
commit
a3fccdf9df
@ -86,7 +86,10 @@ export class Communicator {
|
|||||||
const msgStr = message.toString();
|
const msgStr = message.toString();
|
||||||
const msgJson = JSON.parse(msgStr);
|
const msgJson = JSON.parse(msgStr);
|
||||||
console.log(`Message received on topic ${topic}: ${msgStr}`);
|
console.log(`Message received on topic ${topic}: ${msgStr}`);
|
||||||
if (msgJson.timestamp) console.log(`Timestamp: ${msgJson.timestamp}`);
|
if (msgJson.timestamp) {
|
||||||
|
const age = Date.now() - msgJson.timestamp;
|
||||||
|
console.log(`Message age: ${age / 1000}s`);
|
||||||
|
}
|
||||||
console.log(msgJson);
|
console.log(msgJson);
|
||||||
state[msgJson.name].on = msgJson.on;
|
state[msgJson.name].on = msgJson.on;
|
||||||
if (msgJson.feedRate) state[msgJson.name].feedRate = msgJson.feedRate;
|
if (msgJson.feedRate) state[msgJson.name].feedRate = msgJson.feedRate;
|
||||||
|
Loading…
Reference in New Issue
Block a user