c++設(shè)計(jì)技術(shù)文檔(共18頁)_第1頁
c++設(shè)計(jì)技術(shù)文檔(共18頁)_第2頁
c++設(shè)計(jì)技術(shù)文檔(共18頁)_第3頁
c++設(shè)計(jì)技術(shù)文檔(共18頁)_第4頁
c++設(shè)計(jì)技術(shù)文檔(共18頁)_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上實(shí)驗(yàn)一 技術(shù)開發(fā)文檔1.需求分析 (1)顯示輸入的點(diǎn)的坐標(biāo)。 (2)已知直線上兩點(diǎn)的坐標(biāo),求取直線的斜率、截距和直線方程。 (3)已知圓心坐標(biāo),圓的半徑或直徑,求取圓的周長、面積和圓的方程。 (4)已知矩形一點(diǎn)的坐標(biāo),一邊與x軸夾角的弧度值及兩邊長度,求取矩形四個(gè)點(diǎn)坐標(biāo)、圓心坐標(biāo)、周長、面積和矩形方程。 (5)已知拋物線上一點(diǎn)的坐標(biāo)及拋物線的對稱軸,求取準(zhǔn)線方程、拋物線開口方向和拋物線方程。2.概念抽象 (1)定義點(diǎn)類,在點(diǎn)類中定義xinput()、yinput()和point_output()三個(gè)函數(shù)。 (2)定義線類,在線類中定義first_point_input

2、()、second_point_input()、tile_rate(_x1, _y1, _x2, _y2)、intercept(_k, _x1, _y1)和line_output()五個(gè)函數(shù)。 (3)定義圓類,在圓類中定義circle_center_input()、r_or_d_input()、circle_perimeter()、circle_area()和circle_output()五個(gè)函數(shù)。 (4)定義矩形類,在矩形類中定義rectangle_input()、rectangle_points()、rectangle_perimeter_and_area()和rectangle_outp

3、ut()四個(gè)函數(shù)。 (5)定義拋物線類,在拋物線類中定義parabolic_input()和parabolic_output()兩個(gè)函數(shù)。 注:函數(shù)定義及具體應(yīng)用詳見附件3.類的分析及說明附件:點(diǎn)、線、圓、矩形、拋物線的對象定義源代實(shí)驗(yàn)二 技術(shù)開發(fā)文檔1.需求分析 (1) 定義AD、DA板卡類,完成對板卡的封裝; (2) 實(shí)現(xiàn)單通道和多通道的單點(diǎn)采集、多點(diǎn)采集、大批量采集; (3) 實(shí)現(xiàn)單通道和多通道的單點(diǎn)輸出、多點(diǎn)輸出; 2.現(xiàn)實(shí)世界 (1)AD采集 PCI8932板卡AD采集過程為創(chuàng)建設(shè)備對象、判斷創(chuàng)建設(shè)備對象是否成功、用戶從鍵盤選擇輸入量程、設(shè)置硬件參數(shù)、初始化AD、判斷AD初始化是否成

4、功、數(shù)據(jù)采集、電壓轉(zhuǎn)換并顯示。定義AD板卡類,在類中定義創(chuàng)建設(shè)備對象函數(shù)、選擇輸入量程函數(shù)、設(shè)置硬件參數(shù)函數(shù)和初始化AD函數(shù),從而完成對板卡的封裝。(2)DA輸出PCI8932板卡DA輸出的過程為創(chuàng)建設(shè)備對象、判斷創(chuàng)建設(shè)備對象是否成功、用戶從鍵盤上輸入DA通道號、用戶從鍵盤上輸入電壓值和輸出恒定電壓。定義DA板卡類,在類中定義創(chuàng)建設(shè)備對象函數(shù),從而完成對板卡的封裝。注:函數(shù)定義及具體應(yīng)用詳見附件3.類的分析及說明(1)AD采集類圖(2)DA輸出類圖附件:AD采集源代碼 DA輸出源代碼 附件 點(diǎn)、線、圓、矩形、拋物線的對象定義源代碼/該程序用于幾何圖形點(diǎn)、線、圓、矩形、拋物線的對象定義/線由點(diǎn)派

5、生;圓由點(diǎn)派生;矩形由線派生;拋物線由點(diǎn)派生/可以獲得幾何圖形的特征點(diǎn)、特征線等參數(shù)#include#includeusing namespace std;const double PI=3.14159;/定義點(diǎn)類class Point public: double xinput(); /輸入點(diǎn)的橫坐標(biāo) double yinput(); /輸入點(diǎn)的縱坐標(biāo) void point_output(); /輸出點(diǎn)的坐標(biāo) private: double x; double y;/定義線類class Line:public Point public: void first_point_input(); /

