Вы находитесь на странице: 1из 6

International Journal of Advanced Computer Science, Vol. 2, No. 3, Pp.99-104, Mar. 2012.

The Design and Development of Database in Electricians Digital Assistant


Jingzhao Li
Manuscript
Received: 18,Jun., 2011 Revised: 27,Sep., 2011 Accepted: 14,Feb., 2012 Published: 15,Apr., 2012

Keywords
Digital assistant; Embedded database; ARM; SQLite; Linux

Abstract Electricians digital assistant has the functions, including multimeter, oscilloscope, common electrical formula calculation, and electrical parameter manual query. Its hardware is made up of a microprocessor S3C2440 based on ARM core, the circuit for data collection and process and the display circuit of touch-screen/LCD. In addition, an embedded Linux operating system and embedded database SQLite3 are transplanted to design application program. In this paper, the design and development of embedded database used in electricians digital assistant is introduced. Based on the embedded database SQLite3 was transplanted to ARM-Linux platform, we designed data tables and fields of electricians digital assistant. It is emphasis analyzed that the creation of database table and design of the database query in electrical technology data query module.

user application program in the process of development. The transplantation and application of embedded database SQLite3 of the electricians digital assistant is analyzed in this paper.

2. The Functions and Architecture of Electricians Digital Assistant


The electricians digital assistant has the following functions: (1) Multimeter. It can measure the usual electrical signals and parameters, such as resistance, capacitance, inductance, voltage, current, frequency and so on. In addition, it can also measure the real-time instantaneous value of online AC voltage & current, power factor, active power, reactive power, apparent power, frequency and other electrical parameters. (2) Oscilloscope. It displays the waveform of measured electrical signals such as voltage, current, power in the form of wave shape and digital [2]. (3) Formula calculation with online edit. It can execute the common electrical formula calculation. The user can submit the observed values to the formula in electricians digital assistant directly, obtain the results and preserve them. The electricians digital assistant simultaneously also supports the online formula edit, which makes the electricians digital assistant more universal.
Electricians digital assistant

1. Introduction
The embedded system has already became a new economic growth point in IT industry, the PDA(Personal Digital Assistant) as a high-end embedded system production has also been developed rapidly. Especially with the population of microprocessor based on ARM core and the open source code Linux OS, the PDA is widely applied and its functions continue to be improved and enriched. However, there are more general types of PDA but the fewer professional type now [1]. Supported by Anhui provincial natural science foundation of universities key projects, we studied a professional PDA used by electrician in this article; this professional PDA has the functions, including multimeter, oscilloscope, common electrical formula calculation and electrical parameter information manual query. This type of PDA will enable the electrical technicians to work without multiple instruments, numerous information queries and formula calculations, which greatly improves the work efficiency. As the electricians digital assistant need to deal with a large amount of information and data, embedded database SQLite3 is transplanted to ARM-Linux platform to design
This work is supported by Anhui Provincial Natural Science Foundation of Universities Key Projects Project Approval (KJ2009A093). Jingzhao Li is with School of Computer Science and Engineering,Anhui University of Science and Technology Faculty (jzh.li@aust.edu.cn)

Oscilloscope Module

Fig.1 Function modules of electricians digital assistant

(4) Electrical data query. The user can query the desired electrical professional technical data with the title or keywords using the precise or fuzzy queries. Meanwhile,

Multimeter Module

Formula Computation Module

Data Query Module

GPRS Module

V oiceNavigationModule

100

International Journal of Advanced Computer Science, Vol. 2, No. 3, Pp.99-104, Mar. 2012.

this module can automatically store the related data and seek the history data. (5) Voice navigation and GPRS communications, etc. This PDA supports the voice navigation, browses, downloads or uploads the personal data using GPRS. Function module design of the electrician digital assistant is shown in figure 1. This electricians digital assistant obtains the measure value of electrical signals through the bottom data acquisition module. The system control signals are triggered by touch screen. Its structure of the electricians digital assistant is shown in figure 2.

