Tải bản đầy đủ (.doc) (37 trang)

thảo luận đề tài Mô phỏng và hiển thị mục tiêu radar trên màn hình PC. học viện bưu chính viễn thông

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (664.49 KB, 37 trang )

B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
I)N i dung:ộ
Mô ph ng v hi n th m c tiêu radar trên m n hình PC.ỏ à ể ị ụ à
II)Yêu c u :ầ
Ch ng trình mô ph ng radar s c p xung ,ch ng ,quét không gian vòng tròn dùng ươ ỏ ơ ấ ủ độ
cho c nh gi i .ả ớ
Các ch tiêu k thu t:ỉ ỹ ậ
+C ly l m vi c c a i radar :Dự à ệ ủ đà
max
,D
min
.
+T n s sóng mang.ầ ố
+Công su t b c x .ấ ứ ạ
+ c i m xung: r ng xung,chu k xung.Đặ đ ể độ ộ ỳ
+ nh y máy thu.Độ ạ
-Ch ng trình có các tính n ng c th sau:ươ ă ụ ể
+Hi n th 6 m c tiêu cùng m t lúc,quét m c tiêu n o thì m c tiêu ó m i sáng , l i ể ị ụ ộ ụ à ụ đ ớ để ạ
d u v t qu o.ấ ế ỹ đạ
+Quét cánh sóng nhanh ch m .Quét cùng chi u ,ng c chi u kim ng h .ậ ề ượ ề đồ ồ
+T ng bám sát m c tiêu theo góc ph ng v .ự độ ụ ươ ị
+Hi n th b ng c¸cth«ng s c a các m c tiêu :ể ị ả ố ủ ụ
*)C ly m c tiêu.ự ụ
*)Góc ph ng v .ươ ị
*) cao c a m c tiêu.Độ ủ ụ
*)V n t cậ ố .
+Hi n th các thông s k thu t c a Radarể ị ố ỹ ậ ủ
+M n hình kh i ng à ở độ
+M n hình thông s quétà ố
+ M n hình d li u c a radar à ữ ệ ủ


+Hi n th 4m n hình :ể ị à
*)Trang m n hình hi n th nhìn vòng.à ể ị
*)Trang m n hình hi n th c ly D theo cách quét tia i n t trên à ể ị ự đ ệ ư
m n hình nhìn th ng.à ẳ
*)Trang m n hình hi n th c ly D theo cách quét tia i n t trên à ể ị ự đ ệ ư
m n hình vòng tròn.à
*)Trang m n hình hi n th c ly D theo cách quét tia i n t trên à ể ị ự đ ệ ư
m n hình xo n c.à ắ ố
+Có ch i u khi n b ng tay hay t ng (VD:10s thay i trang m n hình 1 l n).ế độ đ ề ể ằ ự độ đổ à ầ
+ chính xác thay i theo trang m n hình. Độ đổ à
III) Ch ng trình mô ph ng radar:ươ ỏ
Ch ng trình mô ph ng radar vi t b ng ngôn ng Visual Basic 6.0.ươ ỏ ế ằ ữ
IV/ Code ch ng trìnhươ
Dim t As Integer
Public i As Integer
Public j As Integer
Public xoan As Integer
Public Lang As Integer
Const pi = 3.14
Public huong As Integer
Public muctieu As Integer
Public ppquet As Integer
Public z1 As Double
1
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Public z2 As Double
Public z3 As Double
Public z4 As Double
Public z5 As Double

Public z6 As Double
Public somt1 As Double 'So muc tieu
Public somt2 As Double
Public somt3 As Double
Public somt4 As Double
Public somt5 As Double
Public somt6 As Double
Public Rmax As Double 'Ban kinh radar
Public kc1 As Double 'Quan li khoang cach muc tieu va tia quet
Public kc2 As Double
Public kc3 As Double
Public kc4 As Double
Public kc5 As Double
Public kc6 As Double
Public k1 As Integer ' quan li thuoc tho
Public k3 As Integer
Public k4 As Integer
Public k5 As Integer
Public k6 As Integer
Public k1tinh As Integer 'Quan li thuoc tho
Public k2tinh As Integer
Public k3tinh As Integer
Public k4tinh As Integer
Public k5tinh As Integer
Public k6tinh As Integer
Public delta1 As Integer 'Quan li goc giua muc tieu va thanh quet
Public quet1 As Integer ' quan li chieu quet
Public quet2 As Integer
Public quet3 As Integer
Public quet4 As Integer

Public quet5 As Integer
Public quet6 As Integer
'Quan li goc giua MT va tia quet
Public delta2 As Integer
Public delta3 As Integer
Public delta4 As Integer
Public delta5 As Integer
Public delta6 As Integer
'Qaun li hien thi muc tieu len thuoc tron
Public T1 As Integer
Public T2 As Integer
Public T3 As Integer
Public T4 As Integer
Public T5 As Integer
Public T6 As Integer
Public T1tinh As Integer
Public T2tinh As Integer
Public T3tinh As Integer
2
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Public T4tinh As Integer
Public T5tinh As Integer
Public T6tinh As Integer
'Quan li MT hien thi tren thuoc nhieu vong tron
Public Mu1tinh As Integer
Public Mu2tinh As Integer
Public Mu3tinh As Integer
Public Mu4tinh As Integer
Public Mu5tinh As Integer

Public Mu6tinh As Integer
Private Sub Circl_Click()
ppquet = 2
End Sub
Private Sub Direct_Click()
ppquet = 1
End Sub
Private Sub Display_Click()
If Lang = 0 Then
If Display.Caption = "Ti p t c" Thenế ụ
Timer1.Enabled = True
Display.Caption = "D ng"ừ
Else
Display.Caption = "Ti p t c"ế ụ
Timer1.Enabled = False
End If
End If
If Lang = 1 Then
If Display.Caption = "Continue" Then
Timer1.Enabled = True
Display.Caption = "Pause"
Else
Display.Caption = "Continue"
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Exit1_Click()
End
End Sub

Private Sub English_Click()
English1
Lang = 1
End Sub
Private Sub FileExit_Click()
End
End Sub
3
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Private Sub FileNew_Click()
Form2.Show
End Sub
Private Sub FileOpen_Click()
'On Error GoTo DialogError
With CommonDialog1
' CancelError = True
.Filter = "Executables (*.exe)|*.exe|Com Files (*.frm)|*.frm|Batch Files (*.vpb)|*.vpb"
.FilterIndex = 1
.DialogTitle = "Select a program to open"
.ShowOpen

'MsgBox "You selected " & .FileName
End With
End Sub
Private Sub Form_Load()
Thuan.Value = True
tatca.Value = True
t = 0
i = 0 'Quan li tia quet

j = 0 'Quan li goc quet
Lang = 0
somt1 = 0
somt2 = 0
somt3 = 0
somt4 = 0
somt5 = 0
somt6 = 0
' Cac tham so de quan li muc tieu tren cac loai thuoc
thangtinh.Visible = False
thangtho.Visible = False
M2tho.Visible = False
M2tinh.Visible = False
M3tinh.Visible = False
M3tho.Visible = False
M4tho.Visible = False
M4tinh.Visible = False
M5tho.Visible = False
M5tinh.Visible = False
M6tho.Visible = False
M6tinh.Visible = False
Mu1.Visible = False
Mu2.Visible = False
Mu3.Visible = False
Mu4.Visible = False
Mu5.Visible = False
4
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Mu6.Visible = False

End Sub
Private Sub HelpMe_Click()
MsgBox " Nguyem Khac Tinh Lpo DT7-K46 Khoa Dien Tu Vien Thong ", vbOKOnly, "About
Me"
End Sub
Private Sub HelpPro_Click()
MsgBox " Bai tap lon mon hoc Dinh Vi Dan Duong ", vbOKOnly, "About Pro"
End Sub
Private Sub Muctieu1_Click()
muctieu = 1
End Sub
Private Sub Muctieu2_Click()
muctieu = 2
End Sub
Private Sub Muctieu3_Click()
muctieu = 3
End Sub
Private Sub Muctieu4_Click()
muctieu = 4
End Sub
Private Sub Muctieu5_Click()
muctieu = 5
End Sub
Private Sub Muctieu6_Click()
muctieu = 6
End Sub
Private Sub MulCircle_Click()
ppquet = 3
End Sub
Private Sub Nguoc_Click()

huong = 1
End Sub
Private Sub Option4_Click()
ppquet = 4
End Sub
Private Sub Setting_Click()
5
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Form2.Show
End Sub
Private Sub tatca_Click()
muctieu = 0
End Sub
Private Sub Thuan_Click()
huong = 0
End Sub
Private Sub Timer1_Timer()
'//////////////////////////
For xoan = 0 To 1080
Form1.Line (8800 + xoan * Cos(pi * xoan / 180), 2700 + xoan * Sin(pi * xoan / 180))-(8800 +
(xoan + 1) * Cos(pi * (xoan + 1) / 180), 2700 + (xoan + 1) * Sin((xoan + 1) * pi / 180))
Next
'/////////////////////////////////
Label100.Caption = Time
Ngay.Caption = Date
Rmax = 20
Label19.Caption = Rmax
Dthmax.Caption = Rmax
Dthmin.Caption = Rmax / 10

'Somuctieu.Caption = somt1 + somt2 + somt3 + somt4 + somt5 + somt6
Dim gocpv1 As Double
'Hien thi MT len man hinh radar
MT1
MT2
MT3
MT4
MT5
MT6
'chuong trinh tinh goc lech de quet theo muc tieu
delta1 = gocpv(M1.Left, M1.Top) - gocpv(Stic.x2, Stic.y2)
delta2 = gocpv(M2.Left, M2.Top) - gocpv(Stic.x2, Stic.y2)
delta3 = gocpv(M3.Left, M3.Top) - gocpv(Stic.x2, Stic.y2)
delta4 = gocpv(M4.Left, M4.Top) - gocpv(Stic.x2, Stic.y2)
delta5 = gocpv(M5.Left, M5.Top) - gocpv(Stic.x2, Stic.y2)
delta6 = gocpv(M6.Left, M6.Top) - gocpv(Stic.x2, Stic.y2)
If muctieu = 0 Then
tiaquet
' Hienthi du lieu len cac Edit
Display1
Display2
Display3
Display4
Display5
Display6
6
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
'Hien thi MT len thuoc
'Quet thang

If ppquet = 1 Then
Quetthang
TM1
TM2
TM3
TM4
TM5
TM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT1
TrMT2
TrMT3
TrMT4
TrMT5
TrMT6
End If
'neu la qet nhieu vong
If ppquet = 3 Then
Quetnhieu
MulMT1
MulMT2
MulMT3
MulMT4
MulMT5
MulMT6
End If
If ppquet = 4 Then

Form1.Frame5.Visible = False
End If

End If
'///////////////////////////////////////////////
If muctieu = 1 Then
Display1
UnDisplay2
UnDisplay3
UnDisplay4
UnDisplay5
UnDisplay6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang
TM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5
7
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
UnTM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc

UnTM3
UnTM4
UnTM5
UnTM6
End If
If ppquet = 3 Then
Quetnhieu
MulMT1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5
UnTM6
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False
End If
'Chuong trinh bam muc tieu
delta1 = gocpv(M1.Left, M1.Top) - gocpv(Stic.x2, Stic.y2)
If (delta1 >= 6) Then
quetthuan
quet1 = 1
End If
If (delta1 <= -6) Then
quetnguoc
quet1 = 2
End If
If (-6 < delta1) And (delta1 < 6) Then
If quet1 = 1 Then
quetthuan

quet1 = 1
End If
If quet1 = 2 Then
quetnguoc
quet1 = 2
End If
End If
If z1 > 1500 Then
tatca.Value = True
Muctieu1.Value = False
End If
If t > 360 Then
8
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
t = 0
End If
'Label16.Caption = delta1
End If
'//////////////////////////////////////////////////////
If muctieu = 2 Then
UnDisplay1
Display2
UnDisplay3
UnDisplay4
UnDisplay5
UnDisplay6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang

UnTM1
TM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5
UnTM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT2
UnTM1
' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5
UnTM6
End If
If ppquet = 3 Then
Quetnhieu
MulMT2
UnTM1

UnTM3
UnTM4
UnTM5
UnTM6
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False

End If
'Chuong trinh bam muc tieu
delta2 = gocpv(M2.Left, M2.Top) - gocpv(Stic.x2, Stic.y2)
If (delta2 >= 6) Then
quetthuan
9
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
quet2 = 1
End If
If (delta2 <= -6) Then
quetnguoc
quet2 = 2
End If
If (-6 < delta2) And (delta2 < 6) Then
If quet2 = 1 Then
quetthuan
quet2 = 1
End If
If quet2 = 2 Then
quetnguoc
quet2 = 2
End If
End If
'Chuong trinh kiem tra xem con trong radar
If z2 > 1500 Then
tatca.Value = True
Muctieu2.Value = False
End If
If t > 360 Then

t = 0
End If
End If
If muctieu = 3 Then
UnDisplay1
UnDisplay2
Display3
UnDisplay4
UnDisplay5
UnDisplay6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
TM3
UnTM4
UnTM5
UnTM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT3
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc

UnTM4
UnTM5
UnTM6

10
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
End If
If ppquet = 3 Then
Quetnhieu
MulMT3
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc

UnTM4
UnTM5
UnTM6
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False
End If
'Chuong trinh bam muc tieu
delta1 = gocpv(M3.Left, M3.Top) - gocpv(Stic.x2, Stic.y2)
If (delta3 >= 6) Then
quetthuan
quet3 = 1
End If
If (delta3 <= -6) Then
quetnguoc
quet3 = 2
End If
If (-6 < delta3) And (delta3 < 6) Then
If quet3 = 1 Then
quetthuan

quet3 = 1
End If
If quet3 = 2 Then
quetnguoc
quet3 = 2
End If
End If
If z3 > 1500 Then
tatca.Value = True
Muctieu3.Value = False
End If
If t > 360 Then
t = 0
End If
End If
'//////////////////////////////////////////////////
If muctieu = 4 Then
UnDisplay1
UnDisplay2
UnDisplay3
Display4
11
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
UnDisplay5
UnDisplay6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang
UnTM1

UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
TM4
UnTM5
UnTM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT4
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3

UnTM5
UnTM6
End If
If ppquet = 3 Then
Quetnhieu
MulMT4
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3

UnTM5
UnTM6
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False
End If

'Chuong trinh bam muc tieu
delta4 = gocpv(M4.Left, M4.Top) - gocpv(Stic.x2, Stic.y2)
If (delta4 >= 6) Then
quetthuan
quet4 = 1
End If
If (delta4 <= -6) Then
quetnguoc
quet4 = 2
End If
If (-6 < delta4) And (delta4 < 6) Then
If quet4 = 1 Then
quetthuan
12
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
quet4 = 1
End If
If quet4 = 2 Then
quetnguoc
quet4 = 2
End If
End If
If z4 > 1500 Then
tatca.Value = True
Muctieu4.Value = False
End If
If t > 360 Then
t = 0
End If

End If
'///////////////////////////////////
If muctieu = 5 Then
UnDisplay1
UnDisplay2
UnDisplay3
UnDisplay4
Display5
UnDisplay6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang
TM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
TM5
UnTM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
TrMT5
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4

UnTM6
End If

If ppquet = 3 Then
Quetnhieu
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
13
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ

UnTM6
MulMT5
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False
End If
'Chuong trinh bam muc tieu
delta5 = gocpv(M5.Left, M5.Top) - gocpv(Stic.x2, Stic.y2)
If (delta5 >= 6) Then
quetthuan
quet5 = 1
End If
If (delta5 <= -6) Then
quetnguoc
quet5 = 2
End If
If (-6 < delta5) And (delta5 < 6) Then
If quet5 = 1 Then
quetthuan
quet5 = 1

End If
If quet5 = 2 Then
quetnguoc
quet5 = 2
End If
End If
If z5 > 1500 Then
tatca.Value = True
Muctieu5.Value = False
End If
If t > 360 Then
t = 0
End If
End If
'////////////////////////////////////////////////
If muctieu = 6 Then
UnDisplay1
UnDisplay2
UnDisplay3
UnDisplay4
UnDisplay5
Display6
'Chon phuong phap quet
If ppquet = 1 Then
Quetthang
TM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
14

B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
UnTM5
TM6
End If
'NEU LA QUET TRON
If ppquet = 2 Then
Quettron
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5

TrMT6
End If
'neu la quet nhieu vong
If ppquet = 3 Then
Quetnhieu
UnTM1
UnTM2 ' chuong trinh hien thi muc tieu len thuoc
UnTM3
UnTM4
UnTM5

MulMT6
End If
If ppquet = 4 Then
Form1.Frame5.Visible = False
End If

