data/edge5i/modbus

This commit is contained in:
2026-07-02 14:40:49 +05:00
parent 16c1712752
commit 540a8ba1e9
4 changed files with 67 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ function toMetrics(values: number[], timestamp: string): DemoModbusMetric[] {
return values.map((value, index) => ({
edge: EDGE,
timestamp,
tag: `${EDGE}.modbus.${index + 1}`,
tag: `register-${index}`,
value,
}))
}
@@ -42,11 +42,11 @@ async function postMetrics(metrics: DemoModbusMetric[]): Promise<void> {
}
}
console.log('edge5.modbus.posted', { count: metrics.length })
console.log(`${EDGE}.modbus.posted ${metrics.length} metrics`)
}
export const handleDemoModbus: TopicHandler = async (topic, payload) => {
console.log('edge5.modbus.received', { topic, bytes: payload.length })
console.log(`${EDGE}.modbus.received ${topic} ${payload.length} bytes`)
const values = parseValues(payload)
const metrics = toMetrics(values, new Date().toISOString())