random_source
- type: producer
- output: either integer, real or boolean messages
Producer block that generates random messages of a specific type key and type.
Properties
key
: A unicode string that will be used as key in the generated messages. (required, string)type
The type of data that will be generated. Supported types areinteger
,real
andboolean
. (required, string)delay_ms
: If present, the block will waitdelay_ms
before emitting a new sample. (optional, integer)
When type is "integer"
min
: The minimum generated value, default is 0. (optional, integer)max
: The maximum generated value, default is 100. (optional, integer)
When type is "real"
min
: The minimum generated value, default is 0. (optional, real)max
: The maximum generated value, default is 1. (optional, real)
When type is "boolean"
p
: The probability of the generator returningtrue
. Defaults to0.5
The value must be>= 0
and<= 1
. (optional, real)
key
key
The key to be used in generated messages. (e.g. "my_example_key"
).
type
type
The type of the data contained in generated messages (e.g. "integer"
).
min
min
The minimum generated value (e.g. 0
). Only available when type is integer
or real
.
max
max
The maximum generated value (e.g. 100
). Only available when type is integer
or real
.
p
p
The probability of the generator returning true
(e.g. 0.5
). Only available when type is boolean
delay_ms
delay_ms
The delay between generated messages in milliseconds. For example use 5000
for 5 seconds.
Output message
key
: contains thekey
specified as parameter.data
: contains the generated value.type
: thetype
specified as parameter.timestamp
: contains the timestamp (in microseconds) in which the message was generated.
Examples
The following example uses random_source
block to generate messages that emulate a dice throw
every 10000 milliseconds (10 seconds).
random_source
.type("integer")
.min(1)
.max(6)
.delay_ms(10000)
[...]