-
Notifications
You must be signed in to change notification settings - Fork 0
/
SensorEmulator.java
45 lines (35 loc) · 1.36 KB
/
SensorEmulator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package handler;
import java.io.IOException;
import java.util.Scanner;
import org.eclipse.paho.client.mqttv3.MqttException;
public class SensorEmulator {
public static void main(String[] args) throws MqttException, IOException {
System.out.println("Into Sensor Emulator ");
boolean t = true;
while (t) {
Scanner reader = new Scanner(System.in);
System.out.println("Sensor is ON -> ");
String s = reader.next(); //Sensor number 1
String d = reader.next(); //Sensor number 2
System.out.println("you have pressed ->" + s + " " + d + " " + " which causes");
while (s != null || d != null) {
if (s.equals("q") && d.equals("w")) { // first sensor triggered before second sensors,hence someone
// coming from outside
System.out.println(" Sensor is Triggered -> Person going IN Hence ->Calling the Driver class ");
Driver.start2();
break;
} else if (s.equals("w") && d.equals("q")) { // first sensor triggered after second . Hence somebody
// going out
System.out.println("Sensor is Triggered -> Person going OUT Hence ->Calling the Driver claas");
Driver.start2();
break;
}
else {
System.out.println("Nothing because its Just a USELESS INPUT ");
System.out.println("Not the Sensors I designed!");
break;
}
}
}
}
}