BORANG PENGESAHAN STATUS TESIS
Transcription
BORANG PENGESAHAN STATUS TESIS
PSZ 19:16 (Pind. 1/97) Universiti Teknologi Malaysia BORANG PENGESAHAN STATUS TESIS JUDUL: INTERNET-BASED I/O ENGINE FOR A SMART HOUSE SYSTEM SESSI PENGAJIAN: Saya: 2005/2006 SAIFUL SALAMI BIN AZMI (HURUF BESAR) mengaku membenarkan tesis (PSM/Sarjana/Doktor falsafah)* ini disimpan di Perpustakaan Universiti Teknologi Malaysia dengan syarat-syarat kegunaan seperti berikut: 1. 2. 3. 4. Tesis adalah hakmilik Universiti Teknologi Malaysia. Perpustakaan Universtiti Teknologi Malaysia dibenarkan membuat salinan untuk tujuan pengajian sahaja. Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara institusi pengajian tinggi ** Sila tandakan ( √ ) √ SULIT (Mengandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia seperti yang termaktub di dalam AKTA RAHSIA RASMI 1972) TERHAD (Mengandungai maklumat TERHAD yang telah ditentukan oleh organisasi/badan di mana penyelidikan dijalankan) TIDAK TERHAD Disahkan Oleh (TANDATANGAN PENULIS) (TANDATANGAN PENYELIA) Alamat tetap: LOT 1037, SIMPANG BUKIT LADA, EN. ZURAIMI BIN YAHYA 28000, TEMERLOH, PAHANG Tarikh: 12 MEI 2006 CATATAN: * ** Nama Penyelia Tarikh: 12 MEI 2006 Potong yang tidak berkenaan Jika tesis ini SULIT atau TERHAD, sila lampirkan surat daripada pihak berkuasa/organisasi berkenaan dengan menyatakan sekali sebab dan tempoh tesis ini perlu dikelaskan sebagai SULIT atau TERHAD. Tesis dimaksudkan sebagai tesis bagi Ijazah Doktor Falsafah dan Sarjana secara penyelidikan atau disertasi bagi pengajian secara kerja kursus dan penyelidikan atau Laporan Projek Sarjana Muda (PSM). “I certify that I have read this project’s report and that in my opinion it is fully adequate, in scope and quality, as a project’s report for the Bachelor Degree of Electrical Engineering (Computer)”. Signature : ………………………………… Supervisor’s name : EN. ZURAIMI BIN YAHYA Date : 12 MAY 2006 INTERNET-BASED I/O ENGINE FOR A SMART HOUSE SYSTEM SAIFUL SALAMI BIN AZMI A project’s report submitted to the Faculty of Electrical Engineering, Universiti Teknologi Malaysia in partial fulfillment of the requirement for Bachelor Degree of Electrical Engineering (Computer) Faculty of Electrical Engineering Universiti Teknologi Malaysia MAY, 2006 ii “I certify that this project’s report is a copyright of my own work except citation and summary that I have stated each of the resource clearly”. Signature : ………………..………………… Writer’s Name : SAIFUL SALAMI BIN AZMI Date 12 MAY 2006 : iii For Mama, Abah, Aidil, Syahira and Safuraa; who are here today to witness this small achievement of mine. And for Arif, Zaim and Imah; I wish you were here. And these most wonderful people on earth; Anas, Leman, Rast, Din, Syazwan, Yasser and Didier. And finally, kudos to whatever enigmatic forces that lead me to my love, my light. iv ACKNOWLEDGEMENT First and foremost, I would like to take this opportunity to express my deepest grateful appreciation to all who have continuously giving me support, advices and contribution towards the successful completion of this project. I would like to thank my supervisor, Encik Zuraimi Bin Yahya, who has provided invaluable guidance and assistance in the completion of this project. He has provided numerous ideas and constructive suggestions on developing this project. I would also like to thank my beloved family members who have given me indefinite moral and spiritual encouragement throughout my academic endeavors. Finally, I dedicate my sincere appreciation to Anas Fathi Bin Mohd Yusuff; a great friend and mentor who has given me a lot of ideas and driven me beyond my limits and boundaries for this project to succeed, my significant other for her outstanding and undivided support, all my friends and those who had involved directly or indirectly towards the completion of this project. This dissertation will not be successful without the assistance and support given by above people. v ABSTRACT Imagine a life where you are being able to control every system and appliance in your home in much the same way you can control television from the remote control, not just from your couch but from every room in your house and even remotely via the Internet and Intranet. That's the promise of home automation. Though it sounds futuristic, home automation technology has been kicking around for decades. The concept of home automation is to connect all the devices inside a Smart House so that they can be controlled and monitored from anywhere and react to one another. For example, from a remote computer, your home automation system can monitor room temperatures and light the bedrooms. To make this happen, we need a network to tie it all together. One of the critical components of a home automation system is the software interface that lets us control the system from any personal computer, at home, in the office, or on the road. The SmartHouse System software has been developed using Microsoft Windows operating system and Microsoft Visual Basic 6.0 as a project workspace and compiler language and Internet Information Services 5.1 (IIS) as a web server. Based on the results, this software enables the readings from the devices inside of a Smart House to be monitored and controlled via the Internet and Intranet. The software will also capable to trigger an alert system to notify users should any exceptional situation occurs. While this project is conducted by sending and retrieving simulation readings to and from a web server, few advance enhancements and modifications are needed to overcome several limitations and problems such as to make the software interacts directly to the home automation devices. vi ABSTRAK Bayangkan kehidupan di mana anda mampu mengawal sistem dan peralatan di dalam rumah anda sepertimana anda dapat mengawal televisyen menggunakan alat kawalan jauh, bukan sahaja dari sofa malahan dari setiap bilik di dalam rumah dan dari mana-mana tempat menerusi Internet dan Intranet. Itulah keupayaan home automation. Walaupun ia nampak futuristic, teknologi home automation sudah wujud sejak beberapa dekad yang lalu. Konsep kepada home automation adalah bagi menghubungkan setiap peralatan di dalam sebuah Smart House agar peralatan-peralatan tersebut dapat dikawal dan dipantau dari mana-mana tempat dan boleh bertindak balas antara satu sama lain. Sebagai contoh, dari sebuah komputer yang berjauhan, sistem home automation anda dapat memantau suhu bilik dan menghidupkan lampu bilik-bilik tidur. Untuk melaksanakan tugas-tugas ini, satu rangkaian diperlukan bagi menggabungkan kesemua sistem tadi. Satu daripada komponen kritikal bagi sebuah sistem home automation adalah perisian yang membolehkan kita mengawal sistem tersebut dari mana-mana komputer peribadi, di rumah, di dalam pejabat, atau ketika di atas jalanraya. Perisian SmartHouse System ini telah dibangunkan menggunakan sistem pengoperasian Microsoft Windows, Microsoft Visual Basic 6.0 sebagai tempat kerja projek dan bahasa pengkompil dan Internet Information Services 5.1 (IIS) sebagai pelayan web. Berdasarkan kepada hasil projek, perisian ini membolehkan bacaan-bacaan dari peralatan-peralatan di dalam sebuah Smart House dipantau dan dikawal melalui Internet dan Intranet. Ia juga mempunyai sistem penggera sekiranya berlaku bacaan yang tidak diingini. Projek ini dijalankan dengan menggunakan data-data simulasi dari pelayan web. Beberapa pengubahsuaian diperlukan untuk mengatasi beberapa kekurangannya seperti membolehkannya berhubung terus dengan peralatan-peralatan di dalam rumah tersebut. vii CONTENTS CHAPTER CHAPTER I ITEM PAGE TITLE PAGE i SELF ADMISSION ii DEDICATION iii ACKNOWLEDGEMENT iv ABSTRACT v ABSTRAK vi CONTENTS vii LIST OF TABLES xi LIST OF FIGURES xii LIST OF SYMBOLS xiv LIST OF APPENDICES xvi INTRODUCTION 1.1 Introduction 1 1.2 Problem Statement 2 1.3 Objectives 2 1.4 Scope 3 1.5 Project Application 3 1.6 Thesis Outline 4 viii CHAPTER II THEORY AND CONCEPT 2.1 Introduction 5 2.2 Home Automation 5 2.2.1 What is Home Automation? 5 2.2.2 The X-10 Standard 6 2.2.3 Home Automation Management Networks 7 2.3 Internet Information Services (IIS) 10 2.3.1 IIS Overview 11 2.3.2 The IIS Architecture 12 2.3.3 IIS Capacity Planning 13 2.3.3.1 Purpose or Type of Site 14 2.3.3.2 Complexity Level 14 2.3.3.3 Customer Base 14 2.3.3.4 Finding Potential Bottlenecks 14 2.3.3.5 To Determine Potential Bottlenecks 15 2.3.3.6 Network Bandwidth CHAPTER III 16 2.4 Active Server Pages (ASP) 18 2.5 ActiveX Data Object (ADO) 19 2.6 Microsoft Access 2003 20 2.7 Microsoft SQL Server 2000 23 SYSTEM DEVELOPMENT AND DESIGN METHODOLOGY 3.1 Introduction 26 3.2 System Development Model 26 3.3 System Requirements 27 ix 3.3.1 3.3.2 Hardware Requirements 27 3.3.1.1 Computer Specifications 28 Software Requirements 29 3.3.2.1 Microsoft Windows XP 29 3.3.2.2 Microsoft Visual Basic 6.0 29 3.3.2.3 Internet Information Services 5.1 31 3.3.2.4 Macromedia Dreamweaver MX 2004 32 3.3.2.5 Microsoft SQL Server 2000 and Microsoft Access 2003 3.4 3.5 33 System Architecture 35 3.4.1 Block Diagram 35 3.4.2 Flowchart 36 System Design Methodology 37 3.5.1 Graphic User Interface (GUI) 37 3.5.1.1 Forms 38 3.5.1.2 Modules 39 3.5.1.3 ActiveX Components 39 3.5.2 Web Server 40 3.5.2.1 Setting up Root Folder 40 3.5.2.2 Database File Permissions 41 3.5.2.3 Setting up Duplicate Anonymous Accounts on Separate Servers 3.5.3 Data Access 42 45 3.5.3.1 Connection String for Microsoft Access 46 3.5.3.2 Connection String for Microsoft SQL Server 49 x CHAPTER IV RESULTS 4.1 Introduction 52 4.2 Software Testing Checklist 52 4.3 Features and Functions 53 4.3.1 Login 53 4.3.3 Main Window 55 4.3.3 Alert Window 59 4.3.4 System Tray Icon 61 4.4 CHAPTER V Project Achievements 62 CONCLUSION 5.1 Conclusion 64 5.2 Problems and Limitations 65 5.4 Recommendations 66 REFERENCES 68 APPENDIX A 69 APPENDIX B 70 APPENDIX C 71 xi LIST OF TABLES TABLE NO. TITLE PAGE 2.1 Type of Management Networks for a Smart House 8 2.2 Traffic Generated by a Request for a 5 KB Page 17 2.3 Relative Network Interface Speed 18 3.1 Drivers for Microsoft Access and Microsoft SQL Server 45 xii LIST OF FIGURES FIGURE NO. TITLE PAGE 2.1 Harmony Gold 5.1 Screenshot 9 3.1 Incremental Model 27 3.2 Visual Basic 6.0 screenshot 30 3.3 IIS screenshot 32 3.4 Macromedia Dreamweaver MX 2004 screenshot 33 3.5 Connection via IIS Block Diagram 35 3.6 Connection via Live web server Block Diagram 35 3.7 The SmartHouse System flowchart 36 3.8 Software Design Modules 37 3.9 Root Folder for the SmartHouse System 41 3.10 Custom Connection String Dialog Box 46 3.11 Database tables list in Microsoft Access 47 3.12 Login table in Microsoft Access 48 3.13 LivingRoom table in Microsoft Access 48 3.14 Database tables list in Microsoft SQL Server 50 3.15 Login table in Microsoft SQL Server 50 3.16 LivingRoom table in Microsoft SQL Server 51 4.1 The Login Window 54 4.2 The Main Window upon Successful Login 54 4.3 The Login Window upon Unsuccessful Login 55 4.4 The Overview Tab 56 xiii 4.5 The First Floor Tab 57 4.6 The Preferences Tab 58 4.7 The Alert Window 60 4.8 The Alert Log file 60 4.9 System Tray Icon in Offline State 61 4.10 System Tray Icon in Online State 62 4.11 System Tray Icon pop up menu 62 xiv LIST OF SYMBOLS ADO - ActiveX Data Object API - Application Program Interface ASP - Microsoft Active Server Pages CGI - Common Gateway Interface COM - Component Object Model DAO - Data Access Object DNA - Distributed Internet Architecture FTP - File Transfer Protocol GB - Giga Bytes Gbps - Giga bits per second GHz - Giga Hertz GUI - Graphic User Interface HTML - Hypertext Mark-up Language HTTP - Hypertext Transfer Protocol IIS - Internet Information Services ISAPI - Internet Server Application Program Interface KB - Kilo Bytes Kbps - Kilo bits per second MB - Mega Bytes Mbps - Mega bits per second MHz - Mega Hertz MTS - Microsoft Transaction Services NNTP - Network News Transfer Protocol xv NTFS - NT File System ODBC - Open Database Connectivity OLE DB - Object Linking and Embedding Database OO - Object-Oriented PC - Personal Computer PDA - Personal Digital Assistant RF - Radio Frequency SMTP - Simple Mail Transfer Protocol SQL - Structured Query Language TV - Television Win32 - Windows 32-bit XML - Extensible Mark-up Language xvi LIST OF APPENDICES APPENDIX TITLE A Example Source Code for Connection to Local and PAGE Remote SQL Server Database Using Active Server Pages 69 B Example Source Code for Connection to Remote Access Database Using Active Server Pages C 70 Example Source Code for Connection to Local Access Database Using Active Server Pages 71 CHAPTER I INTRODUCTION 1.1 Introduction Remember what television was like before the remote control? Neither do I, but I am guessing it was no fun. The ability to control your television or even your entire home theater while lying on the couch has become a way of life. Now imagine being able to control every system and appliance in your home in much the same way, not just from your couch but from every room in your house and even remotely via the Internet and Intranet. That's the promise of home automation. Though it sounds futuristic, home automation technology has been kicking around for decades. Products based on the X-10 technology - still the most widely used because it is cheap and piggybacks on a home's existing power lines - first hit shelves at RadioShack and Sears in 1978. For much of that time, however, home automation has been for hobbyists willing to spend hours fiddling with phase couplers and noise filters just to, say, dim a light at a particular time. That's now changing. Broadband Internet access, home networks, more sophisticated computer and consumer electronics products, and the digitization of entertainment all are sparking new interest in ways to tie together all of the systems 2 within your home and make life more convenient and enjoyable. Not surprisingly, new technologies with names such as Insteon, Zigbee, and Z-Wave are coming out of the woodwork and vying to supplant X-10 and break this market open. 1.2 Problem Statement The concept of home automation is to connect all the devices inside a Smart House so that they can be controlled and monitored from anywhere and react to one another. For example, from a remote computer, your home automation system can monitor room temperatures, check the front windows and enable the alarm, and light the bedrooms. To make this happen, we need a network to tie it all together. One of the critical components of a home automation system is the software interface that lets us control the system from any personal computer (PC), at home, in the office, or on the road. 1.3 Objective The objective of this project is to develop a software that will enable the readings from the devices inside of a Smart House to be monitored and controlled via the Internet and Intranet. The software will run under the Microsoft Windows environment. The software will also capable to trigger an alert system to notify users should any exceptional situation occurs. 3 1.4 Scope The scope has been focused for client-side use. Because there is no actual device present, simulation data will be sent and retrieved to and from a web server instead of sending specific commands to the devices. The inputs are retrieved from a database on the web server while the outputs are sent to a database on the web server. The software is developed with the assumption that the home automation devices have the capability to send and retrieve their readings to and from a web server. 1.5 Project Application This project is developed as a control system for a Smart House so that it can be monitored and controlled whether locally from inside the Smart House via Intranet or from remote locations over the Internet. While this project in conducted by sending and receiving simulation readings to and from the web server, a few modifications should enable the software to interact directly to the actual home automation devices by sending and receiving commands instead. 4 1.6 Thesis Outline This thesis contains five major chapters. This chapter gives general overview to the entire project. It explains the synopsis of the project. It discusses more on the objective, scope and the application of the project. Chapter Two will describe all techniques, the theory and concepts behind home automation or a Smart House System and developing this software as a web application. All requirements and preliminary design details will be explained in this chapter. The preliminary design includes the concept of a Smart House, the current standard, the management networks, web server, and its connection to the database. However, only theoretical part will be discuss in this chapter. The practical design will be discuss later in Chapter Three. In Chapter Three, all the specification that has been listed in Chapter Two will be applied on the coding and actual system design. System design methodology will be discussed and explained in this chapter. These include all supporting softwares. Explanation on Graphic User Interface (GUI) design and implementation and the connection to the database will also be discussed. Chapter Four will reveal the results that have been acquired upon the completion of the project. All result and explanation regarding the software will be discussed. In this chapter, the software’s functions and the database connection will be tested. The last chapter, Chapter Five will be the conclusion to the project, problem faced and solution, limitations, and recommendations for the system’s future directions. CHAPTER II THEORY AND CONCEPT 2.1 Introduction This chapter will discuss the theory and concepts behind home automation or a Smart House System and developing this software as a web application. In this project, I am trying to determine the basic functions of home control, where a multitude of devices must have a centralized control system for them to be monitored and controlled. My focus has been on designing a software interface and its architecture for a Smart House. 2.2 Home Automation 2.2.1 What is Home Automation? Home automation is basically exactly what is says; automating your home. Home automation is the process of being able to control features of the house from remote locations. It can include the control of: 6 • lights • security system • heating control • audio-visual control • convenience features (such as camera monitoring of the front door, drape control, and detection of the mailbox being opened) 2.2.2 The X-10 Standard The current standard is called X-10, patented by the X-10 company. The X-10 system works as follows: • Each house has a house code: A-H. • Each device within the house has a code: 1-16. • All commands are broadcast through the power mains therefore requiring no additional wiring. • There are several commands, the basic ones being: on, off, dim, all off. • Appliances are generally plugged into modules that are X-10 compatible. These supply your electrical devices with power and accept X-10 commands. There are tens of different types of modules, ranging from light modules, appliance modules, wall switches, IR/X-10 translators and many more. Therefore, if you wished to control a light via X-10 commands, you would plug the light into a light module and the module into the mains. You would assign it an address (A1, for example). Now, when you sent the "a1 on" command down the power lines, the light would turn on. How can messages be sent? There are many different ways. Earlier methods used a simple control box that could be programmed to transmit various X-10 commands 7 down the power lines. Modern methods consist of either using a RF remote control (that interfaces with a radio receiver) or via your computer using special software. A detailed look at how X-10 signals are transmitted is beyond the scope of this introductory article, but basically an X-10 signal is sent at the zero-crossing (0o), 60o and 120o. This means there are 6 X-10 bits per cycle, and a standard X-10 signal takes around 11 cycles to complete. Each signal starts with a unique header of 1110, and then the signal is broadcast with every bit complemented. Each signal is also sent several times to make sure the receivers understand it over the "noise" of the power lines. 2.2.3 Home Automation Management Networks To make home automation works, you need a network to tie it all together. Wireless (Wi-Fi) networks are ideal for distributing data, voice and audio and video to different parts of the home. But they are overkill if you simply want to tell a lamp to turn itself on. Instead, most homes will have two different connected networks: one for accessing and distributing rich broadband content and one for managing all of the devices and systems in the home. These home-automation networks, by contrast, have low data rates (typically less than 200Kbps), are extremely inexpensive, use very little power, and can reliably controls hundreds and even thousands of devices. There are several different types of management networks as shown in Table 2.1. 8 Table 2.1: Type of Management Networks for a Smart House Type Description Uses your home's electrical wiring and outlets. Current applications Power line include lighting, appliances, and security. X-10 is a power-line technology. Think of this as a more sophisticated version of your RF TV remote. In Radio addition to traditional lighting, appliance, and security applications, these signals technologies can also control home entertainment and communications (wireless) systems. Many of the emerging technologies such as Zigbee and Z-Wave are based on RF. As with power line, homes already have telephone wiring and jacks in place. In theory, in addition to voice and data communications, this wire Phone lines can be used for entertainment networking and other applications, but practically speaking, there are few technologies or products currently available. The most reliable and robust option but really practical only when Structured wiring building a new home or conducting extensive renovations. Typical wiring systems include RG-6 (coaxial) wire for entertainment systems, Cat-5 wire for data and communications, as well as wiring for in-wall speakers and touch panels. The other critical component of a home automation system is the software interface. Rather than a single interface, most homes will have many different ways to access and control systems. Most include a software interface that lets you control the system from any PC, at home, in the office, or on the road. Many high-tech homes have wired or wireless touch screens that also let you perform the same tasks in any room, much the way you do with a universal remote. Emerging technologies will also let you control all of your home's systems from mobile devices such as a cell phone or PDA. 9 Figure 2.1 below is a screenshot from a commercial home automation software interface, Harmony Gold 5.1 released by simplyautomate.co.uk. Figure 2.1: Harmony Gold 5.1 Screenshot 10 2.3 Internet Information Services (IIS) Internet Information Services 5.1 (IIS) is the Microsoft Windows XP Web service that makes it easy to publish information on the Intranet. IIS brings the power of Web computing to Windows. With IIS, we can easily share files and printers, or we can create applications to securely publish information on the Web to improve the way the organization shares information. IIS is a secure platform for building and missioncritical applications to the Web. Using Windows XP Professional with IIS installed provides a personal and development operating system that allows us to: • Set up a personal Web server • Share information within the team • Access databases • Develop an enterprise intranet • Develop applications for the Web. IIS integrates proven Internet standards with Windows, so that using the Web does not mean having to start over and learn new ways to publish, manage, or develop content. 11 2.3.1 IIS Overview Visual Basic has arguably becoming the most popular language for developing Component Object Model (COM) components in the middle tier. While most programmers using C++ may have a hard time accepting this, even they cannot deny the fact that Visual Basic 6.0 offers higher levels of productivity than most other languages without sacrificing significant control over standard COM functionality. Because most middle-tier development today is Internet-based, Web developers are among the first to benefit from the productivity gains of Visual Basic. Web developers who take advantage of Visual Basic along with the Microsoft Windows DNA infrastructure are able to complete their Web-based solutions in record time. This fast pace, however, can often lead to solutions that are less than optimal because developers are taking less time to understand the middle-tier infrastructure. Web developers must rely on several pieces of middle-tier infrastructure, including Microsoft Internet Information Services (IIS) and Microsoft Transaction Services (MTS), to create highly scalable Web applications. Although MTS has captured the spotlight in the middle tier, Web developers must understand the IIS architecture and, more importantly, the relationship between IIS and MTS to create optimal solutions. 12 2.3.2 The IIS Architecture First and foremost, IIS is a protocol server. It is implemented as a set of several system services that use the most common Internet protocols including Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), Network News Transfer Protocol (NNTP), and the Simple Mail Transfer Protocol (SMTP). As we know, HTTP has become the ubiquitous protocol used in today's Web applications. IIS also offers standard Application Program Interface (APIs) for extending and customizing the server's capabilities. These APIs are known as the Common Gateway Interface (CGI) and the Internet Server API (ISAPI). CGI is almost never used in IIS applications because it requires a new Win32 process for each HTTP request. Win32 process creation and destruction is relatively expensive, so this approach doesn't scale well in high-volume Web sites. The ISAPI model was introduced to step in where CGI failed. ISAPI is based on the Win32 DLL architecture. Instead of loading a new process for each request, IIS loads an ISAPI-compliant DLL into its process and calls a well-known entry point to satisfy the HTTP request. Once the ISAPI DLL is loaded, it remains loaded until the IIS process is torn down. Hence, a single ISAPI DLL can satisfy all HTTP requests without any operating system overhead. The downside to ISAPI is that it's difficult to implement correctly. If we're developing for ISAPI we obviously have to use a language capable of creating ISAPIcompliant DLLs. While this is not directly possible from Visual Basic, creative programmers have developed mapping layers that allow Visual Basic code to participate 13 in the ISAPI architecture. Nevertheless, most ISAPI developers stay with languages like C or C++ for better performance (no mapping layer) and more control over thread safety. Because Microsoft didn't want to force Web developers to use these complex APIs directly, they introduced Active Server Pages (ASP) as a higher-productivity alternative. ASP is completely based on the ISAPI architecture. In fact, ASP is implemented as a system ISAPI DLL (asp.dll, also referred to as the ASP runtime). When a request for an ASP page comes in, IIS makes sure that the ASP runtime is loaded and uses it to process the page. ASP pages can contain both HTML and script from any scripting language that supports the ActiveX scripting interfaces, such as VBScript. Any HTML found in an ASP page is simply buffered back to the HTTP response. Script, however, is just-in-time compiled and executed using the appropriate scripting language engine. Because developers using Visual Basic can implement code for the ISAPI architecture with a familiar language like VBScript, ASP offers the best solution for high productivity and exceptional performance. 2.3.3 IIS Capacity Planning Capacity planning for a web server installation involves determining the current and future needs of the installation, then choosing hardware and software that can meet current estimated needs, but that can also be expanded or upgraded to meet new needs as they arise. Because there are so many variables and because needs change so rapidly, capacity planning is more of an art than a science and typically requires an iterative approach. This chapter is intended primarily for people who decide what equipment and software to acquire for Web sites, and for site administrators. It explains some aspects of 14 Web server capacity, provides ways to determine where bottlenecks are likely to occur, and shows how much network bandwidth we will need. 2.3.3.1 Purpose or Type of Site First, decide whether the site will be transactional; that is, determine whether customers will be retrieving and storing information, typically in a database. A transactional site involves both reliability and security requirements that do not apply to most non-transactional sites. 2.3.3.2 Complexity Level Next, consider whether the content on the site will be static. A site that makes use of SQL, ASP, ISAPI, CGI, or multimedia requires much more processing capability than a static site. 2.3.3.3 Customer Base Consider the size of the customer base and its potential for expansion, on at least the following time scales: • Current to one month • Six months • One year 2.3.3.4 Finding Potential Bottlenecks Find out what is likely to break first. Unless the site is extremely small, we'll need a test lab to determine that. 15 2.3.3.5 To Determine Potential Bottlenecks 1. Draw a block diagram showing all paths into the site. Include, for example, links to FTP download sites as well as other URLs. 2. Determine what machine hosts each functional component (database, mail, FTP, and so on). 3. Draw a network model of the site and the connections to its environment. Define the topography throughout. Identify slow links. For each page, create a user profile that answers the following questions: • How long does the user stay on the page? • What data gets passed to (or by) the page? • How much database activity (or other activity) does the page generate? • What objects live on each page? How system-friendly are they? (That is, how heavily do they load the system's resources? If they fail, do they do so without crashing other objects or applications?) • What is the threading model of each object? 4. Define which objects are server-side and which are client-side. 5. Build a lab. We'll need at least two computers, because if we run all the pieces of WCAT on one computer, the results will be skewed by WCAT's own use of system resources. Monitor the performance counters at 1-second intervals. When ASP service fails it does so abruptly, and an interval of 10 or 15 seconds is likely to be too long-we'll miss the crucial action. Relevant counters include CPU utilization, Pool non-paged bytes, connections/sec, and so on. 16 Throw traffic at each object, or at a simple page that calls the object, until the object or the server fails. Look for: • Memory leaks (steady decrease in pool non-paged bytes and pool paged bytes). • Stop errors and Dr. Watsons. • Inetinfo failures and failures recorded in the Windows® Event Log. 6. Increase the loading until we observe a failure; document both the failure itself and the maximum number of connections per second we achieve before the system tips over and fail. 7. Go back to the logical block diagram, and under each block fill in the amount of time and resources each object uses. This tells us which object is most likely to limit the site, presuming we know how heavily each one will actually be used by clients. Change the limiting object to make it more efficient if we can, unless it is seldom used and well off the main path. 8. Next, traceroute among all points on the network. Clearly, we can't traceroute the entire Internet; but we can certainly examine a reasonable number of paths between our clients and our server(s). If we are operating only on an intranet, traceroute from our desk to the server. This gives us a ballpark estimate of the routing latencies, which add to the resolution time of each page. Based on this information, we can set our ASP queue and Open Database Connectivity (ODBC) timeouts. 2.3.3.6 Network Bandwidth Once we determine how many customers/clients we want to serve during a given time period, we have the lower limit for our network connection bandwidth. We need to accommodate both normal load and usage spikes; we can average these to get a reasonable estimation of network capacity. 17 Of course, the type of site we operate has a large effect on this issue. For example, if we are largely or entirely subscriber-based, or if our site is only on an intranet or an intranet/extranet combination, we probably already have a good idea of the maximum spike size. If, on the other hand, we issue software revisions to an audience of unknown size on the Web, there may not be a good way to predict the size of resulting spikes. We might, in fact, have to measure one or more actual occurrences to decide whether our bandwidth is sufficient. Table 2.2 shows the traffic generated by a request for a 5 KB page and Table 2.3 shows the relative network interface speed. Table 2.2: Traffic Generated by a Request for a 5 KB Page Traffic Type Bytes Sent TCP Connection 180 (approx.) GET Request 256 (approx.) 5-KB file 5,120 Protocol overhead 1,364 (approx.) Total 6,920 18 Table 2.3: Relative Network Interface Speed Connection Type Connection Speed 5-KB Pages Sent per Second Dedicated PPP/SLIP via modem 28.8 Kbps Roughly half of 1 page Frame Relay or fast modem 56 Kbps Almost 1 page ISDN 128 Kbps Just over 2 pages Typical DSL 640 Kbps Almost 11 pages DS1/T1 1.536 Mbps 26 pages 10-Mb Ethernet 8 Mbps (best case) (Up to) 136 pages DS3/T3 44.736 Mbps 760 pages OC1 51.844 Mbps 880 pages 100-Mb Ethernet 80 Mbps (best case) (Up to) 1,360 pages OC3 155.532 Mbps 2,650 pages OC12 622.128 Mbps 10,580 pages 1-Gbps Ethernet 800 Mbps (best case) (Up to) 13,600 pages 2.4 Active Server Pages (ASP) Microsoft Active Server Pages (ASP) is a server-side scripting environment that we can use to create interactive Web pages and build powerful Web applications. When the server receives a request for an ASP file, it processes server-side scripts contained in the file to build the Web page that is sent to the browser. An Active Server Page (ASP) is an HTML page that includes one or more scripts (small embedded programs) that are processed on a Microsoft Web server before the 19 page is sent to the user. An ASP is somewhat similar to a server-side include or a Common Gateway Interface (CGI) application in that all involve programs that run on the server, usually tailoring a page for the user. Typically, the script in the Web page at the server uses input received as the result of the user's request for the page to access data from a database and then builds or customizes the page on the fly before sending it to the requestor. ASP is a feature of the IIS, but since the server-side script is just building a regular HTML page, it can be delivered to almost any browser. We can create an ASP file by including a script written in VBScript or JScript in an HTML file or by using ActiveX Data Objects (ADO) program statements in the HTML file. We name the HTML file with the ".asp" file suffix. Microsoft recommends the use of the server-side ASP rather than a client-side script, where there is actually a choice, because the serverside script will result in an easily displayable HTML page. Client-side scripts (for example, with JavaScript) may not work as intended on older browsers. 2.5 ActiveX Data Object (ADO) ActiveX Data Objects (ADO) is an Application Program Interface (API) from Microsoft that lets a programmer writing Windows applications get access to a relational or non-relational database from both Microsoft and other database providers. For example, if we wanted to write a program that would provide users of our Web site with data from an IBM DB2 database or an Oracle database, we could include ADO program statements in an HTML file that we then identified as an Active Server Page. Then, when a user requested the page from the Web site, the page sent back would include appropriate data from a database, obtained using ADO code. Like Microsoft's other system interfaces, ADO is an object-oriented programming interface. It is also part of an overall data access strategy from Microsoft 20 called Universal Data Access. Microsoft says that rather than trying to build a universal database as IBM and Oracle have suggested, finding a way to provide universal access to various kinds of existing and future databases is a more practical solution. In order for this to work, Microsoft and other database companies provide a "bridge" program between the database and Microsoft's OLE DB, the low-level interface to databases. OLE DB is the underlying system service that a programmer using ADO is actually using. A feature of ADO, Remote Data Service, supports "data-aware" ActiveX controls in Web pages and efficient client-side caches. As part of ActiveX, ADO is also part of Microsoft's overall Component Object Model (COM), its component-oriented framework for putting programs together. 2.6 Microsoft Access 2003 Access 2003 provides a powerful set of tools that are sophisticated enough for professional developers, yet easy to learn for new users. Create or use powerful database solutions that make organizing, accessing, and sharing information easier than ever. Microsoft Access is a relational database management system from Microsoft, packaged with Microsoft Office Professional which combines the relational Microsoft Jet Database Engine with a graphical user interface. It can use data stored in Access/Jet, SQL Server, Oracle, or any ODBC-compliant data container. Skilled software developers and data architects use it to develop powerful, complex application software. Relatively unskilled programmers and non-programmer "power users" can use it to build simple applications without having to deal with features they don't understand. It supports substantial object-oriented (OO) techniques but falls short of being a fully OO development tool. 21 Microsoft Access was also the name of a communications program from Microsoft, meant to compete with ProComm and other programs. It proved a failure and was dropped. Years later they reused the name for their database software. Access is widely used by small businesses and hobby programmers to create ad hoc customized systems for handling small tasks. Its ease of use and powerful design tools give the nonprofessional programmer a lot of power for little effort. However, this ease of use can be misleading. This sort of developer is often an office worker with little or no training in application or data design. Because Access makes it possible even for such developers to create usable systems, many are misled into thinking that the tool itself is limited to such applications. Some professional application developers use Access for rapid application development, especially for the creation of prototypes and standalone applications that serve as tools for on-the-road salesmen. Access does not scale well if data access is via a network, so applications that are used by more than a handful of people tend to rely on a Client-Server based solution such as Oracle, DB2, Microsoft SQL Server, or MySQL. However, an Access "front end" (the forms, reports, queries and VB code) can be used against a host of database backend, including Access itself, SQL Server, Oracle, and any other ODBC-compliant product. This approach allows the developer to move a matured application's data to a more powerful server without sacrificing the development already in place. Access' cut and paste functionality can make it a useful tool for connecting between other databases (for example, Oracle and Microsoft SQL Server during data or database conversions). Access comes with various import and export features that allow integration with Windows and other platform applications, several of which can be executed on demand from within applications or manually by the user. The programming language available in Access is, as in other products of the Microsoft Office suite, Microsoft Visual Basic for Applications. Two database access 22 libraries of COM components are provided: the legacy Data Access Objects (DAO), only available with Access, and the new ActiveX Data Objects (ADO). Microsoft Access is easily applied to small projects but scales inefficiently to large projects if applications are designed poorly. All database queries, forms, and reports are stored in the database, and in keeping with the ideals of the relational model, there is no possibility of making a physically structured hierarchy with them. One design technique is to divide an Access application between data and programs. One database should contain only tables and relationships, while another would have all programs, forms, reports and queries, and links to the first database tables. Unfortunately, Access allows no relative paths when linking, so the development environment should have the same path as the production environment. This technique also allows the developer to divide the application among different files, so some structure is possible. In Microsoft Access 2003, we can view information on dependencies between database objects. Viewing a list of objects that use a specific object helps maintain a database over time and avoid errors related to missing record sources. For example, the Quarterly Orders query in the Sales database is no longer needed, but before deleting it, we might want to find out which other objects in the database use the query. Then, we could either change the record source of the dependent objects, or delete them, before deleting the Quarterly Orders query. Viewing a complete list of dependent objects helps us save time and minimize errors. In addition to viewing the list of objects that are bound to a selected object, we can also view the objects that are being used by the selected object. Macros, modules, and data access pages are not searched for dependencies. Access projects do not support this feature. 23 2.7 Microsoft SQL Server 2000 Quite a few of us are familiar with Access, and you may have even developed database applications with Access. However, Access is a desktop database. It can't be scaled up, and it can't accommodate many simultaneous users. To develop real database applications, we should move to SQL Server. It's highly scalable and we can use it to develop applications for everything from small networks to thousands of users. Until recently, Microsoft was pushing Access databases with Visual Basic. Now VB6 comes with all the drivers and tools we need to access SQL Server databases and the next version of VB will probably rely heavily on SQL Server. So, this is an excellent time to move up to SQL Server. The current version of SQL Server (version 7) runs under Windows 98 and can be easily deployed in a small network. There are two ways to use SQL Server: as a powerful substitute for Access or as a powerful DBMS (which is what SQL Server is). We can write an application that works with Access, then change its connection to the same database on SQL Server, and the application will work. I know some programmers who upsized their Access database to SQL Server and then changed their DAO-based VB code to work with SQL Server. By the way, converting an application based on DAO to work with ADO is not trivial, but if we write applications based on ADO, we can manipulate Access and SQL Server databases with nearly the same code. 24 Microsoft SQL Server 2000 features include: • Internet Integration. The SQL Server 2000 database engine includes integrated XML support. It also has the scalability, availability, and security features required to operate as the data storage component of the largest Web sites. The SQL Server 2000 programming model is integrated with the Windows DNA architecture for developing Web applications, and SQL Server 2000 supports features such as English Query and the Microsoft Search Service to incorporate user-friendly queries and powerful search capabilities in Web applications. • Scalability and Availability. The same database engine can be used across platforms ranging from laptop computers running Microsoft Windows 98 through large, multiprocessor servers running Microsoft Windows 2000 Data Center Edition. SQL Server 2000 Enterprise Edition supports features such as federated servers, indexed views, and large memory support that allow it to scale to the performance levels required by the largest Web sites. • Enterprise-Level Database Features. The SQL Server 2000 relational database engine supports the features required to support demanding data processing environments. The database engine protects data integrity while minimizing the overhead of managing thousands of users concurrently modifying the database. SQL Server 2000 distributed queries allow us to reference data from multiple sources as if it were a part of a SQL Server 2000 database, while at the same time, the distributed transaction support protects the integrity of any updates of the distributed data. Replication allows us to also maintain multiple copies of data, while ensuring that the separate copies remain synchronized. We can replicate a set of data to multiple, mobile, 25 disconnected users, have them work autonomously, and then merge their modifications back to the publisher. • Ease of installation, deployment, and use. SQL Server 2000 includes a set of administrative and development tools that improve upon the process of installing, deploying, managing, and using SQL Server across several sites. SQL Server 2000 also supports a standards-based programming model integrated with the Windows DNA, making the use of SQL Server databases and data warehouses a seamless part of building powerful and scalable systems. These features allow us to rapidly deliver SQL Server applications that customers can implement with a minimum of installation and administrative overhead. • Data warehousing. SQL Server 2000 includes tools for extracting and analyzing summary data for online analytical processing. SQL Server also includes tools for visually designing databases and analyzing data using English-based questions. CHAPTER III SYSTEM DEVELOPMENT AND DESIGN METHODOLOGY 3.1 Introduction This chapter will discuss about the system requirements and design specifications in details. Before the design stage was started, all system requirements had been analyzed to ensure it does not stray away from the objectives. After the design stage had finished, it had been tested to prove the correctness and efficiency. In this chapter, the design methodology used in developing this software will also be discussed. 3.2 System Development Model The Incremental Model (see Figure 3.1) is implemented in developing the project. This model is used because it is most suitable and accurate in producing the software. It consists of seven stages which are as follows: 1st stage : Define outline requirements. 2nd stage : Assign requirements to increments. 3rd stage : Design system architecture. 27 4th stage : Develop system increment. 5th stage : Validate increment. 6th stage : Integrate increment. 7th stage : Validate system. Figure 3.1: Incremental Model 3.3 System Requirements Generally, there are two major system requirements needed before I could proceed with the system design. It is divided into two categories - software and hardware. Every requirement in each part is discussed in this subtopic. 3.3.1 Hardware Requirements This subtopic will discuss the hardware required when developing the system. 28 3.3.1.1 Computer Specifications This system has been designed on a computer with the following specifications: • AMD Sempron (1.66 GHz) processor • 512 MB RAM • 32 MB Graphic memory • 32 bit NTFS file system • NVIDIA nForce MCP Network Adapter • 120 GB hard drive This system requires at least the following requirements to be best functional. • 1.0 GHz of processor • 256 M of RAM • 30 MB of hard drive space • 32 bit NTFS file system • 10/100 Mbps Network Adapter In the actual system, a live web server – a server connected to the Internet - must be attached for it to function via the Internet. However, in this project I have set up my own computer as a web server by using the Internet Information Services (IIS) 5.1. Therefore, the system development and testing process have been carried out via Intranet. 29 3.3.2 Software Requirements This subtopic will discuss the software required when developing the system. 3.3.2.1 Microsoft Windows XP In this project, the software is built on a Windows XP Professional platform as the operating system. The advantages of Windows are that it is user friendly to all kind of user and has been the most popular operating system in the market. 3.3.2.2 Microsoft Visual Basic 6.0 The Microsoft Visual Basic 6.0 (see Figure 3.2) is used to create the Graphic User Interface (GUI) for the software. The Visual Basic programming language has been used in coding the software engine because it is compatible with the GUI and the library used in the software. The Visual Basic 6.0 is released by Microsoft Corporation and support a 32-bit application in most Microsoft operating system such as Windows 98, Windows 2000, and Windows XP. It allows the programmer to create a basic window function independently. The other reference software used is the Microsoft Studio Network (MSDN) Library Visual Studio 6.0. The MSDN Library is an essential resource for developers using Microsoft tools, products and technologies. It contains a bounty of technical programming information including sample code, documentation, technical articles and reference guides. 30 Visual Basic language has evolved from the original BASIC language and now contains several hundred statements, functions and keywords, many of which relate directly to the Windows GUI. It is a high level programming language developed by Microsoft Visual Studio with a rich toolset of rapid application development features. Beginners can create useful applications by learning just a few of the keywords, yet the power of the language allows professionals to accomplish anything that can be accomplished using any other Windows programming language. Figure 3.2: Visual Basic 6.0 screenshot 31 3.3.2.3 Internet Information Services (IIS) 5.1 Internet Information Services 5.1 (IIS) (see Figure 3.3) is used as a web server for the software to run. IIS is the Microsoft Windows XP Web service that makes it easy to publish information on the Intranet. IIS brings the power of Web computing to Windows. With IIS, we can easily share files and printers, or we can create applications to securely publish information on the Web to improve the way our organization shares information. IIS is a secure platform for building and mission-critical applications to the Web. Using Windows XP Professional with IIS installed provides a personal and development operating system that allows us to: • Set up a personal Web server • Share information within our team • Access databases • Develop an enterprise Intranet • Develop applications for the Web. IIS integrates proven Internet standards with Windows, so that using the Web does not mean having to start over and learn new ways to publish, manage, or develop content. 32 Figure 3.3: IIS screenshot 3.3.2.4 Macromedia Dreamweaver MX 2004 Macromedia Dreamweaver MX 2004 as shown in Figure 3.4 is used to create ASP files. The ASP files contain SQL commands to read and store data from and to the database. Dreamweaver is a professional HTML editor for designing, coding, and developing web pages and web applications. Whether it is hand-coding HTML or work in a visual editing environment, Dreamweaver provides helpful tools to enhance web creation experience. 33 Dreamweaver also includes many coding-related tools and features. Dreamweaver helps build dynamic database-backed web applications using server languages such as ASP, ASP.NET and PHP. Figure 3.4: Macromedia Dreamweaver MX 2004 screenshot 3.3.2.5 Microsoft SQL Server 2000 and Microsoft Access 2003 Microsoft SQL Server 2000 is used as the primary storage for the simulation data. The SQL Server 2000 is used because its database engine includes integrated Extensible Markup Language (XML) support. It also has the scalability, availability, and security features required to operate as the data storage component of the largest Web 34 sites. The SQL Server 2000 programming model is integrated with the Windows DNA architecture for developing Web applications. However, to make the development process much easier, Access 2003 is also used to store the data. It is because the Access files are portable, making it easier to be handled during running tests on multiple computers. 35 3.4 System Architecture 3.4.1 Block Diagram Figure 3.5 depicts flow of processes for the SmartHouse System using connection via IIS as a web server. Request Web client (SmartHouse System) Request IIS with ASP application Response Request Data source (MS Access, MS SQL Server) Data access via ASP Response Response Figure 3.5: Connection via IIS Block Diagram Figure 3.6 depicts flow of processes for the SmartHouse System using connection via a live web server. Request Web client (SmartHouse System) Data access via ASP Live web server Response Request Request Response Live web server data source Response Figure 3.6: Connection via Live web server Block Diagram 36 3.4.2 Flowchart User connects to web server SMARTHOUSE SYSTEM No Access denied No connection error? Yes No User authenticated? Yes Display the readings on selected room No connection error? Alert system Yes No No No Yes Check condition. Trigger alert? Popup alert window and write alert log file. Yes User interrupt? Keep connection Disconnect user Send request via web server Figure 3.7: The SmartHouse System flowchart 37 3.5 System Design Methodology The design had been divided into modules according to functions to be performed. Module division is important to facilitate in improving the software which is going to be done at the end point of the project besides implementing the object oriented programming. Web server Module (IIS) SmartHouse System (Web client) Data access Module (ASP files) Main GUI Module Figure 3.8: Software Design Modules The software structure is divided into 3 main modules which are GUI, web server and data access module. All three modules have its own unique function but are interdependent to each other in running the software. 3.5.1 Graphic User Interface (GUI) Graphic User Interface (GUI) is very important in software development because it is an interface between the user and the system. The GUI must be easy to understand, 38 user friendly, multifunction and has good error handlings. A flexible and attractive GUI will be an advantage to attract the user. In this project, the GUI is developed using Visual Basic 6.0. The VB project file uses some of VB ActiveX components and will call for several forms, modules and user controls. The following subtopics will reveal the function for each ActiveX components, forms, modules and user controls. 3.5.1.1 Forms Form frmAbout • This form will display information regarding the software such as the creator, version, disclaimer and contact info. Form frmAlert • This form uses a timer to check the readings (temperature and brightness) for every room in the Smart House and compares it with the maximum and minimum values set by user. Form frmLogin • User authentication and connecting to the web server is carried out on this form. User will enter the user ID and password; the system will connect to the web server and search for the user ID within its database and authenticates the password provided. If successful, access will be granted and the main window will be displayed. Form frmMain • This form represents the Main Window for the SmartHouse System. Detailed information regarding this form will be discussed in the next chapter under the Main Window subtopic. 39 Form frmSplash • This form will display a splash screen during the software’s startup. Form frmTray • This form will load the software into system tray during its startup. Functions such as to display the main window, hide the main window, view the alert window and setting up preferences are accessible from the system tray icon. 3.5.1.2 Modules Module GlobalVars • This module defines most of the software’s public declarations. Some of the public declarations are defined within respective forms. Module Module2 • This module defines the functions and library used to load the software into the system tray. Module SoundResource • This module defines the functions and library used to play sound for alerts and call for the sound resource from the sound.res file. Module Startup • This module defines the functions and library used to run the software automatically on Windows startup. 3.5.1.3 ActiveX Components These ActiveX Components need to be enabled when developing the software. • Microsoft ActiveX Data Objects 2.5 • Microsoft XML, v3.0 40 3.5.2 • Microsoft Internet Control • Microsoft Scripting Runtime Web Server IIS is used as the web server for the SmartHouse System software for it to run via Intranet. The followings are steps taken to set up the IIS for it to function correctly as the web server to the SmartHouse System software. 3.5.2.1 Setting Up Root Folder Once the IIS has been installed, it will create a root folder in c:\inetpub\wwwroot\ in which all the ASP files or other web application files have to be stored for it to run in IIS. For the SmartHouse System software, the default folder for the ASP files and applications has been set to c:\inetpub\wwwroot\smarthouse\ (see Figure 3.9). 41 Figure 3.9: Root Folder for the SmartHouse System 3.5.2.2 Database File Permissions To check or change the database file permissions: 1. Make sure we have administrator privileges on the computer. 2. In Windows Explorer, locate the database file or the folder containing the database, right-click the file or folder, and select Properties. 3. Select the Security tab. 4. If the IUSR_computername account is not listed in the Group or User Names list, click the Add button to add it. 5. In the Select Users or Groups dialog box, click the Advanced button. 6. The dialog box changes to show more options. 7. Click the Locations button and select the computer’s name. 8. Click the Find Now button. 42 9. A list of account names associated with the computer appears. 10. Select the IUSR_computername account and click OK; then click OK again to clear the dialog box. 11. To assign the IUSR account full permissions, select the Full Control checkbox and click OK. Also, give the folder containing the database share permission as shown in Figure 3.9. This step applies only if the file system is an NTFS file system. If it’s an FAT file system, the dialog box won't have a Security tab. For added security, permissions can be set so that Read permission is turned off for the web folder containing the database. Browsing the folder won’t be permitted, but web pages will still be able to access the database. The same permission settings should also be applied when accessing SQL Server database by granting login permission for the IUSR_computername account. It can be set using the Microsoft SQL Server Enterprise Manager. 3.5.2.3 Setting up Duplicate Anonymous Accounts on Separate Servers Active Server Pages (ASP) pages are often run under the security context of the Internet Guest Account (or, by default, the IUSR_<ComputerName> account). Within these ASP pages, when we reference files or databases on a computer other than the Web server, we must often duplicate this user (the Anonymous user account) on the remote computer. This is because, by default, the Internet Guest Account is a local computer account on the Web server and is not recognized by any other computer on the network. If we duplicate the Internet Guest Account on another computer, we can enable that remote computer to authenticate the account and allow access to resources on that computer. Before we can create a duplicate Anonymous account on a remote computer, we must first know the user name and password for the Anonymous account on the Web 43 server. The user name and password for the new Anonymous account on the remote computer must match the one for the Anonymous account on the Web server. By default, the adsutil.vbs file in Windows 2000 masks the Anonymous user password with asterisks. To obtain the password for the Anonymous account, first perform the following steps to modify the adsutil.vbs file so that it displays the unmasked password: 1. In Notepad, open the adsutil.vbs file (by default, this is located in the <Drive>:\Inetpub\AdminScripts\ folder). 2. With adsutil.vbs open in Notepad, on the Edit menu, click Find, and type the following string: IsSecureProperty = True and then click Find Next. 3. Change this string as follows: IsSecureProperty = False 4. Save the changes to Adsutil.vbs, and then close Notepad. After we modify the adsutil.vbs file, perform the following steps to obtain the Anonymous user name and password: 1. At a command prompt, browse to the following folder: C:\Inetpub\AdminScripts\ 2. At a command prompt, type the following command to obtain the Anonymous account user name for this Web site: cscript adsutil.vbs get w3svc/anonymoususername 3. At a command prompt, type the following command to obtain the password for the Anonymous account: cscript adsutil.vbs get w3svc/anonymoususerpass To create the duplicate account on the remote computer; 1. On the Start menu, point to Programs, point to Administrative Tools, and then 44 click Computer Management. If Administrative Tools is not listed in the Programs menu, we can open it from the Windows Control Panel as well. 2. Under Computer Management, click to expand the System Tools and Local Users and Groups nodes. 3. Click the Users folder to display the list of local user accounts. 4. On the Action menu, click New User. 5. In the User name text box, type the name of the Anonymous account that we obtained from the previous steps. 6. Type and confirm the same password that is used for the Anonymous account on the Web server. The Full Name and Description boxes are optional. 7. Clear the User must change password at next logon and Account is disabled check boxes. Select the User cannot change password and Password never expires check boxes. Click Close to add the new user. 8. To add the Anonymous account to the Guests group, click the Groups folder, double-click Guests, and click Add. To grant new anonymous account "Log on Locally" rights; 1. On the Start menu, point to Programs, point to Administrative Tools, and then click Local Security Policy 2. Under Security Settings, click to expand the Local Policies node, and then click User Rights Assignment. 3. In the right pane, under Policy, double-click Log on locally. 4. Click Add to display the Select Users or Groups dialog box. 5. In the Look in drop-down list box, click the local computer. 6. Click the new Anonymous account, click Add, and then click OK. Be sure to add the Anonymous account that we have just created and not the local Anonymous account for IIS 5.0 on this computer. 45 3.5.3 Data Access An ASP application must connect to a database through Open Database Connectivity (ODBC) driver or an Object Linking and Embedding Database (OLE DB) provider. The driver or provider acts as an interpreter that lets the web application communicate with the database. For more information on the role of database drivers, see Communicating with the database. The following table (Table 3.1) shows some drivers can be used with Microsoft Access and Microsoft SQL Server. Table 3.1: Drivers for Microsoft Access and Microsoft SQL Server Database Database driver Microsoft Access Microsoft Access Driver (ODBC) Microsoft Jet Provider for Access (OLE DB) Microsoft SQL Server Microsoft SQL Server Driver (ODBC) Microsoft SQL Server Provider (OLE DB) We can use a data source name (DSN) or a connection string to connect to the database. A DSN is a one-word identifier that points to the database and contains all the information needed to connect to it. We define a DSN in Windows. We can use a DSN if we’re connecting through an ODBC driver installed on a Windows system. 46 A connection string is a hand-coded expression that identifies the database and lists the information needed to connect to it. The following is an example: Driver=<SQL Server>; Server=Socrates; Database=AcmeMktg; UID=wiley; PWD=roadrunner I’m using a connection string to connect to the database from the ASP files. The connection string can be set by using the Custom Connection String dialog box (see Figure 3.10) in the Dreamweaver MX or simply by hand-coding it. Figure 3.10: Custom Connection String Dialog Box 3.5.3.1 Connection String for Microsoft Access Below is the connection string used to access the database tables (see Figure 3.11) for Microsoft Access. The Login table (see figure 3.12) contains information about user ID, password and user name while the other tables contains the temperature readings, brightness readings, number of persons and windows status for each room. Figure 3.13 is showing information stored in table LivingRoom. set cn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") set doc = server.CreateObject("MSXML2.DomDocument") 47 dbPath = "\\<servername>\databases\housestatus.mdb" rqs = Request.QueryString("ID") cn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" & dbPath Figure 3.11: Database tables list in Microsoft Access 48 Figure 3.12: Login table in Microsoft Access Figure 3.13: LivingRoom table in Microsoft Access 49 3.5.3.2 Connection String for Microsoft SQL Server Below is the connection string used to access the database tables (see Figure 3.14) for Microsoft SQL Server. The Login table (see figure 3.15) contains information about user ID, password and user name while the other tables contains the temperature readings, brightness readings, number of persons and windows status for each room. Figure 3.13 is showing information stored in table LivingRoom. set cn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") set doc = server.CreateObject("MSXML2.DomDocument") rqs = Request.QueryString("ID") cn.Open "Provider=SQLOLEDB; Data Source=<SERVERNAME>; Initial Catalog=SH Integrated Security= SSPI;" 50 Figure 3.14: Database tables list in Microsoft SQL Server Figure 3.15: Login table in Microsoft SQL Server 51 Figure 3.16: LivingRoom table in Microsoft SQL Server CHAPTER IV RESULTS 4.1 Introduction This chapter will discuss on the software testing, software development results and analysis on the software’s functions, features and capabilities. 4.2 Software Testing Checklist Before running the software, few items need to be checked for it to run and to connect correctly to the database on the web server. Here are few steps need to be taken before running the software. 1. Make sure the SmartHouse folder with ASP applications is in the root folder (default is c:\Inetpub\wwwroot\). 2. Make sure the Internet Guest Account (IUSR_computername) has been permission to access the files in that folder. 3. If not, click Add to add the account. Follow everything that has been mentioned in subtopic 3.5.2.2. 53 4. Open the IIS by clicking Control Panel Æ Administrative Tools Æ Internet Information Services. Find the SmartHouse folder under the tree list and right click it and the click Properties. On the Directory Security tab, click Edit. Make sure the Anonymous access in checked and using the IUSR_computername user name. If not, click Browse. 5. Now run the SmartHouse System software. Click the Preferences tab. Under the Connection panel, click the Other button and type “LocalPath” in the text box to test the software locally. 6. If the database is on a remote computer, follow the steps mentioned in subtopic 3.5.2.3 before we can use the Intranet via IIS connections. 4.3 Features and Functions This software consists of four main functions; the login function, the main function, the real-time alert function and the system tray. 4.3.1 Login In this project, user’s information such as the user ID, user name and password are stored in the login database. User will enter the user ID and password in the login window as shown in Figure 4.1; the system will connect to the web server and search for the user ID within its database and authenticates the password provided. If successful, access will be granted and the main window will be displayed (see Figure 4.2). Else if either the user ID is not found or the password provided is invalid or the connection to the server cannot be established, access will be not granted. An error description message will be displayed in the login window (see Figure 4.3). 54 Figure 4.1: The Login Window Figure 4.2: The Main Window upon Successful Login 55 Figure 4.3: The Login Window upon Unsuccessful Login 4.3.2 Main Window The main window consists of four tabbed-windows; Overview, First Floor, Second Floor and Preferences. The Overview tab as shown in Figure 4.4 displays the user status, the general status of the Smart House and checking whether the Real-time Alert is running or not. The menu on the right hand side of the window provide functionalities such as to connect to the server, viewing, turning on or turning off the Real-time Alert and opening the SmartHouse System website. 56 Figure 4.4: The Overview Tab The First Floor and the Second Floor tabs as shown in Figure 4.5 give user the capability to view the status for every room inside the SmartHouse in details. User can choose specific room to be viewed using the View panel by selecting the zone. When the View button is clicked, the Status view panel will display the status for the chosen room. The floor map will also highlight the selected room using the red box. Otherwise, new readings will be automatically updated during specific interval set by user. There are four types of status monitored by the system – room temperature in degree Celsius, room brightness in percentage, number of persons in the specified room and whether the windows for the room are opened or closed. For room that contains no window such as the garage, the door status will be displayed instead. The Control panel allows user to send a desired temperature and brightness value for the displayed room to the web server. 57 Figure 4.5: The First Floor Tab The Preferences tab (see Figure 4.6) provides user the capability to choose the type of connection, the refresh rate for new readings to be retrieved and displayed in the First Floor and Second Floor tab’s Status panel, setting the maximum and minimum value for specific readings to trigger the Alert Window and customizing the SmartHouse System with Windows environment. The Connection panel here is used for development purposes to test the system using different types of connection to the database. For user, it is meant as a function to customize the system according to the type of Internet connection the user has. The refresh rate determines how fast the request for new readings is sent to the web server. This setting will apply to the Status panel in both the First Floor and the Second Floor tabs. The faster the refresh rate is set to, the more frequent the request for new readings is sent to the web server. For slow Internet connection, it is advisable to use the default setting of 60 seconds data retrieval rate. 58 The Max/min settings panel will enable user to set the maximum and minimum values to trigger the Alert Window. For example, if the maximum value set for temperature readings in living room is 30 degree Celsius, any events where the temperature readings in that room goes above the maximum setting, the Alert Window will pop up to notify user about the condition. User must specify which floor the settings are going to be applied to. From there, user can choose whether to apply the settings to every room on the specified floor or to select a specific room from that floor to apply the settings to. The maximum and minimum values can be set for temperature and brightness readings. User can also customize the SmartHouse System settings with Windows environment by using the Windows options panel. It allows user to load the software on Windows startup, show the splash screen on load and play sound when an alert condition occurs. Figure 4.6: The Preferences Tab 59 4.3.3 Alert Window The Alert Window functions as real-time alert monitoring system for the SmartHouse System software. It will constantly receive new readings from the server and compares the values to the maximum and minimum values set by user. If the readings go above or below the maximum or minimum settings, the Alert Window as shown in Figure 4.7 will automatically pop up to notify user about the condition. Rooms which readings surpass the maximum or minimum settings will be marked with red symbol while rooms which readings are in good condition will be marked with green symbol. Upon receiving an alert condition, the Description box in the Alert Window will display the said condition along with which room the alert condition occurs. At the same time, the alert condition will be written into an Alert Log file (see Figure 4.8) which is accessible by clicking the View log button. User can choose whether to play or mute the alert sound whenever an alert condition occurs but the alert window will still popped up to notify user abut the condition. The Real-time Alert can be turned off by clicking the close button or from the Main Window. The SmartHouse System will then stop monitoring the readings for alert conditions. No notification will be popped up if the readings surpass the maximum or minimum settings but new readings will still be constantly retrieved and displayed in the Status panel in the Main Window. Alternatively, user can hide the Alert Window without stopping the Real-time Alert by clicking the minimize button. 60 Figure 4.7: The Alert Window Figure 4.8: The Alert Log file 61 4.3.4 System Tray Icon When the SmartHouse System software is loaded, a red colored house icon (see Figure 4.9) will appear in the system tray icon. The red icon indicates that the system is offline and not connected to the server. Thus, readings for the Smart House are not available yet until the user has connected to the server. By double-clicking on the icon or right-clicking it to pop up a menu, user can view the Main Window and connect to the web server from there. Once connected, the house icon color will turn blue (see Figure 4.10) to indicate that the system is connected to the server and readings from the Smart House are being monitored. User can also view the Alert Window and the Preferences tab by rightclicking the icon and clicking the link from the pop up menu (see Figure 4.11). The System Tray Icon enables user to hide the Main Window while still constantly monitoring the Smart House by clicking the Minimize button for it to run in the background. By double-clicking the System Tray Icon, the Main Window will reappear. Figure 4.9: System Tray Icon in Offline State 62 Figure 4.10: System Tray Icon in Online State Figure 4.11: System Tray Icon pop up menu 4.4 Project Achievements Generally, the main objective of the project has been successfully achieved. The objectives and the scopes mentioned at the beginning of the project are well accomplished although there are problems arisen in developing the software. The software development is successfully conducted using Microsoft Visual basic 6.0 as project workspace and compiler language. Internet Information Services (IIS) is used as the web server with Active Server Pages (ASP) application in it. As a result, the software can be used in Microsoft Windows operating system remotely via Internet or locally via Intranet. In addition, the GUI is created using the Visual Basic making the software interactive, user friendly and reliable. 63 In developing the software, object oriented programming technique is used where the system designs are divided into three different modules. This technique is applied so that the software enhancements and modifications can be made in the future. The SmartHouse System software is designed to enable the readings from the home automation devices inside of a Smart House to be monitored and controlled via the Internet and Intranet. The software also capable to trigger an alert system to notify users should any exceptional situation occurs. An Alert Log will be written upon said condition for user to use for future references. CHAPTER V CONCLUSION 5.1 Conclusion Based on explanations from Chapter I to Chapter IV, it can be concluded that this project has succeeded to achieve the early objectives. The SmartHouse System software will enable the readings from the home automation devices inside of a Smart House to be monitored and controlled via the Internet and Intranet. The software also capable to trigger an alert system to notify users should any exceptional situation occurs. An Alert Log will be written upon said condition for user to use for future references. The project gives me an opportunity in comprehending the design, the function and the vision of a Smart House. This knowledge is important when applying it for the software development process. New programming skills and techniques are also acquired when using Visual Basic for this software development. It also gives me an opportunity to understand the analysis technique and software design in actual environment. From the project, experiences are obtained from analysis and design phase which are important during software development process since through analysis and design phase, the software development progress can run smoothly. 65 5.2 Problems and Limitations Although the main objective for this project has been achieved, but there are some limitations to this software that needs to be addressed in future studies. One of its limitations involves data security. The data sent and received to and from the web sever do not use encryption and decryption algorithm. Because data transferred over the Internet are more often then not being exposed to unwanted intruders, the encryption of the data will reduce this probability from happening. Another limitation to the software is regarding reliability issue. The system is very much depending on how fast the network connection is. The faster the connection speed is, the more stable and reliable it becomes. Slow connections will cause the software to become unstable and becomes unreliable to respond to the software’s request to the web server. This is because the software will constantly sending request for new readings from the web server. If the connection is too slow, the software will experience a delay in retrieving, monitoring and displaying the readings in Smart House. The software uses only one default house layout which means modifications need to be done to the software when applying it to Smart Houses which are using different layout. The major limitation to this software is that it does not communicate directly to the home automation devices. A web server with database is needed as an interface between the SmartHouse System software and the home automation devices. Because there are no actual home automation devices present, it is very hard for me to pursue with this idea. 66 5.3 Recommendations Based on the limitations and problems stated in the previous subtopic, several recommendations have been proposed to overcome the limitations and to enhance the system’s efficiency for its future directions. Data encryption and decryption are an essential part when building a web application such as the SmartHouse System software. I’m suggesting it to be implemented whenever the software is sending or receiving new readings from the server. This way it will help reduce the probability of the information sent and received being trespassed by unwanted intruders. A different kind of method to send request for new readings can be implemented on the software by doing few modifications to its connection settings. All the timers used in Visual Basic 6 needs to be synchronized accordingly for the software to run smoothly and reliably. An option for users and developers to choose or even upload their own house layout can also be implemented on the software’s functions. This way, every time a new user wants to use this software for his Smart House layout, he can just choose the layout according to his house or even designate of what to be monitored in which room. Enhancing the software’s ability so that it can communicate directly with the home automation devices could become a major breakthrough, in this country at least. Although a web server with database remains an integral part for the whole SmartHouse System so that all the readings will have a place to be stored and for documentation purposes in the future, the ability to send commands directly to the devices will help greatly in improving 67 the real-time factor. New readings can be retrieved faster with smaller delays and the software can become more reliable. It would also making it possible for new features, such as sending voice commands or setting timer for devices for it to be turned on or off at certain specific times, to be added. 68 REFERENCES 1. Petroutsos, E. Mastering Database Programming With Visual Basic 6.0. Aladema, CA: Sybex. 2000. 2. Hartmann, P. Teach Yourself Visual Basic 6. New York, NY: Wiley Publishing. 2000. 3. Zahariadis, T. B. Home Networking Technologies and Standards. Norwood, MA: Artech House Inc. 2003. 4. Leonik, T. E. Home Automation Basics. Indianapolis, IN: Sams Technical Publishing. 2000. 5. Halvorson, M. (1998). Microsoft Visual Basic 6.0 Professional Step-By-Step. Redmond, WA: Microsoft Press. 1998. 6. Pressman, R. S. Software Engineering: A Practitioner’s Approach. McGraw-Hill. 2001. 7. IIS 5.1 Documentation: Microsoft Corporation. 8. http://www.w3.org/xmll 9. http://msdn2.microsoft.com 10. http://www.simplyautomate.co.uk APPENDIX A Example Source Code for Connection to Local and Remote SQL Server Database Using Active Server Pages 69 <% dim rs dim doc dim cn dim rqs ' Create Objects set cn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") set doc = server.CreateObject("MSXML2.DomDocument") rqs = Request.QueryString("ID") cn.Open "Provider=sqloledb;Data Source=Soap;Initial Catalog=SH;Integrated Security= SSPI;" ' Set up Recordset rs.CursorLocation = 3 'adUseClient ' Get required data if rqs = 0 then rs.Open "Select * from LivingRoom", cn, 1, 4 else rs.Open "Select * from LivingRoom where UID = " & rqs & "", cn, 1, 4 end if ' Save Recordset to DOMDoc as XML rs.Save doc, 1 ' Set Response property Response.ContentType = "text/xml" ' Stylesheet for browser display Response.Write "<?xml:stylesheet type=""text/xsl"" href=""Recordsetxml.xsl""?>" & vbcrlf ' Send XML from DOMDoc to Response Response.Write doc.xml set doc=nothing rs.Close set rs=nothing cn.Close set cn=nothing %> APPENDIX B Example Source Code for Connection to Remote Access Database Using Active Server Pages 70 <% dim rs dim doc dim cn dim rqs, dbPath ' Create Objects set cn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") set doc = server.CreateObject("MSXML2.DomDocument") dbPath = "\\SOAP\databases\housestatus.mdb" rqs = Request.QueryString("ID") cn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath ' Set up Recordset rs.CursorLocation = 3 'adUseClient ' Get required data if rqs = 0 then rs.Open "Select * from LivingRoom", cn, 1, 4 else rs.Open "Select * from LivingRoom where UID = " & rqs & "", cn, 1, 4 end if ' Save Recordset to DOMDoc as XML rs.Save doc, 1 ' Set Response property Response.ContentType = "text/xml" ' Stylesheet for browser display Response.Write "<?xml:stylesheet type=""text/xsl"" href=""Recordsetxml.xsl""?>" & vbcrlf ' Send XML from DOMDoc to Response Response.Write doc.xml set doc=nothing rs.Close set rs=nothing cn.Close set cn=nothing %> APPENDIX C Example Source Code for Connection to Local Access Database Using Active Server Pages 71 <% dim rs dim doc dim cn dim rqs, dbPath ' Create Objects set cn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") set doc = server.CreateObject("MSXML2.DomDocument") dbPath = "C:\Inetpub\wwwroot\smarthouse\databases\housestatus.mdb" rqs = Request.QueryString("ID") cn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath ' Set up Recordset rs.CursorLocation = 3 'adUseClient ' Get required data if rqs = 0 then rs.Open "Select * from LivingRoom", cn, 1, 4 else rs.Open "Select * from LivingRoom where UID = " & rqs & "", cn, 1, 4 end if ' Save Recordset to DOMDoc as XML rs.Save doc, 1 ' Set Response property Response.ContentType = "text/xml" ' Stylesheet for browser display Response.Write "<?xml:stylesheet type=""text/xsl"" href=""Recordsetxml.xsl""?>" & vbcrlf ' Send XML from DOMDoc to Response Response.Write doc.xml set doc=nothing rs.Close set rs=nothing cn.Close set cn=nothing %>