technical report (final) - الصفحات الشخصية | الجامعة...

57
The Islamic University of Gaza Faculty of Enginerring Computer Department Proposal For Graduate Project Web Based Home Automation System Done By : Ahmed Faris Ahmad Jarghoun Saa'd Ashour 1

Upload: dinhthu

Post on 04-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

The Islamic University of GazaFaculty of EnginerringComputer Department

Proposal For Graduate Project

Web Based Home Automation System

Done By :Ahmed Faris

Ahmad JarghounSaa'd Ashour

Submited to : Eng. Osama Khader

1

Page 2: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Table of ContentsTable of Contents ….……………………………………………………………………...2 Table of Contents ….……………………………………………………………………...31. Introduction.…………………………………………………………...……………...4

1.1 About this Project……………………………………………………………..5 1.2 Description of Problem Domain………………………………………………51.3 What is Home Automation……………………………………………………51.4 System Overview………………………………………………………….….61.5 Research Undertaken………………………………………………………...71.6 Resource Requirements……………………………………………………...8

2. Requirements Analysis……………………………………………………………...92.1 Features of a Home Automation System…………………………………….102.2 Overview of Requirements………………………………………………..…102.3 General and Non-Functional Requirements………………………………….11

2.3.1 Security Requirements…………………………………………..…112.3.2 Performance Requirements………………………………………...112.3.3 User Interface Requirements……………………………………….122.3.4 Data Requirements…………………………………………………132.3.5 Hardware Requirements…………………………………………....132.3.6 Software Requirements…………………………………………….14

2.4 Constraints…………………………………………………………………...142.4.1 External Constraints………………………………………………..142.4.2 Internal Constraints………………………………………………...14

3. High Level Design……………………………………………………………...……153.1 System Architecture………………………………………………………….17

3.1.1 Layers Architecture……………………………………………...…173.1.2 Technology Architecture…………………………………………..173.1.3 Project Architecture………………………………………………..173.1.4 State Diagram………………………………………………………18

3.2 Architecture Details……………………………...……………………....…..193.4 System Interfaces…………………………………………………………….20

3.4.1 User Interface Design………………………………………...……203.4.2 System Interfaces…………………………………………………..21

4. Low Level ……………………………………………………………….224.1 System Architecture………………………………………………………….23

2

Page 3: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

4.1.1 Client/Server Architecture…………………………………………244.1.2 Software Required…………………………………………………244.1.3 System Features……………………………………………………25

4.2 Architecture Details ……………………………………………………....26

4.3 Database Design……………………………………………………27 4.4 User Interface Design … …………………………..………………28

5. Implementation...........................................................................................................315.1 code Implementation ………………………………………………………...32

6. Conclusions……………………………………………………………………..……41 6.1 Possible Future Software Changes………………………………………..….426.2 Final Thoughts……………………………………………………………….42

7. References....................................................................................................................43

3

Page 4: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Introduction

4

Page 5: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Section 1 Introduction

1.1 About this Project

The goal of this project is to develop a secure Web Based Home Automation System that will allow users to remotely operate electric home appliances, e.g. turning on/off lights, in the user’s home.

The user interacts with the Home Automation System through a network, such as the Internet or a Local Area Network intranet by using an ordinary web browser. This will provide a user-friendly interface for the user to access and interact with the electric devices in the home.

Examples of practical uses for such a Home Automation System are many. These include;

energy management heating control lighting control

1.2 Description of Problem Domain

Home automation is a potentially huge growth area and several companies are currently developing software that enable users to access home devices from the office or other remote locations.

However, the software these companies are developing to accomplish home automation have;

Proprietary Interfaces Are Totally Insecure Not Web-Enabled

Therefore this project seeks to develop a Home Automation System that will overcome these limitations.

5

Page 6: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

1.3 What is Home Automation?

Home Automation is a way of controlling electrical appliances from a distance. Commands are sent from one location and received and acted upon in another location.

There are several systems available for implementing this kind of control. This project will focus on the cheapest and most popular method for home automation, use Microcontroller .

1.4 System Overview

The Home Automation System will allow users to use any Internet web browser to remotely control their electric home appliances through a simple web page. This software intends to leverage existing technologies and to utilise them in a new way.

The proposed Home Automation System will be multi-user and will exist in a distributed computer environment such as the Internet but will also be accessible from within an intranet such as an office or in the home itself.