Application Software for Embedded System The Embedded GUI The Embedded OS The Embedded Hardware Platform Fig.2 Structure of electricians digital assistant The Embedded Database

3. The Analysis of Embedded Database


A. Characteristics of Embedded Database Compared with the general computer system, the embedded database, which is determined by the demand of special development environment, has following characteristics [3]: (1) Embedded database management system takes up very little memory space, should be try to avoid redundant data. (2) Embedded database should have good real-time, so as to ensure when embedded real-time operating system is running, will not affect the real-time performance of entire system. (3) Since the embedded system is inevitably related to the underlying hardware, embedded database can operate and control the underlying data. B. The Analysis of Common Embedded Database Common embedded database on Linux platform mainly has PostgreSQL, MySQL, MSQL, BerkeleyDB, SQLite, etc [4]. (1) PostgreSQL PostgreSQL is used freely, so it is the first choice for many Linux distributions. For example, Redhat and TurboLinux are pre-installed PostgreSQL. (2) MySQL MySQL is a multi-user, multi-process SQL database server. MySQL has an implementation tool (client/server), including server daemon, client programs and libraries, so It is suitable for small and simple database. (3) MSQL (miniSQL)

MSQL is a single-user database management system. As it is pithy, which makes the developed application system is very popular among the Internet users. (4) BerkeleyDB BerkeleyDB is an open source embedded database management system, which can provide the application with a high-performance data management service. Programmers only need a few simple API calls can be completed on the data access and management. (5) SQLite SQLite is a type of database, which supports most standard SQL92 statement. It uses a single database file storage, which has large memory capacity; runs rapidly [5]. It is easy to use in deal with similar relational database. Otherwise, the copyright of SQLite allows any application restrictions, including commercial products. This portable embedded database product has been integrated in PHP5. As the above analysis shows, MySQL provides more appropriate functions, has become the first choice for medium and small-scale database applications. But it is charged in commercial applications, and that, for the embedded development, still too much space is taken up. MSQL is a simplified SQL database, energetic, easy for embedded development. But it is not an entirely open source. PostgreSQL has a larger volume, and using Berkeley DB will increase development costs. So we use the SQLite to develop the electricians digital assistant database system in the paper.

Data transmission

4. Embedded Linux Boot and Kernels Transplantation


This PDAs software design is composed of four layers, that is, the bootloader, the OS kernel, the file system and the user application program. A. Boot Transplantation In this paper, U-Boot is selected as the PDA boot program. First, the first stage code of U-Boot is placed in file start.s, which is coded in assembly language, Then a start function (that is armboot()) in file libarm/board.c is coded using c programming language, which is the main function of the entire startup code as well as the U-Boot[1]. B. Linux Transplantation The kernel is the core programs of the OS, also the center of the all component in Linux system, which provides the core management calls of microprocessor for the output. The Linux kernel functions are composed of five parts, including the process management, the memory management, the file system, the device management (such as device drivers, distribution and collection), network protocols, etc. The Linux-2.6.24.4 kernel is transplanted as the PDAs OS [3]. The transplantation follows eight steps: (1) Download the compressed file of kernel source code. Copy file linux-2.6.24.4.tar.bz2 to working directory, unzip, and then get the complete Linux kernel source code. (2) Modify file Makefile. The platform is set as ARM and the cross compilers prefix is defined as arm-linux-, save and quit.
International Journal Publishers Group (IJPG)

Jingzhao Li: The Design and Development of Database in Electricians Digital Assistant.

101