'Chuong trinh bam muc tieu
delta6 = gocpv(M6.Left, M6.Top) - gocpv(Stic.x2, Stic.y2)
If (delta6 >= 6) Then
quetthuan
quet6 = 1
End If
If (delta6 <= -6) Then
quetnguoc
quet6 = 2
End If
If (-6 < delta6) And (delta6 < 6) Then
If quet6 = 1 Then
quetthuan
quet6 = 1
End If
If quet6 = 2 Then
quetnguoc
quet6 = 2
End If
End If
If z6 > 1500 Then
tatca.Value = True
15
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Muctieu6.Value = False
End If
If t > 360 Then
t = 0
End If

End If
i = i + 0.7
If (z1 > 1500) And (z2 > 1500) And (z3 > 1500) And (z4 > 1500) And (z5 > 1500) And (z6 >
1500) Then
Stic.x1 = 1700
Stic.y1 = 1600
Stic.y2 = 120
Stic.x2 = 1700
End If
End Sub
Public Sub Quetthang()
Khongquettron
Khongquetnhieu
Form1.Frame5.Visible = True
Ththo.Visible = True
Thtinh.Visible = True
tinh0.Visible = True
tinh1.Visible = True
tinh2.Visible = True
tinh3.Visible = True
tinh4.Visible = True
tinh5.Visible = True
tinh6.Visible = True
tinh7.Visible = True
tinh8.Visible = True
tinh9.Visible = True
tinh10.Visible = True
th0.Visible = True
th1.Visible = True
th2.Visible = True

th3.Visible = True
th4.Visible = True
th5.Visible = True
th6.Visible = True
th7.Visible = True
th8.Visible = True
th9.Visible = True
th10.Visible = True
Dthmax.Visible = True
Dthmin.Visible = True
End Sub
Public Sub Khongquetthang()
Ththo.Visible = False
Thtinh.Visible = False
16
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
tinh0.Visible = False
tinh1.Visible = False
tinh2.Visible = False
tinh3.Visible = False
tinh4.Visible = False
tinh5.Visible = False
tinh6.Visible = False
tinh7.Visible = False
tinh8.Visible = False
tinh9.Visible = False
tinh10.Visible = False
th0.Visible = False
th1.Visible = False

th2.Visible = False
th3.Visible = False
th4.Visible = False
th5.Visible = False
th6.Visible = False
th7.Visible = False
th8.Visible = False
th9.Visible = False
th10.Visible = False
'Dthmax.Visible = False
Dthmin.Visible = False
End Sub
Public Sub Khongquettron()
trontinh.Visible = False
Trontho1.Visible = False
Trontho2.Visible = False
Trontho3.Visible = False
trontho4.Visible = False
Nhieutinh1.Visible = False
Nhieutinh2.Visible = False
Nhieutinh3.Visible = False
Nhieutinh4.Visible = False
mtrontho.Visible = False
mnhieutinh.Visible = False
End Sub
Public Sub Quettron()
Khongquetthang
Form1.Frame5.Visible = True
Khongquetnhieu
Dthmax.Visible = True

UnTM
trontinh.Visible = True
Trontho1.Visible = True
Trontho2.Visible = True
Trontho3.Visible = True
trontho4.Visible = True
Nhieutinh1.Visible = True
Nhieutinh2.Visible = True
17
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Nhieutinh3.Visible = True
Nhieutinh4.Visible = True
mtrontho.Visible = True
mnhieutinh.Visible = True
End Sub
Public Sub Khongquetnhieu()
Multinh.Visible = False
Nhieutho1.Visible = False
Nhieutho2.Visible = False
Nhieutho3.Visible = False
Nhieutho4.Visible = False
Nhieutinh1.Visible = False
Nhieutinh2.Visible = False
Nhieutinh3.Visible = False
Nhieutinh4.Visible = False
mtrontho.Visible = False
mnhieutinh.Visible = False
mnhieutho.Visible = False
End Sub

Public Sub Quetnhieu()
Khongquetthang
Khongquettron
Form1.Frame5.Visible = True
Dthmax.Visible = True
Multinh.Visible = True
trontinh.Visible = True
Nhieutho1.Visible = True
Nhieutho2.Visible = True
Nhieutho3.Visible = True
Nhieutho4.Visible = True
Nhieutinh1.Visible = True
Nhieutinh2.Visible = True
Nhieutinh3.Visible = True
Nhieutinh4.Visible = True
Trontho1.Visible = True
Trontho2.Visible = True
Trontho3.Visible = True
trontho4.Visible = True
mtrontho.Visible = True
mnhieutinh.Visible = True
mnhieutho.Visible = True
End Sub
Public Sub MT1()
z1 = Sqr((1700 - M1.Left) * (1700 - M1.Left) + (M1.Top - 1600) * (M1.Top - 1600))
M1.Width = 50
M1.Height = 50
M1.Left = 960 + 2 * i
M1.Top = 2640 + 0.5 * i
18

B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
If z1 < 1500 Then
M1.Visible = True
Else
M1.Visible = False
End If
End Sub
Public Sub MT2()
z2 = Sqr((1700 - M2.Left) * (1700 - M2.Left) + (M2.Top - 1600) * (M2.Top - 1600))
M2.Width = 50
M2.Height = 50
M2.Left = 240 + i
M2.Top = 2640 - 2 * i
If z2 < 1500 Then
M2.Visible = True
Else
M2.Visible = False
End If
End Sub
Public Sub MT3()
z3 = Sqr((1700 - M3.Left) * (1700 - M3.Left) + (M3.Top - 1600) * (M3.Top - 1600))
M3.Width = 50
M3.Height = 50
M3.Left = 2040 + 0.5 * i
M3.Top = 2280 + 0.5 * i
If z3 < 1500 Then
M3.Visible = True
Else
M3.Visible = False

End If
End Sub
Public Sub MT4()
z4 = Sqr((1700 - M4.Left) * (1700 - M4.Left) + (M4.Top - 1600) * (M4.Top - 1600))
M4.Width = 50
M4.Height = 50
M4.Left = 2880 - 0.1 * i
M4.Top = 840 + 2 * i
If z4 < 1500 Then
M4.Visible = True
Else
M4.Visible = False
End If
End Sub
Public Sub MT5()
z5 = Sqr((1700 - M5.Left) * (1700 - M5.Left) + (M5.Top - 1600) * (M5.Top - 1600))
M5.Width = 50
M5.Height = 50
M5.Left = 1400 - 0.1 * i
M5.Top = 960 - i
If z5 < 1500 Then
M5.Visible = True
Else
M5.Visible = False
19
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
End If
End Sub
Public Sub MT6()

z6 = Sqr((1700 - M6.Left) * (1700 - M6.Left) + (M6.Top - 1600) * (M6.Top - 1600))
M6.Width = 50
M6.Height = 50
M6.Left = 2400 - 0.5 * i
M6.Top = 360 + 3 * i
If z6 < 1500 Then
M6.Visible = True
Else
M6.Visible = False
End If
End Sub
Public Function Distance(xa As Double, ya As Double, xb As Double, yb As Double) As Double
Dim kq As Double
kq = Sqr((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb))
Distance = kq
End Function
Public Function Check(x1 As Double, y1 As Double, x2 As Double, y2 As Double, x3 As
Double, y3 As Double) As Double
Dim cs As Double
Dim sn As Double
Dim a As Double
Dim b As Double
Dim c As Double
Dim h As Double
a = Distance(x1, y1, x2, y2)
b = Distance(x1, y1, x3, y3)
c = Distance(x2, y2, x3, y3)
cs = (a * a + b * b - c * c) / (2 * a * b)
sn = Sqr(1 - cs * cs)
h = b * sn

Check = h
End Function
Public Function gocpv(a1 As Double, a2 As Double) As Double
Dim goc As Double
If (a1 > 1700) And (a2 < 1600) Then
goc = -(180 / pi) * Atn((a1 - 1700) / (a2 - 1600))
End If
If (a1 > 1700) And (a2 > 1600) Then
goc = 180 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600))
End If
If (a1 < 1700) And (a2 < 1600) Then
goc = 360 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600))
End If
If (a1 < 1700) And (a2 > 1600) Then
goc = 180 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600))
End If
gocpv = goc
End Function
20
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Public Sub TM1()
If D1.Text > 0 Then
k1 = 10 * D1.Text \ Rmax
k1tinh = 100 * (D1.Text - Rmax * k1 / 10) \ Rmax
thangtho.Visible = True
thangtinh.Visible = True
thangtho.Left = 200 + k1 * 280
thangtho.Top = 1250
thangtho.Width = 50

thangtho.Height = 100
thangtinh.Left = 200 + k1tinh * 280
thangtinh.Top = 1650
thangtinh.Width = 50
thangtinh.Height = 100
End If
End Sub
Public Sub TM2()
If D2.Text > 0 Then
k2 = 10 * D2.Text \ Rmax
k2tinh = 100 * (D2.Text - Rmax * k2 / 10) \ Rmax
M2tho.Visible = True
M2tinh.Visible = True
M2tho.Left = 200 + k2 * 280
M2tho.Top = 1350
M2tho.Width = 50
M2tho.Height = 50
M2tinh.Left = 200 + k2tinh * 280
M2tinh.Top = 1750
M2tinh.Width = 50
M2tinh.Height = 50
End If
End Sub
Public Sub TM3()
If D3.Text > 0 Then
k3 = 10 * D3.Text \ Rmax
k3tinh = 100 * (D3.Text - Rmax * k3 / 10) \ Rmax
M3tho.Visible = True
M3tinh.Visible = True
M3tho.Left = 200 + k3 * 280

M3tho.Top = 1350
M3tho.Width = 100
M3tho.Height = 50
M3tinh.Left = 200 + k3tinh * 280
M3tinh.Top = 1750
M3tinh.Width = 100
M3tinh.Height = 50
End If
End Sub
Public Sub TM4()
If D4.Text > 0 Then
k4 = 10 * D4.Text \ Rmax
k4tinh = 100 * (D4.Text - Rmax * k4 / 10) \ Rmax
21
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
M4tho.Visible = True
M4tinh.Visible = True
M4tho.Left = 200 + k4 * 280
M4tho.Top = 1350
M4tho.Width = 50
M4tho.Height = 50
M4tinh.Left = 200 + k4tinh * 280
M4tinh.Top = 1750
M4tinh.Width = 50
M4tinh.Height = 50
End If
End Sub
Public Sub TM5()
If D5.Text > 0 Then

k5 = 10 * D5.Text \ Rmax
k5tinh = 100 * (D5.Text - Rmax * k5 / 10) \ Rmax
M5tho.Visible = True
M5tinh.Visible = True
M5tho.Left = 200 + k5 * 280
M5tho.Top = 1350
M5tho.Width = 50
M5tho.Height = 50
M5tinh.Left = 200 + k5tinh * 280
M5tinh.Top = 1750
M5tinh.Width = 50
M5tinh.Height = 50
End If
End Sub
Public Sub TM6()
If D6.Text > 0 Then
k6 = 10 * D6.Text \ Rmax
k6tinh = 100 * (D6.Text - Rmax * k6 / 10) \ Rmax
M6tho.Visible = True
M6tinh.Visible = True
M6tho.Left = 200 + k6 * 280
M6tho.Top = 1350
M6tho.Width = 50
M6tho.Height = 50
M6tinh.Left = 200 + k6tinh * 280
M6tinh.Top = 1750
M6tinh.Width = 50
M6tinh.Height = 50
End If
End Sub

Public Sub UnTM1()
thangtinh.Visible = False
thangtho.Visible = False
Mu1.Visible = False
End Sub
Public Sub UnTM2()
M2tho.Visible = False
22
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
M2tinh.Visible = False
Mu2.Visible = False
End Sub
Public Sub UnTM3()
M3tho.Visible = False
M3tinh.Visible = False
Mu3.Visible = False
End Sub
Public Sub UnTM4()
M4tho.Visible = False
M4tinh.Visible = False
Mu4.Visible = False
End Sub
Public Sub UnTM5()
M5tho.Visible = False
M5tinh.Visible = False
Mu5.Visible = False
End Sub
Public Sub UnTM6()
M6tho.Visible = False

M6tinh.Visible = False
Mu6.Visible = False
End Sub
Public Sub UnTM()
UnTM1
UnTM2
UnTM3
UnTM4
UnTM5
UnTM6
End Sub
Public Sub UnDisplay1()
D1.Text = 0
PV1.Text = 0
H1.Text = 0
V1.Text = 0
NG1.Text = 0
End Sub
Public Sub UnDisplay2()
D2.Text = 0
PV2.Text = 0
H2.Text = 0
V2.Text = 0
NG2.Text = 0
End Sub
Public Sub UnDisplay3()
D3.Text = 0
PV3.Text = 0
H3.Text = 0
V3.Text = 0

NG3.Text = 0
End Sub
23
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
Public Sub UnDisplay4()
D4.Text = 0
PV4.Text = 0
H4.Text = 0
V4.Text = 0
NG4.Text = 0
End Sub
Public Sub UnDisplay5()
D5.Text = 0
PV5.Text = 0
H5.Text = 0
V5.Text = 0
NG5.Text = 0
End Sub
Public Sub UnDisplay6()
D6.Text = 0
PV6.Text = 0
H6.Text = 0
V6.Text = 0
NG6.Text = 0
End Sub
Public Sub Display1()
kc1 = Check(1700, 1600, Stic.x2, Stic.y2, M1.Left, M1.Top)
If (kc1 < 50) And (Abs(Stic.y2 - M1.Top) < 1700) And (z1 < 1500) Then
D1.Text = z1 * Rmax / 1500

PV1.Text = gocpv(M1.Left, M1.Top)
H1.Text = 14.7 + 0.5 * Sin(i)
somt1 = 1
V1.Text = 10 * (14.7 + 0.5 * Sin(i)) - 0.3 * kc1
NG1.Text = (180 / pi) * Atn(H1.Text / kc1)
End If
If z1 > 1500 Then
somt1 = 0
UnDisplay1
thangtho.Visible = False
thangtinh.Visible = False
Mu1.Visible = False
End If
End Sub
Public Sub Display2()
kc2 = Check(1700, 1600, Stic.x2, Stic.y2, M2.Left, M2.Top)
If (kc2 < 50) And (Abs(Stic.x2 - M2.Left) < 1700) And (z2 < 1500) Then
D2.Text = z2 * Rmax / 1500
PV2.Text = gocpv(M2.Left, M2.Top)
H2.Text = 14.4 - 0.5 * Sin(i)
V2.Text = 10 * (14.4 - 0.5 * Sin(i)) - 0.3 * kc2
somt2 = 1
NG2.Text = (180 / pi) * Atn(H2.Text / kc2)
End If
If z2 > 1500 Then
UnDisplay2
24
B i t p l n môn h c: nh v d n à ậ ớ ọ Đị ị ẫ
ngđườ
M2tho.Visible = False

M2tinh.Visible = False
Mu2.Visible = False
somt2 = 0
End If
End Sub
Public Sub Display3()
kc3 = Check(1700, 1600, Stic.x2, Stic.y2, M3.Left, M3.Top)
If (kc3 < 50) And (Abs(Stic.y2 - M3.Top) < 1700) And (z3 < 1500) Then
D3.Text = z3 * Rmax / 1500
PV3.Text = gocpv(M3.Left, M3.Top)
H3.Text = 15 + 0.5 * Sin(2 * i)
somt3 = 1
V3.Text = 10 * (15 + 0.5 * Sin(2 * i)) + 0.3 * kc3
NG3.Text = (180 / pi) * Atn(H3.Text / kc3)
End If
If z3 > 1500 Then
somt3 = 0
UnDisplay3
M3tho.Visible = False
M3tinh.Visible = False
Mu3.Visible = False
End If
End Sub
Public Sub Display4()
kc4 = Check(1700, 1600, Stic.x2, Stic.y2, M4.Left, M4.Top)
If (kc4 < 50) And (Abs(Stic.x2 - M4.Left) < 1700) And (z4 < 1500) Then
D4.Text = z4 * Rmax / 1500
PV4.Text = gocpv(M4.Left, M4.Top)
H4.Text = 14.7 + 0.5 * Cos(i)
somt4 = 1

V4.Text = 10 * (14.7 + 0.5 * Cos(i)) - 0.3 * kc4
NG4.Text = (180 / pi) * Atn(H4.Text / kc4)
End If
If z4 > 1500 Then
somt4 = 0
UnDisplay4
M4tho.Visible = False
M4tinh.Visible = False
Mu4.Visible = False
End If
End Sub
Public Sub Display5()
kc5 = Check(1700, 1600, Stic.x2, Stic.y2, M5.Left, M5.Top)
If (kc5 < 50) And (Abs(Stic.y2 - M5.Top) < 1700) And (z5 < 1500) Then
D5.Text = z5 * Rmax / 1500
PV5.Text = gocpv(M5.Left, M5.Top)
H5.Text = 14.7 - 0.5 * Cos(i)
somt5 = 1
25

×