- Write your
DeviceProfile
as config file(config/profile.json). - Write your
DeviceList
andVirtualResource
as config file(config/device.json),VirtualResource
is referred to device resources which define inDeviceProfile
- Install a kafka broker and create topic(default
test
), config them in thekafka_reporter
. - Run
main
DeviceProfile
define a kind of device's resource, resource has value attr.DeviceList
define device's attr and virtual resource.VirtualResource
is{profile_name}:{resource_name}:VirtualResource
, eg:crane:current:ResourceFloat
.- Every device create a
VirtualDeviceTwin
withVirtualResource
, then spawnVirtualDeviceTwin
to a thread to generateValues
and reporter them.
- Rich virtual resource: random, line etc.
- Rich reporter with sequence: kafka and mqtt, kafka use one common topic and split one device to one partition by
device_id
key, mqtt sequence with one device one topic which topic name istopic_prefix/device_id
.
- resource_float : random f32 between maximum and minimum
- resource_int: random i32 between maximum and minimum
- one_of_list: config a type list, get one of them
"{\"device_id\":\"001\",\"event_time\":\"1650793385418\",\"current\":\"1.5\",\"voltage\":\"9\"}"
"{\"device_id\":\"002\",\"voltage\":\"7\",\"event_time\":\"1650793385418\",\"current\":\"1.5\"}"
Successfully produced record to topic test partition [0] @ offset 436
Successfully produced record to topic test partition [0] @ offset 437
"{\"device_id\":\"001\",\"event_time\":\"1650793385418\",\"current\":\"1.5\",\"voltage\":\"3\"}"
"{\"device_id\":\"002\",\"voltage\":\"0\",\"event_time\":\"1650793385418\",\"current\":\"1.5\"}"
Successfully produced record to topic test partition [0] @ offset 438
Successfully produced record to topic test partition [0] @ offset 439
"{\"device_id\":\"001\",\"event_time\":\"1650793385418\",\"current\":\"1.5\",\"voltage\":\"0\"}"
"{\"device_id\":\"002\",\"voltage\":\"0\",\"event_time\":\"1650793385418\",\"current\":\"1.5\"}"
Successfully produced record to topic test partition [0] @ offset 440
Successfully produced record to topic test partition [0] @ offset 441
"{\"device_id\":\"001\",\"event_time\":\"1650793385418\",\"current\":\"1.5\",\"voltage\":\"4\"}"
"{\"device_id\":\"002\",\"voltage\":\"0\",\"event_time\":\"1650793385418\",\"current\":\"1.5\"}"
Successfully produced record to topic test partition [0] @ offset 442
Successfully produced record to topic test partition [0] @ offset 443