mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
i hate weather
This commit is contained in:
@@ -10,6 +10,7 @@ const SNAPSHOT_DIR = process.env.ROVER_SNAPSHOT_DIR || '/var/lib/rover-snapshots
|
||||
const POLL_INTERVAL_MS = 300;
|
||||
const roverState = new Map();
|
||||
const events = new EventEmitter();
|
||||
const readCounts = new Map();
|
||||
let pollTimer = null;
|
||||
|
||||
function markState(id, updates = {}) {
|
||||
@@ -35,6 +36,11 @@ function createRoverSnapshotPoller({ roverManager }) {
|
||||
const buffer = await fs.readFile(filePath);
|
||||
const ts = stats.mtimeMs || Date.now();
|
||||
markState(id, { frame: buffer, ts, error: null, failures: 0, mtimeMs: stats.mtimeMs });
|
||||
const count = (readCounts.get(id) || 0) + 1;
|
||||
readCounts.set(id, count);
|
||||
if (count === 1 || count % 30 === 0) {
|
||||
logger.warn('Snapshot read', { id, count, ts, bytes: buffer.length, mtimeMs: stats.mtimeMs });
|
||||
}
|
||||
events.emit('frame', { id, buffer, ts });
|
||||
return { frame: buffer, ts };
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user