




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、汽車黑匣子項(xiàng)目說(shuō)明1.汽車黑匣子簡(jiǎn)介汽車黑匣子,又稱汽車工作信息記錄儀,汽車安全信息記錄儀,也有人將其形象地稱為汽車電子警察。它能夠完整、準(zhǔn)確地記錄汽車行駛狀態(tài)下的有關(guān)情況,并通過(guò)專用軟件在電腦上再現(xiàn)。本項(xiàng)目只是實(shí)現(xiàn)的是它的軟件部分。2.項(xiàng)目要求1.記錄汽車運(yùn)行時(shí)的日期,時(shí)間和速度;2.經(jīng)可能的多存一些信息:使用位段;3.每滿10次(可根據(jù)用戶要求更改)記錄向文件中存一次;4.文件大小只有1.2K(可根據(jù)用戶要求更改);3.分析建模本次項(xiàng)目主要的關(guān)鍵點(diǎn)有不斷的采集數(shù)據(jù)直到汽車停止,將采集到了數(shù)據(jù)存入到一個(gè)大小固定的文件中(此文件大小可以根據(jù)用戶要求改變),將文件里的數(shù)據(jù)讀出查看汽車行駛時(shí)采集到
2、的數(shù)據(jù)。3.1采集數(shù)據(jù)集存儲(chǔ)通過(guò)調(diào)用time 和localtime函數(shù)來(lái)采集日期和時(shí)間,(由于目前沒(méi)有采集速度的設(shè)備所以速度采用手動(dòng)從鍵盤輸入);程序如下;void input(PPER new)int n=0;printf(請(qǐng)輸入卡車行駛的速度n);scanf(%d,&n);time_t timep;struct tm *p;time(&timep);p=localtime(&timep);new-year=(1900+p-tm_year);new-mouth=(1+p-tm_mon);new-day=p-tm_mday;new-hour=p-tm_hour;new-fen=p-tm_min
3、;new-second=p-tm_sec;new-speed=n;new-next=NULL;由于每條數(shù)據(jù)有比較多的信息所以我們定義一個(gè)結(jié)構(gòu)體來(lái)存儲(chǔ)采集到的每條數(shù)據(jù),數(shù)據(jù)采用位段存儲(chǔ)省空間;程序如下:typedef struct carunsigned int year:12;unsigned int mouth:4;unsigned int day:5;unsigned int hour:5;unsigned int fen:6;unsigned int second:6;unsigned int speed:9;struct car * next;PER,*PPER;由于存儲(chǔ)的數(shù)據(jù)條數(shù)比較
4、多且條數(shù)不固定所以采用鏈表將這些結(jié)構(gòu)體鏈接起來(lái),來(lái)的數(shù)據(jù)往鏈表末尾一掛程序如下:PPER addlink(PPER head)int i=0;PPER ps=head;while(1)PPER new=calloc(1,sizeof(PER);input(new);if(NULL=head)head=new;ps=head;i+;elsehead-next=new;if(0=new-speed)return ps;head=head-next;i+;if(i=N)return ps;3.2將數(shù)據(jù)存入文件中每一次存儲(chǔ)數(shù)據(jù)在文件的位置都要從上一次結(jié)束的位置開(kāi)始,我們定義一個(gè)變量n來(lái)記錄每次文件存儲(chǔ)
5、結(jié)束的位置,并存入文件的開(kāi)頭,第二次要存儲(chǔ)數(shù)據(jù)的時(shí)候先讀取n的數(shù)據(jù)就知道上一次存在哪里,然后接著往后面存;文件的大小我們宏定義一個(gè)FILEMAX來(lái)控制每一次剩余文件的大小不能存儲(chǔ)一條 數(shù)據(jù)時(shí)將文件跳到n后面開(kāi)始存儲(chǔ)程序如下:void inputfile(PPER head)int n=sizeof(int);FILE *fp=fopen(xiangmu.txt,r+);if(NULL=fp)fp=fopen(xiangmu.txt,w);fwrite(&n,sizeof(int),1,fp);elsefread(&n,sizeof(int),1,fp);fseek(fp,n,SEEK_SET)
6、;while(1)if(NULL=head)break;if(FILEMAX-ftell(fp)sizeof(PER)fwrite(head,sizeof(PER),1,fp);head=head-next;elsefseek(fp,sizeof(int),SEEK_SET);n=ftell(fp);rewind(fp);fwrite(&n,sizeof(int),1,fp);fclose(fp);3.3顯示文件由于文件是以二進(jìn)制代碼方式存儲(chǔ),人類無(wú)法直接查看所以要先將文件的內(nèi)容調(diào)入PC機(jī)內(nèi)存中顯示在顯示器上才好查看,文件到內(nèi)存放在鏈表中存儲(chǔ)程序如下:PPER outputfile(PPER
7、head)FILE *fp=fopen(xiangmu.txt,r);if(NULL=fp)printf(文件打開(kāi)失敗n);return NULL;fseek(fp,sizeof(int),SEEK_SET);while(1)PPER new=calloc(1,sizeof(PER);fread(new,sizeof(PER),1,fp);new-next=NULL;if(0!=feof(fp)break;head=addlink1(head,new);fclose(fp);return head;PPER output(PPER head)PPER ps=head;if(NULL=head)
8、return head;while(1)show(ps);ps=ps-next;if(NULL=ps)return head;4.畫流程圖由于時(shí)間有限在此就不畫電子版的流程圖;5.編寫程序程序附帶在同一個(gè)文件夾里,再此就不做編寫6.顯示程序運(yùn)行結(jié)果主菜單頁(yè)請(qǐng)輸入功能號(hào)0-退出1-將采集來(lái)的數(shù)據(jù)輸入鏈表中2-顯示鏈表3-將鏈表里的數(shù)據(jù)存入文件中4-釋放鏈表5-把文件里面的數(shù)據(jù)導(dǎo)入鏈表中6-求最大速度7求平均速度顯示文件記錄的所有數(shù)據(jù)時(shí)間2015年8月5日9時(shí)36分48秒speed93km/h時(shí)間2015年8月5日9時(shí)36分49秒speed94km/h時(shí)間2015年8月5日9時(shí)36分50秒spee
9、d95km/h時(shí)間2015年8月5日9時(shí)36分50秒speed96km/h時(shí)間2015年8月5日9時(shí)36分52秒speed97km/h時(shí)間2015年8月5日9時(shí)36分53秒speed98km/h時(shí)間2015年8月5日9時(shí)36分54秒speed99km/h時(shí)間2015年8月5日9時(shí)36分56秒speed100km/h時(shí)間2015年8月5日9時(shí)37分1秒speed101km/h時(shí)間2015年8月5日9時(shí)37分22秒speed102km/h時(shí)間2015年8月5日9時(shí)37分24秒speed103km/h時(shí)間2015年8月5日9時(shí)37分25秒speed104km/h時(shí)間2015年8月5日9時(shí)37分27秒
10、speed105km/h時(shí)間2015年8月5日9時(shí)37分28秒speed106km/h時(shí)間2015年8月5日9時(shí)37分29秒speed107km/h時(shí)間2015年8月5日9時(shí)37分31秒speed108km/h時(shí)間2015年8月5日9時(shí)37分33秒speed109km/h時(shí)間2015年8月5日9時(shí)37分36秒speed110km/h時(shí)間2015年8月5日9時(shí)37分38秒speed111km/h時(shí)間2015年8月5日9時(shí)32分15秒speed12km/h時(shí)間2015年8月5日9時(shí)32分17秒speed13km/h時(shí)間2015年8月5日9時(shí)32分18秒speed14km/h時(shí)間2015年8月5日9
11、時(shí)32分19秒speed15km/h時(shí)間2015年8月5日9時(shí)32分20秒speed16km/h時(shí)間2015年8月5日9時(shí)32分21秒speed17km/h時(shí)間2015年8月5日9時(shí)32分22秒speed18km/h時(shí)間2015年8月5日9時(shí)32分23秒speed19km/h時(shí)間2015年8月5日9時(shí)32分25秒speed20km/h時(shí)間2015年8月5日9時(shí)32分27秒speed21km/h時(shí)間2015年8月5日9時(shí)32分57秒speed22km/h時(shí)間2015年8月5日9時(shí)32分58秒speed23km/h時(shí)間2015年8月5日9時(shí)32分59秒speed24km/h時(shí)間2015年8月5日9
12、時(shí)33分0秒speed25km/h時(shí)間2015年8月5日9時(shí)33分1秒speed26km/h時(shí)間2015年8月5日9時(shí)33分2秒speed27km/h時(shí)間2015年8月5日9時(shí)33分3秒speed28km/h時(shí)間2015年8月5日9時(shí)33分4秒speed29km/h時(shí)間2015年8月5日9時(shí)33分6秒speed30km/h時(shí)間2015年8月5日9時(shí)33分7秒speed31km/h時(shí)間2015年8月5日9時(shí)33分26秒speed32km/h時(shí)間2015年8月5日9時(shí)33分28秒speed33km/h時(shí)間2015年8月5日9時(shí)33分29秒speed34km/h時(shí)間2015年8月5日9時(shí)33分30秒
13、speed35km/h時(shí)間2015年8月5日9時(shí)33分31秒speed36km/h時(shí)間2015年8月5日9時(shí)33分32秒speed37km/h時(shí)間2015年8月5日9時(shí)33分34秒speed38km/h時(shí)間2015年8月5日9時(shí)33分35秒speed39km/h時(shí)間2015年8月5日9時(shí)33分37秒speed40km/h時(shí)間2015年8月5日9時(shí)33分39秒speed41km/h時(shí)間2015年8月5日9時(shí)34分2秒speed42km/h時(shí)間2015年8月5日9時(shí)34分3秒speed43km/h時(shí)間2015年8月5日9時(shí)34分4秒speed44km/h時(shí)間2015年8月5日9時(shí)34分6秒spee
14、d45km/h時(shí)間2015年8月5日9時(shí)34分7秒speed46km/h時(shí)間2015年8月5日9時(shí)34分8秒speed47km/h時(shí)間2015年8月5日9時(shí)34分9秒speed48km/h時(shí)間2015年8月5日9時(shí)34分10秒speed49km/h時(shí)間2015年8月5日9時(shí)34分12秒speed50km/h時(shí)間2015年8月5日9時(shí)34分13秒speed51km/h時(shí)間2015年8月5日9時(shí)34分47秒speed52km/h時(shí)間2015年8月5日9時(shí)34分48秒speed53km/h時(shí)間2015年8月5日9時(shí)34分50秒speed54km/h時(shí)間2015年8月5日9時(shí)34分51秒speed55
15、km/h時(shí)間2015年8月5日9時(shí)34分52秒speed56km/h時(shí)間2015年8月5日9時(shí)34分53秒speed57km/h時(shí)間2015年8月5日9時(shí)34分54秒speed58km/h時(shí)間2015年8月5日9時(shí)34分56秒speed59km/h時(shí)間2015年8月5日9時(shí)34分57秒speed60km/h時(shí)間2015年8月5日9時(shí)34分58秒speed61km/h時(shí)間2015年8月5日9時(shí)35分14秒speed62km/h時(shí)間2015年8月5日9時(shí)35分15秒speed63km/h時(shí)間2015年8月5日9時(shí)35分16秒speed64km/h時(shí)間2015年8月5日9時(shí)35分17秒speed65
16、km/h時(shí)間2015年8月5日9時(shí)35分18秒speed66km/h時(shí)間2015年8月5日9時(shí)35分19秒speed67km/h時(shí)間2015年8月5日9時(shí)35分20秒speed68km/h時(shí)間2015年8月5日9時(shí)35分21秒speed69km/h時(shí)間2015年8月5日9時(shí)35分23秒speed70km/h時(shí)間2015年8月5日9時(shí)35分24秒speed71km/h時(shí)間2015年8月5日9時(shí)35分38秒speed72km/h時(shí)間2015年8月5日9時(shí)35分40秒speed73km/h時(shí)間2015年8月5日9時(shí)35分41秒speed74km/h時(shí)間2015年8月5日9時(shí)35分42秒speed75
17、km/h時(shí)間2015年8月5日9時(shí)35分43秒speed76km/h時(shí)間2015年8月5日9時(shí)35分45秒speed77km/h時(shí)間2015年8月5日9時(shí)35分46秒speed78km/h時(shí)間2015年8月5日9時(shí)35分47秒speed79km/h時(shí)間2015年8月5日9時(shí)35分48秒speed80km/h時(shí)間2015年8月5日9時(shí)35分49秒speed81km/h時(shí)間2015年8月5日9時(shí)36分14秒speed82km/h時(shí)間2015年8月5日9時(shí)36分15秒speed83km/h時(shí)間2015年8月5日9時(shí)36分16秒speed84km/h時(shí)間2015年8月5日9時(shí)36分18秒speed85km/h時(shí)間2015年8月5日9時(shí)36分19秒speed86km/h時(shí)間2015年8月5日9時(shí)36分20秒speed87km/h時(shí)間2015年8月5日9時(shí)36分21秒spee
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 茶葉訂單合同協(xié)議書
- 高三寒假奮戰(zhàn)協(xié)議書
- 門面解約合同協(xié)議書
- 腦部醫(yī)學(xué)成像技術(shù)
- 飯店風(fēng)險(xiǎn)責(zé)任協(xié)議書
- 長(zhǎng)期采購(gòu)委托協(xié)議書
- 魚(yú)池轉(zhuǎn)讓合同協(xié)議書
- 伯利收購(gòu)切爾西協(xié)議書
- 食堂簽訂安全協(xié)議書
- 音樂(lè)培訓(xùn)合作協(xié)議書
- 鋼板樁安全技術(shù)交底
- 師德師風(fēng)-做“四有”好老師
- 衣食住行見(jiàn)證改革開(kāi)放時(shí)代變遷-(修訂)
- 弱電智能化施工方案
- TQGCML 3946-2024 柴油發(fā)電機(jī)組維護(hù)保養(yǎng)規(guī)范
- DGTJ08-9-2023 建筑抗震設(shè)計(jì)標(biāo)準(zhǔn)
- 輸變電工程質(zhì)量通病防治手冊(cè)
- 新生兒X線檢查
- 2024年江西省中考生物·地理合卷試卷真題(含答案逐題解析)
- 【暑假銜接】知識(shí)點(diǎn)專題13 寫話 (講義+試題) 二升三年級(jí)語(yǔ)文(含答案)部編版
- 老年人智能手機(jī)使用教程課件
評(píng)論
0/150
提交評(píng)論