【正文】
在傳輸?shù)臄?shù)據(jù)基礎(chǔ)上,對(duì)其數(shù)據(jù)進(jìn)行一系列算法處理,可將數(shù)據(jù)存入文件,也可用于繪圖。 Android應(yīng)用+光電傳感器由于Android系統(tǒng)的移植性強(qiáng),裝載Android系統(tǒng)的設(shè)備越來越多且便攜性大大提高,計(jì)劃將此軟件移植到Android平臺(tái)中,利用光電傳感器和相應(yīng)的藍(lán)牙開發(fā)板,將傳感器采集到的脈搏信號(hào)傳輸通過藍(lán)牙的形式傳輸?shù)街悄茉O(shè)備中,并利用Android下較為流行的圖表引擎AChartEngine繪制相應(yīng)的波形。Genymotion安裝流程如下:1 注冊(cè)Genymotion賬號(hào)2 下載Genymotion安裝包3 安裝VitualBox4 安裝Eclipse或者Intellij插件注冊(cè)需要通過其官方網(wǎng)址,注冊(cè)后,開發(fā)者可以選擇模擬器的系統(tǒng)環(huán)境。不過由于智能手機(jī)仍需要連接電腦進(jìn)行開發(fā)中的通信,所以一些注意事項(xiàng)需要注意一下:1) 手機(jī)需進(jìn)入“USB調(diào)試模式”,不同的手機(jī)有不同的設(shè)置,開發(fā)者需根據(jù)相應(yīng)的機(jī)型提前設(shè)置好。 開發(fā)板CC254xCC254X模塊是低成本,低功耗的SOC(System on a Chip,系統(tǒng)級(jí)芯片)方案,廣泛用于藍(lán)牙低功耗應(yīng)用,花費(fèi)非常少的材料成本即可構(gòu)建BLE Master或Slave Node。壓電式原理采集信號(hào),數(shù)字信號(hào)輸出,直接通過USB或串口輸出脈搏波波形數(shù)據(jù)。以下為傳感器實(shí)物圖。應(yīng)用軟件整體功能分為兩個(gè)部分,一部分為接收數(shù)據(jù)的前置工作,一部分為處理數(shù)據(jù)的具體功能。 // Stops scanning after a predefined scan period. mScanning = false。 (mLeScanCallback)。 private mOnDataAvailable = new OnDataAvailableListener() { //BLE終端數(shù)據(jù)被讀的事件 Override public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { ((characteristic .getValue()), (), characteristic .getUuid().toString())。接著,并在繪圖過程中調(diào)用PluseSure()方法以計(jì)算BPM。 FileWriter fw = new FileWriter(dataFile, true)。 // 求得BPM Bpp = (float) (timeListSize 1) * 1000 / durTime。在下面的繪圖模塊中可以看到一個(gè)判斷條件:當(dāng)波形數(shù)據(jù)上揚(yáng)(即前一個(gè)數(shù)據(jù)小于0,后一個(gè)大于0,0是判定界限)時(shí),就調(diào)用判斷BPM的方法體。導(dǎo)入引擎包后就可使用其中的繪圖類,如下:// 用于存放每條折線的點(diǎn)數(shù)據(jù) private static XYSeries lineMaibo。 }可以看到,pluseHandler在每一次滿足條件時(shí)運(yùn)行refreshChart(),即刷新視圖:private static void refreshChart() { initLine(lineMaibo)。 (chartListSize 2) 0) { pluseSure()。 (xTemp, yTemp)。其開發(fā)界面如下圖。 (view).setPositiveButton(登錄, new OnClickListener() { Override public void onClick(DialogInterface dialog, int which) { RegClickListener logListener = (RegClickListener) getActivity()。 for (User u : users) { if (().equals(username)) { existFlag = true。 if ((user)) { (true)。此模塊已有功能,可由下列流程圖進(jìn)行說明,;否是開始注冊(cè)符合要求?存入數(shù)據(jù)庫(kù)登錄功能開放部分功能未開放結(jié)束已注冊(cè)?是否設(shè)置模塊主要用于設(shè)置一些常規(guī)的配置,分為普通用戶和管理員進(jìn)行設(shè)置權(quán)限分配,管理員可以使用“用戶管理”中的全部功能,即“增加用戶”“刪除用戶”以及“查詢用戶”,普通用戶則只能使用“查詢用戶”功能,這是為了防止普通用戶無意將修改其他用戶資料而造成的數(shù)據(jù)泄漏。 MapString, String userItem = new HashMapString, String()。 左圖中數(shù)據(jù)看似有規(guī)律性但是波形矮小,一般是因?yàn)闆]有實(shí)際接觸上硬件;而右圖中波形起伏不規(guī)律,一般是由于突然接觸傳感器,使得傳感器自身沒有調(diào)整數(shù)據(jù),藍(lán)牙發(fā)送出的數(shù)據(jù)也因此不規(guī)律。 } ()。 } (msg)。其他還有一些管理或優(yōu)化線程的方法,原理都類似,需要注意的是Android的線程更新和Java下并不盡然相同,Android下只有主線程即UI線程才能被更新,因此關(guān)于Handler的方法調(diào)用都應(yīng)該放在更新視圖的方法中,即onCreate()或onCreateView()方法中,具體方法可見工程代碼或見附錄。 (false)。 }}// 判斷是否為管理員用戶,是則開放功能public void isAdmin() { String user = (user, null)。目前的解決方案是盡量使用可以求得的參數(shù),比如波形的幅度和頻率,使用已經(jīng)可得的數(shù)據(jù)進(jìn)行最大化的數(shù)據(jù)挖掘,由此分析得出結(jié)論。the behavior of the application is modeled as a finitestate machine while the graphical user interface is modeled by using classes and set of translation rules is defined to obtain a platformdependent representation and then the actual methodology has been validated by creating an application for both the Android and Windows Phone platform and by paring the obtained code to the corresponding versions written in the traditional way.Keywords:UML,PIM,PSM,Statechart,Android,Windows PhoneI. INTRODUCTIONTechnological revolution specifically in telemunication has created a large market for mobile phones and everyday hundreds of different applications are developed for smartphones due to their diverse smartphone is built on a mobile puting platform,with more advanced puting capability and connectivity than a feature phone[1].Development of smartphone applications is the process by which software is developed for resourceconstrained devices and it is executed over a specific operating system like Android,Windows Mobile,iPhone iOS,and Nokia ,each platform uses a different programming language,such as Java[2]for Android or ObjectiveC[3]for iPhone,and has a slightly different development process.Therefore,the main limitation in smartphone application development is that the application provided for a platform cannot be executed on the other ones and the developer should provide a version for each leading platform thus increasing timetomarket and solve this problem,in[1],the authors present a prehensive middleware architecture for mobile application to support interoperability and portability of mobile middleware is a software layer between the operating system and the user runtime,the middleware translates platformindependent application operations into the platformspecific counterparts。目前應(yīng)用雖然已經(jīng)實(shí)現(xiàn)核心功能,即接收藍(lán)牙信號(hào)并實(shí)現(xiàn)實(shí)時(shí)繪圖,在終端成功運(yùn)行,但數(shù)據(jù)分析功能和咨詢功能尚不完善,分析功能需要編寫較為高效的數(shù)據(jù)歸納算法對(duì)其本地?cái)?shù)據(jù)進(jìn)行一定的處理統(tǒng)計(jì),咨詢功能則在分析的基礎(chǔ)上針對(duì)不同的數(shù)據(jù)特征作出相應(yīng)的建議;此處,網(wǎng)絡(luò)連接功能仍需進(jìn)一步開發(fā),以完善數(shù)據(jù)的對(duì)比,使應(yīng)用給出的建議更有說服力。3. 對(duì)比分析波形問題波形的分析涉及到一系列數(shù)學(xué)問題,首先是對(duì)波形的除噪去噪,然后是對(duì)波形進(jìn)行小波變換或傳統(tǒng)傅立葉變換,得到頻域的頻譜,接著利用相應(yīng)的數(shù)學(xué)工具對(duì)頻譜進(jìn)行解析,得到一定的結(jié)論。 User user = new User(admin, ******)。 (true)。 (message)。 break。Runnable run=new Runnable() { Override public void run() { try { initLine(lineMaibo)。}上述代碼初始化了ListView組件,并將從數(shù)據(jù)庫(kù)中查詢而得的用戶信息填入列表以顯示出來,此處為了體現(xiàn)查詢效果,將用戶名與密碼一起查詢,用戶可以看到當(dāng)前所有已經(jīng)注冊(cè)的用戶名與密碼。 i ()。 (false)。 } } } Override public void onLog(String username, String password) { ListUser users = ()。對(duì)填寫文本的處理方法則放在了主界面代碼下,這是因?yàn)橐袛嘤脩羰欠褡?cè),部分代碼如下;Override public void onReg(String username, String password) { ListUser users = ()。對(duì)話框與Sqlite輕量數(shù)據(jù)庫(kù)連接,會(huì)將注冊(cè)的用戶名和密碼封裝為一個(gè)對(duì)象”user”,凡是存取用戶皆由數(shù)據(jù)庫(kù)接管,部分代碼如下;dialog_edit_username = (EditText) view .findViewById()。否是否返回連接藍(lán)牙接收到數(shù)據(jù)?存入文件轉(zhuǎn)換數(shù)據(jù)讀寫標(biāo)志?監(jiān)測(cè)數(shù)據(jù)波形圖脈搏穩(wěn)定?計(jì)算BPM開始是是否 接收后續(xù)流程圖界面布局主要由xml配置文件管理,一般來說,應(yīng)用中有多少個(gè)活動(dòng)界面,就需要多少布局文件,因?yàn)楸驹O(shè)計(jì)中并不要求有酷炫的界面效果,所有布局相對(duì)來說比較簡(jiǎn)單。 y[i] = (i)。 // 如果心率曲線上揚(yáng)則調(diào)用心率判斷方法 if (chartListSize 2) if (yTemp 0 amp。 // 響應(yīng)線程 (new Runnable() { Override public void run() { refreshChart()。和其他庫(kù)文件相似,使用AChartEngine引擎也要將相應(yīng)的jar包導(dǎo)入項(xiàng)目庫(kù)文件中,如下圖所示。 } else { (bpmStr)。 int timeListSize = ()。 } // 將接收到的數(shù)據(jù)加入集合 (pluse)。數(shù)據(jù)處理模塊被設(shè)計(jì)為對(duì)接收到的數(shù)據(jù)進(jìn)行一定的算法處理,并在用戶選擇下將接收到的所有數(shù)據(jù)以文件形式保存下來,以便之后靜態(tài)觀察;另一方面,將接收到的數(shù)據(jù)進(jìn)行條件分析,判斷波形的周期,