6、輸入線上一點(diǎn)的坐標(biāo) void second_point_input();/輸入線上另一點(diǎn)的坐標(biāo) double tile_rate(double _x1,double _y1,double _x2,double _y2);/計(jì)算直線的斜率 double intercept(double _k,double _x1,double _y1);/計(jì)算直線的截距 void line_output();/回顯輸入兩點(diǎn)的坐標(biāo),輸出斜率、截距和直線方程 private:double x1;double y1;double x2;double y2;double k;double b;/定義圓類class Ci

7、rcle:public Point public:void circle_center_input();/輸入圓心坐標(biāo)void r_or_d_input();/輸入半徑或直徑double circle_perimeter();/計(jì)算圓的周長double circle_area();/計(jì)算圓的面積void circle_output();/回顯輸入的圓心坐標(biāo)、半徑或直徑,輸出圓的方程 private:char ans;double ox;double oy;double r;double d;double l;double s;/定義矩形類class Rectangle:public Line

8、public: void rectangle_input();/輸入矩形一點(diǎn)的坐標(biāo),一邊與x軸夾角的弧度值及兩邊長度 void rectangle_points();/計(jì)算矩形四個(gè)點(diǎn)和圓心的坐標(biāo) void rectangle_perimeter_and_area();/計(jì)算矩形周長和面積 void rectangle_output();/回顯輸入,輸出矩形四個(gè)點(diǎn)和圓心坐標(biāo)、周長及面積 private: double x1,y1; double x2,y2; double x3,y3; double x4,y4; double x_O,y_O; double angle; double leng

9、th_1; double length_2; double l; double s;/定義拋物線類class Parabolic:public Point public:void parabolic_input();/輸入拋物線上一點(diǎn)的坐標(biāo)void parabolic_output();/選擇拋物線的對稱軸 /計(jì)算并輸出拋物線方程,準(zhǔn)線方程及拋物線開口方向 private:double x;double y;double p;char ans;int main() char ans;coutPlease enter a letter to choose the geometry graph t

10、hat you want to handle.n;coutp for point and l for linen c for circle and r for rectanglen ans;/選擇要處理的幾何圖形if(ans=p)|(ans=P)/處理點(diǎn) Point point; coutEnter the coordinates of the point:n;/輸入點(diǎn)的坐標(biāo) point.xinput(); point.yinput(); coutthe coordinates of the point is endl;/輸出點(diǎn)的坐標(biāo) point.point_output(); coutend

11、l;else if(ans=l)|(ans=L)/處理線 Line line; coutEnter the coordinates of two points:n;/輸入線上兩點(diǎn)的坐標(biāo) coutEnter the coordinates of the first point:n; line.first_point_input(); coutEnter the coordinates of the second point:n; line.second_point_input(); line.line_output(); coutendl;else if(ans=c)|(ans=C)/處理圓 C

12、ircle circle; coutEnter the coordinates of circle center:n;/輸入圓心坐標(biāo) circle.circle_center_input(); circle.r_or_d_input(); circle.circle_perimeter(); circle.circle_area(); circle.circle_output(); coutendl;else if(ans=r)|(ans=R)/處理矩形 Rectangle rectangle; rectangle.rectangle_input(); rectangle.rectangle_

13、points(); rectangle.rectangle_perimeter_and_area(); rectangle.rectangle_output(); coutendl;else Parabolic parabolic;/處理拋物線 coutEnter the coordinates of one point on the parabolic:n; parabolic.parabolic_input(); parabolic.parabolic_output(); return 0;double Point:xinput()coutPlease input the x axis c

14、oordinate of the point.x;return x;double Point:yinput()coutPlease input the y axis coordinate of the point.y;return y;void Point:point_output() cout(x,y)endl;void Line:first_point_input() x1=xinput(); y1=yinput();void Line:second_point_input() x2=xinput(); y2=yinput();double Line:tile_rate(double _x

15、1,double _y1,double _x2,double _y2) double _k;_k=(_y2-_y1)/(_x2-_x1);return _k;double Line:intercept(double _k,double _x1,double _y1) double _b;_b=_y1-_k*_x1;return _b;void Line:line_output() k=tile_rate(x1,y1,x2,y2);b=intercept(k,x1,y1);coutThe coordinates of the two points are:n(x1,y1) (x2,y2)endl

