device_virtual

package module
v1.2.0-dev.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string = "to be replaced by makefile"

Global version for device-sdk-go

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
internal
driver
This package provides a implementation of a ProtocolDriver interface.
This package provides a implementation of a ProtocolDriver interface.
snap

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL