Đồ án Mô phỏng hiển thị mục tiêu Radar trên mà hình máy tính PC

Chỉ thực hiện được với Radar chủ động thứ cấp:

• Radar chủ động thứ cấp là hệ thống radar có khả năng trao đổi thông tin ( truyền số liệu ) với đối tượng (mục tiêu)

• Quá trình trao đổi số liệu giữa M và RS được thực hiện khi M nằm lọt trong búp sóng radar.

• Thời gian trao đổi số liệu phụ thuộc vào tốc độ quét cánh sóng và kích thước búp sóng của trạm Radar

 

doc96 trang | Chia sẻ: maiphuongdc | Ngày: 11/02/2014 | Lượt xem: 2129 | Lượt tải: 12download
Bạn đang xem nội dung tài liệu Đồ án Mô phỏng hiển thị mục tiêu Radar trên mà hình máy tính PC, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
//k=1,2,3,4,5,6.... //x(t)=150.t.. //y(t)=235.t.... //z(t)=10.t... int i,j,k; float x,y,z; int pb; k=4;//muc tieu so 4 ////////////////////////////////////////////// //mang len mot don vi x=-2*t+250-0.0001*t*t;//dinh nghia cac ham tai day y=3*t-100;//dinh nghia cac ham tai day z=20;//dinh nghia cac ham tai day { //tinh khoang cach////////////////////////// if( sqrt(x*x+y*y+z*z)>300) data_vi_tri[k-1][dung_luong][0]=-0.001; else data_vi_tri[k-1][dung_luong][0]=sqrt(x*x+y*y+z*z); //tinh vi tri moi, trong thuc te thi la so lieu moi nhan duoc if((x>=0)&(y>=0)) data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); else if((x>=0)&(y<0))data_vi_tri[k-1][dung_luong][1]=asin(x/sqrt(y*y+x*x)); else if((x=0))data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); if((x<0)&(y<0)) data_vi_tri[k-1][dung_luong][1]=2*pi+asin(x/sqrt(y*y+x*x)); //doi sang do data_vi_tri[k-1][dung_luong][1]=data_vi_tri[k-1][dung_luong][1]*180/pi; //tinh teta data_vi_tri[k-1][dung_luong][2] =asin(z/data_vi_tri[k-1][dung_luong][0])*180/pi; //tinh do cao h data_vi_tri[k-1][dung_luong][3]=z; //toinh van toc van_toc(k , dung_luong, dung_luong-1); data_vi_tri[k-1][dung_luong][4]=vxt; ///////////////////////////////////////////////////// } float fmax, fmin,tg; fmax=data_thanh_quet_phi; fmin=fmax+phan_giai*tt_chieu_quet; if(fmin>=360)fmin=fmin-360; if(fmin<0)fmin=fmin+360; if(fmax<fmin){tg=fmax;fmax=fmin;fmin=tg;}; pb=0; if((fmax-fmin)fmin)&(data_vi_tri[k-1][dung_luong][1]<fmax)) pb=1; if((fmax-fmin)>180) if((data_vi_tri[k-1][dung_luong][1]fmax)) pb=1; //////////////////////////////////////////////////////dung_luong+1 r so phan tu mang if(pb==0) {trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=0;} ///////////////////////////////////////////////////////////////////// if(pb==1) { trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=1; //dich cac ngan du lieu len tren 1 don vi for(i=1;i<=dung_luong;i++) for (j=0;j<=4;j++)data_vi_tri[k-1][i-1][j] = data_vi_tri[k-1][i][j];//dich du lieu tu day } } ////////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::toa_do_m5(float t) { //k=1,2,3,4,5,6.... //x(t)=150.t.. //y(t)=235.t.... //z(t)=10.t... int i,j,k; float x,y,z; int pb; k=5;//muc tieu so 5 ////////////////////////////////////////////// //mang len mot don vi x=-2*t+250-0.0001*t*t;//dinh nghia cac ham tai day y=3*t-300;//dinh nghia cac ham tai day z=20;//dinh nghia cac ham tai day { //tinh khoang cach////////////////////////// data_vi_tri[k-1][dung_luong][0]=sqrt(x*x+y*y+z*z); if( sqrt(x*x+y*y+z*z)>300) data_vi_tri[k-1][dung_luong][0]=-0.001; else //tinh vi tri moi, trong thuc te thi la so lieu moi nhan duoc if((x>=0)&(y>=0)) data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); else if((x>=0)&(y<0))data_vi_tri[k-1][dung_luong][1]=asin(x/sqrt(y*y+x*x)); else if((x=0))data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); if((x<0)&(y<0)) data_vi_tri[k-1][dung_luong][1]=2*pi+asin(x/sqrt(y*y+x*x)); //doi sang do data_vi_tri[k-1][dung_luong][1]=data_vi_tri[k-1][dung_luong][1]*180/pi; //tinh teta data_vi_tri[k-1][dung_luong][2] =asin(z/data_vi_tri[k-1][dung_luong][0])*180/pi; //tinh do cao h data_vi_tri[k-1][dung_luong][3]=z; //toinh van toc van_toc(k , dung_luong, dung_luong-1); data_vi_tri[k-1][dung_luong][4]=vxt; ///////////////////////////////////////////////////// } float fmax, fmin,tg; fmax=data_thanh_quet_phi; fmin=fmax+phan_giai*tt_chieu_quet; if(fmin>=360)fmin=fmin-360; if(fmin<0)fmin=fmin+360; if(fmax<fmin){tg=fmax;fmax=fmin;fmin=tg;}; pb=0; if((fmax-fmin)fmin)&(data_vi_tri[k-1][dung_luong][1]<fmax)) pb=1; if((fmax-fmin)>180) if((data_vi_tri[k-1][dung_luong][1]fmax)) pb=1; //////////////////////////////////////////////////////dung_luong+1 r so phan tu mang if(pb==0) {trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=0;} ///////////////////////////////////////////////////////////////////// if(pb==1) { trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=1; //dich cac ngan du lieu len tren 1 don vi for(i=1;i<=dung_luong;i++) for (j=0;j<=4;j++)data_vi_tri[k-1][i-1][j] = data_vi_tri[k-1][i][j];//dich du lieu tu day } } ///////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::toa_do_m6(float t) { //k=1,2,3,4,5,6.... //x(t)=150.t.. //y(t)=235.t.... //z(t)=10.t... int i,j,k; float x,y,z; int pb; k=6;//muc tieu so 6 ////////////////////////////////////////////// //mang len mot don vi x=-2*t+250-0.0001*t*t;//dinh nghia cac ham tai day y=3*t-150;//dinh nghia cac ham tai day z=20;//dinh nghia cac ham tai day { //tinh khoang cach////////////////////////// data_vi_tri[k-1][dung_luong][0]=sqrt(x*x+y*y+z*z); if( sqrt(x*x+y*y+z*z)>300) data_vi_tri[k-1][dung_luong][0]=-0.001; else //tinh vi tri moi, trong thuc te thi la so lieu moi nhan duoc if((x>=0)&(y>=0)) data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); else if((x>=0)&(y<0))data_vi_tri[k-1][dung_luong][1]=asin(x/sqrt(y*y+x*x)); else if((x=0))data_vi_tri[k-1][dung_luong][1]=pi-asin(x/sqrt(y*y+x*x)); if((x<0)&(y<0)) data_vi_tri[k-1][dung_luong][1]=2*pi+asin(x/sqrt(y*y+x*x)); //doi sang do data_vi_tri[k-1][dung_luong][1]=data_vi_tri[k-1][dung_luong][1]*180/pi; //tinh teta data_vi_tri[k-1][dung_luong][2] =asin(z/data_vi_tri[k-1][dung_luong][0])*180/pi; //tinh do cao h data_vi_tri[k-1][dung_luong][3]=z; //toinh van toc van_toc(k , dung_luong, dung_luong-1); data_vi_tri[k-1][dung_luong][4]=vxt; ///////////////////////////////////////////////////// } float fmax, fmin,tg; fmax=data_thanh_quet_phi; fmin=fmax+phan_giai*tt_chieu_quet; if(fmin>=360)fmin=fmin-360; if(fmin<0)fmin=fmin+360; if(fmax<fmin){tg=fmax;fmax=fmin;fmin=tg;}; pb=0; if((fmax-fmin)fmin)&(data_vi_tri[k-1][dung_luong][1]<fmax)) pb=1; if((fmax-fmin)>180) if((data_vi_tri[k-1][dung_luong][1]fmax)) pb=1; //////////////////////////////////////////////////////dung_luong+1 r so phan tu mang if(pb==0) {trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=0;} ///////////////////////////////////////////////////////////////////// if(pb==1) { trang_thai_truoc_nua[k-1]=trang_thai_truoc[k-1]; trang_thai_truoc[k-1]=trang_thai_hien_thoi[k-1]; trang_thai_hien_thoi[k-1]=1; //dich cac ngan du lieu len tren 1 don vi for(i=1;i<=dung_luong;i++) for (j=0;j<=4;j++)data_vi_tri[k-1][i-1][j] = data_vi_tri[k-1][i][j];//dich du lieu tu day } } //////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::ve_diem(int kieu_xem,int sa,int ch,float v_t,float radius,float d1,float phi,float teta,int mr,int mg,int mb)//de hien thi lai cac may bay moi khi ve lai man hinh, tham khao gia tri //trong mang data, vi tri tuong doi voi thanh_quet_phi { ////////////////////// int d; if((d10))d=(int)floor(d1/dmax*maxx/4.0);else {d=0;radius=0;}; float fmax,fmin,tg; int tg1; if((d10))if(sa) { ve_tung_diem(radius+2,d,phi,teta,240,240,0); Beep(523,50); } else ve_tung_diem(radius,d,phi,teta,mr,mg,mb); /////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::ve_dai_quat(float r_c, float v_t, int ch, int mr, int mg, int mb) { //khai but CPen pPen(PS_SOLID,0,RGB(mr,mg,mb)); //chon but ve CClientDC pdc(this); pdc.SelectObject(pPen); ////////////////////// //ch chi co gia tri1 hoac -1 float r_c1,v_t1; int R,bn; int xmin,xmax,ymin,ymax,tg; r_c1=(float)r_c*pi/180; v_t1=(float)v_t*pi/180; R=(int)floor (maxx/4); for(bn=0;bn<=20;bn++) { xmin=(int)floor(R*sin(v_t1+ch*r_c1*bn/20)); ymin=(int)floor(R*cos(v_t1+ch*r_c1*bn/20))*-1; pdc.MoveTo(gocx,gocy); pdc.LineTo(gocx+xmin,gocy+ymin); } } ///////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::ve_thanh_quet(int kieu_xem,float v_t1 ,float r_c1,int phan_giai,int mr,int mg,int mb,int ch)//de hien thi lai thanh quet moi khi ve lai man hinh,ham nay co tham //khao bien trang thai chieu quet, va denta phi dich chuyen thay //doi no se lam thay doi toc do quet, { int i,mr1,mg1,mb1; float v_t2,anpha; anpha=1.02; for(i=0;i<phan_giai;i++) {//doi mau mr1=floor(mr/pow(anpha,phan_giai-i)); mg1=floor(mg/pow(anpha,phan_giai-i)); mb1=floor(mb/pow(anpha,phan_giai-i)); v_t2=v_t1+r_c1*ch*i; ve_dai_quat(r_c1,v_t2,ch,mr1,mg1,mb1); } } ////////////////////////////////////////////////////////////////////////////////////////////// void CRada2Dlg::DrawScreen(CDC *pDC)//de hien len xoa man hinh cu di man chan nay cho la mau trang { CBrush*pBrush,*pOldBrush,*pB;//choi ve va choi backup pBrush=new CBrush(RGB(150,150,255));//Tao choi ve mau 255,250,230 pOldBrush=pDC->SelectObject(pBrush);//lwu choi /////////////////////////////////// int i=0; CPen pPen15(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen25(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen35(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen45(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen55(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen65(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; // cac Pen nay co do rong la 8 pixel ////////////////////////////////////////// CRect rect2(35+5,maxy*2/3-5,maxx-35-5,10+5); //dung choi to mau pDC->FillRect(&rect2,pBrush); //CRect rect1(gocx-maxx/4,gocy-maxx/4,gocx+maxx/4,gocy+maxx/4); //pDC->FillRect(&rect,pBrush); //pDC->Ellipse(&rect1); CClientDC pdc(this); //them hinh tron-------------- CPen pens(PS_SOLID,2,RGB(0,0,0)); pDC->SelectObject(pens); pDC->Ellipse(gocx-maxx/4,gocy-maxx/4,gocx+maxx/4,gocy+maxx/4); pDC->Ellipse(gocx-maxx/8,gocy-maxx/8,gocx+maxx/8,gocy+maxx/8); //pDC->Ellipse(gocx-maxx/16-maxx/8,gocy-maxx/16-maxx/8,gocx+maxx/16+maxx/8,gocy+maxx/16+maxx/8); pDC->Ellipse(gocx-maxx/16,gocy-maxx/16,gocx+maxx/16,gocy+maxx/16); pDC->Ellipse(gocx-maxx/32,gocy-maxx/32,gocx+maxx/32,gocy+maxx/32); //ve cac truc toa do pDC->MoveTo(gocx-maxx/4*sin(pi/4),gocy-maxx/4*sin(pi/4)); pDC->LineTo(gocx+maxx/4*sin(pi/4),gocy+maxx/4*sin(pi/4)); pDC->MoveTo(gocx+maxx/4*sin(pi/4),gocy-maxx/4*sin(pi/4)); pDC->LineTo(gocx-maxx/4*sin(pi/4),gocy+maxx/4*sin(pi/4)); pDC->MoveTo(gocx-maxx/4,gocy); pDC->LineTo(gocx+maxx/4,gocy); pDC->MoveTo(gocx,gocy-maxx/4); pDC->LineTo(gocx,gocy+maxx/4); //dua text ra man hinh pDC->SetBkColor(RGB(150,150,255)); pDC->TextOut(gocx-10,gocy-maxx/4,"N 0"); pDC->TextOut(gocx-10,gocy+maxx/4-20,"S 180"); pDC->TextOut(gocx-maxx/4,gocy-20,"W 270"); pDC->TextOut(gocx+maxx/4-40,gocy-20,"E 90"); pDC->TextOut(gocx+maxx/4-20,gocy+10,"300Km"); pDC->TextOut(gocx+maxx/8-15,gocy+10,"150Km"); pDC->TextOut(gocx+maxx/16-15,gocy+10,"75Km"); //////////////////////////////////// i=0;int di=120,dj=0;//hai bien vi tri quyet dinh vi tri khoi chu // di giam thi khoi chu dich sang trai pdc.SetBkColor(RGB(150,150,255)); pdc.SelectObject(pPen15); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar1:"); i++; pdc.SelectObject(pPen25); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar2:"); i++; pdc.SelectObject(pPen35); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar3:"); i++; pdc.SelectObject(pPen45); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar4:"); i++; pdc.SelectObject(pPen55); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar5:"); i++; pdc.SelectObject(pPen65); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar6:"); i++; //xoa choi ve di delete pDC->SelectObject(pOldBrush); // ham nay chi ve 4 hinh tron cac truc toa do va cac Tar } /////////////////////////////////////////////////////////////////////// void CRada2Dlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here maxx=cx; maxy=cy; } //////////////////////////////////////////////////////////////////////// void CRada2Dlg::OnBUTTONStart() { // TODO: Add your control notification handler code here if(start==1)start=0;else start=1; } void CRada2Dlg::OnBUTTONSpeed() { // TODO: Add your control notification handler code here if(thang_toc_do<100) thang_toc_do++; tt_toc_do_quet=(floor)(1+thang_toc_do*0.3); CString str; str.Format("Toc do cap:%d",thang_toc_do+3); m_RSpeed=str; UpdateData(FALSE); } void CRada2Dlg::ve_tung_diem(float radius, float d, float phi, float teta, int mr, int mg, int mb) { CClientDC pdc(this); CBrush*pBrush,*pOldBrush; pBrush =new CBrush(RGB(mr,mg,mb)); //chon choi ve pOldBrush=pdc.SelectObject(pBrush); //khai but CPen pPen(PS_SOLID,1,RGB(mr,mg,mb)); //chon but ve pdc.SelectObject(pPen); //ma ve trong phan nay///////////////////////////////////////////////// int xtam,ytam; float phi1=phi*pi/180; xtam=((int)floor(d*sin(phi1))); ytam=((int)floor(d*cos(phi1)))*(-1);//toa do tam diem xtam=xtam+gocx; ytam=ytam+gocy;//hieu chinh toa do CRect rect(xtam-radius,ytam-radius,xtam+radius,ytam+radius); pdc.FillRect(&rect,pBrush); delete pdc.SelectObject(pOldBrush); ////////////////////////////////////////////////////////////////////// } void CRada2Dlg::OnTimer(UINT nIDEvent) { switch(nhin_thang) { case 1: introduce(); break; case 2: cap_nhat(); break; case 3: cap_nhat_nhin_thang(); break; case 4: cap_nhat_nhin_vong(); break; case 5: xoan_oc(); break; } //////////////////////////////////////////////////////////////////////// //cap nhat thong tin chung CString str; str.Format("Toc do cap:%d",thang_toc_do+3); m_RSpeed=str; UpdateData(FALSE); ////////////////////////////////////////////////////////////////// //////----------- CClientDC pdc(this); //////---------- CString m_str[6],tmp; for(int count =0;count<6;count++) { if((data_vi_tri[count][dung_luong-1][0]>dmax)|(data_vi_tri[count][dung_luong-1][0]<dmin)) m_str[count].Format("Out of range"); else m_str[count].Format("D:%3.2f Phi:%3.2f Teta:%2.2f H:%3.2f Vxt:%4.2f ",data_vi_tri[count][dung_luong-1][0],data_vi_tri[count][dung_luong-1][1],data_vi_tri[count][dung_luong-1][2],data_vi_tri[count][dung_luong-1][3],data_vi_tri[count][dung_luong-1][4]); /////------------------------------- switch(count) { case 0: m_m1 = m_str[count]; break; case 1: m_m2 = m_str[count]; break; case 2: m_m3 = m_str[count]; break; case 3: m_m4 = m_str[count]; break; case 4: m_m5 = m_str[count]; break; case 5: m_m6 = m_str[count]; break; } } UpdateData(FALSE); m_toa_do1++; giay=m_toa_do1*time_update/(float)1000; if(giay>=60){phut++;giay=m_toa_do1=0;}; if(phut>=60){gio++;phut=0;}; if(gio>=24){gio=0;}; tmp.Format("Time : %d : %d : %2.2f ",gio,phut,m_toa_do1*time_update/(float)1000); //cap nhat thoi gian he thong m_toa_do=tmp; UpdateData(FALSE); ////////////////////////////////////////// //chuan bi cho chu ki sau if(start) { timeo=timeo+time_update/(float)1000; data_thanh_quet_phi=data_thanh_quet_phi-tt_chieu_quet*tt_toc_do_quet; if (data_thanh_quet_phi>360) data_thanh_quet_phi=data_thanh_quet_phi-360; if(data_thanh_quet_phi<0)data_thanh_quet_phi=data_thanh_quet_phi+360; toa_do_m1(timeo); toa_do_m2(timeo); toa_do_m3(timeo); toa_do_m4(timeo); toa_do_m5(timeo); toa_do_m6(timeo); //che do bam sat if(tt_bam_sat==1) bam_sat(dt_bam); } /////////////////////////////////////////////////////////////////////// CDialog::OnTimer(nIDEvent); } void CRada2Dlg::OnBUTTONInv() { // TODO: Add your control notification handler code here //if(tt_chieu_quet==1) tt_chieu_quet=-1; //else tt_chieu_quet=1; invert(); } void CRada2Dlg::OnButtonRc() { // TODO: Add your control notification handler code here if(phan_giai<100) phan_giai++; } void CRada2Dlg::OnBUTTONNWave() { // TODO: Add your control notification handler code here if(phan_giai>1)phan_giai--; printf("\a"); } void CRada2Dlg::OnBUTTONDSpeed() { // TODO: Add your control notification handler code here if(thang_toc_do>-2)thang_toc_do--; tt_toc_do_quet=1+thang_toc_do*0.3; CString str; str.Format("Toc do cap:%d",thang_toc_do+3); m_RSpeed=str; UpdateData(FALSE); } void CRada2Dlg::bam_sat(int dt_bam) { float den_ta_phi; if((data_vi_tri[dt_bam][dung_luong-1][0] dmax -40 thi them vao sau (data_vi_tri[dt_bam][dung_luong-1][0]>dmax-40))//them vao sau //phan_giai=30; { time_out[0][1]=0;//trang thai truy tim if (tt_toc_do_quet<0) tt_toc_do_quet=-(1+25*0.3);//thang toc do cao else tt_toc_do_quet=(1+10*0.3); } float van_toc_dt;// van toc cua doi tuong bam sat //trang thai on dinh---------------------------------------------------- if((trang_thai_hien_thoi[dt_bam-1]==1)&(trang_thai_truoc[dt_bam-1]==1)) { den_ta_phi=data_vi_tri[dt_bam-1][dung_luong-1][1]-data_vi_tri[dt_bam-1][dung_luong-2][1]; if(fabs(den_ta_phi)>180){if(den_ta_phi<0)den_ta_phi=den_ta_phi+360; else den_ta_phi=-360+den_ta_phi; } if(den_ta_phi*tt_toc_do_quet*-1*tt_chieu_quet<0)invert(); //tt_toc_do_quet=fabs(den_ta_phi)*1.5; //tinh toa do vi tri chinh giua duong quet float trungg=data_thanh_quet_phi +(float)tt_chieu_quet*phan_giai/2; if(trungg<0)trungg=360+trungg; if(trungg>360)trungg=trungg-360; // tinh vi tri tuong doi cua thanh quet va doi tuong float den= data_vi_tri[dt_bam-1][dung_luong-1][1]- trungg; if(fabs(den)>180) { if(den<0) den=360+den; if(den>0)den=den-360; } //hieu chinh toc do duoi bam // int co_bam=0; if(fabs(den)<=8) {tt_toc_do_quet=fabs(den_ta_phi);time_out[0][1]=1;} if((fabs(den)>2)&time_out[0][1]) {if(den_ta_phi>=0)if (den>0) tt_toc_do_quet=den_ta_phi+0.2;else tt_toc_do_quet=den_ta_phi-0.2; if(den_ta_phi0) tt_toc_do_quet=den_ta_phi+0.2;else tt_toc_do_quet=fabs(den_ta_phi-0.2); } //thu gon canh song neu thich hop //if(fabs(den)<10) phan_giai=15; } //Trang thai truy tim--------------------------------------------------------- if((!trang_thai_hien_thoi[dt_bam-1])&(!trang_thai_truoc[dt_bam-1])) { //phan_giai=30; time_out[0][1]=0;//trang thai truy tim if (tt_toc_do_quet<0) tt_toc_do_quet=-(1+25*0.3);//thang toc do cao else tt_toc_do_quet=(1+10*0.3); } thang_toc_do=floor((tt_toc_do_quet-1)/0.3); } //--------------------------------------------------- void CRada2Dlg::OnBUTTONTrak() { CString str; // TODO: Add your control notification handler code here if(tt_bam_sat==0)tt_bam_sat=1; else {tt_bam_sat=0; //tt_toc_do_quet=(floor)(1+thang_toc_do*0.3); } int i; for(i=0;i<=5;i++)trang_thai_hien_thoi[i]=0; for(i=0;i<=5;i++)trang_thai_truoc[i]=0; if(tt_bam_sat){str.Format("Tracking Tar %d",dt_bam);}else {str.Format("None");} m_tt_bam=str; UpdateData(FALSE); //thang_toc_do=dt_bam; } //------------------------------------------------------------- void CRada2Dlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default char Ischar; Ischar=(char)nChar; if(Ischar=='z') dt_bam=1; if(Ischar=='2') dt_bam=2; if(Ischar=='3') dt_bam=3; if(Ischar=='4') dt_bam=4; if(Ischar=='5') dt_bam=5; if(Ischar=='6') dt_bam=6; //else dt_bam=2; //---------------------------------------------------------------- CDialog::OnKeyDown(nChar, nRepCnt, nFlags); } void CRada2Dlg::invert() { if(tt_chieu_quet==-1){tt_chieu_quet=1; data_thanh_quet_phi=data_thanh_quet_phi-phan_giai; } else {tt_chieu_quet=-1;data_thanh_quet_phi=data_thanh_quet_phi+phan_giai;} } void CRada2Dlg::van_toc(int dt_bam ,int dung_luong1, int dung_luong2) { vxt=(data_vi_tri[dt_bam-1][dung_luong1][0]-data_vi_tri[dt_bam-1][dung_luong2][0])/time_update/(dung_luong1-dung_luong2)*1000*1000; v_teta=cos(data_vi_tri[dt_bam-1][dung_luong1][2]-data_vi_tri[dt_bam-1][dung_luong2][2])*data_vi_tri[dt_bam-1][dung_luong1][0]/time_update/(dung_luong1-dung_luong2); v_phi=sin(data_vi_tri[dt_bam-1][dung_luong1][2])*(data_vi_tri[dt_bam-1][dung_luong1][1]-data_vi_tri[dt_bam-1][dung_luong2][1])*data_vi_tri[dt_bam-1][dung_luong1][0]/time_update/(dung_luong1-dung_luong2); } void CRada2Dlg::cap_nhat_nhin_thang() { int i;int toa_do,sa; int gocx1,dai; //khai but int mr=200, mg=0, mb=0; CPen pPen(PS_SOLID,2,RGB(mr,mg,mb)); CPen pPen1(PS_SOLID,8,RGB(mr,mg,mb)); CPen pPen2(PS_SOLID,8,RGB(20,200,200)); CPen pPen3(PS_SOLID,1,RGB(255,0,0));//vang i=0; CPen pPen15(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen25(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen35(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen45(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen55(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; CPen pPen65(PS_SOLID,8,RGB(data_mau[i][0],data_mau[i][1],data_mau[i][2])); i++; //chon but ve CClientDC pdc(this); pdc.SelectObject(pPen); ////////////////////////////// // CBrush*pBrush,*pOldBrush;//choi ve va choi backup pBrush=new CBrush(RGB(150,150,255));//Tao choi ve mau 255,250,230 pOldBrush=pdc.SelectObject(pBrush);//lwu choi //xac dinh vung ve cua man hinh CRect rect(35,maxy*2/3,maxx-35,10); //dung choi to mau pdc.FillRect(&rect,pBrush); int dd,yy,dd1,yy1,yy2,dd2,dtq; //int sa=0; dtq=maxy*2/3-10; dd=maxy*1/6; dd1=maxy*1/8; dd2=maxy*1/12; yy=(int)floor(maxy*6/20.0); yy1=(int)floor(maxy*9/20.0); yy2=(int)floor(maxy*12/20.0); //hien hinh cac doi tuong //chinh xac cap 1 for(i=0;i<=5;i++) { gocx1=floor(data_vi_tri[i][dung_luong-1][0]*(maxx-70)/dmax); gocx1=gocx1+35; if ( (data_vi_tri[i][dung_luong-1][0]>300)|(data_vi_tri[i][dung_luong-1][0]<0))dai=0; else dai=floor((dmax-data_vi_tri[i][dung_luong-1][0])*dd/dmax); //-------------------------------------------- if(trang_thai_hien_thoi[i]==1) sa=1;else sa=0; if(dai!=0) ve_doan_thang(sa,dai,5,gocx1,yy,data_mau[i][0],data_mau[i][1],data_mau[i][2]); } ///chinh xac cap2 for(i=0;i<=5;i++) { gocx1=(int)floor(data_vi_tri[i][dung_luong-1][0]*(maxx-70)/dmax)%(int)floor((maxx-70)/10.0); gocx1=gocx1*10+35; if( (data_vi_tri[i][dung_luong-1][0]>300)|(data_vi_tri[i][dung_luong-1][0]<0))dai=0; else dai=floor((dmax-data_vi_tri[i][dung_luong-1][0])*dd1/dmax); if(trang_thai_hien_thoi[i]==1) sa=1;else sa=0; if(dai!=0) ve_doan_thang(sa,dai,5,gocx1,yy1,data_mau[i][0],data_mau[i][1],data_mau[i][2]); } //chinh xac cap3 for(i=0;i<=5;i++) { gocx1=(int)floor(data_vi_tri[i][dung_luong-1][0]*(maxx-70)/dmax)%(int)floor((maxx-70)/10.0); gocx1=gocx1*10; gocx1=gocx1%(int)(floor((maxx-70)/10.0)); gocx1=gocx1*10+35; if( (data_vi_tri[i][dung_luong-1][0]>300)|(data_vi_tri[i][dung_luong-1][0]<0))dai=0; else dai=floor((dmax-data_vi_tri[i][dung_luong-1][0])*dd1/dmax); if(trang_thai_hien_thoi[i]==1) sa=1;else sa=0; if(dai!=0) ve_doan_thang(sa,dai,5,gocx1,yy2,data_mau[i][0],data_mau[i][1],data_mau[i][2]); } //ve thanh quet bieu thi pha gocx1=floor(data_thanh_quet_phi*(maxx-70)/360.0); gocx1=gocx1+35; ve_doan_thang(0,dtq,1,gocx1,maxy*2/3,255,255,255); ///////////ki hieu qui uoc pdc.SetBkColor(RGB(150,150,255)); i=0;int di,dj;di=120;dj=0;//hai bien vi tri quyet dinh vi tri khoi chu pdc.SelectObject(pPen15); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar1:"); i++; pdc.SelectObject(pPen25); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar2:"); i++; pdc.SelectObject(pPen35); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar3:"); i++; pdc.SelectObject(pPen45); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(di+maxx-35-190,dj+30+i*15,"Tar4:"); i++; pdc.SelectObject(pPen55); pdc.MoveTo(di+maxx-35-150,dj+40+i*15); pdc.LineTo(di+maxx-35-150+20,dj+40+i*15); pdc.TextOut(

Các file đính kèm theo tài liệu này:

  • docrada2dlg_.doc
  • pdfrada2dlg_.pdf
Tài liệu liên quan