itm / wsn-device-drivers

Drivers for Wireless Sensor Network Devices
Other
6 stars 4 forks source link

Make MockDevice behavior configurable #124

Closed danbim closed 12 years ago

danbim commented 12 years ago

In order to test certain use cases (e.g. in benchmarks and unit tests) the MockDevice should provide different behaviors. Using the Map<String,String> configuration-parameter there should be the possibility to configure its behavior.

Parameters:

Option Possible Values Description
UART_LATENCY any Integer If set, the MockDevice will emulate UART latency of Integer.parseInt(arg) milliseconds
BOOT_MESSAGE any String If not null, the MockDevice prints this string to the outgoing data stream after it was reset
BOOT_MESSAGE_TYPE "ascii" | "binary" If "ascii" the string is modified to a byte array via String.toByteArray(), if "binary" the String is parsed using StringUtils.fromStringToByteArray()
HEARTBEAT_MESSAGE any String If not null, the MockDevice writes periodic heartbeat messages to the outgoing data stream (currently named aliveRunnable). The String passed is, depending on the value of HEARTBEAT_MESSAGE_TYPE, parsed and sent periodically as heartbeat message
HEARTBEAT_MESSAGE_TYPE "ascii" | "binary" If "ascii" the string is modified to a byte array via String.toByteArray(), if "binary" the String is parsed using StringUtils.fromStringToByteArray()
HEARTBEAT_MESSAGE_RATE any Integer number as String The number of milliseconds after which the heartbeat message is repeatedly sent. The parameter is parsed with Integer.parseInt().
ECHO "true" | "false" If true, the MockDevice writes every byte read from the incoming stream to the outgoing stream, emulating an echo protocol
danbim commented 12 years ago

Example .properties-File style configuration (e.g., used in WsnDeviceUtilsGui):

UART_LATENCY = 100

BOOT_MESSAGE = Hello, World!
BOOT_MESSAGE_TYPE = ascii

HEARTBEAT_MESSAGE = Nummer Fünf braucht Input!
HEARTBEAT_MESSAGE_TYPE = ascii
HEARTBEAT_MESSAGE_RATE = 5000

ECHO = true