The basic objectives are:

The software will run on any web browser . The software will switch devices attached to the remote computer on and

off.

The proposed system can best be illustrated with the following diagram;

Home (Parallel Port Cable)

Web Server/PC

PIC Circuit

(House wiring)

6

Internet or intranet

Page 7: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Web Browser

Lamp

Figure 1.1 System Overview

1.5 Research Undertaken Several lines of research were conducted to support the implementation of the

Home Automation System.

On the technical side, the research included;

Security Technologies – This will be of vital importance as the home automation system will be accessible from remote locations. A strong authentication architecture will be required.

Communication Technologies – A way of communicating via com ports on a PC will have to be researched. This will be necessary to communicate from the PC to the automated device.

Server Technologies – A lightweight web server has to be researched. Automation Technologies – The technology required for switching on and off the

remote devices will have to be researched.

On the non-technical side, researching various aspects of the project, which will include:

User interface design – We will be researching existing software products already available and also those in development.

Usability of current systems – We will be looking at the usability of different user interfaces currently used.

Functionality of current systems – We also will be examining the functionality of existing systems.

7

Page 8: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

This project will be challenging in many ways. The development of the online interface and communication with the automated devices is a new combination of technologies.

However We have a lot of experience of working in software/hardware environment and feel the resulting software would be benefit in Home Automation.

1.6 Resource Requirements

The resources required for this project are as follows.

Software: NetBeans IDE JCreator Pro Edition

Java SDK 1.5.0Tomcat Apache WebserverInternet Explorer 5.0 or laterParallel Port Java PackageWord 2000

Microsoft Frontpage Microsoft Access 2000

Hardware: Parallel Port cable Kit to collect the circuit

PIC 16F84A Microcontrolle 12V Transformer Resistors , Transistors , Capacitors & , Leds , & Wires

Personal Computer

Knowledge :- JSP , web programming Java Programming Microcontroller Programming concepts Some Skills of design

8

Page 9: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Requirements Analysis

9

Page 10: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Section 2 Requirements Analysis

There are a number of requirements for this project design. The main requirements are;

The system should be as easy to use as possible and should allow the user to access all functionality via a web-based interface.

The system should be designed in a modular fashion. A modular system allows for easier implementation and well as easier modification at a later stage.

2.1 Features of a Home Automation System

The ability to control a device – This is simply the ability to turn On or Off a device, e.g. a lamp, from the Home Automation interface.

The ability to authenticate users – This authenticates user connections to the Home Automation System to prevent unauthorised access.

The ability to assign devices to a logical group – This simply means that a collection of devices are abstracted to logical groups of devices for ease of operation and organisation of devices. These logical groups in this project will be referred to as ‘Rooms’ in the Home Automation System, which can hold any number of devices .

2.2 Overview of Requirements

The basic requirements for the Web Based Home Automation System are:

10

Page 11: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Security Requirements – As users will have to log into the Home Automation System from remote locations and from different computers, security is a very important consideration in this project.

Performance Requirements – The home automation system must perform well and be reliable. Because a home automation system integrates devices in the home it is subject to a high number of possible failures e.g. power cuts, power surges etc. The home automation system must therefore be able to check and monitor the status of the controlled devices. Also the system must allow users to use these devices even if the automation link between these devices has broken down.

User Interface Requirements - A very important point is the ease of use of the system. The web page has to be intuitive and easy to use. Furthermore, it must be also taken into account that the home automation system can be used by people with physical disabilities.

Data Requirements – The data for the Home Automation System will need to stored and accessed reliably and accurately.

Hardware Requirements – A flexible hardware arrangement will be desirable for adding new devices to the system.

These requirements will each be elaborated upon in the next Section 2.3 General and Non-Functional Requirements.

2.3 General and Non-Functional RequirementsThis section will further expand on the overview of requirements

listed in Section 2.2.

2.3.1Security RequirementsThere are security risks associated with using the Home Automation System as it is

designed to operate on a network like the Internet. When accessing the system the user needs to be assured that intruders, such as hacker attempts and third party invasions, can not have access to the Home Automation System. The user therefore needs to be confident that the Home Automation System is secure. The ability to authenticate user connections to the system is required.

To prevent unauthorised access the user has to log on to a website in order to have access to the Home Automation System. A secure system to validate the username and

11

Page 12: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

password information is required. The system will accept this information as proof of the identity and allow the user to access the Home Automation System.

2.3.2Performance Requirements Speed of the Internet connection from the remote computer and

the speed of the connection to the server will affect performance. The Home Automation System will be designed to be capable of operating even with slow Internet connections e.g. a standard 56K modem dial up connection to the network.

The Home Automation System will be designed to operate on a standard personal computer with a standard web browser installed. Response times to commands should be minimal from the browser.

The size of the website HTML & JSP code should be minimized to improve performance on a slower connections to the Internet. The means minimising use of graphics and concentrating on a more functional design. This will be addressed in more detail in Section 2.3.3 User Interface Requirements section.

Efficiency of the software code will have an effect on how quickly commands to the system are given. Every effort will be made to design the code with performance in mind.

Hardware connected to the system may suffer from a latency factor between issuing of a command and when that command is carried out. This will be taken into account and may influence how fast the commands are processed within the system.

2.3.3User Interface Requirements The user interface of the Home Automation System should be intuitive and easy

to use. We plan to provide a web-based interface for users to access the Home Automation System. This will enable users to use the system more easily, since it will be accessible through a common web browser from any computer connected to the Internet. This eliminates the need for installation and configuration of proprietary software.

The user interface will feature the use of meaningful graphics and icons, which will allow the user to easily identify options available. The number and size of these graphics, however, should be kept to a minimum to improve performance on computers with slow connections to the Internet.

12

Page 13: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

As most people are familiar with browsing on the Internet the web based user interface should have a look and feel that is familiar to the user.

The user interface should consist of several windows and buttons to control the different control devices e.g. a lamp.

The user will be able to access the status of all devices that are currently installed and running on the Home Automation System.

The Administrator will be able to add/remove devices to the system. The administrator will also be view all users and their devices.

The proposed system will use a web-based Graphical User Interface, which will have the following characteristics:

Website – The user will be able to access the main website from any web browser.

Login screen – This will be the main entrance to the system. This will feature a pop-up screen and have two text boxes for typing the username and password.

Main Menu – Once the user logs in, a navigation menu will allow the user to select all options available from the main menu page.

2.3.4 Data Requirements

The data for the Home Automation System will need to be stored and accessed in a reliable and accurate way. A database will store the username and passwords of several users at any one time. The database will also keep track of the number and recorded status of all available automated appliances.

Several text files will also be used to store initial start-up configuration details for the Home Automation System. The following table illustrates the data required;

Database Tables

Administrator Details

User Details

Device Details

Levels of Access

13

Page 14: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Figure 2.1 Data Requirements

2.3.5 Hardware Requirements

The hardware requirements for the Home Automation System consist of a computer controlled switching mechanism that will control the device to be automated.

Figure 2.2 PIC16F84A Microcontroller

This hardware is based heavily on the main chip on our project that is PIC16F84A .Detailed Description : 16F84 A PIC The versatile 16F84 A FLASH/EEPROM microcontroller with its easy-to-learn instruction set (only 35 single word instructions) allows the same device package to be used for prototyping and production. In addition, with In-Circuit-Serial Programming™, the designer can update code without the device being removed from the end application circuit board. PIC 16F84 A contains 1024x14 word of FLASH program memory, 64 data memory bytes, and 68 bytes of user RAM. The device also features an 8-bit timer/counter with 8-bit programmable prescaler, Watchdog timer with its own on-chip RC oscillator for reliable operation, Power-On-Reset (POR) Power-up Timer (PWRT), Oscillator Start-up timer (OST) and a maximum speed of 10MHz. 16F84 fits perfectly in applications ranging from high-speed automotive and appliance motor control to low-power remote sensors, electronic locks, security devices and smart cards. PIC 16F84 A has 13 I/O pins and is available in the following package options: 18 PDIP(P), 18 SOIC(SO), and 20 SSOP(SS). PIC 16F84 Features 18-pin Enhanced FLASH / EEPROM 8-bit Beside this chip we will use some simple elements if circuit such as capacitors and resistors etc. , We will use parallel port cable to send and receive data from chip to PC

2.3.6 Software Requirements

During the stage of research , we use many software to integrate our project , thesed software varies from programming software to designing , to software for circuits , etc , these software names discussed before .

14

Page 15: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

2.4 Constraints There are several external and internal constraints associated with this project.

2.4.1 External Constraints

