- Write your
DeviceProfileas config file(config/profile.json). - Write your
DeviceListandVirtualResourceas config file(config/device.json),VirtualResourceis referred to device resources which define inDeviceProfile - Install a kafka broker and create topic(default
test), config them in thekafka_reporter. - Run
main
DeviceProfiledefine a kind of device's resource, resource has value attr.DeviceListdefine device's attr and virtual resource.VirtualResourceis{profile_name}:{resource_name}:VirtualResource, eg:crane:current:ResourceFloat.- Every device create a
VirtualDeviceTwinwithVirtualResource, then spawnVirtualDeviceTwinto a thread to generateValuesand 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_idkey, 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