Chapter 3 System Architecture
3.2 Personal Mobility Monitoring Device
3.2.4 Software Design of ECG Monitoring Mobile Phone
(A) Architecture
Fig.3- 10 Software architecture of ECG monitoring mobile phone
Fig.3- 10 specified the software architecture of ECG monitoring program in mobile phone. The detail description is listed below:
1. LCDUI is the base of any GUI application packages created in J2ME. It has a similar role to the abstract windowing toolkit and swing APIs, which are used in Java SE and Java EE but offers a more restricted and resource-efficient approach to UI development. LCDUI has a simple screen-based approach where a single Displayable is always active at a time in the display area of the application user interface. This Displayable can contain predefined screen elements, or be manipulated in more specific ways. On a logical level, the MIDP UI is divided
into two levels: the high-level and the low-level, as shown in Fig.3- 11.
Fig.3- 11 Class hierarchy of javax.microedition.lcdui
In general, the choice is made between the easy, quick and portable high-level APIs and the more customizable low-level APIs. In ECG monitoring MIDlet architecture, Frame is used to display text string, such as the status of Bluetooth searching, error message when the program occurred a runtime error. Canvas is used to plot ECG waveform, GPS information, HR variable values when the link is established between ECG acquisition module and ECG monitoring mobile phone. Alert in this proposed system is used to perform a warning sound that remind the patient something is wrong, such as heart rate is too fast.
2. A thread is a light weight process in a program. The Java Virtual Machine (JVM) allows an application to have multiple threads of execution running concurrently.
Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new thread object, the new thread has its priority initially set equal to the priority of the
daemon. When a JVM starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class). The JVM continues to execute threads until either of the following occurs: 1) The exit method of class runtime has been called and the security manager has permitted the exit operation to take place. 2) All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagate beyond the run method.
The life cycle of thread is illustrated in Fig.3- 12. In ECG monitoring MIDlet architecture, GPS API, SMS API, BT API, Algorithm, Receiving Thread, and Daily Upload are all independent threads. GPS API is used to get GPS information, such as latitude and longitude. SMS API is one of the packages of the Wireless Messaging API (WMA) which is an optional package for the J2ME that provides platform-independent access to wireless communication resources.
The package in this system is used to let program transmit short message containing ECG raw data and GPS information and transmit it to health care server. BT API is used to establish the link between ECG acquisition module and ECG monitoring mobile phone. It is used JSR 082 package [35] so that application programs utilize Bluetooth functions in the mobile phone.
Fig.3- 12 Life cycle of thread
To extract the physiological parameters measured from front-end ECG acquisition module, this system uses Bluetooth mobile phone with JAVA APIs for Bluetooth Wireless Technology (JABWT) to develop client application program MIDlet to control and use ECG acquisition module to realize the physiological parameter extraction function on personal mobile device. The methods for interface DiscoveryListener in javax.bluetooth API have to be implemented in programs to let MIDlet receive RemoteDevice and ServiceRecord found by DiscoveryAgent. Connection address attributes in remote device service records are used to setup connection to utilize services provided by remote devices. Since the Bluetooth module is in the ECG acquisition module, the API of Javax.microedition.io’s StreamConnection interface can be used to set up connection. After the connection has been set up,
physiological parameter measurement data. Finally, the data can be transmitted to physicians or health care server with short messages. Algorithm is used to get the R-peak wave and calculate the R-R interval which is described in section 0.
Receiving Thread is used to receive the ECG raw data which is from ECG acquisition module. Daily Upload is used to collect the history of heart rate in every minute and send it to health care server every two hour.
Using separate thread can make sure mobile phone continues working without blocking. Table 3- 3 listed the thread files used in the ECG monitoring MIDlet. The active time means when the thread will be dispatched, that is, get the usage of professor. For example, Daily upload will go to running state every two hour to send the average HR of every minute
Table 3- 3 Summarized of thread file Thread Name Active Time Job Description
SMS API Any time Send abnormal data to server
GPS API All time Continuous to receive GPS information
BT API Beginning To establish the Bluetooth link Receiving thread All time To receive ECG data from device Algorithm 5 second To calculate the variation of HR Daily upload 2 hour To upload the average of HR
every minute
3. Buffer is a container that is used to store the ECG raw data from ECG acquisition module. The basic data structure in Buffer of ECG monitoring MIDlet is linked list. Normally, linked list is as Fig.3- 13:
Fig.3- 13 A linked list whose nodes contain two fields:
integer and a link to next node
The reason of using this data structure is that linked lists allow insertion and removal of data at any point in the list, with a constant number of operations and we can’t declare the size of an array because we have no idea about how many data will be sent from ECG acquisition module. Fig.3- 14 is modified linked list that is used in Buffer of ECG monitoring program. A node contains two fields:
an integer array and a link. The integer array contains one second data, which is 512 samples, and the link is a pointer which is directed to next node. So, if we want to review the received data, we can sequential search the data we need and easily to insert or remove node.
Fig.3- 14 Modified linked list (B) Procedure
There are three major states in ECG monitoring mobile phone: 1) Normal ECG monitoring procedure; 2) Abnormal heart rate detected procedure; 3) Daily heart rate
Fig.3- 15 State transition diagram for ECG monitoring procedures
When this procedure has performed for two hour, it will change to daily heart rate upload procedure and go back when finished. If, in anytime, abnormal heart rate was detected during normal ECG monitoring procedure, the procedure will change to abnormal heart detected procedure and go back when finished.
Fig.3- 16 Normal ECG monitoring procedure
The detail steps of normal ECG monitoring procedure is shown in Fig.3- 16 and
described below:
1. The ECG acquisition module is first attached in patient body, as shown in Fig.3- 17.
2. Patient press the beginning bottom on ECG monitoring mobile phone to start measuring, as shown in Fig.3- 18.
3. The BT API is called to establish the connection between ECG acquisition module and ECG monitoring mobile phone.
Fig.3- 17 Snapshot of ECG acquisition module attached on the body
Fig.3- 18 Snapshot of searching ECG acquisition module process: (a) start to inquiry the Bluetooth device around, (b) lists the device found around, (c) found the ECG acquisition module, and try to search the SPP service, and (d) found SPP service and try to create the connection.
4. BT API successfully establishes the connection.
5. ECG monitoring mobile phone will create a Buffer to store the ECG data.
6. The ECG raw data will be received and stored in to the Buffer.
7. The Algorithm will be called to calculate the HR.
8. The HR will be calculated and displayed on the screen of mobile phone to patient, as shown in Fig.3- 19. Due to the overlap is five second, the output time of
calculated HR is shown in Fig.3- 20.
Fig.3- 19 ECG and HR displayed on the screen
Steps 1-8 above are also called initial steps. These steps are used to setup the GUI and connection. The initial steps should be only called one time until the program exit.
Once the initial steps are run, the normal steps 9- 11 will be executed repeated.
Fig.3- 20 Time procedure for calculating HR
Fig.3- 21 (a) abnormal heart rate detected procedure; (b) daily heart rate history upload procedure
According to the different usage, the abnormal heart rate detected procedure and daily heart rate history upload procedure has more steps which is shown in Fig.3- 21 and described below:
9. In abnormal heart rate detected procedure, when the abnormal HR was detected, as shown in Fig.3- 22, the program will get the GPS information by using GPS API; in daily heart rate history upload procedure, the daily upload will collect the history of HR.
10. In abnormal heart rate detected procedure, the SMS API will set the ECG raw data and GPS information as payload of message; in daily heart rate history upload procedure, the SMS API will set the history of HR as payload of message, as shown in Fig.3- 23.
11. In both of two procedures, SMS API will send the message to health care server.
Fig.3- 22 Abnormal HR was detected and warning when (a) HR is too slow, and (b) HR is too fast
Fig.3- 23 Permission of sending SMS