3031 lines
129 KiB
VB.net
3031 lines
129 KiB
VB.net
Imports System.ComponentModel
|
||
Imports FlexCell
|
||
Imports Newtonsoft.Json
|
||
|
||
Public Class AddPeripherals
|
||
|
||
Public Dirpath As String = "C:\Users\Administrator\Desktop\微信临时文件\WeChat Files\wxid_a2psdqznmt8y22\FileStorage\File\2023-07\设备类别\窗帘"
|
||
Public ResulDic As Dictionary(Of String, String)
|
||
Public Resultmodel As DeviceModel
|
||
Public g_Devicemodel As Dictionary(Of String, DeviceModel)
|
||
Public isok As Boolean = False
|
||
Public g_DevType As FromDevType
|
||
'红外
|
||
Public g_Devinfraredrow As Dictionary(Of String, Integer)
|
||
Public g_Devin485fraredrow As Dictionary(Of String, Integer)
|
||
Public g_DevinCURTAINdrow As Dictionary(Of String, Integer)
|
||
Public g_Devintemp As Dictionary(Of String, Integer)
|
||
Public g_DevRELAYrow As Dictionary(Of String, Integer)
|
||
Public g_DevDimming As Dictionary(Of String, Integer)
|
||
Public g_Devservice As Dictionary(Of String, Integer)
|
||
Public g_DevScenenumber As Dictionary(Of String, Integer)
|
||
' Public g_Devservice As Dictionary(Of String, Integer)
|
||
Public g_grd As FlexCell.Grid
|
||
Private _despar As List(Of String)
|
||
Public g_ColumnAnothername As Dictionary(Of String, String)
|
||
Enum FromDevType
|
||
Normal
|
||
Temp
|
||
CURTAIN
|
||
Voice
|
||
FreshAir
|
||
PB_Bus
|
||
DRY_NoCard
|
||
Dev_ColorTemp
|
||
BLEMUSIC
|
||
max
|
||
End Enum
|
||
Enum Tcolname
|
||
<Description("Input sequence number")>
|
||
输入序号 = 0
|
||
<Description("Key alias")>
|
||
按键别名
|
||
<Description("backlight")>
|
||
按键反馈灯
|
||
|
||
max
|
||
End Enum
|
||
Enum Temproweven
|
||
<Description("Infrared forwarding")>
|
||
红外转发 = 1
|
||
<Description("interlock")>
|
||
互锁
|
||
<Description("Cold valve open")>
|
||
冷阈开
|
||
<Description("Cold valve closed")>
|
||
冷阈关
|
||
<Description("Hot valve open")>
|
||
热阈开
|
||
<Description("Hot valve closed")>
|
||
热阈关
|
||
<Description("Low wind speed")>
|
||
风低
|
||
<Description("Medium wind speed")>
|
||
风中
|
||
<Description("High wind speed")>
|
||
风高
|
||
max
|
||
End Enum
|
||
|
||
|
||
Private Sub TextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox2.KeyPress
|
||
'数字0~9所对应的keychar为48~57
|
||
e.Handled = True
|
||
'输入0-9
|
||
If e.KeyChar = vbBack OrElse (Asc(e.KeyChar) >= 47 AndAlso Asc(e.KeyChar) <= 58) Then
|
||
e.Handled = False
|
||
End If
|
||
|
||
End Sub
|
||
|
||
|
||
|
||
Private Sub AddPeripherals_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||
If IsNothing(Resultmodel) Then
|
||
TextBox2.Enabled = False
|
||
TextBox1.Enabled = False
|
||
Resultmodel = Nothing
|
||
'If IO.Directory.Exists(Dirpath) Then
|
||
' Dim dir() As String = IO.Directory.GetDirectories(Dirpath)
|
||
' For Each index In dir
|
||
' index = index.Replace(Dirpath, "").Replace(".", "").Replace("\", "")
|
||
' Cob_DirPath.Items.Add(index)
|
||
' Next
|
||
|
||
'Else
|
||
' Dirpath = "C:\"
|
||
' Dim dir() As String = IO.Directory.GetDirectories(Dirpath)
|
||
' For Each index In dir
|
||
' index = index.Replace(Dirpath, "").Replace(".", "").Replace("/", "")
|
||
' Cob_DirPath.Items.Add(index)
|
||
' Next
|
||
'End If
|
||
Cob_DirPath.Items.Clear()
|
||
Cob_DirPath.Items.AddRange({"Switch", "RelayOrDimming", "Curtain", "Music", "PowerSupply",
|
||
"Rs485", "PLC", "Voice", "Lock", "Other"})
|
||
SplitContainer2.Panel2Collapsed = True
|
||
|
||
Else
|
||
SplitContainer2.Panel2Collapsed = False
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Private Sub Cob_DirPath_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Cob_DirPath.SelectedIndexChanged
|
||
Dim filepath As String = Cob_DirPath.Text & "_"
|
||
If IO.Directory.Exists(Dirpath) Then
|
||
Dim dir() As String = IO.Directory.GetFiles(Dirpath)
|
||
Cob_FilePath.Items.Clear()
|
||
For Each index In dir
|
||
index = index.Replace(Dirpath, "").Replace("\", "")
|
||
Console.WriteLine(index.IndexOf(filepath))
|
||
If index.IndexOf(filepath) = 0 AndAlso index.Contains(".xml") Then
|
||
|
||
Cob_FilePath.Items.Add(index.Substring(filepath.Length))
|
||
End If
|
||
|
||
Next
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Private Sub Cob_FilePath_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Cob_FilePath.SelectedIndexChanged
|
||
'Dim filepath As String = Dirpath & Cob_DirPath.Text & "\" & Cob_FilePath.Text
|
||
Dim filepath As String = $"{Dirpath}\{Cob_DirPath.Text}_{Cob_FilePath.Text}"
|
||
If IO.File.Exists(filepath) Then
|
||
Try
|
||
Resultmodel = FrmMain.LoadModelFromXml(filepath)
|
||
Catch ex As Exception
|
||
MsgBox("Failed to load peripheral device xml! Make sure the xml file is correct!")
|
||
Return
|
||
End Try
|
||
TextBox2.Enabled = True
|
||
TextBox1.Enabled = True
|
||
Label7.Text = $"Device port:{ShowDevicePort(Resultmodel)}"
|
||
Label8.Text = GetDevmodeTypeData(Resultmodel)
|
||
TextBox1.Text = Cob_FilePath.Text.Replace(".xml", "")
|
||
For Each index In Resultmodel.Config
|
||
For Each aindex In index.Attributes
|
||
If aindex.Name.Equals("Dialing address") Then
|
||
Dim rbugf() As String = aindex.DataDefault.Split(" ")
|
||
TextBox2.Text = rbugf(0)
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
|
||
Else
|
||
MsgBox("Failed to load the peripheral device because the device file was not found!!")
|
||
TextBox2.Enabled = False
|
||
TextBox1.Enabled = False
|
||
Return
|
||
End If
|
||
SelectiveDisplay()
|
||
End Sub
|
||
|
||
|
||
|
||
|
||
Public Function GetDevModeAindex(node As DeviceModel, eqstr As String) As String
|
||
Dim result As String = String.Empty
|
||
If Not IsNothing(node) Then
|
||
For Each index In node.Config
|
||
For Each aindex In index.Attributes
|
||
' If aindex.Name.Equals("拨码地址") Then
|
||
If aindex.Name.Equals(eqstr) Then
|
||
result = aindex.Value
|
||
End If
|
||
Next
|
||
Next
|
||
End If
|
||
Return result
|
||
End Function
|
||
Private Sub SetDevModeAindex(node As DeviceModel, eqstr As String, settext As String)
|
||
' Dim result As String = String.Empty
|
||
If Not IsNothing(node) Then
|
||
For Each index In node.Config
|
||
For Each aindex In index.Attributes
|
||
' If aindex.Name.Equals("拨码地址") Then
|
||
If aindex.Name.Equals(eqstr) Then
|
||
aindex.Value = settext
|
||
Exit For
|
||
End If
|
||
Next
|
||
Next
|
||
End If
|
||
End Sub
|
||
Private Function ShowDevicePort(strtype As DeviceModel) As String
|
||
Dim result As String = String.Empty
|
||
Select Case Resultmodel.Desc.DevInterface
|
||
Case "RS485Active"
|
||
result = "485(initiative)2"
|
||
Case "RS485Polling"
|
||
result = "485(polling)1"
|
||
Case "VirtualObject"
|
||
result = "Virtual device"
|
||
Case "PB_BUS_LINE"
|
||
result = "PBequipment"
|
||
Case "PB_LINE_CONTROL"
|
||
result = "Constant Voltage Dimming"
|
||
Case Else
|
||
result = "Unknown equipment"
|
||
End Select
|
||
Return result
|
||
End Function
|
||
Public Sub EditFeedbackLamp(rvdicv As Dictionary(Of String, String), devmodw As DeviceModel)
|
||
Label1.Visible = False
|
||
Label2.Visible = False
|
||
Cob_DirPath.Visible = False
|
||
Cob_FilePath.Visible = False
|
||
Resultmodel = devmodw
|
||
Dim buff() As String = Resultmodel.Name.Split(vbLf)
|
||
If Not IsNothing(Resultmodel) Then
|
||
TextBox2.Enabled = True
|
||
TextBox1.Enabled = True
|
||
TextBox1.Text = buff(2)
|
||
Label7.Text = $"Device port:{ShowDevicePort(Resultmodel)}"
|
||
Label8.Text = GetDevmodeTypeData(Resultmodel)
|
||
|
||
For Each index In Resultmodel.Config
|
||
For Each aindex In index.Attributes
|
||
If aindex.Name.Equals("Dialing address") Then
|
||
TextBox2.Text = aindex.Value
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
|
||
End If
|
||
isok = True
|
||
|
||
g_DevType = DetermineDeviceType()
|
||
ComboBox1.Visible = False
|
||
Label6.Visible = False
|
||
Table_Grid1.Visible = False
|
||
SplitContainer5.Panel2Collapsed = True
|
||
SplitContainer2.Panel2Collapsed = False
|
||
CheckBox1.Visible = False
|
||
CheckBox2.Visible = False
|
||
CheckBox3.Visible = False
|
||
CheckBox4.Visible = False
|
||
CheckBox5.Visible = False
|
||
Label9.Visible = False
|
||
TextBox3.Visible = False
|
||
|
||
FdevPort.Visible = False
|
||
FdevAddr.Visible = False
|
||
FdevPortCom.Visible = False
|
||
FdevPortText.Visible = False
|
||
Fdevtype.Visible = False
|
||
FdevtypeCom.Visible = False
|
||
SplitContainer6.Visible = False
|
||
|
||
|
||
If Not String.IsNullOrEmpty(Resultmodel.Desc.DevDescription) Then
|
||
Dim Rchenk() As String = Resultmodel.Desc.DevDescription.Split(",")
|
||
Dim ischenk As Integer = 0
|
||
For i = 0 To Rchenk.Length - 1
|
||
If i < 4 Then
|
||
ischenk = 0
|
||
Integer.TryParse(Rchenk(i), ischenk)
|
||
Select Case i
|
||
Case 0
|
||
CheckBox1.Checked = ischenk
|
||
Case 1
|
||
CheckBox2.Checked = ischenk
|
||
Case 2
|
||
CheckBox3.Checked = ischenk
|
||
Case 3
|
||
CheckBox5.Checked = ischenk
|
||
'Case 4
|
||
' CheckBox5.Checked = ischenk
|
||
End Select
|
||
|
||
Else
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
|
||
End If
|
||
|
||
Select Case g_DevType
|
||
Case FromDevType.Temp
|
||
|
||
CheckBox1.Visible = True
|
||
CheckBox2.Visible = True
|
||
CheckBox5.Text = "Wind speed mode prompt tone"
|
||
CheckBox5.Visible = True
|
||
SplitContainer4.Panel1Collapsed = True
|
||
SplitContainer4.Panel2Collapsed = False
|
||
Dim val As String = FindAttributeValueUnderModel(Resultmodel, "Device present", "Valveless machine")
|
||
If String.IsNullOrEmpty(val) Then
|
||
CheckBox6.Visible = False
|
||
Else
|
||
CheckBox6.Visible = True
|
||
If val.Equals("1") Then
|
||
CheckBox6.Checked = True
|
||
Else
|
||
CheckBox6.Checked = False
|
||
End If
|
||
End If
|
||
Normal_initTable()
|
||
Normal_SetIDOpenDO(rvdicv)
|
||
Temp_initTable(Resultmodel)
|
||
Temp_SetIDOpenDO()
|
||
Case FromDevType.CURTAIN
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
CURTAIN_initTable(_despar)
|
||
CURTAIN_SetIDOpenDO()
|
||
Case FromDevType.BLEMUSIC
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Label9.Visible = True
|
||
TextBox3.Visible = True
|
||
TextBox3.Enabled = True
|
||
TextBox3.Text = FindAttributeValueUnderModel2(Resultmodel, "Device present", "BleName")
|
||
Normal_initTable()
|
||
Normal_SetIDOpenDO(rvdicv)
|
||
Case FromDevType.Normal
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Normal_initTable()
|
||
Normal_SetIDOpenDO(rvdicv)
|
||
Case FromDevType.Voice
|
||
CheckBox1.Visible = True
|
||
'CheckBox2.Visible = True
|
||
CheckBox5.Text = "Call for a welcome message"
|
||
CheckBox5.Visible = True
|
||
'CheckBox3.Visible = True
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Voice_InitTable()
|
||
Case FromDevType.FreshAir
|
||
CheckBox1.Visible = True
|
||
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Table_Grid1.Visible = True
|
||
FreshAirInitTable(_despar)
|
||
FreshAir_SetIDOpenDO()
|
||
Case FromDevType.PB_Bus
|
||
|
||
FdevPort.Visible = True
|
||
FdevAddr.Visible = True
|
||
FdevPortCom.Visible = True
|
||
FdevPortText.Visible = True
|
||
Fdevtype.Visible = True
|
||
FdevtypeCom.Visible = True
|
||
|
||
|
||
SplitContainer6.Visible = True
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Button2_Click(Nothing, Nothing)
|
||
PB_Bus_initTable()
|
||
Case FromDevType.DRY_NoCard
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
NoCard_initTable()
|
||
Case FromDevType.Dev_ColorTemp
|
||
Table_Grid1.Visible = True
|
||
|
||
Label6.Text = "Display loop"
|
||
Label6.Visible = True
|
||
ComboBox1.Visible = True
|
||
ComboBox1.Items.Clear()
|
||
For i = 1 To Resultmodel.Nodes(0).Nodes.Count
|
||
ComboBox1.Items.Add(i)
|
||
Next
|
||
|
||
SplitContainer4.Panel1Collapsed = False
|
||
SplitContainer4.Panel2Collapsed = True
|
||
SplitContainer5.Panel1Collapsed = False
|
||
ParseDeviceList(g_Devicemodel)
|
||
initGrid()
|
||
Dim cnt As Integer
|
||
If Integer.TryParse(Resultmodel.Desc.DevDescription, cnt) Then
|
||
ComboBox1.Text = cnt
|
||
End If
|
||
Case Else
|
||
SplitContainer2.Panel2Collapsed = True
|
||
End Select
|
||
|
||
End Sub
|
||
|
||
Public Sub PB_Bus_initTable()
|
||
Table_Grid1.NewFile()
|
||
Table_Grid1.Rows = 1
|
||
Table_Grid1.Cols = 5
|
||
Table_Grid1.ExtendLastCol = False
|
||
|
||
|
||
With Table_Grid1
|
||
.Column(0).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(3).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(4).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
' .Column(5).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(0).Width = 50
|
||
.Column(1).Width = 200
|
||
.Column(2).Width = 100
|
||
.Column(3).Width = 100
|
||
.Column(4).Width = 100
|
||
' .Column(5).Width = 50
|
||
|
||
|
||
|
||
' .Column(2).CellType = CellTypeEnum.ComboBox
|
||
.Column(3).CellType = CellTypeEnum.ComboBox
|
||
.Column(4).CellType = CellTypeEnum.ComboBox
|
||
' .Column(5).CellType = CellTypeEnum.ComboBox
|
||
|
||
.Column(2).Locked = True
|
||
.ComboBox(3).Locked = True
|
||
.ComboBox(4).Locked = True
|
||
' .ComboBox(5).Locked = True
|
||
|
||
.Column(0).Locked = True
|
||
.Column(1).Locked = True
|
||
'.Column(5).Locked = True
|
||
.Cell(0, 0).Text = "Input sequence number"
|
||
.Cell(0, 1).Text = "Loop type"
|
||
.Cell(0, 2).Text = "Loop alias"
|
||
.Cell(0, 3).Text = "self check power upper limit"
|
||
.Cell(0, 4).Text = "self check power lower limit"
|
||
'.Cell(0, 5).Text = "备注"
|
||
|
||
End With
|
||
|
||
PB_Bus_AddGrid1RowDragDrop()
|
||
End Sub
|
||
Public Sub PB_Bus_AddGrid1RowDragDrop()
|
||
If Not IsNothing(Resultmodel) Then
|
||
Dim ustr As List(Of String)
|
||
Dim sv As String = String.Empty
|
||
ustr = GetPowerThresholdconfig(Resultmodel, "Parent device type", sv)
|
||
|
||
FdevtypeCom.Items.Clear()
|
||
FdevtypeCom.Items.AddRange(ustr.ToArray)
|
||
FdevtypeCom.Text = sv
|
||
ustr = GetPowerThresholdconfig(Resultmodel, "Parent device address", sv)
|
||
|
||
FdevPortText.Items.Clear()
|
||
FdevPortText.Items.AddRange(ustr.ToArray)
|
||
FdevPortText.Text = sv
|
||
ustr = GetPowerThresholdconfig(Resultmodel, "Parent device port", sv)
|
||
|
||
FdevPortCom.Items.Clear()
|
||
FdevPortCom.Items.AddRange(ustr.ToArray)
|
||
FdevPortCom.Text = sv
|
||
|
||
|
||
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
'添加
|
||
For Each Index In ModuleFre.Nodes
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = Index.LoopAddr
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = Index.DefaultClass
|
||
'If String.IsNullOrEmpty(Index.DefaultAliasName.Trim) Then
|
||
' Index.DefaultAliasName = $"回路{Index.LoopAddr}"
|
||
'End If
|
||
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = Index.DefaultAliasName
|
||
If String.IsNullOrEmpty(Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text.Trim) Then
|
||
Index.DefaultAliasName = $"loop{Index.LoopAddr}"
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = Index.DefaultAliasName
|
||
End If
|
||
|
||
ustr = GetPowerThreshold(Resultmodel, Table_Grid1.Rows - 1, 3)
|
||
Dim scval As String
|
||
If ustr.Count > 0 Then
|
||
'Table_Grid1.Cell(Table_Grid1.Rows - 1, 3).Text = ustr.Item(2)
|
||
scval = JsonConvert.SerializeObject(ustr)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 3).Tag = scval
|
||
Console.WriteLine(scval)
|
||
'Console.WriteLine(ustr.ToString)
|
||
End If
|
||
|
||
ustr = GetPowerThreshold(Resultmodel, Table_Grid1.Rows - 1, 4)
|
||
If ustr.Count > 0 Then
|
||
'Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Text = ustr.Item(2)
|
||
scval = JsonConvert.SerializeObject(ustr)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Tag = JsonConvert.SerializeObject(ustr)
|
||
Console.WriteLine(scval)
|
||
'Console.WriteLine(ustr.ToString)
|
||
End If
|
||
|
||
Next
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
End Sub
|
||
Public Sub NoCard_AddGrid1RowDragDrop()
|
||
If Not IsNothing(Resultmodel) Then
|
||
|
||
For Each ModuleFre In Resultmodel.Config(0).Attributes
|
||
If ModuleFre.Name.Contains("Weak current input") Then
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = ModuleFre.Name
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = ModuleFre.DataDefault
|
||
Dim u As Integer = 0
|
||
Dim d As Integer = 0
|
||
Dim buf() As String = ModuleFre.DataRange.Split(",")
|
||
If buf.Length = 2 Then
|
||
If Integer.TryParse(buf(0), d) AndAlso Integer.TryParse(buf(1), u) Then
|
||
Dim result As List(Of String) = New List(Of String)
|
||
result.Add("")
|
||
For i = d To u
|
||
result.Add(i)
|
||
Next
|
||
If result.Count > 0 Then
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Tag = JsonConvert.SerializeObject(result)
|
||
End If
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Public Function GetPowerThreshold(Resultmodel As DeviceModel, addr As Integer, keysrt As Integer) As List(Of String)
|
||
Dim result As List(Of String) = New List(Of String)
|
||
Dim LoopAddr As String = $"Circuit {Table_Grid1.Cell(addr, 0).Text.Trim} {Table_Grid1.Cell(0, keysrt).Text.Trim}"
|
||
|
||
For Each index In Resultmodel.Config
|
||
If index.Name.Equals("Device present") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals(LoopAddr) Then
|
||
Dim u As Integer = 0
|
||
Dim d As Integer = 0
|
||
Dim buf() As String = node.DataRange.Split(",")
|
||
Table_Grid1.Cell(addr, keysrt).Text = node.DataDefault
|
||
If buf.Length = 2 Then
|
||
If Integer.TryParse(buf(0), d) AndAlso Integer.TryParse(buf(1), u) Then
|
||
For i = d To u
|
||
result.Add(i)
|
||
Next
|
||
|
||
End If
|
||
End If
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
|
||
Return result
|
||
End Function
|
||
|
||
Private Function FindAttributeValueUnderModel(pNode As DeviceModel, groupName As String, attributeName As String) As String
|
||
Dim result As String = String.Empty
|
||
For Each cnode In pNode.Config
|
||
If cnode.Name.Equals(groupName) Then
|
||
For Each ccnode In cnode.Attributes
|
||
If ccnode.Name.Equals(attributeName) Then
|
||
result = ccnode.DataDefault
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
Public Function GetPowerThresholdconfig(Resultmodel As DeviceModel, keysrt As String, ByRef val As String) As List(Of String)
|
||
Dim result As List(Of String) = New List(Of String)
|
||
Dim LoopAddr As String = keysrt
|
||
For Each index In Resultmodel.Config
|
||
If index.Name.Equals("Device present") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals(LoopAddr) Then
|
||
Dim rbugf() As String = node.DataDefault.Split(" ")
|
||
val = rbugf(0)
|
||
Dim buf() As String = node.DataRangeValue.Split(",")
|
||
For Each i In buf
|
||
result.Add(i)
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
Public Sub SetPowerThresholdconfig(Resultmodel As DeviceModel, keysrt As String, val As String)
|
||
|
||
Dim LoopAddr As String = keysrt
|
||
For Each index In Resultmodel.Config
|
||
If index.Name.Equals("Device present") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals(LoopAddr) Then
|
||
node.DataDefault = val
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
|
||
End Sub
|
||
|
||
|
||
|
||
Public Function GetDevmodeTypeData(Tmodel As DeviceModel) As String
|
||
Dim result As String = String.Empty
|
||
For Each index In Tmodel.Nodes
|
||
result = $"{result}{GetAnotherName(index.Name) }{index.DEV_TYPE_DATA.PadLeft(3, "0")},"
|
||
Next
|
||
If result.Length > 0 Then
|
||
result = result.Substring(0, result.Length - 1)
|
||
End If
|
||
Return result
|
||
End Function
|
||
Private Sub CURTAIN_SetIDOpenDO()
|
||
If IsNothing(g_DevRELAYrow) OrElse g_DevRELAYrow.Count > 0 Then
|
||
If Resultmodel.Desc.ProtocolData.Contains("*") Then
|
||
Dim buf() As String = Resultmodel.Desc.ProtocolData.Split(",")
|
||
For i = 0 To buf.Length - 1
|
||
Dim cbuf() As String = buf(i).Split("*")
|
||
Dim skey As String = $"{cbuf(0)}*{cbuf(1)}*{cbuf(2)}"
|
||
|
||
For Each index In g_ColumnAnothername
|
||
If index.Value.Equals(skey) Then
|
||
Table_Grid1.Cell(i + 1, 2).Text = index.Key
|
||
|
||
If cbuf.Length > 3 Then
|
||
Table_Grid1.Cell(i + 1, 3).Text = cbuf(3)
|
||
End If
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
|
||
End If
|
||
End If
|
||
End Sub
|
||
|
||
|
||
|
||
|
||
|
||
Private Function DetermineDeviceType() As FromDevType
|
||
_despar = New List(Of String)
|
||
Dim result As FromDevType = FromDevType.Normal
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
Select Case ModuleFre.Name
|
||
Case "Dev_ColorTemp"
|
||
Return FromDevType.Dev_ColorTemp
|
||
Case "Temp"
|
||
CheckBox4.Visible = True
|
||
Return FromDevType.Temp
|
||
Case "BLEMUSIC"
|
||
|
||
Return FromDevType.BLEMUSIC
|
||
Case "CURTAIN"
|
||
|
||
_despar.Add("Open curtain")
|
||
_despar.Add("Close curtain")
|
||
Return FromDevType.CURTAIN
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
_despar.Add("Low wind speed")
|
||
_despar.Add("In wind speed")
|
||
_despar.Add("High wind speed")
|
||
Return FromDevType.FreshAir
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
_despar.Add("Valve open")
|
||
Return FromDevType.FreshAir
|
||
Case "Voice"
|
||
Return FromDevType.Voice
|
||
Case "PB_LED", "PB_RELAY_DEVICE", "PB_STRIP_DEVICE"
|
||
Return FromDevType.PB_Bus
|
||
Case "DRY_NoCard"
|
||
Return FromDevType.DRY_NoCard
|
||
End Select
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
|
||
Private Sub SelectiveDisplay()
|
||
g_DevType = DetermineDeviceType()
|
||
|
||
|
||
ComboBox1.Visible = False
|
||
Label6.Visible = False
|
||
Table_Grid1.Visible = False
|
||
|
||
CheckBox1.Visible = False
|
||
CheckBox1.Checked = False
|
||
CheckBox5.Visible = False
|
||
CheckBox4.Visible = False
|
||
CheckBox2.Visible = False
|
||
CheckBox3.Visible = False
|
||
|
||
FdevPort.Visible = False
|
||
FdevAddr.Visible = False
|
||
FdevPortCom.Visible = False
|
||
FdevPortText.Visible = False
|
||
Fdevtype.Visible = False
|
||
FdevtypeCom.Visible = False
|
||
SplitContainer6.Visible = False
|
||
Label9.Visible = False
|
||
TextBox3.Visible = False
|
||
SplitContainer5.Panel2Collapsed = True
|
||
SplitContainer2.Panel2Collapsed = False
|
||
If Not String.IsNullOrEmpty(Resultmodel.Desc.DevDescription) Then
|
||
Dim Rchenk() As String = Resultmodel.Desc.DevDescription.Split(",")
|
||
Dim ischenk As Integer = 0
|
||
For i = 0 To Rchenk.Length - 1
|
||
If i < 3 Then
|
||
ischenk = 0
|
||
Integer.TryParse(Rchenk(i), ischenk)
|
||
Select Case i
|
||
Case 0
|
||
CheckBox1.Checked = ischenk
|
||
Case 1
|
||
CheckBox2.Checked = ischenk
|
||
Case 2
|
||
CheckBox3.Checked = ischenk
|
||
End Select
|
||
|
||
Else
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
|
||
End If
|
||
Select Case g_DevType
|
||
Case FromDevType.Temp
|
||
CheckBox1.Visible = True
|
||
CheckBox1.Checked = True
|
||
CheckBox2.Visible = True
|
||
CheckBox5.Text = "Wind speed mode prompt tone"
|
||
CheckBox5.Visible = True
|
||
CheckBox4.Visible = True
|
||
SplitContainer4.Panel1Collapsed = True
|
||
SplitContainer4.Panel2Collapsed = False
|
||
Dim val As String = FindAttributeValueUnderModel(Resultmodel, "Device present", "Valveless machine")
|
||
If String.IsNullOrEmpty(val) Then
|
||
CheckBox6.Visible = False
|
||
Else
|
||
CheckBox6.Visible = True
|
||
If val.Equals("1") Then
|
||
CheckBox6.Checked = True
|
||
Else
|
||
CheckBox6.Checked = False
|
||
End If
|
||
End If
|
||
|
||
Normal_initTable()
|
||
Temp_initTable(Resultmodel)
|
||
Case FromDevType.CURTAIN
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
CURTAIN_initTable(_despar)
|
||
Case FromDevType.BLEMUSIC
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Label9.Visible = True
|
||
TextBox3.Visible = True
|
||
TextBox3.Enabled = True
|
||
TextBox3.Text = FindAttributeValueUnderModel2(Resultmodel, "设备存在", "BleName")
|
||
Normal_initTable()
|
||
Case FromDevType.Normal
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Normal_initTable()
|
||
Case FromDevType.Voice
|
||
SplitContainer4.Panel2Collapsed = True
|
||
CheckBox1.Visible = True
|
||
CheckBox1.Checked = True
|
||
'CheckBox2.Visible = True
|
||
CheckBox5.Text = "Call for a welcome message"
|
||
CheckBox5.Visible = True
|
||
'CheckBox3.Visible = True
|
||
Table_Grid1.Visible = True
|
||
Voice_InitTable()
|
||
Case FromDevType.FreshAir
|
||
CheckBox1.Visible = True
|
||
CheckBox1.Checked = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Table_Grid1.Visible = True
|
||
FreshAirInitTable(_despar)
|
||
Case FromDevType.PB_Bus
|
||
FdevPort.Visible = True
|
||
FdevAddr.Visible = True
|
||
FdevPortCom.Visible = True
|
||
FdevPortText.Visible = True
|
||
Fdevtype.Visible = True
|
||
FdevtypeCom.Visible = True
|
||
|
||
SplitContainer4.Panel2Collapsed = True
|
||
Table_Grid1.Visible = True
|
||
SplitContainer6.Visible = True
|
||
PB_Bus_initTable()
|
||
Case FromDevType.DRY_NoCard
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel2Collapsed = True
|
||
NoCard_initTable()
|
||
Case FromDevType.Dev_ColorTemp
|
||
Table_Grid1.Visible = True
|
||
|
||
Label6.Text = "Display loop"
|
||
Label6.Visible = True
|
||
ComboBox1.Visible = True
|
||
ComboBox1.Items.Clear()
|
||
For i = 1 To Resultmodel.Nodes(0).Nodes.Count
|
||
ComboBox1.Items.Add(i)
|
||
Next
|
||
|
||
SplitContainer4.Panel1Collapsed = False
|
||
SplitContainer4.Panel2Collapsed = True
|
||
SplitContainer5.Panel1Collapsed = False
|
||
ParseDeviceList(g_Devicemodel)
|
||
initGrid()
|
||
Dim cnt As Integer
|
||
If Integer.TryParse(Resultmodel.Desc.DevDescription, cnt) Then
|
||
ComboBox1.Text = cnt
|
||
End If
|
||
|
||
Case Else
|
||
SplitContainer2.Panel2Collapsed = True
|
||
End Select
|
||
End Sub
|
||
|
||
Private Sub Table_Grid1_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles Table_Grid1.CellChange
|
||
Select Case g_DevType
|
||
Case FromDevType.Dev_ColorTemp
|
||
If e.Row = 0 Then Return
|
||
Select Case e.Col
|
||
Case 2
|
||
If Not IsColorTemp Then Return
|
||
Dim strbuf() As String = Table_Grid1.Cell(e.Row, e.Col).Text.Split(":")
|
||
Dim v3 As Integer = 0
|
||
Integer.TryParse(strbuf(0), v3)
|
||
Dim ntabler As Integer = Table_Grid1.Rows - 1
|
||
For r = e.Row + 1 To ntabler
|
||
Dim urle As Integer = ntabler - r + e.Row + 1
|
||
If Table_Grid1.Cell(e.Row, 0).Text.Equals(Table_Grid1.Cell(urle, 0).Text) Then
|
||
Table_Grid1.Row(urle).Delete()
|
||
End If
|
||
Next
|
||
For i = 1 To v3 + 1
|
||
Table_Grid1.InsertRow(e.Row + i, 1)
|
||
Table_Grid1.Range(e.Row + i, 0, e.Row + i, 2).Locked = True
|
||
Table_Grid1.Cell(e.Row + i, 3).Locked = False
|
||
Table_Grid1.Range(e.Row + i, 0, e.Row + i, 2).BackColor = Color.LightGray
|
||
Table_Grid1.Range(e.Row + i, 3, e.Row + i, Table_Grid1.Cols - 1).BackColor = Color.White
|
||
Table_Grid1.Cell(e.Row + i, 0).Text = Table_Grid1.Cell(e.Row, 0).Text
|
||
Next
|
||
Case 3, 4, 5
|
||
If String.IsNullOrEmpty(Table_Grid1.Cell(e.Row, 1).Text) OrElse e.Row = 0 Then
|
||
Select Case e.Col
|
||
Case 3
|
||
Case 4
|
||
Dim typestr As String = Table_Grid1.Cell(e.Row, e.Col).Text
|
||
Dim addr As String = Table_Grid1.Cell(e.Row, e.Col - 1).Text
|
||
Table_Grid1.Cell(e.Row, e.Col + 1).Text = ""
|
||
If String.IsNullOrEmpty(addr) Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = ""
|
||
MsgBox("Please select the device type!")
|
||
Return
|
||
End If
|
||
Table_Grid1.Cell(e.Row, e.Col).Tag = ParseDevDic.Item(addr).Item(typestr).Values(0).Item(0).Item2
|
||
Case 5
|
||
Dim celltxt As String = Table_Grid1.Cell(e.Row, e.Col).Tag
|
||
Dim velltxt As String = Table_Grid1.Cell(e.Row, e.Col).Text
|
||
Dim addr As String = Table_Grid1.Cell(e.Row, e.Col - 1).Text
|
||
Dim typestr As String = Table_Grid1.Cell(e.Row, e.Col - 2).Text
|
||
If String.IsNullOrEmpty(addr) Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = ""
|
||
MsgBox("Please select the device address!")
|
||
Return
|
||
End If
|
||
For Each tnode In ParseDevDic.Item(typestr).Item(addr).Item(celltxt)
|
||
If velltxt.Equals(tnode.Item1) Then
|
||
Table_Grid1.Cell(e.Row, e.Col + 1).Text = tnode.Item3
|
||
Exit For
|
||
End If
|
||
|
||
Next
|
||
|
||
End Select
|
||
Return
|
||
Else
|
||
If Not String.IsNullOrEmpty(Table_Grid1.Cell(e.Row, e.Col).Text) Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = ""
|
||
End If
|
||
End If
|
||
|
||
End Select
|
||
|
||
Case FromDevType.Temp
|
||
|
||
Case FromDevType.CURTAIN
|
||
|
||
If e.Col = 3 AndAlso e.Row > 0 Then
|
||
Dim cetext As String = Table_Grid1.Cell(e.Row, e.Col).Text.Trim
|
||
Dim cstin As Integer = 0
|
||
If Integer.TryParse(cetext, cstin) Then
|
||
If cstin > -1 AndAlso cstin < 256 Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = cstin
|
||
Else
|
||
If cstin > 255 Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = 255
|
||
ElseIf cstin < 0 Then
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = 0
|
||
End If
|
||
|
||
End If
|
||
|
||
Else
|
||
Table_Grid1.Cell(e.Row, e.Col).Text = 0
|
||
End If
|
||
|
||
End If
|
||
Case FromDevType.Voice
|
||
'Dim rtag As String = Table_Grid1.Cell(e.Row, 1).Tag
|
||
'Dim rtext As String = Table_Grid1.Cell(e.Row, 1).Text
|
||
'Dim rtval As String = Table_Grid1.Cell(e.Row, 4).Text
|
||
'If e.Col = 4 Then
|
||
' SetVoiceConfigNode(rtag, rtext, rtval)
|
||
'End If
|
||
Case FromDevType.DRY_NoCard
|
||
Dim LoopAddr As String = $"{Table_Grid1.Cell(e.Row, 0).Text.Trim}"
|
||
For Each ModuleFre In Resultmodel.Config(0).Attributes
|
||
If ModuleFre.Name.Equals(LoopAddr) AndAlso e.Col = 1 Then
|
||
ModuleFre.DataDefault = Table_Grid1.Cell(e.Row, e.Col).Text
|
||
End If
|
||
Next
|
||
|
||
|
||
Case FromDevType.PB_Bus
|
||
If e.Col = 2 Then
|
||
Dim LoopAddr As String = Table_Grid1.Cell(e.Row, Tcolname.输入序号).Text.Trim
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
If ModuleFre.Interface.Equals("DI") Then
|
||
For Each index In ModuleFre.Nodes
|
||
If LoopAddr.Equals(index.LoopAddr) Then
|
||
index.DefaultAliasName = Table_Grid1.Cell(e.Row, Tcolname.按键别名).Text.Trim
|
||
Return
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
ElseIf e.Col > 2 Then
|
||
Dim LoopAddr As String = $"loop{ Table_Grid1.Cell(e.Row, e.Col).Text.Trim}{Table_Grid1.Cell(0, e.Col).Text.Trim}"
|
||
For Each index In Resultmodel.Config
|
||
If index.Name.Equals("Device presence") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals(LoopAddr) Then
|
||
node.DataRangeValue = Table_Grid1.Cell(e.Row, e.Col).Text
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
End If
|
||
|
||
Case FromDevType.Normal, FromDevType.BLEMUSIC
|
||
If e.Row > 0 Then
|
||
Select Case e.Col
|
||
Case Tcolname.按键别名
|
||
Dim LoopAddr As String = Table_Grid1.Cell(e.Row, Tcolname.输入序号).Text.Trim
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
If ModuleFre.Interface.Equals("DI") Then
|
||
For Each index In ModuleFre.Nodes
|
||
If LoopAddr.Equals(index.LoopAddr) Then
|
||
index.DefaultAliasName = Table_Grid1.Cell(e.Row, Tcolname.按键别名).Text.Trim
|
||
Return
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
Case Tcolname.按键反馈灯
|
||
Dim LoopAddr As String = Table_Grid1.Cell(e.Row, Tcolname.按键反馈灯).Text.Trim
|
||
If String.IsNullOrEmpty(LoopAddr) Then Return
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
If ModuleFre.Interface.Equals("DO") Then
|
||
For Each index In ModuleFre.Nodes
|
||
If LoopAddr.Equals(index.LoopAddr) Then
|
||
Return
|
||
End If
|
||
Next
|
||
MsgBox("Backlight serial number does not exist!! The default dimming serial number is restored!")
|
||
Table_Grid1.Cell(e.Row, Tcolname.按键反馈灯).Text = Table_Grid1.Cell(e.Row, Tcolname.输入序号).Text
|
||
End If
|
||
Next
|
||
End Select
|
||
|
||
End If
|
||
End Select
|
||
|
||
End Sub
|
||
|
||
Public Sub SetVoiceConfigNode(nodename As String, keytxt As String, valtext As String)
|
||
If IsNothing(Resultmodel) Then Return
|
||
For Each index In Resultmodel.Config
|
||
If index.Name.Equals(nodename) Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals(keytxt) Then
|
||
node.DataRangeValue = keytxt
|
||
Return
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
Return
|
||
|
||
End Sub
|
||
|
||
|
||
Private Sub Table_Grid1_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs) Handles Table_Grid1.ComboDropDown
|
||
Select Case g_DevType
|
||
Case FromDevType.Dev_ColorTemp
|
||
Select Case e.Col
|
||
Case 2
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange({"1: two-way mixed light (a line 2 line with warm color cool color)", "2: three-way mixed light", "3: four road mix light", "4: five road mix light"})
|
||
Case 3
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange(ParseDevDic.Keys.ToArray)
|
||
Case 4
|
||
Dim typestr As String = Table_Grid1.Cell(e.Row, e.Col).Text
|
||
Dim addr As String = Table_Grid1.Cell(e.Row, e.Col - 1).Text
|
||
If String.IsNullOrEmpty(addr) Then
|
||
MsgBox("Select the device type first!")
|
||
Return
|
||
End If
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange(ParseDevDic.Item(addr).Keys.ToArray)
|
||
|
||
|
||
Case 5
|
||
Dim typestr As String = Table_Grid1.Cell(e.Row, e.Col - 2).Text
|
||
Dim addr As String = Table_Grid1.Cell(e.Row, e.Col - 1).Text
|
||
If String.IsNullOrEmpty(addr) OrElse String.IsNullOrEmpty(typestr) Then
|
||
MsgBox("Select the device address first!")
|
||
Return
|
||
End If
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
For Each index In ParseDevDic.Item(typestr).Item(addr).Values(0).ToArray
|
||
Table_Grid1.ComboBox(e.Col).Items.Add(index.Item1)
|
||
Next
|
||
Table_Grid1.Cell(e.Row, e.Col).Tag = ParseDevDic.Item(typestr).Item(addr).Keys(0)
|
||
End Select
|
||
Case FromDevType.Temp
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.Clear()
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.Add("")
|
||
If IsNothing(Normal_Do_li) Then Return
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.AddRange(Normal_Do_li.ToArray)
|
||
Case FromDevType.CURTAIN
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.Add("")
|
||
If e.Col = 2 Then
|
||
If Not IsNothing(g_DevRELAYrow) OrElse g_DevRELAYrow.Count > 0 Then
|
||
For Each nodex In g_DevRELAYrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, nodex).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, nodex)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
Table_Grid1.ComboBox(e.Col).Items.Add(Anostr)
|
||
Next
|
||
End If
|
||
ElseIf e.Col = 3 Then
|
||
For ti = 0 To 255
|
||
Table_Grid1.ComboBox(e.Col).Items.Add(ti)
|
||
Next
|
||
End If
|
||
|
||
Case FromDevType.Normal, FromDevType.BLEMUSIC
|
||
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.Clear()
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.Add("")
|
||
If IsNothing(Normal_Do_li) Then Return
|
||
Table_Grid1.ComboBox(Tcolname.按键反馈灯).Items.AddRange(Normal_Do_li.ToArray)
|
||
Case FromDevType.Voice
|
||
|
||
Dim rtag As String = Table_Grid1.Cell(e.Row, 1).Tag
|
||
If String.IsNullOrEmpty(rtag) Then Return
|
||
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.Add("")
|
||
Dim li As List(Of String) = Voice_SelectDropdownItem(rtag, e.Col)
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange(li.ToArray)
|
||
Case FromDevType.FreshAir
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.Add("")
|
||
If e.Col = 2 Then
|
||
If Not IsNothing(g_DevRELAYrow) OrElse g_DevRELAYrow.Count > 0 Then
|
||
For Each nodex In g_DevRELAYrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, nodex).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, nodex)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
Table_Grid1.ComboBox(e.Col).Items.Add(Anostr)
|
||
Next
|
||
End If
|
||
End If
|
||
Case FromDevType.PB_Bus
|
||
Dim vsccal As String = Table_Grid1.Cell(e.Row, e.Col).Tag
|
||
'Console.WriteLine(vsccal)
|
||
Dim cellli As List(Of String) = JsonConvert.DeserializeObject(Of List(Of String))(vsccal)
|
||
If IsNothing(cellli) OrElse cellli.Count = 0 Then
|
||
Else
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange(cellli.ToArray)
|
||
End If
|
||
Case FromDevType.DRY_NoCard
|
||
Dim vsccal As String = Table_Grid1.Cell(e.Row, e.Col).Tag
|
||
'Console.WriteLine(vsccal)
|
||
Dim cellli As List(Of String) = JsonConvert.DeserializeObject(Of List(Of String))(vsccal)
|
||
If IsNothing(cellli) OrElse cellli.Count = 0 Then
|
||
Else
|
||
Table_Grid1.ComboBox(e.Col).Items.Clear()
|
||
Table_Grid1.ComboBox(e.Col).Items.AddRange(cellli.ToArray)
|
||
End If
|
||
|
||
|
||
End Select
|
||
|
||
End Sub
|
||
|
||
Public Function GetAnotherName(str As String) As String
|
||
Dim result As String = String.Empty
|
||
If String.IsNullOrEmpty(str) Then
|
||
result = "unknown"
|
||
Else
|
||
Select Case str
|
||
Case "CLED_FRESHAIR"
|
||
result = "CLED_FRESHAIR"
|
||
Case "CLEDFLOORHEAT"
|
||
result = "CLEDFLOORHEAT"
|
||
Case "485FloorHeat"
|
||
result = "FloorHeat"
|
||
Case "485FreshAir"
|
||
result = "FreshAir"
|
||
Case "485MUSIC"
|
||
result = "485MUSIC"
|
||
Case "CURTAIN"
|
||
result = "CURTAIN"
|
||
Case "INFRARED_FORWARD"
|
||
result = "INFRARED_FORWARD"
|
||
Case "RS485_Curtain"
|
||
result = "RS485_Curtain"
|
||
Case "RELAY"
|
||
result = "RELAY"
|
||
Case "MUSIC"
|
||
result = "MUSIC"
|
||
Case "Dimming"
|
||
result = "Dimming"
|
||
Case "DO"
|
||
result = "DO"
|
||
Case "Temp"
|
||
result = "Temp"
|
||
Case "DI"
|
||
result = "DI"
|
||
Case "PB_RELAY_DEVICE"
|
||
result = "PB_RELAY_DEVICE"
|
||
Case "PB_STRIP_DEVICE"
|
||
result = "PB_STRIP_DEVICE"
|
||
Case "PB_LINE_CONTROL"
|
||
result = "PB_LINE_CONTROL"
|
||
Case Else
|
||
result = $"Unknown equipment:{str}"
|
||
End Select
|
||
|
||
End If
|
||
Return result
|
||
End Function
|
||
|
||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||
ResulDic = New Dictionary(Of String, String)
|
||
|
||
If IsNothing(Resultmodel) Then
|
||
MsgBox("Failed to add a device. The device is not selected!")
|
||
Return
|
||
End If
|
||
|
||
If IsNothing(g_Devicemodel) Then
|
||
MsgBox("Failed to add a device because the host model is not added!")
|
||
Return
|
||
End If
|
||
|
||
If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
|
||
MsgBox("Failed to add a device. The device alias or address is empty!")
|
||
Return
|
||
End If
|
||
|
||
Dim olddevname As String = Resultmodel.Name
|
||
Dim newdevname As String = $"{ShowDevicePort(Resultmodel)}{vbLf}Device address:{TextBox2.Text.Trim }{vbLf}{TextBox1.Text.Trim }"
|
||
|
||
Select Case g_DevType
|
||
Case FromDevType.Temp
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
ResulDic.Add(Table_Grid1.Cell(i, Tcolname.输入序号).Text.Trim, Table_Grid1.Cell(i, Tcolname.按键反馈灯).Text.Trim)
|
||
Next
|
||
Dim Tdic As New Dictionary(Of String, String)
|
||
|
||
For i = 1 To Temp_Grid.Rows - 1
|
||
Dim AnoName As String = Temp_Grid.Cell(i, 2).Text
|
||
Console.WriteLine($"1:{Temp_Grid.Cell(i, 1).Text}_2:{Temp_Grid.Cell(i, 2).Text}")
|
||
If g_ColumnAnothername.ContainsKey(AnoName) Then
|
||
AnoName = g_ColumnAnothername.Item(AnoName)
|
||
Else
|
||
AnoName = ""
|
||
End If
|
||
Tdic.Add(Temp_Grid.Cell(i, 1).Text, AnoName)
|
||
Next
|
||
If Temp_BindingRelay(Tdic) Then
|
||
Resultmodel.Desc.ProtocolData = JsonConvert.SerializeObject(Tdic)
|
||
If CheckBox1.Checked Then
|
||
Resultmodel.Desc.DevDescription = "1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = "0"
|
||
End If
|
||
If CheckBox2.Checked Then
|
||
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},0"
|
||
End If
|
||
If CheckBox3.Checked Then
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},0"
|
||
End If
|
||
If CheckBox5.Checked Then
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = $"{ Resultmodel.Desc.DevDescription},0"
|
||
End If
|
||
|
||
|
||
Else
|
||
Return
|
||
End If
|
||
Case FromDevType.FreshAir
|
||
Dim Rtime As String = String.Empty
|
||
Dim TisNull As Boolean = False
|
||
Dim dic As New Dictionary(Of String, String)
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
If Not String.IsNullOrEmpty(Table_Grid1.Cell(i, 2).Text) Then
|
||
TisNull = True
|
||
End If
|
||
Next
|
||
|
||
If TisNull Then
|
||
|
||
For i = 0 To _despar.Count - 1
|
||
'判断是否选择继电器
|
||
If String.IsNullOrEmpty(Table_Grid1.Cell(i + 1, 2).Text) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}Unselected relay!")
|
||
Return
|
||
End If
|
||
'判断继电器是否存在
|
||
Dim AnoName As String = Table_Grid1.Cell(i + 1, 2).Text
|
||
AnoName = g_ColumnAnothername.Item(AnoName)
|
||
Dim Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(AnoName))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}Relay not found!")
|
||
Return
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return
|
||
End If
|
||
End If
|
||
'判断是否选择同一路继电器
|
||
If dic.ContainsKey(AnoName) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}And{dic.Item(Table_Grid1.Cell(i + 1, 2).Text)} Relay conflict!")
|
||
Return
|
||
Else
|
||
dic.Add(AnoName, Table_Grid1.Cell(i + 1, 1).Text)
|
||
End If
|
||
|
||
|
||
Rtime = $"{Rtime}{AnoName},"
|
||
Next
|
||
If Rtime.Length > 0 Then
|
||
Rtime = Rtime.Substring(0, Rtime.Length - 1)
|
||
End If
|
||
BindingRelay(dic)
|
||
If CheckBox1.Checked Then
|
||
Resultmodel.Desc.DevDescription = "1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = "0"
|
||
End If
|
||
Resultmodel.Desc.ProtocolData = Rtime
|
||
Else
|
||
BindingRelay(dic)
|
||
Resultmodel.Desc.ProtocolData = Rtime
|
||
End If
|
||
|
||
Case FromDevType.CURTAIN
|
||
Dim dic As New Dictionary(Of String, String)
|
||
Dim Rtime As String = String.Empty
|
||
Dim Tstart As Integer = 0
|
||
Console.WriteLine(Table_Grid1.Cell(1, 2).Text)
|
||
If String.IsNullOrEmpty(Table_Grid1.Cell(1, 2).Text) AndAlso String.IsNullOrEmpty(Table_Grid1.Cell(2, 2).Text) Then
|
||
BindingRelay(dic)
|
||
If CheckBox1.Checked Then
|
||
Resultmodel.Desc.DevDescription = "1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = "0"
|
||
End If
|
||
Resultmodel.Desc.ProtocolData = Rtime
|
||
Else
|
||
For i = 0 To _despar.Count - 1
|
||
'判断是否选择继电器
|
||
If String.IsNullOrEmpty(Table_Grid1.Cell(i + 1, 2).Text) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}Unselected relay!")
|
||
Return
|
||
End If
|
||
'判断继电器是否存在
|
||
Dim AnoName As String = Table_Grid1.Cell(i + 1, 2).Text
|
||
AnoName = g_ColumnAnothername.Item(AnoName)
|
||
Dim Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(AnoName))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}Relay not found!")
|
||
Return
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return
|
||
End If
|
||
End If
|
||
'判断是否选择同一路继电器
|
||
If dic.ContainsKey(AnoName) Then
|
||
MsgBox($"{Table_Grid1.Cell(i + 1, 1).Text}And{Table_Grid1.Cell(i + 1, 2).Text} Relay conflict!")
|
||
Return
|
||
Else
|
||
dic.Add(AnoName, Table_Grid1.Cell(i + 1, 1).Text)
|
||
End If
|
||
Tstart = 0
|
||
Integer.TryParse(Table_Grid1.Cell(1, 3).Text, Tstart)
|
||
Rtime = $"{Rtime}{AnoName}*{Tstart },"
|
||
Next
|
||
If Rtime.Length > 0 Then
|
||
Rtime = Rtime.Substring(0, Rtime.Length - 1)
|
||
End If
|
||
|
||
|
||
BindingRelay(dic)
|
||
If CheckBox1.Checked Then
|
||
Resultmodel.Desc.DevDescription = "1"
|
||
Else
|
||
Resultmodel.Desc.DevDescription = "0"
|
||
End If
|
||
Resultmodel.Desc.ProtocolData = Rtime
|
||
End If
|
||
|
||
|
||
|
||
Case FromDevType.Normal, FromDevType.BLEMUSIC
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
ResulDic.Add(Table_Grid1.Cell(i, Tcolname.输入序号).Text.Trim, Table_Grid1.Cell(i, Tcolname.按键反馈灯).Text.Trim)
|
||
Next
|
||
If TextBox3.Visible Then
|
||
SetDevModeAindex(Resultmodel, "BleName", TextBox3.Text)
|
||
End If
|
||
Case FromDevType.Voice
|
||
Dim rtag As String
|
||
Dim rtext As String
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
'If String.IsNullOrEmpty(Table_Grid1.Cell(i, 4).Text) Then Continue For
|
||
rtag = Table_Grid1.Cell(i, 1).Tag
|
||
rtext = Table_Grid1.Cell(i, 1).Text
|
||
If String.IsNullOrEmpty(rtag) Then Continue For
|
||
For Each node In Resultmodel.Config
|
||
If node.CFG_Type.Equals("XiaoBaoCMD") Then
|
||
|
||
|
||
If node.Name.Equals(rtag) Then
|
||
|
||
For Each index In node.Attributes
|
||
If index.Name.Equals(rtext) Then
|
||
Dim AnoName As String = Table_Grid1.Cell(i, 4).Text.Replace(vbCrLf, vbLf)
|
||
|
||
If g_ColumnAnothername.ContainsKey(AnoName) Then
|
||
AnoName = g_ColumnAnothername.Item(AnoName)
|
||
End If
|
||
|
||
index.DataRangeValue = AnoName
|
||
Exit For
|
||
End If
|
||
Next
|
||
Exit For
|
||
End If
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
Dim devdes As String = String.Empty
|
||
|
||
If CheckBox1.Checked Then
|
||
devdes = $"1"
|
||
Else
|
||
devdes = $"0"
|
||
End If
|
||
If CheckBox2.Checked Then
|
||
devdes = $"{devdes},1"
|
||
Else
|
||
devdes = $"{devdes},0"
|
||
End If
|
||
|
||
If CheckBox3.Checked Then
|
||
devdes = $"{devdes},1"
|
||
Else
|
||
devdes = $"{devdes},0"
|
||
End If
|
||
If CheckBox5.Checked Then
|
||
devdes = $"{devdes},1"
|
||
Else
|
||
devdes = $"{devdes},0"
|
||
End If
|
||
Resultmodel.Desc.DevDescription = devdes
|
||
Case FromDevType.Dev_ColorTemp
|
||
Dim cnt As Integer
|
||
If Integer.TryParse(ComboBox1.Text, cnt) Then
|
||
Resultmodel.Desc.DevDescription = cnt
|
||
Else
|
||
MsgBox("No display loop is selected!!!")
|
||
Return
|
||
End If
|
||
Dim dicli As Dictionary(Of String, Dictionary(Of String, List(Of List(Of String)))) = New Dictionary(Of String, Dictionary(Of String, List(Of List(Of String))))
|
||
Dim nkey, mkey As String
|
||
Dim cdic As Dictionary(Of String, List(Of List(Of String)))
|
||
Dim cli As List(Of List(Of String))
|
||
Dim vli As List(Of String)
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
nkey = Table_Grid1.Cell(i, 0).Text
|
||
If dicli.ContainsKey(nkey) Then
|
||
cdic = dicli.Item(nkey)
|
||
Else
|
||
cdic = New Dictionary(Of String, List(Of List(Of String)))
|
||
dicli.Add(nkey, cdic)
|
||
End If
|
||
If Not String.IsNullOrEmpty(Table_Grid1.Cell(i, 1).Text) Then
|
||
mkey = $"{Table_Grid1.Cell(i, 1).Text},{Table_Grid1.Cell(i, 2).Text}"
|
||
If cdic.ContainsKey(mkey) Then
|
||
cli = cdic.Item(mkey)
|
||
Else
|
||
cli = New List(Of List(Of String))
|
||
cdic.Add(mkey, cli)
|
||
End If
|
||
Else
|
||
If Table_Grid1.Row(i).Visible AndAlso (String.IsNullOrEmpty(Table_Grid1.Cell(i, 3).Text) OrElse String.IsNullOrEmpty(Table_Grid1.Cell(i, 4).Text) OrElse String.IsNullOrEmpty(Table_Grid1.Cell(i, 5).Text)) Then
|
||
MsgBox($"Missing data in line {i}!!!")
|
||
Return
|
||
End If
|
||
vli = New List(Of String)
|
||
vli.Add(Table_Grid1.Cell(i, 3).Text)
|
||
vli.Add(Table_Grid1.Cell(i, 4).Text)
|
||
vli.Add(Table_Grid1.Cell(i, 5).Text)
|
||
vli.Add(Table_Grid1.Cell(i, 5).Tag)
|
||
vli.Add(Table_Grid1.Cell(i, 4).Tag)
|
||
vli.Add(Table_Grid1.Cell(i, 6).Text)
|
||
cli.Add(vli)
|
||
End If
|
||
Next
|
||
|
||
|
||
|
||
For Each node In Resultmodel.Nodes
|
||
For i = 1 To node.Nodes.Count
|
||
Dim Index = node.Nodes(i - 1)
|
||
If Index.DefaultClass.Equals("Dev_ColorTemp") Then
|
||
|
||
If dicli.ContainsKey(Index.LoopAddr) Then
|
||
|
||
Dim Oldcdic As List(Of List(Of String)) = JsonConvert.DeserializeObject(Of List(Of List(Of String)))(Index.Description)
|
||
If Not IsNothing(Oldcdic) AndAlso Oldcdic.Count > 0 Then
|
||
For Each oldnode In Oldcdic
|
||
If Not IsNothing(oldnode) AndAlso oldnode.Count > 4 Then
|
||
SetColumnBind(oldnode(4), oldnode(0), oldnode(2), True)
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
|
||
|
||
|
||
cdic = dicli.Item(Index.LoopAddr)
|
||
Index.DefaultAliasName = cdic.Keys(0)
|
||
Index.Description = JsonConvert.SerializeObject(cdic.Values(0))
|
||
|
||
For Each cdnode In cdic.Values(0)
|
||
If Not IsNothing(cdnode) AndAlso cdnode.Count > 4 Then
|
||
SetColumnBind(cdnode(4), cdnode(0), cdnode(2), False)
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
|
||
End If
|
||
Next
|
||
Next
|
||
End Select
|
||
|
||
'存在且原名和旧名不一样 则为新设备
|
||
If g_Devicemodel.ContainsKey(newdevname) AndAlso Not (newdevname.Equals(olddevname)) Then
|
||
MsgBox("Failed to add a device. A device with the same alias and device address exists. Procedure!!")
|
||
Return
|
||
Else
|
||
If IfDipAddress(newdevname, TextBox2.Text.Trim, olddevname) Then
|
||
If isok And g_Devicemodel.ContainsKey(olddevname) Then
|
||
g_Devicemodel.Remove(olddevname)
|
||
End If
|
||
SetDevModeAindex(Resultmodel, "Dialing address", TextBox2.Text.Trim)
|
||
Resultmodel.Name = newdevname
|
||
g_Devicemodel.Add(newdevname, Resultmodel)
|
||
|
||
|
||
Dim ndic As New Dictionary(Of String, String)
|
||
|
||
For Each tindex In g_ColumnAnothername
|
||
If olddevname.Contains("Device address:") AndAlso tindex.Key.Contains(olddevname) Then
|
||
ndic.Add(tindex.Key, tindex.Value)
|
||
End If
|
||
Next
|
||
For Each yindex In ndic
|
||
Dim nkey, nval As String
|
||
nkey = yindex.Key.Replace(olddevname, newdevname)
|
||
nval = yindex.Value.Replace(olddevname, newdevname) '
|
||
g_ColumnAnothername.Remove(yindex.Key)
|
||
If g_ColumnAnothername.ContainsKey(nkey) Then
|
||
g_ColumnAnothername.Item(nkey) = nval
|
||
Else
|
||
g_ColumnAnothername.Add(nkey, nval)
|
||
End If
|
||
'
|
||
Next
|
||
|
||
Else
|
||
Return
|
||
End If
|
||
End If
|
||
|
||
Me.DialogResult = System.Windows.Forms.DialogResult.OK
|
||
Me.Close()
|
||
Return
|
||
End Sub
|
||
Public Sub SetColumnBind(devname As String, nodetype As String, devloop As String, istrue As Boolean)
|
||
If String.IsNullOrEmpty(devloop) Then Return
|
||
For i = TableInteraction.TableColNumber.InsertColumn To g_grd.Cols - 1
|
||
Dim g_devname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, i)
|
||
If g_devname.devname.Equals(devname) Then
|
||
For ci = g_devname.fc To g_devname.lc
|
||
Dim g_devcloumn = New CtabRange(g_grd, TableInteraction.TableRowNumber.FunctionAnotherName, ci)
|
||
If g_devcloumn.devname.Equals(nodetype) Then
|
||
For vi = g_devcloumn.fc To g_devcloumn.lc
|
||
If g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeID, vi).Text.Equals(devloop) Then
|
||
g_grd.Column(vi).Visible = istrue
|
||
If Not istrue Then
|
||
g_grd.Range(TableInteraction.TableRowNumber.Max, vi, g_grd.Rows - 1, vi).ClearText()
|
||
End If
|
||
Console.WriteLine($"Column{vi},Visible{istrue}")
|
||
Exit Sub
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
|
||
|
||
End Sub
|
||
|
||
|
||
|
||
|
||
Private ParseDevDic As Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, List(Of (String, String, String)))))
|
||
Public Sub ParseDeviceList(Devicemodel As Dictionary(Of String, DeviceModel))
|
||
|
||
ParseDevDic = New Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, List(Of (String, String, String)))))
|
||
Dim typename As String
|
||
For Each index In Devicemodel.Values
|
||
For Each node In index.Nodes
|
||
'If node.Name.Equals("Virtual_Card") Then
|
||
' UniqueDevice = index
|
||
' NoCardNode = node
|
||
' Exit For
|
||
'End If
|
||
If node.Name.Equals("Dimming") Then
|
||
typename = GetAnotherName(node.Name)
|
||
' typename = $"{node.Name}"
|
||
If String.IsNullOrEmpty(typename) Then
|
||
Continue For
|
||
Else
|
||
Dim addressdic As Dictionary(Of String, Dictionary(Of String, List(Of (String, String, String))))
|
||
If ParseDevDic.ContainsKey(typename) Then
|
||
addressdic = ParseDevDic.Item(typename)
|
||
Else
|
||
addressdic = New Dictionary(Of String, Dictionary(Of String, List(Of (String, String, String))))
|
||
ParseDevDic.Add(typename, addressdic)
|
||
End If
|
||
|
||
Dim addr As String
|
||
Dim loopdic As Dictionary(Of String, List(Of (String, String, String)))
|
||
Dim loopli As List(Of (String, String, String))
|
||
If index.Desc.Name.Equals("BLV_C12") Then
|
||
addr = 0
|
||
Else
|
||
addr = FindAttributeValueUnderModel2(index, “Device present”, "Dialing address")
|
||
End If
|
||
If addressdic.ContainsKey(addr) Then
|
||
loopdic = addressdic.Item(addr)
|
||
Else
|
||
loopdic = New Dictionary(Of String, List(Of (String, String, String)))
|
||
addressdic.Add(addr, loopdic)
|
||
End If
|
||
If loopdic.ContainsKey(node.DEV_TYPE_DATA) Then
|
||
loopli = loopdic.Item(node.DEV_TYPE_DATA)
|
||
Else
|
||
loopli = New List(Of (String, String, String))
|
||
loopdic.Add(node.DEV_TYPE_DATA, loopli)
|
||
End If
|
||
For Each liindex In node.Nodes
|
||
loopli.Add((liindex.LoopAddr, index.Name, liindex.DefaultAliasName))
|
||
Next
|
||
End If
|
||
Else
|
||
Continue For
|
||
End If
|
||
Next
|
||
Next
|
||
|
||
End Sub
|
||
Private Function FindAttributeValueUnderModel2(pNode As DeviceModel, groupName As String, attributeName As String) As String
|
||
For Each cnode In pNode.Config
|
||
If cnode.Name.Equals(groupName) Then
|
||
For Each ccnode In cnode.Attributes
|
||
If ccnode.Name.Equals(attributeName) Then
|
||
Return ccnode.Value
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
End Function
|
||
|
||
Public Function IfDipAddress(newnama As String, addr As String, oldname As String) As Boolean
|
||
If IsNothing(g_Devicemodel) OrElse IsNothing(Resultmodel) Then Return False
|
||
Dim adddevaddress As String = addr
|
||
Dim adddevn As String = String.Empty
|
||
Dim lidevn As String = String.Empty
|
||
Dim lidevaddress As String = String.Empty
|
||
newnama = newnama.Replace(vbLf, "")
|
||
Dim olddevname As String
|
||
For Each node In Resultmodel.Nodes
|
||
adddevn = $"{node.DEV_TYPE_DATA }_{adddevaddress}"
|
||
|
||
For i = 0 To g_Devicemodel.Count - 1
|
||
If i = 0 Then
|
||
lidevaddress = 0
|
||
Else
|
||
lidevaddress = GetDevModeAindex(g_Devicemodel.Values(i), "Dialing address")
|
||
End If
|
||
|
||
For Each index In g_Devicemodel.Values(i).Nodes
|
||
lidevn = $"{index.DEV_TYPE_DATA }_{lidevaddress}"
|
||
If adddevn.Equals(lidevn) AndAlso Not (oldname.Equals(g_Devicemodel.Values(i).Name)) AndAlso g_DevType <> FromDevType.Voice Then
|
||
olddevname = g_Devicemodel.Values(i).Name.Replace(vbLf, "")
|
||
MsgBox($"Failed to add device{vbLf}{newnama }{vbLf}And{vbLf}{olddevname}{vbLf}Device address conflict!!")
|
||
Return False
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
|
||
Next
|
||
|
||
Return True
|
||
End Function
|
||
|
||
|
||
#Region "Temp"
|
||
Public Shared Function CheckWhetherTheKeyExists(startint As Integer, nodeleng As Integer, dic As Dictionary(Of String, String)) As Boolean
|
||
Dim cleng As Integer = nodeleng + startint
|
||
If cleng > Temproweven.max Then Return False
|
||
Dim dicket As String = String.Empty
|
||
For i = startint To cleng - 1
|
||
dicket = GetDescriptionOriginal(CType(i, Temproweven)) '[Enum].GetName(GetType(Temproweven), i)
|
||
If dic.ContainsKey(dicket) AndAlso Not String.IsNullOrEmpty(dic.Item(dicket)) Then
|
||
Continue For
|
||
Else
|
||
Return False
|
||
End If
|
||
Next
|
||
Return True
|
||
End Function
|
||
Public Shared Function CheckWhetherTheKeyExists2(dic As Dictionary(Of String, String)) As Boolean
|
||
If IsNothing(dic) OrElse dic.Count = 0 Then Return False
|
||
For i As Integer = 0 To dic.Count
|
||
If i < Temproweven.风高 Then
|
||
If String.IsNullOrEmpty(dic.Values(i)) Then
|
||
Continue For
|
||
Else
|
||
Return False
|
||
End If
|
||
End If
|
||
|
||
|
||
Next
|
||
Return True
|
||
End Function
|
||
Private Sub Temp_SetIDOpenDO()
|
||
Dim dic As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(Resultmodel.Desc.ProtocolData)
|
||
Dim celltxt As String
|
||
For i = Temproweven.红外转发 To Temp_Grid.Rows - 1
|
||
celltxt = Temp_Grid.Cell(i, 1).Text
|
||
If dic.ContainsKey(celltxt) Then
|
||
Dim AnoName = dic.Item(celltxt)
|
||
|
||
For Each index In g_ColumnAnothername
|
||
If index.Value.Equals(AnoName) Then
|
||
Temp_Grid.Cell(i, 2).Text = index.Key
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
|
||
If dic.ContainsKey("Infrared forwarding") Then
|
||
If String.IsNullOrEmpty(dic.Item("Infrared forwarding")) OrElse g_Devinfraredrow.ContainsKey(dic.Item("Infrared forwarding")) Then
|
||
CheckBox4.Checked = False
|
||
Else
|
||
If g_Devinfraredrow.ContainsKey(dic.Item("Infrared forwarding")) Then
|
||
Dim r As Integer = g_Devinfraredrow.Item(dic.Item("Infrared forwarding"))
|
||
If g_grd.Column(r).Visible Then
|
||
CheckBox4.Checked = True
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
|
||
|
||
End Sub
|
||
Public Function Temp_BindingRelay(Tdic As Dictionary(Of String, String)) As Boolean
|
||
|
||
Dim rowname As String
|
||
Dim dic As New Dictionary(Of String, String)
|
||
Dim frelist As New List(Of String)
|
||
Dim rowval As String
|
||
Dim Lstart As List(Of Integer)
|
||
|
||
Dim arryls As New List(Of String)
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
Select Case ModuleFre.Name
|
||
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
If String.IsNullOrEmpty(Tdic.Item("Fresh wind _ Low wind speed")) And String.IsNullOrEmpty(Tdic.Item("Fresh wind _ Wind speed")) And String.IsNullOrEmpty(Tdic.Item("Fresh wind _ High wind speed")) Then
|
||
|
||
Else
|
||
arryls.Add("Fresh wind _ Low wind speed")
|
||
arryls.Add("Fresh wind _ Wind speed")
|
||
arryls.Add("Fresh wind _ High wind speed")
|
||
End If
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
If String.IsNullOrEmpty(Tdic.Item("Floor heating _ Valve open")) Then
|
||
Else
|
||
arryls.Add("Floor heating _ Valve open")
|
||
End If
|
||
End Select
|
||
Next
|
||
|
||
For Each arynode In arryls
|
||
rowval = Tdic.Item(arynode)
|
||
If String.IsNullOrEmpty(rowval) Then
|
||
MsgBox($"{arynode}Relay not configured!")
|
||
Return False
|
||
End If
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{arynode}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{arynode}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{arynode}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, arynode)
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
|
||
'温控部分
|
||
If CheckWhetherTheKeyExists2(Tdic) Then
|
||
'接触原绑定进行新绑定
|
||
Tx_BindingRelay(dic)
|
||
Return True
|
||
End If
|
||
|
||
'判断是否是氟机或水机
|
||
If CheckWhetherTheKeyExists(Temproweven.红外转发, 1, Tdic) OrElse
|
||
CheckWhetherTheKeyExists(Temproweven.冷阈开, 1, Tdic) Then
|
||
'判断温控是氟机还是水机
|
||
If CheckWhetherTheKeyExists(Temproweven.红外转发, 1, Tdic) Then
|
||
|
||
If CheckBox4.Checked Then
|
||
Tx_BindingRelay(dic)
|
||
Else
|
||
|
||
rowname = String.Empty
|
||
|
||
|
||
rowname = GetDescriptionOriginal(Temproweven.红外转发)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_Devinfraredrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Infrared not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The infrared configuration already exists. Continue to clear the infrared configuration", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Infrared collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
'接触原绑定进行新绑定
|
||
Tx_BindingRelay(dic)
|
||
End If
|
||
|
||
Return True
|
||
Else '温控为水机 需要
|
||
|
||
|
||
|
||
|
||
'判断风速继电器是否配置
|
||
If Not CheckWhetherTheKeyExists(Temproweven.风低, 3, Tdic) Then
|
||
MsgBox("The wind speed relay of the water cooler temperature control air conditioner is incorrectly configured!!")
|
||
Return False
|
||
End If
|
||
'风速
|
||
For i = Temproweven.风低 To Temproweven.max - 1
|
||
rowname = GetDescriptionOriginal(CType(i, Temproweven)) '[Enum].GetName(GetType(Temproweven), i)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
Next
|
||
|
||
'判断水机配置的继电器是否有数据
|
||
If CheckWhetherTheKeyExists(Temproweven.冷阈开, 4, Tdic) Then '双阈三线
|
||
|
||
For i = Temproweven.冷阈开 To Temproweven.热阈关
|
||
rowname = GetDescriptionOriginal(CType(i, Temproweven)) 'GetDescriptionOriginal( i)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
Next
|
||
'双阈2线
|
||
ElseIf CheckWhetherTheKeyExists(Temproweven.冷阈开, 1, Tdic) AndAlso
|
||
CheckWhetherTheKeyExists(Temproweven.热阈开, 1, Tdic) Then
|
||
|
||
rowname = GetDescriptionOriginal(Temproweven.冷阈开)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
rowname = GetDescriptionOriginal(Temproweven.热阈开)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
'单阈三线
|
||
ElseIf CheckWhetherTheKeyExists(Temproweven.冷阈开, 1, Tdic) AndAlso
|
||
CheckWhetherTheKeyExists(Temproweven.冷阈关, 1, Tdic) Then
|
||
|
||
rowname = GetDescriptionOriginal(Temproweven.冷阈开)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
rowname = GetDescriptionOriginal(Temproweven.冷阈关)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
ElseIf CheckWhetherTheKeyExists(Temproweven.冷阈开, 1, Tdic) Then '单阈2线
|
||
rowname = GetDescriptionOriginal(Temproweven.冷阈开)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
End If
|
||
'接触原绑定进行新绑定
|
||
Tx_BindingRelay(dic)
|
||
Return True
|
||
End If
|
||
Else '判断温控类型异常
|
||
'判断风速继电器是否配置
|
||
|
||
If CheckWhetherTheKeyExists(Temproweven.风低, 3, Tdic) Then
|
||
For i = Temproweven.风低 To Temproweven.风高
|
||
rowname = GetDescriptionOriginal(CType(i, Temproweven)) 'GetDescriptionOriginal( i)
|
||
rowval = Tdic.Item(rowname)
|
||
Lstart = TableInteraction.CURTAIN_check(g_grd, g_DevRELAYrow.Item(rowval))
|
||
|
||
If IsNothing(Lstart) Then
|
||
MsgBox($"{rowname}Relay not found!")
|
||
Return False
|
||
End If
|
||
If Lstart.Count > 0 Then
|
||
If MsgBox($"{rowname}The relay already has a configuration. If you continue, the relay configuration will be cleared", MsgBoxStyle.OkCancel) <> MsgBoxResult.Ok Then
|
||
Return False
|
||
End If
|
||
|
||
End If
|
||
If dic.ContainsKey(rowval) Then
|
||
MsgBox($"{rowname}And{dic.Item(rowval)}Relay collision!")
|
||
Return False
|
||
Else
|
||
dic.Add(rowval, rowname)
|
||
End If
|
||
Next
|
||
Tx_BindingRelay(dic)
|
||
Return True
|
||
End If
|
||
If CheckWhetherTheKeyExists(Temproweven.互锁, 1, Tdic) Then
|
||
Return True
|
||
End If
|
||
MsgBox("The temperature control type cannot be determined if infrared forwarding or cold threshold opening relays are not configured!!")
|
||
Return False
|
||
End If
|
||
|
||
|
||
End Function
|
||
Public Sub Temp_initTable(devmodw As DeviceModel)
|
||
Temp_Grid.NewFile()
|
||
Temp_Grid.Rows = Temproweven.max
|
||
Temp_Grid.Cols = 3
|
||
Temp_Grid.ExtendLastCol = True
|
||
|
||
For i = 0 To Temproweven.max - 1
|
||
|
||
If i = 0 Then
|
||
Temp_Grid.Cell(i, 1).Text = "Event description"
|
||
Temp_Grid.Cell(i, 2).Text = "Bound loop"
|
||
'Table_Grid1.Cell(i, 3).Text = "延时"
|
||
'Table_Grid1.Cell(i, 4).Text = "延时单位"
|
||
Temp_Grid.Column(1).Locked = True
|
||
'Table_Grid1.Column(4).Locked = True
|
||
Temp_Grid.Column(2).CellType = CellTypeEnum.ComboBox
|
||
Temp_Grid.ComboBox(2).Locked = True
|
||
Temp_Grid.Column(2).Width = 150
|
||
'Table_Grid1.Column(3).CellType = CellTypeEnum.ComboBox
|
||
'Table_Grid1.ComboBox(3).Locked = True
|
||
Continue For
|
||
End If
|
||
Temp_Grid.Cell(i, 1).Text = GetDescriptionOriginal(CType(i, Temproweven)) '[Enum].GetName(GetType(Temproweven), i)
|
||
Next
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
Select Case ModuleFre.Name
|
||
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
Temp_Grid.AddItem("")
|
||
Temp_Grid.Cell(Temp_Grid.Rows - 1, 1).Text = "Fresh wind _ Low wind speed"
|
||
Temp_Grid.AddItem("")
|
||
Temp_Grid.Cell(Temp_Grid.Rows - 1, 1).Text = "Fresh wind _ Wind speed"
|
||
Temp_Grid.AddItem("")
|
||
Temp_Grid.Cell(Temp_Grid.Rows - 1, 1).Text = "Fresh wind _ High wind speed"
|
||
|
||
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
Temp_Grid.AddItem("")
|
||
Temp_Grid.Cell(Temp_Grid.Rows - 1, 1).Text = "Floor heating _ Valve open"
|
||
|
||
|
||
End Select
|
||
Next
|
||
Temp_Grid.Range(0, 0, Temp_Grid.Rows - 1, Temp_Grid.Cols - 1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
End Sub
|
||
#End Region
|
||
|
||
|
||
|
||
#Region "Normal"
|
||
|
||
Public Sub Normal_initTable2(li As List(Of DeviceChildNodeClass))
|
||
Grid1.NewFile()
|
||
Grid1.Rows = 1
|
||
Grid1.Cols = 3
|
||
Grid1.ExtendLastCol = True
|
||
Grid1.Column(0).Visible = True
|
||
Grid1.Cell(0, 1).Text = "Loop type"
|
||
Grid1.Cell(0, 2).Text = "Loop alias"
|
||
Grid1.Column(1).Locked = True
|
||
Grid1.Column(2).Locked = True
|
||
Grid1.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
Grid1.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
Normal_AddGrid1RowDragDrop2(li)
|
||
End Sub
|
||
Private Sub Normal_AddGrid1RowDragDrop2(li As List(Of DeviceChildNodeClass))
|
||
For Each devnade In li
|
||
For i = 0 To devnade.Nodes.Count - 1
|
||
Dim Index = devnade.Nodes(i)
|
||
Grid1.AddItem("")
|
||
Grid1.Cell(Grid1.Rows - 1, 2).Text = Index.DefaultAliasName
|
||
Grid1.Cell(Grid1.Rows - 1, 1).Text = $"{devnade.Name }*{ Index.LoopAddr}"
|
||
|
||
Next
|
||
|
||
Next
|
||
|
||
End Sub
|
||
|
||
Public Shared Function GetDescriptionOriginal(ByVal this As [Enum]) As String
|
||
Dim name = this.ToString()
|
||
Dim field = this.[GetType]().GetField(name)
|
||
If field Is Nothing Then Return name
|
||
Dim att = System.Attribute.GetCustomAttribute(field, GetType(DescriptionAttribute), False)
|
||
Return If(att Is Nothing, field.Name, (CType(att, DescriptionAttribute)).Description)
|
||
End Function
|
||
Public Sub Normal_initTable()
|
||
|
||
Table_Grid1.NewFile()
|
||
Table_Grid1.Rows = 1
|
||
Table_Grid1.Cols = Tcolname.max
|
||
Table_Grid1.ExtendLastCol = True
|
||
For i = 0 To Tcolname.max - 1
|
||
Table_Grid1.Cell(0, i).Text = GetDescriptionOriginal(CType(i, Tcolname)) ' [Enum].GetName(GetType(Tcolname), i)
|
||
Console.WriteLine( Table_Grid1.Cell(0, i).Text)
|
||
Select Case i
|
||
Case Tcolname.输入序号
|
||
With Table_Grid1.Column(i)
|
||
.Width = 50
|
||
'.Visible = True
|
||
.Locked = True
|
||
End With
|
||
|
||
Case Tcolname.按键别名
|
||
With Table_Grid1.Column(i)
|
||
.Width = 200
|
||
.Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Locked = True
|
||
End With
|
||
Case Tcolname.按键反馈灯
|
||
With Table_Grid1.Column(i)
|
||
.Width = 50
|
||
.Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
'.Locked = True
|
||
.CellType = CellTypeEnum.ComboBox
|
||
End With
|
||
Table_Grid1.ComboBox(i).Locked = True
|
||
Case Else
|
||
Exit For
|
||
End Select
|
||
|
||
Next
|
||
|
||
Normal_AddGrid1RowDragDrop()
|
||
End Sub
|
||
|
||
Public Sub NoCard_initTable()
|
||
|
||
Table_Grid1.NewFile()
|
||
Table_Grid1.Rows = 1
|
||
Table_Grid1.Cols = 2
|
||
Table_Grid1.ExtendLastCol = True
|
||
|
||
|
||
With Table_Grid1
|
||
.Column(0).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(0).Width = 350
|
||
.Column(1).Width = 200
|
||
.Column(1).CellType = CellTypeEnum.ComboBox
|
||
.Column(0).Locked = True
|
||
.ComboBox(1).Locked = True
|
||
.Cell(0, 0).Text = "Loop alias"
|
||
.Cell(0, 1).Text = "Mapping loop"
|
||
|
||
End With
|
||
NoCard_AddGrid1RowDragDrop()
|
||
|
||
End Sub
|
||
|
||
|
||
Private Normal_Do_li As List(Of String)
|
||
Private Sub Normal_AddGrid1RowDragDrop()
|
||
|
||
Normal_Do_li = New List(Of String)
|
||
If Not IsNothing(Resultmodel) Then
|
||
Dim li As New List(Of DeviceChildNodeClass)
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
|
||
If ModuleFre.Name.Equals("Dimming") Then
|
||
If ModuleFre.Nodes.Count > 0 Then
|
||
li.Add(ModuleFre)
|
||
End If
|
||
|
||
ElseIf ModuleFre.Name.Equals("RELAY") Then
|
||
If ModuleFre.Nodes.Count > 0 Then
|
||
li.Add(ModuleFre)
|
||
End If
|
||
ElseIf ModuleFre.Name.Equals("DI") Then
|
||
If ModuleFre.Nodes.Count > 0 Then
|
||
ComboBox1.Visible = True
|
||
Label6.Visible = True
|
||
Table_Grid1.Visible = True
|
||
SplitContainer4.Panel1Collapsed = False
|
||
End If
|
||
For Each index In ModuleFre.Nodes
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = index.LoopAddr
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = index.DefaultAliasName
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = index.LoopAddr
|
||
Next
|
||
|
||
ElseIf ModuleFre.Name.Equals("SLIDER") Then
|
||
If ModuleFre.Nodes.Count > 0 Then
|
||
li.Add(ModuleFre)
|
||
End If
|
||
ElseIf ModuleFre.Name.Equals("DO") Then
|
||
For Each index In ModuleFre.Nodes
|
||
Normal_Do_li.Add(index.LoopAddr)
|
||
Next
|
||
ComboBox1.Items.AddRange(Normal_Do_li.ToArray)
|
||
ComboBox1.SelectedIndex = ComboBox1.Items.Count - 1
|
||
End If
|
||
Next
|
||
If li.Count > 0 Then
|
||
If Table_Grid1.Rows > 1 Then
|
||
SplitContainer5.Panel1Collapsed = False
|
||
Else
|
||
SplitContainer5.Panel1Collapsed = True
|
||
End If
|
||
SplitContainer5.Panel2Collapsed = False
|
||
Normal_initTable2(li)
|
||
End If
|
||
|
||
|
||
End If
|
||
End Sub
|
||
|
||
|
||
Private Sub Normal_SetIDOpenDO(rvdicv As Dictionary(Of String, String))
|
||
If IsNothing(rvdicv) OrElse rvdicv.Count = 0 Then Return
|
||
If Not IsNothing(Resultmodel) Then
|
||
Table_Grid1.Column(Tcolname.按键别名).Locked = True
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
If rvdicv.ContainsKey(Table_Grid1.Cell(i, Tcolname.输入序号).Text.Trim) Then
|
||
Table_Grid1.Cell(i, Tcolname.按键反馈灯).Text = rvdicv.Item(Table_Grid1.Cell(i, Tcolname.输入序号).Text.Trim)
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
End Sub
|
||
|
||
|
||
|
||
#End Region
|
||
|
||
#Region "CURTAIN"
|
||
Private Sub Tx_BindingRelay(dic As Dictionary(Of String, String))
|
||
Dim olddic As Dictionary(Of String, String)
|
||
Try
|
||
olddic = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(Resultmodel.Desc.ProtocolData)
|
||
Catch ex As Exception
|
||
olddic = Nothing
|
||
Console.WriteLine($"{ex.Message }")
|
||
End Try
|
||
|
||
'解绑
|
||
If Not IsNothing(olddic) AndAlso olddic.Count > 0 Then
|
||
For Each node In olddic
|
||
If g_DevRELAYrow.ContainsKey(node.Value) AndAlso g_grd.Cols > g_DevRELAYrow.Item(node.Value) Then
|
||
g_grd.Column(g_DevRELAYrow.Item(node.Value)).Locked = False
|
||
g_grd.Column(g_DevRELAYrow.Item(node.Value)).Visible = True
|
||
|
||
End If
|
||
If g_Devinfraredrow.ContainsKey(node.Value) AndAlso g_grd.Cols > g_Devinfraredrow.Item(node.Value) Then
|
||
g_grd.Column(g_Devinfraredrow.Item(node.Value)).Locked = False
|
||
g_grd.Column(g_Devinfraredrow.Item(node.Value)).Visible = True
|
||
End If
|
||
|
||
Next
|
||
End If
|
||
'绑定
|
||
For Each node In dic
|
||
If g_DevRELAYrow.ContainsKey(node.Key) AndAlso g_grd.Cols > g_DevRELAYrow.Item(node.Key) Then
|
||
'g_grd.Column(g_DevRELAYrow.Item(node.Key)).Locked = True
|
||
g_grd.Column(g_DevRELAYrow.Item(node.Key)).Visible = False
|
||
g_grd.Range(TableInteraction.TableRowNumber.Max, g_DevRELAYrow.Item(node.Key), g_grd.Rows - 1, g_DevRELAYrow.Item(node.Key)).ClearText()
|
||
Console.WriteLine(g_grd.Cell(8, g_DevRELAYrow.Item(node.Key)).Text)
|
||
'g_grd.Column(g_DevRELAYrow.Item(node.Key)).Locked = True
|
||
g_grd.Range(TableInteraction.TableRowNumber.Max, g_DevRELAYrow.Item(node.Key), g_grd.Rows - 1, g_DevRELAYrow.Item(node.Key)).ForeColor = Color.Black
|
||
|
||
End If
|
||
If g_Devinfraredrow.ContainsKey(node.Key) AndAlso g_grd.Cols > g_Devinfraredrow.Item(node.Key) Then
|
||
' g_grd.Column(g_Devinfraredrow.Item(node.Key)).Locked = True
|
||
g_grd.Column(g_Devinfraredrow.Item(node.Key)).Visible = False
|
||
End If
|
||
Next
|
||
End Sub
|
||
Private Sub BindingRelay(dic As Dictionary(Of String, String))
|
||
|
||
Dim oldbuf() As String = Resultmodel.Desc.ProtocolData.Split(",")
|
||
'解绑
|
||
If Not IsNothing(oldbuf) AndAlso Resultmodel.Desc.ProtocolData.Contains("*") Then 'oldbuf.Length > 1 Then
|
||
For Each node In oldbuf
|
||
Dim oldcbuf() As String = node.Split("*")
|
||
Dim buf As String = $"{oldcbuf(0)}*{oldcbuf(1)}*{oldcbuf(2)}"
|
||
If g_DevRELAYrow.ContainsKey(buf) AndAlso g_grd.Cols > g_DevRELAYrow.Item(buf) Then
|
||
g_grd.Column(g_DevRELAYrow.Item(buf)).Locked = False
|
||
g_grd.Column(g_DevRELAYrow.Item(buf)).Visible = True
|
||
End If
|
||
Next
|
||
End If
|
||
'绑定
|
||
For Each node In dic
|
||
If g_DevRELAYrow.ContainsKey(node.Key) AndAlso g_grd.Cols > g_DevRELAYrow.Item(node.Key) Then
|
||
|
||
g_grd.Column(g_DevRELAYrow.Item(node.Key)).Visible = False
|
||
g_grd.DrawMode = DrawModeEnum.Normal
|
||
g_grd.Range(TableInteraction.TableRowNumber.Max, g_DevRELAYrow.Item(node.Key), g_grd.Rows - 1, g_DevRELAYrow.Item(node.Key)).ClearText()
|
||
Console.WriteLine(g_grd.Cell(8, g_DevRELAYrow.Item(node.Key)).Text)
|
||
' g_grd.Column(g_DevRELAYrow.Item(node.Key)).Locked = True
|
||
g_grd.Range(TableInteraction.TableRowNumber.Max, g_DevRELAYrow.Item(node.Key), g_grd.Rows - 1, g_DevRELAYrow.Item(node.Key)).ForeColor = Color.Black
|
||
g_grd.DrawMode = DrawModeEnum.Normal
|
||
End If
|
||
Next
|
||
End Sub
|
||
|
||
Public Sub CURTAIN_initTable(li As List(Of String))
|
||
Table_Grid1.NewFile()
|
||
Table_Grid1.Rows = li.Count + 1
|
||
Table_Grid1.Cols = 5
|
||
Table_Grid1.ExtendLastCol = True
|
||
Table_Grid1.Range(0, 0, Table_Grid1.Rows - 1, Table_Grid1.Cols - 1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
For i = 0 To li.Count
|
||
|
||
If i = 0 Then
|
||
Table_Grid1.Cell(i, 1).Text = "Relay description"
|
||
Table_Grid1.Cell(i, 2).Text = "relay"
|
||
Table_Grid1.Cell(i, 3).Text = "delay"
|
||
Table_Grid1.Cell(i, 4).Text = "Delay unit"
|
||
Table_Grid1.Column(1).Locked = True
|
||
Table_Grid1.Column(4).Locked = True
|
||
Table_Grid1.Column(2).CellType = CellTypeEnum.ComboBox
|
||
Table_Grid1.ComboBox(2).Locked = True
|
||
Table_Grid1.Column(2).Width = 450
|
||
Table_Grid1.Column(3).CellType = CellTypeEnum.ComboBox
|
||
'Table_Grid1.ComboBox(3).Locked = True
|
||
Continue For
|
||
Else
|
||
Table_Grid1.Cell(i, 1).Text = li.Item(i - 1)
|
||
End If
|
||
Table_Grid1.Cell(i, 4).Text = "seconds"
|
||
Next
|
||
|
||
|
||
End Sub
|
||
|
||
Private Sub Temp_Grid_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs) Handles Temp_Grid.ComboDropDown
|
||
Temp_Grid.ComboBox(e.Col).Items.Clear()
|
||
Temp_Grid.ComboBox(e.Col).Items.Add("")
|
||
Select Case e.Row
|
||
Case 1
|
||
If Not IsNothing(g_Devinfraredrow) OrElse g_Devinfraredrow.Count > 0 Then
|
||
For Each nodex In g_Devinfraredrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, nodex).Text
|
||
g_grd.Row(TableInteraction.TableRowNumber.FunctionChildNodeAnother).Visible = True
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, nodex)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
Temp_Grid.ComboBox(e.Col).Items.Add(Anostr)
|
||
Next
|
||
End If
|
||
Return
|
||
Case 2
|
||
If Not IsNothing(g_Devintemp) OrElse g_Devintemp.Count > 0 Then
|
||
For Each nodex In g_Devintemp.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, nodex).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, nodex)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
Temp_Grid.ComboBox(e.Col).Items.Add(Anostr)
|
||
Next
|
||
End If
|
||
Return
|
||
Case Else
|
||
If Not IsNothing(g_DevRELAYrow) OrElse g_DevRELAYrow.Count > 0 Then
|
||
For Each nodex In g_DevRELAYrow.Values
|
||
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, nodex).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, nodex)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
Temp_Grid.ComboBox(e.Col).Items.Add(Anostr)
|
||
Next
|
||
End If
|
||
Return
|
||
|
||
End Select
|
||
|
||
End Sub
|
||
Private IsTemp_GridCellChange As Boolean = True
|
||
Private Sub Temp_Grid_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles Temp_Grid.CellChange
|
||
If IsTemp_GridCellChange Then
|
||
Dim redstrin As String = Temp_Grid.Cell(1, 2).Text.Trim
|
||
'If String.IsNullOrEmpty(redstrin) Then
|
||
' 'For i = Temproweven.冷阈开 To Temproweven.max - 1
|
||
' ' 'Temp_Grid.Cell(i, 2).Locked = False
|
||
' 'Next
|
||
'Else
|
||
' IsTemp_GridCellChange = False
|
||
' For i = Temproweven.冷阈开 To Temproweven.max - 1
|
||
' Temp_Grid.Cell(i, 2).Text = ""
|
||
' 'Temp_Grid.Cell(i, 2).Locked = True
|
||
' Next
|
||
' IsTemp_GridCellChange = True
|
||
'End If
|
||
|
||
|
||
|
||
End If
|
||
|
||
End Sub
|
||
|
||
#End Region
|
||
|
||
|
||
|
||
#Region "语音"
|
||
Private Sub Voice_InitTable()
|
||
Table_Grid1.NewFile()
|
||
Table_Grid1.DrawMode = DrawModeEnum.OwnerDraw
|
||
Table_Grid1.Rows = 1
|
||
Table_Grid1.Cols = 5
|
||
Table_Grid1.ExtendLastCol = True
|
||
Table_Grid1.Range(0, 0, 0, 0).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
With Table_Grid1
|
||
.Cell(0, 1).Text = "Glossary panel"
|
||
.Cell(0, 2).Text = "Glossary"
|
||
.Cell(0, 3).Text = "Device type"
|
||
.Cell(0, 4).Text = "Device name"
|
||
.Column(1).Locked = True
|
||
.Column(2).Locked = True
|
||
.Column(2).Visible = False
|
||
.Column(1).Width = 320
|
||
.Column(2).Width = 120
|
||
.Column(3).Visible = False
|
||
.Column(4).Width = 120
|
||
.Column(4).CellType = CellTypeEnum.ComboBox
|
||
.ComboBox(4).Locked = True
|
||
End With
|
||
Voice_FillInTable()
|
||
End Sub
|
||
Private VoiceNode_Dic As Dictionary(Of String, List(Of String))
|
||
Private Sub Voice_FillInTable()
|
||
VoiceNode_Dic = New Dictionary(Of String, List(Of String))
|
||
For Each node In Resultmodel.Config
|
||
|
||
If node.CFG_Type.Equals("XiaoBaoCMD") Then
|
||
Dim li As New List(Of String)
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Row(Table_Grid1.Rows - 1).Locked = True
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = node.Name
|
||
For Each Cnode In node.Attributes
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = Cnode.Name
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Tag = node.Name
|
||
li.Add(Cnode.Name)
|
||
If Voice_Isinteninthe(node.Name, Cnode.DataRangeValue) Then
|
||
If g_Devservice.ContainsKey(Cnode.DataRangeValue) Then
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Text = Cnode.DataRangeValue
|
||
Continue For
|
||
End If
|
||
If g_DevScenenumber.ContainsKey(Cnode.DataRangeValue) Then
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Text = Cnode.DataRangeValue
|
||
Continue For
|
||
End If
|
||
|
||
For Each index In g_ColumnAnothername
|
||
If index.Value.Equals(Cnode.DataRangeValue) Then
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Text = index.Key
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
VoiceNode_Dic.Add(node.Name, li)
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
End Sub
|
||
Private Function Voice_Isinteninthe(fnoe As String, keystr As String) As Boolean
|
||
' g_grd
|
||
Dim result As Boolean = False
|
||
If String.IsNullOrEmpty(keystr) Then Return result
|
||
' Select Case fnoe
|
||
'Case "0 场景"
|
||
'result = g_DevScenenumber.ContainsKey(keystr)
|
||
If Not result Then
|
||
result = g_DevScenenumber.ContainsKey(keystr)
|
||
End If
|
||
' Case "1 继电器"
|
||
If Not result Then
|
||
result = g_DevRELAYrow.ContainsKey(keystr)
|
||
End If
|
||
|
||
If Not result Then
|
||
result = g_DevDimming.ContainsKey(keystr)
|
||
End If
|
||
' Case "4 服务信息"
|
||
'result = g_Devservice.ContainsKey(keystr)
|
||
If Not result Then
|
||
result = g_Devservice.ContainsKey(keystr)
|
||
End If
|
||
|
||
' Case "5 窗帘"
|
||
If Not result Then
|
||
result = g_DevinCURTAINdrow.ContainsKey(keystr)
|
||
End If
|
||
|
||
If Not result Then
|
||
result = g_Devin485fraredrow.ContainsKey(keystr)
|
||
End If
|
||
' Case "7 空调"
|
||
If Not result Then
|
||
result = g_Devintemp.ContainsKey(keystr)
|
||
End If
|
||
|
||
' Case "15 电视"
|
||
If Not result Then
|
||
result = g_Devinfraredrow.ContainsKey(keystr)
|
||
End If
|
||
' Case "16 调光"
|
||
If Not result Then
|
||
result = g_DevDimming.ContainsKey(keystr)
|
||
End If
|
||
'Case "18 灯带"
|
||
If Not result Then
|
||
result = g_DevDimming.ContainsKey(keystr)
|
||
End If
|
||
' Case "21 音乐"
|
||
' End Select
|
||
Return result
|
||
End Function
|
||
Private Function Voice_SelectDropdownItem(keystr As String, ecol As Integer) As List(Of String)
|
||
' g_grd
|
||
Dim li As New List(Of String)
|
||
'Select Case keystr
|
||
' Case "0 场景"
|
||
For Each node In g_DevScenenumber
|
||
li.Add($"{node.Key }")
|
||
Next
|
||
' Case "1 继电器"
|
||
For Each node In g_DevRELAYrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
For Each node In g_DevDimming.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
' Case "4 服务信息"
|
||
|
||
For Each node In g_Devservice
|
||
'Dim Anostr = g_grd.Cell(node, TableInteraction.TableColNumber.KeyVal).Text
|
||
'If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
'Dim gdevname = New CtabRange(g_grd, node, TableInteraction.TableColNumber.DeviceName)
|
||
'Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{node.Key }")
|
||
Next
|
||
' resulrdic.Add($"{hostname }*{_grd.Cell(i, TableColNumber.KeyVal).Text }*HOSTSERVICE", i)
|
||
|
||
' Case "5 窗帘"
|
||
|
||
For Each node In g_DevinCURTAINdrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
For Each node In g_Devin485fraredrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
' Case "7 空调"
|
||
For Each node In g_Devintemp.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
' Case "15 电视"
|
||
|
||
For Each node In g_Devinfraredrow.Values
|
||
Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
Anostr = $"{gdevname.devname}_{Anostr}"
|
||
li.Add($"{Anostr}")
|
||
Next
|
||
' Case "16 调光"
|
||
'For Each node In g_DevDimming.Values
|
||
' Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
' If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
' Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
' Anostr = $"{gdevname.devname}_{Anostr}"
|
||
' li.Add($"{Anostr}")
|
||
'Next
|
||
' Case "18 灯带"
|
||
'For Each node In g_DevDimming.Values
|
||
' Dim Anostr = g_grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeAnother, node).Text
|
||
' If String.IsNullOrEmpty(Anostr) Then Continue For
|
||
' Dim gdevname = New CtabRange(g_grd, TableInteraction.TableRowNumber.DeviceName, node)
|
||
' Anostr = $"{gdevname.devname}_{Anostr}"
|
||
' li.Add($"{Anostr}")
|
||
'Next
|
||
'' Case "21 音乐"
|
||
'End Select
|
||
Return li
|
||
End Function
|
||
Private Sub Table_Grid1_OwnerDrawCell(Sender As Object, e As Grid.OwnerDrawCellEventArgs) Handles Table_Grid1.OwnerDrawCell
|
||
If e.Row < 1 OrElse e.Col <> 1 Then Return
|
||
|
||
Dim i, j As Integer
|
||
Dim blnDrawLine As Boolean
|
||
Dim node, tmpNode As RowNode
|
||
Dim intLevel As Integer
|
||
Dim intWidth As Integer
|
||
Dim intAdd As Integer
|
||
|
||
'判断是否为集合
|
||
If VoiceNode_Dic.ContainsKey(Table_Grid1.Cell(e.Row, e.Col).Text) Then
|
||
intWidth = 10
|
||
intAdd = 6
|
||
Else
|
||
intWidth = 20
|
||
intAdd = 26
|
||
End If
|
||
|
||
'画树线
|
||
Dim pen As New System.Drawing.Pen(Color.CornflowerBlue, 1)
|
||
|
||
Try
|
||
pen.DashStyle = Drawing2D.DashStyle.Solid
|
||
|
||
|
||
|
||
If intWidth = 10 AndAlso VoiceNode_Dic.Item(Table_Grid1.Cell(e.Row, e.Col).Text).Count > 0 Then
|
||
'+/-
|
||
Dim rect As New Rectangle(e.Bounds.Left + 2 + intLevel * intWidth, CInt(e.Bounds.Top + (e.Bounds.Height - 9) / 2), 8, 8)
|
||
e.Graphics.FillRectangle(Brushes.White, rect)
|
||
e.Graphics.DrawRectangle(Pens.Black, rect)
|
||
If e.Row + 1 < Table_Grid1.Rows AndAlso Table_Grid1.Row(e.Row + 1).Visible = False Then
|
||
e.Graphics.DrawLine(Pens.Black, rect.Left + 2, rect.Top + 4, rect.Right - 2, rect.Top + 4)
|
||
e.Graphics.DrawLine(Pens.Black, rect.Left + 4, rect.Top + 2, rect.Left + 4, rect.Bottom - 2)
|
||
Else
|
||
e.Graphics.DrawLine(Pens.Black, rect.Left + 2, rect.Top + 4, rect.Right - 2, rect.Top + 4)
|
||
'e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2) + 7, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1))
|
||
e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1))
|
||
|
||
End If
|
||
|
||
Else
|
||
'上半部分
|
||
e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + 10 * i + 6), CInt(e.Bounds.Top - 1), CInt(e.Bounds.Left + 10 * i + 6), CInt(e.Bounds.Top + e.Bounds.Height / 2))
|
||
|
||
If e.Row + 1 < Table_Grid1.Rows AndAlso Not VoiceNode_Dic.ContainsKey(Table_Grid1.Cell(e.Row + 1, e.Col).Text) Then
|
||
'下半部分
|
||
e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + 10 * i + 6), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + 10 * i + 6), CInt(e.Bounds.Bottom + 1))
|
||
End If
|
||
|
||
'水平的
|
||
e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd + 10), CInt(e.Bounds.Top + e.Bounds.Height / 2))
|
||
|
||
End If
|
||
'文字
|
||
Dim bColor As New SolidBrush(Table_Grid1.Cell(e.Row, e.Col).ForeColor)
|
||
If bColor.Color.A = 0 Then bColor.Color = Color.Black
|
||
With Table_Grid1.Cell(e.Row, e.Col)
|
||
If intWidth = 10 Then
|
||
Dim ft = New Font(.Font, FontStyle.Bold)
|
||
e.Graphics.DrawString(.Text, ft, bColor, e.Bounds.Left + intWidth * intLevel + 12, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 1)
|
||
Else
|
||
e.Graphics.DrawString(.Text, .Font, bColor, e.Bounds.Left + intWidth * intLevel + 15, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 1)
|
||
End If
|
||
End With
|
||
|
||
|
||
Catch ex As Exception
|
||
|
||
End Try
|
||
|
||
e.Handled = True
|
||
End Sub
|
||
|
||
Private Sub Table_Grid1_Click(Sender As Object, e As EventArgs) Handles Table_Grid1.Click
|
||
|
||
If g_DevType = FromDevType.Voice Then
|
||
Try
|
||
Dim point As Point = Table_Grid1.PointToClient(System.Windows.Forms.Cursor.Position)
|
||
|
||
Dim cel As Cell = Table_Grid1.HitTest(point.X, point.Y)
|
||
|
||
If cel Is Nothing Then Return
|
||
|
||
|
||
If cel.Row < 1 OrElse cel.Col <> 1 Then Return
|
||
|
||
If Not VoiceNode_Dic.ContainsKey(Table_Grid1.Cell(cel.Row, cel.Col).Text) Then Return
|
||
Dim intWidth As Integer = 10
|
||
Dim rect As New Rectangle(cel.Bounds.Left + 2, cel.Bounds.Top + ((cel.Bounds.Height - 9) \ 2), 8, 8)
|
||
If rect.Contains(point) = False Then Return
|
||
|
||
Dim li As List(Of String) = VoiceNode_Dic.Item(Table_Grid1.Cell(cel.Row, cel.Col).Text)
|
||
For i As Integer = 0 To li.Count - 1
|
||
Table_Grid1.Row(cel.Row + 1 + i).Visible = Not Table_Grid1.Row(cel.Row + 1 + i).Visible
|
||
Next
|
||
|
||
Table_Grid1.Refresh()
|
||
|
||
Catch ex As Exception
|
||
Console.WriteLine($"Grid_Click Error:{ex.Message}")
|
||
End Try
|
||
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Private Sub Grid1_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles Grid1.CellChange
|
||
If e.Row > 0 Then
|
||
Dim Strarry() As String = Grid1.Cell(e.Row, 1).Text.Split("*")
|
||
If IsNothing(Resultmodel) Then Return
|
||
For Each node In Resultmodel.Nodes
|
||
If node.Name.Equals(Strarry(0)) Then
|
||
For Each index In node.Nodes
|
||
If index.LoopAddr.Equals(Strarry(1)) Then
|
||
index.DefaultAliasName = Grid1.Cell(e.Row, 2).Text
|
||
End If
|
||
Next
|
||
Exit For
|
||
Else
|
||
Continue For
|
||
End If
|
||
Next
|
||
|
||
|
||
|
||
|
||
End If
|
||
End Sub
|
||
|
||
|
||
|
||
#End Region
|
||
|
||
|
||
#Region "FreshAir"
|
||
|
||
Public Sub FreshAirInitTable(li As List(Of String))
|
||
With Table_Grid1
|
||
.NewFile()
|
||
'Table_Grid1.DrawMode = DrawModeEnum.OwnerDraw
|
||
.Rows = 1
|
||
.Cols = 3
|
||
Table_Grid1.ExtendLastCol = True
|
||
.Range(0, 0, 0, 0).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(2).CellType = CellTypeEnum.ComboBox
|
||
.Cell(0, 1).Text = "Relay description"
|
||
.Cell(0, 2).Text = "relay"
|
||
.Column(1).Locked = True
|
||
.Column(0).Visible = True
|
||
.Column(1).Width = 120
|
||
.Column(2).Width = 120
|
||
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
|
||
End With
|
||
|
||
FreshAirTableAddRow(li)
|
||
|
||
End Sub
|
||
Public Sub FreshAirTableAddRow(li As List(Of String))
|
||
For Each index In li
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = index
|
||
Next
|
||
|
||
End Sub
|
||
Private Sub FreshAir_SetIDOpenDO()
|
||
If Not IsNothing(g_DevRELAYrow) AndAlso g_DevRELAYrow.Count > 0 AndAlso Not String.IsNullOrEmpty(Resultmodel.Desc.ProtocolData) Then
|
||
Dim buf() As String = Resultmodel.Desc.ProtocolData.Split(",")
|
||
For i = 0 To buf.Length - 1
|
||
Dim cbuf() As String = buf(i).Split("*")
|
||
Dim skey As String = $"{cbuf(0)}*{cbuf(1)}*{cbuf(2)}"
|
||
|
||
For Each index In g_ColumnAnothername
|
||
If index.Value.Equals(skey) Then
|
||
Table_Grid1.Cell(i + 1, 2).Text = index.Key
|
||
|
||
If cbuf.Length > 3 Then
|
||
Table_Grid1.Cell(i + 1, 3).Text = cbuf(3)
|
||
End If
|
||
Exit For
|
||
End If
|
||
Next
|
||
|
||
Next
|
||
End If
|
||
End Sub
|
||
|
||
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
|
||
CheckBox3.Checked = CheckBox2.Checked
|
||
|
||
End Sub
|
||
|
||
Private Sub FdevtypeCom_SelectedIndexChanged(sender As Object, e As EventArgs) Handles FdevtypeCom.SelectedIndexChanged
|
||
SetPowerThresholdconfig(Resultmodel, "Parent device type", FdevtypeCom.Text)
|
||
End Sub
|
||
|
||
Private Sub FdevPortCom_SelectedIndexChanged(sender As Object, e As EventArgs) Handles FdevPortCom.SelectedIndexChanged
|
||
SetPowerThresholdconfig(Resultmodel, "Parent device port", FdevPortCom.Text)
|
||
End Sub
|
||
|
||
Private Sub FdevPortText_SelectedIndexChanged(sender As Object, e As EventArgs) Handles FdevPortText.SelectedIndexChanged
|
||
SetPowerThresholdconfig(Resultmodel, "Parent device address", FdevPortText.Text)
|
||
End Sub
|
||
|
||
|
||
|
||
|
||
|
||
Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.CheckedChanged
|
||
If CheckBox6.Checked Then
|
||
SetPowerThresholdconfig(Resultmodel, "Valveless machine", 1)
|
||
Else
|
||
SetPowerThresholdconfig(Resultmodel, "Valveless machine", 0)
|
||
End If
|
||
|
||
End Sub
|
||
Public IsColorTemp As Boolean
|
||
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
|
||
'判断是否为特定类型
|
||
If g_DevType = FromDevType.Dev_ColorTemp Then
|
||
Dim vl As Integer = 0
|
||
Integer.TryParse(ComboBox1.Text, vl)
|
||
For i = 1 To Table_Grid1.Rows - 1
|
||
Dim v2 As Integer = -1
|
||
Integer.TryParse(Table_Grid1.Cell(i, 0).Text, v2)
|
||
If v2 <= vl Then
|
||
Table_Grid1.Row(i).Visible = True
|
||
Else
|
||
Table_Grid1.Row(i).Visible = False
|
||
End If
|
||
Next
|
||
End If
|
||
End Sub
|
||
|
||
|
||
Private Sub initGrid()
|
||
IsColorTemp = False
|
||
Table_Grid1.Visible = False
|
||
Table_Grid1.AutoRedraw = False
|
||
With Table_Grid1
|
||
.NewFile()
|
||
'Table_Grid1.DrawMode = DrawModeEnum.OwnerDraw
|
||
.Rows = 1
|
||
.Cols = 7
|
||
Table_Grid1.ExtendLastCol = True
|
||
.Range(0, 0, 0, 0).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(2).CellType = CellTypeEnum.ComboBox
|
||
.Column(3).CellType = CellTypeEnum.ComboBox
|
||
.Column(4).CellType = CellTypeEnum.ComboBox
|
||
.Column(5).CellType = CellTypeEnum.ComboBox
|
||
.Cell(0, 1).Text = "Color temperature loop"
|
||
.Cell(0, 2).Text = "Color temperature loop type"
|
||
.Cell(0, 3).Text = "Device type"
|
||
.Cell(0, 4).Text = "Device address"
|
||
.Cell(0, 5).Text = "Equipment loop"
|
||
.Cell(0, 6).Text = "Loop name"
|
||
.ComboBox(2).Locked = True
|
||
.ComboBox(3).Locked = True
|
||
.ComboBox(4).Locked = True
|
||
.ComboBox(5).Locked = True
|
||
.Column(6).Locked = True
|
||
.Column(1).Locked = True
|
||
.Column(0).Visible = False
|
||
'.Column(3).Locked = True
|
||
'.Column(4).Locked = True
|
||
'.Column(5).Locked = True
|
||
.Column(1).Width = 230
|
||
.Column(2).Width = 230
|
||
.Column(3).Width = 180
|
||
.Column(4).Width = 180
|
||
.Column(5).Width = 200
|
||
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(3).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(4).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(5).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
.Column(6).Alignment = FlexCell.AlignmentEnum.CenterCenter
|
||
End With
|
||
|
||
For Each node In Resultmodel.Nodes
|
||
For i = 1 To node.Nodes.Count
|
||
Dim Index = node.Nodes(i - 1)
|
||
If Index.DefaultClass.Equals("Dev_ColorTemp") Then
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Row(Table_Grid1.Rows - 1).Visible = False
|
||
Dim spbuf() As String = Nothing
|
||
If Not String.IsNullOrEmpty(Index.DefaultAliasName) Then
|
||
spbuf = Index.DefaultAliasName.Split(",")
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = spbuf(0)
|
||
Else
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = Index.Name
|
||
End If
|
||
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = i
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 3, Table_Grid1.Rows - 1, 5).Merge()
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 1, Table_Grid1.Rows - 1, 6).BackColor = Color.Gray
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 3, Table_Grid1.Rows - 1, 5).Locked = True
|
||
|
||
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 0, Table_Grid1.Rows - 1, 1).Locked = True
|
||
If Not IsNothing(spbuf) AndAlso spbuf.Length = 2 Then
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = spbuf(1)
|
||
If Not String.IsNullOrEmpty(Index.Description) Then
|
||
Dim li As List(Of List(Of String)) = JsonConvert.DeserializeObject(Of List(Of List(Of String)))(Index.Description)
|
||
For Each linode In li
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 1, Table_Grid1.Rows - 1, 2).BackColor = Color.LightGray
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 0, Table_Grid1.Rows - 1, 2).Locked = True
|
||
Table_Grid1.Row(Table_Grid1.Rows - 1).Visible = False
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = i
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 5).Tag = linode(3)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Tag = linode(4)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 3).Text = linode(0)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 4).Text = linode(1)
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 5).Text = linode(2)
|
||
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 6).Text = linode(5)
|
||
Next
|
||
End If
|
||
Else
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = "1: two-way mixed light (a line 2 line with warm color cool color)"
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 1, Table_Grid1.Rows - 1, 2).BackColor = Color.LightGray
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 0, Table_Grid1.Rows - 1, 2).Locked = True
|
||
Table_Grid1.Row(Table_Grid1.Rows - 1).Visible = False
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = i
|
||
Table_Grid1.AddItem("")
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 1, Table_Grid1.Rows - 1, 2).BackColor = Color.LightGray
|
||
Table_Grid1.Range(Table_Grid1.Rows - 1, 0, Table_Grid1.Rows - 1, 2).Locked = True
|
||
Table_Grid1.Row(Table_Grid1.Rows - 1).Visible = False
|
||
Table_Grid1.Cell(Table_Grid1.Rows - 1, 0).Text = i
|
||
End If
|
||
|
||
End If
|
||
Next
|
||
Next
|
||
Table_Grid1.AutoRedraw = True
|
||
Table_Grid1.Visible = True
|
||
IsColorTemp = True
|
||
End Sub
|
||
|
||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||
SplitContainer6.Panel1Collapsed = Not SplitContainer6.Panel1Collapsed
|
||
End Sub
|
||
|
||
Private Sub TextBox3_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox3.KeyPress
|
||
e.Handled = True
|
||
'输入0-9
|
||
If e.KeyChar = vbBack OrElse (Asc(e.KeyChar) >= 32 AndAlso Asc(e.KeyChar) <= 126) Then
|
||
e.Handled = False
|
||
End If
|
||
End Sub
|
||
|
||
|
||
#End Region
|
||
|
||
|
||
|
||
End Class |