7036 lines
335 KiB
VB.net
7036 lines
335 KiB
VB.net
Imports System.ComponentModel
|
||
Imports System.IO
|
||
Imports System.Net
|
||
Imports BLV_Studio.EnumExtend
|
||
Imports BLV_Studio.GridModel.DeviceEventModel
|
||
Imports FlexCell
|
||
Imports Newtonsoft.Json
|
||
|
||
Public Class TableInteraction
|
||
#Region "全局变量"
|
||
Public _isVisible_Attributes As Boolean = True
|
||
Public _isVisible_Port As Boolean = True
|
||
Public _isVisible_Action As Boolean = True
|
||
Public _isVisible_Scenes As Boolean = True
|
||
Public _isVisible_Conditions As Boolean = True
|
||
''' <summary>
|
||
''' RCU设备名
|
||
''' </summary>
|
||
Public _RcuModelName As String = ""
|
||
Public Property AliasEncoding As Text.Encoding
|
||
''' <summary>刷新锁计数</summary>
|
||
Private _autoRedraw As Integer
|
||
''' <summary>进度条 控件</summary>
|
||
Public _tsp As ToolStripProgressBar
|
||
|
||
''' <summary>表格控件</summary>
|
||
Public _grd As FlexCell.Grid
|
||
''' <summary>条件文件名</summary>
|
||
Public ConditionFileName As String
|
||
''' <summary>
|
||
''' 设备对象基类信息
|
||
''' </summary>
|
||
''' <returns></returns>
|
||
Public Property BasicClasses As DeviceObjectClasses
|
||
''' <summary>基类文件名</summary>
|
||
Public BasicClassFilename As String
|
||
|
||
''' <summary>
|
||
''' 条件
|
||
''' </summary>
|
||
''' <returns></returns>
|
||
Public Property Condictions As ConfigActionConcitons
|
||
|
||
Public ConfigInfo As ConfigInfoStuct
|
||
|
||
''' <summary>
|
||
''' 主机名
|
||
''' </summary>
|
||
''' <returns></returns>
|
||
Property hostname As String
|
||
''' <summary>
|
||
''' 设备键值对 设备名-设备信息集合 主机=主机名 外设=外设名+播马地址
|
||
''' </summary>
|
||
Public Dic_Devicemodel As Dictionary(Of String, DeviceModel)
|
||
|
||
''' <summary>
|
||
''' 设备动作信息 设备名-动作信息集合
|
||
''' </summary>
|
||
Public Dic_ActionConfiguration As List(Of TableRowTag)
|
||
|
||
Private _Tip As String = "" ''' $"{ Chr(TableColSwitchKeyDate.TurnOn)} 表示开{vbLf }{ Chr(TableColSwitchKeyDate.TurnDrown)} 表示关{vbLf }数字 表示亮度百分比{vbCrLf }" '"表示先关后开{vbLf }{ Chr(TableColSwitchKeyDate.OnTodrowm)} 表示先开后关{vbLf }{ Chr(TableColSwitchKeyDate.TurnOn)} 表示只开不关{vbLf }{ Chr(TableColSwitchKeyDate.TurnDrown)} 表示只关不开{vbLf }数字 表示亮度百分比{vbCrLf }"
|
||
''' <summary>
|
||
''' 场景号 累加
|
||
''' </summary>
|
||
Private _SceneID As Integer = 1
|
||
''' <summary>文件是否有修改,如果有修改,则在关闭时提示保存</summary>
|
||
Public _isCellChanged As Boolean = True
|
||
Public _actionIndex As UShort
|
||
''' <summary>
|
||
''' 列的开始加载位置
|
||
''' </summary>
|
||
Private _ColumnStartLoad As Integer = TableColNumber.Max
|
||
'' <summary>
|
||
'' 服务集合!
|
||
'' </summary>
|
||
Private _ServerAction As Dictionary(Of String, Integer)
|
||
''' <summary>
|
||
''' 服务插入行起始位
|
||
''' </summary>
|
||
Private _ServerInsertRows As Integer
|
||
|
||
Public ColumnAnothername As Dictionary(Of String, String)
|
||
|
||
#End Region
|
||
|
||
|
||
#Region "枚举"
|
||
''' <summary>
|
||
''' 固定行
|
||
''' </summary>
|
||
Enum TableRowNumber
|
||
''' <summary>
|
||
''' 设备名
|
||
''' </summary>
|
||
DeviceName = 1
|
||
''' <summary>
|
||
''' 功能名
|
||
''' </summary>
|
||
FunctionName
|
||
FunctionAnotherName
|
||
''' <summary>
|
||
''' 功能下属节点ID
|
||
''' </summary>
|
||
FunctionChildNodeID
|
||
''' <summary>
|
||
''' 功能下属节点别名
|
||
''' </summary>
|
||
FunctionChildNodeAnother
|
||
''' <summary>
|
||
''' 条件列名
|
||
''' </summary>
|
||
ConditionalColumnName
|
||
Max
|
||
End Enum
|
||
''' <summary>
|
||
''' 固定列
|
||
''' </summary>
|
||
Enum TableColNumber
|
||
''' <summary>
|
||
''' 行号
|
||
''' </summary>
|
||
RowID = 0
|
||
|
||
<Description("Address provision")>
|
||
DeviceName
|
||
<Description("enable")>
|
||
choose
|
||
<Description("Scene number")>
|
||
SceneID
|
||
<Description("Key value")>
|
||
KeyVal
|
||
<Description("Key name")>
|
||
KeyName
|
||
'<Description("设备类型")>
|
||
'DeviceType
|
||
|
||
<Description("Scene attribute")>
|
||
SceneAttribute
|
||
<Description("Service attribute")>
|
||
ServerAttribute
|
||
InsertColumn
|
||
Max
|
||
End Enum
|
||
''' <summary>
|
||
''' 列数据的数据类型
|
||
''' </summary>
|
||
Enum TableColDateType
|
||
''' <summary>
|
||
''' 表列-音乐数据
|
||
''' </summary>
|
||
Music
|
||
''' <summary>
|
||
''' 表列-开关数据
|
||
''' </summary>
|
||
SwitchKey
|
||
''' <summary>
|
||
''' 表列-服务添加
|
||
''' </summary>
|
||
ServiceCondition
|
||
|
||
End Enum
|
||
''' <summary>
|
||
'''
|
||
''' </summary>
|
||
Enum TableColSwitchKeyDate
|
||
''' <summary>
|
||
''' 按键开
|
||
''' </summary>
|
||
TurnOn = -24116
|
||
''' <summary>
|
||
''' 按键关
|
||
''' </summary>
|
||
TurnDrown = -23592
|
||
''' <summary>
|
||
''' 表示先开后关
|
||
''' </summary>
|
||
'OnTodrowm = -24080
|
||
''' <summary>
|
||
''' 代表先关后开
|
||
''' </summary>
|
||
'drowmToOn = -24075
|
||
End Enum
|
||
|
||
|
||
|
||
Enum tabRange
|
||
devname
|
||
fr
|
||
lr
|
||
fc
|
||
lc
|
||
End Enum
|
||
|
||
#End Region
|
||
|
||
#Region "类 Body"
|
||
Public Sub New(ByRef tsp As ToolStripProgressBar)
|
||
|
||
CopyActionData = New Dictionary(Of Integer, String)
|
||
|
||
_actionIndex = 1
|
||
_tsp = tsp
|
||
Dic_Devicemodel = New Dictionary(Of String, DeviceModel)
|
||
|
||
Dic_ActionConfiguration = New List(Of TableRowTag)
|
||
|
||
_ServerAction = New Dictionary(Of String, Integer)
|
||
|
||
ColumnAnothername = New Dictionary(Of String, String)
|
||
|
||
AliasEncoding = Text.Encoding.GetEncoding("GBK")
|
||
|
||
End Sub
|
||
|
||
#End Region
|
||
|
||
|
||
#Region "表格设置"
|
||
''' <summary>
|
||
''’
|
||
''' </summary>
|
||
''' <returns></returns>
|
||
Public Property Grid As Grid
|
||
Get
|
||
Return _grd
|
||
End Get
|
||
Set(value As Grid)
|
||
_grd = value
|
||
grdRemoveHandler()
|
||
grdAddHandler()
|
||
End Set
|
||
End Property
|
||
Public Sub grdRemoveHandler()
|
||
|
||
RemoveHandler _grd.OwnerDrawCell, AddressOf Grid_OwnerDrawCell
|
||
RemoveHandler _grd.Click, AddressOf Grid_Click
|
||
RemoveHandler _grd.DoubleClick, AddressOf Grid_DoubleClick
|
||
RemoveHandler _grd.ComboDropDown, AddressOf Grid_ComboDropDown
|
||
'RemoveHandler _grd.ComboClick, AddressOf Grid_ComboClick
|
||
RemoveHandler _grd.CellChange, AddressOf Grid_CellChange
|
||
'RemoveHandler _grd.SelChange, AddressOf Grid_SelChange
|
||
'RemoveHandler _grd.KeyDown, AddressOf Grid_KeyDown
|
||
'RemoveHandler _grd.KeyUp, AddressOf Grid_KeyUp
|
||
'RemoveHandler _grd.MouseMove, AddressOf Grid_MouseMove
|
||
'RemoveHandler _grd.MouseWheel, AddressOf Grid_MouseWheel
|
||
'RemoveHandler _grd.LeaveCell, AddressOf Grid_LeaveCell
|
||
'RemoveHandler _grd.MouseDown, AddressOf Grid_MouseDown
|
||
'RemoveHandler _grd.MouseUp, AddressOf Grid_MouseUp
|
||
|
||
End Sub
|
||
|
||
Public Sub grdAddHandler()
|
||
'AddHandler _grd.MouseWheel, AddressOf Grid_MouseWheel
|
||
'AddHandler _grd.MouseMove, AddressOf Grid_MouseMove
|
||
'AddHandler _grd.KeyUp, AddressOf Grid_KeyUp
|
||
'AddHandler _grd.KeyDown, AddressOf Grid_KeyDown
|
||
'AddHandler _grd.SelChange, AddressOf Grid_SelChange
|
||
AddHandler _grd.CellChange, AddressOf Grid_CellChange
|
||
AddHandler _grd.ComboDropDown, AddressOf Grid_ComboDropDown
|
||
'AddHandler _grd.ComboClick, AddressOf Grid_ComboClick
|
||
AddHandler _grd.Click, AddressOf Grid_Click
|
||
AddHandler _grd.DoubleClick, AddressOf Grid_DoubleClick
|
||
AddHandler _grd.OwnerDrawCell, AddressOf Grid_OwnerDrawCell
|
||
'AddHandler _grd.LeaveCell, AddressOf Grid_LeaveCell
|
||
'AddHandler _grd.MouseDown, AddressOf Grid_MouseDown
|
||
'AddHandler _grd.MouseUp, AddressOf Grid_MouseUp
|
||
|
||
End Sub
|
||
|
||
Private Sub Grid_OwnerDrawCell(Sender As Object, e As Grid.OwnerDrawCellEventArgs)
|
||
'Console.WriteLine($"Grid_OwnerDrawCell_{e.Row}_{ e.Col}_{_grd.Cell(e.Row, e.Col).Text }")
|
||
If e.Row < TableRowNumber.Max OrElse e.Col < TableColNumber.InsertColumn Then
|
||
'Dim bColor As New SolidBrush(_grd.Cell(e.Row, e.Col).ForeColor)
|
||
|
||
'With _grd.Cell(e.Row, e.Col)
|
||
' Dim stringFormat = New StringFormat()
|
||
' stringFormat.Alignment = StringAlignment.Center
|
||
' Dim ft = New Font(_grd.DefaultFont.Name, .FontSize)
|
||
' Console.WriteLine($"Grid_OwnerDrawCell__【{ .Text}】color:【{ .ForeColor}】 Left:【{e.Bounds.Left}】 top:【{e.Bounds.Top}】Height:【{e.Bounds.Height}】Width:【{e.Bounds.Width}】 ppp:【{e.Graphics.MeasureString(.Text, .Font).Height}】")
|
||
' Dim rect As RectangleF = New RectangleF(e.Bounds.Left, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 2, e.Bounds.Width, e.Bounds.Height)
|
||
' e.Graphics.DrawString(.Text, ft, bColor, rect, stringFormat)
|
||
|
||
'End With
|
||
Return
|
||
End If
|
||
If Dic_ActionConfiguration.Count <= (e.Row - TableRowNumber.Max) Then
|
||
|
||
Return
|
||
End If
|
||
'获取显示内容
|
||
'Dim nodename As String = _grd.Cell(TableRowNumber.FunctionName, e.Col).Text
|
||
Dim celltext As String = _grd.Cell(e.Row, e.Col).Text.Trim
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(e.Row - TableRowNumber.Max)
|
||
Dim Isflig As Boolean = False
|
||
|
||
'画树线
|
||
Dim pen As New System.Drawing.Pen(Color.CornflowerBlue, 1)
|
||
If Not String.IsNullOrEmpty(_grd.Cell(e.Row, e.Col).Text) Then
|
||
Console.WriteLine(_grd.Cell(e.Row, e.Col).Text)
|
||
End If
|
||
Try
|
||
pen.DashStyle = Drawing2D.DashStyle.Solid
|
||
|
||
'判断内容
|
||
If rowtag.G_DicRow.ContainsKey(e.Col) Then
|
||
Dim cdrstr As String = rowtag.G_DicRow.Item(e.Col)
|
||
Dim g_devname As New CtabRange(_grd, TableRowNumber.FunctionName, e.Col)
|
||
Dim ctstr As String = EstimateFilag(cdrstr, g_devname.devname)
|
||
Dim nbuf() As String = cdrstr.Split(vbLf)
|
||
If Not String.IsNullOrEmpty(celltext) AndAlso celltext.Equals(ctstr) AndAlso Not (cdrstr.Substring(0, 1).Equals("0") AndAlso nbuf.Length = 1) Then
|
||
'+/-
|
||
|
||
For i = 0 To 8
|
||
e.Graphics.DrawLine(Pens.Green, e.Bounds.Left, e.Bounds.Top + i, e.Bounds.Left + i, e.Bounds.Top)
|
||
Next
|
||
End If
|
||
End If
|
||
|
||
|
||
|
||
'文字
|
||
Dim bColor As New SolidBrush(_grd.Cell(e.Row, e.Col).ForeColor)
|
||
|
||
With _grd.Cell(e.Row, e.Col)
|
||
Dim stringFormat = New StringFormat()
|
||
stringFormat.Alignment = StringAlignment.Center
|
||
Dim ft = New Font(_grd.DefaultFont.Name, 8.2)
|
||
' Console.WriteLine($"Grid_OwnerDrawCell__【{ .Text}】color:【{ .ForeColor}】 Left:【{e.Bounds.Left}】 top:【{e.Bounds.Top}】Height:【{e.Bounds.Height}】Width:【{e.Bounds.Width}】 ppp:【{e.Graphics.MeasureString(.Text, .Font).Height}】")
|
||
Dim rect As RectangleF = New RectangleF(e.Bounds.Left, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 2, e.Bounds.Width, e.Bounds.Height)
|
||
e.Graphics.DrawString(.Text, ft, bColor, rect, stringFormat)
|
||
|
||
End With
|
||
|
||
|
||
Catch ex As Exception
|
||
|
||
End Try
|
||
|
||
e.Handled = True
|
||
End Sub
|
||
Public Function EstimateFilag(cellstr As String, nodename As String) As String
|
||
|
||
If String.IsNullOrEmpty(cellstr) OrElse String.IsNullOrEmpty(nodename) Then Return String.Empty
|
||
Dim tbuf() As String = cellstr.Split(vbLf)
|
||
Dim cbuf() As String = tbuf(0).Split(",")
|
||
If cbuf.Length < 2 Then Return String.Empty
|
||
Dim buf() As String = cbuf(cbuf.Length - 1).Split("*")
|
||
Dim result As String = String.Empty
|
||
Select Case nodename
|
||
Case "RKEY"
|
||
result = cellstr
|
||
Case "CLED_FRESHAIR"
|
||
result = cellstr
|
||
Case "CLEDFLOORHEAT"
|
||
result = cellstr
|
||
Case "485FloorHeat", "485FreshAir"
|
||
If buf.Length > 3 Then
|
||
cbuf = buf(3).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
End If
|
||
|
||
'Case
|
||
'result = $"{buf(3)}"
|
||
Case "485MUSIC"
|
||
result = cellstr
|
||
'Case
|
||
|
||
' result = $"{buf(3)}"
|
||
Case "INFRARED_FORWARD"
|
||
If buf.Length = 3 Then
|
||
|
||
cbuf = buf(2).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
ElseIf buf.Length > 3 Then
|
||
cbuf = buf(2).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
cbuf = buf(3).Split(" ")
|
||
'result = $"{cbuf(cbuf.Length - 1)}"
|
||
result = $"{result}:{cbuf(cbuf.Length - 1)}"
|
||
End If
|
||
|
||
Case "RELAY", "PB_RELAY_DEVICE"
|
||
|
||
If buf.Length > 2 Then
|
||
cbuf = buf(2).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
If result.Equals("开") Then
|
||
result = Chr(TableColSwitchKeyDate.TurnOn).ToString()
|
||
ElseIf result.Equals("关") Then
|
||
result = Chr(TableColSwitchKeyDate.TurnDrown).ToString()
|
||
End If
|
||
End If
|
||
|
||
'If buf.Length > 2 Then
|
||
' cbuf = buf(2).Split(" ")
|
||
' result = $"{cbuf(cbuf.Length - 1)}"
|
||
' If result.Equals("80") Then
|
||
' result = Chr(TableColSwitchKeyDate.TurnOn).ToString()
|
||
' ElseIf result.Equals("0") Then
|
||
' result = Chr(TableColSwitchKeyDate.TurnDrown).ToString()
|
||
' End If
|
||
'End If
|
||
Case "PB_LINE_CONTROL", "PB_STRIP_DEVICE", "PB_LED_DEVICE"
|
||
result = cellstr
|
||
'If buf.Length > 3 AndAlso ((tbuf(0).Contains("PB灯带亮度控制")) OrElse (tbuf(0).Contains("控制灯光"))) Then
|
||
' cbuf = buf(3).Split(" ")
|
||
|
||
' result = $"{cbuf(cbuf.Length - 1)}"
|
||
' If result.Equals("80") Then
|
||
' result = Chr(TableColSwitchKeyDate.TurnOn).ToString()
|
||
' ElseIf result.Equals("0") Then
|
||
' result = Chr(TableColSwitchKeyDate.TurnDrown).ToString()
|
||
' End If
|
||
'End If
|
||
Case "Dimming"
|
||
result = cellstr
|
||
If buf.Length > 2 AndAlso cellstr.Contains("Control lighting") Then
|
||
cbuf = buf(3).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
If result.Equals("80") Then
|
||
result = Chr(TableColSwitchKeyDate.TurnOn).ToString()
|
||
ElseIf result.Equals("0") Then
|
||
result = Chr(TableColSwitchKeyDate.TurnDrown).ToString()
|
||
End If
|
||
End If
|
||
|
||
Case "DO", "LIGHT", "DRY_CURTAIN", "RS485_Curtain", "CURTAIN"
|
||
If buf.Length > 2 Then
|
||
cbuf = buf(2).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
End If
|
||
|
||
Case "RS485_Curtain"
|
||
result = cellstr
|
||
If buf.Length = 3 Then
|
||
cbuf = buf(2).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
End If
|
||
Case "MUSIC"
|
||
result = cellstr
|
||
|
||
Case "DRY_NoCard"
|
||
result = cellstr
|
||
Case "HOPO_Curtain"
|
||
result = cellstr
|
||
Case "Dev_ColorTemp"
|
||
result = cellstr
|
||
Case "BLEMUSIC"
|
||
result = cellstr
|
||
Case "Carbon_Device", "Scene_Restore"
|
||
result = cellstr
|
||
'Case
|
||
' result = $"{buf(2)}"
|
||
'Case
|
||
' result = $"{buf(2)}"
|
||
Case "Temp"
|
||
If buf.Length > 5 Then
|
||
'cbuf = buf(3).Split(" ")
|
||
'result = $"{cbuf(cbuf.Length - 1)}"
|
||
cbuf = buf(4).Split(" ")
|
||
result = $"{cbuf(cbuf.Length - 1)}"
|
||
cbuf = buf(5).Split(" ")
|
||
result = $"{result}{cbuf(cbuf.Length - 1)}"
|
||
End If
|
||
|
||
Case Else
|
||
|
||
End Select
|
||
Return result
|
||
End Function
|
||
|
||
Public Sub LoadTheHostTable(model As DeviceModel)
|
||
|
||
'新主机项目 清空设备列表
|
||
Dic_Devicemodel.Clear()
|
||
Dic_ActionConfiguration.Clear()
|
||
_ServerAction.Clear()
|
||
ColumnAnothername.Clear()
|
||
'记录主机名称
|
||
hostname = model.Name
|
||
_ServerInsertRows = 0
|
||
_SceneID = 1
|
||
_ColumnStartLoad = TableColNumber.Max - 1
|
||
'加载表头
|
||
initGrid1()
|
||
'加载设备
|
||
'将主机存入设备列表
|
||
Dic_Devicemodel.Add(model.Name, model)
|
||
'ShowRelay(model)
|
||
|
||
ShowRelay_Test(model)
|
||
|
||
SpecifySetting(model.Name, "")
|
||
End Sub
|
||
|
||
|
||
''' <summary>
|
||
''' 表头初始化
|
||
''' </summary>
|
||
Public Sub initGrid1()
|
||
LockGridAutoRedraw()
|
||
If Not IsNothing(oldColDisplayDic) Then
|
||
oldColDisplayDic.Clear()
|
||
End If
|
||
_grd.NewFile()
|
||
|
||
_grd.DefaultRowHeight = 21
|
||
_grd.DrawMode = DrawModeEnum.OwnerDraw
|
||
_grd.Cols = TableColNumber.Max
|
||
_grd.Rows = TableRowNumber.DeviceName
|
||
_grd.Column(0).Visible = False
|
||
_grd.Row(0).Visible = False
|
||
_grd.DefaultFont = New Font(_grd.DefaultFont.Name, 8)
|
||
'_grd.BackColorFixed = Color.LightPink
|
||
'_grd.BackColorFixedSel = Color.LightCoral
|
||
For i As Integer = TableRowNumber.DeviceName To TableRowNumber.Max - 1
|
||
_grd.AddItem("")
|
||
Next
|
||
|
||
|
||
_grd.Row(TableRowNumber.FunctionChildNodeAnother).Height = 70
|
||
|
||
With _grd.Range(TableRowNumber.DeviceName, TableColNumber.SceneID, TableRowNumber.FunctionChildNodeID, TableColNumber.SceneAttribute)
|
||
.Merge()
|
||
.Alignment = AlignmentEnum.CenterCenter
|
||
End With
|
||
|
||
_grd.Cell(TableRowNumber.DeviceName, TableColNumber.InsertColumn - 1).Text = "主机时间偏移"
|
||
_grd.Cell(TableRowNumber.DeviceName, TableColNumber.InsertColumn - 1).Locked = True
|
||
'With _grd.Range(TableRowNumber.FunctionChildNodeID, TableColNumber.InsertColumn - 1, TableRowNumber.FunctionChildNodeID, TableColNumber.InsertColumn - 1)
|
||
' .Merge()
|
||
' .Alignment = AlignmentEnum.CenterCenter
|
||
'End With
|
||
With _grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1)
|
||
.Text = "0"
|
||
.CellType = CellTypeEnum.ComboBox
|
||
.Alignment = AlignmentEnum.CenterCenter
|
||
' .Locked = True
|
||
End With
|
||
With _grd.Range(TableRowNumber.DeviceName, TableColNumber.DeviceName, TableRowNumber.FunctionChildNodeID, TableColNumber.choose)
|
||
.Merge()
|
||
.Alignment = AlignmentEnum.CenterCenter
|
||
.WrapText = True
|
||
End With
|
||
With _grd.Range(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName, TableRowNumber.FunctionChildNodeAnother, TableColNumber.InsertColumn - 1)
|
||
.Merge()
|
||
.Alignment = AlignmentEnum.CenterCenter
|
||
.Locked = True
|
||
End With
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).WrapText = True
|
||
'_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = "test"
|
||
With _grd.Cell(TableRowNumber.DeviceName, TableColNumber.DeviceName)
|
||
.Text = "There is a card to take power"
|
||
.Locked = True
|
||
.WrapText = True
|
||
End With
|
||
With _grd.Cell(TableRowNumber.DeviceName, TableColNumber.SceneID)
|
||
.Text = _Tip
|
||
.Locked = True
|
||
.WrapText = True
|
||
End With
|
||
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.DeviceName).Text = EnumExtender.GetEnumDescription(TableColNumber.DeviceName)
|
||
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.KeyVal).Text = EnumExtender.GetEnumDescription(TableColNumber.KeyVal)
|
||
_grd.Column(TableColNumber.KeyVal).Width = 30
|
||
_grd.Column(TableColNumber.KeyVal).Locked = True
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.KeyName).Text = EnumExtender.GetEnumDescription(TableColNumber.KeyName)
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.choose).Text = EnumExtender.GetEnumDescription(TableColNumber.choose)
|
||
_grd.Column(TableColNumber.choose).Width = 30
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.SceneID).Text = EnumExtender.GetEnumDescription(TableColNumber.SceneID)
|
||
_grd.Column(TableColNumber.SceneID).Width = 40
|
||
_grd.Column(TableColNumber.SceneID).Locked = True
|
||
_grd.Column(TableColNumber.InsertColumn).Width = 0
|
||
_grd.Column(TableColNumber.choose).Width = 0
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.ServerAttribute).Text = EnumExtender.GetEnumDescription(TableColNumber.ServerAttribute)
|
||
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.SceneAttribute).Text = EnumExtender.GetEnumDescription(TableColNumber.SceneAttribute)
|
||
_grd.Range(TableRowNumber.ConditionalColumnName, TableColNumber.DeviceName, TableRowNumber.ConditionalColumnName, TableColNumber.ServerAttribute).Locked = True
|
||
_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.SceneAttribute).Text = EnumExtender.GetEnumDescription(TableColNumber.SceneAttribute)
|
||
'_grd.Cell(TableRowNumber.ConditionalColumnName, TableColNumber.DeviceType).Text = EnumExtender.GetEnumDescription(TableColNumber.DeviceType)
|
||
_grd.Row(TableRowNumber.FunctionChildNodeID).Locked = True
|
||
_grd.Row(TableRowNumber.FunctionName).Visible = False
|
||
_grd.FrozenRows = TableRowNumber.Max - 1
|
||
_grd.FrozenCols = TableColNumber.Max - 2
|
||
'_grd.Column(TableColNumber.InsertColumn).AutoFit()
|
||
UnLockGridAutoRedraw()
|
||
End Sub
|
||
|
||
Public Sub AddToTableDevMode(filepath As String)
|
||
Dim from1 As New AddPeripherals
|
||
from1.Dirpath = filepath
|
||
from1.g_grd = _grd
|
||
from1.g_Devicemodel = Dic_Devicemodel
|
||
from1.g_DevRELAYrow = GetDevLoopName("RELAY", "PB_RELAY_DEVICE")
|
||
from1.g_Devinfraredrow = GetDevLoopName("INFRARED_FORWARD")
|
||
from1.g_Devintemp = GetDevLoopName("Temp")
|
||
from1.g_DevDimming = GetDevLoopName("Dimming")
|
||
from1.g_Devin485fraredrow = GetDevLoopName("RS485_Curtain")
|
||
from1.g_DevinCURTAINdrow = GetDevLoopName("CURTAIN")
|
||
from1.g_Devservice = GetHOSTSERVICENumber()
|
||
from1.g_DevScenenumber = GetSceneNumbeAr()
|
||
from1.g_ColumnAnothername = ColumnAnothername
|
||
If from1.ShowDialog() <> DialogResult.OK Then Return
|
||
If IsNothing(from1.Resultmodel) Then
|
||
MsgBox("Failed to add peripheral devices. Procedure!")
|
||
Return
|
||
End If
|
||
ShowRelay(from1.Resultmodel, from1.ResulDic)
|
||
Grid_Click(Nothing, Nothing)
|
||
For Each index In from1.Resultmodel.Nodes
|
||
If index.Interface.Equals("DI") AndAlso (index.DEV_TYPE_DATA.Equals("10") OrElse index.DEV_TYPE_DATA.Equals("24")) Then
|
||
SpecifySetting(from1.Resultmodel.Name, "")
|
||
End If
|
||
Next
|
||
|
||
|
||
End Sub
|
||
|
||
Public Shared Function CURTAIN_check(grd As FlexCell.Grid, col As Integer) As List(Of Integer)
|
||
If IsNothing(grd) OrElse grd.Cols - 1 <= col Then Return Nothing
|
||
Dim li As New List(Of Integer)
|
||
For i = TableRowNumber.Max To grd.Rows - 1
|
||
'Console.WriteLine($"{grd.Cell(i, col).Text.Trim}___{grd.Column(col).Locked}")
|
||
If (Not String.IsNullOrEmpty(grd.Cell(i, col).Text.Trim)) OrElse grd.Column(col).Locked Then
|
||
li.Add(i)
|
||
End If
|
||
Next
|
||
Return li
|
||
End Function
|
||
Public Function GetSceneNumbeAr() As Dictionary(Of String, Integer)
|
||
Dim resulrdic As New Dictionary(Of String, Integer)
|
||
For i = TableRowNumber.Max To _grd.Rows - 1
|
||
Dim g_devname = New CtabRange(_grd, i, TableColNumber.DeviceName)
|
||
If g_devname.devname.Equals("HOSTSERVICE") Then
|
||
Continue For
|
||
End If
|
||
If _grd.Cell(i, TableColNumber.SceneID).Text.Equals("Voice") AndAlso String.IsNullOrEmpty(_grd.Cell(i, TableColNumber.SceneAttribute).Text) Then
|
||
Continue For
|
||
End If
|
||
Dim ss As String = $"{_grd.Cell(i, TableColNumber.SceneID).Text}*({_grd.Cell(i, TableColNumber.KeyName).Text})"
|
||
resulrdic.Add($"{_grd.Cell(i, TableColNumber.SceneID).Text}*({_grd.Cell(i, TableColNumber.KeyName).Text})", i)
|
||
Next
|
||
Return resulrdic
|
||
End Function
|
||
Public Function GetHOSTSERVICENumber() As Dictionary(Of String, Integer)
|
||
Dim resulrdic As New Dictionary(Of String, Integer)
|
||
For i = TableRowNumber.Max To _grd.Rows - 1
|
||
Dim g_devname = New CtabRange(_grd, i, TableColNumber.DeviceName)
|
||
If g_devname.devname.Equals("HOSTSERVICE") Then
|
||
Dim dkey As String = $"{hostname}*HOSTSERVICE*{_grd.Cell(i, TableColNumber.KeyVal).Text }*({_grd.Cell(i, TableColNumber.KeyName).Text})"
|
||
If resulrdic.ContainsKey(dkey) Then
|
||
Continue For
|
||
End If
|
||
resulrdic.Add(dkey, i)
|
||
Else
|
||
|
||
Continue For
|
||
End If
|
||
Next
|
||
Return resulrdic
|
||
End Function
|
||
Public Function GetDevLoopName(LoopName As String, Optional LoopName1 As String = Nothing) As Dictionary(Of String, Integer)
|
||
Dim resulrdic As New Dictionary(Of String, Integer)
|
||
'resulrdic.Add("", 0)
|
||
For i = TableColNumber.InsertColumn To _grd.Cols - 1
|
||
Dim g_devname = New CtabRange(_grd, TableRowNumber.FunctionName, i)
|
||
|
||
If g_devname.devname.Equals(LoopName) Then
|
||
Dim devname = New CtabRange(_grd, TableRowNumber.DeviceName, i)
|
||
Dim gdevname = New CtabRange(_grd, TableRowNumber.FunctionName, i)
|
||
Dim devnamestr As String = devname.devname
|
||
For ci = g_devname.fc To g_devname.lc
|
||
resulrdic.Add($"{devnamestr}*{_grd.Cell(TableRowNumber.FunctionChildNodeID, ci).Text }*{gdevname.devname }", ci)
|
||
Next
|
||
End If
|
||
If (LoopName1 <> Nothing) AndAlso g_devname.devname.Equals(LoopName1) Then
|
||
Dim devname = New CtabRange(_grd, TableRowNumber.DeviceName, i)
|
||
Dim gdevname = New CtabRange(_grd, TableRowNumber.FunctionName, i)
|
||
Dim devnamestr As String = devname.devname
|
||
For ci = g_devname.fc To g_devname.lc
|
||
resulrdic.Add($"{devnamestr}*{_grd.Cell(TableRowNumber.FunctionChildNodeID, ci).Text }*{gdevname.devname }", ci)
|
||
Next
|
||
End If
|
||
i = g_devname.lc
|
||
Next
|
||
Return resulrdic
|
||
End Function
|
||
|
||
Public Sub ShowRelay_Test(moduStr As DeviceModel, Optional OPTdic As Dictionary(Of String, String) = Nothing)
|
||
LockGridAutoRedraw()
|
||
|
||
|
||
'_grd.Cols = TableColNumber.Max
|
||
Dim demoindex As Integer = _ColumnStartLoad
|
||
|
||
Dim Interace_DI As New List(Of DeviceChildNodeClass)
|
||
|
||
Dim Interace_DO As New List(Of DeviceChildNodeClass)
|
||
|
||
' If moduStr.Nodes.Count = 1 AndAlso moduStr.Nodes(0).Nodes.Count = 0 Then
|
||
If moduStr.Nodes.Count = 1 AndAlso (moduStr.Nodes(0).Nodes.Count = 0 OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("48") OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("46")) Then
|
||
|
||
Dim ctext As String = _grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text
|
||
If String.IsNullOrEmpty(ctext) Then
|
||
ctext = moduStr.Name
|
||
Else
|
||
ctext = ctext & "," & moduStr.Name
|
||
End If
|
||
|
||
'ctext = ctext.Substring(0, ctext.Length - 1)
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = ctext
|
||
UnLockGridAutoRedraw()
|
||
Return
|
||
End If
|
||
For Each ModuleFre In moduStr.Nodes
|
||
Select Case ModuleFre.Interface
|
||
Case "DO"
|
||
If String.IsNullOrEmpty(ModuleFre.DEV_TYPE_DATA) OrElse ModuleFre.DEV_TYPE_DATA = 4 Then Continue For
|
||
If ModuleFre.DEV_TYPE_DATA = 21 AndAlso ModuleFre.PROTOCOL_VER = 1 Then
|
||
Interace_DO.Insert(0, ModuleFre)
|
||
Else
|
||
Interace_DO.Add(ModuleFre)
|
||
End If
|
||
Case "DI"
|
||
Interace_DI.Add(ModuleFre)
|
||
End Select
|
||
Next
|
||
For Each indesx In Interace_DO
|
||
If indesx.DEV_TYPE_DATA = 3 Then
|
||
AddColumnConfig(indesx, demoindex, _ColumnStartLoad, moduStr, OPTdic)
|
||
Else
|
||
AddColumnConfig(indesx, demoindex, _ColumnStartLoad, moduStr)
|
||
End If
|
||
|
||
Next
|
||
|
||
_ColumnStartLoad = demoindex
|
||
|
||
ShowSwitch2(moduStr.Name, Interace_DI, OPTdic)
|
||
ChangeTheServiceLineNumber()
|
||
|
||
UnLockGridAutoRedraw()
|
||
|
||
End Sub
|
||
|
||
Public Sub ShowRelay(moduStr As DeviceModel, Optional OPTdic As Dictionary(Of String, String) = Nothing)
|
||
LockGridAutoRedraw()
|
||
'_grd.Cols = TableColNumber.Max
|
||
Dim demoindex As Integer = _ColumnStartLoad
|
||
|
||
Dim g_Dimming As DeviceChildNodeClass
|
||
Dim g_RELAY As DeviceChildNodeClass
|
||
Dim g_DO As DeviceChildNodeClass
|
||
Dim g_MUSIC As DeviceChildNodeClass
|
||
Dim g_Lock As DeviceChildNodeClass
|
||
Dim g_RS485_Curtain As DeviceChildNodeClass
|
||
Dim g_485MUSIC As DeviceChildNodeClass
|
||
Dim g_CURTAIN As DeviceChildNodeClass
|
||
Dim g_INFRARED_FORWARD As DeviceChildNodeClass
|
||
Dim g_Temp As DeviceChildNodeClass
|
||
Dim g_485FreshAir As DeviceChildNodeClass
|
||
Dim g_485FloorHeat As DeviceChildNodeClass
|
||
Dim g_PBnode As DeviceChildNodeClass
|
||
Dim Dev_ColorTemp As DeviceChildNodeClass
|
||
|
||
Dim All_DO As New List(Of DeviceChildNodeClass)
|
||
Dim Interace_DI As New List(Of DeviceChildNodeClass)
|
||
g_PBnode = Nothing
|
||
g_Dimming = Nothing
|
||
g_RELAY = Nothing
|
||
g_DO = Nothing
|
||
g_MUSIC = Nothing
|
||
g_Lock = Nothing
|
||
g_RS485_Curtain = Nothing
|
||
g_485MUSIC = Nothing
|
||
g_CURTAIN = Nothing
|
||
g_INFRARED_FORWARD = Nothing
|
||
g_Temp = Nothing
|
||
g_485FreshAir = Nothing
|
||
g_485FloorHeat = Nothing
|
||
Dev_ColorTemp = Nothing
|
||
If moduStr.Nodes.Count = 1 AndAlso (moduStr.Nodes(0).Nodes.Count = 0 OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("48") OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("46")) Then
|
||
|
||
Dim ctext As String = _grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text
|
||
If String.IsNullOrEmpty(ctext) Then
|
||
ctext = moduStr.Name
|
||
Else
|
||
ctext = ctext & "," & moduStr.Name
|
||
End If
|
||
|
||
'ctext = ctext.Substring(0, ctext.Length - 1)
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = ctext
|
||
UnLockGridAutoRedraw()
|
||
Return
|
||
End If
|
||
For Each ModuleFre In moduStr.Nodes
|
||
If ModuleFre.Name.Equals("Dimming") Then
|
||
g_Dimming = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("RELAY") Then
|
||
g_RELAY = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("Dev_ColorTemp") Then
|
||
Dev_ColorTemp = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("DO") Then
|
||
g_DO = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("RKEY") AndAlso ModuleFre.Interface.Equals("DO") Then
|
||
g_Lock = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("DRY_NoCard") Then
|
||
g_DO = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("MUSIC") AndAlso ModuleFre.PROTOCOL_VER.Equals("1") Then
|
||
g_MUSIC = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("Lock") Then
|
||
g_Lock = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("485MUSIC") Then
|
||
g_485MUSIC = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("RS485_Curtain") Then
|
||
g_RS485_Curtain = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("CURTAIN") Then
|
||
g_CURTAIN = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("INFRARED_FORWARD") Then
|
||
g_INFRARED_FORWARD = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("Temp") Then
|
||
g_Temp = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("485FreshAir") Then
|
||
g_485FreshAir = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("CLED_FRESHAIR") Then
|
||
g_485FreshAir = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("CLEDFLOORHEAT") Then
|
||
g_485FloorHeat = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("485FloorHeat") Then
|
||
g_485FloorHeat = ModuleFre
|
||
ElseIf ModuleFre.Name.Equals("PB_LED") OrElse ModuleFre.Name.Equals("PB_RELAY_DEVICE") OrElse ModuleFre.Name.Equals("PB_STRIP_DEVICE") Then
|
||
g_PBnode = ModuleFre
|
||
ElseIf ModuleFre.Interface.Equals("DO") AndAlso Not ModuleFre.Name.Equals("Virtual_Card") Then
|
||
All_DO.Add(ModuleFre)
|
||
ElseIf ModuleFre.Interface.Equals("DI") Then
|
||
Interace_DI.Add(ModuleFre)
|
||
End If
|
||
|
||
Next
|
||
|
||
AddColumnConfig(g_MUSIC, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_DO, demoindex, _ColumnStartLoad, moduStr, OPTdic)
|
||
AddColumnConfig(g_Dimming, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_RELAY, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_Lock, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_PBnode, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_RS485_Curtain, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_485MUSIC, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_CURTAIN, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_INFRARED_FORWARD, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_Temp, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_485FloorHeat, demoindex, _ColumnStartLoad, moduStr)
|
||
AddColumnConfig(g_485FreshAir, demoindex, _ColumnStartLoad, moduStr)
|
||
For Each donode In All_DO
|
||
AddColumnConfig(donode, demoindex, _ColumnStartLoad, moduStr)
|
||
Next
|
||
|
||
|
||
|
||
If Not IsNothing(Dev_ColorTemp) Then
|
||
AddColumnConfig(Dev_ColorTemp, demoindex, _ColumnStartLoad, moduStr, Nothing, CInt(moduStr.Desc.DevDescription))
|
||
End If
|
||
|
||
_ColumnStartLoad = demoindex
|
||
|
||
ShowSwitch2(moduStr.Name, Interace_DI, OPTdic)
|
||
ChangeTheServiceLineNumber()
|
||
UnLockGridAutoRedraw()
|
||
End Sub
|
||
|
||
Public Shared 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 Fresh air"
|
||
Case "CLEDFLOORHEAT"
|
||
result = "CLED Underfloor heating"
|
||
Case "485FloorHeat"
|
||
result = "Underfloor heating"
|
||
Case "485FreshAir"
|
||
result = "Fresh air"
|
||
Case "485MUSIC"
|
||
result = "485 music"
|
||
Case "CURTAIN"
|
||
result = "Dry contact curtain"
|
||
Case "INFRARED_FORWARD"
|
||
result = "Infrared"
|
||
Case "RS485_Curtain"
|
||
result = "485 Curtain"
|
||
Case "RELAY"
|
||
result = "RELAY"
|
||
Case "MUSIC"
|
||
result = "music"
|
||
Case "Dimming"
|
||
result = "Dimming"
|
||
Case "DO"
|
||
result = "DO"
|
||
Case "Temp"
|
||
result = "Temp"
|
||
Case "PB_LINE_CONTROL"
|
||
result = "PB_LINE_CONTROL"
|
||
Case "PB_STRIP_DEVICE"
|
||
result = "PB_STRIP_DEVICE"
|
||
Case "PB_RELAY_DEVICE"
|
||
result = "PLC_RELAY"
|
||
Case "Dev_ColorTemp"
|
||
result = "Color temperature control"
|
||
Case "BLEMUSIC"
|
||
result = "BLE MUSIC"
|
||
Case "Carbon_Device"
|
||
result = "Carbon Device"
|
||
Case "DRY_NoCard"
|
||
result = "Non-stuck power off"
|
||
Case "RKEY"
|
||
result = "RKEY"
|
||
Case "Scene_Restore"
|
||
result = "Scene Restore"
|
||
Case Else
|
||
result = $"{str}"
|
||
End Select
|
||
|
||
End If
|
||
Return result
|
||
End Function
|
||
|
||
|
||
''' <summary>
|
||
''' 加载设备头输出信息
|
||
''' </summary>
|
||
''' <param name="ModuleFre"></param>
|
||
''' <param name="demoindex"></param>
|
||
''' <param name="Startid"></param>
|
||
''' <param name="moduStr"></param>
|
||
Public Sub AddColumnConfig(ModuleFre As DeviceChildNodeClass, ByRef demoindex As Integer, Startid As Integer, moduStr As DeviceModel, ByRef Optional OPTdic As Dictionary(Of String, String) = Nothing, Optional len As Integer = 0)
|
||
'添加继电器列
|
||
If IsNothing(ModuleFre) OrElse ModuleFre.Nodes.Count = 0 Then Return
|
||
If len = 0 Then
|
||
len = ModuleFre.Nodes.Count
|
||
End If
|
||
'Console.WriteLine($"AddColumnConfig::::{demoindex}:{ _grd.Column(demoindex).Visible}")
|
||
_grd.InsertCol(demoindex, len)
|
||
|
||
_grd.Column(demoindex).Visible = True
|
||
'_grd.Column(demoindex).Width = 300
|
||
_grd.Range(0, demoindex, _grd.Rows - 1, demoindex).BackColor = Color.White
|
||
_grd.Range(0, demoindex, _grd.Rows - 1, demoindex).ForeColor = Color.Black
|
||
'_grd.Cols = demoindex + ModuleFre.Nodes.Count
|
||
_grd.Cell(TableRowNumber.FunctionName, demoindex).Text = ModuleFre.Name
|
||
_grd.Cell(TableRowNumber.FunctionAnotherName, demoindex).Text = GetAnotherName(ModuleFre.Name)
|
||
_grd.Range(TableRowNumber.FunctionName, demoindex, TableRowNumber.FunctionName, demoindex + len - 1).Locked = False
|
||
'For ti = demoindex To demoindex + len - 1
|
||
' Console.WriteLine($"C:{ti} V:{_grd.Column(ti).Locked }")
|
||
'Next
|
||
Console.WriteLine($"R:{TableRowNumber.FunctionName} V:{_grd.Row(TableRowNumber.FunctionName).Locked }")
|
||
_grd.Range(TableRowNumber.FunctionName, demoindex, TableRowNumber.FunctionName, demoindex + len - 1).Merge()
|
||
_grd.Range(TableRowNumber.FunctionName, demoindex, TableRowNumber.FunctionName, demoindex + len - 1).Locked = True
|
||
_grd.Range(TableRowNumber.FunctionAnotherName, demoindex, TableRowNumber.FunctionAnotherName, demoindex + len - 1).Locked = False
|
||
_grd.Range(TableRowNumber.FunctionAnotherName, demoindex, TableRowNumber.FunctionAnotherName, demoindex + len - 1).Merge()
|
||
_grd.Range(TableRowNumber.FunctionAnotherName, demoindex, TableRowNumber.FunctionAnotherName, demoindex + len - 1).Locked = True
|
||
_grd.Range(TableRowNumber.DeviceName, Startid, TableRowNumber.DeviceName, demoindex + len - 1).Locked = False
|
||
_grd.Range(TableRowNumber.DeviceName, Startid, TableRowNumber.DeviceName, demoindex + len - 1).Merge()
|
||
_grd.Range(TableRowNumber.DeviceName, Startid, TableRowNumber.DeviceName, demoindex + len - 1).Locked = True
|
||
|
||
_grd.Cell(TableRowNumber.DeviceName, Startid).Text = moduStr.Name
|
||
|
||
|
||
_grd.Range(TableRowNumber.DeviceName, Startid, TableRowNumber.FunctionChildNodeAnother, Startid + len - 1).Alignment = AlignmentEnum.CenterCenter
|
||
|
||
For i As Integer = 0 To len - 1
|
||
Dim incol As Integer = demoindex + i
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeID, incol).Text = (i + 1).ToString
|
||
'Console.WriteLine($"{ModuleFre.Name}_R:{TableRowNumber.FunctionChildNodeID.ToString }_C:{Startid + i}_{(i + 1).ToString}")
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, incol).Text = ModuleFre.Nodes(i).DefaultAliasName
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, incol).WrapText = True
|
||
_grd.Column(incol).Width = 30
|
||
' Console.WriteLine($"AddColumnConfig::::{incol}:{_grd.Column(incol).Visible}:{_grd.Column(incol).Width}")
|
||
|
||
_grd.Column(incol).Visible = True
|
||
|
||
|
||
'_grd.Cell(TableRowNumber.FunctionChildNodeAnother, incol).Orientation = TextOrientationEnum.Vertical
|
||
With _grd.Range(TableRowNumber.FunctionChildNodeAnother, incol, TableRowNumber.ConditionalColumnName, incol)
|
||
.Locked = False
|
||
.Merge()
|
||
' .Locked = True
|
||
End With
|
||
'If i = 0 Then
|
||
' _grd.Cell(TableRowNumber.FunctionName, demoindex).Text = ModuleFre.Nodes(i).BaseClasses.Classes(0).Name
|
||
'End If
|
||
|
||
If IsNothing(OPTdic) OrElse OPTdic.Count = 0 Then Continue For
|
||
If _grd.Cell(TableRowNumber.FunctionChildNodeAnother, incol).Text.Equals("visible") Then Continue For
|
||
If i = len - 1 AndAlso (Not ModuleFre.Nodes(i).Name.Equals("RKEY")) Then
|
||
_grd.Column(incol).Visible = False
|
||
End If
|
||
|
||
For j = 0 To OPTdic.Count - 1
|
||
If OPTdic.Values(j).Equals(ModuleFre.Nodes(i).LoopAddr) Then
|
||
OPTdic.Item(OPTdic.Keys(j)) = (incol).ToString
|
||
' _grd.Column(incol).Width = 0
|
||
End If
|
||
Next
|
||
Next
|
||
|
||
demoindex = demoindex + len
|
||
|
||
End Sub
|
||
|
||
''' <summary>
|
||
''' 加载设备输入信息
|
||
''' </summary>
|
||
''' <param name="moduStr"></param>
|
||
Public Sub ShowSwitch(moduStrName As String, nterace_DI As List(Of DeviceChildNodeClass), Optional OPTdic As Dictionary(Of String, String) = Nothing)
|
||
|
||
Dim rowid As Integer
|
||
Dim startrow As Integer = _grd.Rows
|
||
Dim ModuleFre As DeviceChildNodeClass
|
||
Dim SceneAttri As String = "1,1,0"
|
||
For j As Integer = 0 To nterace_DI.Count - 1
|
||
ModuleFre = nterace_DI.Item(j)
|
||
rowid = _grd.Rows
|
||
' If ModuleFre.Name.Equals("DI") Then
|
||
'获取主机服务插入行起始位置
|
||
If moduStrName.Equals(hostname) Then
|
||
_ServerInsertRows = ModuleFre.Nodes.Count
|
||
End If
|
||
'添加继电器行
|
||
For i As Integer = 0 To ModuleFre.Nodes.Count - 1
|
||
_grd.AddItem("")
|
||
|
||
If j = 0 Then
|
||
_grd.Cell(rowid, TableColNumber.DeviceName).Text = moduStrName
|
||
_grd.Cell(rowid, TableColNumber.DeviceName).WrapText = True
|
||
End If
|
||
|
||
Dim gTableRowTag As New TableRowTag()
|
||
gTableRowTag.G_DevNodeName = ModuleFre.Name
|
||
gTableRowTag.G_DevNodeIndex = i + 1
|
||
gTableRowTag.G_DevModeName = moduStrName
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.choose, "1")
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneAttribute, SceneAttri)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneID, _SceneID)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyVal, (i + 1).ToString)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyName, ModuleFre.Nodes(i).Name)
|
||
If moduStrName.Equals(hostname) Then
|
||
gTableRowTag.Set_G_Attributes("DRY", BasicClasses)
|
||
SceneAttri = "1,1,1152921504606846976"
|
||
Else
|
||
gTableRowTag.Set_G_Attributes("KEY", BasicClasses)
|
||
SceneAttri = "1,2,1224996690830819360"
|
||
End If
|
||
|
||
Dic_ActionConfiguration.Add(gTableRowTag)
|
||
|
||
If Not (IsNothing(OPTdic) OrElse OPTdic.Count = 0) Then
|
||
If OPTdic.ContainsKey(ModuleFre.Nodes(i).LoopAddr) Then
|
||
Dim bgc As Integer = -1
|
||
If Integer.TryParse(OPTdic.Item(ModuleFre.Nodes(i).LoopAddr), bgc) Then
|
||
gTableRowTag.G_DicRow.Add(bgc, "Corresponding scenario")
|
||
_grd.Cell(rowid + i, bgc).Text = Chr("Corresponding scenario")
|
||
End If
|
||
End If
|
||
End If
|
||
|
||
_grd.Cell(rowid + i, TableColNumber.SceneID).Text = _SceneID.ToString
|
||
_grd.Cell(rowid + i, TableColNumber.KeyVal).Text = (i + 1).ToString
|
||
_grd.Cell(rowid + i, TableColNumber.KeyName).Text = ModuleFre.Nodes(i).Name
|
||
_grd.Cell(rowid + i, TableColNumber.choose).Text = "1"
|
||
_grd.Cell(rowid + i, TableColNumber.SceneAttribute).Text = SceneAttri
|
||
_SceneID = _SceneID + 1
|
||
|
||
_grd.Cell(rowid + i, TableColNumber.ServerAttribute).WrapText = True
|
||
Next
|
||
'End If
|
||
Next
|
||
If nterace_DI.Count > 0 Then
|
||
_grd.Range(startrow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(startrow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Locked = True
|
||
End If
|
||
|
||
|
||
_grd.Range(TableRowNumber.Max - 1, TableColNumber.RowID, _grd.Rows - 1, _grd.Cols - 1).Alignment = AlignmentEnum.CenterCenter
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.SceneAttribute, _grd.Rows - 1, _grd.Cols - 1).CellType = CellTypeEnum.ComboBox
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.choose, _grd.Rows - 1, TableColNumber.choose).CellType = CellTypeEnum.CheckBox
|
||
|
||
End Sub
|
||
''' <summary>
|
||
''' 加载设备输入信息
|
||
''' </summary>
|
||
''' <param name="moduStr"></param>
|
||
Public Sub ShowSwitch2(moduStrName As String, nterace_DI As List(Of DeviceChildNodeClass), Optional OPTdic As Dictionary(Of String, String) = Nothing)
|
||
'当前行
|
||
Dim rowid As Integer
|
||
'起始添加行
|
||
Dim startrow As Integer = _grd.Rows
|
||
Dim ModuleFre As DeviceChildNodeClass
|
||
|
||
Dim Mergerow, Mergecol As Integer
|
||
Dim SceneAttri As String = "1,1,0"
|
||
For j As Integer = 0 To nterace_DI.Count - 1
|
||
ModuleFre = nterace_DI.Item(j)
|
||
|
||
'获取服务组起始行号
|
||
Dim srowid As CtabRange = GetRowDevNametabRange("HOSTSERVICE", TableColNumber.DeviceName)
|
||
'默认从最后一行添加
|
||
If IsNothing(srowid) Then
|
||
startrow = _grd.Rows
|
||
Else
|
||
startrow = srowid.fr
|
||
End If
|
||
|
||
rowid = startrow
|
||
' If ModuleFre.Name.Equals("DI") Then
|
||
'获取主机服务插入行起始位置
|
||
'If moduStrName.Equals(hostname) Then
|
||
' _ServerInsertRows = ModuleFre.Nodes.Count
|
||
'End If
|
||
'添加继电器行
|
||
|
||
|
||
For i As Integer = 0 To ModuleFre.Nodes.Count - 1
|
||
'记录添加行行号
|
||
rowid = startrow + i
|
||
'行节点初始数据
|
||
Dim gTableRowTag As New TableRowTag()
|
||
If moduStrName.Equals(hostname) Then
|
||
gTableRowTag.Set_G_Attributes("DRY", BasicClasses)
|
||
ModuleFre.Nodes(i).DefaultClass = "DRY"
|
||
SceneAttri = "1,1,1152921504606846976"
|
||
Else
|
||
' If String.IsNullOrEmpty(ModuleFre.Nodes(i).DefaultClass) Then
|
||
If ModuleFre.Nodes(i).DefaultClass.Equals("KEY") Then
|
||
gTableRowTag.Set_G_Attributes("KEY", BasicClasses)
|
||
SceneAttri = "1,2,1224996690830819360"
|
||
If ModuleFre.PROTOCOL_VER.Equals("003") Then
|
||
SceneAttri = "1,2,1152921504606846976"
|
||
End If
|
||
|
||
ElseIf ModuleFre.Nodes(i).DefaultClass.Equals("CARD") Then
|
||
gTableRowTag.Set_G_Attributes(ModuleFre.Nodes(i).DefaultClass, BasicClasses)
|
||
SceneAttri = "1365,1,1152921504606846976"
|
||
ElseIf ModuleFre.Nodes(i).DefaultClass.Equals("SLIDER") Then
|
||
gTableRowTag.Set_G_Attributes(ModuleFre.Nodes(i).DefaultClass, BasicClasses)
|
||
SceneAttri = "2,1,1152921504606847008"
|
||
ElseIf ModuleFre.Nodes(i).DefaultClass.Equals("RKEY") Then
|
||
gTableRowTag.Set_G_Attributes(ModuleFre.Nodes(i).DefaultClass, BasicClasses)
|
||
SceneAttri = "4,12,1152921504606847008"
|
||
Else
|
||
gTableRowTag.Set_G_Attributes(ModuleFre.Nodes(i).DefaultClass, BasicClasses)
|
||
SceneAttri = "1,1,1152921504606846976"
|
||
End If
|
||
End If
|
||
gTableRowTag.G_DevNodeName = ModuleFre.Name
|
||
gTableRowTag.G_DevNodeIndex = ModuleFre.Nodes(i).LoopAddr ' i + 1
|
||
gTableRowTag.G_DevModeName = moduStrName
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.choose, "1")
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneAttribute, SceneAttri)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneID, _SceneID)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyVal, ModuleFre.Nodes(i).LoopAddr)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyName, ModuleFre.Nodes(i).DefaultAliasName)
|
||
|
||
'添加行Or插入行 ---如果已经添加服务则要用插入方式
|
||
If rowid >= _grd.Rows Then
|
||
_grd.AddItem("")
|
||
'_grd.Row(rowid).Locked = False
|
||
Dic_ActionConfiguration.Add(gTableRowTag)
|
||
Else
|
||
Dim growlock As Boolean = _grd.Row(rowid).Locked
|
||
_grd.Row(rowid).Locked = False
|
||
_grd.InsertRow(rowid, 1)
|
||
_grd.Row(rowid).Locked = growlock
|
||
' _grd.Row(rowid).Locked = False
|
||
Dic_ActionConfiguration.Insert(rowid - TableRowNumber.Max, gTableRowTag)
|
||
End If
|
||
|
||
'设置设备名
|
||
If j = 0 AndAlso i = 0 Then
|
||
_grd.Cell(rowid, TableColNumber.DeviceName).Text = moduStrName
|
||
_grd.Cell(rowid, TableColNumber.DeviceName).WrapText = True
|
||
Mergerow = rowid
|
||
End If
|
||
|
||
'设置 DI对应反馈灯
|
||
If Not (IsNothing(OPTdic) OrElse OPTdic.Count = 0) Then
|
||
If OPTdic.ContainsKey(ModuleFre.Nodes(i).LoopAddr) Then
|
||
Dim bgc As Integer = -1
|
||
If Integer.TryParse(OPTdic.Item(ModuleFre.Nodes(i).LoopAddr), bgc) Then
|
||
gTableRowTag.G_DicRow.Add(bgc, "Corresponding scenario")
|
||
_grd.Cell(rowid, bgc).Text = "Corresponding scenario"
|
||
_grd.Column(bgc).Visible = False
|
||
_grd.Column(bgc).Locked = True
|
||
End If
|
||
|
||
End If
|
||
End If
|
||
'设置表格
|
||
|
||
_grd.Cell(rowid, TableColNumber.SceneID).Text = _SceneID.ToString
|
||
_grd.Cell(rowid, TableColNumber.KeyVal).Text = ModuleFre.Nodes(i).LoopAddr '(i + 1).ToString
|
||
_grd.Cell(rowid, TableColNumber.KeyName).Text = ModuleFre.Nodes(i).DefaultAliasName
|
||
_grd.Cell(rowid, TableColNumber.choose).Text = "1"
|
||
_grd.Cell(rowid, TableColNumber.SceneAttribute).Text = SceneAttri
|
||
_SceneID = _SceneID + 1
|
||
|
||
_grd.Cell(rowid, TableColNumber.ServerAttribute).WrapText = True
|
||
|
||
If ModuleFre.Name.Equals("Voice") Then
|
||
_grd.Row(rowid).Locked = True
|
||
_grd.Cell(rowid, TableColNumber.SceneAttribute).Text = ""
|
||
gTableRowTag.G_DicRow.Item(TableColNumber.SceneAttribute) = ""
|
||
End If
|
||
Next
|
||
Next
|
||
'Dim rowlock = _grd.Row(24).Locked
|
||
'rowlock = _grd.Row(26).Locked
|
||
If nterace_DI.Count > 0 Then
|
||
Try
|
||
_grd.Range(Mergerow, TableColNumber.DeviceName, rowid, TableColNumber.DeviceName).Locked = False
|
||
_grd.Range(Mergerow, TableColNumber.DeviceName, rowid, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(Mergerow, TableColNumber.DeviceName, rowid, TableColNumber.DeviceName).Locked = True
|
||
Catch ex As Exception
|
||
|
||
End Try
|
||
|
||
End If
|
||
'rowlock = _grd.Row(24).Locked
|
||
'rowlock = _grd.Row(26).Locked
|
||
_grd.Range(TableRowNumber.Max - 1, TableColNumber.RowID, _grd.Rows - 1, _grd.Cols - 1).Alignment = AlignmentEnum.CenterCenter
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.SceneAttribute, _grd.Rows - 1, _grd.Cols - 1).CellType = CellTypeEnum.ComboBox
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.choose, _grd.Rows - 1, TableColNumber.choose).CellType = CellTypeEnum.CheckBox
|
||
|
||
End Sub
|
||
|
||
Public Function GetgrdRange(r As Integer, c As Integer, selectstr As tabRange) As String
|
||
Dim result As String = String.Empty
|
||
With _grd.Range(r, c, r, c)
|
||
Select Case selectstr
|
||
Case tabRange.devname
|
||
result = _grd.Cell(.FirstRow, .FirstCol).Text
|
||
Case tabRange.fc
|
||
result = .FirstCol
|
||
Case tabRange.lc
|
||
result = .LastCol
|
||
Case tabRange.fr
|
||
result = .FirstRow
|
||
Case tabRange.lr
|
||
result = .LastRow
|
||
End Select
|
||
Return result
|
||
|
||
End With
|
||
End Function
|
||
|
||
Private Function GetRowDevNametabRange(devname As String, colint As Integer, Optional startcrow As Integer = TableRowNumber.Max) As CtabRange
|
||
Dim result As CtabRange = Nothing
|
||
Dim g_devname As CtabRange
|
||
For i = startcrow To _grd.Rows - 1
|
||
g_devname = New CtabRange(_grd, i, colint)
|
||
If devname.Equals(g_devname.devname) Then
|
||
result = g_devname
|
||
Exit For
|
||
End If
|
||
i = g_devname.lr
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
Private Function GetCoLDevNametabRange(devname As String, colint As Integer, Optional startcol As Integer = TableColNumber.InsertColumn) As CtabRange
|
||
Dim result As CtabRange = Nothing
|
||
Dim g_devname As CtabRange
|
||
For i = startcol To _grd.Cols - 1
|
||
g_devname = New CtabRange(_grd, colint, i)
|
||
If devname.Equals(g_devname.devname) Then
|
||
result = g_devname
|
||
Exit For
|
||
End If
|
||
i = g_devname.lc
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
|
||
|
||
''' <summary>
|
||
''' 模型关联的表格控件
|
||
''' </summary>
|
||
''' <returns></returns>
|
||
Protected Friend Sub LockGridAutoRedraw()
|
||
If _grd Is Nothing Then Return
|
||
If _autoRedraw = 0 Then
|
||
_grd.AutoRedraw = False
|
||
End If
|
||
_autoRedraw += 1
|
||
|
||
End Sub
|
||
|
||
Protected Friend Sub UnLockGridAutoRedraw()
|
||
If _grd Is Nothing Then Return
|
||
_autoRedraw -= 1
|
||
If _autoRedraw = 0 Then
|
||
_grd.AutoRedraw = True
|
||
_grd.Refresh()
|
||
Else
|
||
_autoRedraw = 0
|
||
End If
|
||
End Sub
|
||
|
||
#End Region
|
||
#Region "表格事件"
|
||
Public Cell_x, Cell_y As Integer
|
||
Private Sub Grid_Click(Sender As Object, e As EventArgs)
|
||
'Console.WriteLine($"Grid_Click{_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text }")
|
||
Dim C_x, C_y As Integer
|
||
C_x = _grd.ActiveCell.Row
|
||
C_y = _grd.ActiveCell.Col
|
||
' Console.WriteLine($"C_x:{C_x} Cell_x:{Cell_x} C_y:{C_y} Cell_y:{Cell_y} ")
|
||
If C_x < TableRowNumber.Max Then Return
|
||
If C_y = 5 Then '新加
|
||
If Cell_x = C_x AndAlso Cell_y = C_y Then Return '防止 重复点击
|
||
End If
|
||
'Console.WriteLine(_grd.Column(Cell_y).Locked)
|
||
If Cell_x >= _grd.Rows OrElse Cell_y >= _grd.Cols Then
|
||
Cell_x = 0
|
||
Cell_y = 0
|
||
End If
|
||
|
||
|
||
_grd.Range(Cell_x, 0, Cell_x, _grd.Cols - 1).BackColor = Color.White
|
||
_grd.Range(0, Cell_y, _grd.Rows - 1, Cell_y).BackColor = Color.White
|
||
|
||
|
||
If C_x < TableRowNumber.Max OrElse C_y < TableColNumber.SceneID Then Return
|
||
|
||
_grd.Range(C_x, 2, C_x, _grd.Cols - 1).BackColor = Color.LightBlue
|
||
If Not (C_y < TableColNumber.InsertColumn) Then
|
||
_grd.Range(TableRowNumber.FunctionChildNodeID, C_y, _grd.Rows - 1, C_y).BackColor = Color.LightBlue
|
||
End If
|
||
CheckGridData()
|
||
_grd.Cell(C_x, C_y).BackColor = Color.LightPink
|
||
|
||
Cell_x = C_x
|
||
Cell_y = C_y
|
||
'Console.WriteLine(_grd.Cell(Cell_x, Cell_y).Locked)
|
||
End Sub
|
||
|
||
Public Function CheckGridData() As Boolean
|
||
Dim result As Boolean = True
|
||
For r = 7 To _grd.Rows - 1
|
||
For c = 6 To _grd.Cols - 1
|
||
If _grd.Cell(r, c).ForeColor = Color.DarkRed Then
|
||
_grd.Cell(r, c).BackColor = Color.OrangeRed
|
||
Console.WriteLine($" r:{r} c:{c} colname :{_grd.Cell(TableRowNumber.FunctionChildNodeAnother, c).Text} text:{_grd.Cell(r, c).Text}")
|
||
result = False
|
||
End If
|
||
Next
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
|
||
Private Sub Grid_DoubleClick(Sender As Object, e As EventArgs)
|
||
'Console.WriteLine($"Grid_DoubleClick{_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text }")
|
||
If _grd.ActiveCell.Row = TableRowNumber.DeviceName AndAlso _grd.ActiveCell.Col = TableColNumber.DeviceName Then
|
||
Dim fromshow As New PowerSupply
|
||
fromshow.G_ActionConfiguration = Dic_ActionConfiguration
|
||
fromshow.ParseDeviceList(Dic_Devicemodel, _grd)
|
||
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
|
||
ElseIf _grd.ActiveCell.Row > TableRowNumber.Max - 1 AndAlso _grd.ActiveCell.Col = TableColNumber.DeviceName Then
|
||
'取到设备名
|
||
Dim devname As String = GetgrdRange(_grd.ActiveCell.Row, TableColNumber.DeviceName, tabRange.devname)
|
||
ModifyingDeviceInformationGroup(devname)
|
||
ElseIf _grd.ActiveCell.Row = TableRowNumber.DeviceName AndAlso _grd.ActiveCell.Col > TableColNumber.InsertColumn Then
|
||
'取到设备名
|
||
Dim devname As String = GetgrdRange(_grd.ActiveCell.Row, _grd.ActiveCell.Col, tabRange.devname)
|
||
ModifyingDeviceInformationGroup(devname)
|
||
|
||
ElseIf _grd.ActiveCell.Row = TableRowNumber.FunctionChildNodeAnother AndAlso _grd.ActiveCell.Col = TableColNumber.DeviceName Then
|
||
Dim from1 As New DeviceListFrom
|
||
Dim steinput As String = _grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text.Trim
|
||
|
||
from1.SetDevnameTotable(steinput, Dic_Devicemodel)
|
||
If from1.ShowDialog() <> DialogResult.OK Then Return
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = from1.G_result
|
||
|
||
|
||
ElseIf _grd.ActiveCell.Row >= TableRowNumber.Max AndAlso _grd.ActiveCell.Col = TableColNumber.SceneAttribute Then
|
||
If String.IsNullOrEmpty(_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text) Then Return
|
||
Dim fromshow As New ExecutionCondition
|
||
fromshow.DicDevicemodel = Dic_Devicemodel
|
||
fromshow.G_grid = _grd
|
||
fromshow.G_ActionConfiguration = Dic_ActionConfiguration
|
||
fromshow.g_BasicClasses = BasicClasses
|
||
fromshow.G_Row = _grd.ActiveCell.Row
|
||
fromshow.G_celltag = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Tag)
|
||
If IsNothing(fromshow.G_celltag) Then
|
||
fromshow.G_celltag = New Dictionary(Of String, String)
|
||
End If
|
||
fromshow.G_ConfigActionConcitons = Condictions
|
||
fromshow.G_input = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.SceneAttribute).Text
|
||
fromshow.G_ModeDevType = Dic_ActionConfiguration.Item(_grd.ActiveCell.Row - TableRowNumber.Max).G_KeyType.ToArray
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Tag = JsonConvert.SerializeObject(fromshow.G_celltag)
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = fromshow.G_Result
|
||
|
||
End If
|
||
|
||
|
||
End Sub
|
||
|
||
Public Sub ModifyingDeviceInformationGroup(devname As String)
|
||
'判断设备是否是外设
|
||
If String.IsNullOrEmpty(devname) OrElse String.IsNullOrEmpty(hostname) Then
|
||
Return
|
||
End If
|
||
If devname.Equals(hostname) Then
|
||
MsgBox("主机不可修改设备属性!!")
|
||
Return
|
||
End If
|
||
If devname.Equals("HOSTSERVICE") Then
|
||
MsgBox("服务不可修改设备属性!!")
|
||
Return
|
||
End If
|
||
Dim cdicv As New Dictionary(Of Integer, String) '列号+DO地址
|
||
Dim rdicv As New Dictionary(Of Integer, String) '行号+DI地址
|
||
Dim rvdicv As New Dictionary(Of String, String) 'DO地址+DI地址
|
||
Dim startrow, startcol As Integer
|
||
'获取外设DO的所在列号集合
|
||
Dim tabledev As CtabRange = GetCoLDevNametabRange(devname, TableRowNumber.DeviceName)
|
||
If Not IsNothing(tabledev) Then
|
||
startcol = tabledev.fc
|
||
tabledev = GetCoLDevNametabRange("DO", TableRowNumber.FunctionName, tabledev.fc)
|
||
End If
|
||
If Not IsNothing(tabledev) Then
|
||
For i = tabledev.fc To tabledev.lc
|
||
cdicv.Add(i, _grd.Cell(TableRowNumber.FunctionChildNodeID, i).Text)
|
||
Next
|
||
End If
|
||
'行号集合
|
||
Dim devmodw As DeviceModel = Dic_Devicemodel.Item(devname)
|
||
tabledev = GetRowDevNametabRange(devname, TableColNumber.DeviceName)
|
||
'不一定在行有设备名
|
||
If Not IsNothing(tabledev) Then
|
||
startrow = tabledev.fr
|
||
For Each index In devmodw.Nodes
|
||
If index.Name.Equals("DI") Then
|
||
For Each node In index.Nodes
|
||
For i = tabledev.fr To tabledev.lr
|
||
Console.WriteLine($"{_grd.Cell(i, TableColNumber.KeyName).Text}_{node.Name}")
|
||
If _grd.Cell(i, TableColNumber.KeyVal).Text.Equals(node.LoopAddr) Then
|
||
If rdicv.ContainsKey(i) Then
|
||
Continue For
|
||
Else
|
||
rdicv.Add(i, _grd.Cell(i, TableColNumber.KeyVal).Text)
|
||
End If
|
||
End If
|
||
Next
|
||
Next
|
||
Exit For
|
||
End If
|
||
Next
|
||
'匹配 DI_DO 键值对
|
||
For Each index In rdicv
|
||
For Each node In cdicv
|
||
If _grd.Cell(index.Key, node.Key).Text.Trim.Equals("Corresponding scenario") Then
|
||
'_grd.Cell(index.Key, node.Key).Text = ""
|
||
If rvdicv.ContainsKey(index.Value) Then
|
||
Exit For
|
||
Else
|
||
rvdicv.Add(index.Value, node.Value)
|
||
Exit For
|
||
End If
|
||
End If
|
||
Next
|
||
If Not rvdicv.ContainsKey(index.Value) Then
|
||
rvdicv.Add(index.Value, "")
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
'设置到弹窗显示
|
||
Dim from1 As New AddPeripherals
|
||
from1.g_Devicemodel = Dic_Devicemodel
|
||
from1.g_grd = _grd
|
||
from1.g_Devintemp = GetDevLoopName("Temp")
|
||
from1.g_DevRELAYrow = GetDevLoopName("RELAY", "PB_RELAY_DEVICE")
|
||
from1.g_Devinfraredrow = GetDevLoopName("INFRARED_FORWARD")
|
||
from1.g_DevDimming = GetDevLoopName("Dimming")
|
||
|
||
from1.g_Devin485fraredrow = GetDevLoopName("RS485_Curtain")
|
||
from1.g_DevinCURTAINdrow = GetDevLoopName("CURTAIN")
|
||
from1.g_Devservice = GetHOSTSERVICENumber()
|
||
from1.g_DevScenenumber = GetSceneNumbeAr()
|
||
from1.g_ColumnAnothername = ColumnAnothername
|
||
from1.EditFeedbackLamp(rvdicv, devmodw)
|
||
If from1.ShowDialog() <> DialogResult.OK Then Return
|
||
'根据弹窗设置重新设置界面置
|
||
|
||
_grd.Cell(TableRowNumber.DeviceName, startcol).Text = devmodw.Name
|
||
If startrow > 0 Then
|
||
For ri = tabledev.fr To tabledev.lr
|
||
Dic_ActionConfiguration(ri - TableRowNumber.Max).G_DevModeName = devmodw.Name
|
||
Next
|
||
_grd.Cell(startrow, TableColNumber.DeviceName).Text = devmodw.Name
|
||
End If
|
||
|
||
|
||
|
||
If IsNothing(from1.ResulDic) OrElse from1.ResulDic.Count = 0 Then Return
|
||
Dim colstr As String
|
||
LockGridAutoRedraw()
|
||
For Each rindex In rdicv
|
||
|
||
If from1.ResulDic.ContainsKey(rindex.Value) Then
|
||
colstr = from1.ResulDic.Item(rindex.Value)
|
||
'_grd.Cell(rindex.Key, TableColNumber.KeyName).Text =devmodw.
|
||
|
||
For Each cnode In cdicv
|
||
If _grd.Cell(rindex.Key, cnode.Key).Text.Trim.Equals("Corresponding scenario") Then
|
||
_grd.Cell(rindex.Key, cnode.Key).Text = ""
|
||
_grd.Column(cnode.Key).Visible = True
|
||
_grd.Column(cnode.Key).Locked = False
|
||
End If
|
||
If cnode.Value.Equals(colstr) Then
|
||
_grd.Cell(rindex.Key, cnode.Key).Text = "Corresponding scenario"
|
||
_grd.Column(cnode.Key).Visible = False
|
||
_grd.Column(cnode.Key).Locked = True
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
UnLockGridAutoRedraw()
|
||
End Sub
|
||
|
||
Private Function DetermineDeviceType(Resultmodel As DeviceModel) As Integer
|
||
|
||
Dim result As Integer = 0
|
||
For Each ModuleFre In Resultmodel.Nodes
|
||
Select Case ModuleFre.Name
|
||
Case "Temp"
|
||
Return 1
|
||
Case "CURTAIN"
|
||
Return 2
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
Return 4
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
Return 4
|
||
Case "语音"
|
||
Return 3
|
||
End Select
|
||
Next
|
||
Return result
|
||
End Function
|
||
|
||
Public Sub UnlockColumn(Resultmodel As DeviceModel, Optional mbool As Boolean = True)
|
||
Select Case DetermineDeviceType(Resultmodel)
|
||
Case 0
|
||
Return
|
||
Case 1
|
||
|
||
Case 2
|
||
Case 3
|
||
Case 4
|
||
Case Else
|
||
Return
|
||
End Select
|
||
End Sub
|
||
|
||
|
||
Private Sub Grid_CellChange(Sender As Object, e As FlexCell.Grid.CellChangeEventArgs)
|
||
|
||
'Console.WriteLine($"Grid_CellChange_{_grd.Cell(e.Row, e.Col).Text }")
|
||
Dim errindex As Integer = 0
|
||
Try
|
||
|
||
Select Case e.Row
|
||
'Case ComboDropDownON.HostDev
|
||
' For Each HostDevFN In IO.Directory.GetFiles(HostDevFNP)
|
||
' Grid1.ComboBox(0).Items.Add(HostDevFN.Substring(HostDevFNP.Length, HostDevFN.Length - HostDevFNP.Length - 4))
|
||
' Next
|
||
Case TableRowNumber.FunctionAnotherName
|
||
If TableColNumber.ServerAttribute = e.Col Then
|
||
Dim dtime As Integer = 0
|
||
Try
|
||
dtime = CInt(_grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1).Text)
|
||
If dtime < -24 OrElse dtime > 24 Then
|
||
dtime = 0
|
||
End If
|
||
Catch ex As Exception
|
||
dtime = 0
|
||
End Try
|
||
_grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1).Text = dtime
|
||
_grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1).CellType = CellTypeEnum.ComboBox
|
||
_grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1).Locked = False
|
||
End If
|
||
|
||
Case >= TableRowNumber.Max
|
||
errindex = 1
|
||
Console.WriteLine()
|
||
If e.Col = TableColNumber.SceneAttribute Then
|
||
errindex = 3
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(e.Row - TableRowNumber.Max)
|
||
If ExecutionCondition.CheckDataIsOk(_grd.Cell(e.Row, e.Col).Text, Condictions, Dic_ActionConfiguration.Item(e.Row - TableRowNumber.Max).G_KeyType.ToArray, rowtag, Dic_ActionConfiguration, _grd) Then
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
AddTableToTableRowTag(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.Black
|
||
Else
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.DarkRed
|
||
AddTableToTableRowTag(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
End If
|
||
|
||
|
||
|
||
ElseIf e.Col = TableColNumber.ServerAttribute Then
|
||
errindex = 4
|
||
Dim hostNode As DeviceChildNodeClass = Nothing
|
||
For Each Anode In Dic_Devicemodel.Item(hostname).Nodes
|
||
If Anode.Name.Equals("HOSTSERVICE") Then
|
||
hostNode = Anode
|
||
Exit For
|
||
End If
|
||
Next
|
||
If ServiceAttribute.CheckDataIsOk(_grd.Cell(e.Row, e.Col).Text, hostNode) Then
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.Black
|
||
Dim serverstr As String = AddTableToTableRowTagX(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
If String.IsNullOrEmpty(_grd.Cell(e.Row, e.Col).Text) Then
|
||
Dim wbuff() As String = serverstr.Trim.Split(vbLf)
|
||
For Each index In wbuff
|
||
grdRemoveServerRow(index)
|
||
Next
|
||
|
||
Return
|
||
End If
|
||
Dim vbuff() As String = _grd.Cell(e.Row, e.Col).Text.Split(vbLf)
|
||
|
||
For Each index In vbuff
|
||
Dim vbuf() As String = index.Split(",")
|
||
grdInsertServerRow(hostname, "HOSTSERVICE", CInt(vbuf(0)), "SERVICE", vbuf(1), hostNode)
|
||
Next
|
||
|
||
Else
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.DarkRed
|
||
AddTableToTableRowTagX(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
End If
|
||
ElseIf e.Col = TableColNumber.KeyName Then
|
||
|
||
AddTableToTableRowTagtow(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
'ElseIf _grd.Cell(TableRowNumber.FunctionName, e.Col).Text.Equals("MUSIC") Then
|
||
' errindex = 2
|
||
' 'If MusicArrangement.CheckDataIsOk(_grd.Cell(e.Row, e.Col).Text, BasicClasses) Then
|
||
' ' _grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
' ' AddTableToTableRowTagtow(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
' 'Else
|
||
' ' _grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
' 'End If
|
||
' Dim g_devname As New CtabRange(_grd, TableRowNumber.FunctionName, e.Col)
|
||
' If ActionParameter.CheckDataIsOk(g_devname.devname.ToUpper, _grd.Cell(e.Row, e.Col).Text, BasicClasses) Then
|
||
' _grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
' AddTableToTableRowTagtow(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
' Else
|
||
' _grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
' End If
|
||
ElseIf e.Col = TableColNumber.choose Then
|
||
|
||
AddTableToTableRowTagtow(e.Row, e.Col, _grd.Cell(e.Row, e.Col).Text)
|
||
|
||
ElseIf e.Col > TableColNumber.ServerAttribute Then
|
||
errindex = 5
|
||
Dim g_devname As New CtabRange(_grd, TableRowNumber.FunctionName, e.Col)
|
||
Dim highpric As String = _grd.Cell(e.Row, e.Col).Text
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(e.Row - TableRowNumber.Max)
|
||
If g_devname.devname.Equals("DO") Then
|
||
g_devname.devname = g_devname.devname.Replace("DO", "LIGHT")
|
||
ElseIf g_devname.devname.Equals("CURTAIN") Then
|
||
g_devname.devname = g_devname.devname.Replace("CURTAIN", "DRY_CURTAIN")
|
||
End If
|
||
If highpric.Equals("advanced") Then
|
||
Dim fromshow As New ActionParameter
|
||
fromshow.g_DevNodename = rowtag.G_DevNodeName
|
||
fromshow.KeyName = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.KeyName).Text
|
||
fromshow.g_ExecutionMode = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.SceneAttribute).Text
|
||
Dim celltex As String = String.Empty
|
||
Dim celltxt As String = String.Empty
|
||
If rowtag.G_DicRow.ContainsKey(e.Col.ToString) Then
|
||
celltex = rowtag.G_DicRow.Item(e.Col.ToString)
|
||
Else
|
||
celltex = ""
|
||
End If
|
||
fromshow.GetEquipmentParameter(g_devname.devname.ToUpper, celltex, BasicClasses)
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then
|
||
If celltex.Contains("*") Then
|
||
highpric = EstimateFilag(celltex, g_devname.devname)
|
||
Else
|
||
highpric = celltex
|
||
End If
|
||
|
||
CheckGridCellChangeIsOk(g_devname, celltex, e)
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = highpric
|
||
Return
|
||
End If
|
||
|
||
highpric = EstimateFilag(fromshow.G_Result, g_devname.devname)
|
||
CheckGridCellChangeIsOk(g_devname, fromshow.G_Result, e)
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = highpric
|
||
Return
|
||
Else
|
||
|
||
End If
|
||
'Dim highpric As String = _grd.Cell(e.Row, e.Col).Text.Trim
|
||
|
||
If rowtag.G_DicRow.ContainsKey(e.Col) Then
|
||
Dim celltxt As String = rowtag.G_DicRow.Item(e.Col)
|
||
celltxt = EstimateFilag(celltxt, g_devname.devname)
|
||
If Not String.IsNullOrEmpty(highpric) AndAlso highpric.Equals(celltxt) Then
|
||
highpric = rowtag.G_DicRow.Item(e.Col)
|
||
End If
|
||
End If
|
||
CheckGridCellChangeIsOk(g_devname, highpric, e)
|
||
|
||
End If
|
||
Case = TableRowNumber.FunctionChildNodeAnother
|
||
If e.Col > TableColNumber.ServerAttribute Then
|
||
|
||
Dim gdevname = New CtabRange(_grd, TableRowNumber.DeviceName, e.Col)
|
||
Dim gTdevname = New CtabRange(_grd, TableRowNumber.FunctionName, e.Col)
|
||
Dim val As String = $"{gdevname.devname }*{_grd.Cell(TableRowNumber.FunctionChildNodeID, e.Col).Text }*{gTdevname.devname }"
|
||
Dim key As String = $"{gdevname.devname}_{ _grd.Cell(TableRowNumber.FunctionChildNodeAnother, e.Col).Text}"
|
||
'Dim key As String = $"{_grd.Cell(TableRowNumber.FunctionChildNodeAnother, e.Col).Text}"
|
||
If String.IsNullOrEmpty(key) Then Return
|
||
If ColumnAnothername.ContainsKey(key) Then
|
||
MsgBox($"{key}:该别名已存在!请重新命名!")
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, e.Col).Text = ""
|
||
Console.WriteLine($"{ e.Col}:{_grd.Cell(TableRowNumber.FunctionChildNodeAnother, e.Col).Text}")
|
||
Return
|
||
Else
|
||
For Each strval In ColumnAnothername
|
||
If strval.Value.Equals(val) Then
|
||
ColumnAnothername.Remove(strval.Key)
|
||
Exit For
|
||
End If
|
||
Next
|
||
ColumnAnothername.Add(key, val)
|
||
End If
|
||
End If
|
||
|
||
|
||
|
||
End Select
|
||
Catch ex As Exception
|
||
MsgBox($"{errindex}_{ex.Message}")
|
||
End Try
|
||
|
||
End Sub
|
||
Public Sub CheckGridCellChangeIsOk(g_devname As CtabRange, highpric As String, e As FlexCell.Grid.CellChangeEventArgs)
|
||
|
||
If g_devname.devname.ToUpper.Equals("DIMMING") OrElse
|
||
g_devname.devname.ToUpper.Equals("485MUSIC") OrElse
|
||
g_devname.devname.ToUpper.Equals("INFRARED_FORWARD") OrElse
|
||
g_devname.devname.ToUpper.Equals("PB_RELAY_DEVICE") OrElse
|
||
g_devname.devname.ToUpper.Equals("PB_STRIP_DEVICE") OrElse
|
||
g_devname.devname.ToUpper.Equals("PB_LED_DEVICE") OrElse
|
||
g_devname.devname.ToUpper.Equals("DRY_CURTAIN") OrElse
|
||
g_devname.devname.ToUpper.Equals("LIGHT") OrElse
|
||
g_devname.devname.ToUpper.Equals("RELAY") OrElse
|
||
g_devname.devname.ToUpper.Equals("TEMP") OrElse
|
||
g_devname.devname.ToUpper.Equals("PB_LINE_CONTROL") OrElse
|
||
g_devname.devname.ToUpper.Equals("485FloorHeat".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("485FreshAir".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("CLED_FRESHAIR".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("CLEDFLOORHEAT".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("DRY_NoCard".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("Dev_ColorTemp".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("RKEY".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("BLEMUSIC".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("RS485_Curtain".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("Carbon_Device".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("Scene_Restore".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("HOPO_Curtain".ToUpper) OrElse
|
||
g_devname.devname.ToUpper.Equals("MUSIC".ToUpper) Then
|
||
If ActionParameter.CheckDataIsOk(g_devname.devname.ToUpper, highpric, BasicClasses) Then
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.Black
|
||
AddTableToTableRowTagtow(e.Row, e.Col, highpric)
|
||
Else
|
||
If CheckDataIsOk(g_devname.devname, highpric) Then
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.Black
|
||
AddTableToTableRowTagtow(e.Row, e.Col, highpric)
|
||
Else
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.DarkRed
|
||
AddTableToTableRowTagtow(e.Row, e.Col, highpric)
|
||
End If
|
||
End If
|
||
Else
|
||
If CheckDataIsOk(g_devname.devname, highpric) Then
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.White
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.Black
|
||
AddTableToTableRowTagtow(e.Row, e.Col, highpric)
|
||
Else
|
||
_grd.Cell(e.Row, e.Col).BackColor = Color.OrangeRed
|
||
_grd.Cell(e.Row, e.Col).ForeColor = Color.DarkRed
|
||
AddTableToTableRowTagtow(e.Row, e.Col, highpric)
|
||
End If
|
||
|
||
End If
|
||
|
||
End Sub
|
||
|
||
|
||
Public Sub grdRemoveServerRow(serverstr As String)
|
||
|
||
If String.IsNullOrEmpty(serverstr) Then Return
|
||
Dim buf() As String = serverstr.Split(",")
|
||
Dim serverindex As String = $"{buf(0)},{buf(1)}"
|
||
'存在调用则不用删除
|
||
For i As Integer = TableRowNumber.Max To _grd.Rows - 1
|
||
If String.IsNullOrEmpty(_grd.Cell(i, TableColNumber.ServerAttribute).Text.Trim) Then Continue For
|
||
Dim Clfbuf() As String = _grd.Cell(i, TableColNumber.ServerAttribute).Text.Trim.Split(vbLf)
|
||
For Each index In Clfbuf
|
||
If index.Trim.IndexOf(serverindex) = 0 Then
|
||
Return
|
||
End If
|
||
Next
|
||
Next
|
||
If Not _ServerAction.ContainsKey(serverindex) Then Return
|
||
Dim deleterow As Integer = _ServerAction.Item(serverindex)
|
||
'
|
||
Dim srowid As CtabRange = GetRowDevNametabRange("HOSTSERVICE", TableColNumber.DeviceName)
|
||
'表格删除
|
||
|
||
If srowid.fr = deleterow Then
|
||
_grd.Cell(deleterow, TableColNumber.DeviceName).Text = "HOSTSERVICE"
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Locked = False
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, _grd.Rows - 1, TableColNumber.DeviceName).Locked = True
|
||
End If
|
||
_grd.Row(deleterow).Delete()
|
||
'内存删除
|
||
Dic_ActionConfiguration.RemoveAt(deleterow - TableRowNumber.Max)
|
||
'更服务所在行行号
|
||
For i As Integer = 0 To _ServerAction.Count
|
||
If _ServerAction.Values(i) > deleterow Then
|
||
_ServerAction.Item(_ServerAction.Keys(i)) = _ServerAction.Values(i) - 1
|
||
End If
|
||
Next
|
||
'删除服务动作
|
||
_ServerAction.Remove(serverindex)
|
||
|
||
_ServerInsertRows = _ServerInsertRows - 1
|
||
End Sub
|
||
|
||
|
||
Public Sub grdInsertServerRow(DevModeName As String, DevNodeName As String, DevNodeIndex As Integer, rowtype As String, Keytype As String, hostNode As DeviceChildNodeClass)
|
||
Dim serverindex As String = $"{DevNodeIndex},{Keytype}"
|
||
If _ServerAction.ContainsKey(serverindex) Then Return
|
||
Dim InsertRow As Integer = _grd.Rows
|
||
|
||
_ServerAction.Add(serverindex, InsertRow)
|
||
|
||
Dim gTableRowTag As New TableRowTag()
|
||
Dim KeyName As String = ServiceAttribute.Getservername(DevNodeIndex, hostNode)
|
||
gTableRowTag.G_DevNodeName = DevNodeName
|
||
gTableRowTag.G_DevNodeIndex = DevNodeIndex
|
||
gTableRowTag.G_DevModeName = DevModeName
|
||
gTableRowTag.Set_G_Attributes(rowtype, BasicClasses, Keytype)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.choose, "1")
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneAttribute, $"{Keytype},1,0")
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.SceneID, _SceneID)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyVal, DevNodeIndex.ToString)
|
||
gTableRowTag.G_DicRow.Add(TableColNumber.KeyName, KeyName)
|
||
|
||
' If _grd.Rows <= InsertRow Then
|
||
|
||
'获取服务组起始行号
|
||
Dim srowid As CtabRange = GetRowDevNametabRange("HOSTSERVICE", TableColNumber.DeviceName)
|
||
|
||
_grd.AddItem("")
|
||
Dic_ActionConfiguration.Add(gTableRowTag)
|
||
Dim rindex As Integer = _grd.Rows - 1
|
||
_grd.Cell(rindex, TableColNumber.DeviceName).Text = $"{DevNodeName}"
|
||
_grd.Cell(rindex, TableColNumber.SceneID).Text = _SceneID.ToString
|
||
_grd.Cell(rindex, TableColNumber.KeyVal).Text = DevNodeIndex.ToString
|
||
_grd.Cell(rindex, TableColNumber.KeyName).Text = KeyName
|
||
_grd.Cell(rindex, TableColNumber.choose).Text = "1"
|
||
_grd.Cell(rindex, TableColNumber.SceneAttribute).Text = $"{Keytype},1,0"
|
||
_SceneID = _SceneID + 1
|
||
|
||
If Not IsNothing(srowid) Then
|
||
_grd.Range(srowid.fr, TableColNumber.DeviceName, rindex, TableColNumber.DeviceName).Locked = False
|
||
_grd.Range(srowid.fr, TableColNumber.DeviceName, rindex, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(srowid.fr, TableColNumber.DeviceName, rindex, TableColNumber.DeviceName).Locked = True
|
||
End If
|
||
|
||
|
||
'Else
|
||
' _grd.InsertRow(InsertRow, 1)
|
||
' Dic_ActionConfiguration.Insert(_ServerInsertRows, gTableRowTag)
|
||
' _grd.Cell(InsertRow, TableColNumber.DeviceName).Text = $"{DevNodeName}"
|
||
' _grd.Cell(InsertRow, TableColNumber.SceneID).Text = _SceneID.ToString
|
||
' _grd.Cell(InsertRow, TableColNumber.KeyVal).Text = DevNodeIndex.ToString
|
||
' _grd.Cell(InsertRow, TableColNumber.KeyName).Text = KeyName
|
||
' _grd.Cell(InsertRow, TableColNumber.choose).Text = "1"
|
||
' _grd.Cell(InsertRow, TableColNumber.SceneAttribute).Text = $"{Keytype},1,0"
|
||
|
||
'End If
|
||
|
||
|
||
|
||
|
||
|
||
|
||
_ServerInsertRows = _ServerInsertRows + 1
|
||
_grd.Range(TableRowNumber.Max - 1, TableColNumber.RowID, _grd.Rows - 1, _grd.Cols - 1).Alignment = AlignmentEnum.CenterCenter
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.SceneAttribute, _grd.Rows - 1, _grd.Cols - 1).CellType = CellTypeEnum.ComboBox
|
||
_grd.Range(TableRowNumber.Max, TableColNumber.choose, _grd.Rows - 1, TableColNumber.choose).CellType = CellTypeEnum.CheckBox
|
||
|
||
End Sub
|
||
|
||
Public Sub ChangeTheServiceLineNumber()
|
||
'获取服务组起始行号
|
||
Dim srowid As CtabRange = GetRowDevNametabRange("HOSTSERVICE", TableColNumber.DeviceName)
|
||
If IsNothing(srowid) Then Return
|
||
Dim index As String
|
||
Dim buff() As String
|
||
For i = srowid.fr To srowid.lr
|
||
|
||
index = _grd.Cell(i, TableColNumber.KeyVal).Text.Trim
|
||
buff = _grd.Cell(i, TableColNumber.SceneAttribute).Text.Trim.Split(",")
|
||
index = $"{index},{buff(0)}"
|
||
_ServerAction.Item(index) = i
|
||
|
||
Next
|
||
End Sub
|
||
|
||
|
||
Private Sub AddTableToTableRowTag(row As Integer, col As Integer, text As String)
|
||
|
||
If String.IsNullOrEmpty(text) Then Return
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(row - TableRowNumber.Max)
|
||
If rowtag.G_DicRow.ContainsKey(col.ToString) Then
|
||
rowtag.G_DicRow.Item(col.ToString) = text
|
||
Else
|
||
rowtag.G_DicRow.Add(col.ToString, text)
|
||
End If
|
||
|
||
End Sub
|
||
Private Sub AddTableToTableRowTagtow(row As Integer, col As Integer, text As String)
|
||
|
||
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(row - TableRowNumber.Max)
|
||
If rowtag.G_DicRow.ContainsKey(col.ToString) Then
|
||
rowtag.G_DicRow.Item(col.ToString) = text
|
||
Else
|
||
rowtag.G_DicRow.Add(col.ToString, text)
|
||
End If
|
||
|
||
End Sub
|
||
Private Function AddTableToTableRowTagX(row As Integer, col As Integer, text As String) As String
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(row - TableRowNumber.Max)
|
||
Dim reslut As String = String.Empty
|
||
If String.IsNullOrEmpty(text) Then
|
||
If rowtag.G_DicRow.ContainsKey(col.ToString) Then
|
||
reslut = rowtag.G_DicRow.Item(col.ToString)
|
||
End If
|
||
|
||
End If
|
||
|
||
If rowtag.G_DicRow.ContainsKey(col.ToString) Then
|
||
reslut = rowtag.G_DicRow.Item(col.ToString)
|
||
rowtag.G_DicRow.Item(col.ToString) = text
|
||
Else
|
||
rowtag.G_DicRow.Add(col.ToString, text)
|
||
End If
|
||
Return reslut
|
||
End Function
|
||
|
||
Public Function GetComboDropDownDic() As Dictionary(Of String,List(Of String))
|
||
Dim dic As New Dictionary(Of String,List(Of String))
|
||
Dim typeInten() As String = {"RELAY","RS485_Curtain".ToUpper,"LIGHT","CURTAIN","DRY_CURTAIN","DIMMING","TEMP","DO",
|
||
"INFRARED_FORWARD","CLED_FRESHAIR","CLEDFLOORHEAT","485FreshAir".ToUpper,"485FloorHeat".ToUpper,"PB_LINE_CONTROL",
|
||
"PB_LED_DEVICE","PB_STRIP_DEVICE","PB_RELAY_DEVICE","DRY_NoCard".ToUpper,"Dev_ColorTemp".ToUpper,"RKEY".ToUpper,
|
||
"BLEMUSIC".ToUpper,"Carbon_Device".ToUpper,"HOPO_Curtain".ToUpper,"Scene_Restore".ToUpper}
|
||
Try
|
||
For Each index In typeInten
|
||
AddLog($"获取类型{index}的下拉选项")
|
||
|
||
Dim li As New List(Of String)
|
||
|
||
If index.Equals("DO".ToUpper) Then
|
||
Dim strarry() As String = {"open","close","flash","Corresponding scenario"}
|
||
li.AddRange(strarry)
|
||
End If
|
||
Select Case index
|
||
Case "RELAY","PB_RELAY_DEVICE"
|
||
Dim cl = [Enum].GetValues(GetType(TableColSwitchKeyDate))
|
||
For Each Cindex In cl
|
||
li.Add(Chr(Cindex))
|
||
Next
|
||
Case "RS485_Curtain".ToUpper,"CURTAIN","DRY_CURTAIN"
|
||
Dim strarry() As String = {"open","close","stop","intertangent"}
|
||
li.AddRange(strarry)
|
||
Case "DIMMING","PB_LINE_CONTROL","PB_STRIP_DEVICE","PB_LED_DEVICE"
|
||
Dim strarry() As String = {Chr(TableColSwitchKeyDate.TurnDrown).ToString(),"5","20","50",Chr(TableColSwitchKeyDate.TurnOn).ToString()}
|
||
li.AddRange(strarry)
|
||
Case "TEMP","CLEDFLOORHEAT","485FloorHeat".ToUpper
|
||
Dim strarry() As String = {"Open 26 degrees","close"}
|
||
li.AddRange(strarry)
|
||
Case "INFRARED_FORWARD"
|
||
Dim strarry() As String = {"Turn on the TV","Turn off the TV","Mute ","volume+","volume-"}
|
||
li.AddRange(strarry)
|
||
Case "485FreshAir".ToUpper,"CLED_FRESHAIR"
|
||
Dim strarry() As String = {"open","close"}
|
||
li.AddRange(strarry)
|
||
Case "LIGHT"',"DO"
|
||
Dim strarry() As String = {"open","close","flash","Corresponding scenario"}
|
||
li.AddRange(strarry)
|
||
End Select
|
||
If li.Count > 0 OrElse index.Equals("DRY_NoCard".ToUpper) OrElse index.Equals("HOPO_Curtain".ToUpper) OrElse index.Equals("Dev_ColorTemp".ToUpper) OrElse
|
||
index.Equals("Carbon_Device".ToUpper) OrElse index.Equals("RKEY".ToUpper) OrElse index.Equals("BLEMUSIC".ToUpper) OrElse index.Equals("Scene_Restore".ToUpper) Then
|
||
li.Add("advanced")
|
||
End If
|
||
dic.Add(index,li)
|
||
Next
|
||
Return dic
|
||
Catch ex As Exception
|
||
AddLog($"获取对应类型的下拉选项失败 :{ex.Message} ")‘进入下来选项并清空下拉选项21,14
|
||
Return dic
|
||
End Try
|
||
|
||
|
||
End Function
|
||
|
||
Public Sub AddLog(ByVal logMessage As String)
|
||
Dim logFilePath As String = "C:\Logs\MyAppLog.txt"
|
||
Try
|
||
' 确保日志目录存在
|
||
Dim logDirectory As String = Path.GetDirectoryName(logFilePath)
|
||
If Not Directory.Exists(logDirectory) Then
|
||
Directory.CreateDirectory(logDirectory)
|
||
End If
|
||
|
||
' 打开日志文件并追加日志消息
|
||
Using writer As New StreamWriter(logFilePath, True)
|
||
writer.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") & " - " & logMessage)
|
||
End Using
|
||
Catch ex As Exception
|
||
' 如果写入日志时发生错误,输出错误信息到控制台
|
||
Console.WriteLine("Error writing to log file: " & ex.Message)
|
||
End Try
|
||
End Sub
|
||
Private Sub Grid_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs)
|
||
AddLog($"进入下来选项并清空下拉选项{e.Row},{e.Col}")
|
||
'Console.WriteLine($"Grid_ComboDropDown{_grd.Cell(e.Row, e.Col).Text }")
|
||
|
||
_grd.ComboBox(0).Items.Clear()
|
||
Dim ComboDropDownDic As Dictionary(Of String, List(Of String)) = GetComboDropDownDic()
|
||
AddLog($"获取对应类型的下拉选项完毕")
|
||
Select Case e.Row
|
||
Case TableRowNumber.FunctionAnotherName
|
||
If TableColNumber.ServerAttribute Then
|
||
For i = -24 To 24
|
||
_grd.ComboBox(0).Items.Add(i)
|
||
Next
|
||
|
||
End If
|
||
|
||
'Case ComboDropDownON.HostDev
|
||
' For Each HostDevFN In IO.Directory.GetFiles(HostDevFNP)
|
||
' Grid1.ComboBox(0).Items.Add(HostDevFN.Substring(HostDevFNP.Length, HostDevFN.Length - HostDevFNP.Length - 4))
|
||
' Next
|
||
Case >= TableRowNumber.Max
|
||
|
||
’ Console.WriteLine()
|
||
AddLog($"进入下拉添加选项")
|
||
If _grd.ActiveCell.Col = TableColNumber.SceneAttribute Then
|
||
AddLog($"进入ExecutionCondition")
|
||
Dim fromshow As New ExecutionCondition
|
||
fromshow.G_grid = _grd
|
||
fromshow.DicDevicemodel = Dic_Devicemodel
|
||
fromshow.G_ActionConfiguration = Dic_ActionConfiguration
|
||
fromshow.g_BasicClasses = BasicClasses
|
||
fromshow.G_Row = _grd.ActiveCell.Row
|
||
fromshow.G_celltag = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Tag)
|
||
If IsNothing(fromshow.G_celltag) Then
|
||
fromshow.G_celltag = New Dictionary(Of String, String)
|
||
End If
|
||
fromshow.G_ConfigActionConcitons = Condictions
|
||
fromshow.G_input = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.SceneAttribute).Text
|
||
fromshow.G_ModeDevType = Dic_ActionConfiguration.Item(_grd.ActiveCell.Row - TableRowNumber.Max).G_KeyType.ToArray
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
AddLog($"退出ExecutionCondition {fromshow.G_Result},{ JsonConvert.SerializeObject(fromshow.G_celltag)}")
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = fromshow.G_Result
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Tag = JsonConvert.SerializeObject(fromshow.G_celltag)
|
||
|
||
ElseIf _grd.ActiveCell.Col = TableColNumber.ServerAttribute Then
|
||
Dim fromshow As New ServiceAttribute
|
||
AddLog($"退出ServerAttribute")
|
||
fromshow.G_input = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.ServerAttribute).Text
|
||
fromshow.G_hostNode = Nothing
|
||
For Each Anode In Dic_Devicemodel.Item(hostname).Nodes
|
||
If Anode.Name.Equals("HOSTSERVICE") Then
|
||
fromshow.G_hostNode = Anode
|
||
End If
|
||
Next
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
AddLog($"退出退出{fromshow.G_result}")
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = fromshow.G_result
|
||
|
||
'ElseIf _grd.Cell(TableRowNumber.FunctionName, _grd.ActiveCell.Col).Text.Equals("MUSIC") Then
|
||
|
||
' Dim fromshow As New ActionParameter
|
||
' Dim g_devname As New CtabRange(_grd, TableRowNumber.FunctionName, _grd.ActiveCell.Col)
|
||
' fromshow.GetEquipmentParameter(g_devname.devname.ToUpper, _grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text, BasicClasses)
|
||
' If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
' _grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = fromshow.G_Result
|
||
|
||
ElseIf _grd.ActiveCell.Col > TableColNumber.ServerAttribute Then
|
||
|
||
Dim g_devname As New CtabRange(_grd, TableRowNumber.FunctionName, _grd.ActiveCell.Col)
|
||
AddLog($"准备设置音乐动作{e.Row},{e.Col},{g_devname.devname}")
|
||
If g_devname.devname.ToUpper.Equals("485MUSIC") OrElse
|
||
g_devname.devname.ToUpper.Equals("MUSIC".ToUpper) Then
|
||
AddLog($"设置音乐动作{e.Row},{e.Col},{g_devname.devname}")
|
||
Dim fromshow As New ActionParameter
|
||
fromshow.KeyName = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.KeyName).Text
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(e.Row - TableRowNumber.Max)
|
||
fromshow.g_DevNodename = rowtag.G_DevNodeName
|
||
fromshow.g_ExecutionMode = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.SceneAttribute).Text
|
||
fromshow.GetEquipmentParameter(g_devname.devname.ToUpper, _grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text, BasicClasses)
|
||
If fromshow.ShowDialog() <> DialogResult.OK Then Return
|
||
_grd.Cell(_grd.ActiveCell.Row, _grd.ActiveCell.Col).Text = fromshow.G_Result
|
||
Else
|
||
AddLog($"添加下拉选项1 {g_devname.devname.ToUpper} { JsonConvert.SerializeObject(ComboDropDownDic)}")
|
||
If ComboDropDownDic.ContainsKey(g_devname.devname.ToUpper) Then
|
||
Dim li As List(Of String) = ComboDropDownDic.Item(g_devname.devname.ToUpper)
|
||
If IsNothing(li) Then
|
||
Return
|
||
End If
|
||
_grd.ComboBox(0).Items.AddRange(li.ToArray)
|
||
Else
|
||
For Each index In [Enum].GetValues(GetType(TableColSwitchKeyDate))
|
||
_grd.ComboBox(0).Items.Add(Chr(index))
|
||
Next
|
||
|
||
End If
|
||
End If
|
||
|
||
|
||
End If
|
||
|
||
|
||
End Select
|
||
|
||
End Sub
|
||
Public Function CheckDataIsOk(devname As String, datastr As String) As Boolean
|
||
If String.IsNullOrEmpty(datastr) Then Return True
|
||
Dim ComboDropDownDic As Dictionary(Of String, List(Of String)) = GetComboDropDownDic()
|
||
Select Case devname.ToUpper
|
||
Case "DIMMING", "PB_LINE_CONTROL", "PB_LED_DEVICE", "PB_STRIP_DEVICE"
|
||
Dim dvalint As Integer = -1
|
||
If datastr.Equals(Chr(TableColSwitchKeyDate.TurnDrown).ToString()) OrElse datastr.Equals(Chr(TableColSwitchKeyDate.TurnOn).ToString()) Then Return True
|
||
If Integer.TryParse(datastr, dvalint) Then
|
||
If dvalint > -1 AndAlso dvalint < 101 Then
|
||
Return True
|
||
End If
|
||
Else
|
||
Return False
|
||
End If
|
||
Case "485MUSIC"
|
||
|
||
Case "TEMP", "RS485_Curtain".ToUpper, "DRY_CURTAIN", "485FloorHeat".ToUpper, "485FreshAir".ToUpper, "INFRARED_FORWARD", "RELAY", "DO", "LIGHT", "CLED_FRESHAIR", "CLEDFLOORHEAT"
|
||
For Each indx In ComboDropDownDic.Item(devname.ToUpper)
|
||
If indx.Equals(datastr) Then
|
||
Return True
|
||
End If
|
||
Next
|
||
Return False
|
||
|
||
|
||
Case "MUSIC".ToUpper
|
||
Case "DRY_NoCard".ToUpper
|
||
Case "Dev_ColorTemp".ToUpper
|
||
Case "BLEMUSIC".ToUpper
|
||
Case "HOPO_Curtain".ToUpper
|
||
Case "Carbon_Device".ToUpper
|
||
Case "Scene_Restore".ToUpper
|
||
Case Else
|
||
For Each index In [Enum].GetValues(GetType(TableColSwitchKeyDate))
|
||
If datastr.Equals(Chr(index).ToString) Then
|
||
Return True
|
||
End If
|
||
Next
|
||
End Select
|
||
|
||
Return False
|
||
End Function
|
||
Public Sub SpecifySetting(devname As String, cand As String)
|
||
Dim srowid As CtabRange = GetRowDevNametabRange(devname, TableColNumber.DeviceName)
|
||
If IsNothing(srowid) Then Return
|
||
For i = srowid.fr To srowid.lr
|
||
'If i = srowid.fr Then
|
||
|
||
'End If
|
||
Select Case _grd.Cell(i, TableColNumber.KeyName).Text
|
||
Case "Insert card"
|
||
_grd.Range(i, TableColNumber.KeyName, i, TableColNumber.KeyName).SelectCells()
|
||
AddSceneLine("Insert card")
|
||
_grd.Cell(i + 1, TableColNumber.KeyName).Text = "pull out"
|
||
'Console.WriteLine(_grd.Cell(i + 1, TableColNumber.SceneAttribute).Text)
|
||
If _grd.Cell(i + 1, TableColNumber.SceneAttribute).Text.Contains("1365,1") Then
|
||
_grd.Cell(i + 1, TableColNumber.SceneAttribute).Text = "2730,1,1152921504606846976"
|
||
Else
|
||
_grd.Cell(i + 1, TableColNumber.SceneAttribute).Text = "2,1,1152921504606846976"
|
||
End If
|
||
i = i + 1
|
||
|
||
Case "door bell"
|
||
_grd.Cell(i, TableColNumber.SceneAttribute).Text = "1,1,1152921504606847520"
|
||
|
||
Case "SOS pressed"
|
||
_grd.Range(i, TableColNumber.KeyName, i, TableColNumber.KeyName).SelectCells()
|
||
AddSceneLine("SOS pressed")
|
||
_grd.Cell(i + 1, TableColNumber.KeyName).Text = "SOS release"
|
||
_grd.Cell(i + 1, TableColNumber.SceneAttribute).Text = "2,1,1152921504606846976"
|
||
i = i + 1
|
||
Case "Open door contact"
|
||
_grd.Range(i, TableColNumber.KeyName, i, TableColNumber.KeyName).SelectCells()
|
||
AddSceneLine("Open door contact")
|
||
_grd.Cell(i + 1, TableColNumber.KeyName).Text = "Close door contact"
|
||
_grd.Cell(i, TableColNumber.SceneAttribute).Text = "2,1,1152921504606846976"
|
||
i = i + 1
|
||
Case Else
|
||
If _grd.Cell(i, TableColNumber.KeyName).Text.Contains("Sliding bar") Then
|
||
_grd.Range(i, TableColNumber.KeyName, i, TableColNumber.KeyName).SelectCells()
|
||
AddSceneLine("Right sliding")
|
||
_grd.Cell(i + 1, TableColNumber.KeyName).Text = "Left sliding"
|
||
_grd.Cell(i + 1, TableColNumber.SceneAttribute).Text = "1,1,1152921504606847008"
|
||
i = i + 1
|
||
End If
|
||
End Select
|
||
|
||
Next
|
||
|
||
End Sub
|
||
|
||
Public Function AddSceneLine(Optional valname As String = "", Optional condition As String = "") As Boolean
|
||
If _grd.ActiveCell.Row >= TableRowNumber.Max And _grd.ActiveCell.Col >= TableColNumber.choose Then
|
||
Dim Crowtag As TableRowTag = Dic_ActionConfiguration.Item(_grd.ActiveCell.Row - TableRowNumber.Max)
|
||
|
||
If Crowtag.G_DevNodeName.Equals("HOSTSERVICE") AndAlso False Then
|
||
MsgBox("The replication scenario fails, and the service scenario cannot be replicated!")
|
||
Return False
|
||
Else
|
||
Dim rowtag As New TableRowTag
|
||
|
||
rowtag.G_DevModeName = Crowtag.G_DevModeName
|
||
rowtag.G_DevNodeName = Crowtag.G_DevNodeName
|
||
rowtag.G_DevNodeIndex = Crowtag.G_DevNodeIndex
|
||
rowtag.G_KeyType = Crowtag.G_KeyType
|
||
Dim old_SceneID As String = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.SceneID).Text
|
||
Dim FirstRow, Firstcol, LastCol, Lastrow As Integer
|
||
With _grd.Range(_grd.ActiveCell.Row, TableColNumber.DeviceName, _grd.ActiveCell.Row, TableColNumber.DeviceName)
|
||
FirstRow = .FirstRow
|
||
Firstcol = .FirstCol
|
||
LastCol = .LastCol
|
||
Lastrow = .LastRow
|
||
End With
|
||
|
||
Dic_ActionConfiguration.Insert(_grd.ActiveCell.Row - TableRowNumber.Max, rowtag)
|
||
|
||
|
||
|
||
Dim growlock As Boolean = _grd.Row(_grd.ActiveCell.Row).Locked
|
||
_grd.InsertRow(_grd.ActiveCell.Row, 1)
|
||
_grd.Row(_grd.ActiveCell.Row).Locked = growlock
|
||
|
||
|
||
For Each node In Crowtag.G_DicRow
|
||
If node.Key = TableColNumber.SceneID Then
|
||
|
||
rowtag.G_DicRow.Add(node.Key, old_SceneID)
|
||
_grd.Cell(_grd.ActiveCell.Row, node.Key).Text = old_SceneID
|
||
_grd.Cell(_grd.ActiveCell.Row + 1, node.Key).Text = _SceneID
|
||
|
||
|
||
|
||
|
||
Else
|
||
If node.Key = TableColNumber.KeyName AndAlso Not String.IsNullOrEmpty(valname) Then
|
||
rowtag.G_DicRow.Add(node.Key, valname)
|
||
_grd.Cell(_grd.ActiveCell.Row, node.Key).Text = valname
|
||
ElseIf node.Key = TableColNumber.SceneAttribute AndAlso Not String.IsNullOrEmpty(condition) Then
|
||
rowtag.G_DicRow.Add(node.Key, condition)
|
||
_grd.Cell(_grd.ActiveCell.Row, node.Key).Text = condition
|
||
Else
|
||
|
||
rowtag.G_DicRow.Add(node.Key, node.Value)
|
||
_grd.Cell(_grd.ActiveCell.Row, node.Key).Text = node.Value
|
||
End If
|
||
|
||
If node.Key = 6 Then
|
||
_grd.Cell(_grd.ActiveCell.Row, node.Key).Tag = _grd.Cell(_grd.ActiveCell.Row + 1, node.Key).Tag
|
||
End If
|
||
End If
|
||
Next
|
||
Crowtag.G_DicRow.Item(TableColNumber.SceneID) = _SceneID
|
||
_SceneID = _SceneID + 1
|
||
If FirstRow = _grd.ActiveCell.Row Then
|
||
_grd.Range(FirstRow, TableColNumber.choose, FirstRow, TableColNumber.Max).Locked = False
|
||
_grd.Range(FirstRow, TableColNumber.SceneAttribute, FirstRow, _grd.Cols - 1).CellType = CellTypeEnum.ComboBox
|
||
_grd.Range(FirstRow, TableColNumber.choose, FirstRow, TableColNumber.choose).CellType = CellTypeEnum.CheckBox
|
||
_grd.Range(FirstRow, TableColNumber.SceneID, FirstRow, TableColNumber.KeyVal).Locked = True
|
||
|
||
Dim rlockli As New List(Of Integer)
|
||
For rli = _grd.ActiveCell.Row To Lastrow + 1
|
||
If _grd.Row(rli).Locked = True Then
|
||
_grd.Row(rli).Locked = False
|
||
rlockli.Add(rli)
|
||
End If
|
||
Next
|
||
|
||
_grd.Range(_grd.ActiveCell.Row, Firstcol, FirstRow + 1, LastCol).Locked = False
|
||
_grd.Range(_grd.ActiveCell.Row, Firstcol, FirstRow + 1, LastCol).Merge()
|
||
_grd.Range(_grd.ActiveCell.Row, Firstcol, FirstRow + 1, LastCol).Locked = True
|
||
|
||
For Each rl In rlockli
|
||
_grd.Row(rl).Locked = True
|
||
Next
|
||
End If
|
||
'_grd.Range(_grd.ActiveCell.Row, Firstcol, Lastrow 1, LastCol).Locked = False
|
||
'_grd.Range(_grd.ActiveCell.Row, Firstcol, Lastrow + 1, LastCol).Merge()
|
||
'_grd.Range(_grd.ActiveCell.Row, Firstcol, Lastrow + 1, LastCol).Locked = True
|
||
|
||
|
||
ChangeTheServiceLineNumber()
|
||
Return True
|
||
End If
|
||
Else
|
||
MsgBox("Failed to copy the scenario. The scenario to be copied is not selected!")
|
||
Return False
|
||
End If
|
||
End Function
|
||
|
||
Public Sub LaunchService()
|
||
'Dim srowid As CtabRange = GetRowDevNametabRange("HOSTSERVICE", TableColNumber.DeviceName)
|
||
'If IsNothing(srowid) Then Return
|
||
'For i = srowid.fr To srowid.lr
|
||
' If _grd.Row(i).Height > 0 Then
|
||
' _grd.Row(i).Height = 0
|
||
' Else
|
||
' _grd.Row(i).Height = 19
|
||
' End If
|
||
|
||
'Next
|
||
DisplayDicCol()
|
||
End Sub
|
||
|
||
Public oldColDisplayDic As Dictionary(Of Integer, Boolean)
|
||
|
||
Public Sub DisplayDicCol()
|
||
If IsNothing(_grd) OrElse _grd.Cols = 0 Then Return
|
||
If IsNothing(oldColDisplayDic) Then
|
||
oldColDisplayDic = New Dictionary(Of Integer, Boolean)
|
||
End If
|
||
Dim isEmpty As Integer = oldColDisplayDic.Count
|
||
|
||
For i = 1 To _grd.Cols - 1
|
||
|
||
If isEmpty = 0 Then
|
||
|
||
If _grd.Column(i).Visible = True Then
|
||
If oldColDisplayDic.ContainsKey(i) Then
|
||
oldColDisplayDic.Item(i) = True
|
||
Else
|
||
oldColDisplayDic.Add(i, True)
|
||
End If
|
||
|
||
Else
|
||
oldColDisplayDic.Add(i, False)
|
||
End If
|
||
_grd.Column(i).Visible = True
|
||
|
||
Else
|
||
If oldColDisplayDic.ContainsKey(i) Then
|
||
_grd.Column(i).Visible = oldColDisplayDic.Item(i)
|
||
oldColDisplayDic.Remove(i)
|
||
|
||
End If
|
||
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
End Sub
|
||
|
||
|
||
|
||
Private CopyActionData As Dictionary(Of Integer, String)
|
||
Public Sub CopySceneActionData()
|
||
CopyActionData.Clear()
|
||
If _grd.ActiveCell.Row > TableRowNumber.Max - 1 Then
|
||
For ei As Integer = TableColNumber.KeyName To _grd.Cols - 1
|
||
CopyActionData.Add(ei, _grd.Cell(_grd.ActiveCell.Row, ei).Text.Trim)
|
||
Next
|
||
Else
|
||
MsgBox("Non-scene action data cannot be copied!")
|
||
End If
|
||
End Sub
|
||
Public Sub GlueSceneActionData()
|
||
If CopyActionData.Count = 0 Then Return
|
||
If _grd.ActiveCell.Row > TableRowNumber.Max - 1 Then
|
||
If AddSceneLine() Then
|
||
' _grd.Cell(_grd.ActiveCell.Row + 1, TableColNumber.KeyName).Text = _grd.Cell(_grd.ActiveCell.Row + 1, TableColNumber.KeyName).Text.Trim & "(复制)"
|
||
For Each index In CopyActionData
|
||
If index.Key = TableColNumber.KeyName Then
|
||
_grd.Cell(_grd.ActiveCell.Row + 1, index.Key).Text = index.Value.Trim & "(Copy)"
|
||
Else
|
||
_grd.Cell(_grd.ActiveCell.Row + 1, index.Key).Text = index.Value
|
||
End If
|
||
Next
|
||
End If
|
||
Else
|
||
Return
|
||
End If
|
||
End Sub
|
||
Public Sub SelectRowNode()
|
||
'LockGridAutoRedraw()
|
||
If _grd.ActiveCell.Row > TableRowNumber.Max - 1 Then
|
||
If _grd.ActiveCell.Col = TableColNumber.DeviceName Then
|
||
Dim fr, lr, fc, lc As Integer
|
||
With _grd.Range(_grd.ActiveCell.Row, TableColNumber.DeviceName, _grd.ActiveCell.Row, TableColNumber.DeviceName)
|
||
fr = .FirstRow
|
||
lr = .LastRow
|
||
fc = .FirstCol
|
||
lc = .LastCol
|
||
End With
|
||
Dim Removename As String = _grd.Cell(fr, TableColNumber.DeviceName).Text.Trim
|
||
|
||
If Removename.Trim.Equals(hostname) Then
|
||
MsgBox("Host devices cannot be deleted!!!")
|
||
Return
|
||
ElseIf Removename.Trim.Equals("HOSTSERVICE") Then
|
||
MsgBox("The service module cannot be deleted!!!")
|
||
Return
|
||
Else
|
||
|
||
Dim devmode As DeviceModel = Dic_Devicemodel.Item(Removename)
|
||
Dic_Devicemodel.Remove(Removename)
|
||
Dim serverli As New List(Of String)
|
||
For i = fr To lr
|
||
'从模块最大行号开始删
|
||
Dim deleteid As Integer = lr - i + fr
|
||
'先删除输入行
|
||
_grd.Row(deleteid).Delete()
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(deleteid - TableRowNumber.Max)
|
||
Dic_ActionConfiguration.RemoveAt(deleteid - TableRowNumber.Max)
|
||
|
||
If rowtag.G_DicRow.ContainsKey(TableColNumber.ServerAttribute) Then
|
||
Dim serverstr As String = rowtag.G_DicRow.Item(TableColNumber.ServerAttribute)
|
||
If Not String.IsNullOrEmpty(serverstr) Then
|
||
serverli.Add(serverstr)
|
||
End If
|
||
End If
|
||
Next
|
||
ChangeTheServiceLineNumber()
|
||
|
||
For Each serverstr In serverli
|
||
Dim wbuff() As String = serverstr.Trim.Split(vbLf)
|
||
For Each index In wbuff
|
||
grdRemoveServerRow(index)
|
||
Next
|
||
Next
|
||
Dim coldevname As String = String.Empty
|
||
Dim TCols As Integer = _grd.Cols - 2
|
||
For ci = TableColNumber.InsertColumn To TCols
|
||
With _grd.Range(TableRowNumber.DeviceName, ci, TableRowNumber.DeviceName, ci)
|
||
fr = .FirstRow
|
||
lr = .LastRow
|
||
fc = .FirstCol
|
||
lc = .LastCol
|
||
End With
|
||
If Removename.Equals(_grd.Cell(fr, fc).Text.Trim) Then
|
||
'清空待删列缓存数据
|
||
DeleteTableClunm(fc, lc)
|
||
'删除列
|
||
Dim cons As Integer = ColumnAnothername.Count
|
||
For indekey = 0 To cons - 1
|
||
|
||
If ColumnAnothername.Keys(cons - 1 - indekey).Contains(Removename) Then
|
||
ColumnAnothername.Remove(ColumnAnothername.Keys(cons - 1 - indekey))
|
||
End If
|
||
Next
|
||
_grd.Range(0, fc, _grd.Rows - 1, lc).DeleteByCol()
|
||
|
||
_ColumnStartLoad = _ColumnStartLoad - (lc - fc + 1)
|
||
Exit For
|
||
End If
|
||
ci = lc
|
||
Next
|
||
'如果是特殊设备
|
||
Unboundrelay(devmode)
|
||
End If
|
||
Else
|
||
Dim topval, inthepval, downpval As String
|
||
topval = _grd.Cell(_grd.ActiveCell.Row - 1, TableColNumber.KeyVal).Text.Trim
|
||
inthepval = _grd.Cell(_grd.ActiveCell.Row, TableColNumber.KeyVal).Text.Trim
|
||
If _grd.ActiveCell.Row + 1 > _grd.Rows - 1 Then
|
||
downpval = String.Empty
|
||
Else
|
||
downpval = _grd.Cell(_grd.ActiveCell.Row + 1, TableColNumber.KeyVal).Text.Trim
|
||
End If
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(_grd.ActiveCell.Row - TableRowNumber.Max)
|
||
Dim g_devname = New CtabRange(_grd, _grd.ActiveCell.Row, TableColNumber.DeviceName)
|
||
If g_devname.devname.Trim.Equals("HOSTSERVICE") Then
|
||
MsgBox("服務模块不可删除!!!")
|
||
Return
|
||
End If
|
||
If Not String.IsNullOrEmpty(inthepval) Then
|
||
If topval.Equals(inthepval) OrElse downpval.Equals(inthepval) Then
|
||
|
||
Dim deleterow As Integer = _grd.ActiveCell.Row
|
||
Dim srowid As CtabRange = GetRowDevNametabRange(rowtag.G_DevModeName, TableColNumber.DeviceName)
|
||
_grd.Row(deleterow).Delete()
|
||
Dic_ActionConfiguration.RemoveAt(deleterow - TableRowNumber.Max)
|
||
|
||
If srowid.fr = deleterow Then
|
||
_grd.Cell(deleterow, TableColNumber.DeviceName).Text = rowtag.G_DevModeName
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, srowid.lr - 1, TableColNumber.DeviceName).Merge()
|
||
_grd.Range(deleterow, TableColNumber.DeviceName, srowid.lr - 1, TableColNumber.DeviceName).Locked = True
|
||
End If
|
||
|
||
'If rowtag.G_DevModeName.Equals(hostname) Then
|
||
' _ServerInsertRows = _ServerInsertRows - 1
|
||
' For dei As Integer = 0 To _ServerAction.Count - 1
|
||
' _ServerAction.Item(_ServerAction.Keys(dei)) = _ServerAction.Values(dei) - 1
|
||
' Next
|
||
'End If
|
||
|
||
|
||
If rowtag.G_DicRow.ContainsKey(TableColNumber.ServerAttribute) Then
|
||
Dim serverstr As String = rowtag.G_DicRow.Item(TableColNumber.ServerAttribute)
|
||
If Not String.IsNullOrEmpty(serverstr) Then
|
||
Dim wbuff() As String = serverstr.Trim.Split(vbLf)
|
||
For Each index In wbuff
|
||
grdRemoveServerRow(index)
|
||
Next
|
||
End If
|
||
End If
|
||
ChangeTheServiceLineNumber()
|
||
Else
|
||
MsgBox("设备固定输入不可删除")
|
||
End If
|
||
End If
|
||
End If
|
||
ElseIf _grd.ActiveCell.Row = TableRowNumber.DeviceName AndAlso _grd.ActiveCell.Col >= TableColNumber.InsertColumn AndAlso _grd.ActiveCell.Col < (_grd.Cols - 1) Then
|
||
|
||
Dim g_devname = New CtabRange(_grd, TableRowNumber.DeviceName, _grd.ActiveCell.Col)
|
||
Dim srowid As CtabRange = GetRowDevNametabRange(g_devname.devname, TableColNumber.DeviceName)
|
||
If g_devname.devname.Trim.Equals(hostname) Then
|
||
MsgBox("主机设备不可删除!!!")
|
||
Return
|
||
|
||
End If
|
||
'删除行
|
||
Dim devmode As DeviceModel = Dic_Devicemodel.Item(g_devname.devname)
|
||
Dic_Devicemodel.Remove(g_devname.devname)
|
||
If Not IsNothing(srowid) Then
|
||
Dim serverli As New List(Of String)
|
||
For i = srowid.fr To srowid.lr
|
||
'从模块最大行号开始删
|
||
Dim deleteid As Integer = srowid.lr - i + srowid.fr
|
||
'先删除输入行
|
||
_grd.Row(deleteid).Delete()
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(deleteid - TableRowNumber.Max)
|
||
Dic_ActionConfiguration.RemoveAt(deleteid - TableRowNumber.Max)
|
||
|
||
If rowtag.G_DicRow.ContainsKey(TableColNumber.ServerAttribute) Then
|
||
Dim serverstr As String = rowtag.G_DicRow.Item(TableColNumber.ServerAttribute)
|
||
If Not String.IsNullOrEmpty(serverstr) Then
|
||
serverli.Add(serverstr)
|
||
End If
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
'清空待删列缓存数据
|
||
DeleteTableClunm(g_devname.fc, g_devname.lc)
|
||
'删除列
|
||
Dim cons As Integer = ColumnAnothername.Count
|
||
For indekey = 0 To cons - 1
|
||
|
||
If ColumnAnothername.Keys(cons - 1 - indekey).Contains(g_devname.devname) Then
|
||
ColumnAnothername.Remove(ColumnAnothername.Keys(cons - 1 - indekey))
|
||
End If
|
||
Next
|
||
|
||
|
||
_grd.Range(0, g_devname.fc, _grd.Rows - 1, g_devname.lc).DeleteByCol()
|
||
_ColumnStartLoad = _ColumnStartLoad - (g_devname.lc - g_devname.fc + 1)
|
||
'如果是特殊设备
|
||
Unboundrelay(devmode)
|
||
End If
|
||
UnLockGridAutoRedraw()
|
||
End Sub
|
||
|
||
|
||
Public Sub Unboundrelay(devmode As DeviceModel)
|
||
If IsNothing(devmode) Then Return
|
||
If devmode.Nodes(0).Name.Equals("CURTAIN") OrElse
|
||
devmode.Nodes(0).Name.ToUpper.Equals("485FreshAir".ToUpper) OrElse
|
||
devmode.Nodes(0).Name.ToUpper.Equals("485FloorHeat".ToUpper) OrElse
|
||
devmode.Nodes(0).Name.ToUpper.Equals("CLED_FRESHAIR".ToUpper) OrElse
|
||
devmode.Nodes(0).Name.ToUpper.Equals("CLEDFLOORHEAT".ToUpper) Then
|
||
Dim oldbuf() As String = devmode.Desc.ProtocolData.Split(",")
|
||
If Not IsNothing(oldbuf) AndAlso oldbuf.Length > 0 Then
|
||
For Each index In oldbuf
|
||
Dim g_DevRELAYrow = GetDevLoopName("RELAY", "PB_RELAY_DEVICE")
|
||
If String.IsNullOrEmpty(index) Then Continue For
|
||
Dim oldcbuf() As String = index.Split("*")
|
||
Dim buf As String = $"{oldcbuf(0)}*{oldcbuf(1)}*{oldcbuf(2)}"
|
||
If g_DevRELAYrow.ContainsKey(buf) AndAlso _grd.Cols > g_DevRELAYrow.Item(buf) Then
|
||
_grd.Column(g_DevRELAYrow.Item(buf)).Visible = True
|
||
_grd.Column(g_DevRELAYrow.Item(buf)).Locked = False
|
||
End If
|
||
Next
|
||
End If
|
||
Else
|
||
For Each node In devmode.Nodes
|
||
If node.Name.ToUpper.Equals("TEMP") Then
|
||
Dim dic As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(devmode.Desc.ProtocolData)
|
||
If Not IsNothing(dic) AndAlso dic.Count > 0 Then
|
||
For Each index In dic
|
||
Dim g_DevRELAYrow = GetDevLoopName("RELAY", "PB_RELAY_DEVICE")
|
||
If g_DevRELAYrow.ContainsKey(index.Value) AndAlso _grd.Cols > g_DevRELAYrow.Item(index.Value) Then
|
||
_grd.Column(g_DevRELAYrow.Item(index.Value)).Visible = True
|
||
_grd.Column(g_DevRELAYrow.Item(index.Value)).Locked = False
|
||
End If
|
||
Next
|
||
End If
|
||
ElseIf node.Name.Equals("Dev_ColorTemp") Then
|
||
For i = 1 To node.Nodes.Count
|
||
Dim Index = node.Nodes(i - 1)
|
||
If Index.DefaultClass.Equals("Dev_ColorTemp") 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
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
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 _grd.Cols - 1
|
||
Dim g_devname = New CtabRange(_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(_grd, TableInteraction.TableRowNumber.FunctionAnotherName, i)
|
||
If g_devcloumn.devname.Equals(nodetype) Then
|
||
For vi = g_devcloumn.fc To g_devcloumn.lc
|
||
If _grd.Cell(TableInteraction.TableRowNumber.FunctionChildNodeID, vi).Text.Equals(devloop) Then
|
||
_grd.Column(vi).Visible = istrue
|
||
|
||
Console.WriteLine($"Column{vi},Visible{istrue}")
|
||
Exit Sub
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
|
||
|
||
End Sub
|
||
|
||
Private Sub DeleteTableClunm(startindex As Integer, endtindex As Integer)
|
||
Dim len As Integer = endtindex - startindex + 1
|
||
Dim dic As New List(Of (Integer, String))
|
||
|
||
Dim dick, dicv As String
|
||
Dim G_DicRowlen As Integer = -1
|
||
For i = TableRowNumber.Max To _grd.Rows - 1
|
||
Dim rowtag As TableRowTag = Dic_ActionConfiguration.Item(i - TableRowNumber.Max)
|
||
'删除每行中需要删的列数据
|
||
'For j = startindex To endtindex
|
||
' If rowtag.G_DicRow.ContainsKey(j) Then
|
||
' rowtag.G_DicRow.Remove(j)
|
||
' End If
|
||
'Next
|
||
'变更列号
|
||
dic.Clear()
|
||
G_DicRowlen = rowtag.G_DicRow.Count - 1
|
||
For nodeindex As Integer = 0 To G_DicRowlen
|
||
dick = rowtag.G_DicRow.Keys(nodeindex)
|
||
dicv = rowtag.G_DicRow.Values(nodeindex)
|
||
|
||
If dick >= startindex AndAlso dick <= endtindex Then
|
||
|
||
dic.Add((dick, "Remove"))
|
||
End If
|
||
If dick > endtindex Then
|
||
dic.Add((dick, "Alter"))
|
||
|
||
End If
|
||
Next
|
||
If dic.Count > 2 Then
|
||
Console.WriteLine("")
|
||
End If
|
||
dic.Sort()
|
||
For Each node In dic
|
||
Select Case node.Item2
|
||
Case "Alter"
|
||
Dim news As String = rowtag.G_DicRow.Item(node.Item1)
|
||
rowtag.G_DicRow.Add((node.Item1 - len), rowtag.G_DicRow.Item(node.Item1))
|
||
rowtag.G_DicRow.Remove(node.Item1)
|
||
Case "Remove"
|
||
rowtag.G_DicRow.Remove(node.Item1)
|
||
End Select
|
||
Next
|
||
Next
|
||
End Sub
|
||
|
||
#End Region
|
||
|
||
#Region "编译"
|
||
Public Function TableCompiletoByte(Optional savePath As String = "",
|
||
Optional ByVal IsShowCompileResult As Boolean = False,
|
||
Optional ByVal ifCfgVerPlusPlus As Boolean = False) As Boolean
|
||
Dim lst As New List(Of Byte())
|
||
_actionIndex = 1
|
||
Dim newTableCompile As New TableCompile
|
||
Dim configInfoLst As New List(Of Byte())
|
||
' 编译配置信息
|
||
If IsNothing(ConfigInfo.Author) Then
|
||
MsgBox("Room type not selected!!!")
|
||
Return False
|
||
End If
|
||
Dim tmpInfo() As Byte = FillConfigInfo(ConfigInfo, hostname).ToArray
|
||
configInfoLst.Add(tmpInfo)
|
||
Console.WriteLine($"Compile configuration information:{ByteToString(tmpInfo)}")
|
||
lst.AddRange(configInfoLst.ToArray)
|
||
'编译设备存在
|
||
Dim deviceExistsDatas As List(Of Byte())
|
||
Dim OutDevlist As New List(Of Byte)
|
||
deviceExistsDatas = FillDeviceExistsData(Dic_Devicemodel)
|
||
lst.AddRange(deviceExistsDatas.ToArray)
|
||
'获取编译的设备动作
|
||
Dim actibuf As List(Of Byte()) = FillDeviceObject(Dic_Devicemodel, Dic_ActionConfiguration, _grd)
|
||
For Each buf In actibuf
|
||
lst.Add(buf)
|
||
Next
|
||
|
||
'语音
|
||
actibuf = VoicementDeviceObject()
|
||
For Each buf In actibuf
|
||
lst.Add(buf)
|
||
Next
|
||
'编译场景
|
||
Dim NoCardDatabuf As List(Of Byte()) = GetNoCardData()
|
||
For Each buf In NoCardDatabuf
|
||
lst.Add(buf)
|
||
Next
|
||
|
||
'编译场景信息
|
||
Dim SceneDatas As List(Of Byte())
|
||
SceneDatas = FillSceneData(Dic_ActionConfiguration)
|
||
lst.AddRange(SceneDatas.ToArray)
|
||
Dim frames As List(Of Byte()) = newTableCompile.FillDataFrames(lst)
|
||
|
||
Dim path As String = savePath.Replace(".blv", ".dat")
|
||
'Dim filename As String = Application.StartupPath & "\Shipment\test.dat"
|
||
'If Not IO.Directory.Exists(Application.StartupPath & "\Shipment\") Then IO.Directory.CreateDirectory(Application.StartupPath & "\Shipment\")
|
||
If IO.File.Exists(path) Then IO.File.Delete(path)
|
||
Using steam As New IO.FileStream(path, IO.FileMode.OpenOrCreate)
|
||
For Each frame As Byte() In frames
|
||
steam.Write(frame, 0, frame.Length)
|
||
Console.WriteLine($"Length:{frame.Length:D4} Data:{BitConverter.ToString(frame).Replace("-", " ")}")
|
||
Next
|
||
steam.Flush()
|
||
steam.Close()
|
||
End Using
|
||
Dim filebuff() As Byte = IO.File.ReadAllBytes(path)
|
||
Dim ismod As Integer = filebuff.Length Mod 4
|
||
Dim buff As New List(Of Byte)
|
||
buff.AddRange(filebuff)
|
||
For isnum As Integer = 1 To (4 - ismod)
|
||
buff.Add(0)
|
||
Next
|
||
IO.File.WriteAllBytes(path, buff.ToArray)
|
||
MsgBox($"Compile complete:{path}")
|
||
Return True
|
||
End Function
|
||
Public Function GetNoCardData() As List(Of Byte())
|
||
Dim result As New List(Of Byte())
|
||
|
||
Dim UniqueDevice As DeviceModel
|
||
Dim NoCardNode As DeviceChildNodeClass
|
||
Dim vli, nli As List(Of Byte())
|
||
Dim mli As Byte()
|
||
For Each index In Dic_Devicemodel.Values
|
||
For Each node In index.Nodes
|
||
If node.Name.Equals("Virtual_Card") Then
|
||
UniqueDevice = index
|
||
NoCardNode = node
|
||
vli = PortInformation(NoCardNode)
|
||
nli = ConditionalInformation(UniqueDevice)
|
||
mli = EquipmentCommonStats(UniqueDevice)
|
||
If Not IsNothing(vli) AndAlso vli.Count > 0 AndAlso Not IsNothing(vli) AndAlso vli.Count > 0 Then
|
||
result.AddRange(vli)
|
||
result.AddRange(nli)
|
||
If Not IsNothing(mli) AndAlso mli.Count > 0 Then
|
||
result.Add(mli)
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
Next
|
||
Next
|
||
Return result
|
||
End Function
|
||
Public Function EquipmentCommonStats(UniqueDevice As DeviceModel) As Byte()
|
||
Dim lst As New List(Of Byte)
|
||
Dim strbuf() As String = UniqueDevice.Desc.ProtocolData.Split(",")
|
||
If strbuf.Length < 2 Then Return Nothing
|
||
Dim cmd As Byte = &HB
|
||
lst.Add(cmd)
|
||
lst.Add(If(strbuf(0).Equals("1"), 1, 0))
|
||
Dim number As Integer = 0
|
||
If String.IsNullOrEmpty(strbuf(1)) Then
|
||
lst.AddRange(BitConverter.GetBytes(CShort(number)))
|
||
Else
|
||
Integer.TryParse(strbuf(1), number)
|
||
lst.AddRange(BitConverter.GetBytes(CShort(number)))
|
||
End If
|
||
|
||
lst.Add(CInt(strbuf(2)))
|
||
Return lst.ToArray
|
||
End Function
|
||
'端口信息
|
||
Public Function PortInformation(NoCardNode As DeviceChildNodeClass) As List(Of Byte())
|
||
Dim result As New List(Of Byte())
|
||
Dim sbuf() As String
|
||
Dim isport As Boolean
|
||
For Each node In NoCardNode.Nodes
|
||
sbuf = node.Description.Split(",")
|
||
isport = True
|
||
For i = 0 To sbuf.Length - 1
|
||
If String.IsNullOrEmpty(sbuf(i)) AndAlso (i <> 2 AndAlso i <> 3) Then
|
||
isport = False
|
||
End If
|
||
Next
|
||
If isport AndAlso sbuf.Length > 4 Then
|
||
result.Add(GetPortInformation(node.LoopAddr, node.Description))
|
||
|
||
Else
|
||
Continue For
|
||
End If
|
||
|
||
Next
|
||
Return result
|
||
End Function
|
||
Public Function GetPortInformation(LoopAddr As String, nStr As String) As Byte()
|
||
Dim cmd As Byte = &H9
|
||
Dim Data = New List(Of Byte)
|
||
Dim strbuf() As String = nStr.Split(",")
|
||
Data.Add(cmd)
|
||
Data.Add(CInt(strbuf(5)))
|
||
Data.Add(CInt(strbuf(6)))
|
||
Data.AddRange(BitConverter.GetBytes(CShort(CInt(strbuf(4)))))
|
||
If String.IsNullOrEmpty(strbuf(2)) Then
|
||
Data.Add(0)
|
||
Else
|
||
Data.Add(CInt(strbuf(2)))
|
||
End If
|
||
Data.Add(CInt(LoopAddr)) '- 1) '增加了减1
|
||
If String.IsNullOrEmpty(strbuf(3)) OrElse strbuf(3).Equals("0") Then
|
||
Data.Add(0)
|
||
Else
|
||
Data.Add(1)
|
||
End If
|
||
Return Data.ToArray
|
||
End Function
|
||
Public Function ConditionalInformation(UniqueDevice As DeviceModel) As List(Of Byte())
|
||
Dim result As New List(Of Byte())
|
||
Dim sbuf() As String
|
||
Dim isport As Boolean
|
||
Dim IfGridRowdic As Dictionary(Of String, List(Of String))
|
||
Try
|
||
IfGridRowdic = JsonConvert.DeserializeObject(Of Dictionary(Of String, List(Of String)))(UniqueDevice.Desc.DevDescription)
|
||
Catch ex As Exception
|
||
Return Nothing
|
||
End Try
|
||
|
||
If IsNothing(IfGridRowdic) Then Return result
|
||
For Each index In IfGridRowdic
|
||
For Each node In index.Value
|
||
sbuf = node.Split(",")
|
||
isport = True
|
||
For Each nStr In sbuf
|
||
If String.IsNullOrEmpty(nStr) Then
|
||
isport = False
|
||
End If
|
||
Next
|
||
If isport AndAlso sbuf.Length > 3 Then
|
||
result.Add(GetConditionalInformation(index.Key, node))
|
||
Else
|
||
Continue For
|
||
End If
|
||
Next
|
||
Next
|
||
Return result
|
||
End Function
|
||
'条件信息
|
||
Public Function GetConditionalInformation(key As String, nStr As String) As Byte()
|
||
Dim cmd As Byte = &H8
|
||
Dim Data = New List(Of Byte)
|
||
Dim strbuf() As String = nStr.Split(",")
|
||
Dim nbbuf() As String
|
||
Data.Add(cmd)
|
||
nbbuf = strbuf(1).Split(":")
|
||
Data.Add(PowerSupply.GetNoCarDataKeyVal(nbbuf(0)))
|
||
Data.Add(CInt(key))
|
||
Data.Add(strbuf(0))
|
||
Data.AddRange(BitConverter.GetBytes(CShort(CInt(strbuf(13)))))
|
||
Data.Add(GetGlossary8(strbuf(14)))
|
||
For i = 1 To 11
|
||
'nbbuf = strbuf(i + 1).Split(":")
|
||
Data.Add(PowerSupply.GetNoCarDataKeyVal(strbuf(i + 1)))
|
||
Next
|
||
|
||
Return Data.ToArray
|
||
End Function
|
||
Public Function GetGlossary8(sb As String) As Byte
|
||
Dim result As Byte = 0
|
||
Select Case sb
|
||
Case "S"
|
||
result = 1
|
||
Case "m"
|
||
result = 2
|
||
Case "H"
|
||
result = 3
|
||
Case Else
|
||
result = 0
|
||
End Select
|
||
Return result
|
||
End Function
|
||
Private Function FillSceneData(SwitchConfig As List(Of TableRowTag)) As List(Of Byte())
|
||
Dim tmpBufferCount As Integer = 0
|
||
Dim resultDatas As New List(Of Byte())
|
||
Dim cmd As Byte = &H6
|
||
Dim buf As List(Of Byte)
|
||
For Each num In SwitchConfig
|
||
buf = New List(Of Byte)
|
||
buf.Add(cmd)
|
||
tmpBufferCount = CShort(num.G_DicRow.Item(TableColNumber.SceneID))
|
||
buf.AddRange(BitConverter.GetBytes(tmpBufferCount)) '2字节场景编号
|
||
|
||
Dim aliasData() As Byte = AliasEncoding.GetBytes(num.G_DicRow.Item(TableColNumber.KeyName))
|
||
ReDim Preserve aliasData(15)
|
||
buf.AddRange(aliasData) '16字节场景别名
|
||
|
||
buf.AddRange(BitConverter.GetBytes(tmpBufferCount)) '2n动作编号集
|
||
|
||
'tmpBufferCount = tmpBufferCount + buf.Count
|
||
resultDatas.Add(buf.ToArray)
|
||
Next
|
||
|
||
'PrintInfo("场景编译完成,长度:" & tmpBufferCount & "Bytes")
|
||
Return resultDatas
|
||
End Function
|
||
Public Function FillDeviceObject(ByRef DeviceModuleDic As Dictionary(Of String, DeviceModel), SwitchConfig As List(Of TableRowTag), Grid1 As FlexCell.Grid) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
'行tag
|
||
Dim rowtag As TableRowTag
|
||
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
Dim g_devLoop As Integer = 1
|
||
'遍历每个事件
|
||
For i As Integer = 0 To SwitchConfig.Count - 1
|
||
'取行tag、
|
||
rowtag = SwitchConfig.Item(i)
|
||
'枚举列直
|
||
'判断是否执行
|
||
If rowtag.G_DicRow.Count > 0 AndAlso rowtag.G_DicRow.Item(TableColNumber.choose).Equals("1") AndAlso Not String.IsNullOrEmpty(rowtag.G_DicRow.Item(TableColNumber.SceneAttribute)) Then
|
||
|
||
Dim Grow As Integer = i + TableRowNumber.Max
|
||
Dim celltag As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(_grd.Cell(Grow, TableColNumber.SceneAttribute).Tag)
|
||
If Not IsNothing(celltag) AndAlso celltag.ContainsKey("CallRow") Then
|
||
Continue For
|
||
End If
|
||
'模型的设备类型
|
||
Console.WriteLine($"FillDeviceObject 2561 {rowtag.G_DevModeName}")
|
||
Dim devType As Byte
|
||
Try
|
||
devType = GetActionDeviceType(DeviceModuleDic, rowtag.G_DevModeName, rowtag.G_DevNodeName)
|
||
Catch ex As Exception
|
||
Console.WriteLine($"FillDeviceObject 2561 {rowtag.G_DevModeName}")
|
||
End Try
|
||
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, rowtag.G_DevModeName, rowtag.G_DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(rowtag.G_DevNodeIndex))
|
||
'获取场景属性
|
||
Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
UShort.TryParse(Exbuf(0), strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
'执行条件编译数据
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(Exbuf(2))
|
||
'取执行模式
|
||
Dim condition As Byte
|
||
Dim isCheckOut As Integer = 0
|
||
Dim CheckOutdeng As Integer = 0
|
||
Select Case Exbuf(1)
|
||
Case "8", "9"
|
||
condition = GetExecModeDataUnderCondtion(2)
|
||
isCheckOut = CInt(Exbuf(1))
|
||
Case "7", "10"
|
||
condition = GetExecModeDataUnderCondtion(1)
|
||
isCheckOut = CInt(Exbuf(1))
|
||
Case Else
|
||
condition = GetExecModeDataUnderCondtion(Exbuf(1))
|
||
End Select
|
||
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort = CUShort(rowtag.G_DicRow.Item(TableColNumber.SceneID))
|
||
Dim sceneNum() As Byte = BitConverter.GetBytes(sceneIndex)
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
'执行动作
|
||
Dim ncbuf As New List(Of Byte())
|
||
Dim Scenebuf As New List(Of Byte())
|
||
Dim multiplebuf As New List(Of List(Of Byte()))
|
||
Dim col As Integer = -1
|
||
Dim t_col As Integer = -1
|
||
Dim DevGroupName As String = String.Empty
|
||
Dim databuff As List(Of Byte())
|
||
Dim textval As String = String.Empty
|
||
Dim DevModeName As String
|
||
Dim Ismusic As Boolean = False
|
||
Dim CheckOutDic As New Dictionary(Of String, List(Of Byte))
|
||
'''转移到 入住服务
|
||
'If Not IsNothing(celltag) AndAlso celltag.ContainsKey("34 A9PB调光渐变时间") Then
|
||
' Dim Rdic As New Dictionary(Of String, String)
|
||
' Dim Musicdic As New Dictionary(Of String, String)
|
||
' Dim partime As String = String.Empty
|
||
' Dim partime1 As String = String.Empty
|
||
' For Each TheDevMode In DeviceModuleDic.Values
|
||
' Musicdic.Clear()
|
||
' Rdic.Clear()
|
||
' Select Case TheDevMode.Desc.Name
|
||
' Case "灯带"
|
||
' Rdic.Add("Dimming".ToUpper, "36 灯带调光渐变时间")
|
||
' partime = celltag.Item("36 灯带调光渐变时间")
|
||
' Case "1到10V调光"
|
||
' Rdic.Add("Dimming".ToUpper, "32 1-10V调光渐变时间")
|
||
' partime = celltag.Item("32 1-10V调光渐变时间")
|
||
' Case "A9调光"
|
||
' Rdic.Add("Dimming".ToUpper, "33 A9恒压调光渐变时间")
|
||
' partime = celltag.Item("33 A9恒压调光渐变时间")
|
||
' Case "A8PB调光"
|
||
' Rdic.Add("Dimming".ToUpper, "34 A9PB调光渐变时间")
|
||
' partime = celltag.Item("34 A9PB调光渐变时间")
|
||
' 'Case "PB"
|
||
|
||
|
||
' Case "PB_STRIP_DEVICE"
|
||
' Rdic.Add("PB_STRIP_DEVICE".ToUpper, "C8PLC外设恒压调光渐变时间")
|
||
' partime = celltag.Item("C8PLC外设恒压调光渐变时间")
|
||
|
||
' Case "BLV_C12"
|
||
' For Each configindex In TheDevMode.Nodes
|
||
' Select Case configindex.Name
|
||
' Case "PB_LINE_CONTROL".ToUpper
|
||
' Rdic.Add("PB_LINE_CONTROL".ToUpper, "C8PLC自带恒压调光渐变时间")
|
||
' partime = celltag.Item("C8PLC自带恒压调光渐变时间")
|
||
' partime1 = celltag.Item("48 主机调光百分比值(0-100)")
|
||
' Case "Dimming".ToUpper
|
||
' Rdic.Add("Dimming".ToUpper, "35 C12调光渐变时间")
|
||
' partime = celltag.Item("35 C12调光渐变时间")
|
||
' partime1 = celltag.Item("48 主机调光百分比值(0-100)")
|
||
' End Select
|
||
' Next
|
||
|
||
' If Not String.IsNullOrEmpty(celltag.Item("7 设定音乐音量")) Then
|
||
' Musicdic.Add(7, celltag.Item("7 设定音乐音量"))
|
||
' End If
|
||
' If Not String.IsNullOrEmpty(celltag.Item("8 设定提示音音量")) Then
|
||
' Musicdic.Add(8, celltag.Item("8 设定提示音音量"))
|
||
' End If
|
||
' If Not String.IsNullOrEmpty(celltag.Item("9 设定门铃和欢迎词音量")) Then
|
||
' Musicdic.Add(9, celltag.Item("9 设定门铃和欢迎词音量"))
|
||
' End If
|
||
' If Not String.IsNullOrEmpty(celltag.Item("10 设定全局音量上限")) Then
|
||
' Musicdic.Add(10, celltag.Item("10 设定全局音量上限"))
|
||
' 'Musicdic.Add(10, celltag.Item("10 设定最大音量限制"))
|
||
' End If
|
||
' If Not String.IsNullOrEmpty(celltag.Item("12 设定助眠音量")) Then
|
||
' Musicdic.Add(12, celltag.Item("12 设定助眠音量"))
|
||
' 'Musicdic.Add(10, celltag.Item("10 设定最大音量限制"))
|
||
' End If
|
||
|
||
' Case Else
|
||
' Continue For
|
||
' End Select
|
||
' If Rdic.ContainsKey("PB_LINE_CONTROL".ToUpper) Then
|
||
' If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,9,{partime}", Rdic)
|
||
' If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' End If
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,10,{partime1}", Rdic)
|
||
' If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' End If
|
||
|
||
' End If
|
||
' If Rdic.ContainsKey("PB_STRIP_DEVICE".ToUpper) Then
|
||
' If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_STRIP_DEVICE", 1, $"0,0,9,{partime}", Rdic)
|
||
' If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' End If
|
||
' 'databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,10,{partime}", Rdic)
|
||
' 'If Not IsNothing(databuff) Then
|
||
' ' ncbuf.AddRange(databuff.ToArray)
|
||
' 'End If
|
||
' End If
|
||
' If Rdic.ContainsKey("Dimming".ToUpper) Then
|
||
' If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 1, $"0,0,1,{partime}", Rdic)
|
||
' If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' End If
|
||
' Rdic.Clear()
|
||
' Rdic.Add("Dimming".ToUpper, "48 主机调光百分比值(0-100)")
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 1, $"0,0,16,{partime1}", Rdic)
|
||
' If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' End If
|
||
' End If
|
||
' If Musicdic.Count > 0 Then
|
||
' For Each mnode In Musicdic
|
||
' databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "MUSIC", 1, $"0,0,0,{mnode.Key },{mnode.Value },0", Nothing)
|
||
' If IsNothing(databuff) Then Continue For
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
' Next
|
||
' End If
|
||
|
||
' Next
|
||
|
||
'End If
|
||
'遍历设备列表
|
||
|
||
If rowtag.G_DicRow.ContainsKey(TableColNumber.ServerAttribute) = False OrElse String.IsNullOrEmpty(rowtag.G_DicRow.Item(TableColNumber.ServerAttribute)) Then '按键
|
||
|
||
Else '服务
|
||
'获取场景属性
|
||
|
||
Dim Tserverbuf() As String = rowtag.G_DicRow.Item(TableColNumber.ServerAttribute).Split(vbLf)
|
||
|
||
For Each Findex In Tserverbuf
|
||
Dim serverbuf() As String = Findex.Split(",")
|
||
DevModeName = hostname
|
||
DevGroupName = "HOSTSERVICE"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, serverbuf(0), serverbuf(1), Nothing, CInt(serverbuf(2)), CInt(serverbuf(3)))
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Scenebuf.AddRange(databuff.ToArray)
|
||
Next
|
||
|
||
End If
|
||
If Not IsNothing(celltag) AndAlso celltag.ContainsKey("CallRowA") AndAlso Not String.IsNullOrEmpty(celltag.Item("CallRowA")) Then
|
||
'添加反饋燈
|
||
Dim callA() = celltag.Item("CallRowA").Split(",")
|
||
For Each callindex In callA
|
||
|
||
databuff = AdditionalFeedbackLamp(callindex, DeviceModuleDic, celltag)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Scenebuf.AddRange(databuff.ToArray)
|
||
databuff = ParallelScenario(callindex, DeviceModuleDic, SwitchConfig)
|
||
If Not IsNothing(databuff) Then
|
||
multiplebuf.Add(databuff)
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
For Each index In rowtag.G_DicRow
|
||
Integer.TryParse(index.Key, col)
|
||
|
||
'If index.Value.Equals("插卡") Then
|
||
If index.Value.Equals("Check-in service") And rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Substring(0, 1).Equals("1") Then
|
||
Dim onecelltag As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(_grd.Cell(7, TableColNumber.SceneAttribute).Tag)
|
||
If Not IsNothing(onecelltag) AndAlso onecelltag.ContainsKey("34 A9PB Dimming gradient time") Then
|
||
Dim Rdic As New Dictionary(Of String, String)
|
||
Dim Musicdic As New Dictionary(Of String, String)
|
||
|
||
Dim partime As String = String.Empty
|
||
Dim partime1 As String = String.Empty
|
||
Dim partime2 As String = String.Empty
|
||
Dim partime3 As String = String.Empty
|
||
For Each TheDevMode In DeviceModuleDic.Values
|
||
Musicdic.Clear()
|
||
Rdic.Clear()
|
||
Select Case TheDevMode.Desc.Name
|
||
Case "灯带"
|
||
Rdic.Add("Dimming".ToUpper, "36 Dimming gradient time of light strip")
|
||
partime = onecelltag.Item("36 Dimming gradient time of light strip")
|
||
Case "1到10V调光"
|
||
Rdic.Add("Dimming".ToUpper, "32 1-10V Dimming gradient time")
|
||
partime = onecelltag.Item("32 1-10V Dimming gradient time")
|
||
Case "A9调光"
|
||
Rdic.Add("Dimming".ToUpper, "33 A9 Constant voltage dimming gradient time")
|
||
partime = onecelltag.Item("33 A9 Constant voltage dimming gradient time")
|
||
Case "A8PB调光"
|
||
Rdic.Add("Dimming".ToUpper, "34 A9PB Dimming gradient time")
|
||
partime = onecelltag.Item("34 A9PB Dimming gradient time")
|
||
'Case "PB"
|
||
|
||
|
||
Case "PB_STRIP_DEVICE"
|
||
Rdic.Add("PB_STRIP_DEVICE".ToUpper, "C8PLC peripheral constant voltage dimming gradient time")
|
||
partime = onecelltag.Item("C8PLC peripheral constant voltage dimming gradient time")
|
||
|
||
Case "BLV_C12"
|
||
For Each configindex In TheDevMode.Nodes
|
||
Select Case configindex.Name
|
||
Case "PB_LINE_CONTROL".ToUpper
|
||
Rdic.Add("PB_LINE_CONTROL".ToUpper, "C8PLC comes with constant pressure dimming gradient time")
|
||
partime = onecelltag.Item("C8PLC comes with constant pressure dimming gradient time")
|
||
If onecelltag.ContainsKey("48 Percentage of host dimming(0-100)") Then
|
||
partime1 = onecelltag.Item("48 Percentage of host dimming(0-100)")
|
||
Else
|
||
partime1 = Nothing
|
||
End If
|
||
If onecelltag.ContainsKey("50 Adjustable Lower limit Settings (0-100)") Then
|
||
partime2 = onecelltag.Item("50 Adjustable Lower limit Settings (0-100)")
|
||
Else
|
||
partime2 = Nothing
|
||
End If
|
||
If onecelltag.ContainsKey("49 Adjustable Upper limit Settings (0-100)") Then
|
||
partime3 = onecelltag.Item("49 Adjustable Upper limit Settings (0-100)")
|
||
Else
|
||
partime3 = Nothing
|
||
End If
|
||
|
||
Case "Dimming".ToUpper
|
||
Rdic.Add("Dimming".ToUpper, "35 C12 dimming gradient")
|
||
partime = onecelltag.Item("35 C12 Dimming gradient time")
|
||
|
||
If onecelltag.ContainsKey("48 Host dimming percentage (0-100)") Then
|
||
partime1 = onecelltag.Item("48 Host dimming percentage (0-100)")
|
||
Else
|
||
partime1 = Nothing
|
||
End If
|
||
If onecelltag.ContainsKey("50 Adjustable Lower limit Settings (0-100)") Then
|
||
partime2 = onecelltag.Item("50 Adjustable Lower limit Settings (0-100)")
|
||
Else
|
||
partime2 = Nothing
|
||
End If
|
||
If onecelltag.ContainsKey("49 Adjustable Upper limit Settings (0-100)") Then
|
||
partime3 = onecelltag.Item("49 Adjustable Upper limit Settings (0-100)")
|
||
Else
|
||
partime3 = Nothing
|
||
End If
|
||
|
||
End Select
|
||
Next
|
||
|
||
If Not String.IsNullOrEmpty(onecelltag.Item("7 Set music volume")) Then
|
||
Musicdic.Add(7, onecelltag.Item("7 Set music volume"))
|
||
End If
|
||
If Not String.IsNullOrEmpty(onecelltag.Item("8 Set prompt sound volume")) Then
|
||
Musicdic.Add(8, onecelltag.Item("8 Set prompt sound volume"))
|
||
End If
|
||
If Not String.IsNullOrEmpty(onecelltag.Item("9 Set doorbell and welcome message volume")) Then
|
||
Musicdic.Add(9, onecelltag.Item("9 Set doorbell and welcome message volume"))
|
||
End If
|
||
If Not String.IsNullOrEmpty(onecelltag.Item("10 Set global volume limit")) Then
|
||
Musicdic.Add(10, onecelltag.Item("10 Set global volume limit"))
|
||
'Musicdic.Add(10, onecelltag.Item("10 Set global volume limit"))
|
||
End If
|
||
If Not String.IsNullOrEmpty(onecelltag.Item("12 Set sleep aid volume")) Then
|
||
Musicdic.Add(12, onecelltag.Item("12 Set sleep aid volume"))
|
||
'Musicdic.Add(10, celltag.Item("10 设定最大音量限制"))
|
||
End If
|
||
|
||
Case Else
|
||
Continue For
|
||
End Select
|
||
If Rdic.ContainsKey("PB_LINE_CONTROL".ToUpper) Then
|
||
If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,9,{partime}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
'databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,10,{partime1}", Rdic)
|
||
'If Not IsNothing(databuff) Then
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
'End If
|
||
|
||
End If
|
||
If Rdic.ContainsKey("PB_LINE_CONTROL".ToUpper) Then
|
||
If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,9,{partime}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime1) Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 1, $"0,0,10,{partime1}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime2) Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 2, $"0,0,12,{partime2}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime3) Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "PB_LINE_CONTROL", 3, $"0,0,11,{partime3}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
|
||
If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
If Rdic.ContainsKey("Dimming".ToUpper) OrElse Rdic.ContainsKey("PB_LINE_CONTROL".ToUpper) Then
|
||
For Each devRKEYnode In devRKEY
|
||
If Not String.IsNullOrEmpty(partime2) Then
|
||
Rdic.Clear()
|
||
Rdic.Add("RKEY".ToUpper, "50 Adjustable Lower limit Settings (0-100)")
|
||
databuff = GetActionDatagather(DeviceModuleDic, devRKEYnode.Name, "RKEY", 1, $"0,0,6,{partime2}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime3) Then
|
||
Rdic.Clear()
|
||
Rdic.Add("RKEY".ToUpper, "49 Adjustable Upper limit Settings (0-100)")
|
||
databuff = GetActionDatagather(DeviceModuleDic, devRKEYnode.Name, "RKEY", 1, $"0,0,5,{partime3}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
Next
|
||
End If
|
||
|
||
|
||
|
||
|
||
If Rdic.ContainsKey("Dimming".ToUpper) Then
|
||
If String.IsNullOrEmpty(partime) AndAlso String.IsNullOrEmpty(partime1) Then Continue For
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 1, $"0,0,1,{partime}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime1) Then
|
||
Rdic.Clear()
|
||
Rdic.Add("Dimming".ToUpper, "48 Host dimming percentage (0-100)")
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 1, $"0,0,48,{partime1}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime2) Then
|
||
Rdic.Clear()
|
||
Rdic.Add("Dimming".ToUpper, "50 Adjustable Lower limit Settings (0-100)")
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 2, $"0,0,50,{partime2}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
If Not String.IsNullOrEmpty(partime3) Then
|
||
Rdic.Clear()
|
||
Rdic.Add("Dimming".ToUpper, "49 Adjustable Upper limit Settings (0-100)")
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "Dimming", 3, $"0,0,49,{partime3}", Rdic)
|
||
If Not IsNothing(databuff) Then
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
|
||
End If
|
||
If Musicdic.Count > 0 Then
|
||
For Each mnode In Musicdic
|
||
databuff = GetActionDatagather(DeviceModuleDic, TheDevMode.Name, "MUSIC", 1, $"0,0,0,{mnode.Key },{mnode.Value },0", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Next
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
|
||
|
||
For Each vindex In Voicement
|
||
If vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("1") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "MUSIC", 1, "0,0,0,1,0,开启语音识别", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
|
||
For Each vindex In devTempment
|
||
If vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("1") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,1,1,0,0,温控器高级设置,0*秒*0 设置*1 插卡状态同步*1 开*0*0", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
ElseIf vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("0") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,1,2,0,0,温控器高级设置,0*秒*0 设置*1 插卡状态同步*1 开*0*0", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
|
||
End If
|
||
'If vindex.Desc.DevDescription.Length > 6 AndAlso vindex.Desc.DevDescription.Substring(6, 1).Equals("1") Then
|
||
' databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,2,1,0,0,温控器高级设置,0*秒*0 设置*2 风速模式提示音*1 开*0*0", Nothing)
|
||
' If IsNothing(databuff) Then Continue For
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
'Else
|
||
' databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,2,2,0,0,温控器高级设置,0*秒*0 设置*2 风速模式提示音*1 开*0*0", Nothing)
|
||
' If IsNothing(databuff) Then Continue For
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
|
||
'End If
|
||
|
||
Next
|
||
|
||
|
||
'ElseIf index.Value.Equals("拔卡") Then
|
||
ElseIf index.Value.Equals("Check-in service") And rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Substring(0, 1).Equals("2") Then
|
||
Dim onecelltag As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(_grd.Cell(7, TableColNumber.SceneAttribute).Tag)
|
||
|
||
|
||
|
||
For Each vindex In Voicement
|
||
If vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("1") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "MUSIC", 1, "0,0,0,2,0,关闭语音识别", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
Next
|
||
For Each vindex In devTempment
|
||
If vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("1") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,1,1,0,0,温控器高级设置,0*秒*0 设置*1 插卡状态同步*1 开*0*0", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
ElseIf vindex.Desc.DevDescription.Length > 0 AndAlso vindex.Desc.DevDescription.Substring(0, 1).Equals("0") Then
|
||
databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,1,2,0,0,温控器高级设置,0*秒*0 设置*1 插卡状态同步*1 开*0*0", Nothing)
|
||
If IsNothing(databuff) Then Continue For
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
|
||
End If
|
||
'If vindex.Desc.DevDescription.Length > 6 AndAlso vindex.Desc.DevDescription.Substring(6, 1).Equals("1") Then
|
||
' databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,2,1,0,0,温控器高级设置,0*秒*0 设置*2 风速模式提示音*1 开*0*0", Nothing)
|
||
' If IsNothing(databuff) Then Continue For
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
'Else
|
||
' databuff = GetActionDatagather(DeviceModuleDic, vindex.Name, "Temp", 1, "0,2,0,2,2,0,0,温控器高级设置,0*秒*0 设置*2 风速模式提示音*1 开*0*0", Nothing)
|
||
' If IsNothing(databuff) Then Continue For
|
||
' ncbuf.AddRange(databuff.ToArray)
|
||
|
||
'End If
|
||
|
||
|
||
Next
|
||
|
||
End If
|
||
If col > TableColNumber.Max - 2 And col < Grid1.Cols - 1 Then
|
||
|
||
Integer.TryParse(Grid1.Cell(TableRowNumber.FunctionChildNodeID, col).Text, t_col)
|
||
Console.WriteLine($"{Grid1.Cell(TableRowNumber.FunctionChildNodeAnother, col).Text}_{Grid1.Cell(TableRowNumber.FunctionChildNodeID, col).Text}")
|
||
DevGroupName = Grid1.Cell(TableRowNumber.FunctionName, col - t_col + 1).Text
|
||
DevModeName = Grid1.Cell(TableRowNumber.DeviceName, Grid1.Range(TableRowNumber.DeviceName, col, TableRowNumber.DeviceName, col).FirstCol).Text
|
||
If DevGroupName.ToUpper.Equals("MUSIC") And Not String.IsNullOrEmpty(index.Value) Then
|
||
Ismusic = True
|
||
Else
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, index.Value, celltag)
|
||
If IsNothing(databuff) Then Continue For
|
||
Scenebuf.AddRange(databuff.ToArray)
|
||
End If
|
||
If index.Value.Contains("Play prompt sound") AndAlso (index.Value.Contains("2 Play (prompt sound)") OrElse index.Value.Contains("1 Mute (alert sound)")) Then
|
||
|
||
Dim strbuf() As String = index.Value.Split(vbLf)
|
||
For Each prnode In strbuf
|
||
If prnode.Contains("2 Play (prompt sound)") OrElse prnode.Contains("1 Mute (alert sound)") Then
|
||
DevModeName = hostname
|
||
DevGroupName = "HOSTSERVICE"
|
||
Dim serverbuf() As String = prnode.Split(",")
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, 24, serverbuf(2), Nothing, CInt(serverbuf(0)), CInt(serverbuf(1)))
|
||
Else
|
||
DevGroupName = Grid1.Cell(TableRowNumber.FunctionName, col - t_col + 1).Text
|
||
DevModeName = Grid1.Cell(TableRowNumber.DeviceName, Grid1.Range(TableRowNumber.DeviceName, col, TableRowNumber.DeviceName, col).FirstCol).Text
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, prnode, celltag)
|
||
End If
|
||
If isCheckOut > 0 Then
|
||
|
||
If rowtag.G_DevModeName.Equals(DevModeName) AndAlso prnode.Equals("Corresponding scenario") AndAlso DevGroupName.Equals("DO") AndAlso Grid1.Column(col).Visible = True Then
|
||
CheckOutdeng = t_col
|
||
End If
|
||
End If
|
||
|
||
If IsNothing(databuff) Then Continue For
|
||
If prnode.Equals("Corresponding scenario") AndAlso DevGroupName.Equals("DO") AndAlso rowtag.G_DicRow.Count = 6 AndAlso isCheckOut = 0 Then Continue For
|
||
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Next
|
||
Continue For
|
||
ElseIf index.Value.Contains("Huaersi Music Control") Then
|
||
Dim strbuf() As String = index.Value.Split(vbLf)
|
||
Dim Tpar As String = String.Empty
|
||
Dim tbuf() As String
|
||
For Each prnode In strbuf
|
||
|
||
If prnode.Contains("2 Shutdown") Then
|
||
tbuf = prnode.Split(",")
|
||
Tpar = $"{tbuf(0)},{tbuf(1)},{tbuf(2)},{tbuf(tbuf.Length - 2)}"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, Tpar, celltag)
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Continue For
|
||
ElseIf prnode.Contains("1 Power on") Then
|
||
tbuf = prnode.Split(",")
|
||
Tpar = $"{tbuf(0)},{tbuf(1)},{tbuf(2)},{tbuf(tbuf.Length - 2)}"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, Tpar, celltag)
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
If prnode.Contains("channel") Then
|
||
Tpar = $"{tbuf(0)},{tbuf(1)},{tbuf(3)},0,{tbuf(tbuf.Length - 2)}"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, Tpar, celltag)
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
If prnode.Contains("volume") Then
|
||
Tpar = $"{tbuf(0)},{tbuf(1)},0,{tbuf(4)},{tbuf(5)},{tbuf(tbuf.Length - 2)}"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, Tpar, celltag)
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
Else
|
||
Tpar = $"{tbuf(0)},{tbuf(1)},0,{tbuf(4)},{tbuf(tbuf.Length - 2)}"
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, Tpar, celltag)
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
End If
|
||
|
||
Next
|
||
Continue For
|
||
End If
|
||
|
||
databuff = GetActionDatagather(DeviceModuleDic, DevModeName, DevGroupName, t_col, index.Value, celltag)
|
||
|
||
|
||
If isCheckOut > 0 Then
|
||
If rowtag.G_DevModeName.Equals(DevModeName) AndAlso index.Value.Equals("Corresponding scenario") AndAlso DevGroupName.Equals("DO") AndAlso Grid1.Column(col).Visible = True Then
|
||
CheckOutdeng = t_col
|
||
End If
|
||
End If
|
||
|
||
If IsNothing(databuff) Then Continue For
|
||
If index.Value.Equals("Corresponding scenario") AndAlso DevGroupName.Equals("DO") AndAlso rowtag.G_DicRow.Count = 6 AndAlso isCheckOut = 0 Then Continue For
|
||
|
||
ncbuf.AddRange(databuff.ToArray)
|
||
End If
|
||
Next
|
||
'
|
||
If Ismusic = True And Scenebuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(0) '设备类型
|
||
|
||
li.Add(0) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(BitConverter.GetBytes(CShort(g_devLoop))) '设备回路 2
|
||
g_devLoop += 1
|
||
li.AddRange(BitConverter.GetBytes(CShort(0))) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = Scenebuf.Count
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In Scenebuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
result.Add(li.ToArray)
|
||
End If
|
||
'本行动作数据
|
||
If ncbuf.Count > 50 Then
|
||
MsgBox($"{sceneIndex}The number of scene actions has exceeded the limit. Please increase the services to move some of the actions to the new service.。")
|
||
|
||
End If
|
||
If ncbuf.Count > 0 Then
|
||
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
Dim valCount As UShort
|
||
If Ismusic = True Then
|
||
valCount = sceneIndex + 30000
|
||
Else
|
||
valCount = sceneIndex
|
||
End If
|
||
|
||
li.AddRange(BitConverter.GetBytes(valCount)) '2字节,场景编号 2
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
valCount = CUShort(ncbuf.Count)
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
'40901001
|
||
'40902001
|
||
'21 1 1 0 19 24 0 2
|
||
'3 0 1 0 14 0 0 1
|
||
If isCheckOut > 0 Then '判断是否需添加服务
|
||
CheckOutDic = CheckOutKey(isCheckOut, rowtag.G_DevNodeIndex, CheckOutdeng, li, devAddr)
|
||
For Each index In CheckOutDic
|
||
result.Add(index.Value.ToArray)
|
||
Next
|
||
Else
|
||
li = PowerSupplyService(rowtag, strEventNum, li, DeviceModuleDic)
|
||
result.Add(li.ToArray)
|
||
End If
|
||
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
|
||
'调用场景
|
||
For Each blian In multiplebuf
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(blian(0)(0)) '设备类型
|
||
|
||
li.Add(blian(1)(0)) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(blian(2)) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(blian(3)) '2字节,场景编号 2
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
Next
|
||
|
||
|
||
Else
|
||
Continue For
|
||
End If
|
||
Next
|
||
|
||
Return result
|
||
|
||
End Function
|
||
Public Function PowerSupplyService(rowtag As TableRowTag, strEventNum As UShort, li As List(Of Byte), DeviceModuleDic As Dictionary(Of String, DeviceModel)) As List(Of Byte)
|
||
'判断是否是入住服务
|
||
Console.WriteLine(rowtag.G_DevNodeName.ToUpper.Equals("HOSTSERVICE"))
|
||
|
||
If rowtag.G_DevNodeName.ToUpper.Equals("HOSTSERVICE") AndAlso rowtag.G_DevNodeIndex = 1 Then
|
||
Dim DevDescription As String = String.Empty
|
||
Dim addr As Integer = 0
|
||
For Each index In DeviceModuleDic
|
||
For Each node In index.Value.Nodes
|
||
If node.DEV_TYPE_DATA.Equals("19") Then
|
||
DevDescription = index.Value.Desc.DevDescription
|
||
addr = GetActionDeviceAddr(DeviceModuleDic, index.Key, "")
|
||
End If
|
||
Next
|
||
Next
|
||
|
||
If Not String.IsNullOrEmpty(DevDescription) Then
|
||
Dim actionlen As Integer = 116
|
||
Dim buf() As String = DevDescription.Split(",")
|
||
Select Case strEventNum
|
||
Case 1
|
||
If buf(0).Equals("1") Then
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({21, addr, 1, 0, 16, 0, 0, 1})
|
||
End If
|
||
If buf(3).Equals("1") Then
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({21, addr, 1, 0, 192, 0, 10, 2})
|
||
End If
|
||
|
||
' GetActionDatagather()
|
||
Case 2
|
||
If buf(0).Equals("1") Then
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({21, addr, 1, 0, 32, 0, 10, 1})
|
||
End If
|
||
|
||
Case Else
|
||
|
||
End Select
|
||
End If
|
||
|
||
|
||
End If
|
||
Return li
|
||
|
||
|
||
End Function
|
||
|
||
Public Function CheckOutKey(isCheckOut As Integer, Diloop As Integer, devloop As Integer, li As List(Of Byte), addr As Integer) As Dictionary(Of String, List(Of Byte))
|
||
If devloop = 0 Then
|
||
devloop = Diloop
|
||
End If
|
||
Dim actionlen As Integer = 116
|
||
Dim resulrdic As New Dictionary(Of String, List(Of Byte))
|
||
Select Case isCheckOut '"7 清理", "8 勿扰", "9 稍后", "10 退房"
|
||
Case "7"
|
||
|
||
'li(actionlen) = li(actionlen) + 1
|
||
'li.AddRange({4, 0, 3, 0, 1, 0, 0, 1})
|
||
'resulrdic.Add("1", li)
|
||
Dim index As Integer
|
||
Dim actionlencun As Integer = li(actionlen) - 1
|
||
For i = 0 To actionlencun
|
||
index = (actionlencun - i) * 8 + actionlen
|
||
If li(index + 1) = 6 AndAlso li(index + 2) = addr AndAlso li(index + 3) = devloop AndAlso li(index + 4) = 0 AndAlso
|
||
li(index + 5) = 3 AndAlso li(index + 6) = 0 AndAlso li(index + 7) = 0 AndAlso li(index + 8) = 1 Then
|
||
li(actionlen) = li(actionlen) - 1
|
||
li.RemoveAt(index + 8)
|
||
li.RemoveAt(index + 7)
|
||
li.RemoveAt(index + 6)
|
||
li.RemoveAt(index + 5)
|
||
li.RemoveAt(index + 4)
|
||
li.RemoveAt(index + 3)
|
||
li.RemoveAt(index + 2)
|
||
li.RemoveAt(index + 1)
|
||
End If
|
||
|
||
Next
|
||
Dim li1(li.Count - 1), li2(actionlen) As Byte
|
||
Dim arrli1, arrli2 As List(Of Byte)
|
||
arrli1 = New List(Of Byte)
|
||
arrli2 = New List(Of Byte)
|
||
Array.Copy(li.ToArray, li2, actionlen)
|
||
'li2(actionlen) = 0
|
||
Array.Copy(li.ToArray, li1, li.Count - 1)
|
||
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup("1224996759550300160")
|
||
Dim libufb() As Byte = li.ToArray
|
||
Array.Copy(clause, 0, libufb, 9, 8)
|
||
li.Clear()
|
||
li.AddRange(libufb)
|
||
|
||
li(3) = 1
|
||
li(actionlen) = li(actionlen) + 4
|
||
li.AddRange({4, 0, 11, 0, 1, 0, 0, 1})
|
||
li.AddRange({4, 0, 11, 0, 2, 0, 10, 2})
|
||
li.AddRange({21, 1, 1, 0, 19, 167, 0, 1})
|
||
Dim loopBuf() As Byte = BitConverter.GetBytes(CShort(devloop))
|
||
li.AddRange({6, addr, devloop, 0, 14, 0, 1, 2})
|
||
resulrdic.Add("1", li)
|
||
|
||
clause = GetConditionDataUnderConditionGroup("1224996725190561792")
|
||
|
||
Array.Copy(clause, 0, li1, 9, 8)
|
||
arrli1.Clear()
|
||
arrli1.AddRange(li1)
|
||
arrli1(3) = 2
|
||
arrli1(actionlen) = arrli1(actionlen) + 4
|
||
|
||
arrli1.AddRange({4, 0, 3, 0, 1, 0, 0, 1})
|
||
arrli1.AddRange({4, 0, 11, 0, 1, 0, 0, 1})
|
||
arrli1.AddRange({21, 1, 1, 0, 19, 168, 0, 2})
|
||
' arrli1.AddRange({6, addr, devloop, 0, 14, 0, 1, 2})
|
||
arrli1.AddRange({6, addr, devloop, 0, 3, 0, 0, 1})
|
||
resulrdic.Add("2", arrli1)
|
||
|
||
clause = GetConditionDataUnderConditionGroup("1224996690830821376")
|
||
|
||
Array.Copy(clause, 0, li2, 9, 8)
|
||
arrli2.Clear()
|
||
arrli2.AddRange(li2)
|
||
arrli2(3) = 3
|
||
arrli2(actionlen) = arrli2(actionlen) + 3
|
||
arrli2.AddRange({4, 0, 3, 0, 2, 0, 0, 1})
|
||
arrli2.AddRange({4, 0, 11, 0, 2, 0, 0, 1})
|
||
arrli2.AddRange({21, 1, 1, 0, 19, 169, 0, 2})
|
||
|
||
resulrdic.Add("3", arrli2)
|
||
|
||
|
||
|
||
|
||
|
||
Case "8"
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({4, 0, 2, 0, 1, 0, 0, 1})
|
||
resulrdic.Add("1", li)
|
||
Case "7"
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({4, 0, 3, 0, 1, 0, 0, 1})
|
||
resulrdic.Add("1", li)
|
||
Case "9"
|
||
li(actionlen) = li(actionlen) + 1
|
||
li.AddRange({4, 0, 7, 0, 1, 0, 0, 1})
|
||
resulrdic.Add("1", li)
|
||
Case "10"
|
||
Dim index As Integer
|
||
Dim actionlencun As Integer = li(actionlen) - 1
|
||
For i = 0 To actionlencun
|
||
index = (actionlencun - i) * 8 + actionlen
|
||
If li(index + 1) = 6 AndAlso li(index + 2) = addr AndAlso li(index + 3) = devloop AndAlso li(index + 4) = 0 AndAlso
|
||
li(index + 5) = 3 AndAlso li(index + 6) = 0 AndAlso li(index + 7) = 0 AndAlso li(index + 8) = 1 Then
|
||
li(actionlen) = li(actionlen) - 1
|
||
li.RemoveAt(index + 8)
|
||
li.RemoveAt(index + 7)
|
||
li.RemoveAt(index + 6)
|
||
li.RemoveAt(index + 5)
|
||
li.RemoveAt(index + 4)
|
||
li.RemoveAt(index + 3)
|
||
li.RemoveAt(index + 2)
|
||
li.RemoveAt(index + 1)
|
||
End If
|
||
|
||
Next
|
||
Dim li1(li.Count - 1), li2(li.Count - 1) As Byte
|
||
Dim arrli1, arrli2 As List(Of Byte)
|
||
arrli1 = New List(Of Byte)
|
||
arrli2 = New List(Of Byte)
|
||
Array.Copy(li.ToArray, li2, li.Count - 1)
|
||
Array.Copy(li.ToArray, li1, li.Count - 1)
|
||
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup("1224996691906658304")
|
||
Dim libufb() As Byte = li.ToArray
|
||
Array.Copy(clause, 0, libufb, 9, 8)
|
||
li.Clear()
|
||
li.AddRange(libufb)
|
||
|
||
li(3) = 1
|
||
li(actionlen) = li(actionlen) + 4
|
||
li.AddRange({4, 0, 9, 0, 1, 0, 0, 1})
|
||
li.AddRange({4, 0, 9, 0, 2, 0, 10, 2})
|
||
li.AddRange({21, 1, 1, 0, 19, 24, 0, 1})
|
||
Dim loopBuf() As Byte = BitConverter.GetBytes(CShort(devloop))
|
||
li.AddRange({6, addr, devloop, 0, 14, 0, 1, 2})
|
||
resulrdic.Add("1", li)
|
||
|
||
clause = GetConditionDataUnderConditionGroup("1224996691369787392")
|
||
|
||
Array.Copy(clause, 0, li1, 9, 8)
|
||
arrli1.Clear()
|
||
arrli1.AddRange(li1)
|
||
arrli1(3) = 2
|
||
arrli1(actionlen) = arrli1(actionlen) + 3
|
||
|
||
arrli1.AddRange({4, 0, 6, 0, 1, 0, 0, 1})
|
||
arrli1.AddRange({21, 1, 1, 0, 19, 18, 0, 2})
|
||
' arrli1.AddRange({6, addr, devloop, 0, 14, 0, 1, 2})
|
||
arrli1.AddRange({6, addr, devloop, 0, 3, 0, 0, 1})
|
||
resulrdic.Add("2", arrli1)
|
||
|
||
clause = GetConditionDataUnderConditionGroup("1224996690831867904")
|
||
|
||
Array.Copy(clause, 0, li2, 9, 8)
|
||
arrli2.Clear()
|
||
arrli2.AddRange(li2)
|
||
arrli2(3) = 3
|
||
arrli2(actionlen) = arrli2(actionlen) + 3
|
||
arrli2.AddRange({4, 0, 6, 0, 2, 0, 0, 1})
|
||
arrli2.AddRange({21, 1, 1, 0, 19, 19, 0, 2})
|
||
arrli2.AddRange({6, addr, devloop, 0, 2, 0, 0, 1})
|
||
resulrdic.Add("3", arrli2)
|
||
'40901001
|
||
'40902001
|
||
'21 1 1 0 19 24 0 2
|
||
'3 0 1 0 14 0 0 1
|
||
|
||
Case Else
|
||
Return resulrdic
|
||
End Select
|
||
Return resulrdic
|
||
End Function
|
||
|
||
Public Function ParallelScenario(number As String, ByRef DeviceModuleDic As Dictionary(Of String, DeviceModel), SwitchConfig As List(Of TableRowTag)) As List(Of Byte())
|
||
Dim li As New List(Of Byte())
|
||
'获取行号
|
||
Dim Nr As Integer = 0
|
||
For r = 7 To _grd.Rows - 1
|
||
If _grd.Cell(r, 3).Text.Equals(number) Then
|
||
Nr = r
|
||
Exit For
|
||
End If
|
||
Next
|
||
If Nr < 7 Then Return li
|
||
'模型的设备类型
|
||
Dim rowtag As TableRowTag = SwitchConfig.Item(Nr - TableRowNumber.Max)
|
||
'Console.WriteLine("ParallelScenario 3123")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, rowtag.G_DevModeName, rowtag.G_DevNodeName)
|
||
li.Add({devType})
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, rowtag.G_DevModeName, rowtag.G_DevNodeName)
|
||
li.Add({devAddr})
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(rowtag.G_DevNodeIndex))
|
||
li.Add(devLoop)
|
||
'场景编号
|
||
Dim sceneIndex As UShort = CUShort(rowtag.G_DicRow.Item(TableColNumber.SceneID))
|
||
Dim sceneNum() As Byte = BitConverter.GetBytes(sceneIndex)
|
||
li.Add(sceneNum)
|
||
Return li
|
||
End Function
|
||
|
||
Public Function AdditionalFeedbackLamp(number As String, ByRef DeviceModuleDic As Dictionary(Of String, DeviceModel), celltag As Dictionary(Of String, String)) As List(Of Byte())
|
||
Dim li As New List(Of Byte())
|
||
'获取行号
|
||
Dim Nr As Integer
|
||
For r = 7 To _grd.Rows - 1
|
||
Console.WriteLine(_grd.Cell(r, 3).Text)
|
||
If _grd.Cell(r, 3).Text.Equals(number) Then
|
||
Nr = r
|
||
Exit For
|
||
End If
|
||
Next
|
||
If Nr = 0 Then Return Nothing
|
||
'获取设备名
|
||
Dim devname As String = GetgrdRange(Nr, 1, tabRange.devname)
|
||
'获取设备名对应反馈灯列
|
||
Dim tabledev As CtabRange = GetCoLDevNametabRange(devname, TableRowNumber.DeviceName)
|
||
tabledev = GetCoLDevNametabRange("DO", TableRowNumber.FunctionName, tabledev.fc)
|
||
'行遍历反馈灯列动作
|
||
For col = tabledev.fc To tabledev.lc
|
||
If String.IsNullOrEmpty(_grd.Cell(Nr, col).Text) Then
|
||
Continue For
|
||
Else
|
||
Dim databuff = GetActionDatagather(DeviceModuleDic, devname, "DO", _grd.Cell(TableRowNumber.FunctionChildNodeID, col).Text, _grd.Cell(Nr, col).Text, celltag)
|
||
li.AddRange(databuff.ToArray)
|
||
End If
|
||
|
||
Next
|
||
Return li
|
||
|
||
|
||
End Function
|
||
|
||
|
||
Private Function TempDeviceObject(ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
Dim bytedic As New Dictionary(Of Integer, List(Of Byte()))
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
'模型的设备类型
|
||
'Console.WriteLine("TempDeviceObject 3180")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevName, DevNodeName)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(1))
|
||
'获取场景属性
|
||
'Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
UShort.TryParse(1, strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
'执行条件编译数据
|
||
|
||
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(1152921504606846976)
|
||
'取执行模式
|
||
Dim condition As Byte = GetExecModeDataUnderCondtion(1)
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort
|
||
Dim sceneNum() As Byte
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
'Dim Startname() As String = Dev.Desc.ProtocolData.Split(",")
|
||
Dim dic As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(Dev.Desc.ProtocolData)
|
||
|
||
If Not AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.红外转发, 1, dic) AndAlso
|
||
Not AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.风低, 3, dic) AndAlso
|
||
Not AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈开, 1, dic) AndAlso
|
||
Not AddPeripherals.CheckWhetherTheKeyExists2(dic) AndAlso
|
||
Not AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.互锁, 1, dic) Then
|
||
|
||
MsgBox($"无法识别温控类型,编译失败!!")
|
||
Return Nothing
|
||
End If
|
||
'判断所关联回路的回路设备存在
|
||
For Each index In dic
|
||
If String.IsNullOrEmpty(index.Value.Trim) Then Continue For
|
||
Dim Obuf() As String = index.Value.Trim.Split("*") '开
|
||
|
||
If Not DeviceModuleDic.ContainsKey(Obuf(0)) Then
|
||
MsgBox($"设备:{DevName}{vbCrLf }事件:{index.Key }{vbCrLf } 关联继电器回路:{index.Value}{vbCrLf }未找到,编译失败!!")
|
||
Return Nothing
|
||
End If
|
||
Next
|
||
Dim temptype As Integer = -1
|
||
' 判断是否是氟机 是则直接组包
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.红外转发, 1, dic) AndAlso Not AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.风低, 3, dic) Then
|
||
temptype = 0
|
||
Else '不是氟机
|
||
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈开, 4, dic) Then '双阈三线
|
||
temptype = 4
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈开, 1, dic) AndAlso
|
||
AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.热阈开, 1, dic) Then '双阈2线
|
||
temptype = 3
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈开, 1, dic) AndAlso
|
||
AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈关, 1, dic) Then '单阈三线
|
||
temptype = 2
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.冷阈开, 1, dic) Then '单阈2线
|
||
temptype = 1
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists2(dic) Then
|
||
temptype = 5
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.风低, 3, dic) Then '单阈2线
|
||
temptype = 6
|
||
ElseIf AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.互锁, 1, dic) Then '单阈2线
|
||
temptype = 7
|
||
End If
|
||
|
||
End If
|
||
|
||
Dim Dbuf() As String
|
||
Eventnumber = Eventnumber + 1
|
||
For i = 1 To 11
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891392)
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
Select Case i
|
||
|
||
Case 1 '开机
|
||
UShort.TryParse(32800, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
|
||
|
||
|
||
Select Case temptype
|
||
Case 0
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
Case 1
|
||
|
||
Case 2
|
||
Case 3
|
||
Case 5
|
||
'Continue For
|
||
Case 4
|
||
Case 6
|
||
End Select
|
||
If temptype <> 0 AndAlso AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.红外转发, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
End If
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.互锁, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.互锁)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "Temp", Dbuf(1), "0,1,1,1,1,1,16"))
|
||
End If
|
||
If checkbuf(1).Equals("1") Then
|
||
'Dbuf = dic.Item(GetDescriptionOriginal( AddPeripherals.Temproweven.互锁)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, hostname, "MUSIC", 1, "0,2,3,1,11,0"))
|
||
End If
|
||
If checkbuf(3).Equals("1") Then
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, "Temp", 1, "0,2,0,2,1,0,0"))
|
||
Else
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, "Temp", 1, "0,2,0,2,2,0,0"))
|
||
End If
|
||
|
||
Case 2 '关机
|
||
UShort.TryParse(32, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If temptype <> 0 AndAlso AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.红外转发, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
Case 1
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 2
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 3
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 6
|
||
Case 5
|
||
'Continue For
|
||
End Select
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.风低, 3, dic) Then '单阈2线
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风低)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风中)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风高)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
|
||
End If
|
||
|
||
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.互锁, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.互锁)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "Temp", Dbuf(1), "0,1,1,1,1,1,16"))
|
||
|
||
End If
|
||
If checkbuf(1).Equals("1") Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.互锁)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, hostname, "MUSIC", 1, "0,2,3,1,12,0"))
|
||
End If
|
||
|
||
If checkbuf(3).Equals("1") Then
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, "Temp", 1, "0,2,0,2,1,0,0"))
|
||
Else
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, "Temp", 1, "0,2,0,2,2,0,0"))
|
||
End If
|
||
Case 3 '冷阀开
|
||
UShort.TryParse(1028, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 6
|
||
Case 1
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 2
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 3
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 5
|
||
Continue For
|
||
End Select
|
||
Case 4 '冷阀关
|
||
UShort.TryParse(4, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 6
|
||
Case 1
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 2
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 3
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 5
|
||
Continue For
|
||
End Select
|
||
Case 5 '热阀开
|
||
UShort.TryParse(768, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 1
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 2
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 3
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 6
|
||
Case 5
|
||
Continue For
|
||
End Select
|
||
Case 6 '热阀关
|
||
UShort.TryParse(256, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 1
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 2
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 3
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.热阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈开)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.冷阈关)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 6
|
||
Case 5
|
||
Continue For
|
||
End Select
|
||
Case 7 '风速停
|
||
UShort.TryParse(8, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 5, 7
|
||
Continue For
|
||
Case Else
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风低)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风中)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风高)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
End Select
|
||
|
||
Case 8 '风速低
|
||
UShort.TryParse(2056, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 5, 7
|
||
Continue For
|
||
Case Else
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风低)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风中)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风高)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
End Select
|
||
|
||
Case 9 '风速中
|
||
UShort.TryParse(4104, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 5, 7
|
||
Continue For
|
||
Case Else
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风低)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风中)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风高)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
End Select
|
||
Case 10 '风速高
|
||
UShort.TryParse(6152, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152939096792891424)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Case 5, 7
|
||
Continue For
|
||
Case Else
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风低)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风中)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.风高)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
End Select
|
||
Case 11 '控制
|
||
UShort.TryParse(30, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152921504606847008)
|
||
End If
|
||
Select Case temptype
|
||
Case 0
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
Case 5
|
||
'Continue For
|
||
Case Else
|
||
|
||
End Select
|
||
If temptype <> 0 AndAlso AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.红外转发, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.红外转发)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "INFRARED_FORWARD", Dbuf(1), "0,1,1"))
|
||
End If
|
||
If AddPeripherals.CheckWhetherTheKeyExists(AddPeripherals.Temproweven.互锁, 1, dic) Then
|
||
Dbuf = dic.Item(GetDescriptionOriginal(AddPeripherals.Temproweven.互锁)).Trim.Split("*")
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), "Temp", Dbuf(1), "0,1,1,1,1,1,16"))
|
||
|
||
End If
|
||
|
||
|
||
End Select
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
Return result
|
||
|
||
|
||
End Function
|
||
Private Function Virtual_CardFillDeviceObject(ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
'模型的设备类型
|
||
'Console.WriteLine("CURTAINFillDeviceObject 3615")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevName, DevNodeName)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(1))
|
||
'获取场景属性
|
||
'Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
|
||
'执行条件编译数据
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(0)
|
||
'取执行模式
|
||
Dim condition As Byte = GetExecModeDataUnderCondtion(1)
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort
|
||
|
||
Dim sceneNum() As Byte
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
Eventnumber = Eventnumber + 1
|
||
|
||
For i = 1 To 2
|
||
|
||
UShort.TryParse(i, strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, hostname, "HOSTSERVICE", 1, i))
|
||
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
Return result
|
||
End Function
|
||
|
||
Private Function DRY_NoCardFillDeviceObject(ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
'模型的设备类型
|
||
'Console.WriteLine("CURTAINFillDeviceObject 3615")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevName, DevNodeName)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(1))
|
||
'获取场景属性
|
||
'Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
UShort.TryParse(1, strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
'执行条件编译数据
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(0)
|
||
'取执行模式
|
||
Dim condition As Byte = GetExecModeDataUnderCondtion(1)
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort
|
||
|
||
Dim sceneNum() As Byte
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
Eventnumber = Eventnumber + 1
|
||
|
||
For i = 1 To 1
|
||
|
||
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, hostname, "HOSTSERVICE", 1, "2"))
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
Return result
|
||
|
||
|
||
End Function
|
||
Private Function Dev_ColorTempFillDeviceObject(ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
'编译固定参书
|
||
Dim cmd As Byte = &HA
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
Dim cvint As Integer = 0
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
Integer.TryParse(Dev.Desc.DevDescription, cvint)
|
||
Dim li As New List(Of Byte)
|
||
li.Add(cmd)
|
||
li.Add(devAddr)
|
||
li.Add(cvint)
|
||
|
||
For Each node In Dev.Nodes
|
||
If node.Name.Equals("Dev_ColorTemp") Then
|
||
For i = 1 To cvint
|
||
Dim spbuf() As String = Nothing
|
||
If Not String.IsNullOrEmpty(node.Nodes(i - 1).DefaultAliasName) Then
|
||
spbuf = node.Nodes(i - 1).DefaultAliasName.Split(",")
|
||
spbuf = spbuf(1).Split(":")
|
||
Dim typem As Integer = 0
|
||
Integer.TryParse(spbuf(0), typem)
|
||
li.Add(typem)
|
||
Dim vli As List(Of List(Of String)) = JsonConvert.DeserializeObject(Of List(Of List(Of String)))(node.Nodes(i - 1).Description)
|
||
For Each linode In vli
|
||
li.Add(CInt(linode(3)))
|
||
li.Add(CInt(linode(1)))
|
||
li.Add(CInt(linode(2)))
|
||
Next
|
||
If vli.Count < 5 Then
|
||
Dim licount As Integer = ((5 - vli.Count) * 3) - 1
|
||
Dim testbuf(licount) As Byte
|
||
li.AddRange(testbuf)
|
||
End If
|
||
Else
|
||
Continue For
|
||
End If
|
||
|
||
|
||
Next
|
||
End If
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
Return result
|
||
|
||
End Function
|
||
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
|
||
|
||
|
||
Private Function CURTAINFillDeviceObject(ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
'模型的设备类型
|
||
Console.WriteLine("CURTAINFillDeviceObject 3615")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevName, DevNodeName)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(1))
|
||
'获取场景属性
|
||
'Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
UShort.TryParse(1, strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
'执行条件编译数据
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(0)
|
||
'取执行模式
|
||
Dim condition As Byte = GetExecModeDataUnderCondtion(1)
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort
|
||
|
||
Dim sceneNum() As Byte
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
Dim Startname() As String = Dev.Desc.ProtocolData.Split(",")
|
||
If Startname.Length < 2 Then Return Nothing
|
||
|
||
Dim Obuf() As String = Startname(0).Split("*") '开
|
||
Dim Dbuf() As String = Startname(1).Split("*") '关
|
||
If Not DeviceModuleDic.ContainsKey(Obuf(0)) Then
|
||
MsgBox($"{DevName} 干接点窗帘开继电器回路未找到!!")
|
||
Return Nothing
|
||
ElseIf Not DeviceModuleDic.ContainsKey(Dbuf(0)) Then
|
||
MsgBox($"{DevName} 干接点窗帘关继电器回路未找到!!")
|
||
Return Nothing
|
||
End If
|
||
Eventnumber = Eventnumber + 1
|
||
|
||
For i = 1 To 3
|
||
|
||
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
Select Case i
|
||
Case 1 '窗帘开
|
||
UShort.TryParse(1, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Obuf(0), Obuf(2), Obuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Obuf(0), Obuf(2), Obuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString, CInt(Obuf(3)), 2))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, DevNodeName, 1, "0,2,3"))
|
||
Case 2
|
||
UShort.TryParse(2, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Obuf(0), Obuf(2), Obuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString, CInt(Dbuf(3)), 2))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, DevNodeName, 1, "0,2,3"))
|
||
|
||
Case 3
|
||
UShort.TryParse(6, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Obuf(0), Obuf(2), Obuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0), Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
' ncbuf.Add(GetActionData(DeviceModuleDic, Dbuf(0),Dbuf(2), Dbuf(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString, CInt(Dbuf(2)), 2))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, DevName, DevNodeName, 1, "0,2,3"))
|
||
|
||
End Select
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
Return result
|
||
|
||
|
||
End Function
|
||
Private Function Rs485DeviceObject(Tdevtype As Integer, ByRef Eventnumber As Integer, DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As List(Of Byte())
|
||
'返回变量
|
||
Dim result As New List(Of Byte())
|
||
Dim ncbuf As New List(Of Byte())
|
||
'编译固定参书
|
||
Dim cmd As Byte = &H4
|
||
'模型的设备类型
|
||
Console.WriteLine("Rs485DeviceObject 3729")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevName, DevNodeName)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevName, DevNodeName)
|
||
'回路地址
|
||
Dim devLoop() As Byte = BitConverter.GetBytes(CShort(1))
|
||
'获取场景属性
|
||
'Dim Exbuf() As String = rowtag.G_DicRow.Item(TableColNumber.SceneAttribute).Split(",")
|
||
'事件编号
|
||
Dim strEventNum As UShort = 1
|
||
UShort.TryParse(1, strEventNum)
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(strEventNum)
|
||
'执行条件编译数据
|
||
Dim clause() As Byte = GetConditionDataUnderConditionGroup(1152921504606846976)
|
||
'取执行模式
|
||
Dim condition As Byte = GetExecModeDataUnderCondtion(1)
|
||
'事件条件别名
|
||
Dim aliasbuf(31) As Byte
|
||
'场景编号
|
||
Dim sceneIndex As UShort
|
||
|
||
Dim sceneNum() As Byte
|
||
'30位保留字段
|
||
Dim keepBuf(31) As Byte
|
||
'保留字段(32字节) -> 2022-05-28 V3.1 32bytes
|
||
Dim keepParam(31) As Byte
|
||
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
If String.IsNullOrEmpty(Dev.Desc.ProtocolData) Then Return Nothing
|
||
Dim Startname() As String = Dev.Desc.ProtocolData.Split(",")
|
||
If Dev.Desc.ProtocolData.Contains("Floor heating _ Valve open") Then
|
||
Dim uvdic As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(Dev.Desc.ProtocolData)
|
||
Dim uvlis As New List(Of String)
|
||
Select Case Tdevtype
|
||
Case 1
|
||
If String.IsNullOrEmpty(uvdic.Item("Floor heating _ Valve open")) Then Return Nothing
|
||
uvlis.Add(uvdic.Item("Floor heating _ Valve open"))
|
||
Case 2
|
||
If String.IsNullOrEmpty(uvdic.Item("Floor heating _ Valve open")) And String.IsNullOrEmpty(uvdic.Item("Floor heating _ Valve open")) And String.IsNullOrEmpty(uvdic.Item("Floor heating _ Valve open")) Then Return Nothing
|
||
uvlis.Add(uvdic.Item("Fresh wind _ Low wind speed"))
|
||
uvlis.Add(uvdic.Item("Fresh wind _ Wind speed"))
|
||
uvlis.Add(uvdic.Item("Fresh wind _ High wind speed"))
|
||
|
||
End Select
|
||
|
||
Startname = uvlis.ToArray
|
||
End If
|
||
|
||
Dim Rli As New List(Of String())
|
||
|
||
|
||
For i = 0 To Startname.Length - 1
|
||
Dim Obuf() As String = Startname(i).Split("*") '开
|
||
If Not DeviceModuleDic.ContainsKey(Obuf(0)) Then
|
||
If Tdevtype = 1 Then
|
||
MsgBox($" Floor heating valve open relay circuit not found!!")
|
||
Return Nothing
|
||
Else
|
||
Select Case i
|
||
Case 1
|
||
MsgBox($"Low fresh wind speed relay circuit not found!!")
|
||
Case 2
|
||
MsgBox($"Relay circuit not found in fresh wind speed!!")
|
||
Case 3
|
||
MsgBox($"High fresh wind speed Relay circuit not found!!")
|
||
End Select
|
||
Return Nothing
|
||
End If
|
||
|
||
Return Nothing
|
||
Else
|
||
Rli.Add(Obuf)
|
||
End If
|
||
Next
|
||
|
||
|
||
Eventnumber = Eventnumber + 1
|
||
|
||
Dim checkbuf() As String = Dev.Desc.DevDescription.Split(",")
|
||
If checkbuf(0).Equals("1") Then
|
||
clause = GetConditionDataUnderConditionGroup(1152921504606847008)
|
||
End If
|
||
Select Case Tdevtype
|
||
Case 1
|
||
For i = 1 To 2
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
|
||
Select Case i
|
||
Case 1
|
||
UShort.TryParse(256, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
Case 2
|
||
UShort.TryParse(0, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
End Select
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
Case 2
|
||
For i = 1 To 4
|
||
|
||
sceneIndex = CUShort(Eventnumber)
|
||
sceneNum = BitConverter.GetBytes(sceneIndex)
|
||
ncbuf.Clear()
|
||
Select Case i
|
||
Case 1 '窗帘开
|
||
UShort.TryParse(0, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(1)(0), Rli.Item(1)(2), Rli.Item(1)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(2)(0), Rli.Item(2)(2), Rli.Item(2)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
|
||
Case 2
|
||
UShort.TryParse(769, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(1)(0), Rli.Item(1)(2), Rli.Item(1)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(2)(0), Rli.Item(2)(2), Rli.Item(2)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
|
||
Case 3
|
||
UShort.TryParse(513, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(1)(0), Rli.Item(1)(2), Rli.Item(1)(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(2)(0), Rli.Item(2)(2), Rli.Item(2)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
Case 4
|
||
UShort.TryParse(257, strEventNum)
|
||
eventNum = BitConverter.GetBytes(strEventNum)
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(0)(0), Rli.Item(0)(2), Rli.Item(0)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(1)(0), Rli.Item(1)(2), Rli.Item(1)(1), Chr(TableColSwitchKeyDate.TurnDrown).ToString))
|
||
ncbuf.Add(GetActionData(DeviceModuleDic, Rli.Item(2)(0), Rli.Item(2)(2), Rli.Item(2)(1), Chr(TableColSwitchKeyDate.TurnOn).ToString))
|
||
|
||
End Select
|
||
If ncbuf.Count > 0 Then
|
||
Dim li As New List(Of Byte)
|
||
|
||
li.Add(cmd) '命令参数
|
||
|
||
li.Add(devType) '设备类型
|
||
|
||
li.Add(devAddr) '设备地址
|
||
li.AddRange(BitConverter.GetBytes(_actionIndex)) '动作编号 2
|
||
_actionIndex += 1
|
||
li.AddRange(devLoop) '设备回路 2
|
||
li.AddRange(eventNum) '添加事件编号 2
|
||
li.AddRange(clause) '获取执行模式 8
|
||
li.AddRange(keepParam) '条件保留32Byte 32
|
||
li.Add(condition) '获取执行条件编译数据 1
|
||
li.AddRange(aliasbuf) '32字节,事件条件别名 2022-06-07 caocong 32
|
||
|
||
li.AddRange(sceneNum) '2字节,场景编号 2
|
||
Eventnumber = Eventnumber + 1
|
||
li.AddRange(keepBuf) '30位保留字段 32
|
||
Dim valCount As UShort = ncbuf.Count
|
||
|
||
li.Add(valCount) '获取执行动作数量 2
|
||
For Each buf In ncbuf '32
|
||
li.AddRange(buf) '获取动作数据
|
||
Next
|
||
|
||
result.Add(li.ToArray)
|
||
' Console.WriteLine($"UDP收到的数据:{ByteToString(li.ToArray)}")
|
||
End If
|
||
Next
|
||
|
||
End Select
|
||
|
||
Return result
|
||
|
||
|
||
End Function
|
||
|
||
|
||
Private Function GetActionDeviceType(DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As Byte
|
||
Dim Dev As DeviceModel
|
||
|
||
Dev = DeviceModuleDic.Item(DevName)
|
||
|
||
|
||
If DevName.Equals(hostname) Then
|
||
For Each index In Dev.Config
|
||
If index.Name.Equals($"{DevNodeName } device group information") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals("DeviceType") Then
|
||
Return CInt(node.DataDefault)
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
Else
|
||
For Each index In Dev.Nodes
|
||
If index.Name.Equals($"{DevNodeName}") Then
|
||
Return CInt(index.DEV_TYPE_DATA)
|
||
End If
|
||
Next
|
||
End If
|
||
End Function
|
||
|
||
Private Function GetActionDeviceAddr(DeviceModuleDic As Dictionary(Of String, DeviceModel), DevName As String, DevNodeName As String) As Byte
|
||
Dim Dev As DeviceModel = DeviceModuleDic.Item(DevName)
|
||
|
||
For Each index In Dev.Config
|
||
If DevName.Equals(hostname) Then
|
||
If index.Name.Equals($"{DevNodeName } device group information") Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals("DeviceAddr") Then
|
||
Return CInt(node.DataDefault)
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
Else
|
||
If index.Name.Equals($“Device present”) Then
|
||
For Each node In index.Attributes
|
||
If node.Name.Equals("Dialing address") Then
|
||
Return CInt(node.Value)
|
||
End If
|
||
|
||
Next
|
||
|
||
End If
|
||
End If
|
||
Next
|
||
|
||
End Function
|
||
|
||
Private Function GetConditionDataUnderConditionGroup(u64 As String) As Byte()
|
||
'Dim result As New List(Of Byte)
|
||
'For i = 1 To 8
|
||
' result.Add(0)
|
||
'Next
|
||
'If pNode.RowType <> RowNode.RowTypeEnum.DeviceEventAllConditions Then Throw New Exception("转换条件时无效的类型")
|
||
'Dim a As New ConditionConverter
|
||
'For Each node As RowNode In pNode.Nodes
|
||
' Select Case node.Name
|
||
' Case " 1 动作输出使能"
|
||
' a.动作输出使能 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 2 判断房态"
|
||
' a.房态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 3 控制取电服务"
|
||
' a.控制取电服务 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 4 判断取电状态"
|
||
' a.取电状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 5 判断勿扰状态"
|
||
' a.勿扰状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 6 判断清理状态"
|
||
' a.清理状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 7 判断呼叫状态"
|
||
' a.呼叫状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 8 判断洗衣状态"
|
||
' a.洗衣状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case " 9 判断退房状态"
|
||
' a.退房状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "10 判断稍后状态"
|
||
' a.稍后状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "11 判断SOS状态"
|
||
' a.SOS状态 = CInt(GetNodeSelectStringValue(node))
|
||
' ' Case "12 判断预约待租状态"
|
||
' Case "12 判断送餐状态"
|
||
' a.预约待租状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "13 判断开锁状态"
|
||
' a.开锁状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "14 判断行李状态"
|
||
' a.行李状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "15 判断保险箱状态"
|
||
' a.保险箱状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "16 判断门磁状态"
|
||
' a.门磁状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "17 判断提示音状态"
|
||
' a.提示音状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "18 判断背光状态"
|
||
' a.背光状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "19 判断季节状态"
|
||
' a.季节状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "20 判断时间状态"
|
||
' a.时间状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "21 判断起夜状态"
|
||
' a.起夜状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case "22 判断锁定状态"
|
||
' a.锁定状态 = CInt(GetNodeSelectStringValue(node))
|
||
' Case Else
|
||
' Throw New Exception($"未知条件属性名:{node.Name}")
|
||
' End Select
|
||
'Next
|
||
|
||
'Return a.GetConditionData()
|
||
Dim num As UInt64 = 0
|
||
UInt64.TryParse(u64, num)
|
||
Return BitConverter.GetBytes(num)
|
||
End Function
|
||
|
||
''' <summary>
|
||
''' 从动作行节点获取动作数据
|
||
''' </summary>
|
||
''' <param name="node"></param>
|
||
''' <returns></returns>
|
||
Private Function GetActionDatagather(DeviceModuleDic As Dictionary(Of String, DeviceModel), DevModeName As String, colname As String, DeviceLoop As String, textval As String, tagdic As Dictionary(Of String, String), Optional delaytime As Integer = 0, Optional unit As Integer = 1) As List(Of Byte())
|
||
' If node.RowType <> RowNode.RowTypeEnum.DeviceEventAction Then Throw New Exception($"行号:{node.RowListIndex},文本:{node.Text}不为动作节点")
|
||
If String.IsNullOrEmpty(textval) Then Return Nothing
|
||
Dim li As New List(Of Byte())
|
||
Dim strbuf() As String = textval.Split(vbLf)
|
||
For Each Tnode In strbuf
|
||
|
||
|
||
'执行方式,不同设备类型有不同方式
|
||
Dim bolicActio As List(Of Byte()) = GetSymbolicAction(colname, Tnode, tagdic)
|
||
If IsNothing(bolicActio) OrElse bolicActio.Count = 0 Then Return Nothing
|
||
For Each liindex In bolicActio
|
||
Dim buf(7) As Byte
|
||
'模型的设备类型
|
||
'Console.WriteLine("GetActionDatagather 4053")
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevModeName, colname)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevModeName, colname)
|
||
|
||
'设备类型,外接设备设备类型(主机特殊处理)
|
||
buf(0) = devType
|
||
'设备地址,选择对象的设备拨码地址(主机特殊处理)
|
||
buf(1) = devAddr
|
||
'设备回路,选择对象的回路地址
|
||
|
||
Dim loopBuf() As Byte = BitConverter.GetBytes(CShort(DeviceLoop))
|
||
Array.Copy(loopBuf, 0, buf, 2, loopBuf.Length)
|
||
|
||
Dim par() As String = Tnode.Split(",")
|
||
If par.Length > 1 Then
|
||
Integer.TryParse(par(0), delaytime)
|
||
Integer.TryParse(par(1), unit)
|
||
End If
|
||
|
||
buf(4) = liindex(0) '执行方式 继电器开关
|
||
|
||
'执行内容,不同设备类型有不同内容
|
||
buf(5) = liindex(1) '执行内容
|
||
|
||
'延时时间,动作执行延时
|
||
buf(6) = delaytime '延时时间
|
||
|
||
'延时单位,做东执行延时单位
|
||
buf(7) = unit '延时单位
|
||
|
||
'2022-10-31 Momo 打印动作数据
|
||
' Dim tmpStr As String = BitConverter.ToString(buf).Replace("-", " ")
|
||
' PrintInfo(" [行号:" & node.RowListIndex & "] - " & "> 动作数据:" & tmpStr)
|
||
|
||
li.Add(buf)
|
||
Next
|
||
Next
|
||
Return li
|
||
|
||
|
||
|
||
End Function
|
||
Private Function GetActionData(DeviceModuleDic As Dictionary(Of String, DeviceModel), DevModeName As String, colname As String, DeviceLoop As String, textval As String, Optional delaytime As Integer = 0, Optional unit As Integer = 1) As Byte()
|
||
' If node.RowType <> RowNode.RowTypeEnum.DeviceEventAction Then Throw New Exception($"行号:{node.RowListIndex},文本:{node.Text}不为动作节点")
|
||
If String.IsNullOrEmpty(textval) Then Return Nothing
|
||
Dim bolicActio As List(Of Byte()) = GetSymbolicAction(colname, textval, Nothing)
|
||
If IsNothing(bolicActio) OrElse bolicActio.Count = 0 Then Return Nothing
|
||
|
||
Dim buf(7) As Byte
|
||
'模型的设备类型
|
||
Dim devType As Byte = GetActionDeviceType(DeviceModuleDic, DevModeName, colname)
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = GetActionDeviceAddr(DeviceModuleDic, DevModeName, colname)
|
||
|
||
'设备类型,外接设备设备类型(主机特殊处理)
|
||
buf(0) = devType
|
||
'设备地址,选择对象的设备拨码地址(主机特殊处理)
|
||
buf(1) = devAddr
|
||
'设备回路,选择对象的回路地址
|
||
Dim loopBuf() As Byte = BitConverter.GetBytes(CShort(DeviceLoop))
|
||
Array.Copy(loopBuf, 0, buf, 2, loopBuf.Length)
|
||
|
||
Dim par() As String = textval.Split(",")
|
||
If par.Length > 1 Then
|
||
Integer.TryParse(par(0), delaytime)
|
||
Integer.TryParse(par(1), unit)
|
||
End If
|
||
'执行方式,不同设备类型有不同方式
|
||
|
||
buf(4) = bolicActio(0)(0) '执行方式 继电器开关
|
||
|
||
'执行内容,不同设备类型有不同内容
|
||
buf(5) = bolicActio(0)(1) '执行内容
|
||
|
||
'延时时间,动作执行延时
|
||
buf(6) = delaytime '延时时间
|
||
|
||
'延时单位,做东执行延时单位
|
||
buf(7) = unit '延时单位
|
||
|
||
'2022-10-31 Momo 打印动作数据
|
||
' Dim tmpStr As String = BitConverter.ToString(buf).Replace("-", " ")
|
||
' PrintInfo(" [行号:" & node.RowListIndex & "] - " & "> 动作数据:" & tmpStr)
|
||
|
||
Return buf
|
||
|
||
|
||
|
||
End Function
|
||
Public Function GetSymbolicAction(modetyupe As String, straction As String, defkey As Dictionary(Of String, String)) As List(Of Byte())
|
||
Dim result(1) As Byte
|
||
Dim Tresult(1) As Byte
|
||
Dim li As New List(Of Byte())
|
||
|
||
Dim parstr() As String = straction.Split(",")
|
||
|
||
|
||
Dim parCasre As String = String.Empty
|
||
If IsNothing(parstr) OrElse parstr.Length = 0 Then Return Nothing
|
||
Dim strli As New List(Of String)
|
||
strli.AddRange(parstr)
|
||
If strli.Item(strli.Count - 1).Contains("*") Then
|
||
strli.RemoveAt(strli.Count - 1)
|
||
parstr = strli.ToArray
|
||
End If
|
||
Select Case modetyupe
|
||
Case "RKEY"
|
||
If parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 0 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
End If
|
||
Case "RELAY", "PB_RELAY_DEVICE"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0) '快速设置
|
||
Select Case parCasre
|
||
Case Chr(TableColSwitchKeyDate.TurnOn).ToString
|
||
result(0) = 1
|
||
Case Chr(TableColSwitchKeyDate.TurnDrown).ToString
|
||
result(0) = 2
|
||
'Case Chr(TableColSwitchKeyDate.OnTodrowm).ToString
|
||
' result(0) = 3
|
||
'Case Chr(TableColSwitchKeyDate.drowmToOn).ToString
|
||
' result(0) = 1
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
li.Add(result)
|
||
Case "Dimming"
|
||
Dim strint As Integer = 0
|
||
If Not IsNothing(defkey) Then
|
||
If defkey.ContainsKey("Dimming".ToUpper) Then
|
||
Dim rbuf() As String = defkey.Item("Dimming".ToUpper).Split(" ")
|
||
If Not IsNothing(rbuf) Then
|
||
‘Integer.TryParse(rbuf(0), strint)
|
||
Integer.TryParse(rbuf(0), parstr(2))
|
||
End If
|
||
End If
|
||
End If
|
||
If parstr.Length = 1 Then
|
||
Dim dimmval As Integer = 0
|
||
If straction.Equals(Chr(TableColSwitchKeyDate.TurnOn).ToString) Then
|
||
straction = 80
|
||
ElseIf straction.Equals(Chr(TableColSwitchKeyDate.TurnDrown).ToString) Then
|
||
straction = 0
|
||
End If
|
||
Integer.TryParse(straction, dimmval)
|
||
result(1) = dimmval
|
||
If strint = 0 Then
|
||
If dimmval = 0 Then
|
||
strint = 2
|
||
Else
|
||
strint = 1
|
||
End If
|
||
End If
|
||
result(0) = strint
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
' result(0) = parstr(2)
|
||
If (parstr.Count - 2) > 1 Then
|
||
result(1) = parstr(3)
|
||
'If strint = 0 Then
|
||
' If result(1) = 0 Then
|
||
' strint = 2
|
||
' Else
|
||
' strint = 1
|
||
' End If
|
||
'End If
|
||
result(0) = parstr(2)
|
||
End If
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
|
||
li.Add(result)
|
||
|
||
Case "PB_LINE_CONTROL", "PB_STRIP_DEVICE", "PB_LED_DEVICE"
|
||
Dim strint As Integer = 0
|
||
|
||
|
||
If Not IsNothing(defkey) Then
|
||
If defkey.ContainsKey("Dimming".ToUpper) Then
|
||
Dim rbuf() As String = defkey.Item("Dimming".ToUpper).Split(" ")
|
||
If Not IsNothing(rbuf) Then
|
||
Integer.TryParse(rbuf(0), strint)
|
||
End If
|
||
End If
|
||
|
||
Select Case strint
|
||
Case 7
|
||
strint = 30 '主机未支持 2024.5.31
|
||
Case 8
|
||
strint = 31 '主机未支持 2024.5.31
|
||
Case 9
|
||
strint = 8
|
||
Case 10
|
||
strint = 28
|
||
Case 11
|
||
strint = 29
|
||
Case 26
|
||
strint = 26
|
||
Case 27
|
||
strint = 27
|
||
Case 28
|
||
strint = 32
|
||
Case 29
|
||
strint = 33
|
||
Case Else
|
||
strint = 0
|
||
End Select
|
||
|
||
'If defkey.ContainsKey("PB_LINE_CONTROL".ToUpper) Then
|
||
' Dim rbuf() As String = defkey.Item("PB_LINE_CONTROL".ToUpper).Split(" ")
|
||
' If Not IsNothing(rbuf) Then
|
||
' Integer.TryParse(rbuf(0), strint)
|
||
' End If
|
||
'End If
|
||
'If defkey.ContainsKey("PB_STRIP_DEVICE".ToUpper) Then
|
||
' Dim rbuf() As String = defkey.Item("PB_STRIP_DEVICE".ToUpper).Split(" ")
|
||
' If Not IsNothing(rbuf) Then
|
||
' Integer.TryParse(rbuf(0), strint)
|
||
' End If
|
||
'End If
|
||
End If
|
||
|
||
|
||
|
||
If parstr.Length = 1 Then
|
||
Dim dimmval As Integer = 0
|
||
If straction.Equals(Chr(TableColSwitchKeyDate.TurnOn).ToString) Then
|
||
result(1) = 1
|
||
result(0) = 17
|
||
ElseIf straction.Equals(Chr(TableColSwitchKeyDate.TurnDrown).ToString) Then
|
||
result(1) = 2
|
||
result(0) = 17
|
||
Else
|
||
Integer.TryParse(straction, dimmval)
|
||
result(1) = dimmval
|
||
'If strint = 0 Then
|
||
' If dimmval = 0 Then
|
||
' strint = 2
|
||
' Else
|
||
' strint = 1
|
||
' End If
|
||
'End If
|
||
result(0) = 18
|
||
End If
|
||
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
' result(0) = parstr(2)
|
||
If (parstr.Count - 2) > 1 Then
|
||
result(1) = parstr(3)
|
||
'If strint = -1 Then
|
||
' If result(1) = 0 Then
|
||
' strint = 2
|
||
' Else
|
||
' strint = 1
|
||
' End If
|
||
'End If
|
||
result(0) = parstr(2)
|
||
End If
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
|
||
li.Add(result)
|
||
|
||
Case "DO", "LIGHT"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "open"
|
||
result(0) = 1
|
||
Case "close"
|
||
result(0) = 2
|
||
Case "flash"
|
||
result(0) = 14
|
||
Case "Corresponding scenario"
|
||
result(0) = 3
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
ElseIf parstr.Length > 2 Then
|
||
result(0) = parstr(2)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
|
||
li.Add(result)
|
||
Case "Temp"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0) '快速设置
|
||
Select Case parCasre
|
||
Case "Open 26 degrees"
|
||
Dim sw As Integer = 1 '开关状态
|
||
Dim mode As Integer = 0 '模式
|
||
Dim speed As Integer = 2 '风速
|
||
Dim fm As Integer = 1 '阀门
|
||
Dim temp As Integer = 26 '温度
|
||
result(1) = fm
|
||
result(1) = result(1) Or (speed << 2)
|
||
result(1) = result(1) Or (mode << 4)
|
||
result(1) = result(1) Or (sw << 6)
|
||
|
||
result(0) = temp
|
||
Case "close"
|
||
Dim sw As Integer = 2 '开关状态
|
||
Dim mode As Integer = 0 '模式
|
||
Dim speed As Integer = 2 '风速
|
||
Dim fm As Integer = 1 '阀门
|
||
Dim temp As Integer = 26 '温度
|
||
result(1) = fm
|
||
result(1) = result(1) Or (speed << 2)
|
||
result(1) = result(1) Or (mode << 4)
|
||
result(1) = result(1) Or (sw << 6)
|
||
|
||
result(0) = temp
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
|
||
ElseIf parstr.Length > 6 Then '高级设置
|
||
Dim sw As Integer = CInt(parstr(2)) '开关状态
|
||
Dim mode As Integer = CInt(parstr(3)) '模式
|
||
Dim speed As Integer = CInt(parstr(4)) '风速
|
||
Dim fm As Integer = CInt(parstr(5)) '阀门
|
||
Dim temp As Integer = CInt(parstr(6)) '温度
|
||
result(1) = fm
|
||
result(1) = result(1) Or (speed << 2)
|
||
result(1) = result(1) Or (mode << 4)
|
||
result(1) = result(1) Or (sw << 6)
|
||
|
||
result(0) = temp
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
li.Add(result)
|
||
Case "CURTAIN", "DRY_CURTAIN"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "open"
|
||
result(0) = 1
|
||
Case "close"
|
||
result(0) = 2
|
||
Case "stop"
|
||
result(0) = 6
|
||
Case "intertangent"
|
||
result(0) = 4
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
ElseIf parstr.Length > 2 Then
|
||
result(0) = parstr(2)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
|
||
li.Add(result)
|
||
Case "RS485_Curtain"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "open"
|
||
result(0) = 1
|
||
Case "close"
|
||
result(0) = 2
|
||
Case "stop"
|
||
result(0) = 6
|
||
Case "intertangent"
|
||
result(0) = 4
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
ElseIf parstr.Length > 2 Then
|
||
parCasre = parstr(2)
|
||
Else
|
||
parCasre = String.Empty
|
||
End If
|
||
|
||
li.Add(result)
|
||
Case "HOSTSERVICE"
|
||
Dim sw As Integer '开关状态
|
||
sw = CInt(straction)
|
||
result(0) = sw
|
||
li.Add(result)
|
||
Case "MUSIC"
|
||
|
||
'If Not IsNothing(defkey) Then
|
||
' If defkey.ContainsKey("MUSIC".ToUpper) Then
|
||
' Dim rbuf() As String = defkey.Item("Dimming".ToUpper).Split(" ")
|
||
' If Not IsNothing(rbuf) Then
|
||
' Integer.TryParse(rbuf(0), strint)
|
||
' End If
|
||
' End If
|
||
'End If
|
||
|
||
|
||
|
||
Dim dirIndex As Integer = 0 'node.Params(0).ValueData '文件夹索引
|
||
Dim modeStatus As Integer = 0 'node.Params(1).ValueData '播放时场景状态
|
||
Dim fileIndex As Integer = 0 'node.Params(2).ValueData '文件索引
|
||
If straction.Contains("Play prompt sound") AndAlso (straction.Contains("5 Volume +") OrElse straction.Contains("6 Volume -")) Then
|
||
parstr(4) = parstr(3)
|
||
parstr(3) = parstr(2)
|
||
parstr(2) = 0
|
||
End If
|
||
If straction.Contains("Play music") AndAlso (straction.Contains("1 play") OrElse straction.Contains("2 stop")) Then
|
||
parstr(4) = 0
|
||
End If
|
||
|
||
|
||
Select Case parstr.Count - 3 '延时和延时单位占了数组两个元素
|
||
Case 1
|
||
dirIndex = parstr(2)
|
||
Case 2
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
Case 3
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
fileIndex = parstr(4) '文件索引
|
||
Case > 3
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
fileIndex = parstr(4) '文件索引
|
||
Case Else
|
||
|
||
End Select
|
||
'2022-05-06 Caocong: 先将变量初始化为0.有可能没有三个参数 ---end
|
||
result(0) = result(0) Or (dirIndex << 0)
|
||
result(0) = result(0) Or (modeStatus << 4)
|
||
result(1) = fileIndex
|
||
li.Add(result)
|
||
|
||
Case "CLED_FRESHAIR"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "open"
|
||
Tresult(0) = 1
|
||
Tresult(1) = 2
|
||
li.Add(Tresult)
|
||
Case "close"
|
||
result(0) = 0
|
||
result(1) = 0
|
||
li.Add(result)
|
||
End Select
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "CLEDFLOORHEAT"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "Open 26 degrees"
|
||
Tresult(0) = 1
|
||
Tresult(1) = 26
|
||
li.Add(Tresult)
|
||
Case "close"
|
||
result(0) = 1
|
||
result(1) = 0
|
||
li.Add(result)
|
||
End Select
|
||
|
||
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "485FreshAir"
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "open"
|
||
Tresult(0) = 1
|
||
Tresult(1) = 1
|
||
li.Add(Tresult)
|
||
result(0) = 4
|
||
result(1) = 2
|
||
li.Add(result)
|
||
Case "close"
|
||
result(0) = 1
|
||
result(1) = 0
|
||
li.Add(result)
|
||
End Select
|
||
|
||
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "485FloorHeat" '地暖
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "Open 26 degrees"
|
||
Tresult(0) = 1
|
||
Tresult(1) = 1
|
||
li.Add(Tresult)
|
||
result(0) = 3
|
||
result(1) = 26
|
||
li.Add(result)
|
||
Case "close"
|
||
result(0) = 1
|
||
result(1) = 0
|
||
li.Add(result)
|
||
End Select
|
||
|
||
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "INFRARED_FORWARD"
|
||
|
||
If parstr.Length = 1 Then
|
||
parCasre = parstr(0)
|
||
Select Case parCasre
|
||
Case "Turn on the TV"
|
||
result(0) = 1
|
||
result(1) = 18
|
||
Case "Turn off the TV"
|
||
result(0) = 2
|
||
result(1) = 1
|
||
|
||
Case "Mute"
|
||
result(0) = 1
|
||
result(1) = 1
|
||
Case "volume+"
|
||
result(0) = 1
|
||
result(1) = 3
|
||
Case "volume-"
|
||
result(0) = 1
|
||
result(1) = 4
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
li.Add(result)
|
||
|
||
ElseIf parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
|
||
Case "DRY_NoCard"
|
||
If parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "Dev_ColorTemp"
|
||
If parstr.Length > 2 Then '高级设置
|
||
result(0) = parstr(2)
|
||
If (parstr.Count - 3) > 1 Then result(1) = parstr(3)
|
||
li.Add(result)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
Case "HOPO_Curtain"
|
||
If parstr.Length = 4 Then
|
||
result(0) = parstr(2)
|
||
ElseIf parstr.Length > 4 Then
|
||
result(0) = parstr(2)
|
||
result(1) = parstr(3)
|
||
Else
|
||
Return Nothing
|
||
End If
|
||
li.Add(result)
|
||
Case "BLEMUSIC"
|
||
Dim dirIndex As Integer = 0 'node.Params(0).ValueData '文件夹索引
|
||
Dim modeStatus As Integer = 0 'node.Params(1).ValueData '播放时场景状态
|
||
Dim fileIndex As Integer = 0 'node.Params(2).ValueData '文件索引
|
||
Select Case parstr.Count - 3 '延时和延时单位占了数组两个元素
|
||
Case 1
|
||
dirIndex = parstr(2)
|
||
result(0) = dirIndex
|
||
result(1) = modeStatus
|
||
Case 2
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
result(0) = dirIndex
|
||
result(1) = modeStatus
|
||
Case >= 3
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
fileIndex = parstr(4) '文件索引
|
||
result(0) = result(0) Or (dirIndex << 0)
|
||
result(0) = result(0) Or (modeStatus << 4)
|
||
result(1) = fileIndex
|
||
Case Else
|
||
|
||
End Select
|
||
'2022-05-06 Caocong: 先将变量初始化为0.有可能没有三个参数 ---end
|
||
|
||
|
||
li.Add(result)
|
||
Case "Carbon_Device", "Scene_Restore"
|
||
Dim dirIndex As Integer = 0 'node.Params(0).ValueData '文件夹索引
|
||
Dim modeStatus As Integer = 0 'node.Params(1).ValueData '播放时场景状态
|
||
Dim fileIndex As Integer = 0 'node.Params(2).ValueData '文件索引
|
||
Select Case parstr.Count - 3 '延时和延时单位占了数组两个元素
|
||
Case 1
|
||
dirIndex = parstr(2)
|
||
result(0) = dirIndex
|
||
result(1) = modeStatus
|
||
Case 2
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
result(0) = dirIndex
|
||
result(1) = modeStatus
|
||
Case >= 3
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
fileIndex = parstr(4) '文件索引
|
||
result(0) = dirIndex
|
||
result(1) = result(1) Or (fileIndex << 0)
|
||
result(1) = result(1) Or (modeStatus << 4)
|
||
|
||
Case Else
|
||
|
||
End Select
|
||
li.Add(result)
|
||
Case "485MUSIC"
|
||
|
||
|
||
Dim dirIndex As Integer = 0 'node.Params(0).ValueData '文件夹索引
|
||
Dim modeStatus As Integer = 0 'node.Params(1).ValueData '播放时场景状态
|
||
Dim fileIndex As Integer = 0 'node.Params(2).ValueData '文件索引
|
||
Select Case parstr.Count - 3 '延时和延时单位占了数组两个元素
|
||
Case 1
|
||
dirIndex = parstr(2)
|
||
Case 2
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
Case >= 3
|
||
dirIndex = parstr(2) '文件夹索引
|
||
modeStatus = parstr(3) '播放时场景状态
|
||
fileIndex = parstr(4) '文件索引
|
||
Case Else
|
||
|
||
End Select
|
||
'2022-05-06 Caocong: 先将变量初始化为0.有可能没有三个参数 ---end
|
||
result(0) = result(0) Or (dirIndex << 0)
|
||
result(0) = result(0) Or (modeStatus << 4)
|
||
result(1) = fileIndex
|
||
li.Add(result)
|
||
Case Else
|
||
Return Nothing
|
||
End Select
|
||
|
||
Return li
|
||
End Function
|
||
|
||
|
||
|
||
|
||
Private Function GetExecModeDataUnderCondtion(straction As String) As Byte
|
||
|
||
Dim result As Integer = 1
|
||
Integer.TryParse(straction, result)
|
||
Return result
|
||
End Function
|
||
|
||
Public Function GetdevGroupHread(devMode As DeviceModel, Addrstr As String) As Byte()
|
||
Dim buf = New List(Of Byte)
|
||
'命令参数
|
||
Dim cmd As Byte = &H4
|
||
Dim devType As Byte
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte = Addrstr
|
||
Dim DevGroupName = $"DI"
|
||
For Each cnode In devMode.Nodes
|
||
If cnode.Name.Equals(DevGroupName) Then
|
||
devType = cnode.DEV_TYPE_DATA
|
||
End If
|
||
Next
|
||
buf.Add(cmd) '命令参数
|
||
|
||
buf.Add(devType) '设备类型
|
||
|
||
buf.Add(devAddr) '设备地址
|
||
|
||
Return buf.ToArray
|
||
End Function
|
||
Public Function GetActionGroupHread(devMode As DeviceModel) As Byte()
|
||
Dim buf = New List(Of Byte)
|
||
'命令参数
|
||
Dim cmd As Byte = &H4
|
||
Dim devType As Byte
|
||
'模型的拨码地址
|
||
Dim devAddr As Byte
|
||
Dim DevGroupName = $"DI设备组信息"
|
||
'模型的设备类型
|
||
For Each cnode In devMode.Config
|
||
If cnode.Name.Equals(DevGroupName) Then
|
||
For Each node In cnode.Attributes
|
||
Select Case node.Name
|
||
Case "DeviceType"
|
||
devType = node.DataDefault
|
||
Case "DeviceAddr"
|
||
devAddr = node.DataDefault
|
||
Case Else
|
||
Continue For
|
||
End Select
|
||
Next
|
||
End If
|
||
Next
|
||
buf.Add(cmd) '命令参数
|
||
|
||
buf.Add(devType) '设备类型
|
||
|
||
buf.Add(devAddr) '设备地址
|
||
|
||
Return buf.ToArray
|
||
End Function
|
||
'' <summary>
|
||
'' 填充设备存在
|
||
'' </summary>
|
||
'' <returns></returns>
|
||
Public Voicement As List(Of DeviceModel)
|
||
Public devTempment As List(Of DeviceModel)
|
||
Public devRKEY As List(Of DeviceModel)
|
||
Public Function FillDeviceExistsData(ByRef DeviceModuleDic As Dictionary(Of String, DeviceModel)) As List(Of Byte())
|
||
Dim resultDatas As New List(Of Byte())
|
||
Dim cmd As Byte = &H3
|
||
Dim buf As List(Of Byte)
|
||
Dim devmovement As New List(Of DeviceModel)
|
||
Dim Heat485ment As New List(Of DeviceModel)
|
||
Dim Air485ment As New List(Of DeviceModel)
|
||
Dim AirDRYNoCard As New List(Of DeviceModel)
|
||
Dim Dev_ColorTemp As New List(Of DeviceModel)
|
||
Dim Dev_BLEMUSIC As New List(Of DeviceModel)
|
||
Dim VirtualCard As New List(Of DeviceModel)
|
||
Voicement = New List(Of DeviceModel)
|
||
devTempment = New List(Of DeviceModel)
|
||
devRKEY = New List(Of DeviceModel)
|
||
For Each Fnode In DeviceModuleDic.Values
|
||
|
||
' 配置RCU模型设备存在数据
|
||
If String.IsNullOrEmpty(Fnode.Desc.DevInterface) Then
|
||
buf = New List(Of Byte)
|
||
buf.Add(cmd)
|
||
Dim tmpBuffer() As Byte = FillRCUModelDeviceExsist(Fnode)
|
||
buf.AddRange(tmpBuffer)
|
||
resultDatas.Add(buf.ToArray)
|
||
'PrintInfo(" 主机模型 编译完成,长度:" & tmpBuffer.Count & " Bytes")
|
||
Else
|
||
Dim tmpBufferLst As List(Of Byte()) = FillExternalModelDeviceExsist(Fnode, DeviceModuleDic.Values(0))
|
||
Dim tmpOutData As Byte()
|
||
For i = 0 To tmpBufferLst.Count - 1
|
||
tmpOutData = tmpBufferLst(i).ToArray
|
||
resultDatas.Add(tmpOutData.ToArray)
|
||
Next
|
||
End If
|
||
|
||
For Each Ccnode In Fnode.Config
|
||
If Not IsNothing(Ccnode.CFG_Type) AndAlso Ccnode.CFG_Type.Equals("DeviceExists") Then
|
||
buf = New List(Of Byte)
|
||
Console.WriteLine(Ccnode.Name)
|
||
buf.Add(cmd)
|
||
Dim tmpBuffer() As Byte = FillModeDeviceExsist(Ccnode, Fnode)
|
||
buf.AddRange(tmpBuffer)
|
||
resultDatas.Add(buf.ToArray)
|
||
'PrintInfo(" 设备存在 编译完成,长度:" & tmpBuffer.Count & " Bytes")
|
||
End If
|
||
Next
|
||
|
||
For Each Ccnode In Fnode.Nodes
|
||
Select Case Ccnode.Name
|
||
Case "RKEY"
|
||
If Ccnode.Interface.Equals("DO") Then
|
||
devRKEY.Add(Fnode)
|
||
End If
|
||
Case "BLEMUSIC"
|
||
Dev_BLEMUSIC.Add(Fnode)
|
||
Case "Dev_ColorTemp"
|
||
Dev_ColorTemp.Add(Fnode)
|
||
Case "DRY_NoCard"
|
||
AirDRYNoCard.Add(Fnode)
|
||
Case "Temp"
|
||
devTempment.Add(Fnode)
|
||
Case "CURTAIN"
|
||
devmovement.Add(Fnode)
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
Air485ment.Add(Fnode)
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
Heat485ment.Add(Fnode)
|
||
Case "语音"
|
||
Voicement.Add(Fnode)
|
||
Case "Virtual_Card"
|
||
VirtualCard.Add(Fnode)
|
||
Case Else
|
||
|
||
End Select
|
||
Next
|
||
|
||
Next
|
||
Dim T_SceneID As Integer = _SceneID
|
||
Dim result As List(Of Byte())
|
||
For Each node In devmovement
|
||
result = CURTAINFillDeviceObject(T_SceneID, DeviceModuleDic, node.Name, "CURTAIN")
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
For Each node In AirDRYNoCard
|
||
result = DRY_NoCardFillDeviceObject(T_SceneID, DeviceModuleDic, node.Name, "DRY_NoCard")
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
For Each node In Dev_ColorTemp
|
||
result = Dev_ColorTempFillDeviceObject(T_SceneID, DeviceModuleDic, node.Name, "Dev_ColorTemp")
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
For Each node In VirtualCard
|
||
result = Virtual_CardFillDeviceObject(T_SceneID, DeviceModuleDic, node.Name, "Virtual_Card")
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
For Each node In devTempment
|
||
result = TempDeviceObject(T_SceneID, DeviceModuleDic, node.Name, "Temp")
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
For Each node In Heat485ment
|
||
|
||
For Each tname In node.Nodes
|
||
Select Case tname.Name
|
||
Case "485FloorHeat", "CLEDFLOORHEAT"
|
||
result = Rs485DeviceObject(1, T_SceneID, DeviceModuleDic, node.Name, tname.Name)
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
|
||
End Select
|
||
Next
|
||
|
||
|
||
Next
|
||
For Each node In Air485ment
|
||
|
||
For Each tname In node.Nodes
|
||
Select Case tname.Name
|
||
Case "485FreshAir", "CLED_FRESHAIR"
|
||
result = Rs485DeviceObject(2, T_SceneID, DeviceModuleDic, node.Name, tname.Name)
|
||
If IsNothing(result) Then Continue For
|
||
resultDatas.AddRange(result.ToArray)
|
||
|
||
End Select
|
||
Next
|
||
|
||
Next
|
||
|
||
Return resultDatas
|
||
End Function
|
||
|
||
Public Function VoicementDeviceObject() As List(Of Byte())
|
||
Dim cmd As Byte = &H5
|
||
Dim lst As New List(Of Byte())
|
||
For Each node In Voicement
|
||
For Each Cnode In node.Config
|
||
If Cnode.CFG_Type.Equals("XiaoBaoCMD") Then
|
||
For Each cTnode In Cnode.Attributes
|
||
'Console.WriteLine($"cTnode.DataRangeValue:{cTnode.DataRangeValue}")
|
||
If Not String.IsNullOrEmpty(cTnode.DataRangeValue) Then
|
||
Dim Data = New List(Of Byte)
|
||
Data.Add(cmd)
|
||
Data.Add(CInt(Cnode.CFG_Value))
|
||
Data.Add(CInt(cTnode.DataDefault))
|
||
|
||
Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
|
||
If buf.Length = 2 Then
|
||
Dim devType As Byte = 0
|
||
Dim devAddr As Byte = 0
|
||
Data.Add(devType)
|
||
Data.Add(devAddr)
|
||
Data.AddRange(BitConverter.GetBytes(CShort(buf(0))))
|
||
lst.Add(Data.ToArray)
|
||
ElseIf buf.Length = 3 Then
|
||
If cTnode.DataRangeValue.Contains("HOSTSERVICE") Then
|
||
Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(1))
|
||
Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(1))
|
||
Data.Add(devType)
|
||
Data.Add(devAddr)
|
||
Data.AddRange(BitConverter.GetBytes(CShort(buf(2))))
|
||
lst.Add(Data.ToArray)
|
||
Else
|
||
Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
Data.Add(devType)
|
||
Data.Add(devAddr)
|
||
Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
lst.Add(Data.ToArray)
|
||
End If
|
||
|
||
End If
|
||
|
||
|
||
'Select Case Cnode.Name
|
||
' Case "0 场景"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
|
||
' Dim devType As Byte = 0
|
||
' Dim devAddr As Byte = 0
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(0))))
|
||
|
||
' Case "1 继电器"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "4 服务信息"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(1))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(1))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(2))))
|
||
' Case "5 窗帘"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "7 空调"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), "Temp")
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), "Temp")
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "15 电视"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "16 调光"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "18 灯带"
|
||
' Dim buf As String() = cTnode.DataRangeValue.Split("*")
|
||
' Dim devType As Byte = GetActionDeviceType(Dic_Devicemodel, buf(0), buf(2))
|
||
' Dim devAddr As Byte = GetActionDeviceAddr(Dic_Devicemodel, buf(0), buf(2))
|
||
' Data.Add(devType)
|
||
' Data.Add(devAddr)
|
||
' Data.AddRange(BitConverter.GetBytes(CShort(buf(1))))
|
||
' Case "21 音乐"
|
||
'End Select
|
||
|
||
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
|
||
|
||
|
||
'result = Rs485DeviceObject(2, T_SceneID, DeviceModuleDic, node.Name, node.Nodes(0).Name)
|
||
'If IsNothing(result) Then Continue For
|
||
'resultDatas.AddRange(result.ToArray)
|
||
Next
|
||
Return lst
|
||
End Function
|
||
|
||
''' <summary>
|
||
''' 根据RCU模型的设备存在属性组,配置设备存在数据
|
||
''' </summary>
|
||
''' <param name="pNode">模型节点</param>
|
||
''' <returns></returns>
|
||
Private Function FillModeDeviceExsist(Ccnode As DeviceModelConfigGroup, pNode As DeviceModel) As Byte()
|
||
'If pNode.RowType <> RowNode.RowTypeEnum.ModelAttributes_DeviceExists Then Throw New Exception($"行号:{pNode.RowListIndex} 不为设备存在模型属性类型")
|
||
|
||
Dim buf As New List(Of Byte)
|
||
Dim Cbuf(10) As Byte
|
||
For Each node In Ccnode.Attributes
|
||
|
||
Select Case node.Name
|
||
Case "DeviceType"
|
||
Cbuf(0) = node.DataDefault
|
||
Case "DeviceAddr"
|
||
Cbuf(1) = node.DataDefault
|
||
Case "DevicePort"
|
||
Cbuf(2) = node.DataRangeValue
|
||
Case "DeviceBaud"
|
||
Dim baudData() As Byte = BitConverter.GetBytes(CInt(node.DataDefault))
|
||
Cbuf(3) = baudData(0)
|
||
Cbuf(4) = baudData(1)
|
||
Cbuf(5) = baudData(2)
|
||
Cbuf(6) = baudData(3)
|
||
Case "DeviceVer"
|
||
Cbuf(7) = node.DataDefault
|
||
Case "DeviceRetryNum"
|
||
Cbuf(8) = node.DataDefault
|
||
Case "DeviceRetryTime"
|
||
Dim retryTimeData() As Byte = BitConverter.GetBytes(CShort(node.DataDefault))
|
||
Cbuf(9) = retryTimeData(0)
|
||
Cbuf(10) = retryTimeData(1)
|
||
Case Else
|
||
Continue For
|
||
End Select
|
||
|
||
Next
|
||
|
||
|
||
|
||
buf.AddRange(Cbuf)
|
||
Dim keepParam(63) As Byte '保留字段(32字节) -> 2022-05-28 V3.1 32bytes->64Bytes
|
||
buf.AddRange(keepParam)
|
||
|
||
Dim index As Integer = Ccnode.Name.IndexOf("device group information")
|
||
Dim type As String = Ccnode.Name.Substring(0, index - 1)
|
||
Dim inputCount, outputCount As UShort
|
||
Dim inputSettings As New List(Of Byte)
|
||
Dim outputAliases As New List(Of Byte)
|
||
Dim inputGroupNode As DeviceChildNodeClass = Nothing
|
||
Dim outputGroupNode As DeviceChildNodeClass = Nothing
|
||
|
||
Select Case type.Trim '
|
||
Case "DI"
|
||
inputGroupNode = FindModelDeviceGroupUnderModel(pNode, "DI")
|
||
Case Else
|
||
outputGroupNode = FindModelDeviceGroupUnderModel(pNode, type)
|
||
End Select
|
||
|
||
If inputGroupNode Is Nothing Then
|
||
inputCount = 0
|
||
Else
|
||
For Each node In inputGroupNode.Nodes
|
||
'If node.RowType <> RowNode.RowTypeEnum.DeviceObject Then Continue For
|
||
'If node.Compile = False Then Continue For
|
||
inputCount += 1
|
||
inputSettings.AddRange(GetDeviceObjectSetting(pNode.Name, node.DefaultClass))
|
||
Next
|
||
End If
|
||
|
||
If outputGroupNode Is Nothing Then
|
||
outputCount = 0
|
||
Else
|
||
For Each node In outputGroupNode.Nodes
|
||
'If node.RowType <> RowNode.RowTypeEnum.DeviceObject Then Continue For
|
||
'If node.Compile = False Then Continue For
|
||
outputCount += 1
|
||
Dim aliasData() As Byte
|
||
'Momo 2022-05-03 增加DeviceAlias非空判断,避免报错
|
||
If String.IsNullOrEmpty(node.Name) = False Then
|
||
aliasData = AliasEncoding.GetBytes(node.Name)
|
||
End If
|
||
ReDim Preserve aliasData(31) 'caocong 2022-06-07 修改别名长度16Byte -> 32Byte
|
||
outputAliases.AddRange(aliasData)
|
||
Console.WriteLine($"{node.DefaultAliasName}{vbCrLf}")
|
||
Next
|
||
Console.WriteLine($"{outputGroupNode.Name}:{outputGroupNode.Nodes.Count }:{outputAliases.Count }{vbCrLf}")
|
||
End If
|
||
|
||
buf.AddRange(BitConverter.GetBytes(inputCount)) '输入回路数(2字节)
|
||
buf.AddRange(BitConverter.GetBytes(outputCount)) '输出回路数(2字节)
|
||
buf.AddRange(inputSettings.ToArray) '所有输入回路设置(n*4字节)
|
||
buf.AddRange(outputAliases.ToArray) '所有输出回路别名(n*16字节)
|
||
|
||
|
||
Return buf.ToArray
|
||
End Function
|
||
Private Function FindModelDeviceGroupUnderModel(pNode As DeviceModel, name As String) As DeviceChildNodeClass
|
||
Dim resultNode As DeviceChildNodeClass = Nothing
|
||
''2022-05-14 2.0.2.0 版本以前:匹配节点名称与“DI”‘DO’字符串,来确定是否返回端点
|
||
''外设有继电器时,继电器名称为“Relay”,Interface为“DO”,此方法会范围“0”
|
||
For Each node In pNode.Nodes
|
||
'If node.RowType <> RowNode.RowTypeEnum.DeviceGroup Then Continue For
|
||
If String.Compare(node.Name, name, True) <> 0 Then Continue For
|
||
resultNode = node
|
||
Exit For
|
||
Next
|
||
|
||
Return resultNode
|
||
End Function
|
||
Private Function FindAttributeUnderModel(pNode As DeviceModel, groupName As String, attributeName As String) As Boolean
|
||
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 True
|
||
End If
|
||
Next
|
||
End If
|
||
Next
|
||
Return False
|
||
End Function
|
||
Private Function FillExternalModelDeviceExsist(pNode As DeviceModel, hostNode As DeviceModel) As List(Of Byte())
|
||
Dim outDataLst As New List(Of Byte()) '输出数据列表
|
||
Dim strObjGroupNodesTypedataAndProtocol As String = ""
|
||
|
||
Dim baudData(3) As Byte '波特率(4字节)
|
||
Dim retryTimeData(1) As Byte '重发次数(2字节)
|
||
Dim keepParam(59) As Byte '保留字段(32字节) -> 2022-05-28 V3.1 32bytes->64Bytes
|
||
Dim ipadd(3) As Byte
|
||
Dim ObjGroupNodesInOutDic As New Dictionary(Of String, List(Of Byte)) '键值对,用于保存合并后的数据,Val = 设备组编译后的byte数组
|
||
Dim ObjGroupNodesInputCnt As New Dictionary(Of String, UInt16) '键值对,用于保存合并后的输入回路数,Val = 设备组编译后的byte数组
|
||
Dim ObjGroupNodesoutputCnt As New Dictionary(Of String, UInt16) '键值对,用于保存合并后的输出回路数,Val = 设备组编译后的byte数组
|
||
|
||
Dim ObjGroupNodesInpuSettings As New Dictionary(Of String, List(Of Byte)) '用于保存合并后输入设定数组
|
||
Dim ObjGroupNodesOutputAliases As New Dictionary(Of String, List(Of Byte)) '用于保存合并后输出别名数组
|
||
|
||
'添加设备组公共信息
|
||
Dim Baudrate() As String = FindAttributeValueUnderModel(pNode, “Device present”, "Baud rate").Split(" ")
|
||
baudData = BitConverter.GetBytes(CInt(Baudrate(1)))
|
||
retryTimeData = BitConverter.GetBytes(CShort(FindAttributeValueUnderModel(pNode, “Device present”, "Resend time")))
|
||
Dim tmpAddr As Byte = CInt(FindAttributeValueUnderModel2(pNode, “Device present”, "Dialing address")) '设备地址(1字节)
|
||
Dim hostAddr As Byte = CInt(FindNodeValueUnderModel(hostNode, "RS485", pNode.Desc.DevInterface)) '设备地址(1字节)
|
||
Dim TemptDevType As Byte = 0
|
||
Dim ParentDevType As Byte = 0
|
||
Dim ParentDevAddr As Byte = 0
|
||
Dim ParentDevPort As Byte = 0
|
||
Dim bytes(9) As Byte
|
||
Dim node As Boolean = FindAttributeUnderModel(pNode, "Device present", "BleName")
|
||
If node Then
|
||
Dim nodestr = FindAttributeValueUnderModel2(pNode, "Device present", "BleName") '父设备美型(1字节)
|
||
bytes = System.Text.Encoding.UTF8.GetBytes(nodestr)
|
||
Array.Copy(bytes, 0, keepParam, 8, bytes.Length)
|
||
TemptDevType = bytes(0)
|
||
End If
|
||
node = FindAttributeUnderModel(pNode, “Device present”, "Parent device type")
|
||
If node Then
|
||
ParentDevType = CInt(FindAttributeValueUnderModel(pNode, “Device present”, "Parent device type")) '父设备美型(1字节)
|
||
End If
|
||
|
||
node = FindAttributeUnderModel(pNode, “Device present”, "Parent device address")
|
||
If node Then
|
||
ParentDevAddr = CInt(FindAttributeValueUnderModel(pNode, “Device present”, "Parent device address")) '父设备美型(1字节)
|
||
End If
|
||
|
||
node = FindAttributeUnderModel(pNode, “Device present”, "Parent device port")
|
||
If node Then
|
||
Dim BaudDevPort() As String = FindAttributeValueUnderModel(pNode, “Device present”, "Parent device port").Split(" ")
|
||
ParentDevPort = CInt(BaudDevPort(0)) '父设备美型(1字节)
|
||
End If
|
||
node = FindAttributeUnderModel(pNode, "Device present", "Valveless machine")
|
||
If node Then
|
||
Dim BaudDevPort() As String = FindAttributeValueUnderModel(pNode, "Device present", "Valveless machine").Split(" ")
|
||
TemptDevType = CInt(BaudDevPort(0)) '父设备美型(1字节)
|
||
End If
|
||
keepParam(0) = ParentDevType
|
||
keepParam(1) = ParentDevAddr
|
||
keepParam(2) = ParentDevPort
|
||
keepParam(8) = TemptDevType
|
||
For indexi = 1 To 5
|
||
node = FindAttributeUnderModel(pNode, "设备存在", $"弱电输入{indexi}")
|
||
If node Then
|
||
Dim BaudDevPort() As String = FindAttributeValueUnderModel(pNode, "设备存在", $"弱电输入{indexi}").Split(" ")
|
||
ParentDevPort = CInt(BaudDevPort(0)) '父设备美型(1字节)
|
||
keepParam(2 + indexi) = ParentDevPort
|
||
End If
|
||
Next
|
||
If Not IsNothing(pNode.Desc.DevTypeData) AndAlso pNode.Desc.DevTypeData.Equals("55") Then
|
||
Dim tabledev As CtabRange = GetRowDevNametabRange(pNode.Name, TableRowNumber.DeviceName)
|
||
If Not IsNothing(tabledev) Then
|
||
Dim txtbuf() As String
|
||
Dim txt As String
|
||
Dim txtbyte() As Byte
|
||
For indexi = tabledev.fr To tabledev.lr
|
||
txtbuf = _grd.Cell(indexi, TableColNumber.SceneAttribute).Text.Split(",")
|
||
txt = _grd.Cell(indexi, TableColNumber.SceneID).Text
|
||
txtbyte = BitConverter.GetBytes(CShort(txt))
|
||
If txtbuf(0).Equals("1") Then
|
||
Array.Copy(txtbyte, 0, keepParam, 8, txtbyte.Length)
|
||
ElseIf txtbuf(0).Equals("2") Then
|
||
Array.Copy(txtbyte, 0, keepParam, 10, txtbyte.Length)
|
||
End If
|
||
Next
|
||
|
||
|
||
End If
|
||
End If
|
||
|
||
|
||
|
||
|
||
|
||
For Each cnode In pNode.Nodes
|
||
strObjGroupNodesTypedataAndProtocol = cnode.DEV_TYPE_DATA & "," & cnode.PROTOCOL_VER
|
||
If ObjGroupNodesInOutDic.ContainsKey(strObjGroupNodesTypedataAndProtocol) = False Then
|
||
'添加输出合并设备键值对’
|
||
ObjGroupNodesInOutDic.Add(strObjGroupNodesTypedataAndProtocol, New List(Of Byte))
|
||
ObjGroupNodesInputCnt.Add(strObjGroupNodesTypedataAndProtocol, 0) '输入回路数 = 0
|
||
ObjGroupNodesoutputCnt.Add(strObjGroupNodesTypedataAndProtocol, 0) '输出回路数 = 0
|
||
ObjGroupNodesInpuSettings.Add(strObjGroupNodesTypedataAndProtocol, New List(Of Byte))
|
||
ObjGroupNodesOutputAliases.Add(strObjGroupNodesTypedataAndProtocol, New List(Of Byte))
|
||
|
||
With ObjGroupNodesInOutDic(strObjGroupNodesTypedataAndProtocol)
|
||
.Add(&H3) '设备存在,每个数据块前面都加上 &H03
|
||
.Add(CByte(cnode.DEV_TYPE_DATA)) '设备类型(1字节)
|
||
|
||
.Add(tmpAddr)
|
||
'PrintInfo(" *** 设备地址:" & tmpAddr.ToString)
|
||
|
||
.Add(hostAddr) '485端口(1字节)
|
||
.AddRange(baudData) '波特率(4字节)
|
||
|
||
.Add(CByte(cnode.PROTOCOL_VER)) '协议版本(1字节)
|
||
.Add(CInt(FindAttributeValueUnderModel(pNode, “Device present”, "Number of resending"))) '重发次数(1字节)
|
||
.AddRange(retryTimeData) '重发间隔(2字节)
|
||
If cnode.DEV_TYPE_DATA.Equals("42") Then
|
||
Dim ipAddr As IPAddress = IPAddress.Parse(FindAttributeValueUnderModel(pNode, “Device present”, "中控IP地址")) '设备地址(1字节)
|
||
ipadd = ipAddr.GetAddressBytes()
|
||
' PrintInfo(" 中控IP地址 IPadd :" & ipAddr.ToString)
|
||
ElseIf cnode.DEV_TYPE_DATA.Equals("43") Then
|
||
Dim ipAddr As IPAddress = IPAddress.Parse(FindAttributeValueUnderModel(pNode, “Device present”, "域控IP地址")) '设备地址(1字节)
|
||
ipadd = ipAddr.GetAddressBytes()
|
||
' PrintInfo(" 域控IP地址 IPadd :" & ipAddr.ToString)
|
||
End If
|
||
.AddRange(ipadd)
|
||
.AddRange(keepParam)
|
||
End With
|
||
|
||
End If
|
||
|
||
|
||
|
||
|
||
'遍历设备
|
||
For Each objNode In cnode.Nodes
|
||
|
||
Select Case objNode.Interface
|
||
Case "DI"
|
||
ObjGroupNodesInputCnt(strObjGroupNodesTypedataAndProtocol) += 1 '输入回路数+1
|
||
ObjGroupNodesInpuSettings(strObjGroupNodesTypedataAndProtocol).AddRange(GetDeviceObjectSetting(pNode.Name, objNode.DefaultClass))'输入回路设定’
|
||
‘ObjGroupNodesInpuSettings(strObjGroupNodesTypedataAndProtocol).AddRange(GetDeviceObjectSetting(pNode.Name, objNode.DefaultClass))'输入回路设定’
|
||
|
||
Case "DO"
|
||
Dim tmpDevAlias As String = String.Empty
|
||
If Not String.IsNullOrEmpty(objNode.DefaultAliasName) Then
|
||
tmpDevAlias = objNode.DefaultAliasName
|
||
End If
|
||
'If String.IsNullOrEmpty(tmpDevAlias) Then Continue For '未命名别名的输出设备不参与编译
|
||
Dim aliasData() As Byte = AliasEncoding.GetBytes(tmpDevAlias)
|
||
ReDim Preserve aliasData(31) 'caocong 2022-06-07 修改别名长度16Byte -> 32Byte
|
||
ObjGroupNodesoutputCnt(strObjGroupNodesTypedataAndProtocol) += 1 '输出回路数+1’
|
||
ObjGroupNodesOutputAliases(strObjGroupNodesTypedataAndProtocol).AddRange(aliasData) '输出回路别名’
|
||
Case Else
|
||
Continue For
|
||
End Select
|
||
Next
|
||
|
||
Next
|
||
|
||
|
||
'遍历合并后的设备组(保存于键值对中)
|
||
For Each strKey As String In ObjGroupNodesInOutDic.Keys
|
||
Dim inputCnt As UInt16 = ObjGroupNodesInputCnt(strKey)
|
||
Dim outputCnt As UInt16 = ObjGroupNodesoutputCnt(strKey)
|
||
|
||
Dim arryInputSetting As Byte() = ObjGroupNodesInpuSettings(strKey).ToArray
|
||
Dim arryOutputSetting As Byte() = ObjGroupNodesOutputAliases(strKey).ToArray
|
||
|
||
ObjGroupNodesInOutDic(strKey).AddRange(BitConverter.GetBytes(inputCnt))
|
||
ObjGroupNodesInOutDic(strKey).AddRange(BitConverter.GetBytes(outputCnt))
|
||
|
||
ObjGroupNodesInOutDic(strKey).AddRange(arryInputSetting) '所有输入回路设置(n*4字节)
|
||
ObjGroupNodesInOutDic(strKey).AddRange(arryOutputSetting) '所有输出回路别名(n*16字节)
|
||
|
||
outDataLst.Add(ObjGroupNodesInOutDic(strKey).ToArray)
|
||
Next
|
||
Dim tmpOutData As Byte()
|
||
For i = 0 To outDataLst.Count - 1
|
||
tmpOutData = outDataLst(i).ToArray
|
||
Console.WriteLine($"设备编译数据:{ByteToString(tmpOutData.ToArray)}")
|
||
Next
|
||
Dim tmpBufferLst As List(Of Byte()) = SelfCheckingPower(pNode)
|
||
If IsNothing(tmpBufferLst) AndAlso tmpBufferLst.Count = 0 Then
|
||
Else
|
||
outDataLst.AddRange(tmpBufferLst.ToArray)
|
||
End If
|
||
|
||
Return outDataLst
|
||
|
||
End Function
|
||
Public Function SelfCheckingPower(pNode As DeviceModel) As List(Of Byte())
|
||
|
||
Dim outDataLst As New List(Of Byte()) '输出数据列表
|
||
If Not pNode.Desc.DevInterface.Equals("PB_BUS_LINE") Then Return outDataLst
|
||
For Each objNode In pNode.Nodes
|
||
|
||
If objNode.DEV_TYPE_DATA.Equals("49") OrElse objNode.DEV_TYPE_DATA.Equals("50") OrElse objNode.DEV_TYPE_DATA.Equals("51") Then
|
||
Dim cmd As Byte = &H7
|
||
Dim tmpAddr As Byte = CInt(FindAttributeValueUnderModel(pNode, “Device present”, "Dialing address")) '设备地址(1字节)
|
||
Dim devtype As Byte = CByte(objNode.DEV_TYPE_DATA)
|
||
|
||
'遍历设备
|
||
For Each jNode As DeviceChildNode In objNode.Nodes
|
||
'If objNode.RowType <> RowNode.RowTypeEnum.DeviceObject Then Continue For '设备
|
||
'If objNode.Compile = False Then Continue For '判断是否enable action’
|
||
' Dim bpTag As DeviceObjectRowNodeTag = objNode.Tag
|
||
Select Case jNode.Interface
|
||
Case "DI"
|
||
|
||
Case "DO"
|
||
Dim nli As New List(Of Byte)
|
||
Dim upAddr As Integer = CInt(FindAttributeValueUnderModel(pNode, “Device present”, $"Circuit {jNode.LoopAddr} self check power lower limit")) '设备地址(1字节)
|
||
Dim domAddr As Integer = CInt(FindAttributeValueUnderModel(pNode, “Device present”, $"Circuit {jNode.LoopAddr} self check power upper limit")) '设备地址(1字节)
|
||
nli.Add(cmd)
|
||
nli.Add(devtype)
|
||
nli.Add(tmpAddr)
|
||
nli.AddRange(BitConverter.GetBytes(CShort(jNode.LoopAddr)))
|
||
nli.AddRange(BitConverter.GetBytes(CShort(upAddr)))
|
||
nli.AddRange(BitConverter.GetBytes(CShort(domAddr)))
|
||
|
||
outDataLst.Add(nli.ToArray)
|
||
Case Else
|
||
Continue For
|
||
End Select
|
||
Next
|
||
End If
|
||
|
||
Next
|
||
Return outDataLst
|
||
|
||
End Function
|
||
Private Function GetDeviceObjectSetting(devname As String, nodetype As String) As Byte()
|
||
Dim buf() As Byte
|
||
|
||
Select Case nodetype
|
||
Case "KEY"
|
||
If devname.Equals(hostname) Then
|
||
buf = {3, 2, 2, 0}
|
||
Else
|
||
buf = {1, 2, 2, 0}
|
||
End If
|
||
|
||
Case "RKEY"
|
||
buf = {1, 0, 0, 100}
|
||
Case "PIR"
|
||
buf = {2, 2, 60, 0}
|
||
Case "DRY"
|
||
buf = {3, 2, 2, 0}
|
||
Case "SLIDER"
|
||
buf = {2, 2, 2, 0}
|
||
Case "CARD"
|
||
buf = {0, 1, 0, 0}
|
||
Case "Virtual_Card"
|
||
buf = {2, 0, 0, 0}
|
||
Case "MUSIC"
|
||
buf = {1, 0, 0, 0}
|
||
Case "Carbon_Device", "Scene_Restore"
|
||
buf = {1, 0, 0, 0}
|
||
End Select
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
'If devname.Equals(hostname) Then
|
||
' buf = {3, 2, 2, 0}
|
||
'Else
|
||
' buf = {1, 2, 2, 0}
|
||
'End If
|
||
|
||
'For Each node As RowNode In pNode.Nodes
|
||
' '查询设备属性集合
|
||
' If node.RowType <> RowNode.RowTypeEnum.DeviceAttributes Then Continue For
|
||
|
||
' '获取设备属性值
|
||
' Dim index As Integer = 0
|
||
' Dim tag As AttributeRowNodeTag
|
||
' For Each n As RowNode In node.Nodes
|
||
' tag = n.Tag
|
||
' buf(index) = tag.ValueData
|
||
|
||
' index += 1
|
||
' If index >= 4 Then Exit For
|
||
' Next
|
||
'Next
|
||
Return buf
|
||
End Function
|
||
Public Function ByteToString(databuff() As Byte)
|
||
Dim strData As String = String.Empty
|
||
For i = 0 To databuff.Length - 1
|
||
strData &= $" {Hex(databuff(i)).PadLeft(2, "0"c)}"
|
||
Next
|
||
Return strData
|
||
End Function
|
||
Private Function FindAttributeValueUnderModel(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.DataDefault
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
End Function
|
||
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
|
||
Private Function FindNodeValueUnderModel(pNode As DeviceModel, groupName As String, attributeName As String) As String
|
||
For Each cnode In pNode.Nodes
|
||
If cnode.Name.Equals(groupName) Then
|
||
For Each ccnode In cnode.Nodes
|
||
If ccnode.Interface.Equals(attributeName) Then
|
||
Return ccnode.LoopAddr
|
||
End If
|
||
Next
|
||
|
||
End If
|
||
Next
|
||
End Function
|
||
''' <summary>
|
||
''' 配置RCU模型设备存在数据
|
||
''' </summary>
|
||
''' <param name="pNode">模型节点</param>
|
||
''' <returns></returns>
|
||
Private Function FillRCUModelDeviceExsist(pNode As DeviceModel) As Byte()
|
||
' If pNode.RowType <> RowNode.RowTypeEnum.Model Then Throw New Exception($"行号:{pNode.RowListIndex} 不为RCU模型类型")
|
||
Dim buf As New List(Of Byte)
|
||
|
||
'Dim tag As ModelRowNodeTag = pNode.Tag
|
||
buf.Add(pNode.Desc.DevTypeData) '设备类型(1字节)
|
||
buf.Add(&H0) '设备地址(1字节)
|
||
buf.Add(&H0) '485端口(1字节)
|
||
|
||
Dim baudrate As Integer = 0
|
||
buf.AddRange(BitConverter.GetBytes(baudrate)) '波特率(4字节)
|
||
|
||
buf.Add(pNode.Desc.ProtocolVer) '协议版本(1字节)
|
||
buf.Add(&H0) '重发次数(1字节)
|
||
|
||
Dim retryInterval As Short = 0
|
||
buf.AddRange(BitConverter.GetBytes(retryInterval)) '重发间隔(2字节)
|
||
|
||
Dim keepParam(63) As Byte
|
||
buf.AddRange(keepParam) '保留字段(32字节) -> 2022-05-28 V3.1 32bytes->64Bytes
|
||
|
||
Dim inputCount As Short = 0
|
||
Dim outputCount As Short = 0
|
||
buf.AddRange(BitConverter.GetBytes(inputCount)) '输入回路数(2字节)
|
||
buf.AddRange(BitConverter.GetBytes(outputCount)) '输出回路数(2字节)
|
||
|
||
'所有输入回路设置(n*4字节)
|
||
|
||
'所有输出回路别名(n*16字节)
|
||
|
||
Return buf.ToArray
|
||
End Function
|
||
Public Function FillConfigInfo(configInfo As ConfigInfoStuct, adevName As String) As List(Of Byte)
|
||
Dim resultDatas As New List(Of Byte())
|
||
Dim cmd As Byte = &H1
|
||
Dim buf As List(Of Byte) = New List(Of Byte)
|
||
|
||
|
||
Dim arrayCopyLenght As Integer = 0
|
||
|
||
'命令
|
||
buf.Add(cmd)
|
||
|
||
'发布作者 P0~31
|
||
Dim bytesAuthor() As Byte = AliasEncoding.GetBytes(configInfo.Author.Trim)
|
||
Dim bytesAuthor_32bytes(31) As Byte
|
||
|
||
If bytesAuthor.Length <= 32 Then
|
||
arrayCopyLenght = bytesAuthor.Length
|
||
Else
|
||
arrayCopyLenght = 32
|
||
End If
|
||
Array.Copy(bytesAuthor, bytesAuthor_32bytes, arrayCopyLenght)
|
||
|
||
buf.AddRange(bytesAuthor_32bytes)
|
||
|
||
|
||
'软件版本号 P32~35
|
||
'Dim strConfigToolsVersion As String = Replace(configInfo.ConfigToolVersion, ".", "", 1, 4)
|
||
'Dim byetConfigToolsVersion() As Byte = System.Text.Encoding.UTF8.GetBytes(strConfigToolsVersion)
|
||
Dim ByteConfigToolsVersion() As String = configInfo.ConfigToolVersion.Split(".")
|
||
Dim byetConfigToolsVersion(3) As Byte
|
||
byetConfigToolsVersion(0) = Val(ByteConfigToolsVersion(0))
|
||
byetConfigToolsVersion(1) = Val(ByteConfigToolsVersion(1))
|
||
byetConfigToolsVersion(2) = Val(ByteConfigToolsVersion(2))
|
||
byetConfigToolsVersion(3) = Val(ByteConfigToolsVersion(3))
|
||
|
||
buf.AddRange(byetConfigToolsVersion)
|
||
|
||
'配置发布日期 P36~42
|
||
'Dim strReleaseDate As String = Format(configInfo.ReleaseDate, "yyyyMMddHHmmss")
|
||
'Dim byteReleaseDate() = System.Text.Encoding.UTF8.GetBytes(strReleaseDate)
|
||
Dim byteReleaseDate(6) As Byte '
|
||
byteReleaseDate(0) = configInfo.ReleaseDate.Year \ 256 'yy H
|
||
byteReleaseDate(1) = configInfo.ReleaseDate.Year Mod 256 'yy L
|
||
byteReleaseDate(2) = configInfo.ReleaseDate.Month 'Month
|
||
byteReleaseDate(3) = configInfo.ReleaseDate.Day 'd
|
||
byteReleaseDate(4) = configInfo.ReleaseDate.Hour 'h
|
||
byteReleaseDate(5) = configInfo.ReleaseDate.Minute 'm
|
||
byteReleaseDate(6) = configInfo.ReleaseDate.Second 's
|
||
|
||
buf.AddRange(byteReleaseDate)
|
||
|
||
'项目名称 P43~74
|
||
Dim byteHotelName() As Byte = AliasEncoding.GetBytes(configInfo.HotelName.Trim)
|
||
Dim byteHotelName_32Bytes(31) As Byte
|
||
|
||
If byteHotelName.Length <= 32 Then
|
||
arrayCopyLenght = byteHotelName.Length
|
||
Else
|
||
arrayCopyLenght = 32
|
||
End If
|
||
Array.Copy(byteHotelName, byteHotelName_32Bytes, arrayCopyLenght)
|
||
|
||
buf.AddRange(byteHotelName_32Bytes)
|
||
|
||
|
||
'项目编号 P75~78
|
||
Dim byteHotelCode() As Byte = iByte4(configInfo.HotelCode)
|
||
|
||
buf.AddRange(byteHotelCode)
|
||
|
||
'项目分组 P79~110
|
||
Dim byteHoteGroupName() As Byte = AliasEncoding.GetBytes(configInfo.HotelGroupName.Trim)
|
||
Dim byteHoteGroupName_32Bytes(31) As Byte
|
||
|
||
If byteHoteGroupName.Length <= 32 Then
|
||
arrayCopyLenght = byteHoteGroupName.Length
|
||
Else
|
||
arrayCopyLenght = 32
|
||
End If
|
||
Array.Copy(byteHoteGroupName, byteHoteGroupName_32Bytes, arrayCopyLenght)
|
||
|
||
buf.AddRange(byteHoteGroupName_32Bytes)
|
||
|
||
'房型别名 P111~142
|
||
Dim byteRoomTypeName() As Byte = AliasEncoding.GetBytes(configInfo.RoomTypeName.Trim)
|
||
Dim byteRoomTypeName_32Bytes(31) As Byte
|
||
|
||
If byteRoomTypeName.Length <= 32 Then
|
||
arrayCopyLenght = byteRoomTypeName.Length
|
||
Else
|
||
arrayCopyLenght = 32
|
||
End If
|
||
Array.Copy(byteRoomTypeName, byteRoomTypeName_32Bytes, arrayCopyLenght)
|
||
|
||
buf.AddRange(byteRoomTypeName_32Bytes)
|
||
|
||
|
||
'配置版本号 P143~146
|
||
'Dim byteConfigFileVersion() As Byte = iByte4(configInfo.CfgFileVersion)
|
||
'buf.AddRange(byteConfigFileVersion)
|
||
|
||
'Momo 2022-09-06 配置版本号只有3位 P143~145
|
||
Dim byteConfigFileVersion() As Byte = iByte3(configInfo.CfgFileVersion)
|
||
buf.AddRange(byteConfigFileVersion)
|
||
|
||
'配置机型 P146~P209 MCU机型名称 64
|
||
Dim tmpModelName As String = adevName.Trim
|
||
'MsgBox(tmpModelName)
|
||
Dim byteModelName() As Byte = AliasEncoding.GetBytes(tmpModelName)
|
||
Dim byteModelName_64Bytes(63) As Byte
|
||
|
||
If byteModelName.Length <= 64 Then
|
||
arrayCopyLenght = byteModelName.Length
|
||
Else
|
||
arrayCopyLenght = 64
|
||
End If
|
||
Array.Copy(byteModelName, byteModelName_64Bytes, arrayCopyLenght)
|
||
|
||
buf.AddRange(byteModelName_64Bytes)
|
||
|
||
|
||
'2024.12.20 CZH
|
||
Dim dtime As Short = 0
|
||
Try
|
||
dtime = CShort(_grd.Cell(TableRowNumber.FunctionAnotherName, TableColNumber.InsertColumn - 1).Text)
|
||
If dtime < -24 OrElse dtime > 24 Then
|
||
dtime = 0
|
||
End If
|
||
Catch ex As Exception
|
||
dtime = 0
|
||
End Try
|
||
|
||
Dim eventNum() As Byte = BitConverter.GetBytes(dtime)
|
||
buf.AddRange(eventNum)
|
||
|
||
|
||
|
||
|
||
|
||
'完成配置数据添加
|
||
Return buf 'resultDatas
|
||
End Function
|
||
|
||
''' <summary>
|
||
''' Integer 类型转 4 字节 byte数组,高字节在前
|
||
''' </summary>
|
||
''' <param name="i"></param>
|
||
''' <returns></returns>
|
||
Public Function iByte4(ByVal i As Integer) As Byte()
|
||
Dim btemp() As Byte = {0, 0, 0, 0}
|
||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||
btemp(3) = b(3)
|
||
btemp(2) = b(2)
|
||
btemp(1) = b(1)
|
||
btemp(0) = b(0)
|
||
Return btemp
|
||
End Function
|
||
|
||
''' <summary>
|
||
''' Integer 类型转 3 字节 byte数组,高字节在前
|
||
''' </summary>
|
||
''' <param name="i"></param>
|
||
''' <returns></returns>
|
||
Public Function iByte3(ByVal i As Integer) As Byte()
|
||
Dim btemp() As Byte = {0, 0, 0}
|
||
Dim b() As Byte = BitConverter.GetBytes(i)
|
||
btemp(2) = b(2)
|
||
btemp(1) = b(1)
|
||
btemp(0) = b(0)
|
||
Return btemp
|
||
|
||
|
||
End Function
|
||
|
||
Public Function SaveToExle(g_XmlPath As String)
|
||
Try
|
||
_grd.ExportToExcel(g_XmlPath,)
|
||
Return True
|
||
Catch ex As Exception
|
||
Return False
|
||
End Try
|
||
|
||
End Function
|
||
Public Function Save(g_XmlPath As String)
|
||
|
||
|
||
Try
|
||
Dim fxml As New DrSeverGrid(Dic_Devicemodel, Dic_ActionConfiguration, _grd, BasicClassFilename, ConditionFileName)
|
||
fxml.Save(g_XmlPath)
|
||
Return True
|
||
Catch ex As Exception
|
||
Return False
|
||
End Try
|
||
|
||
End Function
|
||
Public Sub test()
|
||
For i = 5 To 20
|
||
Console.WriteLine($"Rows :{i} VAL :{_grd.Row(i).Locked }")
|
||
For j = 1 To 10
|
||
Console.WriteLine($"cols :{j} VAL :{_grd.Column(j).Locked }")
|
||
Console.WriteLine($"cell :{i},{j} VAL :{_grd.Cell(i, j).Locked }")
|
||
Next
|
||
Next
|
||
_grd.Column(1).Locked = False
|
||
_grd.Row(9).Locked = False
|
||
_grd.Row(8).Locked = False
|
||
With _grd.Range(8, 1, 9, 1)
|
||
.ClearAll()
|
||
.Locked = False
|
||
'.Merge()
|
||
End With
|
||
|
||
|
||
End Sub
|
||
'上传无卡取电回路别名
|
||
Public Function tbl_room_ble_devlistInsert(HotelID As String, RoomTypeID As String) As String
|
||
'判断设备列表是否为空
|
||
Dim result As String = ""
|
||
Dim strbuf() As String
|
||
Dim arrayCopyLenght As String = $"{HotelID}_{RoomTypeID}"
|
||
result = $"'{arrayCopyLenght}',"
|
||
Dim kstr As String = ""
|
||
Dim cnt As Integer = 0
|
||
Dim updatastr As String = ""
|
||
For Each index In Dic_Devicemodel.Values
|
||
For Each node In index.Nodes
|
||
If node.Name.Equals("Virtual_Card") AndAlso node.Interface.Equals("DO") Then
|
||
cnt = 0
|
||
For Each node1 In node.Nodes
|
||
strbuf = node1.Description.Split(",")
|
||
'Description = "卫红外,关门磁(18),50,,2,2,0"
|
||
If strbuf.Count > 1 Then
|
||
kstr = $"{kstr}loop{cnt},"
|
||
result = $"{result}'{strbuf(1).Replace("(", "_").Replace(")", "")}',"
|
||
updatastr = $"{updatastr}loop{cnt} = VALUES(loop{cnt}),"
|
||
End If
|
||
cnt = cnt + 1
|
||
Next
|
||
End If
|
||
Next
|
||
Next
|
||
If kstr.Length > 0 Then
|
||
result = result.Substring(0, result.Length - 1)
|
||
kstr = kstr.Substring(0, kstr.Length - 1)
|
||
updatastr = updatastr.Substring(0, updatastr.Length - 1)
|
||
result = $"INSERT INTO tbl_rcu_virtualcard_looplogs (Combination_ID,{kstr}) VALUES ({result})
|
||
ON DUPLICATE KEY UPDATE {updatastr};"
|
||
Else
|
||
Return ""
|
||
End If
|
||
|
||
Return result
|
||
End Function
|
||
Public Function TestReportingScenario(_UserName As String, _HotleID As String, _RoomTypeID As String, filename As String, Version As String) As ReportingScenario
|
||
Dim aaa As New ReportingScenario(_UserName, _HotleID, _RoomTypeID, filename, Version, _grd, Dic_Devicemodel, Dic_ActionConfiguration)
|
||
Dim li As List(Of MDevNodeMessage) = aaa.getDateDisposeRuning
|
||
Dim str As String = JsonConvert.SerializeObject(li)
|
||
'MsgBox(str)
|
||
Dim nsurl As String = "https://boonlive-rcu.com/api/UploadRoomTypeModal" '"https://pms.boonlive-rcu.com/api/UploadRoomTypeModal"
|
||
GetAccountAuth(nsurl, str)
|
||
Return aaa
|
||
End Function
|
||
Private Function GetAccountAuth(url As String, data As String) As Boolean
|
||
Dim jsonString As String = HttpMothod.PostData2(url, data)
|
||
If String.IsNullOrWhiteSpace(jsonString) OrElse jsonString.ToUpper.Contains("False".ToUpper) Then
|
||
Throw New Exception($"用户鉴权异常,请联系管理员")
|
||
Return False
|
||
End If
|
||
|
||
Return True
|
||
End Function
|
||
Public Function LoadFile(path As String) As Boolean
|
||
'新主机项目 清空设备列表
|
||
Try
|
||
'Dim ts As DateTime = Now
|
||
'Dim st As TimeSpan
|
||
Dic_Devicemodel.Clear()
|
||
Dic_ActionConfiguration.Clear()
|
||
_ServerAction.Clear()
|
||
ColumnAnothername.Clear()
|
||
'记录主机名称
|
||
hostname = ""
|
||
_ServerInsertRows = 0
|
||
_SceneID = 1
|
||
_ColumnStartLoad = TableColNumber.Max - 1
|
||
initGrid1()
|
||
LockGridAutoRedraw()
|
||
Dim fxml As New DrSeverGrid(Dic_Devicemodel, Dic_ActionConfiguration, _grd, BasicClassFilename, ConditionFileName)
|
||
|
||
grdRemoveHandler()
|
||
'st = Now - ts
|
||
'Console.WriteLine($"st1:({st.TotalMilliseconds })")
|
||
|
||
fxml.LoadFile(path)
|
||
|
||
|
||
'st = Now - ts
|
||
'Console.WriteLine($"st2:({st.TotalMilliseconds })")
|
||
hostname = _grd.Cell(1, 8).Text
|
||
Dic_Devicemodel = fxml.Dic_Devicemodel
|
||
_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = getFunctionChildNodeAnother(Dic_Devicemodel)
|
||
_ColumnStartLoad = fxml.InsertColumn
|
||
BasicClassFilename = fxml.Dic_Bname
|
||
ConditionFileName = fxml.Dic_Cname
|
||
_SceneID = fxml.G_SceneID
|
||
ColumnAnothername = fxml.ColumnAnothername
|
||
|
||
_ServerInsertRows = _grd.Rows - 1
|
||
ChangeTheServiceLineNumber()
|
||
grdAddHandler()
|
||
|
||
UnLockGridAutoRedraw()
|
||
|
||
'st = Now - ts
|
||
'Console.WriteLine($"st3:({st.TotalMilliseconds })")
|
||
Return True
|
||
Catch ex As Exception
|
||
Return False
|
||
End Try
|
||
|
||
|
||
|
||
|
||
End Function
|
||
Public Function getFunctionChildNodeAnother(Devicemodel As Dictionary(Of String, DeviceModel)) As String
|
||
Dim result As String = String.Empty
|
||
For Each moduStr In Devicemodel.Values
|
||
If moduStr.Nodes.Count = 1 AndAlso (moduStr.Nodes(0).Nodes.Count = 0 OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("48") OrElse moduStr.Nodes(0).DEV_TYPE_DATA.Equals("46")) Then
|
||
If String.IsNullOrEmpty(result) Then
|
||
result = moduStr.Name
|
||
Else
|
||
result = result & "," & moduStr.Name
|
||
End If
|
||
|
||
End If
|
||
Next
|
||
Return result
|
||
'_grd.Cell(TableRowNumber.FunctionChildNodeAnother, TableColNumber.DeviceName).Text = "test"
|
||
End Function
|
||
|
||
|
||
|
||
|
||
#End Region
|
||
End Class
|
||
|
||
Public Class CtabRange
|
||
Public devname As String = String.Empty
|
||
Public fr As Integer = 0
|
||
Public lr As Integer = 0
|
||
Public fc As Integer = 0
|
||
Public lc As Integer = 0
|
||
Sub New(grd As FlexCell.Grid, tabr As Integer, tabc As Integer)
|
||
If grd.Rows > tabr AndAlso grd.Cols > tabc Then
|
||
With grd.Range(tabr, tabc, tabr, tabc)
|
||
devname = grd.Cell(.FirstRow, .FirstCol).Text
|
||
|
||
fc = .FirstCol
|
||
|
||
lc = .LastCol
|
||
|
||
fr = .FirstRow
|
||
|
||
lr = .LastRow
|
||
End With
|
||
End If
|
||
|
||
End Sub
|
||
|
||
End Class
|
||
|