?? cmdmod.bas
字號:
Attribute VB_Name = "CmdMod"
Declare Function GetTickCount Lib "kernel32" () As Long
''''''''''''''''''''''''''''''''''''''''''''''''
'將分析儀上的按鍵以定義的方式先行定義
'這些定義都是對應到一些特定的字元
'程式中只要給定這些定好的字元,即可進行傳輸
'定好的通用字串比較容易了解
''''''''''''''''''''''''''''''''''''''''''''''''
Public Const SystemReset = "ZrE"
'Public Const ReturnKey = Chr$(13)
'Public Const LFKey = Chr$(10)
'Public Const SpaceKey = Chr$(&H20)
Public Const ShiftKey = "!"
Public Const LeftKey = "l"
Public Const RightKey = "r"
Public Const UpKey = "u"
Public Const DownKey = "d"
Public Const EnterKey = "E"
Public Const DataKey = "Y"
Public Const FormatKey = "F"
Public Const ScaleKey = "S"
Public Const FreqKey = "Q"
Public Const InputKey = "I"
Public Const TriggerKey = "T"
Public Const StartKey = "Gw"
Public Const PauseKey = "P"
Public Const AvgKey = "V"
Public Const SaveKey = "M"
Public Const UtilityKey = "U"
Public Const InstKey = "Z"
Public Const SystemInfo = "?"
Public Const TraceDump = "J"
Public Const XDump = "j"
Public Const FirstUpItem = "!u"
Public Const FirstLeftItem = "!l"
Public Const SetupPara = "i"
Public Const ShowStatus = "!1"
Public Const GetStatus = "!9"
Public Const SCH1Couple = "COUPLE CH1:"
Public Const SCH2Couple = "COUPLE CH2:"
Public Const Ch12Weight = "WEIGHT:"
Public Const SNDRepeat = "REPEAT:"
Public Const SNDAccept = "U ACCEPT:"
Public Const SNDSlope = "SLOPE:"
Public Const SNDAutoSave = "AUTOSAVE:"
Public Const SNDExceedan = "EXCEEDAN:"
Public Const SNDIncrUpd = "INCR UPD:"
Public Const SNDImpulse = "IMPULSE:"
'Other Definition
Public Const Octave_Mode = 0
Public Const Narrow_Mode = 1
'宣告系統設定之常數,給SetupInfo的傳回值用
Public Const InstrumentMode = 0
Public Const OptionNo = 1
Public Const PrintType = 2
Public Const DisplayType = 3
Public Const ActiveNo = 4
Public Const ChannelCount = 5
Public Const FreqResolution = 6
Public Const Y1Unit = 7
Public Const Y2Unit = 8
'測試用陣列
Public Test(12) As Integer
Public TestC(12) As String
Public tests1(2000) As Single
''''''''''''''''''''''''''''''''''''''''''''''''''
'設定Attenuate大小的函式
'0:0dB,1:5dB,2:10dB,3:15dB,4:20dB,5:25dB,6:30dB
''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Attenuate(ComPort As MSComm, Value As Integer)
ComPort.Output = InputKey
ComPort.Output = FirstLeftItem + RightKey + RightKey + RightKey
ComPort.Output = RightKey + RightKey + FirstUpItem
While Value > 0
ComPort.Output = DownKey
TimeDelay 100
Value = Value - 1
Wend
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'設定頻率平均的副程式
'包括有模式、數量、及增量等
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQAvg(ComPort As MSComm, m_Mode As Integer, m_No As Integer, m_Incr As Integer)
Dim Count%, Info%(12), PreNo%
ComPort.Output = AvgKey
TimeDelay 200
ComPort.Output = FirstLeftItem + FirstUpItem
Do Until m_Mode = 0
ComPort.Output = DownKey
TimeDelay 200
m_Mode = m_Mode - 1
Loop
ComPort.Output = RightKey
TimeDelay 200
ComPort.Output = Str(m_No) + EnterKey
TimeDelay 300
ComPort.Output = RightKey
'Incr Upd Setup
Count = 0
Do
ComPort.Output = AvgKey
If Info(8) = m_Incr Then
Exit Do
Else
ComPort.Output = EnterKey
TimeDelay 1000
If PreNo <> Info(8) Then Count = Count + 1
End If
PreNo = Info(8)
Loop Until Count > 10
If Count > 10 Then
MsgBox "Incr Upd 的設定出現逾時,請更改延遲時間!"
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'有關每個波道的頻率設定參數
'm_TraceA--0:Spec Ch1,1:Spec Ch2,2:Psd Ch1,3:Psd Ch2,4:Time Ch1
' 5:Time Ch2,6:Diff Ch1,7:Freq Resp,8:Coherence,9:Cross Cor
' 9:Cross Pow
'm_TraceB--0:Spec Ch1,1:Spec Ch2,2:Psd Ch1,3:Psd Ch2,4:Time Ch1
' 5:Time Ch2,6:Diff Ch1,7:Freq Resp,8:Coherence,9:Cross Cor
'm_AxisA--0:Lin Mag,1:Log Mag,2:dB Mag,3:Phase,4:Real,5:Imaginary
'm_AxisB--0:Lin Mag,1:Log Mag,2:dB Mag,3:Phase,4:Real,5:Imaginary
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQData(ComPort As MSComm, m_TraceA As Integer, m_TraceB As Integer, m_AxisA As Integer, m_AxisB As Integer)
ComPort.Output = DataKey
ComPort.Output = FirstLeftItem + FirstUpItem
Do
If m_TraceA = 0 Then Exit Do
ComPort.Output = DownKey
m_TraceA = m_TraceA - 1
Loop
TimeDelay 200
ComPort.Output = RightKey + FirstUpItem
Do
If m_TraceB = 0 Then Exit Do
ComPort.Output = DownKey
m_TraceB = m_TraceB - 1
Loop
TimeDelay 200
ComPort.Output = RightKey + FirstUpItem
Do
If m_AxisA = 0 Then Exit Do
ComPort.Output = DownKey
m_AxisA = m_AxisA - 1
Loop
TimeDelay 200
ComPort.Output = RightKey + FirstUpItem
Do
If m_AxisB = 0 Then Exit Do
ComPort.Output = DownKey
m_AxisB = m_AxisB - 1
Loop
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'將頻域的資料抓回來的函式
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FreqDataDump(ComPort As MSComm, m_YData() As Single)
'ComPort:Com Port No.
'm_YData:Y axis data
Dim Buf$, Position%, BufStr$
Dim DataNo%, I%
''Trace dump process
ComPort.InputLen = 0
Buf = ComPort.Input
Buf = ""
ComPort.Output = TraceDump
TimeDelay 1000
Do
Buf = Trim(ComPort.Input)
BufStr = Buf
TimeDelay 100
Loop Until Len(Buf) > 20
Buf = Right(Buf, Len(Buf) - 1)
Position = InStr(Buf, ",")
DataNo = Val(Mid(Buf, 1, Position - 1))
Buf = Right(Buf, Len(Buf) - Position)
For I = 0 To DataNo - 2
Do
Position = InStr(Buf, ",")
If Position < 1 Then
Buf = Buf + Trim(ComPort.Input)
TimeDelay 50
End If
Loop Until Position >= 1
m_YData(I) = Val(Mid(Buf, 1, Position - 1))
If I = DataNo - 1 Then Exit For
Buf = Right(Buf, Len(Buf) - Position)
Next
m_YData(DataNo - 1) = Val(Buf)
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'將頻域的格式作設定
'm_Format--0:A above B,1:A only ,2:B only,3:A front B
'm_Style--0:Trace,1:Freq Tabl,2:Ampl Tabl
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQFormat(ComPort As MSComm, m_Format As Integer, m_Style As Integer)
'Frequency Format Setting Sub
ComPort.Output = FormatKey
ComPort.Output = FirstLeftItem + FirstUpItem
Do
If m_Format = 0 Then Exit Do
ComPort.Output = DownKey
m_Format = m_Format - 1
TimeDelay 100
Loop
'TimeDelay 200
ComPort.Output = RightKey + RightKey + FirstUpItem
Do
If m_Style = 0 Then Exit Do
ComPort.Output = DownKey
m_Style = m_Style - 1
TimeDelay 100
Loop
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'將頻域的格式作設定
'Narrow Band 時的頻域設定
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQFreq(ComPort As MSComm, m_BaseBand As Integer, m_Resolution As Integer, m_Window As Integer, m_Filter As Integer, m_Force As Integer, m_Exp As Integer)
ComPort.Output = FreqKey
ComPort.Output = FirstLeftItem + FirstUpItem
Do
If m_BaseBand = 0 Then Exit Do
ComPort.Output = DownKey
TimeDelay 100
m_BaseBand = m_BaseBand - 1
Loop
ComPort.Output = RightKey + RightKey + FirstUpItem
Do
If m_Resolution = 0 Then Exit Do
ComPort.Output = DownKey
TimeDelay 100
m_Resolution = m_Resolution - 1
Loop
ComPort.Output = RightKey + FirstUpItem
Do
If m_Window = 0 Then Exit Do
ComPort.Output = DownKey
TimeDelay 100
m_Window = m_Window - 1
Loop
ComPort.Output = RightKey + FirstUpItem
Do
If m_Filter = 0 Then Exit Do
ComPort.Output = DownKey
TimeDelay 100
m_Filter = m_Filter - 1
Loop
ComPort.Output = RightKey + FirstUpItem
TimeDelay 100
ComPort.Output = Str(m_Force) + EnterKey
TimeDelay 100
ComPort.Output = DownKey
ComPort.Output = Str(m_Exp) + EnterKey
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Narrow Band量測時的Intensity 設定函式
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQIntensity(ComPort As MSComm, m_Temp As Single, m_Pres As Single, m_Dens As Single, m_Sep As Single)
ComPort.Output = InputKey
ComPort.Output = FirstLeftItem + LeftKey + FirstUpItem
TimeDelay 200
ComPort.Output = Str(m_Temp) + EnterKey
TimeDelay 100
ComPort.Output = DownKey
ComPort.Output = Str(m_Pres) + EnterKey
TimeDelay 100
ComPort.Output = DownKey
ComPort.Output = Str(m_Dens) + EnterKey
TimeDelay 100
ComPort.Output = DownKey
ComPort.Output = Str(m_Sep) + EnterKey
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'觸發設定函式
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FREQTrigger(ComPort As MSComm, m_Source As Integer, m_Repeat As Integer, m_delay1 As Integer, m_delay2 As Integer, m_Slope As Integer, m_Level As Integer)
Dim Count%, Info%(12), PreNo%
ComPort.Output = TriggerKey
TimeDelay 200
ComPort.Output = FirstLeftItem + FirstUpItem
Do Until m_Source = 0
ComPort.Output = DownKey
m_Source = m_Source - 1
TimeDelay 300
Loop
ComPort.Output = RightKey
'Repeat Setup
ComPort.Output = FirstUpItem
Count = 0
Do
' StatusInfo ComPort, Info()
ComPort.Output = TriggerKey
If Info(3) = m_Repeat Then
Exit Do
Else
ComPort.Output = EnterKey
TimeDelay 1000
If PreNo <> Info(3) Then Count = Count + 1
End If
PreNo = Info(3)
Loop Until Count > 10
If Count > 10 Then
MsgBox "Repeat 的設定出現逾時,請更改延遲時間!"
End If
ComPort.Output = DownKey + DownKey
TimeDelay 200
ComPort.Output = Str(m_delay1) + EnterKey
TimeDelay 500
ComPort.Output = DownKey
ComPort.Output = Str(m_delay2) + EnterKey
TimeDelay 200
ComPort.Output = RightKey
TimeDelay 200
ComPort.Output = FirstUpItem
'Slope Setup
Count = 0
Do
'StatusInfo ComPort, Info()
ComPort.Output = TriggerKey
If Info(5) = m_Slope Then
Exit Do
Else
ComPort.Output = EnterKey
TimeDelay 1000
If PreNo <> Info(5) Then Count = Count + 1
End If
PreNo = Info(5)
Loop Until Count > 10
If Count > 10 Then
MsgBox "Slope 的設定出現逾時,請更改延遲時間!"
End If
'dB Level Setup
ComPort.Output = DownKey
TimeDelay 500
ComPort.Output = Str(m_Level) + EnterKey
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'分析儀工具函式
'm_Time:index --0:Hour,1:Min,2:Sec.
' 3:Mon.,4:Day,5:Year
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Hp3569_Utility(ComPort As MSComm, m_Time() As Integer)
ComPort.Output = UtilityKey
ComPort.Output = FirstLeftItem + FirstUpItem
ComPort.Output = Str(m_Time(0))
ComPort.Output = DownKey
ComPort.Output = Str(m_Time(1))
ComPort.Output = DownKey
ComPort.Output = Str(m_Time(2))
ComPort.Output = DownKey
ComPort.Output = Str(m_Time(3))
ComPort.Output = DownKey
ComPort.Output = Str(m_Time(4))
ComPort.Output = DownKey
ComPort.Output = Str(m_Time(5))
ComPort.Output = DownKey
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'設定 Mic Pol 的值
'0:0V,1:200V
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub MicPol(ComPort As MSComm, Value As Integer)
ComPort.Output = InputKey
ComPort.Output = FirstLeftItem + RightKey + RightKey + RightKey
ComPort.Output = RightKey + RightKey + RightKey + FirstUpItem
While Value > 0
ComPort.Output = DownKey
Value = Value - 1
Wend
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'設定Source的型態
'SRCType:0:Off,1:Pink,2:White
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Source(ComPort As MSComm, SRCType As Integer)
ComPort.Output = InputKey
ComPort.Output = FirstLeftItem + RightKey + RightKey + RightKey
ComPort.Output = RightKey + FirstUpItem
While SRCType > 0
ComPort.Output = DownKey
SRCType = SRCType - 1
Wend
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -