'Stating Globally Used Variables and Routines
Public publicFile
Public fileString
Public H1, H2, H3, H4
Public L1, L2, L3
Public a, b, c, d, e, f
Public PFlag, JFlag, DFlag, SFlag
Public RegPath, cl$
Public Const NUM = 7
Public Const MC = 101
Public Const pi = 3.14159265359
Public Const MICRO = (4 * pi) / 10
Public Sub AData()
'Assign Values To Variables As Data1
'Height Values
H1 = Val(TowerData.Text2.Text)
H2 = Val(TowerData.Text3.Text)
H3 = Val(TowerData.Text4.Text)
H4 = Val(TowerData.Text5.Text)
'Lenght Values
L1 = Val(TowerData.Text6.Text)
L2 = Val(TowerData.Text7.Text)
L3 = Val(TowerData.Text8.Text)
End Sub
Public Function CheckLCurrent() As Integer
'Validating Line Current Values
For l = 0 To 5
CheckLCurrent = 10
If Val(PAlign.Text1(l).Text) < 1 Then
MsgBox ("Value for Line Current " + PAlign.Label1(l).Caption + " is Unacceptable."), 16
CheckLCurrent = l
GoTo JOut
End If
Next l
JOut:
End Function
Public Sub DrawTower()
'Tower Image Drawing at TowerData
TowerData.ScaleWidth = 600
TowerData.ScaleHeight = 800
TowerData.Line (300, 70)-(300, 400)
TowerData.Line (300, 70)-(276, 340)
TowerData.Line (300, 70)-(324, 340)
TowerData.Line (276, 340)-(258, 440)
TowerData.Line (324, 340)-(342, 440)
TowerData.Line (258, 440)-(300, 400)
TowerData.Line (342, 440)-(300, 400)
TowerData.Line (234, 125)-(366, 125)
TowerData.Line (234, 125)-(300, 110)
TowerData.Line (366, 125)-(300, 110)
TowerData.Line (232, 130)-(236, 145), , BF
TowerData.Line (364, 130)-(368, 145), , BF
TowerData.Line (209, 185)-(391, 185)
TowerData.Line (209, 185)-(300, 170)
TowerData.Line (391, 185)-(300, 170)
TowerData.Line (207, 190)-(211, 205), , BF
TowerData.Line (389, 190)-(393, 205), , BF
TowerData.Line (234, 245)-(366, 245)
TowerData.Line (234, 245)-(300, 230)
TowerData.Line (366, 245)-(300, 230)
TowerData.Line (232, 250)-(236, 265), , BF
TowerData.Line (364, 250)-(368, 265), , BF
TowerData.Line (60, 70)-(60, 440)
TowerData.Line (110, 125)-(110, 440)
TowerData.Line (160, 185)-(160, 440)
TowerData.Line (210, 245)-(210, 440)
TowerData.DrawStyle = 2
TowerData.Line (40, 440)-(296, 440)
TowerData.Line (40, 70)-(296, 70)
TowerData.Line (90, 125)-(230, 125)
TowerData.Line (140, 185)-(202, 185)
TowerData.Line (190, 245)-(227, 245)
TowerData.Line (238, 138)-(362, 138)
TowerData.Line (213, 198)-(387, 198)
TowerData.Line (238, 258)-(362, 258)
TowerData.DrawStyle = 0
End Sub
Public Function FileDrive() As Integer
'Checking For Windows\System Drive Location
For dr = 69 To 65 Step -1
checkpath = Chr$(dr) & ":\config.sys"
On Error Resume Next
Open checkpath For Input As #1
If Err.Number = 0 Then GoTo out
Close #1
Next dr
out:
FileDrive = dr
Close #1
End Function
Public Function GetPosition(LString As String) As Integer
'Centering Of Text In Printer Scale
GetPosition = Int((90 - Len(LString)) / 2)
End Function
Public Function GetVersion() As String
'Getting Version Information
Static strVer As String
If strVer = "" Then
strVer = Trim$(Str$(App.Major)) & "." & Format$(App.Minor, "##00") & "." & Format$(App.Revision, "000")
End If
GetVersion = strVer
End Function
Public Sub graphMS1(a, b, c, d, e, f)
'Memory Reservations
Dim XA(7), YA(7), ICR(7), ICI(7)
Dim ABX(101), ABY(101), bf(101)
Dim io(7)
'Assigning Line Current Values
For l = 1 To 3
io(l) = Val(PAlign.Text1(l - 1).Text)
Next l
For l = 4 To 6
io(l + 1) = Val(PAlign.Text1(l - 1).Text)
Next l
'Assigning Position And Angle Values
200 For i = 1 To NUM
210 On i GoTo 220, 230, 240, 250, 270, 280, 290
220 XA(i) = L1 / 2: YA(i) = H1: RAD = a: GoTo 300
230 XA(i) = L2 / 2: YA(i) = H2: RAD = b: GoTo 300
240 XA(i) = L3 / 2: YA(i) = H3: RAD = c: GoTo 300
250 XA(i) = 0!: YA(i) = H4: RAD = 0: GoTo 300
270 XA(i) = -1 * (L1 / 2): YA(i) = H3: RAD = d: GoTo 300
280 XA(i) = -1 * (L2 / 2): YA(i) = H2: RAD = e: GoTo 300
290 XA(i) = -1 * (L3 / 2): YA(i) = H1: RAD = f
'Line Current Components
300 ICR(i) = io(i) * Cos(RAD): ICI(i) = io(i) * Sin(RAD)
310 If i = 4 Then ICR(i) = 0: ICI(i) = 0
320 Next i
'Electromagnetic Field Computation
350 For ix = 1 To MC
360 xx = (ix - 1) * 100 / 100 - 50: YY = 1
370 '
390 BXSUMR = 0: BXSUMI = 0
400 BYSUMR = 0: BYSUMI = 0
410 For i = 1 To NUM
420 d = Sqr((xx - XA(i)) ^ 2 + (YA(i) - YY) ^ 2)
430 BR = (MICRO / 2 / pi / d) * ICR(i): BI = (MICRO / 2 / pi / d) * ICI(i)
440 BXR = (BR * (YA(i) - YY)) / d: BXI = (BI * (YA(i) - YY)) / d
450 BYR = (BR * (xx - XA(i))) / d: BYI = (BI * (xx - XA(i))) / d
460 BXSUMR = BXSUMR + BXR: BYSUMR = BYSUMR + BYR
470 BXSUMI = BXSUMI + BXI: BYSUMI = BYSUMI + BYI
480 Next i
490 ABX(ix) = Sqr(BXSUMR ^ 2 + BXSUMI ^ 2): ABY(ix) = Sqr(BYSUMR ^ 2 + BYSUMI ^ 2): 'RXY = ABX(IX) / ABY(IX)
510 If BXSUMR = 0 Then thx = 90 Else thx = (Atn(BXSUMI / BXSUMR)) * (180 / pi)
520 If BYSUMR = 0 Then thy = 90 Else thy = (Atn(BYSUMI / BYSUMR)) * (180 / pi)
'Angle Range Limitation
550 If BXSUMR > 0 And BXSUMI > 0 Then thx = thx
560 If BXSUMR > 0 And BXSUMI < 0 Then thx = thx
570 If BXSUMR > 0 And BXSUMI = 0 Then thx = 0
580 If BXSUMR < 0 And BXSUMI > 0 Then thx = thx + 180
590 If BXSUMR < 0 And BXSUMI < 0 Then thx = thx - 180
600 If BXSUMR < 0 And BXSUMI = 0 Then thx = 180
610 If BXSUMR = 0 And BXSUMI > 0 Then thx = 90
620 If BXSUMR = 0 And BXSUMI < 0 Then thx = -90
630 '
640 If BYSUMR > 0 And BYSUMI > 0 Then thy = thy
650 If BYSUMR > 0 And BYSUMI < 0 Then thy = thy
660 If BYSUMR > 0 And BYSUMI = 0 Then thy = 0
670 If BYSUMR < 0 And BYSUMI > 0 Then thy = thy + 180
680 If BYSUMR < 0 And BYSUMI < 0 Then thy = thy - 180
690 If BYSUMR < 0 And BYSUMI = 0 Then thy = 180
700 If BYSUMR = 0 And BYSUMI > 0 Then thy = 90
710 If BYSUMR = 0 And BYSUMI < 0 Then thy = -90
'Phase Angle Difference And Angle Range Limitation
thyx = thy - thx
thxy = thx - thy
If thyx > 180 And thyx <= 360 Then thyx = thyx - 360
If thyx >= -360 And thyx < -180 Then thyx = thyx + 360
If thyx >= -180 And thyx <= 180 Then thyx = thyx
If thxy > 180 And thxy <= 360 Then thxy = thxy - 360
If thxy >= -360 And thxy < -180 Then thxy = thxy + 360
If thxy >= -180 And thxy <= 180 Then thxy = thxy
'Radian Conversion
radyx = 2 * thyx * (pi / 180): radxy = 2 * thxy * (pi / 180)
radx = thx * (pi / 180): rady = thy * (pi / 180)
'Compound Electromagnetic Field Density Computation
bf(ix) = 0
For sd = 1 To 360 Step 1
radsd = sd * (pi / 180)
Em = Sqr((ABX(ix) * Cos(radsd + radx)) ^ 2 + (ABY(ix) * Cos(radsd + rady)) ^ 2)
If Em > bf(ix) Then bf(ix) = Em: sdx = sd
Next sd
810 Next ix
'Graphics Initialization
MSheet1.ScaleHeight = 400
MSheet1.ScaleWidth = 640
'Y-Scale Computation
Max = 0
For mx = 1 To 101
If bf(mx) > Max Then Max = bf(mx)
Next mx
Yinc = 200 / Max
'Writing Scale Information
MSheet1.Label5.Caption = "X Scale = 1 : 2 [m]"
'On Error Resume Next
If (CInt((Max / 20) * 100)) / 100 < 1 Then MSheet1.Label6.Caption = "Y Scale = 1 : " + "0" + Str$((CInt((Max / 20) * 100)) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If (CInt((Max / 20) * 100)) / 100 >= 1 Then: MSheet1.Label6.Caption = "Y Scale = 1 : " + Str$((CInt((Max / 20) * 100)) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If CInt(Max * 100) / 100 < 1 Then MSheet1.Label7.Caption = "Max Val : " + "0" + Str$(CInt(Max * 100) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If CInt(Max * 100) / 100 >= 1 Then: MSheet1.Label7.Caption = "Max Value : " + Str$(CInt(Max * 100) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'Plotting X-Y Axis And Border
MSheet1.Line (75, 100)-(75, 300)
MSheet1.Line (75, 300)-(575, 300)
MSheet1.Line (45, 80)-(595, 330), , B
'Plotting The Results
inc = 5
For T = 2 To 101
MSheet1.DrawWidth = 2
MSheet1.Line (((T - 1) * inc) + 70, 300 - ((ABX(T - 1) * Yinc) * 1))-((T * inc) + 70, 300 - ((ABX(T) * Yinc) * 1)), QBColor(1)
MSheet1.Line (((T - 1) * inc) + 70, 300 - ((ABY(T - 1) * Yinc) * 1))-((T * inc) + 70, 300 - ((ABY(T) * Yinc) * 1)), QBColor(4)
MSheet1.Line (((T - 1) * inc) + 70, 300 - (((bf(T - 1)) * Yinc) * 1))-((T * inc) + 70, 300 - (((bf(T)) * Yinc) * 1)), QBColor(2)
MSheet1.DrawWidth = 1
Next T
'Plotting Axes Lines and Zero Marker
For xaxis = 1 To 50
MSheet1.Line (75 + (xaxis * inc * 2), 300)-(75 + (xaxis * inc * 2), 305)
Next xaxis
For yaxis = 1 To 20
MSheet1.Line (75, 300 - (yaxis * 10))-(70, 300 - (yaxis * 10))
Next yaxis
MSheet1.DrawStyle = 2
MSheet1.Line (325, 100)-(325, 300)
MSheet1.DrawStyle = 0
End Sub
Public Sub graphMS2(a, b, c, d, e, f)
'Memory Reservations
Dim XA(7), YA(7), ICR(7), ICI(7)
Dim ABX(101), ABY(101), bf(101)
Dim io(7)
'Assigning Line Current Values
For l = 1 To 3
io(l) = Val(PAlign.Text1(l - 1).Text)
Next l
For l = 4 To 6
io(l + 1) = Val(PAlign.Text1(l - 1).Text)
Next l
'Assigning Position And Angle Values
200 For i = 1 To NUM
210 On i GoTo 220, 230, 240, 250, 270, 280, 290
220 XA(i) = L1 / 2: YA(i) = H1: RAD = a: GoTo 300
230 XA(i) = L2 / 2: YA(i) = H2: RAD = b: GoTo 300
240 XA(i) = L3 / 2: YA(i) = H3: RAD = c: GoTo 300
250 XA(i) = 0!: YA(i) = H4: RAD = 0: GoTo 300
270 XA(i) = -1 * (L1 / 2): YA(i) = H3: RAD = d: GoTo 300
280 XA(i) = -1 * (L2 / 2): YA(i) = H2: RAD = e: GoTo 300
290 XA(i) = -1 * (L3 / 2): YA(i) = H1: RAD = f
'Line Current Components
300 ICR(i) = io(i) * Cos(RAD): ICI(i) = io(i) * Sin(RAD)
310 If i = 4 Then ICR(i) = 0: ICI(i) = 0
320 Next i
'Electromagnetic Field Computation
350 For ix = 1 To MC
360 xx = (ix - 1) * 100 / 100 - 50: YY = 1
370 '
390 BXSUMR = 0: BXSUMI = 0
400 BYSUMR = 0: BYSUMI = 0
410 For i = 1 To NUM
420 d = Sqr((xx - XA(i)) ^ 2 + (YA(i) - YY) ^ 2)
430 BR = (MICRO / 2 / pi / d) * ICR(i): BI = (MICRO / 2 / pi / d) * ICI(i)
440 BXR = (BR * (YA(i) - YY)) / d: BXI = (BI * (YA(i) - YY)) / d
450 BYR = (BR * (xx - XA(i))) / d: BYI = (BI * (xx - XA(i))) / d
460 BXSUMR = BXSUMR + BXR: BYSUMR = BYSUMR + BYR
470 BXSUMI = BXSUMI + BXI: BYSUMI = BYSUMI + BYI
480 Next i
490 ABX(ix) = Sqr(BXSUMR ^ 2 + BXSUMI ^ 2): ABY(ix) = Sqr(BYSUMR ^ 2 + BYSUMI ^ 2): 'RXY = ABX(IX) / ABY(IX)
510 If BXSUMR = 0 Then thx = 90 Else thx = (Atn(BXSUMI / BXSUMR)) * (180 / pi)
520 If BYSUMR = 0 Then thy = 90 Else thy = (Atn(BYSUMI / BYSUMR)) * (180 / pi)
'Angle Range Limitation
550 If BXSUMR > 0 And BXSUMI > 0 Then thx = thx
560 If BXSUMR > 0 And BXSUMI < 0 Then thx = thx
570 If BXSUMR > 0 And BXSUMI = 0 Then thx = 0
580 If BXSUMR < 0 And BXSUMI > 0 Then thx = thx + 180
590 If BXSUMR < 0 And BXSUMI < 0 Then thx = thx - 180
600 If BXSUMR < 0 And BXSUMI = 0 Then thx = 180
610 If BXSUMR = 0 And BXSUMI > 0 Then thx = 90
620 If BXSUMR = 0 And BXSUMI < 0 Then thx = -90
630 '
640 If BYSUMR > 0 And BYSUMI > 0 Then thy = thy
650 If BYSUMR > 0 And BYSUMI < 0 Then thy = thy
660 If BYSUMR > 0 And BYSUMI = 0 Then thy = 0
670 If BYSUMR < 0 And BYSUMI > 0 Then thy = thy + 180
680 If BYSUMR < 0 And BYSUMI < 0 Then thy = thy - 180
690 If BYSUMR < 0 And BYSUMI = 0 Then thy = 180
700 If BYSUMR = 0 And BYSUMI > 0 Then thy = 90
710 If BYSUMR = 0 And BYSUMI < 0 Then thy = -90
'Phase Angle Difference Computation And Angle Limitation
thyx = thy - thx
thxy = thx - thy
If thyx > 180 And thyx <= 360 Then thyx = thyx - 360
If thyx >= -360 And thyx < -180 Then thyx = thyx + 360
If thyx >= -180 And thyx <= 180 Then thyx = thyx
If thxy > 180 And thxy <= 360 Then thxy = thxy - 360
If thxy >= -360 And thxy < -180 Then thxy = thxy + 360
If thxy >= -180 And thxy <= 180 Then thxy = thxy
'Radian Conversion
radyx = 2 * thyx * (pi / 180): radxy = 2 * thxy * (pi / 180)
radx = thx * (pi / 180): rady = thy * (pi / 180)
'Compound Electromamagnetic Field Density Computation
bf(ix) = 0
For sd = 1 To 360 Step 1
radsd = sd * (pi / 180)
Em = Sqr((ABX(ix) * Cos(radsd + radx)) ^ 2 + (ABY(ix) * Cos(radsd + rady)) ^ 2)
If Em > bf(ix) Then bf(ix) = Em: sdx = sd
Next sd
810 Next ix
'Graphics Initialization
MSheet2.ScaleHeight = 400
MSheet2.ScaleWidth = 640
'Y-Scale Computation
Max = 0
For mx = 1 To 101
If bf(mx) > Max Then Max = bf(mx)
Next mx
Yinc = 200 / Max
'Writing Scale Information
MSheet2.Label5.Caption = "X Scale = 1 : 2 [m]"
'On Error Resume Next
If (CInt((Max / 20) * 100)) / 100 < 1 Then MSheet2.Label6.Caption = "Y Scale = 1 : " + "0" + Str$((CInt((Max / 20) * 100)) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If (CInt((Max / 20) * 100)) / 100 >= 1 Then: MSheet2.Label6.Caption = "Y Scale = 1 : " + Str$((CInt((Max / 20) * 100)) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If CInt(Max * 100) / 100 < 1 Then MSheet2.Label7.Caption = "Max Value : " + "0" + Str$(CInt(Max * 100) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'On Error Resume Next
If CInt(Max * 100) / 100 >= 1 Then: MSheet2.Label7.Caption = "Max Value : " + Str$(CInt(Max * 100) / 100)
'If Err Then MsgBox (Error$(Err)): Form2.SetFocus: Form2.Text1.Text = 1000: Exit Sub
'Plotting X-Y Axis And Border
MSheet2.Line (75, 100)-(75, 300)
MSheet2.Line (75, 300)-(575, 300)
MSheet2.Line (45, 80)-(595, 330), , B
'Plotting The Results
inc = 5
For T = 2 To 101
MSheet2.DrawWidth = 2
MSheet2.Line (((T - 1) * inc) + 70, 300 - ((ABX(T - 1) * Yinc) * 1))-((T * inc) + 70, 300 - ((ABX(T) * Yinc) * 1)), QBColor(1)
MSheet2.Line (((T - 1) * inc) + 70, 300 - ((ABY(T - 1) * Yinc) * 1))-((T * inc) + 70, 300 - ((ABY(T) * Yinc) * 1)), QBColor(4)
MSheet2.Line (((T - 1) * inc) + 70, 300 - (((bf(T - 1)) * Yinc) * 1))-((T * inc) + 70, 300 - (((bf(T)) * Yinc) * 1)), QBColor(2)
MSheet2.DrawWidth = 1
Next T
'Plotting Axes Lines and Zero Marker
For xaxis = 1 To 50
MSheet2.Line (75 + (xaxis * inc * 2), 300)-(75 + (xaxis * inc * 2), 305)
Next xaxis
For yaxis = 1 To 20
MSheet2.Line (75, 300 - (yaxis * 10))-(70, 300 - (yaxis * 10))
Next yaxis
MSheet2.DrawStyle = 2
MSheet2.Line (325, 100)-(325, 300)
MSheet2.DrawStyle = 0
End Sub
Public Sub Header(outTitle As String)
'Printer Scale
px = Printer.ScaleWidth / 90
py = Printer.ScaleHeight / 60
'Printing Header
Printer.CurrentY = py * 1
Lp$ = outTitle
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = App.EXEName & " Ver " & GetVersion & " " & App.LegalCopyright
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = App.CompanyName
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
If PFlag = 1 And DFlag = 1 Then GoTo headData
If PFlag = 1 And DFlag = 0 Then GoTo headGraph
If PFlag = 0 And DFlag = 0 Then GoTo headInput
Exit Sub
headData:
Printer.Print ""
Lp$ = "MAGNETIC FIELD DISTRIBUTION"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = "VERTICAL-TYPE ELECTRICAL POWER LINES"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print ""
Lp$ = "-------------------------------------------------------"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print ""
Printer.Print Tab(13); "X[m]"; Tab(20); "Bx[��T]"; Tab(30); "Bz[��T]"; Tab(40); "Bx+Bz[��T]"; Tab(53); "��x[��]"; Tab(64); "��z[��]"; Tab(73); "��x+��z[��]"
Printer.Print ""
Exit Sub
headInput:
Printer.CurrentY = py * 27
Lp$ = "TRANSMISSION LINE MODEL"
Printer.CurrentX = px * GetPosition(Lp$) + 1
Printer.Print Lp$
Printer.CurrentY = py * 33
Lp$ = "MAGNETIC FIELD DISTRIBUTION"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = "VERTICAL-TYPE ELECTRICAL POWER LINES"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print ""
Lp$ = "Given Values"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = "-------------------------------------------------------"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print ""
Exit Sub
headGraph:
Printer.CurrentY = py * 27
Lp$ = "MAGNETIC FIELD DISTRIBUTION"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.CurrentY = py * 29
Lp$ = "SCALE X = 1 : 2[m]"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = "SCALE Y : {MAGNITUDE} max = " & Max
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Lp$ = "SCALE Y : {PHASE} -360 �` 360 [deg]"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print
Lp$ = "LEGENDS : X Z X + Z"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.CurrentY = py * 57
Lp$ = "PHASE and PHASE DIFFERENCE"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
End Sub
Public Sub InitialPrint()
AData
Header ("DATA GIVEN VALUES")
'Printer Scale
px = Printer.ScaleWidth / 90
py = Printer.ScaleHeight / 60
Lp$ = "Height 1 (H1) = " + TowerData.Text2.Text + " [m]"
cpx = px * GetPosition(Lp$)
For lc = 0 To 5
Printer.CurrentX = cpx
Printer.Print "LINE CURRENT " & Str(lc + 1) & " = " + PAlign.Text1(lc).Text + " [A]"
Next lc
Printer.Print ""
Lp$ = viewTitle
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print viewTitle
Printer.Print
Printer.CurrentX = cpx
Printer.Print "Height 1 (H1) = " + TowerData.Text2.Text + " [m]"
Printer.CurrentX = cpx
Printer.Print "Height 2 (H2) = " + TowerData.Text3.Text + " [m]"
Printer.CurrentX = cpx
Printer.Print "Height 3 (H3) = " + TowerData.Text4.Text + " [m]"
Printer.CurrentX = cpx
Printer.Print "Height 4 (H4) = " + TowerData.Text5.Text + " [m]"
Printer.Print ""
Printer.CurrentX = cpx
Printer.Print "Length 1 (L1) = " + TowerData.Text6.Text + " [m]"
Printer.CurrentX = cpx
Printer.Print "Length 2 (L2) = " + TowerData.Text7.Text + " [m]"
Printer.CurrentX = cpx
Printer.Print "Length 3 (L3) = " + TowerData.Text8.Text + " [m]"
Printer.Print
Lp$ = "-------------------------------------------------------"
Printer.CurrentX = px * GetPosition(Lp$)
Printer.Print Lp$
Printer.Print ""
scl = Int(4800 / Val(TowerData.Text5.Text))
Printer.Line (2398, 1458)-(9118, 7218), , B
Printer.Line (2758, 6738)-(8758, 6738)
basex = 5758: basey = 6738
Printer.Line (basex, basey)-(basex, basey - (H4 * scl))
Printer.Line (basex - (3 * scl), basey)-(basex - (1.25 * scl), basey - (H1 * scl))
Printer.Line -(basex - (1.25 * scl), basey - (H3 * scl))
Printer.Line -(basex, basey - (H4 * scl))
Printer.Line -(basex + (1.25 * scl), basey - (H3 * scl))
Printer.Line -(basex + (1.25 * scl), basey - (H1 * scl))
Printer.Line -(basex + (3 * scl), basey)
Printer.Line (basex - (0.5 * L3 * scl), basey - (H3 * scl))-(basex + (0.5 * L3 * scl), basey - (H3 * scl))
Printer.Line -(basex, basey - ((H3 + 1.5) * scl))
Printer.Line -(basex - (0.5 * L3 * scl), basey - (H3 * scl))
Printer.Line (basex - (0.5 * L2 * scl), basey - (H2 * scl))-(basex + (0.5 * L2 * scl), basey - (H2 * scl))
Printer.Line -(basex + (1.25 * scl), basey - ((H2 + 1.5) * scl))
Printer.Line -(basex - (1.25 * scl), basey - ((H2 + 1.5) * scl))
Printer.Line -(basex - (0.5 * L2 * scl), basey - (H2 * scl))
Printer.Line (basex - (0.5 * L1 * scl), basey - (H1 * scl))-(basex + (0.5 * L1 * scl), basey - (H1 * scl))
Printer.Line -(basex + (1.25 * scl), basey - ((H1 + 1.5) * scl))
Printer.Line -(basex - (1.25 * scl), basey - ((H1 + 1.5) * scl))
Printer.Line -(basex - (0.5 * L1 * scl), basey - (H1 * scl))
Printer.Line (basex - (L1 * 0.5 * scl), basey - (H1 * scl))-(basex - (((L1 * 0.5) - 0.5) * scl), basey - ((H1 - 2) * scl)), , BF
Printer.Line (basex + (L1 * 0.5 * scl), basey - (H1 * scl))-(basex + (((L1 * 0.5) - 0.5) * scl), basey - ((H1 - 2) * scl)), , BF
Printer.Line (basex - (L2 * 0.5 * scl), basey - (H2 * scl))-(basex - (((L2 * 0.5) - 0.5) * scl), basey - ((H2 - 2) * scl)), , BF
Printer.Line (basex + (L2 * 0.5 * scl), basey - (H2 * scl))-(basex + (((L2 * 0.5) - 0.5) * scl), basey - ((H2 - 2) * scl)), , BF
Printer.Line (basex - (L3 * 0.5 * scl), basey - (H3 * scl))-(basex - (((L3 * 0.5) - 0.5) * scl), basey - ((H3 - 2) * scl)), , BF
Printer.Line (basex + (L3 * 0.5 * scl), basey - (H3 * scl))-(basex + (((L3 * 0.5) - 0.5) * scl), basey - ((H3 - 2) * scl)), , BF
Printer.EndDoc
End Sub
Public Sub LSelect()
If SFlag = 1 Then GoTo sftrue Else GoTo sffalse
sftrue:
MFTLInfo.Hide
MainWindow
Exit Sub
'Language Selection Option
sffalse:
Language.Show
MFTLInfo.Hide
End Sub
Public Sub Main()
'Main Program FrontLine
MFTLInfo.Show
End Sub
Public Sub MainWindow()
'Going to Main Windows
Navigator.Show
TowerData.Show
PAlign.Show
Language.Hide
End Sub
Public Sub outgraph()
AData
PAssign
'Printer Setup For Data Printout
If DFlag = 0 Or PFlag = 0 Then GoTo skip0
exs$ = viewTitle & " CALCULATED DATA"
Header (exs$)
skip0:
'Memory Reservations
Dim XA(7), YA(7), ICR(7), ICI(7)
Dim ABX(101), ABY(101), bf(101)
Dim thx(101), thy(101), thyx(101), thxy(101)
Dim io(7)
'Assigning Line Current Values
For l = 1 To 3
io(l) = Val(PAlign.Text1(l - 1).Text)
Next l
For l = 4 To 6
io(l + 1) = Val(PAlign.Text1(l - 1).Text)
Next l
'Saving To File Routine
If PFlag = 1 Or DFlag = 1 Then GoTo skip1
PAlign.commondialog1.Filter = "Text (*.txt)|*.txt"
PAlign.commondialog1.DefaultExt = "Text (*.txt)|*.txt"
PAlign.commondialog1.InitDir = App.Path
On Error Resume Next
PAlign.commondialog1.ShowSave
If Err Then Exit Sub
Open PAlign.commondialog1.filename For Output As #1
skip1:
'Assigning Position And Angle Values
200 For i = 1 To NUM
210 On i GoTo 220, 230, 240, 250, 270, 280, 290
220 XA(i) = L1 / 2: YA(i) = H1: RAD = a: GoTo 300
230 XA(i) = L2 / 2: YA(i) = H2: RAD = b: GoTo 300
240 XA(i) = L3 / 2: YA(i) = H3: RAD = c: GoTo 300
250 XA(i) = 0!: YA(i) = H4: RAD = 0: GoTo 300
270 XA(i) = -1 * (L1 / 2): YA(i) = H3: RAD = d: GoTo 300
280 XA(i) = -1 * (L2 / 2): YA(i) = H2: RAD = e: GoTo 300
290 XA(i) = -1 * (L3 / 2): YA(i) = H1: RAD = f
'Line Current Components
300 ICR(i) = io(i) * Cos(RAD): ICI(i) = io(i) * Sin(RAD)
310 If i = 4 Then ICR(i) = 0: ICI(i) = 0
320 Next i
'Electromagnetic Field Computation
350 For ix = 1 To MC
360 xx = (ix - 1) * 100 / 100 - 50: YY = 1
370 '
390 BXSUMR = 0: BXSUMI = 0
400 BYSUMR = 0: BYSUMI = 0
410 For i = 1 To NUM
420 d = Sqr((xx - XA(i)) ^ 2 + (YA(i) - YY) ^ 2)
430 BR = (MICRO / 2 / pi / d) * ICR(i): BI = (MICRO / 2 / pi / d) * ICI(i)
440 BXR = (BR * (YA(i) - YY)) / d: BXI = (BI * (YA(i) - YY)) / d
450 BYR = (BR * (xx - XA(i))) / d: BYI = (BI * (xx - XA(i))) / d
460 BXSUMR = BXSUMR + BXR: BYSUMR = BYSUMR + BYR
470 BXSUMI = BXSUMI + BXI: BYSUMI = BYSUMI + BYI
480 Next i
490 ABX(ix) = Sqr(BXSUMR ^ 2 + BXSUMI ^ 2): ABY(ix) = Sqr(BYSUMR ^ 2 + BYSUMI ^ 2): 'RXY = ABX(IX) / ABY(IX)
510 If BXSUMR = 0 Then thx(ix) = 90 Else thx(ix) = (Atn(BXSUMI / BXSUMR)) * (180 / pi)
520 If BYSUMR = 0 Then thy(ix) = 90 Else thy(ix) = (Atn(BYSUMI / BYSUMR)) * (180 / pi)
'Angle Range Limitation
550 If BXSUMR > 0 And BXSUMI > 0 Then thx(ix) = thx(ix)
560 If BXSUMR > 0 And BXSUMI < 0 Then thx(ix) = thx(ix)
570 If BXSUMR > 0 And BXSUMI = 0 Then thx(ix) = 0
580 If BXSUMR < 0 And BXSUMI > 0 Then thx(ix) = thx(ix) + 180
590 If BXSUMR < 0 And BXSUMI < 0 Then thx(ix) = thx(ix) - 180
600 If BXSUMR < 0 And BXSUMI = 0 Then thx(ix) = 180
610 If BXSUMR = 0 And BXSUMI > 0 Then thx(ix) = 90
620 If BXSUMR = 0 And BXSUMI < 0 Then thx(ix) = -90
630 '
640 If BYSUMR > 0 And BYSUMI > 0 Then thy(ix) = thy(ix)
650 If BYSUMR > 0 And BYSUMI < 0 Then thy(ix) = thy(ix)
660 If BYSUMR > 0 And BYSUMI = 0 Then thy(ix) = 0
670 If BYSUMR < 0 And BYSUMI > 0 Then thy(ix) = thy(ix) + 180
680 If BYSUMR < 0 And BYSUMI < 0 Then thy(ix) = thy(ix) - 180
690 If BYSUMR < 0 And BYSUMI = 0 Then thy(ix) = 180
700 If BYSUMR = 0 And BYSUMI > 0 Then thy(ix) = 90
710 If BYSUMR = 0 And BYSUMI < 0 Then thy(ix) = -90
'Phase Angle Difference Computation And Angle Limitation
thyx(ix) = thy(ix) - thx(ix)
thxy(ix) = thx(ix) - thy(ix)
If thyx(ix) > 180 And thyx(ix) <= 360 Then thyx(ix) = thyx(ix) - 360
If thyx(ix) >= -360 And thyx(ix) < -180 Then thyx(ix) = thyx(ix) + 360
If thyx(ix) >= -180 And thyx(ix) <= 180 Then thyx(ix) = thyx(ix)
If thxy(ix) > 180 And thxy(ix) <= 360 Then thxy(ix) = thxy(ix) - 360
If thxy(ix) >= -360 And thxy(ix) < -180 Then thxy(ix) = thxy(ix) + 360
If thxy(ix) >= -180 And thxy(ix) <= 180 Then thxy(ix) = thxy(ix)
'Radian Conversion
radyx = 2 * thyx(ix) * (pi / 180): radxy = 2 * thxy(ix) * (pi / 180)
radx = thx(ix) * (pi / 180): rady = thy(ix) * (pi / 180)
'Compound Electromagnetic Field Density Computation
bf(ix) = 0
For sd = 1 To 360 Step 1
radsd = sd * (pi / 180)
Em = Sqr((ABX(ix) * Cos(radsd + radx)) ^ 2 + (ABY(ix) * Cos(radsd + rady)) ^ 2)
If Em > bf(ix) Then bf(ix) = Em: sdx = sd
Next sd
'Writing File To Disk Routine
If PFlag = 1 Or DFlag = 1 Then GoTo skip2
790 Print #1, xx, Format(ABX(ix), "##0.0000"), Format(ABY(ix), "##0.0000"), Format(bf(ix), "##0.0000"), Format(thx(ix), "##0.0000"), Format(thy(ix), "##0.0000"), Format(thyx(ix), "##0.0000")
skip2:
'Writing Of Data To ViewData
If DFlag = 0 Or PFlag = 1 Then GoTo skip3
Lst$ = xx & " " & Format(ABX(ix), "##0.0000") & " " & Format(ABY(ix), "##0.0000") & " " & Format(bf(ix), "##0.0000") & " " & Format(thx(ix), "##0.0000") & " " & Format(thy(ix), "##0.0000") & " " & Format(thyx(ix), "##0.0000")
ViewData.List1.AddItem Lst$
skip3:
'Printing Of Data
If DFlag = 0 Or PFlag = 0 Then GoTo skip4
If xx = 0 Then
Printer.Print ""
Lp$ = "-------------------------------------------------------"
Printer.CurrentX = (Printer.ScaleWidth / 90) * GetPosition(Lp$)
Printer.Print Lp$
Printer.NewPage
Header (exs$)
End If
Printer.Print Tab(13); xx; Tab(20); Format(ABX(ix), "##0.0000"); Tab(30); Format(ABY(ix), "##0.0000"); Tab(42); Format(bf(ix), "##0.0000"); Tab(52); Format(thx(ix), "##0.0000"); Tab(63); Format(thy(ix), "##0.0000"); Tab(75); Format(thyx(ix), "##0.0000")
skip4:
810 Next ix
If DFlag = 1 Then GoTo preExit
If PFlag = 1 Then GoTo toPrinter
820 Close #1
MsgBox ("DATA HAS BEEN TRANSFERED TO " + Chr$(13) + PAlign.commondialog1.filename), 64
Exit Sub
toPrinter:
'Magnitude Border
Printer.Line (2398, 1458)-(9118, 7218), , B
'Magnitude X-Y Axis
Printer.Line (2758, 1938)-(2758, 6738)
Printer.Line (2758, 6738)-(8758, 6738)
'Phase Border
Y2 = 8130
Printer.Line (2398, 1458 + Y2)-(9118, 7218 + Y2), , B
'Phase X-Y Axis
Printer.Line (2758, 1938 + Y2)-(2758, 6738 + Y2)
Printer.Line (2758, 6738 + Y2)-(8758, 6738 + Y2)
'Computing For Scale
Max = 0
For mx = 1 To 101
If bf(mx) > Max Then Max = bf(mx)
Next mx
Xinc = 60
Yinc = 4800 / Max
aYinc = 4800 / 720
Header ("GRAPHICAL DATA PRINTOUT")
'Magnitude Graph Origin Points
Xo = 2698
Yo = 6738
'Phase Graph Origin Points
aYo = 4338 + 8130
rYo = Yo + 8130
'Plotting The Result
For T = 2 To 101
Printer.DrawWidth = 2
Printer.Line (((T - 1) * Xinc) + Xo, Yo - ((ABX(T - 1) * Yinc) * 1))-((T * Xinc) + Xo, Yo - ((ABX(T) * Yinc) * 1)), QBColor(1)
Printer.Line (((T - 1) * Xinc) + Xo, aYo - ((thx(T - 1) * aYinc)))-((T * Xinc) + Xo, aYo - ((thx(T) * aYinc))), QBColor(1)
Printer.Line (((T - 1) * Xinc) + Xo, Yo - ((ABY(T - 1) * Yinc) * 1))-((T * Xinc) + Xo, Yo - ((ABY(T) * Yinc) * 1)), QBColor(4)
Printer.Line (((T - 1) * Xinc) + Xo, aYo - ((thy(T - 1) * aYinc)))-((T * Xinc) + Xo, aYo - ((thy(T) * aYinc))), QBColor(4)
Printer.Line (((T - 1) * Xinc) + Xo, Yo - (((bf(T - 1)) * Yinc) * 1))-((T * Xinc) + Xo, Yo - (((bf(T)) * Yinc) * 1)), QBColor(2)
Printer.Line (((T - 1) * Xinc) + Xo, aYo - ((thyx(T - 1) * aYinc)))-((T * Xinc) + Xo, aYo - ((thyx(T) * aYinc))), QBColor(2)
Printer.DrawWidth = 1
Next T
'Axes Lines
For xaxis = 1 To 50
Printer.Line (Xo + 60 + (xaxis * Xinc * 2), Yo)-(Xo + 60 + (xaxis * Xinc * 2), Yo + 120)
Printer.Line (Xo + 60 + (xaxis * Xinc * 2), rYo)-(Xo + 60 + (xaxis * Xinc * 2), rYo + 120)
Next xaxis
For yaxis = 1 To 20
Printer.Line (Xo + 60, Yo - (yaxis * 240))-(Xo, Yo - (yaxis * 240))
Printer.Line (Xo + 60, rYo - (yaxis * 240))-(Xo, rYo - (yaxis * 240))
Next yaxis
'Zero Marker
Printer.DrawStyle = 2
Printer.Line (5758, 1938)-(5758, 6738)
Printer.DrawStyle = 0
Printer.DrawStyle = 2
Printer.Line (2758, aYo)-(8758, aYo)
Printer.Line (5758, 10068)-(5758, 14868)
Printer.DrawStyle = 0
preExit:
Printer.EndDoc
End Sub
Public Sub PAssign()
rada = 0
radb = -(2 / 3) * pi
radc = (2 / 3) * pi
'Assign Phase Values For D, E and F
If PAlign.Option1.Value Then
d = rada: e = radb: f = radc
ElseIf PAlign.Option2.Value Then
d = radb: e = radc: f = rada
ElseIf PAlign.Option3.Value Then
d = radc: e = rada: f = radb
ElseIf PAlign.Option4.Value Then
d = rada: e = radc: f = radb
ElseIf PAlign.Option5.Value Then
d = radb: e = rada: f = radc
ElseIf PAlign.Option6.Value Then
d = radc: e = radb: f = rada
End If
'Assign Phase Value For A, B and C
If PAlign.Option7.Value Then
c = rada: b = radb: a = radc
ElseIf PAlign.Option8.Value Then
c = radb: b = radc: a = rada
ElseIf PAlign.Option9.Value Then
c = radc: b = rada: a = radb
ElseIf PAlign.Option10.Value Then
c = rada: b = radc: a = radb
ElseIf PAlign.Option11.Value Then
c = radb: b = rada: a = radc
ElseIf PAlign.Option12.Value Then
c = radc: b = radb: a = rada
End If
End Sub
Public Sub phasePS1(a, b, c, d, e, f)
'Memory Reservations
Dim XA(7), YA(7), ICR(7), ICI(7)
Dim ABX(101), ABY(101), thx(101), thy(101), thyx(101), thxy(101)
Dim io(7)
'Assigning Line Current Values
For l = 1 To 3
io(l) = Val(PAlign.Text1(l - 1).Text)
Next l
For l = 4 To 6
io(l + 1) = Val(PAlign.Text1(l - 1).Text)
Next l
'Assigning Position And Angle Values
200 For i = 1 To NUM
210 On i GoTo 220, 230, 240, 250, 270, 280, 290
220 XA(i) = L1 / 2: YA(i) = H1: RAD = a: GoTo 300
230 XA(i) = L2 / 2: YA(i) = H2: RAD = b: GoTo 300
240 XA(i) = L3 / 2: YA(i) = H3: RAD = c: GoTo 300
250 XA(i) = 0!: YA(i) = H4: RAD = 0: GoTo 300
270 XA(i) = -1 * (L1 / 2): YA(i) = H3: RAD = d: GoTo 300
280 XA(i) = -1 * (L2 / 2): YA(i) = H2: RAD = e: GoTo 300
290 XA(i) = -1 * (L3 / 2): YA(i) = H1: RAD = f
'Line Current Components
300 ICR(i) = io(i) * Cos(RAD): ICI(i) = io(i) * Sin(RAD)
310 If i = 4 Then ICR(i) = 0: ICI(i) = 0
320 Next i
'Electromagnetic Field Computation
350 For ix = 1 To MC
360 xx = (ix - 1) * 100 / 100 - 50: YY = 1
370 '
390 BXSUMR = 0: BXSUMI = 0
400 BYSUMR = 0: BYSUMI = 0
410 For i = 1 To NUM
420 d = Sqr((xx - XA(i)) ^ 2 + (YA(i) - YY) ^ 2)
430 BR = (MICRO / 2 / pi / d) * ICR(i): BI = (MICRO / 2 / pi / d) * ICI(i)
440 BXR = (BR * (YA(i) - YY)) / d: BXI = (BI * (YA(i) - YY)) / d
450 BYR = (BR * (xx - XA(i))) / d: BYI = (BI * (xx - XA(i))) / d
460 BXSUMR = BXSUMR + BXR: BYSUMR = BYSUMR + BYR
470 BXSUMI = BXSUMI + BXI: BYSUMI = BYSUMI + BYI
480 Next i
490 ABX(ix) = Sqr(BXSUMR ^ 2 + BXSUMI ^ 2): ABY(ix) = Sqr(BYSUMR ^ 2 + BYSUMI ^ 2): 'RXY = ABX(IX) / ABY(IX)
510 If BXSUMR = 0 Then thx(ix) = 90 Else thx(ix) = (Atn(BXSUMI / BXSUMR)) * (180 / pi)
520 If BYSUMR = 0 Then thy(ix) = 90 Else thy(ix) = (Atn(BYSUMI / BYSUMR)) * (180 / pi)
'Angle Range Limitation
550 If BXSUMR > 0 And BXSUMI > 0 Then thx(ix) = thx(ix)
560 If BXSUMR > 0 And BXSUMI < 0 Then thx(ix) = thx(ix)
570 If BXSUMR > 0 And BXSUMI = 0 Then thx(ix) = 0
580 If BXSUMR < 0 And BXSUMI > 0 Then thx(ix) = thx(ix) + 180
590 If BXSUMR < 0 And BXSUMI < 0 Then thx(ix) = thx(ix) - 180
600 If BXSUMR < 0 And BXSUMI = 0 Then thx(ix) = 180
610 If BXSUMR = 0 And BXSUMI > 0 Then thx(ix) = 90
620 If BXSUMR = 0 And BXSUMI < 0 Then thx(ix) = -90
630 '
640 If BYSUMR > 0 And BYSUMI > 0 Then thy(ix) = thy(ix)
650 If BYSUMR > 0 And BYSUMI < 0 Then thy(ix) = thy(ix)
660 If BYSUMR > 0 And BYSUMI = 0 Then thy(ix) = 0
670 If BYSUMR < 0 And BYSUMI > 0 Then thy(ix) = thy(ix) + 180
680 If BYSUMR < 0 And BYSUMI < 0 Then thy(ix) = thy(ix) - 180
690 If BYSUMR < 0 And BYSUMI = 0 Then thy(ix) = 180
700 If BYSUMR = 0 And BYSUMI > 0 Then thy(ix) = 90
710 If BYSUMR = 0 And BYSUMI < 0 Then thy(ix) = -90
'Phase Angle Difference Computation And Angle Limitation
thyx(ix) = thy(ix) - thx(ix)
thxy(ix) = thx(ix) - thy(ix)
If thyx(ix) > 180 And thyx(ix) <= 360 Then thyx(ix) = thyx(ix) - 360
If thyx(ix) >= -360 And thyx(ix) < -180 Then thyx(ix) = thyx(ix) + 360
If thyx(ix) >= -180 And thyx(ix) <= 180 Then thyx(ix) = thyx(ix)
If thxy(ix) > 180 And thxy(ix) <= 360 Then thxy(ix) = thxy(ix) - 360
If thxy(ix) >= -360 And thxy(ix) < -180 Then thxy(ix) = thxy(ix) + 360
If thxy(ix) >= -180 And thxy(ix) <= 180 Then thxy(ix) = thxy(ix)
810 Next ix
'Recalculating For A Continuous Curve
For tx = 2 To MC
If Abs(thx(tx - 1) - thx(tx)) < 180 Then GoTo askip1
MARK = thx(tx - 1)
If MARK - thx(tx) > 0 Then thx(tx) = thx(tx) + 360 Else thx(tx) = thx(tx) - 360
askip1:
Next tx
For tx = 2 To MC
If Abs(thy(tx - 1) - thy(tx)) < 180 Then GoTo askip2
MARK = thy(tx - 1)
If MARK - thy(tx) > 0 Then thy(tx) = thy(tx) + 360 Else thy(tx) = thy(tx) - 360
askip2:
Next tx
For tx = 2 To MC
If Abs(thyx(tx - 1) - thyx(tx)) < 180 Then GoTo askip3
MARK = thyx(tx - 1)
If MARK - thyx(tx) > 0 Then thyx(tx) = thyx(tx) + 360 Else thyx(tx) = thyx(tx) - 360
askip3:
Next tx
'Graphics Initialization
PSheet1.ScaleHeight = 400
PSheet1.ScaleWidth = 640
'Scale Initialization
incy = 200 / 720
inc = 5
'Writing Scale Information
PSheet1.Label5.Caption = "X Scale = 1 : 2 [m]"
PSheet1.Label6.Caption = "Y Scale = 1 : 36 [deg]"
PSheet1.Label7.Caption = "Y Range : -360 �` 360 [degree]"
'plotting the X-Y Axis And Border
PSheet1.Line (75, 100)-(75, 300)
PSheet1.Line (75, 300)-(575, 300)
PSheet1.Line (45, 80)-(595, 330), , B
'Plotting The Result
For T = 2 To 101
PSheet1.DrawWidth = 2
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thx(T - 1) * incy)))-((T * inc) + 70, 200 - ((thx(T) * incy))), QBColor(1)
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thy(T - 1) * incy)))-((T * inc) + 70, 200 - ((thy(T) * incy))), QBColor(4)
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thyx(T - 1) * incy)))-((T * inc) + 70, 200 - ((thyx(T) * incy))), QBColor(2)
PSheet1.DrawWidth = 1
Next T
'Plotting Axes Lines And Zero Marker
For xaxis = 1 To 50
PSheet1.Line (75 + (xaxis * inc * 2), 300)-(75 + (xaxis * inc * 2), 305)
Next xaxis
For yaxis = 1 To 20
PSheet1.Line (75, 300 - (yaxis * 10))-(70, 300 - (yaxis * 10))
Next yaxis
PSheet1.DrawStyle = 2
PSheet1.Line (75, 200)-(575, 200)
PSheet1.Line (325, 100)-(325, 300)
PSheet1.DrawStyle = 0
End Sub
Public Sub phasePS1(a, b, c, d, e, f)
'Memory Reservations
Dim XA(7), YA(7), ICR(7), ICI(7)
Dim ABX(101), ABY(101), thx(101), thy(101), thyx(101), thxy(101)
Dim io(7)
'Assigning Line Current Values
For l = 1 To 3
io(l) = Val(PAlign.Text1(l - 1).Text)
Next l
For l = 4 To 6
io(l + 1) = Val(PAlign.Text1(l - 1).Text)
Next l
'Assigning Position And Angle Values
200 For i = 1 To NUM
210 On i GoTo 220, 230, 240, 250, 270, 280, 290
220 XA(i) = L1 / 2: YA(i) = H1: RAD = a: GoTo 300
230 XA(i) = L2 / 2: YA(i) = H2: RAD = b: GoTo 300
240 XA(i) = L3 / 2: YA(i) = H3: RAD = c: GoTo 300
250 XA(i) = 0!: YA(i) = H4: RAD = 0: GoTo 300
270 XA(i) = -1 * (L1 / 2): YA(i) = H3: RAD = d: GoTo 300
280 XA(i) = -1 * (L2 / 2): YA(i) = H2: RAD = e: GoTo 300
290 XA(i) = -1 * (L3 / 2): YA(i) = H1: RAD = f
'Line Current Components
300 ICR(i) = io(i) * Cos(RAD): ICI(i) = io(i) * Sin(RAD)
310 If i = 4 Then ICR(i) = 0: ICI(i) = 0
320 Next i
'Electromagnetic Field Computation
350 For ix = 1 To MC
360 xx = (ix - 1) * 100 / 100 - 50: YY = 1
370 '
390 BXSUMR = 0: BXSUMI = 0
400 BYSUMR = 0: BYSUMI = 0
410 For i = 1 To NUM
420 d = Sqr((xx - XA(i)) ^ 2 + (YA(i) - YY) ^ 2)
430 BR = (MICRO / 2 / pi / d) * ICR(i): BI = (MICRO / 2 / pi / d) * ICI(i)
440 BXR = (BR * (YA(i) - YY)) / d: BXI = (BI * (YA(i) - YY)) / d
450 BYR = (BR * (xx - XA(i))) / d: BYI = (BI * (xx - XA(i))) / d
460 BXSUMR = BXSUMR + BXR: BYSUMR = BYSUMR + BYR
470 BXSUMI = BXSUMI + BXI: BYSUMI = BYSUMI + BYI
480 Next i
490 ABX(ix) = Sqr(BXSUMR ^ 2 + BXSUMI ^ 2): ABY(ix) = Sqr(BYSUMR ^ 2 + BYSUMI ^ 2): 'RXY = ABX(IX) / ABY(IX)
510 If BXSUMR = 0 Then thx(ix) = 90 Else thx(ix) = (Atn(BXSUMI / BXSUMR)) * (180 / pi)
520 If BYSUMR = 0 Then thy(ix) = 90 Else thy(ix) = (Atn(BYSUMI / BYSUMR)) * (180 / pi)
'Angle Range Limitation
550 If BXSUMR > 0 And BXSUMI > 0 Then thx(ix) = thx(ix)
560 If BXSUMR > 0 And BXSUMI < 0 Then thx(ix) = thx(ix)
570 If BXSUMR > 0 And BXSUMI = 0 Then thx(ix) = 0
580 If BXSUMR < 0 And BXSUMI > 0 Then thx(ix) = thx(ix) + 180
590 If BXSUMR < 0 And BXSUMI < 0 Then thx(ix) = thx(ix) - 180
600 If BXSUMR < 0 And BXSUMI = 0 Then thx(ix) = 180
610 If BXSUMR = 0 And BXSUMI > 0 Then thx(ix) = 90
620 If BXSUMR = 0 And BXSUMI < 0 Then thx(ix) = -90
630 '
640 If BYSUMR > 0 And BYSUMI > 0 Then thy(ix) = thy(ix)
650 If BYSUMR > 0 And BYSUMI < 0 Then thy(ix) = thy(ix)
660 If BYSUMR > 0 And BYSUMI = 0 Then thy(ix) = 0
670 If BYSUMR < 0 And BYSUMI > 0 Then thy(ix) = thy(ix) + 180
680 If BYSUMR < 0 And BYSUMI < 0 Then thy(ix) = thy(ix) - 180
690 If BYSUMR < 0 And BYSUMI = 0 Then thy(ix) = 180
700 If BYSUMR = 0 And BYSUMI > 0 Then thy(ix) = 90
710 If BYSUMR = 0 And BYSUMI < 0 Then thy(ix) = -90
'Phase Angle Difference Computation And Angle Limitation
thyx(ix) = thy(ix) - thx(ix)
thxy(ix) = thx(ix) - thy(ix)
If thyx(ix) > 180 And thyx(ix) <= 360 Then thyx(ix) = thyx(ix) - 360
If thyx(ix) >= -360 And thyx(ix) < -180 Then thyx(ix) = thyx(ix) + 360
If thyx(ix) >= -180 And thyx(ix) <= 180 Then thyx(ix) = thyx(ix)
If thxy(ix) > 180 And thxy(ix) <= 360 Then thxy(ix) = thxy(ix) - 360
If thxy(ix) >= -360 And thxy(ix) < -180 Then thxy(ix) = thxy(ix) + 360
If thxy(ix) >= -180 And thxy(ix) <= 180 Then thxy(ix) = thxy(ix)
810 Next ix
'Recalculating For A Continuous Curve
For tx = 2 To MC
If Abs(thx(tx - 1) - thx(tx)) < 180 Then GoTo askip1
MARK = thx(tx - 1)
If MARK - thx(tx) > 0 Then thx(tx) = thx(tx) + 360 Else thx(tx) = thx(tx) - 360
askip1:
Next tx
For tx = 2 To MC
If Abs(thy(tx - 1) - thy(tx)) < 180 Then GoTo askip2
MARK = thy(tx - 1)
If MARK - thy(tx) > 0 Then thy(tx) = thy(tx) + 360 Else thy(tx) = thy(tx) - 360
askip2:
Next tx
For tx = 2 To MC
If Abs(thyx(tx - 1) - thyx(tx)) < 180 Then GoTo askip3
MARK = thyx(tx - 1)
If MARK - thyx(tx) > 0 Then thyx(tx) = thyx(tx) + 360 Else thyx(tx) = thyx(tx) - 360
askip3:
Next tx
'Graphics Initialization
PSheet1.ScaleHeight = 400
PSheet1.ScaleWidth = 640
'Scale Initialization
incy = 200 / 720
inc = 5
'Writing Scale Information
PSheet1.Label5.Caption = "X Scale = 1 : 2 [m]"
PSheet1.Label6.Caption = "Y Scale = 1 : 36 [deg]"
PSheet1.Label7.Caption = "Y Range : -360 �` 360 [degree]"
'plotting the X-Y Axis And Border
PSheet1.Line (75, 100)-(75, 300)
PSheet1.Line (75, 300)-(575, 300)
PSheet1.Line (45, 80)-(595, 330), , B
'Plotting The Result
For T = 2 To 101
PSheet1.DrawWidth = 2
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thx(T - 1) * incy)))-((T * inc) + 70, 200 - ((thx(T) * incy))), QBColor(1)
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thy(T - 1) * incy)))-((T * inc) + 70, 200 - ((thy(T) * incy))), QBColor(4)
PSheet1.Line (((T - 1) * inc) + 70, 200 - ((thyx(T - 1) * incy)))-((T * inc) + 70, 200 - ((thyx(T) * incy))), QBColor(2)
PSheet1.DrawWidth = 1
Next T
'Plotting Axes Lines And Zero Marker
For xaxis = 1 To 50
PSheet1.Line (75 + (xaxis * inc * 2), 300)-(75 + (xaxis * inc * 2), 305)
Next xaxis
For yaxis = 1 To 20
PSheet1.Line (75, 300 - (yaxis * 10))-(70, 300 - (yaxis * 10))
Next yaxis
PSheet1.DrawStyle = 2
PSheet1.Line (75, 200)-(575, 200)
PSheet1.Line (325, 100)-(325, 300)
PSheet1.DrawStyle = 0
End Sub
Public Function readfile(filename$) As String
RegPath = Chr$(FileDrive) + ":\Windows\System\" & filename$
readfile = ""
ln = 0
Dim lx$(20)
On Error Resume Next
Open RegPath For Input As #1
If Err Then GoTo mxt
Lp:
ln = ln + 1
If EOF(1) Then GoTo xt
Line Input #1, lx$(ln)
GoTo Lp
xt:
For cnt = 1 To ln - 1
readfile = readfile + lx$(cnt) + Chr$(13)
Next cnt
mxt:
Close #1
End Function
Public Sub registerfile()
'Checking For Licence
filemsg$ = readfile("MFTL32.dll")
If filemsg$ = "" Then cl$ = "UNREGISTERED": Exit Sub
cl$ = ""
total = 0
mystring = filemsg$
For ec = 1 To Len(filemsg$) Step 2
ek$ = Mid(mystring, ec, 2)
For xx = 1 To 2
Value = Val(Mid(ek$, xx, 1))
If Mid(ek$, xx, 1) = "A" Or Mid(ek$, xx, 1) = "a" Then Value = 10
If Mid(ek$, xx, 1) = "B" Or Mid(ek$, xx, 1) = "b" Then Value = 11
If Mid(ek$, xx, 1) = "C" Or Mid(ek$, xx, 1) = "c" Then Value = 12
If Mid(ek$, xx, 1) = "D" Or Mid(ek$, xx, 1) = "d" Then Value = 13
If Mid(ek$, xx, 1) = "E" Or Mid(ek$, xx, 1) = "e" Then Value = 14
If Mid(ek$, xx, 1) = "F" Or Mid(ek$, xx, 1) = "f" Then Value = 15
If xx = 1 Then Value = Value * 16
If xx = 2 Then Value = Value
total = total + Value
Next xx
xl$ = Chr$(total)
cl$ = cl$ + xl$
total = 0
Next ec
End Sub
Public Function viewTitle() As String
If JFlag = 1 Then viewTitle = "���̉�� ": GoTo jl
viewTitle = "LEFT "
jl:
If PAlign.Option1.Value Then viewTitle = viewTitle & PAlign.Option1.Caption
If PAlign.Option2.Value Then viewTitle = viewTitle & PAlign.Option2.Caption
If PAlign.Option3.Value Then viewTitle = viewTitle & PAlign.Option3.Caption
If PAlign.Option4.Value Then viewTitle = viewTitle & PAlign.Option4.Caption
If PAlign.Option5.Value Then viewTitle = viewTitle & PAlign.Option5.Caption
If PAlign.Option6.Value Then viewTitle = viewTitle & PAlign.Option6.Caption
If JFlag = 1 Then viewTitle = viewTitle & " | �E�̉�� ": GoTo jr
viewTitle = viewTitle & " | RIGHT "
jr:
If PAlign.Option7.Value Then viewTitle = viewTitle & PAlign.Option7.Caption
If PAlign.Option8.Value Then viewTitle = viewTitle & PAlign.Option8.Caption
If PAlign.Option9.Value Then viewTitle = viewTitle & PAlign.Option9.Caption
If PAlign.Option10.Value Then viewTitle = viewTitle & PAlign.Option10.Caption
If PAlign.Option11.Value Then viewTitle = viewTitle & PAlign.Option11.Caption
If PAlign.Option12.Value Then viewTitle = viewTitle & PAlign.Option12.Caption
End Function
Public Sub WayOut()
'Proper Way Of Ending A Program
End
End Sub