Project
by Mike Kerney
HTML
Security System Status: <br/>
<select id = 'SystemStatusChoice'>
<option id ='Activate'> Activated
<option id = 'Deactivate'> Deactivated
</select>
<br/>
<br/>
Alarm Test:<br/>
Please select the sensor type that has been tripped:<br/>
<select id = 'type'>
<option value="Window"> Window
<option value="Door"> Door
<option value="Fire">Fire
<option value="Smoke"> Smoke
<option value="CarbonMonoxide"> Carbon Monoxide
<option value="None">None
</select>
<input type=button onclick = "AlarmTest()" value="Submit">
<br/>
<br/>
<br/>
<br/>
<div id = "output">
JavaScript
var PhysicalAlarm =0;
var SmokeAlarm = 0;
var CarbMonAlarm = 0;
var FireAlarm = 0;
var WindowSensor=0;
var DoorSensor=0;
var FireSensor=0;
var SmokeSensor=0;
var CarbMonSensor=0;
var AlarmStatus = 0;
var None=0;
function AlarmTest(){
SystemStatus(); //Checks Control Panel Data
//If armed the functions of the system are enabled
if (AlarmStatus==1){
SensorStatus();
AlarmType();
NotifyEmergency();
}
else{
document.getElementById("output").innerHTML ="The security system is not active.";
}
}
//This function takes user imnput to activate or deactivate the alarm
function SystemStatus(){
var Astatus = document.getElementById('SystemStatusChoice').value;
switch (Astatus) {
case "Activated":
AlarmStatus = 1;
break;
case "Deactivated":
AlarmStatus = 0;
break;
default:
text = "No value found";
}
}
//This function checks the status of the sensors
function SensorStatus(){
// The if loop checks the alarm status, and if the alarm is activated, will perform the sensor checks
if (AlarmStatus==1){
// The do while loop repeats checking the sensors until one is tripped
var SensorType = document.getElementById('type').value;
do{
//The switch case uses user input to simulate recieving electrical signals from actual sensors. With real sensors the switch case would not be needed, just the do while loop checking the actual signals from each sensor.
switch (SensorType) {
case "Window":
WindowSensor = 1;
break;
case "Door":
DoorSensor = 1;
break;
case "Smoke":
SmokeSensor = 1;
break;
case "Fire":
FireSensor = 1;
break;
case "CarbonMonoxide":
CarbMonSensor = 1;
break;
case "None":
None=1;
document.getElementById("output").innerHTML ="All is well.";
break;
default:
text = "No value found";
}
}while(WindowSensor==0 && DoorSensor==0 && SmokeSensor==0 && FireSensor== 0 && CarbMonSensor==0&&None==0);
}}
function AlarmType(){
//This function checks the...