(3) Set the Nand Flash partitions. (4) Add yaffs patches. (5) Add the drivers for the LCD and network card in the kernel. (6) Modify the input clock frequency of the platform. (7) Modify the machine code. (8) Execute the commands of make menuconfig and make to compile the kernel, and then a kernel image file named jzlImag is created, this file can be used to boot the kernel after it is written to the development board [5]. C. Design of Driver Program This chapter focuses on the touch screen driver. The touch screen driver needs to be coded by combining with the IAL of MiniGUI, it mainly has the following functions: device file open function s3c2440_ts_open (), device file release function s3c2440_ts_release(), device file read function s3c2440_ts_read(), device file poll function s3c2440_ts_poll(), working mode setting function s3c2440_ts_init(), releasing module function s3c2440_ts_exit() and interrupt function s3c2440_ts_adctc () and so on. For interrupt function s3c2440_ts_isr_adct(), the controller generates interrupt signal INT_TC when the touch pen clicks the touch screen. The register can get the X and Y position after the interrupt, and then the interrupt function wake_up_interruptible (&queue) is called to wake up the driver blocking queue. The drivers of LCD, USB and other equipments are realized in the same way, which are omitted here. D. Design and Implementation of GUI MiniGUI has some common control classes, including static text box, button, edit box, list box, combo box, progress bar, slider, toolbar, scroll control and tree view control, calendar control; it also supports dialog box, message box and other GUI elements such as menu, accelerator key, inserter, timer, etc. MiniGUI is about 500KB in codes and very suitable for developing the graphical interface in PDA. The MiniGUI1.6.10 is used to develop the graphics interface of application programs in this PDA system. Firstly, MiniGUI1.6.10 software is installed and configured on the host machine with the Linux OS. The main steps are as follows: (1) Download the development library libminigui-str-1.6.10.tar.gz, the resource file minigui-res-str-1.6.10.tar.gz (2) Unzip and install the resources in file miniui-res-1.6.10.tar.gz including basic font, icon, and bitmap and mouse cursor. (3) Set MiniGUI as qvfb mode, then MiniGUI can be used to develop graphical interface.

assistant use SQLite3.2.5, the compilation process has the following steps: (1) Download and decompress this package, and build a sqlite directory, then build and go to a new directory which is parallel with the sqlite, in order to store the compiled results separately. After input $tar -zxvf sqlite-3.2.5.tar.gzat the same level, there will generate sqlite-3.2.50 directory. (2) Put arm-linux-gccs directory in the PATH environment variable: PATH: /opt/host/armv4l/bin. (3) Amend sqlite/src/sqliteInt.h, for sure that btree has the correct variable type. Find in the following statement On the ARM-Linux system: #ifndef INTPTR_TYPE #if SQLITE_PTR_SZ==4 #define INTPTR_TYPE int # else #define INTPTR_ TYPE long long # endif Added define SQLITE_PTR_SZ 4 before the above statements, in that way, the type of "typedef INTPTR_TYPE ptris int but not "long long". (4) Modify Makefile.linux-gcc Open $vi Makefile.linux-gcc, and change BCC=gcc -g -02into BCC=arm-linux-gcc -g -02, then run SQLite in ARM-Linux. (5) Install and run the following commands: $./configure -disable -tcl $make $make install Add the -disable tcloption in the above commands; in order to make it do not support tcl, and can reduce the size of the generated library. (6) Run SQLit based on PDA Add the cross-compiling file libsqlite.a to the directory lib of the filing system, and modify permissions: $chmod +wx libsqlite.a. In this way, you can use the library functions from SQLite for developing application program [6].

6. The design of the Electricians digital assistant database


The design of the electricians digital assistant database includes two parts, one is the design of datasheet, and another is the design of field in datasheet. A. Design of Datasheet According to the analysis of the electricians digital assistant functions, the entire system consists of four modules oscilloscope, multimeter module, formula computation module and data query module. Oscilloscope module need to conserve waveform, display it when you need, and keep the waveform and the related information. Multimeter modules need to build the datasheet to conserve all electrical measured value and measured information for preservation and query. Formula computation modules need to implement the formula editor and conserve it, and need to build a data table to keep the electrical formulas.

5. Transplantation SQLite on the ARM-Linux Platform


According to different hardware platforms, SQLite embedded database provides a way to release for cross-compiling source code. If electricians digital
International Journal Publishers Group (IJPG)

102

International Journal of Advanced Computer Science, Vol. 2, No. 3, Pp.99-104, Mar. 2012.

