📄 form3.frm
字号:
TabIndex = 16
Top = 1320
Width = 1095
End
End
Begin VB.Label Label10
Caption = "端口:"
Height = 315
Left = 240
TabIndex = 33
Top = 180
Width = 495
End
End
End
Begin VB.Frame Frame1
Height = 4215
Left = 120
TabIndex = 1
Top = 480
Width = 5895
Begin VB.Frame Frame5
Height = 2055
Left = 240
TabIndex = 5
Top = 360
Width = 4935
Begin VB.TextBox Text4
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3720
TabIndex = 9
Text = "55"
Top = 1440
Width = 975
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3720
TabIndex = 8
Text = "0.05"
Top = 480
Width = 975
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 7
Text = "2"
Top = 1440
Width = 975
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 6
Text = "1.5"
Top = 480
Width = 975
End
Begin VB.Label Label5
Caption = "T值:"
Height = 375
Left = 2880
TabIndex = 13
Top = 1440
Width = 615
End
Begin VB.Label Label3
Caption = "Td 值:"
Height = 495
Left = 2760
TabIndex = 12
Top = 480
Width = 735
End
Begin VB.Label Label2
Caption = "Ti 值:"
Height = 255
Left = 360
TabIndex = 11
Top = 1560
Width = 735
End
Begin VB.Label Label1
Caption = "Kp 值:"
Height = 255
Left = 480
TabIndex = 10
Top = 480
Width = 735
End
End
End
Begin MSComctlLib.TabStrip TabStrip1
Height = 4935
Left = 0
TabIndex = 0
Top = 0
Width = 6135
_ExtentX = 10821
_ExtentY = 8705
TabWidthStyle = 2
MultiRow = -1 'True
TabStyle = 1
_Version = 393216
BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628}
NumTabs = 4
BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "pid"
Key = "pid"
ImageVarType = 2
EndProperty
BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "串口"
Key = "io"
ImageVarType = 2
EndProperty
BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "其他"
Key = "other"
ImageVarType = 2
EndProperty
BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "模式"
Key = "mode"
ImageVarType = 2
EndProperty
EndProperty
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub LoadPropertySettings() '载入窗体数据
Dim i As Integer, Settings As String, Offset As Integer
' 载入端口设置
For i = 1 To 16
cboPort.AddItem "Com" & Trim$(Str$(i))
Next i
' Load Speed Settings
cboSpeed.AddItem "110"
cboSpeed.AddItem "300"
cboSpeed.AddItem "600"
cboSpeed.AddItem "1200"
cboSpeed.AddItem "2400"
cboSpeed.AddItem "4800"
cboSpeed.AddItem "9600"
cboSpeed.AddItem "14400"
cboSpeed.AddItem "19200"
cboSpeed.AddItem "28800"
cboSpeed.AddItem "38400"
cboSpeed.AddItem "56000"
cboSpeed.AddItem "57600"
cboSpeed.AddItem "115200"
cboSpeed.AddItem "128000"
cboSpeed.AddItem "256000"
' 载入数据位设置
cboDataBits.AddItem "4"
cboDataBits.AddItem "5"
cboDataBits.AddItem "6"
cboDataBits.AddItem "7"
cboDataBits.AddItem "8"
' 载入奇偶检验设置
cboParity.AddItem "Even"
cboParity.AddItem "Odd"
cboParity.AddItem "None"
cboParity.AddItem "Mark"
cboParity.AddItem "Space"
' 载入停止位设置
cboStopBits.AddItem "1"
cboStopBits.AddItem "1.5"
cboStopBits.AddItem "2"
' 设置默认的设置
Settings = Form1.MSComm1.Settings
' 在大多数情况下,右边的大部分设置将为一个字符
' 除了可能出现的 1.5 停止位.
If InStr(Settings, ".") > 0 Then
Offset = 2
Else
Offset = 0
End If
cboSpeed.Text = Left$(Settings, Len(Settings) - 6 - Offset)
Select Case Mid$(Settings, Len(Settings) - 4 - Offset, 1)
Case "e"
cboParity.ListIndex = 0
Case "m"
cboParity.ListIndex = 1
Case "n"
cboParity.ListIndex = 2
Case "o"
cboParity.ListIndex = 3
Case "s"
cboParity.ListIndex = 4
End Select
cboDataBits.Text = Mid$(Settings, Len(Settings) - 2 - Offset, 1)
cboStopBits.Text = Right$(Settings, 1 + Offset)
cboPort.ListIndex = Form1.MSComm1.CommPort - 1
optFlow(Form1.MSComm1.Handshaking).Value = True
If Echo Then
optEcho(1).Value = True
Else
optEcho(0).Value = True
End If
End Sub
Private Sub Command1_Click()
acpci.Kp = Text1.Text
acpci.Ti = Text2.Text
acpci.Td = Text3.Text
acpci.T = Text4.Text / 1000#
acpci.Sr = Text5.Text
acpci.a = Text6.Text
'---------------------
Dim OldPort As Integer, ReOpen As Boolean
On Error Resume Next
Echo = iTempEcho
OldPort = Form1.MSComm1.CommPort
NewPort = cboPort.ListIndex + 1
If NewPort <> OldPort Then ' 如果端口号被更改, 关闭原来的端口。
If Form1.MSComm1.PortOpen Then
Form1.MSComm1.PortOpen = False
ReOpen = True
End If
Form1.MSComm1.CommPort = NewPort ' 设置新的端口号。
If Err = 0 Then
If ReOpen Then
Form1.MSComm1.PortOpen = True
End If
End If
If Err Then
MsgBox Error$, 48
Form1.MSComm1.CommPort = OldPort
Exit Sub
End If
End If
Form1.MSComm1.Settings = Trim$(cboSpeed.Text) & "," & Left$(cboParity.Text, 1) _
& "," & Trim$(cboDataBits.Text) & "," & Trim$(cboStopBits.Text)
If Err Then
MsgBox Error$, 48
Exit Sub
End If
Form1.MSComm1.Handshaking = iFlow
If Err Then
MsgBox Error$, 48
Exit Sub
End If
Unload Me
End Sub
Private Sub Command2_Click()
Dialog.ShowOpen
acpci.FileName = Dialog.FileName
filepath.Text = acpci.FileName
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
acpci.Kp = 1.5
acpci.Ti = 2
acpci.Td = 0.05
acpci.T = 0.055
acpci.Sr = 200
acpci.a = 0.8
Unload Me
End Sub
Private Sub Form_Load()
LoadPropertySettings '----------------
Text1.Text = Format(acpci.Kp, "##0.0###")
Text2.Text = Format(acpci.Ti, "##0.0###")
Text3.Text = Format(acpci.Td, "##0.0###")
Text4.Text = Format(acpci.T * 1000, "##0.0###")
Text5.Text = Format(acpci.Sr, "##0.0###")
Text6.Text = Format(acpci.a, "##0.0###")
filepath.Text = acpci.FileName
Form1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form1.Enabled = True
End Sub
Private Sub Option1_Click()
CMD = &H22 '控制命令 输出
D1 = 1
D2 = 0
Call send_data(CMD, D1, D2)
End Sub
Private Sub Option2_Click()
CMD = &H22 '控制命令 输出
D1 = 2
D2 = 0
Call send_data(CMD, D1, D2)
End Sub
Private Sub Option3_Click()
CMD = &H22 '控制命令 输出
D1 = 3
D2 = 0
Call send_data(CMD, D1, D2)
End Sub
Private Sub TabStrip1_Click()
Select Case TabStrip1.SelectedItem.Key
Case "pid"
Frame1.ZOrder 0
Case "io"
Frame2.ZOrder 0
Case "other"
Frame4.ZOrder 0
Case "mode"
Frame3.ZOrder 0
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -