data/edge5/video/v2/+

This commit is contained in:
2026-07-04 17:26:30 +05:00
parent f61fd87bac
commit e0437edf18
5 changed files with 88 additions and 6 deletions

View File

@@ -0,0 +1,23 @@
import { log } from '../helpers/log.js'
import { lastTopicSegment } from '../helpers/topic-match.js'
import type { TopicHandler } from '../types.js'
const LOG_INTERVAL_MS = 10_000
const lastLogByCamera = new Map<string, number>()
export const handleEdge5VideoV2: TopicHandler = async (topic, payload) => {
const cameraId = lastTopicSegment(topic)
if (!cameraId) {
console.warn('edge5.video.v2.invalid_topic', { topic })
return
}
const now = Date.now()
const lastLog = lastLogByCamera.get(cameraId) ?? 0
if (now - lastLog >= LOG_INTERVAL_MS) {
log(`edge5.video.v2 [${cameraId}] ↑ ${payload.length}B`)
lastLogByCamera.set(cameraId, now)
}
}

View File

@@ -4,6 +4,7 @@ import { handleDemoPlc } from './demo-plc.js';
import { handleDemoModbus } from './demo-modbus.js';
import { handleEdge5ModbusV2 } from './edge5-modbus-v2.js';
import { handleEdge5Video } from './edge5-video.js';
import { handleEdge5VideoV2 } from './edge5-video-v2.js';
import { handle as interpretation } from './edge5i-modbus.js';
import { handle as cdab} from './edge5cdab-modbus.js';
@@ -20,3 +21,4 @@ register(EDGE5_VIDEO_TOPIC, handleEdge5Video);
register('data/edge5i/modbus', interpretation);
register('data/edge5cdab/modbus', cdab);
register('data/edge5/video/v2/+', handleEdge5VideoV2);