Moreover, this module should have the function of conserving the calculated results. Electrical data module has a large amount of data which being used often by electrical technicians. Through the above analysis, the system database can be divided into four functional modules, which is the corresponding datasheet design with each module. Oscilloscope modules need to build waveform storage tables, and the fields include measured time, x-axis scale units, y-axis scale units, and waveform. Formula computation module need to establish the table of electrical formula, and the fields include the physical, electrical formula; in addition, build the storage of computing results, in order to store and query results, field including the measuring time and formula, the results and so on. The table of computing results is in connection with the table of electrical formula. Electrical data query module established electrical table, fields including data types, data and information content of the title. Fields and functions of the database are shown in Table1.
TABLE1 FUNCTIONS OF THE DATABASE Table name Function Waveform storage table Save the waveform oscilloscope module Save the measurement results multimeter Measurement storage module table Electrical formula table Save electricity formula The results table Save electricity formula results Electrical data sheet Save electrical information for inquiries

data, based on the choice of data types and the input keywords or title. You can use the exact query or the fuzzy inquiry. A. The Establishment of an Electrical Technical Data Query Module Database Table Design of electrical technical data query modules database has two steps. At first, data is written to the database, providing a query for the user. Secondly, the processed data can be displayed in the system where it is needed, and the API function which is provided by SQLite carry on the data processing conveniently in multi-line edit box of this module. Above all, you type $sqlite3 eepda.db in shell terminal in order to establish a database. Then, you need to create electrical information in the database table, and input create table elecinfo (title, type, info), a datasheet named elecinfo, which has three fields that are title, type and info is established. Before system runs, you need to import the common electrical information to datasheet, including information on the type of the datasheet and data caption that user is querying. According to the users option to query the database, the results will be displayed in the LCD. The statement - sqlite3 eepda.db insert into elecinfo values can make a record being inserted into the elecinfo table. Other records can also be imported in the same way. The stored procedure of electrical data is shown in figure 3. Electrician can deal with data through a variety of library functions which is offered through sqlite-3.2.5, when they are using electricians digital assistant. These library functions consist of sqlite3_open, sqlite3_ exec, sqlite3_snprintf, and sqlite3_close. And the statement sqlite3_snprintf (sizeof(zSq12)), zSq12 is inserted into elecinfo values (' %q' , ' %q' , ' %q') and is explained. When Chinese character is used in process of the application, it will be shown as garbled. If transform the Chinese character to the GB2312, it will be displayed correctly. So format conversion should be used % q for formatting in SQL.When the main window of system is loaded, you need to add initialization code in the main windows procedure function MSG_CREATE. For example, using the command sqlite3_open(eepda.db,&db) to open database, and so on. B. Design of the Database Query Module When users carry on the electrical data query, at first, choose the data type from the combination frame, then choose the data title. For example, if query the data content whose title is the fuzzy, the user need to choose the type the fuzzy control from the data class. Choose the title the fuzzy in the data title combination frame and click the button the inquiry, then the result is displayed in multi-line editor. If the text is longer, the user can use the scroll bar to read information. The process of electrical data query module database is shown in figure 4.

B. Design of Field in Datasheet We have established five figures of database and made the introduction of the field. Now, taking the data query module as the example, we introduced how to design field in the data sheet. Data type of field is not necessary in establishing datasheet in SQLite3, and all data types like value, character and long text are stored in the datasheet. So we only need to consider the rational design of a database table structure. Design of electrical data datasheet is shown in Table2.
TABLE2 FIELD DESIGN OF ELECTRICAL DATA SHEET Description of Memoery field classification Shorten the query time the title of each Electrical data table key, the user can data search by title concrete content the contents of user need

Field name Type of data Title of data Content of data

7. SQLite Application in Electrical Information Query Module


The operations of electrical data query module mainly include data queries and data import. User queries electrical

International Journal Publishers Group (IJPG)

Jingzhao Li: The Design and Development of Database in Electricians Digital Assistant. Begin

103