16、;coutThe tile rate of the line is kendl;coutThe intercept of the line is bendl;coutThe equation expression of the line is ;if(k=0)&(b=0) couty=0endl;else if(k=0)&(b!=0) couty=bendl;else if(k!=0)&(b=0) couty=kxendl;else couty=kx+bendl;void Circle:circle_center_input()ox=xinput();oy=yinput();void Circ

17、le:r_or_d_input()coutans;if(ans=r)coutr;elsecoutd;double Circle:circle_perimeter()if(ans=r)|(ans=R)l=2*PI*r;elsel=PI*d;return l;double Circle:circle_area()if(ans=r)|(ans=R)s=PI*pow(r,2);elses=PI*pow(d/2.0,2);return s;void Circle:circle_output()coutThe coordinates of circle center is (ox,oy)endl;if(a

18、ns=r)|(ans=R)coutThe radius of circle is rendl; if(ox=0)&(oy=0) coutThe equation expression of circle is x*x+y*y= r*rendl;else if(ox=0)&(oy!=0) coutThe equation expression of circle is x*x+(y-oy)*(y-oy)= r*rendl;else if(ox!=0)&(oy=0) coutThe equation expression of circle is (x-ox)*(x-ox)+y*y=r*rendl

19、;else if(ox!=0)&(oy!=0) coutThe equation expression of circle is (x-ox)*(x-ox)+(y-oy)*(y-oy)=r*rendl;else coutIt is impossible.n;elsecoutThe diameter of circle is dendl;if(ox=0)&(oy=0) coutThe equation expression of circle is x*x+y*y= (d/2.0)*(d/2.0)endl;else if(ox=0)&(oy!=0) coutThe equation expres

20、sion of circle is x*x+(y-oy)*(y-oy)= (d/2.0)*(d/2.0)endl;else if(ox!=0)&(oy=0) coutThe equation expression of circle is (x-ox)*(x-ox)+y*y=(d/2.0)*(d/2.0)endl;else if(ox!=0)&(oy!=0) coutThe equation expression of circle is (x-ox)*(x-ox)+(y-oy)*(y-oy)= (d/2.0)*(d/2.0)endl;else coutIt is impossible.n;c

21、outThe perimeter of circle is lendl;coutThe area of circle is sendl;void Rectangle:rectangle_input()coutx1y1;coutangle;coutlength_1length_2;void Rectangle:rectangle_points()x2=x1+length_1*cos(angle);y2=y1+length_1*sin(angle);x3=x1-length_2*sin(angle)+length_1*cos(angle);y3=y1+length_2*cos(angle)+len

22、gth_1*sin(angle);x4=x1-length_2*sin(angle);y4=y1+length_2*cos(angle);x_O=(x1+x3)/2.0;y_O=(y1+y3)/2.0;void Rectangle:rectangle_perimeter_and_area()l=2*(length_1+length_2);s=length_1*length_2;void Rectangle:rectangle_output()coutthe coordinates of the input point is (x1,y1)endl;coutthe input angle is

23、angleendl;coutthe input length of two sides are length_1,length_2endl;coutthe four points of the rectangle are:n(x1,y1) (x2,y2) (x3,y3) (x4,y4)endl;coutthe coordinates of the center point is:n (x_O,y_O)endl;coutthe perimeter of the rectangle is lendl; coutthe area of the rectangle is sendl;void Para

24、bolic:parabolic_input()x=xinput();y=yinput();void Parabolic:parabolic_output()coutPlease input a letter to choose the axis that parabolic symmetry about it.n x stands for x axis and y stands for y axisans;if(ans=x)|(ans=X) p=(y*y)/(2*x);coutThe equation expression of parabolic is y*y=(2*p)xendl;cout

25、The accurate line of parabolic is x=(-p)/2.00)coutThe open direction of parabolic is right.n; else coutThe open direction of parabolic is left.n; else if(ans=y)|(ans=Y)p=(x*x)/(2*y);coutThe equation expression of parabolic is x*x=(2*p)yendl; coutThe accurate line of parabolic is y=(-p)/2.00) coutThe

26、 open direction of parabolic is right.n;else coutThe open direction of parabolic is left.n;elsecoutThe input of letter is wrong.n;附件 AD采集源代碼/ 說明: 本程序演示了如何用程序查詢方式讀取AD數(shù)據(jù)#include stdafx.h#include windows.h#include stdio.h#include conio.h#include PCI8932.h / 驅(qū)動程序接口頭文件, 它位于該演示程序目錄下HANDLE hDevice;DWORD dw

