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

📄 dgp.frm

📁 通过GPIB接口读取频谱仪的测试曲线
💻 FRM
📖 第 1 页 / 共 5 页
字号:
        txtRP.Enabled = True
        txtATT.Enabled = False
    
    Case Else
    End Select
    
End Sub
Sub AzimStop()
    SendServoCmd "RU"
    Toolbar1.Buttons(2).value = tbrPressed
End Sub
Sub AzimSpinCloc()
    SendServoCmd "RP"
    Toolbar1.Buttons(3).value = tbrPressed
End Sub
Sub AzimSpinUnti()
    SendServoCmd "RN"
    Toolbar1.Buttons(1).value = tbrPressed
End Sub
Private Sub Timer1_Timer()
    Static PitcMapAngl, AzimMapAngl, TempAgl As Long
    Static PrePitcTime, CrntPitctime, CrntAzimTime, PreAzimTime As Double
    Static SysClk As Integer
    Static SpinAngl As Long
    If CrntAre <> PreAre Then
        Select Case CrntAre
        Case 0
            If PreAre = 3 Then
                CrntSpins = CrntSpins + 1
                If CrntSpins > 2 Then
                    AzimStop
                End If
                txtSpinNumb.Text = Str$(CrntSpins)
    '            StatusBar1.Panels.Item(6).Text = "圈数:" & Str(CrntSpins)
            End If
        Case 3
            If PreAre = 0 Then
                CrntSpins = CrntSpins - 1
                If CrntSpins < -2 Then
                    AzimStop
                End If
                txtSpinNumb.Text = Str$(CrntSpins)
    '           StatusBar1.Panels.Item(6).Text = "圈数:" & Str(CrntSpins)
            End If
        Case Else
        End Select
        PreAre = CrntAre
    End If
    If PitcMapAngl <> CrntPitcAngl Then
        TempAgl = CrntPitcAngl
        PitcSpinDisp TempAgl
        PitcMapAngl = TempAgl
    End If
    If CrntAzimAngl <> AzimMapAngl Then
'       TempAgl = 90 - CrntAzimAngl - AzimSpecAngl + AzimSpinSta.MaxAgl / 2
'       TempAgl = 0.75 * AzimSpinSta.MaxAgl - CrntAzimAngl - AzimSpecAngl
        TempAgl = CrntAzimAngl
        AzimSpinDisp TempAgl
        AzimMapAngl = CrntAzimAngl
        
    End If
    
'            StatusBar1.Panels.Item(6).Text = "圈数:" & Str(CrntAre)
    txtSpinNumb.Text = Str$(CrntSpins)
    SysClk = SysClk + 1
    If SysClk > 100 Then
        SysClk = 0
'        TranMess "TI"'
'        RetuMess RT$
 '       CrntAzimTime = Val(RT$)
        CrntAzimTime = Timer
        TempAngl = CrntAzimAngl
        AnglDiff = Abs(TempAngl - SpinAngl)
        If AnglDiff > AzimSpinSta.MaxAgl / 2 Then
            AnglDiff = AzimSpinSta.MaxAgl - AnglDiff
        End If
        If AnglDiff > 0 Then
            AzimPeri = AzimSpinSta.MaxAgl * (CrntAzimTime - PreAzimTime) / AnglDiff
            txtCrntAzimSpinSpee.Text = Str$(AzimPeri)
'            txtSweeBegeAngl.Text = Str$(CrntAzimTime - PreAzimTime)
'            txtSweeEndAngl.Text = Str$(AnglDiff)
        Else
            txtCrntAzimSpinSpee.Text = "Stop"
        End If
        PreAzimTime = CrntAzimTime
        SpinAngl = TempAngl
   End If
     
End Sub

'
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  Dim TempAngl As Long
    Select Case Button.Key
    Case "toolTurnLeft"
        If CrntSpins > -2 Then
            AzimSpinUnti
        Else
            AzimStop
        End If
'        SpinDir = False
        
    Case "toolStopRotate"
        AzimStop
    Case "toolClockWise"
           If CrntSpins < 2 Then
           AzimSpinCloc
        Else
            AzimStop
        End If
'        SpinDir = True
    Case "toolAutoSpin"
        If Toolbar1.Buttons(2).value = tbrPressed Then
            If CrntSpins < 0 Then
                AzimSpinCloc
            Else
                AzimSpinUnti
            End If
            
        Else
            AzimStop
        End If
    Case "toolSpdInc"
            AzimSpinSta.CrntSpd = AzimSpinSta.CrntSpd * 1.1
        If AzimSpinSta.CrntSpd > AzimSpinSta.MaxSpd Then
            AzimSpinSta.CrntSpd = AzimSpinSta.MaxSpd
        End If
        SendServoCmd "RS" & AzimSpinSta.CrntSpd

    Case "toolSpdDec"
           AzimSpinSta.CrntSpd = AzimSpinSta.CrntSpd * 0.9
        If AzimSpinSta.CrntSpd < AzimSpinSta.MinSpd Then
            AzimSpinSta.CrntSpd = AzimSpinSta.MinSpd
        End If
        SendServoCmd "RS" & AzimSpinSta.CrntSpd
    Case "toolMaxSpd"
            AzimSpinSta.CrntSpd = AzimSpinSta.MaxSpd
        SendServoCmd "RS" & AzimSpinSta.CrntSpd
 '       StatusBar1.Panels.Item(6).Text = "转速:" & AzimSpinSta.CrntSpd
    Case "toolMinSpd"
          AzimSpinSta.CrntSpd = AzimSpinSta.MinSpd
        SendServoCmd "RS" & AzimSpinSta.CrntSpd
'        StatusBar1.Panels.Item(6).Text = "转速:" & AzimSpinSta.CrntSpd
    Case "toolToObj"
    Case "toolAngleToZero"
            AzimSpecAngl = CrntAzimAngl
            TempAngl = CrntAzimAngl
            AzimSpinDisp TempAngl
    Case "toolSpdCal"
    Case "toolFanScan"
    Case "toolAutoSpin"
        If SpinMtv Then
            SendServoCmd "RU"
            SpinMtv = False
            Toolbar1.Buttons(2).value = tbrPressed
        Else
            If CrntSpins > 0 Then
'                SpinDir = False
'                    SendServoCmd "RP"
                    SendServoCmd "RN"
                Toolbar1.Buttons(1).value = tbrPressed
        Else
'                SpinDir = True
'                SendServoCmd "RN"
                SendServoCmd "RP"
                Toolbar1.Buttons(3).value = tbrPressed
        End If
            SpinMtv = True
        End If
    End Select
    
End Sub

Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
    Dim TempAngl As Long
Select Case Button.Key
Case "toolGoUp"
        SendPitcCmd "RP"
Case "toolStop"
        SendPitcCmd "RU"
Case "toolGoDown"
        SendPitcCmd "RN"
Case "tool2SpeeIncr"
        DA = PitcSpinSta.CrntSpd / 10
        If DA < 1 Then DA = 1
        PitcSpinSta.CrntSpd = PitcSpinSta.CrntSpd + DA
        If PitcSpinSta.CrntSpd > PitcSpinSta.MaxSpd Then
            PitcSpinSta.CrntSpd = PitcSpinSta.MaxSpd
        End If
        RefuRotSpd

Case "tool2SpeeDec"
        DA = PitcSpinSta.CrntSpd / 10
        If DA < 1 Then DA = 1
        PitcSpinSta.CrntSpd = PitcSpinSta.CrntSpd - DA
        If PitcSpinSta.CrntSpd < PitcSpinSta.MinSpd Then
            PitcSpinSta.CrntSpd = PitcSpinSta.MinSpd
        End If
        RefuRotSpd

Case "tool2MaxSpee"
        PitcSpinSta.CrntSpd = PitcSpinSta.MaxSpd
        RefuRotSpd

Case "tool2MinSpee"
        PitcSpinSta.CrntSpd = PitcSpinSta.MinSpd
        RefuRotSpd

Case "toolToObjeAngl"
Case "toolToZero"
            PitcSpecAngl = CrntPitcAngl
            TempAngl = CrntPitcAngl
            PitcSpinDisp TempAngl
End Select

End Sub

Sub RefuRotSpd()
        SendPitcCmd "RS" & PitcSpinSta.CrntSpd
'        StatBar.Panels.Item(2).Text = "转速设置:" & PitcSpinSta.CrntSpd
End Sub

Sub SendCmd(ByVal cmd As String)
    Dim TempStr As String
    TempStr = cmd & ChrB$(13) & ChrB$(10)
'    Send TempStr, ReceNo
'    ibwrt ReceNo, TempStr
'     iwrite RecNo, TempStr
    'ibwrt ReceNo, cmd
    iwrite ReceNo, TempStr, Len(TempStr), 1, ac
    
End Sub

'Private Sub Form_Load()
'    MSComm1.PortOpen = True
'    Text2.Text = MSComm1.Settings
'End Sub
Sub Enter(RtnDat$, Pnts%, addr%)
  Dim TempStr As String
  Dim TempChr As String
  Dim StartTim As Single
  Dim TempInt As Integer
  If Pnts% = 0 Then
    TempStr = "ENTER " & addr%
    MSComm1.Output = TempStr
    CRLF
  End If
    StartTim = Timer
    TempChr = ""
    TempStr = ""
    While TempChr <> ChrB$(10)
        If MSComm1.InBufferCount > 0 Then
            TempChr = MSComm1.Input
'           If AscB(TempChr) = 0 Then GoTo mm
'            tempint = AscB(TempChr)
            TempStr = TempStr & Chr$(AscB(TempChr))
            StartTim = Timer
        ElseIf Timer - StartTim > 2 Then
'            Print "Enter overtime"
'            Beep
            RtnDat$ = TempStr
'            RtnDat$ = ""
           Exit Sub
        End If
     Wend
mm:
  
'    While AscB(TempChr) <> 10
'        If MSComm1.InBufferCount > 0 Then
'            TempChr = MSComm1.Input
'            tempint = AscB(TempChr)
'        ElseIf Timer - StartTim > 5 Then
'           RtnDat$ = TempStr
''           Exit Sub
'        End If
'     Wend
     RtnDat$ = TempStr
    
End Sub

Sub Send(SendDat$, addr%)
    MSComm1.Output = "SEND " & addr%
    MSComm1.Output = Chr$(10)
    MSComm1.Output = SendDat$
    CRLF
End Sub
Sub TranMess(TM$)
    MSComm1.Output = TM$
    CRLF
End Sub
Sub RtnLoc(addr%)
    MSComm1.Output = "LOCAL" & addr%
    CRLF
End Sub


Sub CRLF()
    Dim TempByt(0) As Byte
    TempByt(0) = &HD
    MSComm1.Output = TempByt
    TempByt(0) = &HA
    MSComm1.Output = TempByt
End Sub

Sub SendServoCmd(CmdStr$)
     If MSCommSerVo.PortOpen = False Then
        MSCommSerVo.PortOpen = True
    End If
    MSCommSerVo.Output = "MBRC0:" & CmdStr & "/" & Chr$(13) & Chr$(10)
End Sub

Sub SendPitcCmd(CmdStr As String)
    If MSCommSerVo.PortOpen = False Then
        MSCommSerVo.PortOpen = True
    End If
    MSCommSerVo.Output = "MBRC1:" & CmdStr & "/" & Chr$(13) & Chr$(10)
End Sub

Sub PitcSpinDisp(Angl As Long)
Dim TempAgl As Long
Dim Agl As Double
    TempAgl = Angl - PitcSpecAngl
    If TempAgl < 0 Then
        TempAgl = TempAgl + PitcSpinSta.MaxAgl
    ElseIf TempAgl > PitcSpinSta.MaxAgl Then
        TempAgl = TempAgl - PitcSpinSta.MaxAgl
    End If
    txtCrntPitcAngl.Text = Str$(TempAgl * 360 / PitcSpinSta.MaxAgl)
    Agl = 1.570796 + 2 * 3.1415926 * TempAgl / PitcSpinSta.MaxAgl
   PitcPole = 0.75 * Picture2.ScaleHeight
   X2 = Line2.X1 + PitcPole * Cos(Agl)
   Y2 = Line2.Y1 - PitcPole * Sin(Agl)
   Line2.X2 = X2
   Line2.Y2 = Y2
    
End Sub

Sub AzimSpinDisp(Angl As Long)

    Const AzimPoleR = 720
    Dim TempAgl As Long
    TempAgl = Angl - AzimSpecAngl
    If TempAgl < 0 Then
        TempAgl = TempAgl + AzimSpinSta.MaxAgl
    ElseIf TempAgl > AzimSpinSta.MaxAgl Then
        TempAgl = TempAgl - AzimSpinSta.MaxAgl
    End If
    txtCrntAzimAngl.Text = Str$(TempAgl * 360 / AzimSpinSta.MaxAgl)
    TempAngl = 1.570796 - 2 * 3.1415926 * TempAgl / AzimSpinSta.MaxAgl
    AzimPole.X2 = AzimPole.X1 + AzimPoleR * Cos(TempAngl)
    AzimPole.Y2 = AzimPole.Y1 - AzimPoleR * Sin(TempAngl)
    
   
End Sub

Function AnglVsSpec(Angl As Long) As Long
    Dim TempAgl As Long
    TempAgl = Angl - AzimSpecAngl
    If TempAgl < 0 Then
        TempAgl = TempAgl + AzimSpinSta.MaxAgl
    ElseIf TempAgl > AzimSpinSta.MaxAgl Then
        TempAgl = TempAgl - AzimSpinSta.MaxAgl
    End If
    AnglVsSpec = TempAgl
End Function

Function AnglNorm(Angl As Single)

    If Angl > 6.283185 Then
        AnglNorm = Angl - 6.283185307
    ElseIf Angl < -6.283185307 Then
        AnglNorm = Angl + 6.283185307
    Else
        AnglNorm = Angl
    End If
    
End Function

Private Sub txtInstAddr_Change()
    ReceAddr = Val(txtInstAddr.Text)
'    ibdev 0, ReceAddr, 0, T3s, 1, 0, ReceNo
    iclose RecNo
    ReceNo = iopen("gpib0," & txtInstAddr.Text)
End Sub

⌨️ 快捷键说明

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