Power Cuts - One of the external constraints is the possibility of unreliability of electrical power in the home. The system should be capable of operating and functioning correctly even after such an event has occurred.

Damage of devices :- this condition will be series condition and there is no way to know the status of the device in this condition .

2.4.2 Internal Constraints

Software - The development of this project will be constrained to using the Java programming language and related APIs.

Functionality- The functionally of the Home Automation system will be constrained to operating on only leds that will act as the devices on home because the difficulties of high electricity and components that will cannot treate the high power .

15

Page 16: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

High Level Design

16

Page 17: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Section 3 High Level Design

The overall design approach of the project will be object-oriented design using Java. The Home Automation System will be web based and use several server-side Java technologies .

3.1 System Architecture

The proposed architecture for the Home Automation System will be Client/Server based as the system will be accessed remotely and also accommodate several users at any time.

The use of server-side Java technologies like Servlets will provide a way to create a secure, thin-client, multi-tiered web application. These technologies are ideal as they can handle transaction and state management, multithreading, resource pooling, and other low-level details.

The diagram below shows a basic high level representation of the system.

Figure 3.1 Basic high level representation

17

Page 18: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

3.1.1 Layers Architecture

The Home Automation System will feature a three-tier architecture.

Front-End layer: Client Side Graphical User Interface.

This layer will consist of static and dynamically generated web pages. Dynamic content will be generated by servlets.

Middle- layer: Web Server / Servlets.

This layer will consist of a lightweight web server such as Tomcat to handle user requests and responses.

Back-End layer: Database Server.

This layer will consist of an Access 2000 database which stores information about users and devices. Database access logic will use JDBC/ODBC & SQL to query, insert and update information.

3.1.2 Technology ArchitectureThe use of Java will extend the functionality of the web server.

Each of the Java components will handle a specific request from the client. The web browser sends each online request to a web server where it will be processed. Using logic based on the type of request, the Java will query or update the database or text file as required and sends the necessary response to the user.

The following server-side components will be required;

Log In Log Out

View Devices

Turn On/off Device

18

Page 19: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

3.1.3 Project Architecture

The project architecture consists of four parts:

1)      Client implementations: GUI (HTML & JSP generated code)2)      Server implementations: Client request handling.3)      Database handling: Database connectivity and support for Server.4) Administrator: Adding or removing new devices to the system.

3.1.4 State Diagram

The state diagram below illustrates the normal states for a User and Administrator entering the Home Automation System website.

Figure 3.2 State Diagram

19

Page 20: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

3.2 Architecture Details

Java JDBC technology will be used for database connection.

Figure 3.3 Java JDBC/ODBC Overview

SQL, (Structured Query Language) will be used to update and query the database.

HTML (Hypertext Mark-up Language) will be used for web page design and implementation.

JSP : used to do dynamic web pages that control the device and users .

Java Special packages : will be used to allow communication between the server and the Chip circuit .

20

Page 21: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

3.4 System Interfaces

3.4.1 User Interface Design

The user interface will feature the use of meaningful icons, which will allow the user to easily identify options available. The buttons and function by which the user is able to interact with the Home Automation System are described below.

The different stages that are visible to the User and Administrator are:

Website – The user will be able to access the main website from any web browser.

        Login: Here the user has to enter username and password. If the password is wrong or the username doesn’t exist the user is notified.

        Main Menu: Once the user logs in, a navigation menu will allow the user to select the options available.

The main menu should provide the following functionality;

Device Status: The user can look at the device status. This will indicate whether a device is already on or off. E.g. a lamp may be already switched on and therefore can only be turned off by the user.

Turn On/Off Device: The user turns on/off device. Log Out: The user logs out. The user is now prevented from

interacting with the Home Automation System. This makes it impossible to press the back button on the browser and try to return to the main page.

The following items will be visible to the Administrator:

Add / Remove Device: This page allows the administrator to add/remove devices

Add / Remove Users: Here the Administrator is able to add users and determine their level of access to devices .

21

Page 22: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

3.4.2 System Interfaces

The Home Automation System will interface with an integrated circuit shown below :-

Figure 3.4 PIC Electrical CircuitThe circuit as shown consists of the main chip PIC , and 9 resistors and 2 capacitors and 3 transistors .

22

Page 23: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Low Level Design

23

Page 24: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Section 4 Low Level Design

This low-level design section details the architecture of how the Home Automation System will be designed.

4.1 System Architecture

The proposed architecture for the Home Automation System will use Java server-side technologies that will allow a way to create a secure, thin-client, multi-tiered web application. The system will have to handle transaction and state management, threading, resource pooling, and other low-level details.

The web content for the Home Automation System will be dynamically generated. This requires that the Tomcat web server do some additional processing of the request in order to generate a customised response.

During research into web servers for this project it was discovered that there are many different languages used today to generate the required dynamic content which includes;

CGI Cold Fusion ASP Server-Side JavaScript PHP Java Servlet JSP (Java Server Pages).

Having evaluated the advantages and disadvantages of each of the languages above it was decided to use Java Servlets for the server-side dynamic content generation. The use of Java servlets was chosen because it provided the following advantages;

o platform independenceo runs on in Java Virtual Machine on the web server, so it is safe and portable o can be used across operating systemso can be used across web servers(java enabled)o all requests are handled by separate threads within the web server process

24

Page 25: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

4.1.1 Client/Sever ArchitectureThe table below shows the proposed Client/Server architecture:

Tier Installed On Function

Client Any number of client desktop computers.

Web application presentation and accepts inputs from the user.

Server Web server – Apache2.0/Tomcat 4 Execution of the web application.

DatabaseWeb server – as a data source on this computer. Stores user and device information.

4.1.2 Software RequiredThe table below shows software required for the Home Automation System web

application to operate:

Tier Component Software Required

Client

Operating System Windows 98,NT,2000,XP,Mac OS

Web Browser Internet Explorer 4+ and Netscape Navigator 6+

Runtime Environment JRE 1.4

Server

Operating System Windows XP Pro

Web Server Apache 2.0/Tomcat 4, Java enabled web server.

PIC Chip PIC16F84A

Database Operating System Windows XP ProDatabase Access 2000

25

Page 26: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

4.1.3 System FeaturesThe Home Automation System will have the following features;

The Home Automation System will be developed to operate across a LAN intranet using a 10BaseT Ethernet Hub. The user (Client) will log into a remote computer from the web server. The user computer and the web server computer will operate on this LAN. See Figure 4.1

User 10BaseT Hub Web server

Figure 4.1 Network Overview

The web server’s IP address will be fixed. This IP address cannot change as the java classes will reference this address in their code.

The Apache/Tomcat web server will be servlet enabled and will provide the TCP/IP services required.

The HomeGateway java application will run on the web server in order to accept user commands. This application needs to be running at all times.

To control the devices, the web server communicates with PIC Chip computer .

A database called DB will be added as a data source on the web server.

Access to website will require authentication.

The user will require a friendly interface to the Home Automation System.

26

Page 27: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

4.2 Architecture Details

The implementation and design of each of the classes , and there is the methods required for each of the classes , are listed below.

Authorisation Script – Authorises user to the system.o checkuser(User p) o checklevel(User p) o checklevelstatus(String lid) o username(User p)

Device Control – Encodes/decodes authorisation to the server for security.o taskname(String lid) o updatetask(int status,String id)

Database – Handles the database.o getNextRow() o updateQuery() o getTableQuery()

4.3 Database DesignThe database used in this project is called DB and will be

implemented in Microsoft Access 2000. Access 2000 will be used during the testing phase of the project. Several SQL scripts are required to create the tables and several others to populate the database with data for testing purposes.

There will be basically 4 tables, representing the Automation Devices and the Users Details. The tables and brief explanations are as follows;

admin : describe the admins of the system user: Lists users and their names and levels of access. job: each user and what is the device that can control.

27

Page 28: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Task : describe the devices and their status

A diagram of the DB database tables is shown below;

Figure 4.2 DB database tables.

Table Details

Table 1: admin

      

Table 2: userID (Primary Key) NumericName Alphabetic

28

ID (Primary Key) NumericName Alphabeticpsw AlphabeticAddress AlphabeticEmail Alphabetic

Page 29: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

psw AlphabeticAddress AlphabeticEmail Alphabetic

Table 3: jobUID (Primary Key) NumericLID Numeric

Table 3: taskID (Primary Key) NumericName AlphabeticStatus Numeric

4.4 User Interface Design

This section will show screenshots of the Home Automation System’s online user interface. The screenshots shown are early prototypes and are likely to change significantly during the development of this project.

4.4.1 Screenshot 1 – Index Page

This is the starting page “index.html”. A screen shot of the index page is shown below;

Figure 4.12 index page screenshot

4.4.2 Screenshot 2 – Login Page

This is the main login page for users. The user enters their User name and Password.

The default username is; 1The default password is; 1

29

Page 30: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Figure 4.13 Login web page screenshot

4.4.3 Screenshot 3 – Main Page

This is the main page for selecting the automation devices. The user will be able to view information about the automation devices. Further, the user is capable to view the status of the automation devices.

Figure 4.14 Main web page screenshot

4.4.4 Screenshot 4 – Add Device

This page is where the administrator can add device to the Home Automation System.

Figure 4.15 Add Device web page screenshot

30

Page 31: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

4.4.5 Screenshot 5 – Edit Device

This page is where the administrator can edit device in the Home Automation System e.g. deleting a particular device.

Figure 4.16 Edit Device web page screenshot

31

Page 32: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Code implementation

32

Page 33: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

5.1 Code implementation :-

1) first code below is used to program the pic to meet our goals in this project .

PROCESSOR 16f84#include "p16f84.inc"__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;****************Block of variables******************** Cblock 0x0C var1 number endc;******************************************************

ORG 0x00 goto Main ORG 0x04 goto Main

Main bSf STATUS,RP0 movlw 0x00 movwf TRISb movlw 0x07 movwf TRISa

;initially output zeros bcf STATUS,RP0 movlw 0x00 movwf portb

begin

33

Page 34: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

bcf STATUS,RP0 movfw porta andlw 0x07 movwf var1

andlw 0x03 sublw 0x02 btfsc status,Z call Light

movfw var1 andlw 0x03 sublw 0x01 btfsc status,Z call Gate

movfw var1 andlw 0x03 addlw 0x01 sublw 0x01 btfsc status,Z call Fan

goto begin

;**************************************************************************************************

delay

bcf STATUS,RP0

clrf TMR0 movlw 5 bsf STATUS,RP0 movwf OPTION_REG

movlw 10 movwf number

q2 bcf INTCON,T0IFq1 btfss INTCON,T0IF goto q1

34

Page 35: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

decfsz number,1 goto q2 bcf STATUS,RP0 RETURN;**************************************************************************;**************************************************************************;**************************************************************************

Light movfw var1 andlw 0x04 sublw 0x04 btfsc status,Z goto b2 bcf portb,2 call delay ;return goto begin

b2 bsf portb,2 call delay goto begin

;**************************************************************************

Gate movfw var1 andlw 0x04 sublw 0x04 btfsc status,Z goto b1 bcf portb,1 call delay ;return goto begin

b1 bsf portb,1 call delay goto begin

35

Page 36: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

;**************************************************************************

Fan movfw var1 andlw 0x04 sublw 0x04 btfsc status,Z goto b0 bcf portb,0 call delay ;return goto begin

b0 bsf portb,0 call delay goto begin

;***********************************

END

2) next this is the code of java files and classes nad fuctions serve the project

Check.java

package code.jsp.project1;

import java.io.*;import java.util.*;import java.sql.*;

public class Check{

private Connection connection;private Statement statement;

public Check() throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

String sourceURL = "jdbc:odbc:p";

36

Page 37: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

connection = DriverManager.getConnection(sourceURL,"sa","sa");

statement=connection.createStatement(); }

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public boolean checkuser(User p) throws SQLException{

String id=p.getId();id=id.trim();String psw=p.getPsw();psw=psw.trim();

String sql="select name from user where id='"+id+"' and psw='"+psw+"'";

ResultSet results=statement.executeQuery(sql);//"select name from user" while(results.next()){

String temp=results.getString("name");if(temp!=null) return true;}

return false;}

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public void checklevel(User p) throws SQLException{

String id=p.getId();id=id.trim();String sql="select lid from job where uid='"+id+"'";ResultSet results=statement.executeQuery(sql); while(results.next()){

String temp=results.getString("lid");p.addLevel(temp); }

}

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public String checklevelstatus(String lid) throws SQLException

37

Page 38: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

{ lid=lid.trim();

String sql="select status from task where id='"+lid+"'";

ResultSet results=statement.executeQuery(sql);

while(results.next()){String temp=results.getString("status");temp=temp.trim();return temp; }

return "xxx"; }

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public String taskname(String lid) throws SQLException{

lid=lid.trim();

String sql="select name from task where id='"+lid+"'";

ResultSet results=statement.executeQuery(sql);

while(results.next()){String temp=results.getString("name");temp=temp.trim();return temp; }

return "xxx"; }

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public void updatetask(int status,String id) throws SQLException{

id=id.trim();

String sql="update task set status="+status+" where id='"+id+"'";

statement.executeUpdate(sql);

}

38

Page 39: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

public void username(User p) throws SQLException{

String id=p.getId();id=id.trim();

String sql="select name from user where id='"+id+"'";

ResultSet results=statement.executeQuery(sql);

while(results.next()){String temp=results.getString("name");temp=temp.trim();p.setName(temp); }

}

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

/**public void addGuest(GuestBean guest) throws SQLException{

statement.executeUpdate("insert into guests(firstName,lastName,email) values ('"+

guest.getFirstName()+"','"+guest.getLastName()+"','"+guest.getEmail()+"')");

}*/

//*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/

protected void finalize(){try{

statement.close();connection.close();

}catch(SQLException e){

e.printStackTrace();}

}

/*public static void main(String at[]){//System.out.println("qqqqqqqqqqqq");User u=new User();

39

Page 40: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

u.setId("123");u.setPsw("123");//System.out.println(u.getId());//System.out.println(u.getPsw());

try{ Check c=new Check();if(c.checkuser(u)) {System.out.println("qqqqqqqqqqqq");} System.out.println("*************************");System.out.println(c.checklevelstatus("3"));}catch(Exception e){}

}*/

}

User.java

package code.jsp.project1;

import java.util.*;

public class User{

private String id;private String psw,name,email,address;private Vector levels;

public User(){levels=new Vector();

}

public void setId(String x){ id=x; }

public String getId(){return id;

40

Page 41: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

}//******************************************public void setPsw(String x){

psw=x; }

public String getPsw(){return psw;

}//********************************************public void setName(String x){

name=x; }

public String getName(){return name;

}

//********************************************public void addLevel(String x){

levels.add(x);}

public Vector getLevel(){return levels;

}

}

3) Code of Jsp files is attached software with project

41

Page 42: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Conclusion

42

Page 43: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

Section 6 Conclusions

The project in general has been very successful. The software produced for the project is functionally correct, reasonably robust, and usable. The project has met all of the General and Non-Functional Requirements stated in Section 2, and in addition, has been implemented in a modular fashion, which can be easily modified or rewritten at a later stage.

The user interface is easy to use, and works in all web browsers. It does not require any propriety interfaces, applets or plug-ins to operate. This means that the Home Automation System is accessible from any web browser and that the system could be usable from anywhere on the Internet and therefore from anywhere on the planet!

The software is robust. The design of the software means that most errors are caught in a non-fatal manner, meaning that the software can continue executing even after a bad request.

6.1 Possible Future Software Changes

As the software was being developed, a number of minor shortcomings in the system were found. There are a number of changes to the design that could be considered in future additions to the software;

Due to the nature of the type of PIC module used in this project, the module did not have the ability to respond to a request for status, so it is not possible to query devices for status when the Home Automation System is first started. Therefore, when the system starts, the status of devices is at first unknown, and so is assumed to be ‘Off’ for each device..

The performance of the software is something that could also be improved by optimising the code if given more time. The performance gains to do this however would only be noticeable on very slow connections to the Internet (<28.0 kbps).

There are a number of classes such as the Check class that could have been used so that the overall system would be faster and more memory efficient.

43

Page 44: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

The changes mentioned here would not be too complex to implement. The modular design of the system would allow for changes to be made without significant changes to the existing code.

6.2 Final Thoughts

There is plenty of potential for expansion and commercial development for this project. The areas that were selected for implementation in the Home Automation System provided enough complexity to make the software useful and provide a good proof of concept.

Section 7 References

1. ‘Home Automation Page’ - http://www.geocities.com/ido_bartana/2. Microcontroller Lecture Notes for "Eng Mo'ayyad Al-mobayyed" 3. Sun Microsystems Java Page - http://java.sun.com/4. Internet searching .

44

Page 45: Technical Report (Final) - الصفحات الشخصية | الجامعة ...site.iugaza.edu.ps/afaris/files/2010/02/projectNew.doc · Web viewThis project will focus on the cheapest

45