初始化
This commit is contained in:
122
BLV_INFO.vb
Normal file
122
BLV_INFO.vb
Normal file
@@ -0,0 +1,122 @@
|
||||
Module BLV_INFO
|
||||
|
||||
Private DEBUG_PRINTF_EN As Byte = &H1
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 协议处理返回值
|
||||
''' </summary>
|
||||
Enum PROCESS_RETURN
|
||||
Correct
|
||||
Check_Error
|
||||
DevType_Error
|
||||
Len_Error
|
||||
Cmd_Error
|
||||
End Enum
|
||||
|
||||
''' <summary>
|
||||
''' BUS协议格式
|
||||
''' </summary>
|
||||
Enum BUS_PKT
|
||||
PKT_ADD_FM
|
||||
PKT_TYPE
|
||||
PKT_DevType
|
||||
PKT_ADD_TO
|
||||
PKT_LEN
|
||||
PKT_CHKSUM
|
||||
PKT_CMD
|
||||
PKT_PARA
|
||||
End Enum
|
||||
|
||||
Enum BUS_PKT2
|
||||
PKT_ADD_FM
|
||||
PKT_TYPE
|
||||
PKT_DevType
|
||||
PKT_ADD_TO
|
||||
PKT_LEN
|
||||
PKT_LEN_8
|
||||
PKT_CHKSUM
|
||||
PKT_CMD
|
||||
PKT_PARA
|
||||
End Enum
|
||||
|
||||
Enum DEBUG_WIN
|
||||
File_Info
|
||||
Content_Info
|
||||
End Enum
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 和校验取余数
|
||||
''' 求Byte数组的和校验取余数
|
||||
''' </summary>
|
||||
''' <param name="dataPacket">Byte数组</param>
|
||||
''' <returns>计算校验值</returns>
|
||||
Public Function CheckSum(dataPacket As Byte(), datalen As Byte) As Byte
|
||||
Dim sum As Integer
|
||||
For idx = 0 To datalen - 1
|
||||
sum += dataPacket(idx)
|
||||
sum = sum And &HFF
|
||||
Next
|
||||
Dim sumMod As Byte = &HFF - sum
|
||||
Return sumMod
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 调试信息输出到调试窗口信息
|
||||
''' </summary>
|
||||
''' <param name="str"></param>
|
||||
Public Sub DEBUG_Printf(str As String)
|
||||
If DEBUG_PRINTF_EN = &H1 Then
|
||||
Console.WriteLine(str & vbCrLf)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 将调试信息输出到界面窗口中
|
||||
''' </summary>
|
||||
''' <param name="type">选择输出窗口</param>
|
||||
''' <param name="str">输出的信息</param>
|
||||
''' <param name="col">输出信息颜色</param>
|
||||
Public Sub Debug_Info_Display_On_Window(type As Byte, str As String, col As Color)
|
||||
Dim show_str As String = str
|
||||
Select Case type
|
||||
Case DEBUG_WIN.File_Info '文件解析信息内容显示窗口
|
||||
If Form1.CheckBox1.Checked = True Then '判断当前是否打开该窗口
|
||||
|
||||
Form1.RichTextBox1.SelectionStart = Form1.RichTextBox1.TextLength
|
||||
Form1.RichTextBox1.SelectionColor = col
|
||||
Form1.RichTextBox1.AppendText(show_str & vbCrLf)
|
||||
|
||||
|
||||
End If
|
||||
Case DEBUG_WIN.Content_Info '数据内容解析信息显示窗口
|
||||
If Form1.CheckBox2.Checked = True Then '判断当前是否打开该窗口
|
||||
|
||||
Form1.RichTextBox2.SelectionStart = Form1.RichTextBox2.TextLength
|
||||
Form1.RichTextBox2.SelectionColor = col
|
||||
Form1.RichTextBox2.AppendText(show_str & vbCrLf)
|
||||
|
||||
End If
|
||||
Case Else
|
||||
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Debug_Display_Clear(type As Byte)
|
||||
Select Case type
|
||||
Case DEBUG_WIN.File_Info '文件解析信息内容显示窗口
|
||||
Form1.RichTextBox1.Clear()
|
||||
Case DEBUG_WIN.Content_Info '数据内容解析信息显示窗口
|
||||
Form1.RichTextBox2.Clear()
|
||||
Case Else
|
||||
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
End Module
|
||||
Reference in New Issue
Block a user