-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSecurityDevice.java
63 lines (48 loc) · 1.57 KB
/
SecurityDevice.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This class represents the parent class for all types of sensors and detectors.
public class SecurityDevice {
// The device ID of the hardware.
public String deviceID;
// Stores the status of if battery is low.
public static boolean isBatteryLow;
// Stores the state of connection.
public static boolean isConnected = true;
// Stores if the device is on.
public static boolean isOn = true;
public String DeviceName;
// Contructor of the class.
// @param deviceID the device ID of the device.
public SecurityDevice(String deviceID) {
this.deviceID = deviceID;
}
// Returns the status of the device.
public String doStatusCheck() {
String sts = "\n" + deviceID + "\n";
if(isConnected)
sts += "Device is connected \n";
else
sts += "Device is not connected \n";
if(isOn)
sts += "Device is On \n";
else
sts += "Device is Off \n";
if(isBatteryLow)
sts += "Device's battery is Low";
return sts;
}
// Sends an alert if the any sensor / detector is triggered.
public static void sendAlert(String displayText, String id) {
BaseStation.SendAlert(displayText, id);
}
// Returns the device ID of the device.
public String getDeviceID() {
return deviceID;
}
// Turns on the device.
public static void turnOn() {
isOn = true;
}
// Turns off the device.
public static void turnOff() {
isOn = false;
}
}