Virtual Devices¶
Virtual devices are not "real" devices in a sense that they do not exist in a physical world. They exist solely as abstractions on a platform. Their purpose is to gather data from one or several sensors, perform calculations using a configured mathematical expression, and then output some useful result. For example, they might calculate average temperature across several temperature sensors.
Virtual devices are accessible in Inzwa Cloud like a "real" device. Each virtual devices has a dashboard where users can track and analyze historical data. A pin can be placed on maps or site views for each access to the calculated data.
Creating a Virtual Device¶
To create a virtual device, click and select Manage Devices, then click on the Assign Device icon. From the Assign Device dialog, select Create Virtual Device. Choose the project you want to create virtual device for and click Next button. This will open the Create Virtual device dialog with two tabs: Device and Computed Key.
On the Device tab, specify a label and location for the virtual device, just as you would for any other device.
On the Computed Key tab, set the following properties:
- Device category - Selects the category of devices that will be providing the data for the expression.
- Display units - The units of the value calculated by the expression (eg. km/h). The units will be displayed on charts and dashboards.
- Y-axis label - The label typically displyed on the vertical axis of charts when the calculated data for the virtual device is displayed.
- Mathematical expression - The formula to be evaluated. For guidance on writing an expression, click the Show Help button or use the Constants, Operators and Functions section below. Examples are also available below.
- Number of Digits after Floating Point - Sets the number of precision digits of the computed result.
Use the Arguments section to configure placeholders for data values from real devices to include in the mathmatical expression. Using an argument simply involves typing its name into an expression, which will be replaced with the actual numeric value when evaluated. An expression should have at least one argument configured. Configure as many arguments as necessary to complete the desired expression.
- Trigger - Checking trigger means the configured expression will be evaluated every a time data for the configured device and telemetry key arrives. Only one argument can be a trigger and there must always be exactly one trigger argument. Arguements set as the trigger can only be set to Latest Value search mode.
- Argument name - The name should start with a letter and can only include letters, digits, or underscores. Use this name in an expression.
- Search mode - Defines how a value will be found when the expression is evaluated. There are 3 search modes.
- Latest value - The latest value received for configured datasource key will be used as the argument value when evaluating expression.
- Latest value with time buffer - The same as latest value but the latest value must be within the specified buffer time of when the expression is evaluated. Specify the buffer value by typing amount of time and selecting desired time unit. If more than one value is found within the buffer time, the lastest value will be used.
- Baseline value - For expressions that require a differential calculation using a constant value, use this option to establish the date and time of the baseline value. The first value on or after the specified time will be used.
- Device and Telemetry key - Select the device and its timeseries key that will be the data source for this argument.
Viewing a Virtual Device¶
Like real devices, virtual devices can be displayed on project maps or site images. For projects using a map to display device locations, set the virtial device location in the Device tab. For projects using a site image, follow the instructions for setting a device location.
Once a pin is displayed for a virtual device, a tooltip will be automatically available showing the latest value calculated by the expression. Like all devices, clicking on the tooltip title will open the device dashboard displaying a chart of historical values.
Deactivate a Virtual Device¶
Virtual devices can't be unassigned an reassigned to other projects nor can they be deleted. When you're finished with a virtual device, simple deactivate it from the Manage Devices screen. If the device appears on a site image, remove the pin using the set a device location tool.
Constants, Operators and Functions for use in Expressions¶
Constants¶
Constant | Desciption | Example |
---|---|---|
pi | pi = 3.14159.... | 2 * pi * f |
e | Euler's Number | e ^ 2 |
Operators¶
Operator | Example |
---|---|
Addition | 2 + 2 |
Subtraction | 2 - 2 |
Multiplication | 2 * 2 |
Implicit Multiplication | 2cos(x) |
Division | 2 / 2 |
Exponentials | 2 ^ 2 |
Unary Plus and Minus Sign | +2 - (-2) |
Modulus | 2 % 2 |
Functions¶
All trigonometric functions require input in radians. To convert from degrees to radians, use the deg2rad()
function.
Function | Description | Example |
---|---|---|
abs | Absolute Value | abs(-13) = 13.0 |
acos | Arc Cosine | acos(0.5) = 1.0471 |
asin | Arc Sine | asin(0.5) = 0.523 |
atan | Arc Tangent | atan(0.5) = 0.463 |
cbrt | Cubic Root | cbrt(64) = 4.0 |
ceil | Nearest upper integer | ceil(0.5) = 1.0 |
cos | Cosine | cos(0.5) = 0.877 |
cosh | Hyperbolic Cosine | cosh(0.5) = 1.127 |
deg2rad | Convert degress to radians. Use with trigonometric functions. | deg2rad(0.5)=0.0087 |
exp | Euler's number raised to the power (e^x) | exp(3) = 20.085 |
floor | Nearest lower integer | floor(0.5) = 0.0 |
log | Natural Logarithm (base e) | log(1) = 0.0 |
log10 | Logarithm (base 10) | log10(10) = 1.0 |
log2 | Logarithm (base 2) | log2(4) = 2.0 |
sin | Sine | sin(0.5) = 0.479 |
sinh | Hyperbolic Sine | sinh(0.5) = 0.521 |
sqrt | Square Root | sqrt(9) = 3.0 |
tan | Tangent | tan(0.5) = 0.546 |
tanh | Hyperbolic Tangent | tanh(0.5) = 0.462 |
signum | Signum | signum(5) = 1.0 |
Virtual Device Expression Examples¶
Expression | Description |
---|---|
(A + B + C) / 3 | Average the values from arguements named A, B, and C |
1000sin(deg2rad(D)) | Convert degres to mm/m. Assumes D is in degrees. |
3log(y)/(x+1) | Equivalent to 3 * log(y) / (x+1) |
2cos(xy) | Equivalent to 2 * cos (x * y) |
2 * pi * f * v | Calculate acceleration from the arguments frequency (f) and velocity (v) |