data/edge5i/modbus
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user