Open database N Exist or missing? Y Establish a database table t t Add data in the table Close the database Over Fig.3 Stored procedure of electrical data Create a new database

sending message CB_SETCURSELto the control IDC_TYPE. Filling design of combo box is shown in figure 5.
Query the type of data from the database N Are there matching records? Y Set the content of IDC_TYPE Add query results to IDC_TYPE Back to the index value

Release the query pointer

When MSG_INITDIALOG is loaded to electrical data query dialog box, the API function related to Sqlite is called to initialize the electrical data query module database tables, and retrieve the type of electric data from the database. Retrieval condition is decided by the SQL statement select distinct type from elecinfo. The SQL statement queries all data categories from the table elecinfo. The parameter distinct will be used to return only different value, in order to that there will be not duplication in the query results. If the query success, the results will be classified and filled the combo control. Then the message CB_INSERTSTRING is sent to the list box in the control window by the function SendDlgItemMessage, this message is used to insert new entries to the list box.
Open the database Fill IDC_TYPE Choose type Open the database Choose the title and click the query button Show the query result Click the return button Return the main window Fig.4 Database processing procedure

Exit data query Fig.5 filling process of combo box data

The filling process of data title combo box is similar to data category combo box. After the user selects a data classification, the system will automatically trigger the event nc=CBN_SELCHANGED of data title combine box, implement the select statement, check out all the information under the category title, display the title information in the combo box for users to choose. After the user selects the title, click the query button to trigger the click event of query button, add query button's one-shot event code to the MiniGUI procedure code, and join the query statement select info from elecinfo. If a matching is recorded, the data content is displayed in the multi-line edit box, else returns -1. At last, the system displays the query results by calling the function SetWindowText.

8. Conclusion
It is briefly described that design and development of embedded database used in electricians digital assistant in this paper. Taking the electrical data query module as the example, we analyzed the application of SQLite3 database, and finally realized the function as online calculation, editing and querying electrical data, etc.

References
[1] C.M. Wu, & C.W. Su, Design of a PDA-based Asthma Peak Flow Monitor System, (2009) International Conference on Biomedical Engineering, IFMBE Proceedings, 13, vol. 23, pp. 501-504. [2] J. Li, Based on an embedded system design new pulse therapy instrument, (2006) Journal of Tianjin University supple, pp 61-63. [3] I.H. Jang, Ch.H. Kim & N.Ch. Kim, Region Analysis of

Finally, release the results of the query and put the first piece of data in the current option of the combo box, by
International Journal Publishers Group (IJPG)

104

International Journal of Advanced Computer Science, Vol. 2, No. 3, Pp.99-104, Mar. 2012.

Business Card Images Acquired in PDA Using DCT and Information Pixel Density, Lecture Notes in Computer Science, (2005) Advanced Concepts for Intelligent Vision Systems, vol. 37, no. 08, pp. 243-251. [4] K. Yaghmour, & B. Embedded Linux System, (2003) Publisher: ORelly &Associates, pp. 343-349. [5] A. Ganssle, The Art of Programming Embedded Systems, (2009) Beijing: Posts & Telecom Press. [6] T. Chen, Y. Lian, & J. Huang, A New Approach for Predictable Hard Real-Time Transaction Processing in Embedded Database,Lecture Notes in Computer Science, ( 2005) Embedded Software and Systems, vol. 36, no. 05, pp. 222-228.

Jingzhao LI was born in Huainan, Anhui, China, in 1963. He received the M.Sc. and Ph.D. degrees from China University of Mine in1992 and Hefei University of Science and Technology in 2003, respectively. He is the author or coauthor of more than ten national and international papers and also collaborated in several research projects. Since 1992 he has been with the Department of Electrical Engineering and School of Computer Science and Engineering at AUST. He currently is the Dean and professor of School of Computer Science and Engineering at AUST, and works with both electronic and computer engineering groups. His current research interests include Embedded system, computer control and internet of things design.

International Journal Publishers Group (IJPG)

Вам также может понравиться