2377 lines
72 KiB
VB.net
2377 lines
72 KiB
VB.net
|
|
Public Class FrmRFFunction
|
|||
|
|
Implements IModuleForm
|
|||
|
|
|
|||
|
|
#Region "窗体"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 窗体加载
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub FrmRFWiFiFunction_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|||
|
|
InitPage()
|
|||
|
|
|
|||
|
|
'RF设备列表
|
|||
|
|
InitRFConfigInfo()
|
|||
|
|
|
|||
|
|
'插卡取电
|
|||
|
|
InitInsertCalorie()
|
|||
|
|
|
|||
|
|
'开关面板
|
|||
|
|
InitTime()
|
|||
|
|
|
|||
|
|
'无线温控
|
|||
|
|
InitTempControl()
|
|||
|
|
|
|||
|
|
'微信锁
|
|||
|
|
IsSet()
|
|||
|
|
InitInfoWeChat()
|
|||
|
|
|
|||
|
|
TextBox1.Text = My.Settings.CurtainsCMD
|
|||
|
|
TxtCurtainData.Text = My.Settings.CurtainsData
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 显示窗体接口
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="parentControl"></param>
|
|||
|
|
Public Sub ShowForm(parentControl As Control) Implements IModuleForm.ShowForm
|
|||
|
|
FormBorderStyle = FormBorderStyle.None '无边框
|
|||
|
|
TopLevel = False
|
|||
|
|
Dock = DockStyle.Fill '填满大小
|
|||
|
|
Parent = parentControl '父容器
|
|||
|
|
|
|||
|
|
Show()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 发送函数
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sendPacket"></param>
|
|||
|
|
Public Sub SendData(sendPacket() As Byte)
|
|||
|
|
'FrmRCU.SendData(sendPacket) '方法1
|
|||
|
|
|
|||
|
|
If InvokeRequired Then
|
|||
|
|
Invoke(New Action(Sub()
|
|||
|
|
FrmRCU.SendData(sendPacket)
|
|||
|
|
End Sub))
|
|||
|
|
Else
|
|||
|
|
FrmRCU.SendData(sendPacket)
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "RF无线功能配置"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' RF网关
|
|||
|
|
''' </summary>
|
|||
|
|
Enum RFGateway
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 485网关地址
|
|||
|
|
''' </summary>
|
|||
|
|
Address485
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
DevType
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备地址
|
|||
|
|
''' </summary>
|
|||
|
|
DevAddress
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 和校验
|
|||
|
|
''' </summary>
|
|||
|
|
CheckSum
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 数据包长
|
|||
|
|
''' </summary>
|
|||
|
|
Len
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 命令字
|
|||
|
|
''' </summary>
|
|||
|
|
Cmd
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 数据内容
|
|||
|
|
''' </summary>
|
|||
|
|
Databuff
|
|||
|
|
|
|||
|
|
End Enum
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' RF设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
Enum RFDevType
|
|||
|
|
|
|||
|
|
插卡取电 = &H5
|
|||
|
|
|
|||
|
|
开关面板 = &H7
|
|||
|
|
|
|||
|
|
无线语音 = &H8
|
|||
|
|
|
|||
|
|
无线温控 = &H9
|
|||
|
|
|
|||
|
|
微信锁 = &HA
|
|||
|
|
|
|||
|
|
电动窗帘 = &HB
|
|||
|
|
|
|||
|
|
End Enum
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 检查通信连接
|
|||
|
|
''' </summary>
|
|||
|
|
Public Function CheckConn()
|
|||
|
|
If CheckNetWorkConn() = False OrElse CheckSerialPortConn() = False Then Return False
|
|||
|
|
|
|||
|
|
Return True
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "初始化设备列表信息"
|
|||
|
|
|
|||
|
|
|
|||
|
|
Enum DevColName
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备名称
|
|||
|
|
''' </summary>
|
|||
|
|
DevName = 1
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
DevType = 2
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备地址
|
|||
|
|
''' </summary>
|
|||
|
|
DevAddr = 3
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备状态
|
|||
|
|
''' </summary>
|
|||
|
|
DevState = 4
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 控制计数
|
|||
|
|
''' </summary>
|
|||
|
|
ControlCount = 5
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 控制信息
|
|||
|
|
''' </summary>
|
|||
|
|
ControlInfo = 6
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备测试
|
|||
|
|
''' </summary>
|
|||
|
|
DevTest = 7
|
|||
|
|
|
|||
|
|
End Enum
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub InitRFConfigInfo()
|
|||
|
|
GrdRFcfg.DisplayRowNumber = True
|
|||
|
|
GrdRFcfg.ExtendLastCol = True
|
|||
|
|
GrdRFcfg.Cols = DevColName.DevTest + 1 '设置表格界限
|
|||
|
|
GrdRFcfg.Rows = 1
|
|||
|
|
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.DevName)
|
|||
|
|
.Text = "设备名称"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.DevType)
|
|||
|
|
.Text = "设备类型"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.DevAddr)
|
|||
|
|
.Text = "设备地址"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.DevState)
|
|||
|
|
.Text = "设备状态"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.ControlCount)
|
|||
|
|
.Text = "计数"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.ControlInfo)
|
|||
|
|
.Text = "操作信息"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
With GrdRFcfg.Cell(0, DevColName.DevTest)
|
|||
|
|
.Text = "测试成功率"
|
|||
|
|
.BackColor = Color.LightGray
|
|||
|
|
.ForeColor = Color.Blue
|
|||
|
|
.Font = New Font("Arial", 8, FontStyle.Bold)
|
|||
|
|
End With
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.DevName).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.DevName).Width = 80
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.DevType).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.DevType).Width = 80
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.DevAddr).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.DevAddr).Width = 80
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.DevState).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.DevState).Width = 80
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.ControlCount).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.ControlCount).Width = 40
|
|||
|
|
|
|||
|
|
GrdRFcfg.Column(DevColName.DevTest).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
|||
|
|
GrdRFcfg.Column(DevColName.DevTest).Width = 100
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "RF网关组包"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 填充RF网关包
|
|||
|
|
''' </summary>
|
|||
|
|
Private Function FillRFGatewayPackage(address485 As Byte, devType As Byte, devAddress As Byte, cmd As Byte) As Byte()
|
|||
|
|
Dim packetData(5) As Byte
|
|||
|
|
packetData(RFGateway.Address485) = address485
|
|||
|
|
packetData(RFGateway.DevType) = devType
|
|||
|
|
packetData(RFGateway.DevAddress) = devAddress
|
|||
|
|
packetData(RFGateway.Len) = &H0
|
|||
|
|
packetData(RFGateway.Cmd) = cmd
|
|||
|
|
|
|||
|
|
packetData(RFGateway.CheckSum) = GetSumCheckMod(packetData)
|
|||
|
|
|
|||
|
|
Return packetData
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 填充RF网关包
|
|||
|
|
''' </summary>
|
|||
|
|
Private Function FillRFGatewayDataPackage(address485 As Byte, devType As Byte, devAddress As Byte, cmd As Byte, databuff() As Byte) As Byte()
|
|||
|
|
Dim packetData(6 + databuff.Length - 1) As Byte
|
|||
|
|
packetData(RFGateway.Address485) = address485
|
|||
|
|
packetData(RFGateway.DevType) = devType
|
|||
|
|
packetData(RFGateway.DevAddress) = devAddress
|
|||
|
|
packetData(RFGateway.Len) = $"&H{Hex(databuff.Length)}"
|
|||
|
|
packetData(RFGateway.Cmd) = cmd
|
|||
|
|
|
|||
|
|
Array.Copy(databuff, 0, packetData, RFGateway.Databuff, databuff.Length)
|
|||
|
|
|
|||
|
|
packetData(RFGateway.CheckSum) = GetSumCheckMod(packetData)
|
|||
|
|
|
|||
|
|
Return packetData
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "RF设备配对"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备列表设备总数
|
|||
|
|
''' </summary>
|
|||
|
|
Public _devCount As Integer = 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置RF配对
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnPairing_Click(sender As Object, e As EventArgs) Handles BtnPairing.Click
|
|||
|
|
'If CheckConn() = False Then Exit Sub
|
|||
|
|
PairingBtnChange()
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = &H0
|
|||
|
|
Dim devAddress As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim cmd As Byte = &H9
|
|||
|
|
Dim databuff() As Byte = PairingData()
|
|||
|
|
Console.WriteLine($"配对指令:{ByteToString(databuff)}")
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket) '发送
|
|||
|
|
Console.WriteLine($"设置RF配对数据:{ByteToString(sendPacket)}")
|
|||
|
|
|
|||
|
|
Timer1.Interval = 2000 * 60
|
|||
|
|
Timer1.Start()
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 配对按键变化
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub PairingBtnChange()
|
|||
|
|
If BtnPairing.Text = $"进入配对" Then
|
|||
|
|
BtnPairing.Text = $"退出配对"
|
|||
|
|
BtnPairing.ForeColor = Color.Red
|
|||
|
|
_pairingModel = True
|
|||
|
|
BtnReadRFDevList.Enabled = False
|
|||
|
|
ElseIf BtnPairing.Text = $"退出配对" Then
|
|||
|
|
BtnPairing.Text = $"进入配对"
|
|||
|
|
BtnPairing.ForeColor = Color.Green
|
|||
|
|
_pairingModel = False
|
|||
|
|
BtnReadRFDevList.Enabled = True
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 配对数据内容
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function PairingData()
|
|||
|
|
Dim databuff(0) As Byte
|
|||
|
|
|
|||
|
|
If BtnPairing.Text = $"进入配对" Then
|
|||
|
|
databuff(0) = &H2
|
|||
|
|
AppendTipText($"退出配对{vbCrLf}", Color.Green)
|
|||
|
|
ElseIf BtnPairing.Text = $"退出配对" Then
|
|||
|
|
AppendTipText($"进入配对......{vbCrLf}", Color.Green)
|
|||
|
|
databuff(0) = &H1
|
|||
|
|
Timer1.Stop()
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return databuff
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 定时检测,若在配对状态,则两分钟继续保持
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
'If CheckConn() = False Then Exit Sub
|
|||
|
|
If BtnPairing.Text = $"退出配对" Then
|
|||
|
|
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
|
|||
|
|
'Dim devType As Byte = $"&H{Hex(NupDevType.Value)}"
|
|||
|
|
'Dim devAddress As Byte = $"&H{Hex(NupDevAddress.Value)}"
|
|||
|
|
Dim devType As Byte = &H0
|
|||
|
|
Dim devAddress As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H9
|
|||
|
|
Dim databuff(0) As Byte
|
|||
|
|
databuff(0) = &H3
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
AppendTipText($"保持配对......{vbCrLf}", Color.Green)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket) '发送
|
|||
|
|
'Console.WriteLine($"设置保持连接数据:{sendPacket}")
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取RF网络地址
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnReadRFWifi_Click(sender As Object, e As EventArgs) Handles BtnReadRFWifi.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = &H0
|
|||
|
|
Dim devAddress As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H3
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayPackage(address485, devType, devAddress, cmd)
|
|||
|
|
AppendTipText($"开始读取RF网络状态......{vbCrLf}", Color.Green)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取RF设备网络委托
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data"></param>
|
|||
|
|
Delegate Sub delegate_ReadRFWifi_Change(data As Byte)
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取RF设备网络
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data"></param>
|
|||
|
|
Public Sub ReadRFWifi(data As Byte)
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_ReadRFWifi_Change(AddressOf ReadRFWifi)
|
|||
|
|
Me.Invoke(dev, New Object() {data})
|
|||
|
|
Else
|
|||
|
|
TboNetworkAddress.Text = $"{data}"
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置RF网络地址
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetRFWifi_Click(sender As Object, e As EventArgs) Handles BtnSetRFWifi.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = &H0
|
|||
|
|
Dim devAddress As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H7
|
|||
|
|
Dim databuff(0) As Byte
|
|||
|
|
If TboNetworkAddress.Text = Nothing Then
|
|||
|
|
MsgBox($"需要设置的网络地址不能为空!")
|
|||
|
|
Exit Sub
|
|||
|
|
End If
|
|||
|
|
databuff(0) = $"&H{Hex(TboNetworkAddress.Text)}"
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
Console.WriteLine($"设置网络{ByteToString(sendPacket)}")
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取设备列表在线状态
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnReadRFDevList_Click(sender As Object, e As EventArgs) Handles BtnReadRFDevList.Click
|
|||
|
|
ReadRFDevList()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取RF设备列表
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub ReadRFDevList()
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
InitRFConfigInfo()
|
|||
|
|
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = &H0
|
|||
|
|
Dim devAddress As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H5
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayPackage(address485, devType, devAddress, cmd)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 全部刷新设备列表委托
|
|||
|
|
''' </summary>
|
|||
|
|
Delegate Sub delegate_DevList_Change()
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 刷新设备列表信息
|
|||
|
|
''' 全部刷新_委托
|
|||
|
|
''' </summary>
|
|||
|
|
Public Sub RefreshDeviceList()
|
|||
|
|
_devCount = 1
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_DevList_Change(AddressOf RefreshDeviceList)
|
|||
|
|
Me.Invoke(dev, New Object() {})
|
|||
|
|
Else
|
|||
|
|
For Each key As String In _devList.Keys
|
|||
|
|
GrdRFcfg.AddItem("")
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevName).Text = _devList(key).DevName
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevType).Text = _devList(key).DevType
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevAddr).Text = _devList(key).DevAddr
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevState).Text = _devList(key).DevState
|
|||
|
|
'GrdRFcfg.Cell(_devCount, DevColName.ControlCount).Text = _devList(key).DevControlCount
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.ControlCount).Text = _devList(key).DevControlCount
|
|||
|
|
|
|||
|
|
_devCount += 1
|
|||
|
|
Next
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 局部刷新设备列表委托
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devName"></param>
|
|||
|
|
''' <param name="devType"></param>
|
|||
|
|
''' <param name="devAddr"></param>
|
|||
|
|
Delegate Sub delegate_PairingDevList_Change(devName As String, devType As String, devAddr As String)
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 刷新设备列表信息
|
|||
|
|
''' 局部刷新_委托
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devName"></param>
|
|||
|
|
''' <param name="devType"></param>
|
|||
|
|
''' <param name="devAddr"></param>
|
|||
|
|
Public Sub RefreshPairingDeviceList(devName As String, devType As String, devAddr As String)
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_PairingDevList_Change(AddressOf RefreshPairingDeviceList)
|
|||
|
|
Me.Invoke(dev, New Object() {devName, devType, devAddr})
|
|||
|
|
Else
|
|||
|
|
GrdRFcfg.AddItem("")
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevName).Text = devName
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevType).Text = devType
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.DevAddr).Text = devAddr
|
|||
|
|
GrdRFcfg.Cell(_devCount, DevColName.ControlCount).Text = _devList.Item(devName).DevControlCount
|
|||
|
|
|
|||
|
|
_devCount += 1
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 局部刷新设备列表控制委托
|
|||
|
|
''' </summary>
|
|||
|
|
Delegate Sub delegate_ControlDevList_Change(devType As String, devAddr As String)
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 刷新设备列表控制信息
|
|||
|
|
''' 局部刷新_委托
|
|||
|
|
''' </summary>
|
|||
|
|
Public Sub RefreshDevListControl(devType As String, devAddr As String)
|
|||
|
|
Dim valveTxt As String
|
|||
|
|
Dim TxtInfo() As String
|
|||
|
|
Dim temp() As String
|
|||
|
|
Dim tempTxt As String
|
|||
|
|
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_ControlDevList_Change(AddressOf RefreshDevListControl)
|
|||
|
|
Me.Invoke(dev, New Object() {devType, devAddr})
|
|||
|
|
Else
|
|||
|
|
Dim devName As String = DeviceListInfo.GetDevName(devType, devAddr)
|
|||
|
|
Try
|
|||
|
|
For row As Integer = 1 To GrdRFcfg.Rows - 1
|
|||
|
|
If GrdRFcfg.Cell(row, DevColName.DevType).Text = devType And GrdRFcfg.Cell(row, DevColName.DevAddr).Text = devAddr Then
|
|||
|
|
GrdRFcfg.Cell(row, DevColName.ControlCount).Text = _devList(devName).DevControlCount.ToString
|
|||
|
|
GrdRFcfg.Cell(row, DevColName.ControlInfo).Text = _devList.Item(devName).DevControlInfo
|
|||
|
|
|
|||
|
|
'开关控制阀门信息
|
|||
|
|
If GrdRFcfg.Cell(row, DevColName.DevType).Text = "无线温控" Then
|
|||
|
|
valveTxt = _devList.Item(devName).DevControlInfo
|
|||
|
|
'Console.WriteLine($"原始数据:{valveTxt}")
|
|||
|
|
TxtInfo = valveTxt.Split(",")
|
|||
|
|
'Console.WriteLine($"切割数据:{TxtInfo(2)}")
|
|||
|
|
BtnTempControlValve.Text = TxtInfo(2) '阀门开关
|
|||
|
|
|
|||
|
|
tempTxt = TxtInfo(1)
|
|||
|
|
temp = tempTxt.Split(":")
|
|||
|
|
LblTempControlValue.Text = temp(1)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Exit For
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
_devList(devName).DevControlCount += 1
|
|||
|
|
Next
|
|||
|
|
Catch ex As Exception
|
|||
|
|
Console.WriteLine($"上报数据:{ex.Message}")
|
|||
|
|
End Try
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 清空设备列表
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnClearList_Click(sender As Object, e As EventArgs) Handles BtnClearList.Click
|
|||
|
|
_devList.Clear()
|
|||
|
|
'ReadRFDevList()
|
|||
|
|
InitRFConfigInfo()
|
|||
|
|
TabRFFunction.SelectedIndex = 0
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "窗体功能模块切换"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 全局设备地址
|
|||
|
|
''' 点击后从列表获取
|
|||
|
|
''' </summary>
|
|||
|
|
Private _DevAddress As String
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化功能Page
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitPage()
|
|||
|
|
TabRFFunction.SizeMode = TabSizeMode.Fixed
|
|||
|
|
TabRFFunction.ItemSize = New Size(0, 1)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 点击表格刷新Page控件
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="Sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub GrdRFcfg_Click(Sender As Object, e As EventArgs) Handles GrdRFcfg.Click
|
|||
|
|
|
|||
|
|
If _pairingModel = False Then '配对设备不触发点击事件
|
|||
|
|
If GrdRFcfg.ActiveCell.Row > 0 Then
|
|||
|
|
Select Case GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 2).Text
|
|||
|
|
Case $"插卡取电"
|
|||
|
|
TabRFFunction.SelectedIndex = 1
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case $"开关面板"
|
|||
|
|
TabRFFunction.SelectedIndex = 2
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case $"无线语音"
|
|||
|
|
TabRFFunction.SelectedIndex = 3
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case $"无线温控"
|
|||
|
|
TabRFFunction.SelectedIndex = 4
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case $"微信锁"
|
|||
|
|
TabRFFunction.SelectedIndex = 5
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case $"电动窗帘"
|
|||
|
|
TabRFFunction.SelectedIndex = 6
|
|||
|
|
_DevAddress = GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 3).Text
|
|||
|
|
Case Else
|
|||
|
|
TabRFFunction.SelectedIndex = 0
|
|||
|
|
Console.WriteLine($"当前选择设备为{GrdRFcfg.Cell(GrdRFcfg.ActiveCell.Row, 2).Text}, 未收录此设备类型!")
|
|||
|
|
End Select
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "RF设备"
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "回复信息"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 回复41 00数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="dataBuff"></param>
|
|||
|
|
Public Sub ReplyData(dataBuff As Byte())
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
|
|||
|
|
Dim data(6) As Byte
|
|||
|
|
Dim addr As Byte = dataBuff(0)
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H41
|
|||
|
|
data(0) = addr
|
|||
|
|
data(1) = zero
|
|||
|
|
data(2) = zero
|
|||
|
|
data(3) = zero
|
|||
|
|
data(4) = &H1
|
|||
|
|
data(5) = cmd
|
|||
|
|
data(6) = zero
|
|||
|
|
|
|||
|
|
data(3) = GetSumCheckMod(data)
|
|||
|
|
data = FillPacket(data) '组包
|
|||
|
|
SendData(data) '发送数据
|
|||
|
|
'Console.WriteLine($"回复数据:{ByteToString(data)}")
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "插卡取电 & RF-CR-1808"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置读取扇区标志位
|
|||
|
|
''' </summary>
|
|||
|
|
Private _rfInsertSector() As String = {$"读取", $"设置"}
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化插卡取电信息
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitInsertCalorie()
|
|||
|
|
CboInsertSet.Items.Clear()
|
|||
|
|
CboInsertSet.Items.AddRange(_rfInsertSector)
|
|||
|
|
CboInsertSet.SelectedIndex = 0
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置读取扇区
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnRFInsertCalorie_Click(sender As Object, e As EventArgs) Handles BtnRFInsertCalorie.Click
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.插卡取电
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H19
|
|||
|
|
Dim databuff() As Byte = GetSector()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取扇区值
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetSector()
|
|||
|
|
Dim rfclear(1) As Byte
|
|||
|
|
If CboInsertSet.Text = _rfInsertSector(0) Then
|
|||
|
|
rfclear(0) = &H0
|
|||
|
|
ElseIf CboInsertSet.Text = _rfInsertSector(1) Then
|
|||
|
|
rfclear(0) = &H1
|
|||
|
|
rfclear(1) = $"&H{NudRFSector.Value}"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return rfclear
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 插卡取电回复命令
|
|||
|
|
''' </summary>
|
|||
|
|
Public Sub RFInsertCalorieReplyData()
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.插卡取电
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H18
|
|||
|
|
Dim databuff(0) As Byte
|
|||
|
|
databuff(0) = &H1
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "开关面板 & RF_K9S"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 渐变时间
|
|||
|
|
''' </summary>
|
|||
|
|
Private _GradientTime() As String = {"立即控制", "250ms", "500ms", "1s", "2s", "3s", "4s", "5s"}
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 延时时间
|
|||
|
|
''' </summary>
|
|||
|
|
Private _DelayTime() As String = {"50ms", "100ms", "150ms", "200ms", "250ms"}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化选择时间
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitTime()
|
|||
|
|
'亮灭渐变时间
|
|||
|
|
ComboBox1.Items.Clear()
|
|||
|
|
ComboBox1.Items.AddRange(_GradientTime)
|
|||
|
|
ComboBox1.SelectedIndex = 0
|
|||
|
|
|
|||
|
|
'本地控制延时时间
|
|||
|
|
ComboBox2.Items.Clear()
|
|||
|
|
ComboBox2.Items.AddRange(_DelayTime)
|
|||
|
|
ComboBox2.SelectedIndex = 0
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 控件点击变化
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="btn"></param>
|
|||
|
|
Private Sub BtnChange(btn As Control)
|
|||
|
|
If btn.Text = $"无" Then
|
|||
|
|
btn.Text = $"亮"
|
|||
|
|
btn.ForeColor = Color.Red
|
|||
|
|
ElseIf btn.Text = $"亮" Then
|
|||
|
|
btn.Text = $"灭"
|
|||
|
|
btn.ForeColor = Color.Green
|
|||
|
|
ElseIf btn.Text = $"灭" Then
|
|||
|
|
btn.Text = $"亮"
|
|||
|
|
btn.ForeColor = Color.Red
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 控件状态
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="btn"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function BtnState(btn As Control) As Byte
|
|||
|
|
Dim one As Byte
|
|||
|
|
If btn.Text = $"无" Then
|
|||
|
|
one = &H0
|
|||
|
|
ElseIf btn.Text = $"亮" Then
|
|||
|
|
one = &H1
|
|||
|
|
ElseIf btn.Text = $"灭" Then
|
|||
|
|
one = &H2
|
|||
|
|
End If
|
|||
|
|
Return one
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
'''' <summary>
|
|||
|
|
'''' 设置指示灯
|
|||
|
|
'''' </summary>
|
|||
|
|
'''' <param name="sender"></param>
|
|||
|
|
'''' <param name="e"></param>
|
|||
|
|
'Private Sub BtnSetIndicatorLight_Click(sender As Object, e As EventArgs) Handles BtnSetIndicatorLight.Click
|
|||
|
|
' _port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
' _timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
' Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
' Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
' Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
' Dim cmd As Byte = &H6
|
|||
|
|
' Dim databuff() As Byte = GetSetLight()
|
|||
|
|
|
|||
|
|
' Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
' sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
' SendData(sendPacket)
|
|||
|
|
|
|||
|
|
'End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取设置指示灯的值
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetSetLight() As Byte()
|
|||
|
|
Dim l1 As Byte = BtnState(BtnSwitch1)
|
|||
|
|
Dim l2 As Byte = BtnState(BtnSwitch2)
|
|||
|
|
Dim l3 As Byte = BtnState(BtnSwitch3)
|
|||
|
|
Dim l4 As Byte = BtnState(BtnSwitch4)
|
|||
|
|
Dim l5 As Byte = BtnState(BtnSwitch5)
|
|||
|
|
Dim l6 As Byte = BtnState(BtnSwitch6)
|
|||
|
|
Dim l7 As Byte = BtnState(BtnBacklight)
|
|||
|
|
Dim l8 As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
Dim cmd As Byte = &H23
|
|||
|
|
Dim bit1 As Byte = GetBit(l1, l2, l3, l4)
|
|||
|
|
Dim bit2 As Byte = GetBit(l5, l6, l7, l8)
|
|||
|
|
|
|||
|
|
data.Add(cmd)
|
|||
|
|
data.Add(bit1)
|
|||
|
|
data.Add(bit2)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置指示灯bit
|
|||
|
|
''' 四个Bit的Byte
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="l1"></param>
|
|||
|
|
''' <param name="l2"></param>
|
|||
|
|
''' <param name="l3"></param>
|
|||
|
|
''' <param name="l4"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetBit(l1 As Byte, l2 As Byte, l3 As Byte, l4 As Byte) As Byte
|
|||
|
|
Dim bit As Byte
|
|||
|
|
|
|||
|
|
l4 = l4 << 6
|
|||
|
|
l3 = l3 << 4
|
|||
|
|
l2 = l2 << 2
|
|||
|
|
|
|||
|
|
bit = l4 Or l3 Or l2 Or l1
|
|||
|
|
Console.WriteLine($"设置指示灯值:{bit}")
|
|||
|
|
|
|||
|
|
Return bit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取标志位
|
|||
|
|
''' 八个Bit的Byte
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="b1"></param>
|
|||
|
|
''' <param name="b2"></param>
|
|||
|
|
''' <param name="b3"></param>
|
|||
|
|
''' <param name="b4"></param>
|
|||
|
|
''' <param name="b5"></param>
|
|||
|
|
''' <param name="b6"></param>
|
|||
|
|
''' <param name="b7"></param>
|
|||
|
|
''' <param name="b8"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function BitSign(b1 As Byte, b2 As Byte, b3 As Byte, b4 As Byte, b5 As Byte, b6 As Byte, b7 As Byte, b8 As Byte) As Byte
|
|||
|
|
Dim bit As Byte
|
|||
|
|
b8 = b8 << 7
|
|||
|
|
b7 = b7 << 6
|
|||
|
|
b6 = b6 << 5
|
|||
|
|
b5 = b5 << 4
|
|||
|
|
b4 = b4 << 3
|
|||
|
|
b3 = b3 << 2
|
|||
|
|
b2 = b2 << 1
|
|||
|
|
|
|||
|
|
bit = b8 Or b7 Or b6 Or b5 Or b4 Or b3 Or b2 Or b1
|
|||
|
|
|
|||
|
|
Console.WriteLine($"Bit值:{bit}")
|
|||
|
|
Return bit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置亮灭灯
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetSwitchLights_Click(sender As Object, e As EventArgs) Handles BtnSetSwitchLights.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff() As Byte = GetLightValue()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取亮度值数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetLightValue()
|
|||
|
|
Dim g1 As Byte = &H1
|
|||
|
|
Dim gg As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim cmd As Byte = &H24
|
|||
|
|
Dim bit As Byte = BitSign(g1, gg, gg, gg, gg, gg, gg, gg)
|
|||
|
|
Dim lightvalue As Byte = $"&H{Hex(NumericUpDown1.Value)}"
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
data.Add(cmd)
|
|||
|
|
data.Add(bit)
|
|||
|
|
data.Add(lightvalue)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 选择状态
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="Cbo"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function CheckBoxState(Cbo As CheckBox) As Byte
|
|||
|
|
Dim one As Byte
|
|||
|
|
If Cbo.Checked = False Then
|
|||
|
|
one = &H0
|
|||
|
|
ElseIf Cbo.Checked = True Then
|
|||
|
|
one = &H1
|
|||
|
|
End If
|
|||
|
|
Return one
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置亮灭渐变时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetGradientTime_Click(sender As Object, e As EventArgs) Handles BtnSetGradientTime.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff() As Byte = GetGradientTimeData()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取渐变时间数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetGradientTimeData() As Byte()
|
|||
|
|
Dim g3 As Byte = &H1
|
|||
|
|
Dim gg As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim cmd As Byte = &H24
|
|||
|
|
Dim bit As Byte = BitSign(gg, gg, g3, gg, gg, gg, gg, gg)
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
Dim gtime As Byte = GetGradientTime()
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
data.Add(cmd)
|
|||
|
|
data.Add(bit)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(gtime)
|
|||
|
|
data.Add(zero)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取渐变时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetGradientTime() As Byte
|
|||
|
|
Dim gtime As Byte
|
|||
|
|
|
|||
|
|
Select Case ComboBox1.SelectedIndex
|
|||
|
|
Case 0
|
|||
|
|
gtime = &H0
|
|||
|
|
Case 1
|
|||
|
|
gtime = &H1
|
|||
|
|
Case 2
|
|||
|
|
gtime = &H2
|
|||
|
|
Case 3
|
|||
|
|
gtime = &H3
|
|||
|
|
Case 4
|
|||
|
|
gtime = &H4
|
|||
|
|
Case 5
|
|||
|
|
gtime = &H5
|
|||
|
|
Case 6
|
|||
|
|
gtime = &H6
|
|||
|
|
Case 7
|
|||
|
|
gtime = &H7
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Return gtime
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置本地控制延时时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetDelayTime_Click(sender As Object, e As EventArgs) Handles BtnSetDelayTime.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff() As Byte = GetDelayTimeData()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取本地控制延时时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetDelayTimeData() As Byte()
|
|||
|
|
Dim g4 As Byte = &H1
|
|||
|
|
Dim gg As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim cmd As Byte = &H24
|
|||
|
|
Dim bit As Byte = BitSign(gg, gg, gg, g4, gg, gg, gg, gg)
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
Dim dtime As Byte = GetDelayTime()
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
data.Add(cmd)
|
|||
|
|
data.Add(bit)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(dtime)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取延时时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetDelayTime() As Byte
|
|||
|
|
Dim dtime As Byte
|
|||
|
|
|
|||
|
|
Select Case ComboBox2.SelectedIndex
|
|||
|
|
Case 0
|
|||
|
|
dtime = &H1
|
|||
|
|
Case 1
|
|||
|
|
dtime = &H2
|
|||
|
|
Case 2
|
|||
|
|
dtime = &H3
|
|||
|
|
Case 3
|
|||
|
|
dtime = &H4
|
|||
|
|
Case 4
|
|||
|
|
dtime = &H5
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Return dtime
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 本地控制开关
|
|||
|
|
''' </summary>
|
|||
|
|
Private _switchControl As Boolean = False
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置本地控制开关
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetLocalControl_Click(sender As Object, e As EventArgs) Handles BtnSetLocalControl.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff() As Byte = GetLocalControl()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取本地控制开关数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetLocalControl()
|
|||
|
|
Dim g5 As Byte
|
|||
|
|
If _switchControl = False Then
|
|||
|
|
_switchControl = True
|
|||
|
|
g5 = &H0
|
|||
|
|
ElseIf _switchControl = True Then
|
|||
|
|
_switchControl = False
|
|||
|
|
g5 = &H1
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
Dim cmd As Byte = &H24
|
|||
|
|
Dim bit As Byte = BitSign(zero, zero, zero, zero, g5, zero, zero, zero)
|
|||
|
|
Dim switch As Byte = GetSwitch()
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
data.Add(cmd)
|
|||
|
|
data.Add(bit)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(switch)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取本地控制开关
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetSwitch()
|
|||
|
|
Dim switch As Byte
|
|||
|
|
If BtnSetLocalControl.ForeColor = Color.Green Then
|
|||
|
|
BtnSetLocalControl.ForeColor = Color.Red
|
|||
|
|
switch = &H1
|
|||
|
|
ElseIf BtnSetLocalControl.ForeColor = Color.Red Then
|
|||
|
|
BtnSetLocalControl.ForeColor = Color.Green
|
|||
|
|
switch = &H0
|
|||
|
|
End If
|
|||
|
|
Return switch
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取指示灯信息
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnReadLigthInfo_Click(sender As Object, e As EventArgs) Handles BtnReadLigthInfo.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff(1) As Byte
|
|||
|
|
databuff(0) = &H25
|
|||
|
|
databuff(1) = &H0
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置指示灯
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub SetIndicatorLight()
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H41
|
|||
|
|
Dim databuff() As Byte = GetIndicatorLightData()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取指示灯数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetIndicatorLightData() As Byte()
|
|||
|
|
Dim btn1 As Byte = BtnState(BtnSwitch1)
|
|||
|
|
Dim btn2 As Byte = BtnState(BtnSwitch2)
|
|||
|
|
Dim btn3 As Byte = BtnState(BtnSwitch3)
|
|||
|
|
Dim btn4 As Byte = BtnState(BtnSwitch4)
|
|||
|
|
|
|||
|
|
Dim btn5 As Byte = BtnState(BtnSwitch5)
|
|||
|
|
Dim btn6 As Byte = BtnState(BtnSwitch6)
|
|||
|
|
Dim btn7 As Byte = BtnState(BtnBacklight)
|
|||
|
|
Dim zero As Byte = &H0
|
|||
|
|
|
|||
|
|
Dim light1 As Byte = GetBit(btn1, btn2, btn3, btn4)
|
|||
|
|
Dim light2 As Byte = GetBit(btn5, btn6, btn7, zero)
|
|||
|
|
Dim light3 As Byte = GetBit(zero, zero, zero, zero)
|
|||
|
|
|
|||
|
|
Dim data As New List(Of Byte)
|
|||
|
|
data.Add(zero)
|
|||
|
|
data.Add(light1)
|
|||
|
|
data.Add(light2)
|
|||
|
|
data.Add(light3)
|
|||
|
|
|
|||
|
|
Return data.ToArray
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch1_Click(sender As Object, e As EventArgs) Handles BtnSwitch1.Click
|
|||
|
|
BtnChange(BtnSwitch1)
|
|||
|
|
BtnState(BtnSwitch1)
|
|||
|
|
Console.WriteLine($"按键1:{BtnState(BtnSwitch1)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch2_Click(sender As Object, e As EventArgs) Handles BtnSwitch2.Click
|
|||
|
|
BtnChange(BtnSwitch2)
|
|||
|
|
BtnState(BtnSwitch2)
|
|||
|
|
Console.WriteLine($"按键2:{BtnState(BtnSwitch2)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch3_Click(sender As Object, e As EventArgs) Handles BtnSwitch3.Click
|
|||
|
|
BtnChange(BtnSwitch3)
|
|||
|
|
BtnState(BtnSwitch3)
|
|||
|
|
Console.WriteLine($"按键3:{BtnState(BtnSwitch3)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch4_Click(sender As Object, e As EventArgs) Handles BtnSwitch4.Click
|
|||
|
|
BtnChange(BtnSwitch4)
|
|||
|
|
BtnState(BtnSwitch4)
|
|||
|
|
Console.WriteLine($"按键4:{BtnState(BtnSwitch4)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch5_Click(sender As Object, e As EventArgs) Handles BtnSwitch5.Click
|
|||
|
|
BtnChange(BtnSwitch5)
|
|||
|
|
BtnState(BtnSwitch5)
|
|||
|
|
Console.WriteLine($"按键5:{BtnState(BtnSwitch5)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnSwitch6_Click(sender As Object, e As EventArgs) Handles BtnSwitch6.Click
|
|||
|
|
BtnChange(BtnSwitch6)
|
|||
|
|
BtnState(BtnSwitch6)
|
|||
|
|
Console.WriteLine($"按键6:{BtnState(BtnSwitch6)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub BtnBacklight_Click(sender As Object, e As EventArgs) Handles BtnBacklight.Click
|
|||
|
|
BtnChange(BtnBacklight)
|
|||
|
|
BtnState(BtnBacklight)
|
|||
|
|
Console.WriteLine($"背光灯:{BtnState(BtnBacklight)}")
|
|||
|
|
SetIndicatorLight()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
|
|||
|
|
If CheckBox1.Checked = True Then
|
|||
|
|
Label6.Enabled = False
|
|||
|
|
Label13.Enabled = False
|
|||
|
|
Label14.Enabled = False
|
|||
|
|
NumericUpDown1.Enabled = False
|
|||
|
|
ComboBox1.Enabled = False
|
|||
|
|
ComboBox2.Enabled = False
|
|||
|
|
BtnReadLigthInfo.Enabled = False
|
|||
|
|
BtnSetLocalControl.Enabled = False
|
|||
|
|
BtnSetSwitchLights.Enabled = False
|
|||
|
|
BtnSetGradientTime.Enabled = False
|
|||
|
|
BtnSetDelayTime.Enabled = False
|
|||
|
|
ElseIf CheckBox1.Checked = False Then
|
|||
|
|
Label6.Enabled = True
|
|||
|
|
Label13.Enabled = True
|
|||
|
|
Label14.Enabled = True
|
|||
|
|
NumericUpDown1.Enabled = True
|
|||
|
|
ComboBox1.Enabled = True
|
|||
|
|
ComboBox2.Enabled = True
|
|||
|
|
BtnReadLigthInfo.Enabled = True
|
|||
|
|
BtnSetLocalControl.Enabled = True
|
|||
|
|
BtnSetSwitchLights.Enabled = True
|
|||
|
|
BtnSetGradientTime.Enabled = True
|
|||
|
|
BtnSetDelayTime.Enabled = True
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "无线语音 & RF_VC2006"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 语音模块配置下发
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnForwardingData_Click(sender As Object, e As EventArgs) Handles BtnForwardingData.Click
|
|||
|
|
If String.IsNullOrWhiteSpace(TxtForwardingData.Text) = True Then
|
|||
|
|
MsgBox($"请先输入语音要转发的数据!")
|
|||
|
|
Exit Sub
|
|||
|
|
End If
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.无线语音
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim cmd1 As Byte = &H27
|
|||
|
|
Dim data() As Byte = FrmRCU.CuttingSendData(TxtForwardingData.Text)
|
|||
|
|
Dim databuff As New List(Of Byte)
|
|||
|
|
databuff.Add(cmd1)
|
|||
|
|
databuff.AddRange(data)
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff.ToArray)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "无线温控 & RF_KP_WKA8T"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化无线温控
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitTempControl()
|
|||
|
|
LblTempControlValue.ForeColor = Color.Gold
|
|||
|
|
LblDegree.ForeColor = Color.Gold
|
|||
|
|
|
|||
|
|
BtnTempControlSwitch.ForeColor = Color.Green
|
|||
|
|
BtnTempControlSwitch.Text = $"开"
|
|||
|
|
|
|||
|
|
LblTempControlHigh.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlCentre.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlLow.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlAuto.ForeColor = Color.DimGray
|
|||
|
|
|
|||
|
|
LblTempControlCold.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlHot.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlSupply.ForeColor = Color.DimGray
|
|||
|
|
|
|||
|
|
BtnTempControlAdd.ForeColor = Color.Gray
|
|||
|
|
BtnTempControlMinus.ForeColor = Color.Gray
|
|||
|
|
BtnTempControlVelocity.ForeColor = Color.Gray
|
|||
|
|
BtnTempControlModel.ForeColor = Color.Gray
|
|||
|
|
BtnTempControlValve.ForeColor = Color.Gray
|
|||
|
|
|
|||
|
|
BtnTempControlAdd.Enabled = False
|
|||
|
|
BtnTempControlMinus.Enabled = False
|
|||
|
|
BtnTempControlVelocity.Enabled = False
|
|||
|
|
BtnTempControlModel.Enabled = False
|
|||
|
|
BtnTempControlValve.Enabled = False
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 空调开关控制状态
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub TempControlControlState()
|
|||
|
|
If BtnTempControlSwitch.Text = "开" Then
|
|||
|
|
BtnTempControlSwitch.Text = "关"
|
|||
|
|
BtnTempControlSwitch.ForeColor = Color.Red
|
|||
|
|
BtnTempControlAdd.Enabled = True
|
|||
|
|
BtnTempControlMinus.Enabled = True
|
|||
|
|
BtnTempControlVelocity.Enabled = True
|
|||
|
|
BtnTempControlModel.Enabled = True
|
|||
|
|
|
|||
|
|
BtnTempControlAdd.ForeColor = Color.Green
|
|||
|
|
BtnTempControlMinus.ForeColor = Color.Green
|
|||
|
|
BtnTempControlVelocity.ForeColor = Color.Green
|
|||
|
|
BtnTempControlModel.ForeColor = Color.Green
|
|||
|
|
|
|||
|
|
LblTempControlHigh.ForeColor = Color.Green
|
|||
|
|
LblTempControlCentre.ForeColor = Color.Red
|
|||
|
|
LblTempControlLow.ForeColor = Color.Red
|
|||
|
|
LblTempControlAuto.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
LblTempControlCold.ForeColor = Color.Green
|
|||
|
|
LblTempControlHot.ForeColor = Color.Red
|
|||
|
|
LblTempControlSupply.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
ElseIf BtnTempControlSwitch.Text = "关" Then
|
|||
|
|
BtnTempControlSwitch.Text = "开"
|
|||
|
|
BtnTempControlSwitch.ForeColor = Color.Green
|
|||
|
|
BtnTempControlAdd.Enabled = False
|
|||
|
|
BtnTempControlMinus.Enabled = False
|
|||
|
|
BtnTempControlVelocity.Enabled = False
|
|||
|
|
BtnTempControlModel.Enabled = False
|
|||
|
|
|
|||
|
|
LblTempControlHigh.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlCentre.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlLow.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlAuto.ForeColor = Color.DimGray
|
|||
|
|
|
|||
|
|
LblTempControlCold.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlHot.ForeColor = Color.DimGray
|
|||
|
|
LblTempControlSupply.ForeColor = Color.DimGray
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控风速切换
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub TempControlVelocity()
|
|||
|
|
|
|||
|
|
If LblTempControlHigh.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlHigh.ForeColor = Color.Red
|
|||
|
|
LblTempControlCentre.ForeColor = Color.Green
|
|||
|
|
LblTempControlLow.ForeColor = Color.Red
|
|||
|
|
LblTempControlAuto.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
ElseIf LblTempControlCentre.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlHigh.ForeColor = Color.Red
|
|||
|
|
LblTempControlCentre.ForeColor = Color.Red
|
|||
|
|
LblTempControlLow.ForeColor = Color.Green
|
|||
|
|
LblTempControlAuto.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
ElseIf LblTempControlLow.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlHigh.ForeColor = Color.Red
|
|||
|
|
LblTempControlCentre.ForeColor = Color.Red
|
|||
|
|
LblTempControlLow.ForeColor = Color.Red
|
|||
|
|
LblTempControlAuto.ForeColor = Color.Green
|
|||
|
|
|
|||
|
|
ElseIf LblTempControlAuto.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlHigh.ForeColor = Color.Green
|
|||
|
|
LblTempControlCentre.ForeColor = Color.Red
|
|||
|
|
LblTempControlLow.ForeColor = Color.Red
|
|||
|
|
LblTempControlAuto.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控模式切换
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub TempControlModel()
|
|||
|
|
If LblTempControlCold.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlCold.ForeColor = Color.Red
|
|||
|
|
LblTempControlHot.ForeColor = Color.Green
|
|||
|
|
LblTempControlSupply.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
ElseIf LblTempControlHot.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlCold.ForeColor = Color.Red
|
|||
|
|
LblTempControlHot.ForeColor = Color.Red
|
|||
|
|
LblTempControlSupply.ForeColor = Color.Green
|
|||
|
|
|
|||
|
|
ElseIf LblTempControlSupply.ForeColor = Color.Green Then
|
|||
|
|
LblTempControlCold.ForeColor = Color.Green
|
|||
|
|
LblTempControlHot.ForeColor = Color.Red
|
|||
|
|
LblTempControlSupply.ForeColor = Color.Red
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub TempControl()
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.无线温控
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H41
|
|||
|
|
Dim databuff() As Byte = TempControlDataBit()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取温控数据位
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function TempControlDataBit() As Byte()
|
|||
|
|
Dim dataL As Byte = $"&H{Hex(LblTempControlValue.Text)}"
|
|||
|
|
Dim dataH As Byte = DataHighBit()
|
|||
|
|
|
|||
|
|
Dim databuff(2) As Byte
|
|||
|
|
databuff(0) = &H0
|
|||
|
|
databuff(1) = dataL
|
|||
|
|
databuff(2) = dataH
|
|||
|
|
|
|||
|
|
Return databuff
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 温控数据高位Bit
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function DataHighBit()
|
|||
|
|
Dim valveBit As Byte = ValveData()
|
|||
|
|
Dim velocityBit As Byte = VelocityData()
|
|||
|
|
Dim modelBit As Byte = ModelData()
|
|||
|
|
Dim switchBit As Byte = SwitchData()
|
|||
|
|
|
|||
|
|
Dim dataH As Byte = GetBit(valveBit, velocityBit, modelBit, switchBit)
|
|||
|
|
|
|||
|
|
Return dataH
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取阀门开关
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function ValveData()
|
|||
|
|
Dim valvesBit As Byte
|
|||
|
|
If BtnTempControlValve.Text = $"关阀" Then
|
|||
|
|
valvesBit = &H2
|
|||
|
|
ElseIf BtnTempControlValve.Text = $"开阀" Then
|
|||
|
|
valvesBit = &H1
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return valvesBit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取风速数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function VelocityData()
|
|||
|
|
Dim velocityBit As Byte
|
|||
|
|
If LblTempControlHigh.ForeColor = Color.Green Then
|
|||
|
|
velocityBit = &H3
|
|||
|
|
ElseIf LblTempControlCentre.ForeColor = Color.Green Then
|
|||
|
|
velocityBit = &H2
|
|||
|
|
ElseIf LblTempControlLow.ForeColor = Color.Green Then
|
|||
|
|
velocityBit = &H1
|
|||
|
|
ElseIf LblTempControlAuto.ForeColor = Color.Green Then
|
|||
|
|
velocityBit = &H0
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return velocityBit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取模式数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function ModelData()
|
|||
|
|
Dim modelBit As Byte
|
|||
|
|
If LblTempControlCold.ForeColor = Color.Green Then
|
|||
|
|
modelBit = &H1
|
|||
|
|
ElseIf LblTempControlHot.ForeColor = Color.Green Then
|
|||
|
|
modelBit = &H2
|
|||
|
|
ElseIf LblTempControlSupply.ForeColor = Color.Green Then
|
|||
|
|
modelBit = &H3
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return modelBit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取开关数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function SwitchData()
|
|||
|
|
Dim switchBit As Byte
|
|||
|
|
If BtnTempControlSwitch.Text = $"关" Then
|
|||
|
|
switchBit = &H1
|
|||
|
|
ElseIf BtnTempControlSwitch.Text = $"开" Then
|
|||
|
|
switchBit = &H2
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Return switchBit
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控加温度
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlAdd_Click(sender As Object, e As EventArgs) Handles BtnTempControlAdd.Click
|
|||
|
|
If LblTempControlValue.Text >= "16" AndAlso LblTempControlValue.Text <= "32" Then
|
|||
|
|
LblTempControlValue.Text = CStr(CInt(LblTempControlValue.Text) + 1)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
TempControl()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控减温度
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlMinus_Click(sender As Object, e As EventArgs) Handles BtnTempControlMinus.Click
|
|||
|
|
If LblTempControlValue.Text >= "16" AndAlso LblTempControlValue.Text <= "32" Then
|
|||
|
|
LblTempControlValue.Text = CStr(CInt(LblTempControlValue.Text) - 1)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
TempControl()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控开关
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlSwitch_Click(sender As Object, e As EventArgs) Handles BtnTempControlSwitch.Click
|
|||
|
|
If BtnTempControlSwitch.Text = "开" Then
|
|||
|
|
TempControlControlState()
|
|||
|
|
TempControl()
|
|||
|
|
ElseIf BtnTempControlSwitch.Text = "关" Then
|
|||
|
|
TempControl()
|
|||
|
|
TempControlControlState()
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控风速
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlVelocity_Click(sender As Object, e As EventArgs) Handles BtnTempControlVelocity.Click
|
|||
|
|
TempControlVelocity()
|
|||
|
|
TempControl()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控模式
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlModel_Click(sender As Object, e As EventArgs) Handles BtnTempControlModel.Click
|
|||
|
|
TempControlModel()
|
|||
|
|
TempControl()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 无线温控阀门
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnTempControlValve_Click(sender As Object, e As EventArgs) Handles BtnTempControlValve.Click
|
|||
|
|
'TempControlValve()
|
|||
|
|
TempControl()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置温差
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnSetTemperatureDiff_Click(sender As Object, e As EventArgs) Handles BtnSetTemperatureDiff.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.无线温控
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff(2) As Byte
|
|||
|
|
databuff(0) = &H29
|
|||
|
|
databuff(1) = &H1
|
|||
|
|
databuff(2) = $"&H{Hex(NudTempDiffValue.Value)}"
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取温控器设置
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnReadThermostatSettings_Click(sender As Object, e As EventArgs) Handles BtnReadThermostatSettings.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.无线温控
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff(1) As Byte
|
|||
|
|
databuff(0) = &H2A
|
|||
|
|
databuff(1) = &H0
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "微信锁 & RF_RL1705"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 是否设置
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub IsSet()
|
|||
|
|
CboIsSet.Checked = True
|
|||
|
|
BtnSetWeChat.Enabled = False
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 是否设置唤醒时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub CboIsSet_CheckedChanged(sender As Object, e As EventArgs) Handles CboIsSet.CheckedChanged
|
|||
|
|
If CboIsSet.Checked = True Then
|
|||
|
|
BtnSetWeChat.Enabled = False
|
|||
|
|
ElseIf CboIsSet.Checked = False Then
|
|||
|
|
BtnSetWeChat.Enabled = True
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设置的唤醒时间
|
|||
|
|
''' </summary>
|
|||
|
|
Private _setTime() As String = {"2s", "4s", "8s", "16s", "32s"}
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub InitInfoWeChat()
|
|||
|
|
CboSetTime.Items.Clear()
|
|||
|
|
CboSetTime.Items.AddRange(_setTime)
|
|||
|
|
CboSetTime.SelectedIndex = 0
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 微信锁设置唤醒时间命令
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnSetWeChat.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.微信锁
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff() As Byte = GetTime()
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取唤醒时间
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetTime() As Byte()
|
|||
|
|
Dim databuff(1) As Byte
|
|||
|
|
databuff(0) = &H30
|
|||
|
|
|
|||
|
|
Select Case CboSetTime.SelectedIndex
|
|||
|
|
Case 0
|
|||
|
|
databuff(1) = &H1
|
|||
|
|
Case 1
|
|||
|
|
databuff(1) = &H2
|
|||
|
|
Case 2
|
|||
|
|
databuff(1) = &H3
|
|||
|
|
Case 3
|
|||
|
|
databuff(1) = &H4
|
|||
|
|
Case 4
|
|||
|
|
databuff(1) = &H5
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Return databuff
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 微信锁开锁控制命令
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnOpenLock_Click(sender As Object, e As EventArgs) Handles BtnOpenLock.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.微信锁
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff(1) As Byte
|
|||
|
|
databuff(0) = &H31
|
|||
|
|
databuff(1) = &H1
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 微信锁状态读取命令
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnReadLockState_Click(sender As Object, e As EventArgs) Handles BtnReadLockState.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.微信锁
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim databuff(1) As Byte
|
|||
|
|
databuff(0) = &H32
|
|||
|
|
databuff(1) = &H1
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "电动窗帘 & RF_EC2012"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 窗帘开启
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCurtainStart_Click(sender As Object, e As EventArgs) Handles BtnCurtainStart.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
BtnCurtainStart.ForeColor = Color.Green
|
|||
|
|
BtnCurtainStop.ForeColor = Color.Black
|
|||
|
|
BtnCurtainClose.ForeColor = Color.Black
|
|||
|
|
|
|||
|
|
Dim data() As Byte = {&H55, &HAA, &HAA, &H55, &H30, &H22, &H2, &HA, &HA, &H0, &H0, &H0, &H1, &H1, &H0, &H1, &H1, &H1, &H0, &H0, &H0, &H0}
|
|||
|
|
CurtainSendData(data)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 窗帘停止
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCurtainStop_Click(sender As Object, e As EventArgs) Handles BtnCurtainStop.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
BtnCurtainStart.ForeColor = Color.Black
|
|||
|
|
BtnCurtainStop.ForeColor = Color.Green
|
|||
|
|
BtnCurtainClose.ForeColor = Color.Black
|
|||
|
|
|
|||
|
|
Dim data() As Byte = {&H55, &HAA, &HAA, &H55, &H31, &H22, &H2, &HA, &HA, &H0, &H0, &H0, &H1, &H2, &H0, &H1, &H1, &H1, &H0, &H0, &H0, &H0}
|
|||
|
|
CurtainSendData(data)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 窗帘关闭
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCurtainClose_Click(sender As Object, e As EventArgs) Handles BtnCurtainClose.Click
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
BtnCurtainStart.ForeColor = Color.Black
|
|||
|
|
BtnCurtainStop.ForeColor = Color.Black
|
|||
|
|
BtnCurtainClose.ForeColor = Color.Green
|
|||
|
|
|
|||
|
|
Dim data() As Byte = {&H55, &HAA, &HAA, &H55, &H2F, &H22, &H2, &HA, &HA, &H0, &H0, &H0, &H1, &H0, &H0, &H1, &H1, &H1, &H0, &H0, &H0, &H0}
|
|||
|
|
CurtainSendData(data)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 电动窗帘转发数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCurtainData_Click(sender As Object, e As EventArgs) Handles BtnCurtainData.Click
|
|||
|
|
If String.IsNullOrWhiteSpace(TxtCurtainData.Text) = True Then
|
|||
|
|
MsgBox($"请先输入电动窗帘要转发的数据!")
|
|||
|
|
Exit Sub
|
|||
|
|
End If
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim data() As Byte = FrmRCU.CuttingSendData(TxtCurtainData.Text)
|
|||
|
|
CurtainSendData(data)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 窗帘发送数据
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub CurtainSendData(data() As Byte)
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devType As Byte = RFDevType.电动窗帘
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim cmd1 As Byte = $"&H{Hex(TextBox1.Text)}"
|
|||
|
|
Dim databuff As New List(Of Byte)
|
|||
|
|
databuff.Add(cmd1)
|
|||
|
|
databuff.AddRange(data)
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, databuff.ToArray)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "设备通讯测试"
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 一键测试
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnAKeyTest_Click(sender As Object, e As EventArgs) Handles BtnAKeyTest.Click
|
|||
|
|
Dim devType As Byte
|
|||
|
|
Dim devAddress As Byte
|
|||
|
|
If GrdRFcfg.Rows > 1 Then
|
|||
|
|
AppendTipText($"开始一键通讯测试信息......{vbCrLf}", Color.Green)
|
|||
|
|
For i = 1 To GrdRFcfg.Rows - 1
|
|||
|
|
devType = GetDevType(GrdRFcfg.Cell(i, DevColName.DevType).Text)
|
|||
|
|
devAddress = $"&H{Hex(GrdRFcfg.Cell(i, DevColName.DevAddr).Text)}"
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim data(0) As Byte
|
|||
|
|
data(0) = &H6
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, data)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
PauseWait(10000)
|
|||
|
|
Next
|
|||
|
|
Else
|
|||
|
|
MsgBox($"请先刷新设备列表!")
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="txt"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetDevType(txt As String) As Byte
|
|||
|
|
Dim devType As Byte
|
|||
|
|
Select Case txt
|
|||
|
|
Case $"插卡取电"
|
|||
|
|
devType = &H5
|
|||
|
|
Case $"开关面板"
|
|||
|
|
devType = &H7
|
|||
|
|
Case $"无线语音"
|
|||
|
|
devType = &H8
|
|||
|
|
Case $"无线温控"
|
|||
|
|
devType = &H9
|
|||
|
|
Case $"微信锁"
|
|||
|
|
devType = &HA
|
|||
|
|
Case $"电动窗帘"
|
|||
|
|
devType = &HB
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Return devType
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试_插卡取电
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestInsertCard_Click(sender As Object, e As EventArgs) Handles BtnCommTestInsertCard.Click
|
|||
|
|
Dim devType As Byte = RFDevType.插卡取电
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试_开关面板
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestSwitch_Click(sender As Object, e As EventArgs) Handles BtnCommTestSwitch.Click
|
|||
|
|
Dim devType As Byte = RFDevType.开关面板
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试_无线语音
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestVoice_Click(sender As Object, e As EventArgs) Handles BtnCommTestVoice.Click
|
|||
|
|
Dim devType As Byte = RFDevType.无线语音
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试_无线温控
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestTemp_Click(sender As Object, e As EventArgs) Handles BtnCommTestTemp.Click
|
|||
|
|
Dim devType As Byte = RFDevType.无线温控
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试_微信锁
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestWeChat_Click(sender As Object, e As EventArgs) Handles BtnCommTestWeChat.Click
|
|||
|
|
Dim devType As Byte = RFDevType.微信锁
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 网关通讯测试_电动窗帘
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub BtnCommTestCurtain_Click(sender As Object, e As EventArgs) Handles BtnCommTestCurtain.Click
|
|||
|
|
Dim devType As Byte = RFDevType.电动窗帘
|
|||
|
|
DevCommTest(devType)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯测试
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devType"></param>
|
|||
|
|
Private Sub DevCommTest(devType As Byte)
|
|||
|
|
_port485 = $"&H{Hex(FrmRCU.NudSerialAppPort.Value)}"
|
|||
|
|
_timeouts = $"&H{Hex(FrmRCU.NudTimeOut3.Value)}"
|
|||
|
|
Dim address485 As Byte = $"&H{Hex(Nup485DialAddr.Value)}"
|
|||
|
|
Dim devAddress As Byte = $"&H{Hex(_DevAddress)}"
|
|||
|
|
Dim cmd As Byte = &H6
|
|||
|
|
Dim data(0) As Byte
|
|||
|
|
data(0) = &H6
|
|||
|
|
|
|||
|
|
Dim sendPacket As Byte() = FillRFGatewayDataPackage(address485, devType, devAddress, cmd, data)
|
|||
|
|
AppendTipText($"开始询问通讯测试信息......{vbCrLf}", Color.Green)
|
|||
|
|
sendPacket = FillPacket(sendPacket) '组包
|
|||
|
|
SendData(sendPacket)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 刷新通讯测试信息
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devType"></param>
|
|||
|
|
''' <param name="devAddr"></param>
|
|||
|
|
''' <param name="TestValue"></param>
|
|||
|
|
Delegate Sub delegate_CommTest_Refresh(devType As String, devAddr As String, TestValue As String)
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 刷新通讯测试信息_委托
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devType"></param>
|
|||
|
|
''' <param name="devAddr"></param>
|
|||
|
|
''' <param name="TestValue"></param>
|
|||
|
|
Public Sub RefreshCommTest(devType As String, devAddr As String, TestValue As String)
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_CommTest_Refresh(AddressOf RefreshCommTest)
|
|||
|
|
Me.Invoke(dev, New Object() {devType, devAddr, TestValue})
|
|||
|
|
Else
|
|||
|
|
Dim devName As String = DeviceListInfo.GetDevName(devType, devAddr)
|
|||
|
|
Dim txtColor As Color = GetCommTestTextColor(TestValue)
|
|||
|
|
Dim txtValue As String = $"{TestValue}%"
|
|||
|
|
|
|||
|
|
Select Case devType
|
|||
|
|
Case $"插卡取电"
|
|||
|
|
LblCommTestInsertCard.ForeColor = txtColor
|
|||
|
|
LblCommTestInsertCard.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case $"开关面板"
|
|||
|
|
LblCommTestSwitch.ForeColor = txtColor
|
|||
|
|
LblCommTestSwitch.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case $"无线语音"
|
|||
|
|
LblCommTestVoice.ForeColor = txtColor
|
|||
|
|
LblCommTestVoice.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case $"无线温控"
|
|||
|
|
LblCommTestTemp.ForeColor = txtColor
|
|||
|
|
LblCommTestTemp.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case $"微信锁"
|
|||
|
|
LblCommTestWeChat.ForeColor = txtColor
|
|||
|
|
LblCommTestWeChat.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case $"电动窗帘"
|
|||
|
|
LblCommTestCurtain.ForeColor = txtColor
|
|||
|
|
LblCommTestCurtain.Text = $"通讯成功率 {TestValue}%"
|
|||
|
|
Case Else
|
|||
|
|
Console.WriteLine($"未知设备:{TestValue} %")
|
|||
|
|
End Select
|
|||
|
|
Try
|
|||
|
|
For row As Integer = 1 To GrdRFcfg.Rows - 1
|
|||
|
|
If GrdRFcfg.Cell(row, DevColName.DevType).Text = devType And GrdRFcfg.Cell(row, DevColName.DevAddr).Text = devAddr Then
|
|||
|
|
GrdRFcfg.Cell(row, DevColName.DevTest).ForeColor = txtColor
|
|||
|
|
GrdRFcfg.Cell(row, DevColName.DevTest).Text = txtValue
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"测试失败!原因:{ex.Message}")
|
|||
|
|
End Try
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取通讯测试文本颜色
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="devName"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetCommTestTextColor(devName As String) As Color
|
|||
|
|
Dim txtColor As Color
|
|||
|
|
If devName >= $"80" Then
|
|||
|
|
txtColor = Color.Green
|
|||
|
|
ElseIf devName >= $"40" And devName < $"80" Then
|
|||
|
|
txtColor = Color.Yellow
|
|||
|
|
ElseIf devName < $"40" Then
|
|||
|
|
txtColor = Color.Red
|
|||
|
|
End If
|
|||
|
|
Return txtColor
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
#Region "添加记录"
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 添加记录
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="recordString"></param>
|
|||
|
|
''' <param name="col"></param>
|
|||
|
|
Private Sub AppendTipText(recordString As String, col As Color)
|
|||
|
|
FrmRCU.AppendTipText(recordString, col)
|
|||
|
|
|
|||
|
|
'If InvokeRequired Then
|
|||
|
|
' Invoke(New Action(Sub()
|
|||
|
|
' FrmRCU.AppendTipText(recordString, col)
|
|||
|
|
' End Sub))
|
|||
|
|
'Else
|
|||
|
|
' FrmRCU.AppendTipText(recordString, col)
|
|||
|
|
'End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub FrmRFFunction_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|||
|
|
My.Settings.CurtainsCMD = TextBox1.Text
|
|||
|
|
My.Settings.CurtainsData = TxtCurtainData.Text
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Class
|