Repository navigation
Sensors Simulator
The SensorsSimulator is an object managing all the simulated sensors you've created.
- use
addSensormethod to add a senor to the simulator. - use
addSentMsgLoggerandaddInstructionReceivedLoggerto set uniform loggers to all simulated sensors - use
setGeneralStreamingIntevalto set a uniform streaming rate for all sensors - use
startSendingMsgsInAllSensorsto initiate sending messages on all sensors - use
stopSendingMsgsInAllSensorsto terminate the current streaming of messages on all sensors
Sensors cannot be created directly, but through the class SensorBuilder which allows setting all required properties: id, mac, alias, information paths, instruction paths, message. All the properties can be set through the builder's setter methods.
Notice that the builder API is fluent, so consuctive calls to setter can be concated as follows:
new SensorBuilder().setAlias("my sensor")
.setCommname("iShowerBoiler")
.addInfoSendingPath("boiler.temperature", Double.class)
.addInfoSendingPath("boiler.isOn", Boolean.class)
.addInfoSendingPath("boiler.time", Integer.class)
.addInstructionsReceiveingPath("boiler.set.temperature");NB a path in which a sensor sends data is deifined with a path as well as class. The classes supported are: Integer.class, Double.class, Boolean.class, String.class
In order to create a sensor instance from a builder, call the build method: GenericSensor s = builder.build();
messages can be defined through the builder in the methods:
public SensorBuilder addStreamingRange(String path, List values);
public SensorBuilder setMessageSupplier(Supplier<Map<String, Object>> msgsGenerator);Set a legal range for a single path. When streaming is initialized the sensor will generate a message who's values are within the given ranges and send to the system. This is usful for stress testing for example. Ranges are defined according to the class the path was registered to:
-
Integer.class,Double.class- expect a list of size 2, containing a lower bound (inclusive) and a higher bound (exclusive) -
Boolean.class- list of legal values, contains in the following list:Arrays.asList(true,false) -
String.class- list of legal values
the supplier receives a supplier method that generates a map of legal values each times it is called. This gives the developer a full freedom in message generation. e.g. - a vitals simulated sensor could generate legal heart beat pattern.
Use the following main:
public static void main(String[] args) throws Exception {
launch(simulator, shouldOpenGui);
}Rememeber to set shouldOpenGui value to true if you would like to load the simulator GUI as well, and false otherwise.
The GUI can help you with testing and debugging, since it includes consoles showing messages sent from the simulated sensors, and messages received from sensors (separately). For extensive GUI description look here.
Overview
Quick Start
Smarthouse Usage for Owners
Development Manuals
Continuous Development
Misc.