




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、汽車黑匣子項目說明1.汽車黑匣子簡介汽車黑匣子,又稱汽車工作信息記錄儀,汽車安全信息記錄儀,也有人將其形象地稱為汽車電子警察。它能夠完整、準確地記錄汽車行駛狀態(tài)下的有關情況,并通過專用軟件在電腦上再現(xiàn)。本項目只是實現(xiàn)的是它的軟件部分。2.項目要求1.記錄汽車運行時的日期,時間和速度;2.經(jīng)可能的多存一些信息:使用位段;3.每滿10次(可根據(jù)用戶要求更改)記錄向文件中存一次;4.文件大小只有1.2K(可根據(jù)用戶要求更改);3.分析建模本次項目主要的關鍵點有不斷的采集數(shù)據(jù)直到汽車停止,將采集到了數(shù)據(jù)存入到一個大小固定的文件中(此文件大小可以根據(jù)用戶要求改變),將文件里的數(shù)據(jù)讀出查看汽車行駛時采集到
2、的數(shù)據(jù)。3.1采集數(shù)據(jù)集存儲通過調用time 和localtime函數(shù)來采集日期和時間,(由于目前沒有采集速度的設備所以速度采用手動從鍵盤輸入);程序如下;void input(PPER new)int n=0;printf(請輸入卡車行駛的速度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ù)有比較多的信息所以我們定義一個結構體來存儲采集到的每條數(shù)據(jù),數(shù)據(jù)采用位段存儲省空間;程序如下: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;由于存儲的數(shù)據(jù)條數(shù)比較
4、多且條數(shù)不固定所以采用鏈表將這些結構體鏈接起來,來的數(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ù)存入文件中每一次存儲數(shù)據(jù)在文件的位置都要從上一次結束的位置開始,我們定義一個變量n來記錄每次文件存儲
5、結束的位置,并存入文件的開頭,第二次要存儲數(shù)據(jù)的時候先讀取n的數(shù)據(jù)就知道上一次存在哪里,然后接著往后面存;文件的大小我們宏定義一個FILEMAX來控制每一次剩余文件的大小不能存儲一條 數(shù)據(jù)時將文件跳到n后面開始存儲程序如下: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顯示文件由于文件是以二進制代碼方式存儲,人類無法直接查看所以要先將文件的內容調入PC機內存中顯示在顯示器上才好查看,文件到內存放在鏈表中存儲程序如下:PPER outputfile(PPER
7、head)FILE *fp=fopen(xiangmu.txt,r);if(NULL=fp)printf(文件打開失敗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.畫流程圖由于時間有限在此就不畫電子版的流程圖;5.編寫程序程序附帶在同一個文件夾里,再此就不做編寫6.顯示程序運行結果主菜單頁請輸入功能號0-退出1-將采集來的數(shù)據(jù)輸入鏈表中2-顯示鏈表3-將鏈表里的數(shù)據(jù)存入文件中4-釋放鏈表5-把文件里面的數(shù)據(jù)導入鏈表中6-求最大速度7求平均速度顯示文件記錄的所有數(shù)據(jù)時間2015年8月5日9時36分48秒speed93km/h時間2015年8月5日9時36分49秒speed94km/h時間2015年8月5日9時36分50秒spee
9、d95km/h時間2015年8月5日9時36分50秒speed96km/h時間2015年8月5日9時36分52秒speed97km/h時間2015年8月5日9時36分53秒speed98km/h時間2015年8月5日9時36分54秒speed99km/h時間2015年8月5日9時36分56秒speed100km/h時間2015年8月5日9時37分1秒speed101km/h時間2015年8月5日9時37分22秒speed102km/h時間2015年8月5日9時37分24秒speed103km/h時間2015年8月5日9時37分25秒speed104km/h時間2015年8月5日9時37分27秒
10、speed105km/h時間2015年8月5日9時37分28秒speed106km/h時間2015年8月5日9時37分29秒speed107km/h時間2015年8月5日9時37分31秒speed108km/h時間2015年8月5日9時37分33秒speed109km/h時間2015年8月5日9時37分36秒speed110km/h時間2015年8月5日9時37分38秒speed111km/h時間2015年8月5日9時32分15秒speed12km/h時間2015年8月5日9時32分17秒speed13km/h時間2015年8月5日9時32分18秒speed14km/h時間2015年8月5日9
11、時32分19秒speed15km/h時間2015年8月5日9時32分20秒speed16km/h時間2015年8月5日9時32分21秒speed17km/h時間2015年8月5日9時32分22秒speed18km/h時間2015年8月5日9時32分23秒speed19km/h時間2015年8月5日9時32分25秒speed20km/h時間2015年8月5日9時32分27秒speed21km/h時間2015年8月5日9時32分57秒speed22km/h時間2015年8月5日9時32分58秒speed23km/h時間2015年8月5日9時32分59秒speed24km/h時間2015年8月5日9
12、時33分0秒speed25km/h時間2015年8月5日9時33分1秒speed26km/h時間2015年8月5日9時33分2秒speed27km/h時間2015年8月5日9時33分3秒speed28km/h時間2015年8月5日9時33分4秒speed29km/h時間2015年8月5日9時33分6秒speed30km/h時間2015年8月5日9時33分7秒speed31km/h時間2015年8月5日9時33分26秒speed32km/h時間2015年8月5日9時33分28秒speed33km/h時間2015年8月5日9時33分29秒speed34km/h時間2015年8月5日9時33分30秒
13、speed35km/h時間2015年8月5日9時33分31秒speed36km/h時間2015年8月5日9時33分32秒speed37km/h時間2015年8月5日9時33分34秒speed38km/h時間2015年8月5日9時33分35秒speed39km/h時間2015年8月5日9時33分37秒speed40km/h時間2015年8月5日9時33分39秒speed41km/h時間2015年8月5日9時34分2秒speed42km/h時間2015年8月5日9時34分3秒speed43km/h時間2015年8月5日9時34分4秒speed44km/h時間2015年8月5日9時34分6秒spee
14、d45km/h時間2015年8月5日9時34分7秒speed46km/h時間2015年8月5日9時34分8秒speed47km/h時間2015年8月5日9時34分9秒speed48km/h時間2015年8月5日9時34分10秒speed49km/h時間2015年8月5日9時34分12秒speed50km/h時間2015年8月5日9時34分13秒speed51km/h時間2015年8月5日9時34分47秒speed52km/h時間2015年8月5日9時34分48秒speed53km/h時間2015年8月5日9時34分50秒speed54km/h時間2015年8月5日9時34分51秒speed55
15、km/h時間2015年8月5日9時34分52秒speed56km/h時間2015年8月5日9時34分53秒speed57km/h時間2015年8月5日9時34分54秒speed58km/h時間2015年8月5日9時34分56秒speed59km/h時間2015年8月5日9時34分57秒speed60km/h時間2015年8月5日9時34分58秒speed61km/h時間2015年8月5日9時35分14秒speed62km/h時間2015年8月5日9時35分15秒speed63km/h時間2015年8月5日9時35分16秒speed64km/h時間2015年8月5日9時35分17秒speed65
16、km/h時間2015年8月5日9時35分18秒speed66km/h時間2015年8月5日9時35分19秒speed67km/h時間2015年8月5日9時35分20秒speed68km/h時間2015年8月5日9時35分21秒speed69km/h時間2015年8月5日9時35分23秒speed70km/h時間2015年8月5日9時35分24秒speed71km/h時間2015年8月5日9時35分38秒speed72km/h時間2015年8月5日9時35分40秒speed73km/h時間2015年8月5日9時35分41秒speed74km/h時間2015年8月5日9時35分42秒speed75
17、km/h時間2015年8月5日9時35分43秒speed76km/h時間2015年8月5日9時35分45秒speed77km/h時間2015年8月5日9時35分46秒speed78km/h時間2015年8月5日9時35分47秒speed79km/h時間2015年8月5日9時35分48秒speed80km/h時間2015年8月5日9時35分49秒speed81km/h時間2015年8月5日9時36分14秒speed82km/h時間2015年8月5日9時36分15秒speed83km/h時間2015年8月5日9時36分16秒speed84km/h時間2015年8月5日9時36分18秒speed85km/h時間2015年8月5日9時36分19秒speed86km/h時間2015年8月5日9時36分20秒speed87km/h時間2015年8月5日9時36分21秒spee
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 甘肅省白銀市靖遠縣重點中學2024年中考數(shù)學模試卷含解析
- 廣東滄江中學2024屆中考數(shù)學仿真試卷含解析
- 2025部門級安全培訓考試試題含答案(培優(yōu)A卷)
- 2025年新工人入場安全培訓考試試題研優(yōu)卷
- 2024-2025管理人員崗前安全培訓考試試題【典優(yōu)】
- 2025年新入職工入職安全培訓考試試題含完整答案(有一套)
- 2025公司級安全培訓考試試題【突破訓練】
- 2025企業(yè)主要負責人安全培訓考試試題附參考答案【培優(yōu)A卷】
- 2025年公司三級安全培訓考試試題ab卷
- 工業(yè)分析 第三版 課件全套 盛曉東 第1-6章 試樣的采集和制備 - 安全分析和實驗室安全知識
- 2025年陜西延長石油集團礦業(yè)公司招聘筆試參考題庫含答案解析
- 加油站的物聯(lián)網(wǎng)技術應用
- 《跟上兔子》繪本五年級第1季A-Magic-Card教學課件
- 安全文明離校主題班會
- 2025-2030全球稠油行業(yè)調研及趨勢分析報告
- GB/T 44994-2024聲學助聽器驗配管理
- 銀行成立網(wǎng)點可行性報告范文銀行網(wǎng)點新增的可行性報告
- 2025年職教高考對口升學 護理類 專業(yè)綜合模擬卷(2)(四川適用)(原卷版)
- 《Hadoop技術原理》課件-1.初識Hadoop
- 《關于嚴格規(guī)范涉企行政檢查》知識培訓
- 《電力人工智能樣本增廣技術架構要求》編制說明
評論
0/150
提交評論