Giter VIP home page Giter VIP logo

virtual-device's Introduction

virtual-device

Quick start

  1. Write your DeviceProfile as config file(config/profile.json).
  2. Write your DeviceList and VirtualResource as config file(config/device.json), VirtualResource is referred to device resources which define in DeviceProfile
  3. Install a kafka broker and create topic(default test), config them in the kafka_reporter.
  4. Run main

Understand how it worked

  1. DeviceProfile define a kind of device's resource, resource has value attr.
  2. DeviceList define device's attr and virtual resource.
  3. VirtualResource is {profile_name}:{resource_name}:VirtualResource, eg: crane:current:ResourceFloat.
  4. Every device create a VirtualDeviceTwin with VirtualResource, then spawn VirtualDeviceTwin to a thread to generate Values and reporter them.

Features

  1. Rich virtual resource: random, line etc.
  2. 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 is topic_prefix/device_id.

Supported virtual resource

  • 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

Example

"{\"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

virtual-device's People

Contributors

curtiseng avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.