• Ingen resultater fundet

Figure 5.18: Capturing user input in .html

Once credentials are entered, the user can press theLogin button present at the bottom of the text fields. The login button invokes the JavaScript function known as CheckLogin()where the processing takes place. The first thing defined in the function is to check the input fields to ensure that they are not empty. If text field is empty the user is notified via alert message.

Figure 5.19: Checking User Inputs

However, if the text fields are properly filled than the HTTP request consisting of POST method is sent to the server using AJAX. AJAX decouples the data exchange layer from the presentation layer because network operation are time consuming and if executed on same layer can ruin user experience. In order to create HTTP request using AJAX first we need to create XMLHttpRequest() Object and then define the request structure.

Figure 5.20: Creating post request using AJAX

The server performs the authentication and send back the results. A callback function is created to fetch the data whenever the response is received at the client side. If the user is authenticated then he is transferred to the new menu.html page and if the provided credentials proves to be wrong then an error message is displayed on screen.

Figure 5.21: Callback Function

The menu page consists of one single button present at the bottom of the APP.

This button is used to retrieve the list of rooms assigned to the user.

Figure 5.22: Menu Page

When user presses theGET Room Listbutton HTTP request is sent to the server and in response list of rooms is received in JSON string format. The received data is parsed into the JavaScript object usingJSON.pasrse() function. Now based on the number of rooms received a small list ofDIV is created dynamically for each room inside the MAIN DIV. The div consists of information about the controller board i.e serial number, alarm status and buttons which user can use to change the status of the alarm. Note that the visualization of serial number is just for testing process whereas in real App it should be replaced by room name.

Figure 5.23: Creating list of div representing rooms

Figure 5.24: User room list of the menu page

Now the user can select which room he wants to ARM or DISARM remotely based on the buttons presented on the list. The buttons consist of function call with

parameters i.e serial number and action to be performed. When the button is pressed these parameter are passed to the function named ARM() which makes an HTTP request to the server to perform the specified action on the controller board. Once the specified action is performed the server sends response back to the client which in turn refreshes the list with new information. In this way using simple mobile App the user can control their office rooms remotely.

quirements listed in the analysis section. This evaluation will help us to verify the functionality and prove the feasibility of the system. The overall prototype developed consisting of alarm and access control components is shown in the figure 6.1.

Figure 6.1: Hardware Prototype

6.1 Autonomous Alarm System

Autonomous alarm system has been fully developed and satisfy all of the requirements listed in the table. The proof for completion of each requirement is discussed below.

Figure 6.2: Requirements Number 1

6.1.1 RQ # 1(a)

Each room has its own controller board working independently from other controllers in the system. The system sets the alarm autonomously in each room. The stages through which the system passes before setting the alarm is shown in the figure below.

Figure 6.3: Response received by Controller Board

In the Normal Mode the tag <doorStatus> shows that the lock is open and

<state> of the alarm is Normal. Whereas, in Warning Mode the <state> of an alarm is set to Warning. This is because the tag<lastmovement> shows that five minutes have been passed since last motion is detected. Therefore,lastWarningclock will be triggered to start counting. Once it reaches thirty seconds and still no motion is detected the<state> of the alarm will be changed to final mode known asARM.

Now if someone tries to walk into the room then alarm will be triggered. All of these stages working together helps to set the alarm autonomously.

Figure 6.4: Arm system on button press

6.1.3 RQ # 1(c)

The occupancy is detected using the PIR sensors as they can track the motion within the room. In order to test the accuracy of PIR sensor four different test scenarios were conducted and output of PIR sensor against those scenario was checked. The results of the tests are shown below.

Figure 6.5: PIR sesnor test

Initially when there was no motion within the room the PIR sensor was displaying Normal state as expected. In the second scenario when movement was made in the room the PIR sensor was able to capture it properly. The PIR cover was removed

in the third scenario which lead to the change in the output of PIR as Tamper. In the end wires were shortened to dodge the sensor but PIR sensor was able to detect and report it. The events shown in the figure 6.5 and algorithm implemented helps in detecting whether someone is in the room or not.

6.1.4 RQ # 1(d)

The alarm system is interfaced with the buzzer which means that in case of intrusion the buzzer will be activated. The figure below shows how the ControlerStateAlarm is treated in the firmware.

Figure 6.6: Requirements

TheAlarm Modewill be activated if the movement is detected in premises during the armed mode. As it can be seen from the figure that in the Alarm mode the buzzer is activated by playing sound at a continuous interval of 10 milliseconds.