📄 frmsetnodelocation.frm
字号:
VERSION 5.00
Begin VB.Form frmSetNodeLocation
Caption = "设置坐标"
ClientHeight = 8055
ClientLeft = 60
ClientTop = 345
ClientWidth = 7320
LinkTopic = "Form1"
ScaleHeight = 8055
ScaleWidth = 7320
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton butConvert16to10
Caption = "16->10"
Height = 615
Left = 4680
TabIndex = 20
Top = 5160
Width = 1215
End
Begin VB.CommandButton butQueryNodeLocation
Caption = "查询"
Height = 495
Left = 3720
TabIndex = 19
Top = 960
Width = 1215
End
Begin VB.Timer Timer1
Left = 5880
Top = 1920
End
Begin VB.TextBox textNodeAddress
Height = 495
Left = 1080
TabIndex = 17
Top = 720
Width = 1695
End
Begin VB.CommandButton butConvert10to16
Caption = "10->16"
Height = 615
Left = 4680
TabIndex = 12
Top = 4200
Width = 1215
End
Begin VB.TextBox textAfterConverted
Height = 615
Left = 840
TabIndex = 11
Top = 5160
Width = 1575
End
Begin VB.TextBox textBeforeConverted
Height = 615
Left = 840
TabIndex = 10
Top = 4200
Width = 1575
End
Begin VB.CommandButton butSetNodeLocation
Caption = "设置"
Height = 495
Left = 3720
TabIndex = 8
Top = 1680
Width = 1215
End
Begin VB.CommandButton butCancel
Caption = "退出"
Height = 495
Left = 3720
TabIndex = 7
Top = 2400
Width = 1215
End
Begin VB.TextBox textZ
Height = 495
Left = 1080
TabIndex = 6
Top = 2520
Width = 1695
End
Begin VB.TextBox textY
Height = 495
Left = 1080
TabIndex = 5
Top = 1920
Width = 1695
End
Begin VB.TextBox textX
Height = 495
Left = 1080
TabIndex = 1
Top = 1320
Width = 1695
End
Begin VB.Label Label12
Caption = "RSSI"
Height = 375
Left = 5520
TabIndex = 23
Top = 360
Width = 855
End
Begin VB.Label labrssi
Height = 495
Left = 5640
TabIndex = 22
Top = 960
Width = 1215
End
Begin VB.Label Label11
Caption = "坐标转换"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 21
Top = 3600
Width = 1935
End
Begin VB.Line Line1
X1 = 0
X2 = 7200
Y1 = 3360
Y2 = 3360
End
Begin VB.Label Label10
Caption = "节点地址"
Height = 375
Left = 120
TabIndex = 18
Top = 840
Width = 855
End
Begin VB.Label Label9
Caption = "0X"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 16
Top = 5160
Width = 375
End
Begin VB.Label Label8
Caption = "在2431中,定位引擎使用高6表示坐标的整数部分,低两位表示坐标的小数部分"
ForeColor = &H000080FF&
Height = 375
Left = 240
TabIndex = 15
Top = 6120
Width = 6615
End
Begin VB.Label Label7
Caption = "16进制"
Height = 375
Left = 2760
TabIndex = 14
Top = 5280
Width = 1695
End
Begin VB.Label Label6
Caption = "10进制,精确到0.25"
Height = 375
Left = 2760
TabIndex = 13
Top = 4440
Width = 1575
End
Begin VB.Label Label5
Caption = "请检查串口是否已经正确连接到节点上"
ForeColor = &H000000FF&
Height = 375
Left = 1080
TabIndex = 9
Top = 6720
Width = 3615
End
Begin VB.Label Label4
Caption = "Z"
Height = 375
Left = 600
TabIndex = 4
Top = 2640
Width = 375
End
Begin VB.Label Label3
Caption = "Y"
Height = 375
Left = 600
TabIndex = 3
Top = 2040
Width = 375
End
Begin VB.Label Label2
Caption = "X"
Height = 375
Left = 600
TabIndex = 2
Top = 1440
Width = 375
End
Begin VB.Label Label1
Caption = "请输入节点的坐标(16进制,不包括0x)"
ForeColor = &H000000FF&
Height = 375
Left = 0
TabIndex = 0
Top = 360
Width = 3375
End
End
Attribute VB_Name = "frmSetNodeLocation"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim timeout As Boolean
Dim isreceived As Boolean
Option Explicit
Private Sub butCancel_Click()
If (MsgBox("确定退出吗?", vbOKCancel, "Confirm") = vbOK) Then
Unload Me
MainForm.Show
End If
End Sub
Private Sub butConvert10to16_Click()
Dim doubleBeforeConverted As Double
Dim dotpos As Integer
Dim afterdot As Integer ' 00 1 0.25 1 0.5 2 0.75 3
Dim beforedot As Integer
If Trim(textBeforeConverted.Text) = "" Then
MsgBox "请输入要转换的坐标", vbOKOnly, "error"
Exit Sub
End If
doubleBeforeConverted = CDbl(Trim(textBeforeConverted.Text))
If doubleBeforeConverted > 63.75 Then
MsgBox "坐标最大为63.75", vbOKOnly, "error"
Exit Sub
End If
dotpos = InStr(textBeforeConverted.Text, ".")
If dotpos = 0 Then
'没有小数点
afterdot = 0
beforedot = CInt(textBeforeConverted.Text)
Else
'如果有小数点
beforedot = CInt(Left(Trim(textBeforeConverted.Text), dotpos - 1))
If (Len(Trim(textBeforeConverted.Text))) - dotpos = 1 Then
'1位小数
Select Case Right(Trim(textBeforeConverted.Text), 1)
Case "5"
afterdot = 2
Case "0"
afterdot = 0
Case Else
MsgBox "1位小数只能为0.0,0.5", vbOKOnly, "error"
Exit Sub
End Select
ElseIf (Len(Trim(textBeforeConverted.Text))) - dotpos = 2 Then
Select Case Right(Trim(textBeforeConverted.Text), 2)
Case "00"
afterdot = 0
Case "25"
afterdot = 1
Case "50"
afterdot = 2
Case "75"
afterdot = 3
Case Else
MsgBox "2位小数只能为0.00,0.25,0.50,0.75", vbOKOnly, "error"
Exit Sub
End Select
Else
MsgBox "小数点后最多为2位", vbOKOnly, "error"
Exit Sub
End If
End If
textAfterConverted.Text = Hex(beforedot * 4 + afterdot)
End Sub
Private Sub butSetNodeLocation_Click()
Dim strNodeLocationX As String
Dim strNodeLocationY As String
Dim strNodeLocationZ As String
Dim strNodeAddress As String
Dim i As Integer
strNodeAddress = Trim(textNodeAddress)
strNodeLocationX = Trim(textX.Text)
strNodeLocationY = Trim(textY.Text)
strNodeLocationZ = Trim(textZ.Text)
If (strNodeAddress = "") Then
MsgBox "请输入节点地址", vbOKOnly, "Error"
Exit Sub
End If
If (Len(strNodeAddress) > 2) Then
MsgBox "请输入正确的节点地址信息(长度小于2)", vbOKOnly, "Error"
Exit Sub
End If
If Not isHex(Left(strNodeAddress, 1)) Then
MsgBox "请输入正确的节点地址", vbOKOnly, "Error"
Exit Sub
End If
If Not isHex(Right(strNodeAddress, 1)) Then
MsgBox "请输入正确的节点地址", vbOKOnly, "Error"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -