初始化
This commit is contained in:
BIN
.vs/485_BurningTool/v16/.suo
Normal file
BIN
.vs/485_BurningTool/v16/.suo
Normal file
Binary file not shown.
25
485_BurningTool.sln
Normal file
25
485_BurningTool.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32602.291
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "485_BurningTool", "485_BurningTool.vbproj", "{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6E7D9C31-FF2C-43F8-899C-CF746E324B37}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
165
485_BurningTool.vbproj
Normal file
165
485_BurningTool.vbproj
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1D83284A-C929-4386-B0BE-4F2A29D7D1DA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>_485_BurningTool.My.MyApplication</StartupObject>
|
||||
<RootNamespace>_485_BurningTool</RootNamespace>
|
||||
<AssemblyName>485_BurningTool</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>WindowsForms</MyType>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>485_BurningTool.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>485_BurningTool.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Drawing" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Windows.Forms" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommunicationFlow.vb" />
|
||||
<Compile Include="CommunicationProtocol\BLV_Bootloader\BLV_Bootloader.vb" />
|
||||
<Compile Include="CommunicationProtocol\BLV_Bootloader\SerialPort\SerialPort_BLV_Bootloader.vb" />
|
||||
<Compile Include="CommunicationProtocol\CommunicationProtocol.vb" />
|
||||
<Compile Include="CommunicationProtocol\CommunicationProtocolController.vb" />
|
||||
<Compile Include="Form1.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.vb">
|
||||
<DependentUpon>Form1.vb</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Log\RuningLog.vb" />
|
||||
<Compile Include="Mode\DataProcessing.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Transmitter\DevNetworkCommunication.vb" />
|
||||
<Compile Include="Transmitter\SerialController.vb" />
|
||||
<Compile Include="Transmitter\Transmitter.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CommunicationProtocol\BLV_Bootloader\BLV_Bootloader下载协议 V3.0.xlsx" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.8 %28x86 和 x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
14
485_BurningTool.vbproj.user
Normal file
14
485_BurningTool.vbproj.user
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
<PublishUrlHistory>publish\</PublishUrlHistory>
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>zh-CN</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
30
App.config
Normal file
30
App.config
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="_485_BurningTool.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<_485_BurningTool.My.MySettings>
|
||||
<setting name="m_Applicationconfig" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="UpBaud" serializeAs="String">
|
||||
<value>9600</value>
|
||||
</setting>
|
||||
<setting name="BootBaud" serializeAs="String">
|
||||
<value>9600</value>
|
||||
</setting>
|
||||
<setting name="ProtocolName" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="HexFilePath" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</_485_BurningTool.My.MySettings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
239
CommunicationFlow.vb
Normal file
239
CommunicationFlow.vb
Normal file
@@ -0,0 +1,239 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Reflection
|
||||
Imports System.Threading
|
||||
Imports _485_BurningTool.DataProcessing
|
||||
'通信流程
|
||||
Public MustInherit Class CommunicationFlow
|
||||
'通信类型枚举
|
||||
Public Enum CommunicationType
|
||||
None = 0
|
||||
<Description("串口")>
|
||||
SerialPort = 1
|
||||
<Description(" UDP")>
|
||||
Udp
|
||||
<Description("TCP")>
|
||||
TCP
|
||||
|
||||
maximum
|
||||
End Enum
|
||||
'协议类型枚举
|
||||
Public Enum ProtocolEnum
|
||||
<Description("BLV_Bootloader")>
|
||||
BLV_Bootloader
|
||||
|
||||
maximum
|
||||
End Enum
|
||||
'通信器变量
|
||||
Public m_CommunicationTypeIndex As CommunicationType = CommunicationType.SerialPort
|
||||
Public m_ProtocolEnumIndex As ProtocolEnum
|
||||
|
||||
'通信发送器对象
|
||||
Public m_Transmitter As Transmitter
|
||||
'通信接协议对象
|
||||
Public m_Receiver As CommunicationProtocol
|
||||
'运行线程
|
||||
Public m_RunThread As Thread
|
||||
'线程控制标志
|
||||
Public m_RunThreadFlag As Boolean = False
|
||||
'线程 参数
|
||||
Public m_Parameterlist As Parameterlist
|
||||
'更新界面线程
|
||||
Public m_UpdateUI As Thread
|
||||
|
||||
|
||||
|
||||
|
||||
'切换通信器
|
||||
Public Sub ChangeCommunicationType(portname As String, gControl As Control)
|
||||
Dim CommunicationStr As String
|
||||
For i = CommunicationType.SerialPort To CommunicationType.maximum
|
||||
CommunicationStr = GetEnumDescription(CType(i, CommunicationType))
|
||||
If CommunicationStr = portname Then
|
||||
If Not IsNothing(m_Transmitter) AndAlso m_Transmitter.IsTransmitter Then m_Transmitter.CloseTransmitter()
|
||||
m_CommunicationTypeIndex = i
|
||||
m_Transmitter = Transmitter.CreateTransmitter(m_CommunicationTypeIndex, gControl)
|
||||
|
||||
Return
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
'切换协议
|
||||
Public Sub ChangeProtocol(Protocolstr As String)
|
||||
Dim CommunicationStr As String
|
||||
For i = ProtocolEnum.BLV_Bootloader To ProtocolEnum.maximum - 1
|
||||
CommunicationStr = GetEnumDescription(CType(i, ProtocolEnum))
|
||||
If CommunicationStr = Protocolstr Then
|
||||
m_ProtocolEnumIndex = i
|
||||
'If m_CommunicationFlow.m_Receiver.IsCreateProtocol Then m_CommunicationFlow.m_Receiver.CloseTransmitter()
|
||||
'If m_CommunicationTypeIndex = CommunicationType.None Then
|
||||
' MsgBox("请先选择通信器通信方式!")
|
||||
' Return
|
||||
'End If
|
||||
m_Receiver = CommunicationProtocol.CreateAbstractObject(m_CommunicationTypeIndex, m_ProtocolEnumIndex)
|
||||
If Not IsNothing(m_Transmitter) Then
|
||||
m_Receiver.m_Transmitter = m_Transmitter
|
||||
End If
|
||||
' m_Receiver.m_Transmitter = m_Transmitter
|
||||
Return
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
'刷新发送器
|
||||
Public Sub RefreshTransmitter()
|
||||
If IsNothing(m_Receiver) Then Return
|
||||
m_Receiver.m_Transmitter = m_Transmitter
|
||||
|
||||
End Sub
|
||||
'启动线程
|
||||
Public Sub StartThread()
|
||||
'判断线程是否启动
|
||||
If m_RunThread Is Nothing OrElse m_RunThread.ThreadState = ThreadState.Stopped Then
|
||||
m_RunThread = New Thread(AddressOf Run)
|
||||
m_RunThread.Start()
|
||||
If m_UpdateUI Is Nothing OrElse m_UpdateUI.ThreadState = ThreadState.Stopped Then
|
||||
m_UpdateUI = New Thread(AddressOf RunUpdateUI)
|
||||
m_UpdateUI.Start()
|
||||
End If
|
||||
Else
|
||||
'm_RunThread.Abort()
|
||||
'm_RunThread = New Thread(AddressOf Run)
|
||||
'm_RunThread.Start()
|
||||
End If
|
||||
End Sub
|
||||
'停止线程
|
||||
Public Sub StopThread()
|
||||
If Not IsNothing(m_RunThread) Then
|
||||
m_RunThread.Abort()
|
||||
m_RunThread = Nothing
|
||||
|
||||
m_UpdateUI.Abort()
|
||||
m_UpdateUI = Nothing
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
'更新UI线程
|
||||
Private Sub RunUpdateUI()
|
||||
While True
|
||||
Thread.Sleep(5)
|
||||
If IsNothing(m_Receiver) OrElse IsNothing(m_Receiver.UpdateUIqueue) Then Continue While
|
||||
If m_Receiver.UpdateUIqueue.Count > 0 Then
|
||||
Dim str As (Control, RuningLogConfig, Integer) = m_Receiver.UpdateUIqueue.Dequeue()
|
||||
RuningLog.OutputLogsToTheControl(str.Item1, str.Item2, str.Item3)
|
||||
End If
|
||||
End While
|
||||
End Sub
|
||||
'添加队列
|
||||
|
||||
|
||||
|
||||
'设置线程参数
|
||||
Public Sub SetThreadParameter(Parameterlist As Parameterlist)
|
||||
Parameterlist.CommunicationTypeIndex = m_Transmitter.CommunicationTypeindex
|
||||
m_Parameterlist = Parameterlist
|
||||
m_Receiver.m_Transmitter.ClearSendData()
|
||||
SetThreadFlag(True)
|
||||
StartThread()
|
||||
End Sub
|
||||
|
||||
'设置线程标志
|
||||
Public Sub SetThreadFlag(flag As Boolean)
|
||||
m_RunThreadFlag = flag
|
||||
End Sub
|
||||
'判断当前是否运行
|
||||
Public Function GetRuningNode() As Boolean
|
||||
If m_Parameterlist.EnableFlag Then
|
||||
|
||||
'm_Parameterlist.Action
|
||||
|
||||
Return False
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
'线程运行
|
||||
Private Sub Run()
|
||||
While m_RunThreadFlag
|
||||
If m_Parameterlist.EnableFlag Then
|
||||
m_Receiver.Runing(m_Parameterlist, m_RunThreadFlag)
|
||||
End If
|
||||
Thread.Sleep(5)
|
||||
End While
|
||||
End Sub
|
||||
Public Function IsCreateProtocol() As Boolean
|
||||
If IsNothing(m_Receiver) Then Return False
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class CommunicationProtocolEntity
|
||||
Inherits CommunicationFlow
|
||||
Public Sub New()
|
||||
StartThread()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Public Class Parameterlist
|
||||
'启用标记
|
||||
Public EnableFlag As Boolean
|
||||
'动作类型
|
||||
Public Action As UInt32
|
||||
'下一步动作
|
||||
Public NextAction As UInt32
|
||||
'Public Action As
|
||||
'起始地址
|
||||
Public StartAddress As UInt32
|
||||
'接收地址
|
||||
Public ReceiveAddress As UInt32
|
||||
'接收地址范围长度
|
||||
Public ReceiveAddressRangeLength As UInt32
|
||||
'设备类型
|
||||
Public DeviceType As UInt32
|
||||
'bootloader 超时
|
||||
Public BootloaderTimeout As UInt32
|
||||
'有效时间
|
||||
Public ValidTime As UInt32
|
||||
|
||||
'boot 波特率
|
||||
Public BootBaudRate As UInt32
|
||||
|
||||
'APP波特率
|
||||
Public AppBaudRate As UInt32
|
||||
'升级波特率
|
||||
Public UpgradeBaudRate As UInt32
|
||||
|
||||
'当前步骤
|
||||
Public CurrentStep As Integer
|
||||
'成功跳转
|
||||
Public SuccessJump As Integer
|
||||
'失败跳转
|
||||
Public FailureJump As Integer
|
||||
'按钮
|
||||
Public btn As Button
|
||||
'表格
|
||||
Public DataGrid As DataGridView
|
||||
'富文本框
|
||||
Public RText_OutputText As RichTextBox
|
||||
'流程列表
|
||||
'通信器类型
|
||||
Public CommunicationTypeIndex As Integer
|
||||
Public ProcessList As List(Of (number As Integer, Cmdconfig))
|
||||
Public addtypeli As List(Of (Integer, Integer))
|
||||
Public addtypeliindx As Integer
|
||||
Public DevNumber As Integer
|
||||
Public NTimeOut As Integer
|
||||
Public Throughport As Integer '
|
||||
Public TransnDuion As Integer
|
||||
|
||||
Sub New()
|
||||
DevNumber = 1
|
||||
BootBaudRate = 2400
|
||||
NTimeOut = 10
|
||||
End Sub
|
||||
End Class
|
||||
324
CommunicationProtocol/BLV_Bootloader/BLV_Bootloader.vb
Normal file
324
CommunicationProtocol/BLV_Bootloader/BLV_Bootloader.vb
Normal file
@@ -0,0 +1,324 @@
|
||||
Imports System.ComponentModel
|
||||
Imports _485_BurningTool.CommunicationFlow
|
||||
Imports _485_BurningTool.RuningLog
|
||||
|
||||
Public MustInherit Class BLV_Bootloader
|
||||
Inherits CommunicationProtocol
|
||||
Public m_config As BLV_Bootloaderconfig
|
||||
Private SN As Integer
|
||||
Public m_flowdic As Dictionary(Of String, List(Of (Integer, Cmdconfig)))
|
||||
Enum CmdType
|
||||
<Description("等待回复")>
|
||||
WaitReply = 0
|
||||
<Description("处理回复")>
|
||||
ProcessReply = 1
|
||||
<Description("搜索命令")>
|
||||
SearchCommand = 192 'C0
|
||||
<Description("跳转命令")>
|
||||
skipCommand = 193
|
||||
<Description("设置参数")>
|
||||
SetUpParameters = 194
|
||||
<Description("写入Flash数据")>
|
||||
WriteFlashData = 195
|
||||
<Description("读取Flash数据")>
|
||||
ReadingFlashData = 196
|
||||
<Description("擦除Flash数据")>
|
||||
EraseFlashData = 197
|
||||
<Description("写入EEPROM数据")>
|
||||
WriteEEPROMData = 198
|
||||
<Description("读取EEPROM数据")>
|
||||
ReadingEEPROMData = 199
|
||||
<Description("擦除EEPROM数据")>
|
||||
EraseEEPROMData = 200
|
||||
<Description("校验命令")>
|
||||
CheckCommand = 201
|
||||
|
||||
End Enum
|
||||
|
||||
Enum WorkflowType
|
||||
none = 0
|
||||
<Description("搜索设备")>
|
||||
SearchEquipment = 192
|
||||
<Description("写入Flash")>
|
||||
FlashWrite = 195
|
||||
<Description("写入EEPROM")>
|
||||
EEPROMWrite = 198
|
||||
<Description("群写入Flash")>
|
||||
FlashGroupUpgrade
|
||||
|
||||
<Description("Boot搜索")>
|
||||
BootSearchEquipment
|
||||
|
||||
<Description("Boot搜索")>
|
||||
ReadingFlashData
|
||||
|
||||
|
||||
End Enum
|
||||
'自增SN号
|
||||
Public Function GetSN() As Integer
|
||||
If SN < 15 Then
|
||||
SN += 1
|
||||
Else
|
||||
SN = 0
|
||||
End If
|
||||
Console.WriteLine("SN:" & SN)
|
||||
Return SN
|
||||
End Function
|
||||
|
||||
|
||||
'创建协议类对象
|
||||
Public Shared Function CreateProtocol(communicationType As CommunicationType) As Object
|
||||
Select Case communicationType
|
||||
Case CommunicationType.SerialPort
|
||||
Return New SerialPort_BLV_Bootloader()
|
||||
Case CommunicationType.Udp
|
||||
Return New SerialPort_BLV_Bootloader()
|
||||
Case Else
|
||||
Return Nothing
|
||||
End Select
|
||||
End Function
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataSearchCommand(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataSkipCommand(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataSetUpParameters(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataWriteFlashData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataReadingFlashData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataEraseFlashData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataWriteEEPROMData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataReadingEEPROMData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataEraseEEPROMData(ParamArray args() As String) As Byte()
|
||||
|
||||
|
||||
|
||||
Public MustOverride Function PacketDataCheckCommand(ParamArray args() As String) As Byte()
|
||||
Public MustOverride Sub SetUpgradeProgressProgressbar(gTable As DataGridView, addr As String, devtype As String, val As String, bcolor As Color, Optional RText_OutputText As RichTextBox = Nothing)
|
||||
Public MustOverride Sub NewSearchEquipmentProcess(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub NewBootSearchEquipmentProcess(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub OrdinaryOccurrenceCommand(Parameterlist As Parameterlist)
|
||||
|
||||
Public MustOverride Sub WorkflowTypeNone(Parameterlist As Parameterlist, ByRef isRuning As Boolean)
|
||||
Public MustOverride Sub NewUpgradeProcess(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub NewFlashGroupUpgrade(Parameterlist As Parameterlist)
|
||||
|
||||
Public MustOverride Sub NewSearchEquipmentProcess2(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub NewBootSearchEquipmentProcess2(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub NewUpgradeProcess2(Parameterlist As Parameterlist)
|
||||
Public MustOverride Sub NewFlashGroupUpgrade2(Parameterlist As Parameterlist)
|
||||
'获取固定流程
|
||||
Public Function GetImmobilizationWorkflow(g_WorkflowType As WorkflowType) As Boolean
|
||||
Dim li As New List(Of (number As Integer, Cmdconfig))
|
||||
Dim WorkflowName As String = DataProcessing.GetEnumDescription(g_WorkflowType)
|
||||
If Not m_flowdic.ContainsKey(WorkflowName) Then
|
||||
Select Case g_WorkflowType
|
||||
Case WorkflowType.SearchEquipment
|
||||
li.Add((0, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
Case WorkflowType.FlashWrite, WorkflowType.EEPROMWrite
|
||||
li.Add((0, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((1, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((2, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((3, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((4, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((5, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
li.Add((6, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
'Case WorkflowType.EEPROMWrite
|
||||
' li.Add((0, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
' li.Add((0, New Cmdconfig({CmdType.SearchCommand, GetSN(), 0, 0, 10, 1})))
|
||||
End Select
|
||||
End If
|
||||
|
||||
End Function
|
||||
'创建Cmdconfig 节点
|
||||
|
||||
|
||||
|
||||
|
||||
'升级流程
|
||||
Public MustOverride Function UpgradeProcess(g_Cmdconfig As List(Of (number As Integer, Cmdconfig)), ParamArray args() As Object) As String
|
||||
|
||||
'搜索流程
|
||||
''' <summary>
|
||||
''' 搜索设备流程
|
||||
''' </summary>
|
||||
''' <param name="args">超时时间、表格控件、打印控件 </param>
|
||||
''' <returns></returns>
|
||||
Public MustOverride Function SearchEquipmentProcess(g_Cmdconfig As Cmdconfig, ParamArray args() As Object) As Boolean
|
||||
'开始时间
|
||||
|
||||
'写入Flash流程
|
||||
|
||||
Public Function FlashWriteProcess(ParamArray args() As String) As Boolean
|
||||
|
||||
End Function
|
||||
'写入EEPROM流程
|
||||
Public Function EEPROMWriteProcess(ParamArray args() As String) As Boolean
|
||||
|
||||
End Function
|
||||
|
||||
Public Overrides Function Runing(Parameterlist As Parameterlist, ByRef isRuning As Boolean) As Boolean
|
||||
Try
|
||||
m_Transmitter.mCommunicationFlow = Me
|
||||
If Parameterlist.CommunicationTypeIndex = 1 Then
|
||||
Select Case Parameterlist.Action
|
||||
Case WorkflowType.SearchEquipment
|
||||
NewSearchEquipmentProcess(Parameterlist) '搜索设备流程 False
|
||||
Case WorkflowType.FlashWrite
|
||||
NewUpgradeProcess(Parameterlist) '群组升级流程
|
||||
Case WorkflowType.EEPROMWrite
|
||||
Case WorkflowType.FlashGroupUpgrade
|
||||
'Console.WriteLine(Parameterlist)
|
||||
NewFlashGroupUpgrade(Parameterlist) 'flash组升级流程
|
||||
Case WorkflowType.BootSearchEquipment
|
||||
NewBootSearchEquipmentProcess(Parameterlist) 'boot搜索流程 true
|
||||
Case WorkflowType.ReadingFlashData
|
||||
OrdinaryOccurrenceCommand(Parameterlist)
|
||||
Case WorkflowType.none
|
||||
WorkflowTypeNone(Parameterlist, isRuning)
|
||||
|
||||
End Select
|
||||
ElseIf Parameterlist.CommunicationTypeIndex = 2 Then
|
||||
Select Case Parameterlist.Action
|
||||
Case WorkflowType.SearchEquipment
|
||||
NewSearchEquipmentProcess2(Parameterlist)
|
||||
Case WorkflowType.FlashWrite
|
||||
NewUpgradeProcess2(Parameterlist)
|
||||
Case WorkflowType.EEPROMWrite
|
||||
Case WorkflowType.FlashGroupUpgrade
|
||||
'Console.WriteLine(Parameterlist)
|
||||
NewFlashGroupUpgrade2(Parameterlist)
|
||||
Case WorkflowType.BootSearchEquipment
|
||||
NewBootSearchEquipmentProcess2(Parameterlist)
|
||||
Case WorkflowType.none
|
||||
WorkflowTypeNone(Parameterlist, isRuning)
|
||||
End Select
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
AddQueue(Parameterlist.RText_OutputText, New RuningLogConfig($"线程运行错误:{ ex.Message }", Color.Red))
|
||||
Return False
|
||||
'OutputLogsToTheControl(Parameterlist.RText_OutputText, New RuningLogConfig($"线程运行错误:{ ex.Message }", Color.Red), 1)
|
||||
End Try
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Public Class BLV_Bootloaderconfig
|
||||
'搜索设备流程开关
|
||||
Public SearchEquipmentProcessSwitch As Boolean = False
|
||||
'升级流程开关
|
||||
Public UpgradeProcessSwitch As Boolean = False
|
||||
|
||||
'己方地址
|
||||
Public MyAddress As Byte = 0
|
||||
''接受者类型
|
||||
Public ReceiverType As Byte = 0
|
||||
|
||||
'设备类型
|
||||
Public DeviceType As Byte = 0
|
||||
'对方地址
|
||||
Public ReceiverAddress As Byte = 0
|
||||
'单发开关
|
||||
Public SingleSwitch As Boolean = False
|
||||
'重发开关
|
||||
Public ResendSwitch As Boolean = False
|
||||
|
||||
'校验和
|
||||
Sub New()
|
||||
MyAddress = 0
|
||||
ReceiverType = 96
|
||||
DeviceType = 0
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
'''
|
||||
''' </summary>
|
||||
''' <param name="args"></param>
|
||||
''' <returns></returns>
|
||||
Public Function SetProtocolParam(ParamArray args() As String) As String
|
||||
Dim msgstr As String = ""
|
||||
Try
|
||||
MyAddress = CByte(args(0))
|
||||
Dim nbuf() As String = args(1).Split(",")
|
||||
If nbuf.Length < 3 OrElse Not SetReceiverType(nbuf(0), nbuf(1), nbuf(2), msgstr) Then Return False
|
||||
DeviceType = CByte(args(2))
|
||||
ReceiverAddress = CByte(args(3))
|
||||
|
||||
Catch ex As Exception
|
||||
msgstr = " set protocol parameters fail "
|
||||
End Try
|
||||
Return msgstr
|
||||
End Function
|
||||
'
|
||||
|
||||
|
||||
'设置接受者类型数据
|
||||
'addr:1群发,0单发
|
||||
'resend:1重发,0不重发
|
||||
Public Function SetReceiverType(addr As Boolean, resend As Boolean, SN As Integer, ByRef Optional msgstr As String = "") As Boolean
|
||||
Dim nReceiverType As Byte = 0
|
||||
If SN > 15 AndAlso SN < 0 Then
|
||||
msgstr = "The communication protocol SN of the BLV_Bootloader is incorrect:SN=" & SN
|
||||
Return False
|
||||
End If
|
||||
If addr Then
|
||||
nReceiverType = nReceiverType Or (1 << 7)
|
||||
End If
|
||||
If resend Then
|
||||
'SN = ReceiverType
|
||||
nReceiverType = nReceiverType Or (1 << 6)
|
||||
Else
|
||||
ResendSwitch = True
|
||||
End If
|
||||
nReceiverType = nReceiverType Or SN
|
||||
ReceiverType = nReceiverType
|
||||
Return True
|
||||
End Function
|
||||
'设置接受者类型数据
|
||||
'addr:1群发,0单发
|
||||
'resend:1重发,0不重发
|
||||
Public Function SetReceiverType1(addr As Boolean, resend As Boolean, SN As Integer, ByRef Optional msgstr As String = "") As Boolean
|
||||
Dim nReceiverType As Byte = 0
|
||||
If SN > 15 AndAlso SN < 0 Then
|
||||
msgstr = "The communication protocol SN of the BLV_Bootloader is incorrect:SN=" & SN
|
||||
Return False
|
||||
End If
|
||||
If addr Then
|
||||
nReceiverType = nReceiverType Or (1 << 7)
|
||||
End If
|
||||
If resend Then
|
||||
SN = ReceiverType '
|
||||
nReceiverType = nReceiverType Or (1 << 6)
|
||||
Else
|
||||
ResendSwitch = True
|
||||
End If
|
||||
nReceiverType = nReceiverType Or SN
|
||||
ReceiverType = nReceiverType
|
||||
Return True
|
||||
End Function
|
||||
End Class
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
185
CommunicationProtocol/CommunicationProtocol.vb
Normal file
185
CommunicationProtocol/CommunicationProtocol.vb
Normal file
@@ -0,0 +1,185 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Reflection
|
||||
Imports System.Threading
|
||||
Imports _485_BurningTool.CommunicationFlow
|
||||
|
||||
Public MustInherit Class CommunicationProtocol
|
||||
' Inherits CommunicationFlow
|
||||
|
||||
'创建通信协议对象
|
||||
'Public m_CommunicationProtocol As CommunicationProtocol
|
||||
''创建运行线程
|
||||
'Public m_RunThread As Thread
|
||||
'通信发送器对象
|
||||
Public m_Transmitter As Transmitter
|
||||
Public UpdateUIqueue As Queue(Of (Control, RuningLogConfig, lev As Integer))
|
||||
|
||||
Public Shared Function CreateAbstractObject(communicationType As CommunicationType, protocolType As ProtocolEnum) As CommunicationProtocol
|
||||
Select Case protocolType
|
||||
Case ProtocolEnum.BLV_Bootloader
|
||||
Return BLV_Bootloader.CreateProtocol(communicationType)
|
||||
Case Else
|
||||
Return Nothing
|
||||
End Select
|
||||
|
||||
End Function
|
||||
Public Sub AddQueue(c As Control, rl As RuningLogConfig, Optional lev As Integer = 0)
|
||||
If IsNothing(UpdateUIqueue) OrElse IsNothing(c) OrElse IsNothing(rl) Then Return
|
||||
UpdateUIqueue.Enqueue((c, rl, lev))
|
||||
End Sub
|
||||
'组装对应命令数据
|
||||
Public MustOverride Function AssembleCommandData(command As Integer, ParamArray args() As String) As Byte()
|
||||
Public MustOverride Function CheckData(data As Byte()) As Boolean
|
||||
'设置通信协议参数
|
||||
Public MustOverride Sub SetProtocolParam(ParamArray args() As String)
|
||||
Public MustOverride Sub SetSearchEquipmentProcessSwitch(iswitch As Boolean)
|
||||
|
||||
'Public MustOverride Sub SendCommand(command As Cmdconfig)
|
||||
|
||||
Public MustOverride Function MainProcess(g_WorkflowType As Integer, g_Cmdconfig As List(Of (number As Integer, Cmdconfig)), ParamArray args() As Object) As Boolean
|
||||
'解析接收数据
|
||||
Public MustOverride Function ParseReceiveData(gCmdconfig As Cmdconfig, data As Byte()) As Boolean
|
||||
Public MustOverride Function ParseReceiveData2(gCmdconfig As Cmdconfig, data As Byte()) As Boolean
|
||||
Public MustOverride Function Runing(Parameterlist As Parameterlist, ByRef Isruning As Boolean) As Boolean
|
||||
|
||||
'Private Sub Runingthread(ParamArray args() As Object)
|
||||
|
||||
'End Sub
|
||||
|
||||
'Public Function RuningMainProcess(g_WorkflowType As Integer, g_Cmdconfig As List(Of (number As Integer, Cmdconfig)), ParamArray args() As Object) As Boolean
|
||||
' '判断线程是否创建
|
||||
' If m_RunThread Is Nothing Then
|
||||
' '创建线程
|
||||
' m_RunThread = New Thread(New ParameterizedThreadStart(AddressOf Runingthread))
|
||||
' m_RunThread.Start((g_WorkflowType, g_Cmdconfig, args))
|
||||
|
||||
' '启动线程
|
||||
' m_RunThread.Start()
|
||||
' Else
|
||||
' '判断线程是否运行
|
||||
' If m_RunThread.IsAlive Then
|
||||
' ' 关闭线程
|
||||
' m_RunThread.Abort()
|
||||
|
||||
' End If
|
||||
' '创建线程
|
||||
' 'm_RunThread = New Thread(AddressOf MainProcess)
|
||||
' '启动线程
|
||||
' m_RunThread.Start()
|
||||
' End If
|
||||
'End Function
|
||||
'Public Sub StopRuningMainProcess()
|
||||
' If m_RunThread Is Nothing Then
|
||||
' Exit Sub
|
||||
' Else
|
||||
' If m_RunThread.IsAlive Then
|
||||
' m_RunThread.Abort()
|
||||
' End If
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'命令发送信息类
|
||||
Public Class Cmdconfig
|
||||
|
||||
'命令类型
|
||||
Public CmdValue As Integer
|
||||
'命令参数数组
|
||||
Public CmdArgs As List(Of Object)
|
||||
'发送SN号
|
||||
Public CmdSN As Integer
|
||||
'发送重发次数
|
||||
Public CmdSendCount As Integer
|
||||
'发送次数
|
||||
Public CmdSendCountNow As Integer
|
||||
'持续发生时间
|
||||
Public CmdSendcontinueTime As Integer
|
||||
'发送间隔时间
|
||||
Public CmdSendInterval As Integer
|
||||
'发送命令
|
||||
Public CmdSendData As Byte()
|
||||
'接收命令集合 时间+数据
|
||||
Public CmdReceiveData As List(Of (DateTime, Byte()))
|
||||
'接收命令超时 秒
|
||||
Public CmdReceiveTimeout As Integer
|
||||
'接收命令校验
|
||||
Public CmdReceiveCheck As Boolean
|
||||
'接收命令状态
|
||||
Public CmdReceiveStatus As Boolean
|
||||
|
||||
'接收命令错误信息
|
||||
Public CmdReceiveError As String
|
||||
'发送命令时间
|
||||
Public CmdSendTime As DateTime
|
||||
|
||||
'针对升级写入的序号
|
||||
Public CmdWriteIndex As Integer
|
||||
|
||||
'协议对象
|
||||
Public Protocol As CommunicationProtocol
|
||||
'节点创建时间
|
||||
Public NodeCreateTime As DateTime
|
||||
|
||||
'附加其他协议列表
|
||||
Public OtherProtocol As UDPCommunicationnode
|
||||
|
||||
|
||||
|
||||
'创建对象并设置对应类中变量
|
||||
|
||||
Sub New(args() As Integer)
|
||||
CmdValue = Integer.Parse(args(0))
|
||||
CmdSN = Integer.Parse(args(1))
|
||||
CmdSendCount = Integer.Parse(args(2))
|
||||
CmdSendInterval = Integer.Parse(args(3))
|
||||
CmdReceiveData = New List(Of (DateTime, Byte()))
|
||||
CmdReceiveTimeout = Integer.Parse(args(4))
|
||||
CmdArgs = New List(Of Object)
|
||||
CmdSendTime = DateTime.Now
|
||||
NodeCreateTime = DateTime.Now
|
||||
CmdWriteIndex = 0
|
||||
CmdSendcontinueTime = 0
|
||||
CmdSendCountNow = 0
|
||||
OtherProtocol = New UDPCommunicationnode
|
||||
End Sub
|
||||
'设置发送持续时间
|
||||
Public Sub setCmdSendcontinueTime(iswitch As Integer)
|
||||
CmdSendcontinueTime = iswitch
|
||||
End Sub
|
||||
Public Sub setCmdReceiveStatus(iswitch As Boolean)
|
||||
CmdReceiveStatus = iswitch
|
||||
End Sub
|
||||
Public Sub SetProtocol(nProtocol As CommunicationProtocol)
|
||||
Protocol = nProtocol
|
||||
End Sub
|
||||
Sub New()
|
||||
CmdReceiveData = New List(Of (DateTime, Byte()))
|
||||
CmdArgs = New List(Of Object)
|
||||
End Sub
|
||||
|
||||
Public Sub setUDPCommunicationnode()
|
||||
OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_STATUS = 0
|
||||
OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_RESULT = 0
|
||||
OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_STATUS = 0
|
||||
OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_RESULT = 0
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class UDPCommunicationnode
|
||||
'透传模式命令回复状态
|
||||
Public UDP_TRANSPARENT_MODE_COMMAND_REPLY_STATUS As Integer = 0
|
||||
'透传模式命令回复结果
|
||||
Public UDP_TRANSPARENT_MODE_COMMAND_REPLY_RESULT As Integer = 0
|
||||
'查询主机当前模式命令回复状态
|
||||
Public UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_STATUS As Integer = 0
|
||||
'查询主机当前模式命令回复结果
|
||||
Public UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_RESULT As Integer = 0
|
||||
Sub New()
|
||||
UDP_TRANSPARENT_MODE_COMMAND_REPLY_STATUS = 0
|
||||
UDP_TRANSPARENT_MODE_COMMAND_REPLY_RESULT = 0
|
||||
UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_STATUS = 0
|
||||
UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_RESULT = 0
|
||||
End Sub
|
||||
End Class
|
||||
14
CommunicationProtocol/CommunicationProtocolController.vb
Normal file
14
CommunicationProtocol/CommunicationProtocolController.vb
Normal file
@@ -0,0 +1,14 @@
|
||||
''通信协议基类
|
||||
'通信协议基类只负责
|
||||
'1. 通信协议 命令组包
|
||||
'2. 通信协议 解包
|
||||
'3. 通信协议 命令解析
|
||||
'4. 通信协议 命令执行
|
||||
'5. 通信协议 命令返回
|
||||
|
||||
Public Class CommunicationProtocolController
|
||||
|
||||
Dim m_CommunicationProtocol As CommunicationProtocol
|
||||
|
||||
|
||||
End Class
|
||||
2020
Form1.Designer.vb
generated
Normal file
2020
Form1.Designer.vb
generated
Normal file
File diff suppressed because it is too large
Load Diff
229
Form1.resx
Normal file
229
Form1.resx
Normal file
@@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="Button3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAARRJREFUWEftksENgzAUQ3Ngow7ErXNwYge2YQDOXYEx0hpi6kYJDQmgVsKS9UMq
|
||||
7NcEc+nS36ttW+uW5wvlfd/buq7Ph0A5dThE0xir1nLqMAgUWtst9svNDfuzdodg+TDcJ8fKQxB6Yi5u
|
||||
uxQA5eP4WIzS0IQJQfBsCAKgHKE0ytYmTQjkVFWVDtF1xpZaITYB4OVS4V8jR68jA+D95Uc9xCdPQSFc
|
||||
xbo+ABhI+0Wh39xaT6EM4pu94uX5NXkK8OaPcJYE6jo0A3s8BZTnA9AM9q3FunYzCwBahUiZzuUADKW1
|
||||
JGHiGspPILFsmrQ8ZwFAM4SExSYd2ec1uNh0TQASlOsigL2cBQDx/krt4i5d+jUZ8wSCLX7ZjW1LKAAA
|
||||
AABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="Btn_Search.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAAFxJREFUOE/NjwEKwDAIA326T/NnjkoVV03ZGIweHC0aAtJx6KKD5gVl5i6I5oUc
|
||||
ykE0v6EiYo7/1NntjLx4Y2Dty53FJhMcUAB0ut0wsPbxThEw971gEfE09xtEF/5wqQPHNXMwAAAAAElF
|
||||
TkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="Btn_Upgrade.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAAvJJREFUWEftk1lPWlEUhWna57bpc/+AD1rnAesEoijgUOcBUVBRVGQWtIiM4ogD
|
||||
FgeoRtQH/+Tq2bdcQ6j3RmvVxriSnZxc2Gd9Z591JK961YvTxzcSZFfm8+OLN1Sp1FAoFKirq0NVlfTx
|
||||
QXiDwcFBdHd3Q6PRoLm5GQ0NDaiurkZZeTmKCgv/PQi/odFohH5sDEPDw+jp6UF7eztaWpSQy+SoqalB
|
||||
RUUFiouLkJ+fj7y8vIdD8MYOhwPz5nlMT03BYDBAqx1BX18fOjs70draisZGBWpra1FZWYmSkhIUfCmA
|
||||
Xq8nc1xfX98fgjcOBgPwer1wuVywWCwwmUyYGB+HbkSHgf5+dHV9g0atRlNTE+rr6yGVSlFaVsqZ2+32
|
||||
+wPwxju7u9jY2EAoHMLy8jLcbjdsVhtmZmcxOTmJsdHR3zlg19DW1galUgmZTIavLAe8OU2CbXk3AN44
|
||||
mUwikTjE3t4etjY3EYlEsOJbweKih23qwNzcHKbYNZDJMMtBb28vOjo6WA5aIJfLbxu7OABvfHl5ifPz
|
||||
c6R+pnB0dIT9+D62t7cQjUbh9/uxtLQEp9MJ8zzLgWkaBnYNI1ot+tk1UA7UKpXQ2IUBPr17yzVdXV1x
|
||||
lU6ncXp6iuPjYxwcHCAW28Ha+jpCwSCXgwXXAqwWK2ZmWA4mJjCq07FrGGA56BIbuzAAnZyaqJnq4iKN
|
||||
s7MzJE9O8CORwG4mB+FwmMuBx+OG3WbDLOXASDlgz3FoiOv9/OG9kKk4ABHzAHylUikcHrIc7LMcbG1i
|
||||
NbKKFT/lYJF7jmazOZMDA/d/OoQYQKb+FAHQZgRxG0g8HkdsO4a16BoCgQDLwXc4XU72HCkHphtz6hUB
|
||||
EBYPQGvaQAhknXIQCsFLz3GB5cBq5b5nmz4YgOlmLQTi8/lYDjzcOnfsuQCZElcuQKZuJARy29hzAO6m
|
||||
HABBZYMImf4VABM13LlJ7NS0pqL1o0oI4Mn03wFQcT88lZ7l1Nl6llO/6gVJIvkFfvGnPG6oTRsAAAAA
|
||||
SUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="Button1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAAvJJREFUWEftk1lPWlEUhWna57bpc/+AD1rnAesEoijgUOcBUVBRVGQWtIiM4ogD
|
||||
FgeoRtQH/+Tq2bdcQ6j3RmvVxriSnZxc2Gd9Z591JK961YvTxzcSZFfm8+OLN1Sp1FAoFKirq0NVlfTx
|
||||
QXiDwcFBdHd3Q6PRoLm5GQ0NDaiurkZZeTmKCgv/PQi/odFohH5sDEPDw+jp6UF7eztaWpSQy+SoqalB
|
||||
RUUFiouLkJ+fj7y8vIdD8MYOhwPz5nlMT03BYDBAqx1BX18fOjs70draisZGBWpra1FZWYmSkhIUfCmA
|
||||
Xq8nc1xfX98fgjcOBgPwer1wuVywWCwwmUyYGB+HbkSHgf5+dHV9g0atRlNTE+rr6yGVSlFaVsqZ2+32
|
||||
+wPwxju7u9jY2EAoHMLy8jLcbjdsVhtmZmcxOTmJsdHR3zlg19DW1galUgmZTIavLAe8OU2CbXk3AN44
|
||||
mUwikTjE3t4etjY3EYlEsOJbweKih23qwNzcHKbYNZDJMMtBb28vOjo6WA5aIJfLbxu7OABvfHl5ifPz
|
||||
c6R+pnB0dIT9+D62t7cQjUbh9/uxtLQEp9MJ8zzLgWkaBnYNI1ot+tk1UA7UKpXQ2IUBPr17yzVdXV1x
|
||||
lU6ncXp6iuPjYxwcHCAW28Ha+jpCwSCXgwXXAqwWK2ZmWA4mJjCq07FrGGA56BIbuzAAnZyaqJnq4iKN
|
||||
s7MzJE9O8CORwG4mB+FwmMuBx+OG3WbDLOXASDlgz3FoiOv9/OG9kKk4ABHzAHylUikcHrIc7LMcbG1i
|
||||
NbKKFT/lYJF7jmazOZMDA/d/OoQYQKb+FAHQZgRxG0g8HkdsO4a16BoCgQDLwXc4XU72HCkHphtz6hUB
|
||||
EBYPQGvaQAhknXIQCsFLz3GB5cBq5b5nmz4YgOlmLQTi8/lYDjzcOnfsuQCZElcuQKZuJARy29hzAO6m
|
||||
HABBZYMImf4VABM13LlJ7NS0pqL1o0oI4Mn03wFQcT88lZ7l1Nl6llO/6gVJIvkFfvGnPG6oTRsAAAAA
|
||||
SUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="ToolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="ToolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
</root>
|
||||
120
Log/RuningLog.vb
Normal file
120
Log/RuningLog.vb
Normal file
@@ -0,0 +1,120 @@
|
||||
Public Class RuningLog
|
||||
|
||||
Public Shared level As Integer = 1 '日志级别 0:不输出日志 1:输出日志2:输出基础日志和错误信息
|
||||
Delegate Function Deleg_OutputLogsToTheControl(c As Control, config As RuningLogConfig, Controltype As Integer) As Boolean
|
||||
'输出日志到控件
|
||||
''' <summary>
|
||||
''' ''输出日志到控件
|
||||
''' </summary>
|
||||
''' <param name="c">控件 </param>
|
||||
''' <param name="config">日志</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function OutputLogsToTheControl(c As Control, config As RuningLogConfig, Controltype As Integer) As Boolean
|
||||
Try
|
||||
If c.InvokeRequired Then
|
||||
Dim dev As New Deleg_OutputLogsToTheControl(AddressOf OutputLogsToTheControl)
|
||||
c.Invoke(dev, New Object() {c, config, Controltype})
|
||||
Else
|
||||
If Controltype >= level Then
|
||||
Dim nc As RichTextBox = c
|
||||
'获取富文本字符串末端位置
|
||||
Dim index As Integer = nc.TextLength
|
||||
If (Not IsNothing(config.strdata)) AndAlso config.strdata.Length > 0 Then
|
||||
config.logstr = config.logstr & DataProcessing.ByteToString2(config.strdata)
|
||||
End If
|
||||
|
||||
Dim strtxt = config.logstr & vbCrLf
|
||||
'设置光标位置
|
||||
nc.SelectionStart = index
|
||||
'添加文本
|
||||
nc.AppendText(strtxt)
|
||||
'设置选择区域
|
||||
nc.Select(index, strtxt.Length)
|
||||
'设置选择区域颜色
|
||||
nc.SelectionColor = config.logstrColor
|
||||
'设置选择区域字体
|
||||
nc.SelectionFont = config.logstrFont
|
||||
'取消选中区域
|
||||
nc.DeselectAll()
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
'字符串附加时间戳
|
||||
Public Shared Function AddTimeStamps(str As String) As String
|
||||
Return Now.ToString("yyyy-MM-dd HH:mm:ss:fff") & " " & str
|
||||
End Function
|
||||
|
||||
'设置显示等级
|
||||
Public Shared Sub SetLevel(level As Integer)
|
||||
RuningLog.level = level
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Public Class RuningLogConfig
|
||||
'日志信息
|
||||
Public logstr As String
|
||||
'日志信息颜色
|
||||
Public logstrColor As Color
|
||||
'日志信息字体
|
||||
Public logstrFont As Font
|
||||
'日志信息字体大小
|
||||
'Public logstrFontSize As Integer
|
||||
''日志信息字体粗细
|
||||
'Public logstrFontBold As Boolean
|
||||
''日志信息字体斜体
|
||||
'Public logstrFontItalic As Boolean
|
||||
''日志信息字体下划线
|
||||
'Public logstrFontUnderline As Boolean
|
||||
''日志信息字体删除线
|
||||
'Public logstrFontStrikeout As Boolean
|
||||
''日志信息字体对齐方式
|
||||
'Public logstrFontAlign As StringAlignment
|
||||
'日志信息字体背景色
|
||||
Public logstrFontBackColor As Color
|
||||
Public strdata As Byte()
|
||||
|
||||
''' <summary>
|
||||
''' 文本、颜色、Font
|
||||
''' </summary>
|
||||
''' <param name="args"></param>
|
||||
Sub New(ParamArray args() As Object)
|
||||
If args.Length > 0 Then
|
||||
logstr = RuningLog.AddTimeStamps(args(0).ToString)
|
||||
|
||||
If args.Length > 1 Then
|
||||
|
||||
logstrColor = args(1)
|
||||
If args.Length > 2 Then
|
||||
logstrFont = args(2)
|
||||
Else
|
||||
logstrFont = New Font("宋体", 8)
|
||||
|
||||
End If
|
||||
|
||||
If args.Length > 3 Then
|
||||
strdata = args(3)
|
||||
Else
|
||||
strdata = Nothing
|
||||
End If
|
||||
|
||||
Else
|
||||
logstrColor = Color.Black
|
||||
End If
|
||||
Else
|
||||
logstr = "输空文本"
|
||||
logstrColor = Color.Black
|
||||
logstrFont = New Font("宋体", 12)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
391
Mode/DataProcessing.vb
Normal file
391
Mode/DataProcessing.vb
Normal file
@@ -0,0 +1,391 @@
|
||||
Imports System.IO
|
||||
Imports System.Net
|
||||
Imports System.Net.NetworkInformation
|
||||
Imports System.Net.Sockets
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text
|
||||
Imports System.Threading
|
||||
Imports System.ComponentModel
|
||||
Imports System.Reflection
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public Class DataProcessing
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 端口号转换为Byte数组
|
||||
''' </summary>
|
||||
''' <param name="port"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetPortToBytes(port As String)
|
||||
Dim bport As Integer = CInt(port)
|
||||
Dim ports() As Byte = IntToByteLB(bport)
|
||||
|
||||
Return ports
|
||||
End Function
|
||||
|
||||
'字符串转byte 数组
|
||||
Public Shared Function GetBytesFromStr(str As String) As Byte()
|
||||
Return Encoding.ASCII.GetBytes(str)
|
||||
End Function
|
||||
'bytes转字符串
|
||||
Public Shared Function GetStrFromBytes(bytes() As Byte) As String
|
||||
Return Encoding.ASCII.GetString(bytes)
|
||||
End Function
|
||||
|
||||
'计算数组CRC16校验
|
||||
|
||||
Public Shared Function GetCRC16(data() As Byte) As Integer
|
||||
Dim crc As Integer = &HFFFF
|
||||
Dim i As Integer
|
||||
Dim j As Integer
|
||||
|
||||
For i = 0 To data.Length - 1
|
||||
crc = crc Xor data(i)
|
||||
For j = 0 To 7
|
||||
If (crc And &H1) <> 0 Then
|
||||
crc = (crc >> 1) Xor &HA001
|
||||
Else
|
||||
crc = crc >> 1
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
Return crc
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Int转2个字节Byte
|
||||
''' 低字节在前,高字节在后
|
||||
''' </summary>
|
||||
''' <param name="i"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function IntToByteLB(ByVal i As Integer) As Byte()
|
||||
Dim btemp() As Byte = {0, 0}
|
||||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||||
btemp(0) = b(1)
|
||||
btemp(1) = b(0)
|
||||
Return btemp
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Int转4个字节Byte
|
||||
''' 低字节在前,高字节在后
|
||||
''' </summary>
|
||||
''' <param name="i"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function IntToByteLxxB(ByVal i As Integer) As Byte()
|
||||
Dim btemp() As Byte = {0, 0, 0, 0}
|
||||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||||
btemp(0) = b(3)
|
||||
btemp(1) = b(2)
|
||||
btemp(2) = b(1)
|
||||
btemp(3) = b(0)
|
||||
Return btemp
|
||||
End Function
|
||||
Public Shared Function IntToByteHxxB(ByVal i As Integer) As Byte()
|
||||
Dim btemp() As Byte = {0, 0, 0, 0}
|
||||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||||
btemp(0) = b(0)
|
||||
btemp(1) = b(1)
|
||||
btemp(2) = b(2)
|
||||
btemp(3) = b(3)
|
||||
Return btemp
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Int转2个字节Byte
|
||||
''' 高字节在前,低字节在后
|
||||
''' </summary>
|
||||
''' <param name="i"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function IntToByteHB(ByVal i As Integer) As Byte()
|
||||
Dim btemp() As Byte = {0, 0}
|
||||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||||
btemp(0) = b(0)
|
||||
btemp(1) = b(1)
|
||||
Return btemp
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 获取文件的MD5值
|
||||
''' 返回Byte数组值
|
||||
''' </summary>
|
||||
''' <param name="filepath">文件路径</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetMd5(filepath As String) As Byte()
|
||||
Dim FileStr As FileStream = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)
|
||||
Dim data(FileStr.Length - 1) As Byte
|
||||
FileStr.Read(data, 0, data.Length)
|
||||
|
||||
Dim md5s As Byte() = MD5.Create().ComputeHash(data)
|
||||
'Dim fileMd5 As New StringBuilder()
|
||||
'Dim i As Integer
|
||||
'For i = 0 To md5s.Length - 1
|
||||
' fileMd5.Append(md5s(i).ToString("x2"))
|
||||
'Next
|
||||
|
||||
'Console.WriteLine($"MD5:{fileMd5}")
|
||||
|
||||
Return md5s
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 获取文件的MD5值
|
||||
''' 返回String字符串
|
||||
''' </summary>
|
||||
''' <param name="filepath">文件路径</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetMd5String(filepath As String) As String
|
||||
Dim FileStr As FileStream = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)
|
||||
Dim data(FileStr.Length) As Byte
|
||||
FileStr.Read(data, 0, data.Length)
|
||||
|
||||
Dim md5s As Byte() = MD5.Create().ComputeHash(data)
|
||||
Dim fileMd5 As New StringBuilder()
|
||||
Dim i As Integer
|
||||
For i = 0 To md5s.Length - 1
|
||||
fileMd5.Append(md5s(i).ToString("x2"))
|
||||
Next
|
||||
|
||||
Console.WriteLine($"MD5:{fileMd5}")
|
||||
|
||||
Return fileMd5.ToString()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 获取本地可用IP
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetLocalIp() As List(Of IPAddress)
|
||||
Dim address() As IPAddress
|
||||
Dim destAddress As New List(Of IPAddress)
|
||||
address = Dns.GetHostEntry(Dns.GetHostName()).AddressList
|
||||
For Each pAddress As IPAddress In address
|
||||
If pAddress.AddressFamily = AddressFamily.InterNetwork Then
|
||||
destAddress.Add(pAddress)
|
||||
End If
|
||||
Next
|
||||
Return destAddress
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Byte数组转字符串
|
||||
''' </summary>
|
||||
''' <param name="databuff"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ByteToString(databuff() As Byte)
|
||||
Dim strData As String = String.Empty
|
||||
For i = 0 To databuff.Length - 1
|
||||
strData &= $" {Hex(databuff(i)).PadLeft(2, "0"c)}"
|
||||
Next
|
||||
Return strData
|
||||
End Function
|
||||
Public Shared Function ByteToString2(databuff() As Byte)
|
||||
Dim strData As String = String.Empty
|
||||
For i = 0 To databuff.Length - 1
|
||||
strData &= $" {ByteToHex1(databuff(i)).PadLeft(2, "0"c)}"
|
||||
Next
|
||||
Return strData
|
||||
End Function
|
||||
|
||||
'将16进制字符串转换为字节数组
|
||||
Public Shared Function HexStringToByteArray(hex As String) As Byte()
|
||||
|
||||
Dim bytes As New List(Of Byte)
|
||||
hex = hex.Replace(" ", "").Trim.ToUpper()
|
||||
For i As Integer = 0 To hex.Length - 1 Step 2
|
||||
Dim hexByte As String = hex.Substring(i, 2)
|
||||
bytes.Add(Convert.ToByte(hexByte, 16))
|
||||
Next
|
||||
Return bytes.ToArray()
|
||||
End Function
|
||||
|
||||
'将字节数组转换为16进制字符串
|
||||
Public Shared Function ByteArrayToHexString(bytes As Byte()) As String
|
||||
If bytes Is Nothing OrElse bytes.Length = 0 Then Return ""
|
||||
Dim hex As String = ""
|
||||
For Each b As Byte In bytes
|
||||
hex += b.ToString("X2") & " "
|
||||
Next
|
||||
Return hex.Trim()
|
||||
|
||||
End Function
|
||||
'byte 转16进制字符串
|
||||
Public Shared Function ByteToHex1(ByVal b As Byte) As String
|
||||
Return b.ToString("X2")
|
||||
End Function
|
||||
'16进制字符串 转byte数组
|
||||
'Public Shared Function HexToByte(ByVal hex As String) As Byte()
|
||||
' Dim result As Byte() = New Byte(hex.Length / 2 - 1) {}
|
||||
' For i As Integer = 0 To hex.Length - 1 Step 2
|
||||
' result(i / 2) = Convert.ToByte(hex.Substring(i, 2), 16)
|
||||
|
||||
' Next
|
||||
'End Function
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 等待回复
|
||||
''' </summary>
|
||||
''' <param name="isReply">是否回复标志位</param>
|
||||
''' <param name="TimeOut">超时时间</param>
|
||||
Public Shared Sub WaitReply(isReply As Boolean, TimeOut As Integer) 'ByRef
|
||||
Dim tick As Integer
|
||||
Dim startTick As Integer = My.Computer.Clock.TickCount
|
||||
isReply = False
|
||||
While isReply = False AndAlso tick <= TimeOut
|
||||
Thread.Sleep(3)
|
||||
tick = My.Computer.Clock.TickCount - startTick
|
||||
Application.DoEvents()
|
||||
End While
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 延时N秒
|
||||
''' </summary>
|
||||
''' <param name="HowLong">延时时间值</param>
|
||||
Public Shared Sub PauseWait(ByVal HowLong As Long)
|
||||
Dim tick As Long
|
||||
tick = My.Computer.Clock.TickCount
|
||||
Do
|
||||
My.Application.DoEvents()
|
||||
Loop Until tick + HowLong < My.Computer.Clock.TickCount
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' IP地址转换为Byte数组
|
||||
''' </summary>
|
||||
''' <param name="addr"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetAddressToBytes(addr As String)
|
||||
Dim iadd() As String = addr.Split(New Char() {"."c}, StringSplitOptions.RemoveEmptyEntries)
|
||||
Dim address(3) As Byte
|
||||
address(0) = iadd(0) '例:192
|
||||
address(1) = iadd(1) '例:168
|
||||
address(2) = iadd(2)
|
||||
address(3) = iadd(3)
|
||||
|
||||
Return address
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 获取字符串的MD5值
|
||||
''' </summary>
|
||||
''' <param name="str">需要求MD5的原文字符串</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetStringMd5(str As String) As String
|
||||
Dim md5Hasher As New MD5CryptoServiceProvider()
|
||||
Dim data As Byte() = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(str))
|
||||
Dim fileMd5 As New StringBuilder()
|
||||
Dim i As Integer
|
||||
For i = 0 To data.Length - 1
|
||||
fileMd5.Append(data(i).ToString("X2"))
|
||||
Next
|
||||
|
||||
Return fileMd5.ToString()
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 分块函数
|
||||
''' 计算Byte数组的块数
|
||||
''' </summary>
|
||||
''' <param name="databuff"></param>
|
||||
''' <param name="size"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetBlocks(databuff As Byte(), size As Integer) As Integer
|
||||
Dim blockCount As Integer = databuff.Length \ size
|
||||
If databuff.Length Mod size > 0 Then
|
||||
blockCount += 1
|
||||
End If
|
||||
Return blockCount
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 字符串转换Byte数组
|
||||
''' 字符串为连续且不包含任意字符的字符串
|
||||
''' </summary>
|
||||
''' <param name="str"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function GetStringToDataByte(str As String) As Byte()
|
||||
Dim dataList As New List(Of Byte)
|
||||
|
||||
For index As Integer = 0 To str.Length - 1 Step 2
|
||||
dataList.Add($"&H{str.Substring(index, 2)}")
|
||||
Next
|
||||
|
||||
Return dataList.ToArray
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 把UNIX时间戳转换为标准时间
|
||||
''' </summary>
|
||||
''' <param name="intTime">要转换的UNIX时间戳</param>
|
||||
''' <param name="ime">时区</param>
|
||||
''' <returns>intTime所代表的标准时间</returns>
|
||||
Public Shared Function FromUnixTime(intTime As Long, ime As Long) As Date
|
||||
'If intTime Is Nothing Or Not IsNumeric(intTime) Then
|
||||
' FromUnixTime = Now()
|
||||
' Exit Function
|
||||
'End If
|
||||
'If intTime Is Nothing Or Not IsNumeric(intTimeZone) Then intTimeZone = 0
|
||||
'FromUnixTime = DateAdd("s", intTime, "1970-1-1 0:0:0")
|
||||
'FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)
|
||||
|
||||
Dim a As Date = DateTime.Parse("1970-1-1 0:0:0")
|
||||
a = a.AddSeconds(intTime)
|
||||
a = a.AddHours(ime)
|
||||
|
||||
Return a
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 和校验取余数
|
||||
''' 求Byte数组的和校验取余数
|
||||
''' </summary>
|
||||
''' <param name="dataPacket">Byte数组</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function SumAndMod(dataPacket As Byte()) As Byte
|
||||
Dim sum As Integer
|
||||
For idx = 0 To dataPacket.Length - 1
|
||||
sum += dataPacket(idx)
|
||||
sum = sum And &HFF
|
||||
Next
|
||||
Dim sumMod As Byte = &HFF - sum
|
||||
Return sumMod
|
||||
End Function
|
||||
Public Shared Sub Delay(ByVal time As Integer)
|
||||
Dim timeEnd As Integer = My.Computer.Clock.TickCount + time
|
||||
Do
|
||||
Application.DoEvents()
|
||||
Loop Until My.Computer.Clock.TickCount > timeEnd
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 获取枚举描述特性
|
||||
''' </summary>
|
||||
''' <param name="enumValue">需要获取特性的枚举值</param>
|
||||
''' <returns>枚举描述特性</returns>
|
||||
Public Shared Function GetEnumDescription(enumValue As [Enum]) As String
|
||||
|
||||
Dim fi As FieldInfo = enumValue.GetType().GetField(enumValue.ToString())
|
||||
Dim attr() As DescriptionAttribute =
|
||||
DirectCast(fi.GetCustomAttributes(GetType(DescriptionAttribute),
|
||||
False), DescriptionAttribute())
|
||||
|
||||
If attr.Length > 0 Then
|
||||
Return attr(0).Description
|
||||
Else
|
||||
Return enumValue.ToString()
|
||||
End If
|
||||
End Function
|
||||
|
||||
End Class
|
||||
38
My Project/Application.Designer.vb
generated
Normal file
38
My Project/Application.Designer.vb
generated
Normal file
@@ -0,0 +1,38 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
|
||||
' or if you encounter build errors in this file, go to the Project Designer
|
||||
' (go to Project Properties or double-click the My Project node in
|
||||
' Solution Explorer), and make changes on the Application tab.
|
||||
'
|
||||
Partial Friend Class MyApplication
|
||||
|
||||
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||
Public Sub New()
|
||||
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
|
||||
Me.IsSingleInstance = false
|
||||
Me.EnableVisualStyles = true
|
||||
Me.SaveMySettingsOnExit = true
|
||||
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
|
||||
End Sub
|
||||
|
||||
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||
Protected Overrides Sub OnCreateMainForm()
|
||||
Me.MainForm = Global._485_BurningTool.Form1
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
11
My Project/Application.myapp
Normal file
11
My Project/Application.myapp
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>true</MySubMain>
|
||||
<MainForm>Form1</MainForm>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>0</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
35
My Project/AssemblyInfo.vb
Normal file
35
My Project/AssemblyInfo.vb
Normal file
@@ -0,0 +1,35 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' 有关程序集的一般信息由以下
|
||||
' 控制。更改这些特性值可修改
|
||||
' 与程序集关联的信息。
|
||||
|
||||
'查看程序集特性的值
|
||||
|
||||
<Assembly: AssemblyTitle("485_BurningTool")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("485_BurningTool")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2025")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID
|
||||
<Assembly: Guid("5c3d2dff-e8f9-479f-a4aa-d18cac13772e")>
|
||||
|
||||
' 程序集的版本信息由下列四个值组成:
|
||||
'
|
||||
' 主版本
|
||||
' 次版本
|
||||
' 生成号
|
||||
' 修订号
|
||||
'
|
||||
'可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
'通过使用 "*",如下所示:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.37")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.37")>
|
||||
63
My Project/Resources.Designer.vb
generated
Normal file
63
My Project/Resources.Designer.vb
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' 此代码由工具生成。
|
||||
' 运行时版本:4.0.30319.42000
|
||||
'
|
||||
' 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
' 重新生成代码,这些更改将会丢失。
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'此类是由 StronglyTypedResourceBuilder
|
||||
'类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
'若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
'(以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
'''<summary>
|
||||
''' 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' 返回此类使用的缓存的 ResourceManager 实例。
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("_485_BurningTool.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' 重写当前线程的 CurrentUICulture 属性,对
|
||||
''' 使用此强类型资源类的所有资源查找执行重写。
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
120
My Project/Resources.resx
Normal file
120
My Project/Resources.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
133
My Project/Settings.Designer.vb
generated
Normal file
133
My Project/Settings.Designer.vb
generated
Normal file
@@ -0,0 +1,133 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' 此代码由工具生成。
|
||||
' 运行时版本:4.0.30319.42000
|
||||
'
|
||||
' 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
' 重新生成代码,这些更改将会丢失。
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "My.Settings 自动保存功能"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public Property m_Applicationconfig() As String
|
||||
Get
|
||||
Return CType(Me("m_Applicationconfig"),String)
|
||||
End Get
|
||||
Set
|
||||
Me("m_Applicationconfig") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("9600")> _
|
||||
Public Property UpBaud() As Integer
|
||||
Get
|
||||
Return CType(Me("UpBaud"),Integer)
|
||||
End Get
|
||||
Set
|
||||
Me("UpBaud") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("9600")> _
|
||||
Public Property BootBaud() As Integer
|
||||
Get
|
||||
Return CType(Me("BootBaud"),Integer)
|
||||
End Get
|
||||
Set
|
||||
Me("BootBaud") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public Property ProtocolName() As String
|
||||
Get
|
||||
Return CType(Me("ProtocolName"),String)
|
||||
End Get
|
||||
Set
|
||||
Me("ProtocolName") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public Property HexFilePath() As String
|
||||
Get
|
||||
Return CType(Me("HexFilePath"),String)
|
||||
End Get
|
||||
Set
|
||||
Me("HexFilePath") = value
|
||||
End Set
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global._485_BurningTool.My.MySettings
|
||||
Get
|
||||
Return Global._485_BurningTool.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
21
My Project/Settings.settings
Normal file
21
My Project/Settings.settings
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="m_Applicationconfig" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="UpBaud" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">9600</Value>
|
||||
</Setting>
|
||||
<Setting Name="BootBaud" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">9600</Value>
|
||||
</Setting>
|
||||
<Setting Name="ProtocolName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="HexFilePath" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
381
Transmitter/DevNetworkCommunication.vb
Normal file
381
Transmitter/DevNetworkCommunication.vb
Normal file
@@ -0,0 +1,381 @@
|
||||
Imports System.Net
|
||||
Imports System.Net.Sockets
|
||||
Imports System.Threading
|
||||
|
||||
Public Class DevNetworkCommunication
|
||||
Inherits Transmitter
|
||||
|
||||
Public m_Serial As Socket
|
||||
|
||||
Public m_SerialComfig As UDPComfig
|
||||
Public m_Control As Control
|
||||
|
||||
'接收数据队列
|
||||
Public m_ReceiveQueue As List(Of Cmdconfig) = New List(Of Cmdconfig)
|
||||
'特殊接收处理标志
|
||||
Public m_SpecialReceiveFlag As Integer
|
||||
Public recvBufferli As List(Of Byte)
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 透传数据包头
|
||||
''' </summary>
|
||||
Public _fixedHead As Byte() = {&HAA, &H55}
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 透传数据固定ID
|
||||
''' </summary>
|
||||
Public _fixeSystemId As Byte() = {&H54, &H33, &H53, &H41}
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 透传数据房间信息
|
||||
''' </summary>
|
||||
Public _fixeRoomInfo As Byte() = {&HFF, &HFF, &HFF, &HFF}
|
||||
''' <summary>
|
||||
''' UDP通讯接收线程
|
||||
''' </summary>
|
||||
Private _receiveThread As Thread
|
||||
|
||||
Sub New(gControl As Control)
|
||||
|
||||
m_SerialComfig = New UDPComfig
|
||||
m_ReceiveQueue = New List(Of Cmdconfig)
|
||||
m_ReceiveQueue.Clear()
|
||||
m_Control = gControl
|
||||
|
||||
recvBufferli = New List(Of Byte)
|
||||
m_SpecialReceiveFlag = -1
|
||||
CommunicationTypeindex = 2
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub SendData(data As Cmdconfig)
|
||||
data.CmdSendTime = DateTime.Now
|
||||
If IsNothing(m_Serial) OrElse Not m_Serial.IsBound Then
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"发送器未连接!", Color.Red), 1)
|
||||
Return
|
||||
End If
|
||||
|
||||
'清空发送缓存
|
||||
m_Serial.SendTo(data.CmdSendData, m_SerialComfig.TargetEndPoint)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub CloseTransmitter()
|
||||
If Not IsNothing(m_Serial) Then
|
||||
m_Serial.Shutdown(SocketShutdown.Both)
|
||||
m_Serial.Close()
|
||||
m_Serial = Nothing
|
||||
End If
|
||||
If Not IsNothing(_receiveThread) AndAlso _receiveThread.IsAlive Then
|
||||
_receiveThread.Abort()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub ClearSendData()
|
||||
If IsNothing(m_ReceiveQueue) Then Return
|
||||
m_ReceiveQueue.Clear()
|
||||
End Sub
|
||||
Public Overrides Sub ClearReadData()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ReceiveData(g_comfig As Cmdconfig) As Cmdconfig
|
||||
|
||||
End Function
|
||||
''' <summary>
|
||||
''' UDP接收数据
|
||||
''' </summary>
|
||||
Private Sub UdpRecviveData()
|
||||
|
||||
Dim recvLength As Integer
|
||||
Dim recvBuffer(1024) As Byte
|
||||
|
||||
While m_Serial.IsBound
|
||||
Try
|
||||
recvLength = m_Serial.ReceiveFrom(recvBuffer, m_SerialComfig.TargetEndPoint)
|
||||
'_countRXData += recvLength
|
||||
Dim buf As Byte() = New Byte(recvLength - 1) {}
|
||||
Array.Copy(recvBuffer, buf, recvLength)
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(buf)}", Color.Blue), 1)
|
||||
Catch ex As Exception
|
||||
Console.WriteLine($"Udp Recv Error:{ex.Message}")
|
||||
Return
|
||||
End Try
|
||||
ReceivingDataProcessing(recvBuffer, recvLength)
|
||||
End While
|
||||
' If Not IsNothing(m_Transmitter) AndAlso m_Transmitter.IsTransmitter Then m_Transmitter.CloseTransmitter()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 接收数据处理
|
||||
''' </summary>
|
||||
''' <param name="recvBuffer"></param>
|
||||
''' <param name="recvLength"></param>
|
||||
Private Sub ReceivingDataProcessing(recvBuffer() As Byte, recvLength As Integer)
|
||||
Dim startIndex As Integer '定义一个开始的计数值
|
||||
Dim packetLength As Integer '定义包的长度
|
||||
While startIndex < recvLength '判断计数值是否小于总包长
|
||||
If recvBuffer(startIndex) = _fixedHead(0) AndAlso recvBuffer(startIndex + 1) = _fixedHead(1) Then ' 判断包头是否等于AA55
|
||||
If recvBuffer(startIndex + 4) = _fixeSystemId(0) AndAlso '判断第4,5,6,7位是否等于固定值
|
||||
recvBuffer(startIndex + 5) = _fixeSystemId(1) AndAlso
|
||||
recvBuffer(startIndex + 6) = _fixeSystemId(2) AndAlso
|
||||
recvBuffer(startIndex + 7) = _fixeSystemId(3) Then
|
||||
packetLength = recvBuffer(startIndex + 2) + recvBuffer(startIndex + 3) * 256 '赋值包长
|
||||
If packetLength + startIndex <= recvLength Then '判断包长 + 计数值是否小于等于总包长
|
||||
Dim packetData(packetLength - 1) As Byte '定义一个新数据包数组
|
||||
Array.Copy(recvBuffer, startIndex, packetData, 0, packetLength) '复制数组 +5个重载
|
||||
If CheckCRC16Sucess(packetData, packetData.Length) Then '判断CRC16校验是否通过
|
||||
'显示数据
|
||||
DealData(packetData, packetLength) '分部处理数据(显示文字提示)
|
||||
startIndex += packetData.Length '计数值更新
|
||||
Else
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"CRC16校验失败!", Color.Red), 1)
|
||||
Exit While
|
||||
End If
|
||||
Else
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"数据包长校验失败!", Color.Red), 1)
|
||||
Exit While
|
||||
End If
|
||||
Else
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"数据校验失败!", Color.Red), 1)
|
||||
Exit While
|
||||
End If
|
||||
Else
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"非RCU主机发送的数据!", Color.Red), 1)
|
||||
Exit While
|
||||
End If
|
||||
End While
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 检验CRC16成功
|
||||
''' </summary>
|
||||
''' <param name="dataBuff"></param>
|
||||
''' <param name="length"></param>
|
||||
''' <returns></returns>
|
||||
Private Function CheckCRC16Sucess(dataBuff() As Byte, length As Integer) As Boolean
|
||||
Dim crcBytes() As Byte = GetCRC16CheckSum(dataBuff, length - 2)
|
||||
If crcBytes(0) <> dataBuff(length - 2) OrElse crcBytes(1) <> dataBuff(length - 1) Then Return False
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 处理数据
|
||||
''' </summary>
|
||||
''' <param name="dataBuff"></param>
|
||||
''' <param name="length"></param>
|
||||
''' <returns></returns>
|
||||
Private Function DealData(dataBuff() As Byte, length As Integer) As Boolean
|
||||
Select Case dataBuff(8)
|
||||
Case &H70
|
||||
'获取队列第5个元素
|
||||
Dim len As Integer = m_ReceiveQueue.Count
|
||||
Dim item As Cmdconfig
|
||||
Dim buf(length - 17 - 1) As Byte
|
||||
Array.Copy(dataBuff, 15, buf, 0, buf.Length)
|
||||
|
||||
For i = 0 To len - 1
|
||||
If (len - 1 - i) < m_ReceiveQueue.Count Then
|
||||
item = m_ReceiveQueue(len - 1 - i)
|
||||
If dataBuff(15) = 2 Then
|
||||
item.OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_STATUS = 1
|
||||
item.OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_RESULT = dataBuff(16)
|
||||
End If
|
||||
If dataBuff(15) = 1 Then
|
||||
item.OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_STATUS = 1
|
||||
item.OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_RESULT = dataBuff(16)
|
||||
End If
|
||||
|
||||
'item.Protocol.ParseReceiveData(item, buf)
|
||||
End If
|
||||
Next
|
||||
Case &H71
|
||||
Dim len As Integer = m_ReceiveQueue.Count
|
||||
Dim item As Cmdconfig
|
||||
Dim buf(length - 17 - 1 - 2) As Byte
|
||||
If 17 + buf.Length < dataBuff.Length Then
|
||||
Array.Copy(dataBuff, 17, buf, 0, buf.Length)
|
||||
For i = 0 To len - 1
|
||||
If (len - 1 - i) < m_ReceiveQueue.Count Then
|
||||
item = m_ReceiveQueue(len - 1 - i)
|
||||
'If dataBuff(15) = 2 Then
|
||||
' item.OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_STATUS = 1
|
||||
' item.OtherProtocol.UDP_TRANSPARENT_MODE_COMMAND_REPLY_RESULT = dataBuff(16)
|
||||
'End If
|
||||
'If dataBuff(15) = 1 Then
|
||||
' item.OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_STATUS = 1
|
||||
' item.OtherProtocol.UDP_QUERY_HOST_CURRENT_MODE_COMMAND_REPLY_RESULT = dataBuff(16)
|
||||
'End If
|
||||
|
||||
item.Protocol.ParseReceiveData2(item, buf)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
End Select
|
||||
Return True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 获取CRC16校验和
|
||||
''' </summary>
|
||||
''' <param name="dataBuff">数据</param>
|
||||
''' <param name="length">数据长度</param>
|
||||
''' <returns></returns>
|
||||
Private Function GetCRC16CheckSum(dataBuff() As Byte, length As Integer) As Byte()
|
||||
Dim crc16 As UInteger
|
||||
Dim crcBytes() As Byte
|
||||
|
||||
crc16 = &HFFFF
|
||||
For i = 0 To length - 1
|
||||
crc16 = crc16 And &HFFFF
|
||||
crc16 = crc16 Xor dataBuff(i)
|
||||
For bit = 0 To 7
|
||||
crc16 = IIf((crc16 And 1) = 0, crc16 >> 1, (crc16 >> 1) Xor &HA001)
|
||||
Next
|
||||
Next
|
||||
crc16 = crc16 And &HFFFF
|
||||
crcBytes = BitConverter.GetBytes(UShort.Parse(crc16))
|
||||
Return crcBytes
|
||||
End Function
|
||||
|
||||
Public Overrides Function IsTransmitter() As Boolean
|
||||
If IsNothing(m_Serial) OrElse m_Serial.Connected = False Then Return False
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Overrides Function OpenTransmitter() As Boolean
|
||||
If Not IsNothing(m_Serial) Then
|
||||
m_Serial.Shutdown(SocketShutdown.Both)
|
||||
m_Serial.Close()
|
||||
End If
|
||||
If Not IsNothing(_receiveThread) AndAlso _receiveThread.IsAlive Then
|
||||
_receiveThread.Abort()
|
||||
End If
|
||||
|
||||
m_Serial = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
|
||||
''加保护机制
|
||||
m_Serial.Bind(m_SerialComfig.LocalEndPoint)
|
||||
m_Serial.Connect(m_SerialComfig.TargetEndPoint)
|
||||
_receiveThread = New Thread(New ThreadStart(AddressOf UdpRecviveData))
|
||||
_receiveThread.Start()
|
||||
End Function
|
||||
|
||||
Public Overrides Function GetTransmitterStatus() As Boolean
|
||||
If IsNothing(m_Serial) Then Return False
|
||||
Return True
|
||||
End Function
|
||||
''' <summary>
|
||||
''' 本地ip/本地端口/目标ip/目标端口
|
||||
''' </summary>
|
||||
''' <param name="params"></param>
|
||||
''' <returns></returns>
|
||||
Public Overrides Function SetTransmitterParameter(ParamArray params() As Object) As Boolean
|
||||
If IsNothing(m_SerialComfig) Then Return False
|
||||
Dim ipAddr As IPAddress
|
||||
Dim port As Integer
|
||||
If params.Length > 0 Then
|
||||
'判断是否为ip
|
||||
If IPAddress.TryParse(params(0), ipAddr) Then
|
||||
m_SerialComfig.LocalIP = ipAddr
|
||||
End If
|
||||
If params.Length > 1 Then
|
||||
'判断是否为端口
|
||||
If Integer.TryParse(params(1), port) Then
|
||||
m_SerialComfig.LocalPort = port
|
||||
End If
|
||||
End If
|
||||
If params.Length > 2 Then
|
||||
'判断是否为ip
|
||||
If IPAddress.TryParse(params(2), ipAddr) Then
|
||||
m_SerialComfig.TargetIP = ipAddr
|
||||
End If
|
||||
If params.Length > 3 Then
|
||||
'判断是否为端口
|
||||
If Integer.TryParse(params(3), port) Then
|
||||
m_SerialComfig.TargetPort = port
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'判断本地ip和 端口是否有效
|
||||
If IsNothing(m_SerialComfig.LocalIP) OrElse IsNothing(m_SerialComfig.LocalPort) Then
|
||||
MsgBox("本地ip或端口无效")
|
||||
Else
|
||||
'判断目标ip和 端口是否有效
|
||||
m_SerialComfig.LocalEndPoint = New IPEndPoint(m_SerialComfig.LocalIP, m_SerialComfig.LocalPort)
|
||||
End If
|
||||
'判断目标ip和 端口是否有效
|
||||
If IsNothing(m_SerialComfig.TargetIP) OrElse IsNothing(m_SerialComfig.TargetPort) Then
|
||||
MsgBox("目标ip或端口无效")
|
||||
Else
|
||||
m_SerialComfig.TargetEndPoint = New IPEndPoint(m_SerialComfig.TargetIP, m_SerialComfig.TargetPort)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
'判断是否为端口
|
||||
Private Function IsPort(port As String) As Boolean
|
||||
Return Integer.TryParse(port, port)
|
||||
End Function
|
||||
'判断是否为ip
|
||||
Private Function IsIP(ip As String) As Boolean
|
||||
Dim ipAddr As IPAddress
|
||||
Return IPAddress.TryParse(ip, ipAddr)
|
||||
End Function
|
||||
|
||||
Public Overrides Function SendData(data() As Byte) As Boolean
|
||||
'data.CmdSendTime = DateTime.Now
|
||||
If IsNothing(m_Serial) Then
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"发送器未连接!", Color.Red), 1)
|
||||
Return False
|
||||
End If
|
||||
|
||||
'清空发送缓存
|
||||
m_Serial.SendTo(data, m_SerialComfig.TargetEndPoint)
|
||||
Return True
|
||||
End Function
|
||||
End Class
|
||||
Public Class UDPComfig
|
||||
'本地ip
|
||||
Public LocalIP As IPAddress
|
||||
'本地端口
|
||||
Public LocalPort As Integer
|
||||
'目标ip
|
||||
Public TargetIP As IPAddress
|
||||
'目标端口
|
||||
Public TargetPort As Integer
|
||||
'发送网络端点
|
||||
Public LocalEndPoint As IPEndPoint
|
||||
'接收网络端点
|
||||
Public TargetEndPoint As IPEndPoint
|
||||
|
||||
'获取 串口名称列表
|
||||
Sub New()
|
||||
LocalIP = GetLocalIP.Item(0)
|
||||
|
||||
End Sub
|
||||
|
||||
'获取本地IP列表
|
||||
Public Shared Function GetLocalIP() As List(Of IPAddress)
|
||||
Dim address() As IPAddress
|
||||
Dim destAddress As New List(Of IPAddress)
|
||||
address = Dns.GetHostEntry(Dns.GetHostName()).AddressList
|
||||
For Each pAddress As IPAddress In address
|
||||
If pAddress.AddressFamily = AddressFamily.InterNetwork Then
|
||||
destAddress.Add(pAddress)
|
||||
End If
|
||||
Next
|
||||
Return destAddress
|
||||
End Function
|
||||
|
||||
End Class
|
||||
537
Transmitter/SerialController.vb
Normal file
537
Transmitter/SerialController.vb
Normal file
@@ -0,0 +1,537 @@
|
||||
Imports System.IO.Ports
|
||||
Imports System.Threading
|
||||
Imports _485_BurningTool.BLV_Bootloader
|
||||
|
||||
Public Class SerialController
|
||||
Inherits Transmitter
|
||||
|
||||
Public m_Serial As SerialPort
|
||||
|
||||
Public m_SerialComfig As SerialComfig
|
||||
Public m_Control As Control
|
||||
Private Timer1 As System.Windows.Forms.Timer
|
||||
'接收数据队列
|
||||
Public m_ReceiveQueue As List(Of Cmdconfig) = New List(Of Cmdconfig)
|
||||
'特殊接收处理标志
|
||||
Public m_SpecialReceiveFlag As Integer
|
||||
|
||||
Sub New(gControl As Control)
|
||||
|
||||
CommunicationTypeindex = 1
|
||||
m_SerialComfig = New SerialComfig
|
||||
m_ReceiveQueue = New List(Of Cmdconfig)
|
||||
m_ReceiveQueue.Clear()
|
||||
m_Control = gControl
|
||||
'm_Serial = New SerialPort
|
||||
'CreateSerial(m_SerialComfig)
|
||||
'创建定时器绑定定时器函数
|
||||
'Timer1 = New System.Windows.Forms.Timer
|
||||
'Timer1.Interval = 1000
|
||||
'AddHandler Timer1.Tick, AddressOf TimerTick
|
||||
'Timer1.Start()
|
||||
recvBufferli = New List(Of Byte)
|
||||
m_SpecialReceiveFlag = -1
|
||||
End Sub
|
||||
'定时器函数 定时查看接收队列是否接收超时
|
||||
Public Sub TimerTick()
|
||||
Dim len As Integer = m_ReceiveQueue.Count
|
||||
For i = 0 To len - 1
|
||||
'从尾部倒序查看节点是否超时
|
||||
Dim item As Cmdconfig = m_ReceiveQueue(len - 1 - i)
|
||||
If (Now - item.CmdSendTime).TotalSeconds > item.CmdReceiveTimeout Then
|
||||
m_ReceiveQueue.RemoveAt(len - 1 - i)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
'创建串口连接
|
||||
Public Function CreateSerial(g_SerialComfig As SerialComfig) As Boolean
|
||||
|
||||
Try
|
||||
If IsNothing(m_Serial) Then
|
||||
m_Serial = New SerialPort(g_SerialComfig.PortName, g_SerialComfig.BaudRate, g_SerialComfig.Parity, g_SerialComfig.DataBits, g_SerialComfig.StopBits)
|
||||
AddHandler m_Serial.DataReceived, AddressOf DataReceivedHandler
|
||||
m_Serial.Open()
|
||||
Return True
|
||||
Else
|
||||
Dim m_SerialIsOpen As Boolean = False
|
||||
If m_Serial.IsOpen Then
|
||||
isread = True
|
||||
While isListen
|
||||
Application.DoEvents()
|
||||
Thread.Sleep(10)
|
||||
End While
|
||||
Thread.Sleep(10)
|
||||
m_Serial.Close()
|
||||
m_SerialIsOpen = True
|
||||
End If
|
||||
m_Serial.PortName = g_SerialComfig.PortName
|
||||
m_Serial.BaudRate = g_SerialComfig.BaudRate
|
||||
m_Serial.Parity = g_SerialComfig.Parity
|
||||
m_Serial.DataBits = g_SerialComfig.DataBits
|
||||
m_Serial.StopBits = g_SerialComfig.StopBits
|
||||
m_Serial.Handshake = g_SerialComfig.Handshake
|
||||
If m_SerialIsOpen Then
|
||||
m_Serial.Open()
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
Public Overrides Sub ClearReadData()
|
||||
If IsNothing(m_Serial) Then
|
||||
Return
|
||||
Else
|
||||
If m_Serial.IsOpen Then
|
||||
'清空接收缓存
|
||||
m_Serial.DiscardInBuffer()
|
||||
End If
|
||||
End If
|
||||
If IsNothing(recvBufferli) OrElse recvBufferli.Count = 0 Then
|
||||
Return
|
||||
Else
|
||||
recvBufferli.Clear()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
'设置串口参数
|
||||
|
||||
''' 接收数据偏移量
|
||||
Private _recvOffset, _recvstar As Integer
|
||||
''' <summary>
|
||||
''' 接收数据缓存包
|
||||
''' </summary>
|
||||
Private _recvBuffer(4095) As Byte
|
||||
Public recvBufferli As List(Of Byte)
|
||||
Public recvBufferliindex As Integer = 0
|
||||
'获取 串口数据
|
||||
Private Sub DataReceivedHandler(sender As Object, e As SerialDataReceivedEventArgs)
|
||||
If isread Then Return
|
||||
|
||||
isListen = True
|
||||
Static bytes As Integer = 0
|
||||
Dim sp As SerialPort = DirectCast(sender, SerialPort)
|
||||
|
||||
Try
|
||||
Select Case m_SpecialReceiveFlag
|
||||
Case WorkflowType.SearchEquipment
|
||||
Do
|
||||
bytes = sp.BytesToRead
|
||||
If bytes <= 0 Then
|
||||
isListen = False
|
||||
Exit Sub
|
||||
End If
|
||||
'If bytes + _recvOffset >= 4096 Then
|
||||
|
||||
' 'ShowPortReceData(_recvBuffer)
|
||||
|
||||
' sp.Read(_recvBuffer, _recvOffset, 4096 - _recvOffset)
|
||||
|
||||
' _recvOffset = 0
|
||||
'Else
|
||||
' sp.Read(_recvBuffer, _recvOffset, bytes)
|
||||
' _recvOffset += bytes
|
||||
'End If
|
||||
|
||||
Dim buf(bytes - 1) As Byte
|
||||
sp.Read(buf, 0, bytes)
|
||||
recvBufferli.AddRange(buf)
|
||||
Thread.Sleep(1)
|
||||
Loop While sp.BytesToRead > 0
|
||||
If recvBufferli.Count > 0 Then
|
||||
'RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(recvBufferli.ToArray)}", Color.Black), 1)
|
||||
Dim item As Cmdconfig
|
||||
item = m_ReceiveQueue(0)
|
||||
'判断超时
|
||||
If item.CmdSendTime.AddMilliseconds(item.CmdReceiveTimeout) < Now Then
|
||||
recvBufferli.Clear()
|
||||
recvBufferliindex = 0
|
||||
Console.WriteLine("超时清空-----------------------------")
|
||||
Else
|
||||
'截取搜索回复
|
||||
|
||||
recvBufferliindex = ExtractSearchReply(recvBufferli.ToArray, item)
|
||||
|
||||
End If
|
||||
End If
|
||||
Case Else
|
||||
Do
|
||||
bytes = sp.BytesToRead
|
||||
If bytes <= 0 Then
|
||||
isListen = False
|
||||
Exit Sub
|
||||
End If
|
||||
'If bytes + _recvOffset >= 4096 Then
|
||||
|
||||
' 'ShowPortReceData(_recvBuffer)
|
||||
|
||||
' sp.Read(_recvBuffer, _recvOffset, 4096 - _recvOffset)
|
||||
|
||||
' _recvOffset = 0
|
||||
'Else
|
||||
' sp.Read(_recvBuffer, _recvOffset, bytes)
|
||||
' _recvOffset += bytes
|
||||
'End If
|
||||
|
||||
Dim buf(bytes - 1) As Byte
|
||||
sp.Read(buf, 0, bytes)
|
||||
'清空可读缓存
|
||||
'sp.DiscardInBuffer()
|
||||
|
||||
recvBufferli.AddRange(buf)
|
||||
|
||||
|
||||
Thread.Sleep(7)
|
||||
Loop While sp.BytesToRead > 0
|
||||
|
||||
If recvBufferli.Count > 0 Then
|
||||
|
||||
|
||||
|
||||
Dim buf(recvBufferli.Count - 1) As Byte
|
||||
Array.Copy(recvBufferli.ToArray, 0, buf, 0, buf.Length)
|
||||
recvBufferli.Clear()
|
||||
' Array.Copy(_recvBuffer, _recvstar, buf, 0, buf.Length)
|
||||
'Console.WriteLine(DataProcessing.ByteToString2(buf))
|
||||
'_recvstar = _recvOffset
|
||||
|
||||
'枚举队列
|
||||
'获取队列第5个元素
|
||||
Dim len As Integer = m_ReceiveQueue.Count
|
||||
Dim item As Cmdconfig
|
||||
Dim timep As TimeSpan
|
||||
' RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(buf)}", Color.Blue), 1)
|
||||
mCommunicationFlowAddQueue(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(buf)}", Color.Blue), 1) '
|
||||
' RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(buff)}", Color.Blue), 1)
|
||||
'Console.WriteLine($"RX():{len} ")
|
||||
For i = 0 To len - 1
|
||||
' Console.WriteLine($"RX:{len - 1 - i}< {m_ReceiveQueue.Count }")
|
||||
If (len - 1 - i) < m_ReceiveQueue.Count Then
|
||||
item = m_ReceiveQueue(len - 1 - i)
|
||||
|
||||
|
||||
'timep = (Now - item.CmdSendTime)
|
||||
''判断本节点接收时间是否超时
|
||||
'If item.CmdReceiveStatus OrElse timep.TotalSeconds > item.CmdReceiveTimeout Then
|
||||
' Console.WriteLine($"item.CmdReceiveStatus:{item.CmdReceiveStatus}, timep.TotalSeconds > item.CmdReceiveTimeout :{ timep.TotalSeconds}>{item.CmdReceiveTimeout}")
|
||||
' item.setCmdReceiveStatus(True)
|
||||
' Continue For
|
||||
'End If
|
||||
'按照对应协议解析 并设置到本节点中
|
||||
item.Protocol.ParseReceiveData(item, buf)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End Select
|
||||
isListen = False
|
||||
Catch ex As Exception
|
||||
isListen = False
|
||||
'AppendTipText($"串口接收数据失败,原因:{ex.Message}", Color.Red)
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"串口接收数据失败,原因:{ex.Message}", Color.Red), 1)
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
Delegate Sub delmCommunicationFlowAddQueue(c As Control, rl As RuningLogConfig, lev As Integer)
|
||||
Public Sub mCommunicationFlowAddQueue(c As Control, rl As RuningLogConfig, Optional lev As Integer = 0)
|
||||
If c.InvokeRequired Then
|
||||
Dim d As New delmCommunicationFlowAddQueue(AddressOf mCommunicationFlowAddQueue)
|
||||
c.Invoke(d, c, rl, lev)
|
||||
Else
|
||||
RuningLog.OutputLogsToTheControl(c, rl, lev)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function ExtractSearchReply(bufarry As Byte(), item As Cmdconfig) As Integer
|
||||
|
||||
If bufarry.Length - recvBufferliindex < 12 Then
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"接收数据长度异常!", Color.Red), 1)
|
||||
Return recvBufferliindex
|
||||
End If
|
||||
Dim len As Integer
|
||||
Dim result As Integer = recvBufferliindex
|
||||
'Dim buff(44) As Bytei+
|
||||
'遍历找到sn\
|
||||
' Console.WriteLine($"ExtractSearchReply:{recvBufferliindex} {vbCrLf}RX:{DataProcessing.ByteToString2(bufarry)}")
|
||||
AddQueue(m_Control, New RuningLogConfig($"RX1:", Color.Blue), 1)
|
||||
For i = recvBufferliindex To bufarry.Length - 1
|
||||
If (bufarry(i) And &HF) = (item.CmdSendData(1) And &HF) Then '
|
||||
If i + 6 < bufarry.Length Then
|
||||
If bufarry(i + 2) = item.CmdSendData(0) AndAlso bufarry(i + 6) = item.CmdSendData(7) Then
|
||||
len = bufarry(i + 3) + bufarry(i + 4) * 256
|
||||
Dim buff(len - 1) As Byte
|
||||
If i > 0 Then
|
||||
|
||||
If i + len - 2 < bufarry.Length Then
|
||||
Try
|
||||
Array.Copy(bufarry, i - 1, buff, 0, len)
|
||||
i = i + len - 2
|
||||
|
||||
item.Protocol.ParseReceiveData(item, buff)
|
||||
result = i + 1
|
||||
AddQueue(m_Control, New RuningLogConfig($"RX2:", Color.Blue), 1) '{DataProcessing.ByteToString2(buff)}
|
||||
' RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"RX:{DataProcessing.ByteToString2(buff)}", Color.Blue), 1)
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
Console.WriteLine($"ExtractSearchReply------end:{result}")
|
||||
Return result
|
||||
End Function
|
||||
|
||||
'设置波特率
|
||||
Public Sub AnalyzeData()
|
||||
|
||||
End Sub
|
||||
|
||||
'判断串口是否有数据未接收
|
||||
Public Function IsSerialData() As Boolean
|
||||
' If IsNothing(m_Serial) Then Return False
|
||||
Return m_Serial.BytesToRead > 0
|
||||
End Function
|
||||
|
||||
Public Function SetBaudRate(baudRate As Integer, Optional devnumber As Integer = 1) As Boolean
|
||||
If IsNothing(m_Serial) Then Return False
|
||||
Dim ret As Boolean = m_Serial.IsOpen
|
||||
'Dim buff As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}
|
||||
If m_Serial.IsOpen Then
|
||||
'Thread.Sleep(300 * devnumber)
|
||||
isread = True
|
||||
While isListen
|
||||
Application.DoEvents()
|
||||
Thread.Sleep(10)
|
||||
End While
|
||||
Thread.Sleep(10)
|
||||
'm_Serial.Write(buff, 0, buff.Length)
|
||||
m_Serial.Close()
|
||||
|
||||
End If
|
||||
|
||||
m_Serial.BaudRate = baudRate
|
||||
|
||||
If ret Then
|
||||
isread = False
|
||||
m_Serial.Open()
|
||||
'm_Serial.Write(buff, 0, buff.Length)
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
'打开串口
|
||||
Public Function OpenSerial() As Boolean
|
||||
If IsNothing(m_Serial) Then Return False
|
||||
If Not m_Serial.IsOpen Then
|
||||
isread = False
|
||||
m_Serial.Open()
|
||||
End If
|
||||
End Function
|
||||
'关闭串口连接
|
||||
Public Sub CloseSerial()
|
||||
If IsNothing(m_Serial) Then Return
|
||||
If m_Serial.IsOpen Then
|
||||
isread = True
|
||||
While isListen
|
||||
Application.DoEvents()
|
||||
Thread.Sleep(10)
|
||||
End While
|
||||
Thread.Sleep(10)
|
||||
m_Serial.Close()
|
||||
|
||||
End If
|
||||
Timer1.Stop()
|
||||
End Sub
|
||||
'获取串口接收数据
|
||||
Public Overrides Function ReceiveData(g_comfig As Cmdconfig) As Cmdconfig
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
'发送数据
|
||||
Public Overrides Sub SendData(data As Cmdconfig)
|
||||
data.CmdSendTime = DateTime.Now
|
||||
If IsNothing(m_Serial) OrElse Not m_Serial.IsOpen Then
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"发送器未连接!", Color.Red), 1)
|
||||
Return
|
||||
End If
|
||||
'Dim Rl As New RuningLogConfig($"TX:", Color.DarkGreen)
|
||||
'Rl.strdata = data.CmdSendData
|
||||
' RuningLog.OutputLogsToTheControl(m_Control, Rl, 1)
|
||||
'AddQueue(m_Control, New RuningLogConfig($"TX:", Color.DarkGreen), 1)
|
||||
|
||||
'清空发送缓存
|
||||
'm_Serial.DiscardOutBuffer()
|
||||
|
||||
Try
|
||||
m_Serial.Write(data.CmdSendData, 0, data.CmdSendData.Length)
|
||||
'Dim buff As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}
|
||||
'm_Serial.Write(buff, 0, buff.Length)
|
||||
Catch ex As Exception
|
||||
Console.WriteLine(ex.Message)
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function OpenTransmitter() As Boolean
|
||||
If IsNothing(m_Serial) Then
|
||||
Return CreateSerial(m_SerialComfig)
|
||||
End If
|
||||
If Not m_Serial.IsOpen Then
|
||||
Try
|
||||
isread = False
|
||||
m_Serial.Open()
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
Public isread As Boolean = False
|
||||
Public isListen As Boolean = False
|
||||
Public Overrides Sub CloseTransmitter()
|
||||
If IsNothing(m_Serial) OrElse Not m_Serial.IsOpen Then Return
|
||||
isread = True
|
||||
While isListen
|
||||
Application.DoEvents()
|
||||
Thread.Sleep(10)
|
||||
End While
|
||||
|
||||
Thread.Sleep(10)
|
||||
m_Serial.Close()
|
||||
m_Serial = Nothing
|
||||
End Sub
|
||||
|
||||
Public Overrides Function IsTransmitter() As Boolean
|
||||
If IsNothing(m_Serial) Then
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Overrides Function GetTransmitterStatus() As Boolean
|
||||
If IsNothing(m_Serial) Then Return False
|
||||
Return m_Serial.IsOpen
|
||||
End Function
|
||||
|
||||
'
|
||||
Public Overrides Function SetTransmitterParameter(ParamArray params() As Object) As Boolean
|
||||
If IsNothing(m_SerialComfig) Then Return False
|
||||
'If m_Serial.IsOpen Then m_Serial.Close()
|
||||
If params.Length > 0 Then
|
||||
If TypeOf params(0) Is String Then
|
||||
m_SerialComfig.PortName = params(0)
|
||||
End If
|
||||
End If
|
||||
If params.Length > 1 Then
|
||||
If TypeOf params(1) Is Integer Then
|
||||
m_SerialComfig.BaudRate = params(1)
|
||||
End If
|
||||
End If
|
||||
If params.Length > 2 Then
|
||||
If TypeOf params(2) Is Integer Then
|
||||
m_SerialComfig.DataBits = params(2)
|
||||
End If
|
||||
End If
|
||||
If params.Length > 3 Then
|
||||
If TypeOf params(3) Is Parity Then
|
||||
m_SerialComfig.Parity = params(3)
|
||||
End If
|
||||
End If
|
||||
If params.Length > 4 Then
|
||||
If TypeOf params(4) Is StopBits Then
|
||||
m_SerialComfig.StopBits = params(4)
|
||||
End If
|
||||
End If
|
||||
If params.Length > 5 Then
|
||||
If TypeOf params(5) Is Handshake Then
|
||||
m_SerialComfig.Handshake = params(5)
|
||||
End If
|
||||
End If
|
||||
Return CreateSerial(m_SerialComfig)
|
||||
End Function
|
||||
|
||||
Public Overrides Sub ClearSendData()
|
||||
If IsNothing(m_ReceiveQueue) Then Return
|
||||
m_ReceiveQueue.Clear()
|
||||
End Sub
|
||||
|
||||
Public Overrides Function SendData(data() As Byte) As Boolean
|
||||
'data.CmdSendTime = DateTime.Now
|
||||
If IsNothing(m_Serial) OrElse Not m_Serial.IsOpen Then
|
||||
RuningLog.OutputLogsToTheControl(m_Control, New RuningLogConfig($"发送器未连接!", Color.Red), 1)
|
||||
Return False
|
||||
End If
|
||||
'Dim Rl As New RuningLogConfig($"TX:", Color.DarkGreen)
|
||||
'Rl.strdata = data.CmdSendData
|
||||
' RuningLog.OutputLogsToTheControl(m_Control, Rl, 1)
|
||||
'AddQueue(m_Control, New RuningLogConfig($"TX:", Color.DarkGreen), 1)
|
||||
|
||||
'清空发送缓存
|
||||
'm_Serial.DiscardOutBuffer()
|
||||
|
||||
Try
|
||||
m_Serial.Write(data, 0, data.Length)
|
||||
'Dim buff As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}
|
||||
'm_Serial.Write(buff, 0, buff.Length)
|
||||
Catch ex As Exception
|
||||
Console.WriteLine(ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class SerialComfig
|
||||
'串口名称
|
||||
Public PortName As String
|
||||
'波特率
|
||||
Public BaudRate As Integer
|
||||
'数据位
|
||||
Public DataBits As Integer
|
||||
'校验位
|
||||
Public Parity As Parity
|
||||
'停止位
|
||||
Public StopBits As StopBits
|
||||
'流控制
|
||||
Public Handshake As Handshake
|
||||
|
||||
'获取 串口名称列表
|
||||
Sub New()
|
||||
PortName = GetPortNames()(0)
|
||||
BaudRate = GetBaudRates()(0)
|
||||
DataBits = 8
|
||||
Parity = Parity.None
|
||||
StopBits = StopBits.One
|
||||
Handshake = Handshake.None
|
||||
|
||||
End Sub
|
||||
Public Shared Function GetPortNames() As String()
|
||||
Return SerialPort.GetPortNames()
|
||||
End Function
|
||||
'获取波特率列表
|
||||
Public Shared Function GetBaudRates() As Integer()
|
||||
Return New Integer() {300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000, 512000}
|
||||
End Function
|
||||
End Class
|
||||
43
Transmitter/Transmitter.vb
Normal file
43
Transmitter/Transmitter.vb
Normal file
@@ -0,0 +1,43 @@
|
||||
Imports _485_BurningTool.CommunicationFlow
|
||||
|
||||
Public MustInherit Class Transmitter
|
||||
Public mCommunicationFlow As CommunicationProtocol
|
||||
|
||||
' 发送数据方法
|
||||
Public MustOverride Sub SendData(data As Cmdconfig)
|
||||
Public MustOverride Function SendData(data As Byte()) As Boolean
|
||||
'获取发送器接收数据
|
||||
Public MustOverride Function ReceiveData(g_comfig As Cmdconfig) As Cmdconfig
|
||||
'判断发送器实体化没有
|
||||
Public MustOverride Function IsTransmitter() As Boolean
|
||||
'打开发送器
|
||||
Public MustOverride Function OpenTransmitter() As Boolean
|
||||
'关闭发送器
|
||||
Public MustOverride Sub CloseTransmitter()
|
||||
'获取发送器状态
|
||||
Public MustOverride Function GetTransmitterStatus() As Boolean
|
||||
'设置发送器参数
|
||||
Public MustOverride Function SetTransmitterParameter(ParamArray params() As Object) As Boolean
|
||||
' 清楚发送数据
|
||||
Public MustOverride Sub ClearSendData()
|
||||
Public MustOverride Sub ClearReadData()
|
||||
Public CommunicationTypeindex As Integer
|
||||
|
||||
'创建发送器对象
|
||||
Public Shared Function CreateTransmitter(TransmitterType As CommunicationType, gControl As Control) As Transmitter
|
||||
'CommunicationTypeindex = TransmitterType
|
||||
Select Case TransmitterType
|
||||
Case CommunicationType.SerialPort
|
||||
Return New SerialController(gControl)
|
||||
Case CommunicationType.Udp
|
||||
Return New DevNetworkCommunication(gControl)
|
||||
Case Else
|
||||
Return Nothing
|
||||
End Select
|
||||
End Function
|
||||
Public Sub AddQueue(c As Control, rl As RuningLogConfig, Optional lev As Integer = 0)
|
||||
If IsNothing(mCommunicationFlow) OrElse IsNothing(mCommunicationFlow.UpdateUIqueue) OrElse IsNothing(c) OrElse IsNothing(rl) Then Return
|
||||
mCommunicationFlow.UpdateUIqueue.Enqueue((c, rl, lev))
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,7 @@
|
||||
' <autogenerated/>
|
||||
Option Strict Off
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
<Assembly: Global.System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName:=".NET Framework 4.8")>
|
||||
BIN
obj/Debug/485_BurningTool.exe
Normal file
BIN
obj/Debug/485_BurningTool.exe
Normal file
Binary file not shown.
BIN
obj/Debug/485_BurningTool.pdb
Normal file
BIN
obj/Debug/485_BurningTool.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/485_BurningTool.vbproj.AssemblyReference.cache
Normal file
BIN
obj/Debug/485_BurningTool.vbproj.AssemblyReference.cache
Normal file
Binary file not shown.
0
obj/Debug/485_BurningTool.vbproj.CopyComplete
Normal file
0
obj/Debug/485_BurningTool.vbproj.CopyComplete
Normal file
1
obj/Debug/485_BurningTool.vbproj.CoreCompileInputs.cache
Normal file
1
obj/Debug/485_BurningTool.vbproj.CoreCompileInputs.cache
Normal file
@@ -0,0 +1 @@
|
||||
5585f70d99a2d03ed18e1ed38c4bd2f273f9b93f
|
||||
30
obj/Debug/485_BurningTool.vbproj.FileListAbsolute.txt
Normal file
30
obj/Debug/485_BurningTool.vbproj.FileListAbsolute.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.vbproj.AssemblyReference.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\_485_BurningTool.Form1.resources
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\_485_BurningTool.Resources.resources
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.vbproj.GenerateResource.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.vbproj.CoreCompileInputs.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\485_BurningTool.exe.config
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\485_BurningTool.exe
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\485_BurningTool.pdb
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\485_BurningTool.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.exe
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.pdb
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\Newtonsoft.Json.dll
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\bin\Debug\Newtonsoft.Json.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\新建文件夹\485_BurningTool\obj\Debug\485_BurningTool.vbproj.CopyComplete
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\485_BurningTool.exe.config
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\485_BurningTool.exe
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\485_BurningTool.pdb
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\485_BurningTool.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\Newtonsoft.Json.dll
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\bin\Debug\Newtonsoft.Json.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.vbproj.AssemblyReference.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\_485_BurningTool.Form1.resources
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\_485_BurningTool.Resources.resources
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.vbproj.GenerateResource.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.vbproj.CoreCompileInputs.cache
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.vbproj.CopyComplete
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.exe
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.xml
|
||||
E:\Sync\485_BurningTool\485_BurningTool\485_BurningTool\obj\Debug\485_BurningTool.pdb
|
||||
BIN
obj/Debug/485_BurningTool.vbproj.GenerateResource.cache
Normal file
BIN
obj/Debug/485_BurningTool.vbproj.GenerateResource.cache
Normal file
Binary file not shown.
356
obj/Debug/485_BurningTool.xml
Normal file
356
obj/Debug/485_BurningTool.xml
Normal file
@@ -0,0 +1,356 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>
|
||||
485_BurningTool
|
||||
</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:_485_BurningTool.My.Resources.Resources">
|
||||
<summary>
|
||||
一个强类型的资源类,用于查找本地化的字符串等。
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:_485_BurningTool.My.Resources.Resources.ResourceManager">
|
||||
<summary>
|
||||
返回此类使用的缓存的 ResourceManager 实例。
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:_485_BurningTool.My.Resources.Resources.Culture">
|
||||
<summary>
|
||||
重写当前线程的 CurrentUICulture 属性,对
|
||||
使用此强类型资源类的所有资源查找执行重写。
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.BLV_Bootloader.SearchEquipmentProcess(_485_BurningTool.Cmdconfig,System.Object[])">
|
||||
<summary>
|
||||
搜索设备流程
|
||||
</summary>
|
||||
<param name="args">超时时间、表格控件、打印控件 </param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.BLV_Bootloaderconfig.SetProtocolParam(System.String[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="args"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.SearchEquipmentProcess(_485_BurningTool.Cmdconfig,System.Object[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="limitTime">发送持续时间</param>
|
||||
<param name="g_Cmdconfig">搜索命令节点</param>
|
||||
<param name="args"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.FillSendDataPacket(System.Byte[])">
|
||||
<summary>
|
||||
填充发送数据包
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.FillSendPacket(System.Byte[],System.Byte[],System.Byte[])">
|
||||
<summary>
|
||||
填充发送数据包
|
||||
</summary>
|
||||
<param name="head">数据包头</param>
|
||||
<param name="data">数据内容</param>
|
||||
<param name="crc16">CRC16校验</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.CheckSendData(System.Byte[],System.Byte[])">
|
||||
<summary>
|
||||
填充发送校验数据
|
||||
</summary>
|
||||
<param name="byteHead"></param>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.GetCRC16CheckSum(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
CRC16校验
|
||||
</summary>
|
||||
<param name="dataBuff"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialPort_BLV_Bootloader._dataHeadLength">
|
||||
<summary>
|
||||
包头数据长度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialPort_BLV_Bootloader._dataCRCLength">
|
||||
<summary>
|
||||
数据CRC校验长度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialPort_BLV_Bootloader._fixedHead">
|
||||
<summary>
|
||||
透传数据包头
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialPort_BLV_Bootloader._fixeSystemId">
|
||||
<summary>
|
||||
透传数据固定ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialPort_BLV_Bootloader._fixeRoomInfo">
|
||||
<summary>
|
||||
透传数据房间信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.SendDataHead(System.Byte[])">
|
||||
<summary>
|
||||
填充发送包头数据
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.SerialPort_BLV_Bootloader.FillSendPacketHead(System.Int16,System.Byte,System.Int16)">
|
||||
<summary>
|
||||
填充发送信息包头
|
||||
</summary>
|
||||
<param name="length"></param>
|
||||
<param name="cmdType"></param>
|
||||
<param name="frameNum"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.Form1.m_ApplicationconfigContainsKey(System.String,System.String,System.Int32)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="key"></param>
|
||||
<param name="mode">1获取 2设置</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.Form1.CreateParameterlist(System.Int32,System.Collections.Generic.List{System.ValueTuple{System.Int32,_485_BurningTool.Cmdconfig}},System.Int32,System.Windows.Forms.Button,System.Int32)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="CurrentStep">第一个流程节点</param>
|
||||
<param name="li">流程列表</param>
|
||||
<param name="Action">功能类型</param>
|
||||
<param name="btn">触发按钮</param>
|
||||
<param name="NextAction">运行状态</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.RuningLog.OutputLogsToTheControl(System.Windows.Forms.Control,_485_BurningTool.RuningLogConfig,System.Int32)">
|
||||
<summary>
|
||||
''输出日志到控件
|
||||
</summary>
|
||||
<param name="c">控件 </param>
|
||||
<param name="config">日志</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.RuningLogConfig.#ctor(System.Object[])">
|
||||
<summary>
|
||||
文本、颜色、Font
|
||||
</summary>
|
||||
<param name="args"></param>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetPortToBytes(System.String)">
|
||||
<summary>
|
||||
端口号转换为Byte数组
|
||||
</summary>
|
||||
<param name="port"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.IntToByteLB(System.Int32)">
|
||||
<summary>
|
||||
Int转2个字节Byte
|
||||
低字节在前,高字节在后
|
||||
</summary>
|
||||
<param name="i"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.IntToByteLxxB(System.Int32)">
|
||||
<summary>
|
||||
Int转4个字节Byte
|
||||
低字节在前,高字节在后
|
||||
</summary>
|
||||
<param name="i"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.IntToByteHB(System.Int32)">
|
||||
<summary>
|
||||
Int转2个字节Byte
|
||||
高字节在前,低字节在后
|
||||
</summary>
|
||||
<param name="i"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetMd5(System.String)">
|
||||
<summary>
|
||||
获取文件的MD5值
|
||||
返回Byte数组值
|
||||
</summary>
|
||||
<param name="filepath">文件路径</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetMd5String(System.String)">
|
||||
<summary>
|
||||
获取文件的MD5值
|
||||
返回String字符串
|
||||
</summary>
|
||||
<param name="filepath">文件路径</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetLocalIp">
|
||||
<summary>
|
||||
获取本地可用IP
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.ByteToString(System.Byte[])">
|
||||
<summary>
|
||||
Byte数组转字符串
|
||||
</summary>
|
||||
<param name="databuff"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.WaitReply(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
等待回复
|
||||
</summary>
|
||||
<param name="isReply">是否回复标志位</param>
|
||||
<param name="TimeOut">超时时间</param>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.PauseWait(System.Int64)">
|
||||
<summary>
|
||||
延时N秒
|
||||
</summary>
|
||||
<param name="HowLong">延时时间值</param>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetAddressToBytes(System.String)">
|
||||
<summary>
|
||||
IP地址转换为Byte数组
|
||||
</summary>
|
||||
<param name="addr"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetStringMd5(System.String)">
|
||||
<summary>
|
||||
获取字符串的MD5值
|
||||
</summary>
|
||||
<param name="str">需要求MD5的原文字符串</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetBlocks(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
分块函数
|
||||
计算Byte数组的块数
|
||||
</summary>
|
||||
<param name="databuff"></param>
|
||||
<param name="size"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetStringToDataByte(System.String)">
|
||||
<summary>
|
||||
字符串转换Byte数组
|
||||
字符串为连续且不包含任意字符的字符串
|
||||
</summary>
|
||||
<param name="str"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.FromUnixTime(System.Int64,System.Int64)">
|
||||
<summary>
|
||||
把UNIX时间戳转换为标准时间
|
||||
</summary>
|
||||
<param name="intTime">要转换的UNIX时间戳</param>
|
||||
<param name="ime">时区</param>
|
||||
<returns>intTime所代表的标准时间</returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.SumAndMod(System.Byte[])">
|
||||
<summary>
|
||||
和校验取余数
|
||||
求Byte数组的和校验取余数
|
||||
</summary>
|
||||
<param name="dataPacket">Byte数组</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DataProcessing.GetEnumDescription(System.Enum)">
|
||||
<summary>
|
||||
获取枚举描述特性
|
||||
</summary>
|
||||
<param name="enumValue">需要获取特性的枚举值</param>
|
||||
<returns>枚举描述特性</returns>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.DevNetworkCommunication._fixedHead">
|
||||
<summary>
|
||||
透传数据包头
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.DevNetworkCommunication._fixeSystemId">
|
||||
<summary>
|
||||
透传数据固定ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.DevNetworkCommunication._fixeRoomInfo">
|
||||
<summary>
|
||||
透传数据房间信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.DevNetworkCommunication._receiveThread">
|
||||
<summary>
|
||||
UDP通讯接收线程
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.UdpRecviveData">
|
||||
<summary>
|
||||
UDP接收数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.ReceivingDataProcessing(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
接收数据处理
|
||||
</summary>
|
||||
<param name="recvBuffer"></param>
|
||||
<param name="recvLength"></param>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.CheckCRC16Sucess(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
检验CRC16成功
|
||||
</summary>
|
||||
<param name="dataBuff"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.DealData(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
处理数据
|
||||
</summary>
|
||||
<param name="dataBuff"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.GetCRC16CheckSum(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
获取CRC16校验和
|
||||
</summary>
|
||||
<param name="dataBuff">数据</param>
|
||||
<param name="length">数据长度</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:_485_BurningTool.DevNetworkCommunication.SetTransmitterParameter(System.Object[])">
|
||||
<summary>
|
||||
本地ip/本地端口/目标ip/目标端口
|
||||
</summary>
|
||||
<param name="params"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialController._recvOffset">
|
||||
接收数据偏移量
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialController._recvstar">
|
||||
接收数据偏移量
|
||||
</member>
|
||||
<member name="F:_485_BurningTool.SerialController._recvBuffer">
|
||||
<summary>
|
||||
接收数据缓存包
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
BIN
obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
BIN
obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
Binary file not shown.
BIN
obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
BIN
obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
Binary file not shown.
BIN
obj/Debug/TempPE/My Project.Resources.Designer.vb.dll
Normal file
BIN
obj/Debug/TempPE/My Project.Resources.Designer.vb.dll
Normal file
Binary file not shown.
BIN
obj/Debug/_485_BurningTool.Form1.resources
Normal file
BIN
obj/Debug/_485_BurningTool.Form1.resources
Normal file
Binary file not shown.
BIN
obj/Debug/_485_BurningTool.Resources.resources
Normal file
BIN
obj/Debug/_485_BurningTool.Resources.resources
Normal file
Binary file not shown.
4
packages.config
Normal file
4
packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||
</packages>
|
||||
BIN
packages/Newtonsoft.Json.13.0.3/.signature.p7s
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/.signature.p7s
vendored
Normal file
Binary file not shown.
20
packages/Newtonsoft.Json.13.0.3/LICENSE.md
vendored
Normal file
20
packages/Newtonsoft.Json.13.0.3/LICENSE.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
BIN
packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg
vendored
Normal file
Binary file not shown.
71
packages/Newtonsoft.Json.13.0.3/README.md
vendored
Normal file
71
packages/Newtonsoft.Json.13.0.3/README.md
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
#  Json.NET
|
||||
|
||||
[](https://www.nuget.org/packages/Newtonsoft.Json/)
|
||||
[](https://dev.azure.com/jamesnk/Public/_build/latest?definitionId=8)
|
||||
|
||||
Json.NET is a popular high-performance JSON framework for .NET
|
||||
|
||||
## Serialize JSON
|
||||
|
||||
```csharp
|
||||
Product product = new Product();
|
||||
product.Name = "Apple";
|
||||
product.Expiry = new DateTime(2008, 12, 28);
|
||||
product.Sizes = new string[] { "Small" };
|
||||
|
||||
string json = JsonConvert.SerializeObject(product);
|
||||
// {
|
||||
// "Name": "Apple",
|
||||
// "Expiry": "2008-12-28T00:00:00",
|
||||
// "Sizes": [
|
||||
// "Small"
|
||||
// ]
|
||||
// }
|
||||
```
|
||||
|
||||
## Deserialize JSON
|
||||
|
||||
```csharp
|
||||
string json = @"{
|
||||
'Name': 'Bad Boys',
|
||||
'ReleaseDate': '1995-4-7T00:00:00',
|
||||
'Genres': [
|
||||
'Action',
|
||||
'Comedy'
|
||||
]
|
||||
}";
|
||||
|
||||
Movie m = JsonConvert.DeserializeObject<Movie>(json);
|
||||
|
||||
string name = m.Name;
|
||||
// Bad Boys
|
||||
```
|
||||
|
||||
## LINQ to JSON
|
||||
|
||||
```csharp
|
||||
JArray array = new JArray();
|
||||
array.Add("Manual text");
|
||||
array.Add(new DateTime(2000, 5, 23));
|
||||
|
||||
JObject o = new JObject();
|
||||
o["MyArray"] = array;
|
||||
|
||||
string json = o.ToString();
|
||||
// {
|
||||
// "MyArray": [
|
||||
// "Manual text",
|
||||
// "2000-05-23T00:00:00"
|
||||
// ]
|
||||
// }
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Homepage](https://www.newtonsoft.com/json)
|
||||
- [Documentation](https://www.newtonsoft.com/json/help)
|
||||
- [NuGet Package](https://www.nuget.org/packages/Newtonsoft.Json)
|
||||
- [Release Notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
|
||||
- [Contributing Guidelines](https://github.com/JamesNK/Newtonsoft.Json/blob/master/CONTRIBUTING.md)
|
||||
- [License](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md)
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/json.net)
|
||||
BIN
packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10393
packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
10393
packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9541
packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
9541
packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9741
packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9741
packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11363
packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
11363
packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11325
packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.xml
vendored
Normal file
11325
packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11051
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
11051
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11173
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
11173
packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11338
packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
11338
packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.13.0.3/packageIcon.png
vendored
Normal file
BIN
packages/Newtonsoft.Json.13.0.3/packageIcon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
Reference in New Issue
Block a user