⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datdsp.bas

📁 通过GPIB接口读取频谱仪的测试曲线
💻 BAS
📖 第 1 页 / 共 3 页
字号:
Attribute VB_Name = "Module2"
Type VW
  V1 As Single
  V2 As Single
  V3 As Single
  V4 As Single
  W1 As Single
  W2 As Single
  W3 As Single
  W4 As Single
  A8 As Single
  A9 As Single
  B8 As Single
  B9 As Single
End Type
Type RotCtl
    MaxSpd As Integer
    MinSpd As Integer
    CrntSpd As Integer
    MaxAgl As Long
    Mode As String * 1
End Type
Public MinLvl%, MaxLvl%
Public src$, Rec$, Dat$, Tim$, Freq$
Public CrntSrc$, CrntRec$

Public AzimSpinSta As RotCtl
Public PitcSpinSta As RotCtl


Public MaxLvlAgl&, SpfyAgl&, MaxAgl&, FE%, DeltSpfyAgl&
Public TopLvl%, BtmLvl%
Public CenAgl&, AglAre&, DspCenAgl&, DspAglAre&
Public CrntDspObj As Object
Public PrntMod As Byte
Public GN As Byte

Public MainDspArea As VW
Public CrntVW As VW

Public Lvl%(18432)
Public AglDspAreaPnt%
Public RfrLvl%
Public AmpDspArea%
Public AglAreaOpt&(10)
Public FilSta%
Public Const NoLvl = 32767
Public FilPathNam(15) As String
Public FilPnt%, FilNum%
Public CenAglMod%
Public TilHed$
Public DspCdtMod%
Public CenAglOf3dB&
Public CT%
Public LobWidSW%, SidLobLvlSW%, DirGainSW%, PreRbefSW%
Public LobWid%, SidLobLvl%, DirGain%, PreRbef%
Public xPW, xP
Public LSA&, LL, RSA&, RL
Public Gx!
Public FBRAglAre%, FBR


Public RcvAddr As String
Public SrcAddr As String
Public RcvNo%, SrcNo%
Public MEAS%
Public GPIBcmdStr As String * 16
Public RcvPnts%
Public MeasSwpTim!, MeasAglArea!, RfrAglTim!
Public Rbuf(0 To 4096) As Single
Sub PVIEW(VWn As VW, V1, V2, V3, V4)
  
  VWn.V1 = V1
  VWn.V2 = V3
  VWn.V3 = V2
  VWn.V4 = V4
  
End Sub

Sub PVW(VWn As VW)
  VWn.A8 = (VWn.V2 - VWn.V1) / (VWn.W2 - VWn.W1)
  VWn.A9 = (VWn.V4 - VWn.V3) / (VWn.W4 - VWn.W3)
  VWn.B8 = (VWn.V1 * VWn.W2 - VWn.V2 * VWn.W1) / (VWn.W2 - VWn.W1)
  VWn.B9 = (VWn.V3 * VWn.W4 - VWn.V4 * VWn.W3) / (VWn.W4 - VWn.W3)
End Sub

Sub PWINDOW(VWn As VW, W1, W2, W3, W4)
  
  VWn.W1 = W1
  VWn.W2 = W3
  VWn.W3 = W2
  VWn.W4 = W4
  
End Sub
Sub Main()
    AmpDspArea% = 40
    RfrLvl% = 0
    AglDspAreaPnt% = 10
    AglAreaOpt&(0) = 9
    AglAreaOpt&(1) = 9
    AglAreaOpt&(2) = 18
    AglAreaOpt&(3) = 36
    AglAreaOpt&(4) = 72
    AglAreaOpt&(5) = 90
    AglAreaOpt&(6) = 120
    AglAreaOpt&(7) = 150
    AglAreaOpt&(8) = 180
    AglAreaOpt&(9) = 270
    AglAreaOpt&(10) = 360
    DspCenAgl& = 0
    DspAglAre& = 360
    AmpDspMod% = -1
    CenAglMod% = 0
    FilPnt% = 0
    FilNum% = 0
    MaxAgl& = 18432
    DeltSpfyAgl& = 0
    xP = 3
    FBRAglAre% = 30
    RcvPnts% = 601
    RcvNo% = 0
    SrcNo% = 0
    CrntSrc$ = "HP8648C"
    CrntRec$ = "HP856X"
    

    RcvAddr = "hpib7,18"
    SrcAddr = "hpib7,19"
    Init
'    TilHed$ = "演示"
    Load formDGDP
    formDGDP.Show
    Load formDirGpcPro
    formDirGpcPro.Show
    
    
    
End Sub
Sub Init()
  
    Dim I As Integer
    'initialize Frequncy resoure
 
        
    'initialize rotate table
    With AzimSpinSta
        .CrntSpd = 128
        .MaxSpd = 255
        .MinSpd = 10
        .MaxAgl = 4096
        .Mode = "0"
    End With
    
    With PitcSpinSta
        .CrntSpd = 128
        .MaxSpd = 255
        .MinSpd = 50
        .MaxAgl = 4096
        .Mode = "0"
    End With
    MaxAgl& = AzimSpinSta.MaxAgl
    For I = 0 To 18431
        Lvl%(I) = NoLvl
    Next I
End Sub

Sub CfgDrawEnv()
    If Not (PrntMod) Then
        CrntDspObj.Cls
    End If
    CrntDspObj.CurrentX = 50
    CrntDspObj.CurrentY = CrntDspObj.Height / 3
    CrntDspObj.ForeColor = RGB(0, 0, 0)
    CrntDspObj.Print "  幅度"
    CrntDspObj.Print "(dB/Div)"
'    TitlHed$ = ""
'    Titl$ = TitlHed$ & "方向图"
'    CrntDspObj.CurrentX = (CrntVW.V1 + CrntVW.V2) / 2 - 25 * LenB(Titl$)
'    CrntDspObj.CurrentY = CrntVW.V4 - 255
    'CrntDspObj.Print Titl$
    Dy = (CrntVW.V4 - CrntVW.V3) / 10

    CrntDspObj.ForeColor = RGB(0, 128, 0)
    If PrntMod Then
        CrntDspObj.DrawWidth = 4
    Else
        CrntDspObj.DrawWidth = 1
    End If
    Dyscl = AmpDspArea% / 10
    
    For I% = 0 To 10
        TempY = CrntVW.V3 + Dy * I%
        CrntDspObj.ForeColor = RGB(0, 128, 0)
        CrntDspObj.Line (CrntVW.V1, TempY)-(CrntVW.V2, TempY)
        
        CrntDspObj.CurrentX = CrntVW.V1 - 400
        CrntDspObj.CurrentY = TempY - 144
        TempYscl = RfrLvl% - AmpDspArea% + I% * Dyscl
        Yscl$ = Str$(TempYscl)
        CrntDspObj.ForeColor = RGB(0, 0, 0)
        CrntDspObj.Print Yscl$
    Next I%
    
    Dx = (CrntVW.V2 - CrntVW.V1) / 12
    DspAglAre& = AglAreaOpt&(AglDspAreaPnt%)
    Dxscl = DspAglAre& / 12
'    DspCenAgl& = CenAgl& * 360 / MaxAgl&

    For I% = 0 To 12
        TempX = CrntVW.V1 + Dx * I%
        CrntDspObj.ForeColor = RGB(0, 128, 0)
        CrntDspObj.Line (TempX, CrntVW.V3)-(TempX, CrntVW.V4)
        
        TempXscl = DspCenAgl& - DspAglAre& / 2 + Dxscl * I%
        TempStr$ = Str$(TempXscl)
        PL = InStr(1, TempStr$, ".")
        If PL Then
           Xscl$ = Mid$(TempStr$, 1, PL + 1)
        Else
            Xscl$ = TempStr$
        End If
            
        CrntDspObj.CurrentX = TempX - 120 * Len(Xscl$) / 2
        CrntDspObj.CurrentY = CrntVW.V3 + 72

        CrntDspObj.ForeColor = RGB(0, 0, 0)
        CrntDspObj.Print Xscl$
    Next
    
    CrntDspObj.CurrentX = (CrntVW.V1 + CrntVW.V2) / 2 - 80 * 5
    CrntDspObj.CurrentY = CrntVW.V3 + 300
    CrntDspObj.ForeColor = RGB(0, 0, 0)
    CrntDspObj.Print "方位角(°)"

    

End Sub

Sub AreaOpt()
            AglAre& = AglAreaOpt&(AglDspAreaPnt%) * MaxAgl& / 360
    '        If AmpDspMod% Then
                TopLvl% = MaxLvl%
                BtmLvl% = TopLvl% - AmpDspArea% * 100
'        End If
            Select Case CenAglMod%
            Case 0
                CenAgl& = MaxLvlAgl&
            Case 1
                CenAgl& = MaxLvlAgl&
            Case 2
                CenAgl& = SpfyAgl&
            Case Else
                CenAgl& = MaxLvlAgl&
            End Select

End Sub

Sub DGreDraw()
    DrawClr% = 255 - 16 * (FilNum% - 1)
    If DspCdtMod% Then
        InitPolarCyd
        For I% = 0 To FilNum% - 1
            TempFil$ = FilPathNam(I%)
            ReadFil (TempFil$)
            SpfyAgl& = SpfyAgl& + DeltSpfyAgl&
            If SpfyAgl& > MaxAgl& Then
               SpfyAgl& = SpfyAgl& - MaxAgl&
            ElseIf SpfyAgl& < 0 Then
               SpfyAgl& = SpfyAgl& + MaxAgl&
            End If
 '           DeltSpfyAgl& = 0
            AreaOpt
            DrawClr% = DrawClr% + 16 * I%
            ChangePen DrawClr%
            'PREDRAW CenAgl&, AglAre&, TopLvl%, BtmLvl%, 300
            PPOLDIS CenAgl&, AmpDspArea%
        Next I%
        If MEAS% Then

            
                    SpfyAgl& = SpfyAgl& + DeltSpfyAgl&
                    DeltSpfyAgl& = 0


            AreaOpt
            DrawClr% = 255
            ChangePen DrawClr%
            src$ = CrntSrc$
            Rec$ = CrntRec$
            Tim$ = Time$
            Dat$ = Date$
            PPOLDIS CenAgl&, AmpDspArea%
        End If
    Else
        CfgDrawEnv
        For I% = 0 To FilNum% - 1
            TempFil$ = FilPathNam(I%)
            ReadFil (TempFil$)
                        SpfyAgl& = SpfyAgl& + DeltSpfyAgl&
            If SpfyAgl& > MaxAgl& Then
               SpfyAgl& = SpfyAgl& - MaxAgl&
            ElseIf SpfyAgl& < 0 Then
               SpfyAgl& = SpfyAgl& + MaxAgl&
            End If
'            DeltSpfyAgl& = 0
            AreaOpt
            DrawClr% = DrawClr% + 16 * I%
            ChangePen DrawClr%
            PREDRAW CenAgl&, AglAre&, TopLvl%, BtmLvl%, 300
        Next I%
        If MEAS% Then
                            SpfyAgl& = SpfyAgl& + DeltSpfyAgl&
                    DeltSpfyAgl& = 0

            If SpfyAgl& > MaxAgl& Then
               SpfyAgl& = SpfyAgl& - MaxAgl&
            ElseIf SpfyAgl& < 0 Then
               SpfyAgl& = SpfyAgl& + MaxAgl&
            End If

        
             AreaOpt
             DrawClr% = 255
            ChangePen DrawClr%
            src$ = CrntSrc$
            Rec$ = CrntRec$
            Tim$ = Time$
            Dat$ = Date$
            PREDRAW CenAgl&, AglAre&, TopLvl%, BtmLvl%, 300
        End If
    End If
    CrntDspObj.ForeColor = RGB(0, 64, 0)
    CrntDspObj.CurrentY = CrntVW.V4 - 255
    TempTitl$ = TilHed$ & "方向图(f=" & Freq$ & "MHz)" & "    文件:" & TempFil$
    CrntDspObj.CurrentX = (CrntVW.V1 + CrntVW.V2) / 2 - 25 * LenB(TempTitl$)
    CrntDspObj.Print TempTitl$
'    CrntDspObj.Print "    文件:" & TempFil$
            
    LocX = CrntVW.V2 + 72
    CrntDspObj.CurrentX = LocX
    CrntLoc = CrntVW.V4 + 288
    CrntDspObj.CurrentY = CrntLoc
    CrntDspObj.Print "信号源:" & src$
    CrntLoc = CrntLoc + 288
    CrntDspObj.CurrentX = LocX
    CrntDspObj.CurrentY = CrntLoc
    CrntDspObj.Print "接收机:" & Rec$
    CrntLoc = CrntLoc + 288
    CrntDspObj.CurrentX = LocX
    CrntDspObj.CurrentY = CrntLoc
    CrntDspObj.Print "日期:" & Dat$
    CrntLoc = CrntLoc + 288
    CrntDspObj.CurrentX = LocX
    CrntDspObj.CurrentY = CrntLoc
    CrntDspObj.Print "时间:" & Tim$
    
    CrntLoc = CrntLoc + 576
    If FilNum% > 0 Or MEAS% Then
        If LobWidSW% Then
            If Not (LobWid%) Then
'                xP = 3
                HlfPwrWid xPW, xP
                LobWid% = -1
            End If
            CrntLoc = CrntLoc + 288
            CrntDspObj.CurrentX = LocX
            CrntDspObj.CurrentY = CrntLoc
            
            CrntDspObj.Print "3dB宽度:" & OnePoint(xPW * 360 / MaxAgl&)
            
        End If
        If SidLobLvlSW% Then
            If Not (SidLobLvl%) Then
                LokForSL CenAgl&, LA&, LL, RA&, RL
                LSA& = CenAgl& - LA&: If LSA& < 0 Then LSA& = LSA& + MaxAgl&
                RSA& = RA& - CenAgl&: If RSA& < 0 Then RSA& = RSA& + MaxAgl&
                SidLobLvl% = -1
            End If
            CrntLoc = CrntLoc + 288
            CrntDspObj.CurrentX = LocX
            CrntDspObj.CurrentY = CrntLoc
            CrntDspObj.Print "副瓣电平:"
            CrntLoc = CrntLoc + 288
            CrntDspObj.CurrentX = LocX
            CrntDspObj.CurrentY = CrntLoc
            
            CrntDspObj.Print "左:(" & OnePoint$(-LSA& * 360 / MaxAgl&) & ")=" & OnePoint$(-LL) & "(dB)"
            CrntLoc = CrntLoc + 288
            CrntDspObj.CurrentX = LocX
            CrntDspObj.CurrentY = CrntLoc
            CrntDspObj.Print "右:(" & OnePoint(RSA& * 360 / MaxAgl&) & ")=" & OnePoint(-RL) & "(dB)"
        End If
        If DirGainSW% Then
            If Not (DirGain%) Then
                CALDIRCOE Gx!
'                CALGAIN Gx!
                DirGain% = -1
            End If
            CrntLoc = CrntLoc + 288

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -