Giter Site home page Giter Site logo

device-virtual-go's Introduction

Device-Virtual-GO

The functions of Virtual Device Service GO just like the java version device-virtual, but supports more data types of random values:

  • Bool
  • Int8, Int16, Int32, Int64
  • Uint8, Uint16, Uint32, Uint64
  • Float32, Float64

This version of Virtual Device Service is implemented based on Device SDK GO, and leveraged ql (an embedded SQL database engine) to simulate virtual resources.

Docker compose file settings

Adding service:

device-virtual:
image: edgexfoundry/docker-device-virtual-go:1.0.0
ports:
  - "49990:49990"
container_name: device-virtual
hostname: device-virtual
networks:
  - edgex-network
volumes:
  - db-data:/data/db
  - log-data:/edgex/logs
  - consul-config:/consul/config
  - consul-data:/consul/data
  - db-devicevirtual:/db # Mount ql database directory is optional
depends_on:
  - data
  - command

How to use

For now, Virtual Device Service contains 4 pre-defined devices as random value generators:

Use Core-Command Service APIs to find executable commands information:

  • http://[host]:48082/api/v1/device/name/Random-Boolean-Device
  • http://[host]:48082/api/v1/device/name/Random-Integer-Device
  • http://[host]:48082/api/v1/device/name/Random-UnsignedInteger-Device
  • http://[host]:48082/api/v1/device/name/Random-Float-Device

NOTE:

  • The Enable_Randomization attribute of resource is automatically disabled when you use put command to set a specified value.
  • The minimum and maximum values of resource can be specified in the device profile. Example:
deviceResources:
 -
   name: "Int8"
   description: "Generate random int8 value"
   properties:
     value:
       { type: "Int8", readWrite: "R", minimum: "-100", maximum: "100", defaultValue: "0" }
     units:
       { type: "String", readWrite: "R", defaultValue: "random int8 value" }

Manipulate virtual resources via command ql tool (optional)

  1. Install command ql
  2. Enter ql database directory:
  • If the Virtual Device Service runs in Docker container, use the following command to find the path of ql database directory:
$ docker volume inspect edgex_temp_db-devicevirtual
  • If the Virtual Device Service runs in dev mode, the ql database directory is under the driver directory.

Command examples:

  • Query all data:
$ ql -db deviceVirtual.db -fld "select * from VIRTUAL_RESOURCE"
  • Update Enable_Randomization:
$ ql -db deviceVirtual.db "update VIRTUAL_RESOURCE set ENABLE_RANDOMIZATION=false where DEVICE_NAME=\"Random-Integer-Device\" and DEVICE_RESOURCE_NAME=\"Int8\" "
  • Update Value:
$ ql -db deviceVirtual.db "update VIRTUAL_RESOURCE set VALUE=\"26\" where DEVICE_NAME=\"Random-Integer-Device\" and DEVICE_RESOURCE_NAME=\"Int8\" "

device-virtual-go's People

Contributors

cloudxxx8 avatar felixting avatar iain-anderson avatar jamesrgregg avatar milj19lf avatar steveoss avatar tmpowers avatar tsconn23 avatar weichou1229 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.