### Calculations on sensor values

Measurements of separate Sensors can be combined by combining the Sensors themselve, which is possible in various ways depending on the concrete Sensor types. When Sensors are combined, they form a new (derived) Sensor, which can be monitored and used like any other Sensor.

The following examples clarify this:

• Logical combination of boolean Sensors:
BooleanSensor sensor = ... ; // some boolean Sensor
BooleanSensor not = sensor.not(); // new boolean Sensor measuring the negated value

BooleanSensor sensor2 = BooleanSensor.fromValue(true); // creating a boolean Sensor with a constant value
BooleanSensor or = sensor2.or(sensor); // new boolean Sensor measuring value of first sensor OR value of second sensor
BooleanSensor and = sensor2.and(sensor); // new boolean Sensor measuring value of first sensor AND value of second sensor
• Numerical calculations:
DoubleSensor sensor = ... ; // some Sensor measuring double values
DoubleSensor minus = sensor.negate(); // new Sensor measuring the negated values

DoubleSensor sensor2 = DoubleSensor.fromValue(2d); // creating a double Sensor with a constant value
DoubleSensor added = sensor2.add(sensor); // new double Sensor measuring value of sensor2 + value of sensor
DoubleSensor multiplied = sensor2.multiply(sensor); // new double Sensor measuring value of sensor2 * value of sensor