Variable driver

Properties of devices may have to be stored for later use, or they may require some calculations or other manipulations before they can be used as input for operating other devices. This task is accomplished via variables. The variable driver provides two device types:

Integer type

An integer variable can only hold numbers that have no fractional component. The possible values for integers range from -2147483648 to 2147483647.

Arguments

initvalue
Integer (32-bits).

Properties

value
Integer (32-bits).

Events

value
The current content of the device. Fires an event whenever the value changes.

Commands

assign num
Store the specified integer as the new value to the device.
add num
Calculate a new value for the device by adding the specified integer to the current value.
subtract num
Calculate a new value for the device by subtracting the specified integer from the current value.
subfrom num
Calculate a new value for the device by subtracting the current value from the specified integer.
multiply num
Calculate a new value for the device by multiplying the current value and the specified integer.
divide num
Calculate a new value for the device by deviding the current value by the specified integer.
random max
Store a random number between 0 and max in the device. The number will always be lower than max .

Functions

abs
Return the absolute value of the value of the device.
negate
Return the two's complement of the value of the device.
time fmtstr
Interpret the value as seconds since the epoch and return a string representing that time in the specified format.

Float type

A float variable can store any floating point value.

Arguments

initvalue
Floating point value.

Properties

value
Floating point value.

Events

value
The current content of the device. Fires an event whenever the value changes.

Commands

assign val
Store the specified float as the new value to the device.
add val
Calculate a new value for the device by adding the specified float to the current value.
subtract val
Calculate a new value for the device by subtracting the specified float from the current value.
subfrom val
Calculate a new value for the device by subtracting the current value from the specified float.
multiply val
Calculate a new value for the device by multiplying the current value and the specified float.
divide val
Calculate a new value for the device by deviding the current value by the specified float.
random
Store a random number between 0 and 1. The number will always be below 1.

Functions

abs
Return the absolute value of the value of the device.
round
Round the current value of the device to the nearest integer.
negate
Return the two's complement of the value of the device.
format fmtstr
Return the current value of the device, formated according to the specified format string.