27、ErrorCode;char strErrorMsg256;int InputRange;LONG nReadSizeWords;/ 每次讀取AD數(shù)據(jù)的長度(字)PCI8932_PARA_AD ADPara; / 硬件參數(shù)#define MAX_AD_CHANNELS 4 / 定義最大通道數(shù)#define AD_DATA_LEN 1024*8 / 要讀取和處理的AD數(shù)據(jù)長度(點(diǎn)或字)USHORT ADBufferAD_DATA_LEN; / 分配緩沖區(qū)(存儲原始數(shù)據(jù))class Daqpublic:void CreateDevice(void); int SelectInputRange(vo

28、id);void setparameter(void);void InitDeviceAD(void);int main(int argc, char* argv)BOOL bFirstWait = TRUE; / 為每次等待只顯示一次提示LONG nRetSizeWords;int nADChannel = 0;USHORT ADData;float fVolt;Daq AD;AD.CreateDevice();/創(chuàng)建設(shè)備對象 InputRange = AD.SelectInputRange(); / 要求用戶從鍵盤上選擇輸入量程AD.setparameter();/設(shè)置硬件參數(shù)AD.Ini

29、tDeviceAD();/初始化ADwhile (!kbhit()bFirstWait = TRUE;if (bFirstWait)printf(請等待,您可以按任意鍵退出,但請不要直接關(guān)閉窗口強(qiáng)制退出.n);bFirstWait = FALSE;if(!PCI8932_ReadDeviceAD(hDevice, ADBuffer, nReadSizeWords, &nRetSizeWords)dwErrorCode = PCI8932_GetLastErrorEx(PCI8932_ReadDeviceAD, strErrorMsg);printf(dwErrorCode = %x, %sn,

30、 dwErrorCode, strErrorMsg);getch();PCI8932_ReleaseDeviceAD(hDevice);PCI8932_ReleaseDevice(hDevice); / 釋放設(shè)備對象nADChannel = ADPara.FirstChannel;for(int Index=0; Index ADPara.LastChannel)nADChannel = ADPara.FirstChannel;printf(n);Sleep(200);return 0;/創(chuàng)建設(shè)備對象void Daq:CreateDevice(void) int DeviceLgcID; De

31、viceLgcID = 0;hDevice = PCI8932_CreateDevice(DeviceLgcID); / 創(chuàng)建設(shè)備對象if(hDevice = INVALID_HANDLE_VALUE)dwErrorCode = PCI8932_GetLastErrorEx(PCI8932_CreateDevice, strErrorMsg);printf(dwErrorCode = %x, %sn, dwErrorCode, strErrorMsg);/ 獲取用戶選擇的輸入量程int Daq:SelectInputRange(void)LONG InputRange;Repeat:print

32、f(n);printf(0. -10V +10Vn);printf(1. -5V +5Vn);printf(2. -2.5V +2.5Vn);printf(3. 0V +10Vn);printf(Please Select Input Range0-3:);scanf(%d, &InputRange);if(InputRange3) goto Repeat; / 判斷用戶選擇的量程是否合法,不合法,則重新選擇return InputRange;/設(shè)置硬件參數(shù)void Daq:setparameter(void) memset(&ADPara, 0, sizeof(ADPara); / 將參數(shù)結(jié)

33、構(gòu)初始化為確定值0(強(qiáng)烈建議)/ 預(yù)置硬件參數(shù)ADPara.FirstChannel= 0; / 首通道ADPara.LastChannel= 3; / 末通道ADPara.InputRange= InputRange; / 模擬量輸入量程范圍ADPara.GroundingMode= PCI8932_GNDMODE_SE; / 選擇接地方式為單端ADPara.Gains= PCI8932_GAINS_1MULT; / 程控增益int ChannelCount = ADPara.LastChannel - ADPara.FirstChannel +1;nReadSizeWords = 512 - 512 %ChannelCount; / 將數(shù)據(jù)長度字轉(zhuǎn)換為雙字/初始化ADvoid Daq:InitDeviceAD(void)if(!PCI8932_InitDeviceAD(hDevice, &ADPara)dwErrorCode = PCI8932_GetLastErrorEx(PCI8932_InitDeviceAD, strErrorMsg);printf(dwErrorCode = %x, %sn, dwErrorCode, strErrorMsg);getch();PCI8932_ReleaseDeviceAD(hDe

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論