Files

1509 lines
60 KiB
VB.net
Raw Permalink Normal View History

2025-12-11 10:06:44 +08:00
Imports System.ComponentModel
Imports BLV_Studio.TableInteraction
Imports FlexCell
Imports Newtonsoft.Json
Public Class ExecutionCondition
'条件基类
Public G_ConfigActionConcitons As ConfigActionConcitons
Public g_BasicClasses As DeviceObjectClasses
Public DicDevicemodel As Dictionary(Of String DeviceModel
'输入输出值
Public G_input As String
Public G_Result As String
Public G_celltag As Dictionary(Of String, String)
Public G_Row As Integer = 0
Public G_grid As FlexCell.Grid
Private Gr_Row As Integer = 0
Public G_ActionConfiguration As List(Of TableRowTag)
'基类数据
Public G_ModeDevType() As String
Private Dic_2 As Dictionary(Of String, List(Of String))
'条件列表
Private g_DicDragDrop As Dictionary(Of String, String
Public Shared joinway() As String = {"7 清理(1声)", "8 勿扰", "9 稍后", "10 退房", "13 清理(3声)"}
#Region "条件值"
Private Property 动作输出使能 As UInt64
Private Property 房态 As UInt64
Private Property 控制取电服务 As UInt64
Private Property 取电状态 As UInt64
Private Property 勿扰状态 As UInt64
Private Property 清理状态 As UInt64
Private Property 呼叫状态 As UInt64
Private Property 洗衣状态 As UInt64
Private Property 退房状态 As UInt64
Private Property 稍后状态 As UInt64
Private Property SOS状态 As UInt64
Private Property 预约待租状态 As UInt64
Private Property 开锁状态 As UInt64
Private Property 行李状态 As UInt64
Private Property 保险箱状态 As UInt64
Private Property 门磁状态 As UInt64
Private Property 提示音状态 As UInt64
Private Property 背光状态 As UInt64
Private Property 季节状态 As UInt64
Private Property 时间状态 As UInt64
Private Property 起夜状态 As UInt64
Private Property 锁定状态 As UInt64
#End Region
Enum colname
<Description("rowid")>
rowid = 0
<Description("描述")>
condition
<Description("执行方式")>
switch
max
End Enum
Private Sub ExecutionCondition_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Gr_Row = G_Row
Dic_2 = New Dictionary(Of String, List(Of String))
SceneNumber = New Dictionary(Of String, String)
g_DicDragDrop = New Dictionary(Of String, String)
If Init_Cob_CarryOutType() Then
Init_Cob_KeyType()
InitGrid1()
End If
LoadInputText(G_input)
isloadok = True
GetG_Result()
GetNodeClass()
End Sub
Public Sub GetNodeClass()
If IsNothing(G_grid) And Gr_Row = 0 Then Return
Dim loadtag As TableRowTag = G_ActionConfiguration(Gr_Row - 7)
Dim selectstr As String = String.Empty
ComboBox2.Items.Clear()
If DicDevicemodel.ContainsKey(loadtag.G_DevModeName) Then
Dim devmodw As DeviceModel = DicDevicemodel.Item(loadtag.G_DevModeName)
For Each node In devmodw.Nodes
If node.Name.Equals(loadtag.G_DevNodeName) Then
For Each index In node.Nodes
If index.LoopAddr.Equals(loadtag.G_DevNodeIndex.ToString) Then
selectstr = index.DefaultClass
End If
Next
End If
Next
Select Case selectstr
Case "KEY", "PIR", "DRY"
If devmodw.Desc.Name.Equals("BLV_C12") Then
ComboBox2.Items.AddRange({"KEY", "PIR", "DRY"})
Else
ComboBox2.Items.AddRange({"KEY"})
End If
Case "RKEY"
ComboBox2.Items.Add("RKEY")
Case "Virtual_Card"
ComboBox2.Items.Add("Virtual_Card")
Case "SLIDER"
ComboBox2.Items.Add("SLIDER")
Case "CARD", "BLV_CARD" 'CZH250903 增加测试 "BLV_CARD"
ComboBox2.Items.Add("CARD")
Case "Carbon_Device"
ComboBox2.Items.Add("Carbon_Device")
Case "Scene_Restore"
ComboBox2.Items.Add("Scene_Restore")
Case Else
End Select
End If
If ComboBox2.Items.Count > 0 Then
'判断下拉选项中有没有符合 selectstr
If ComboBox2.Items.Contains(selectstr) Then
ComboBox2.Text = selectstr
Else
ComboBox2.Text = ComboBox2.Items(0)
End If
'ComboBox2.Text = ComboBox2.Items(0)
End If
End Sub
#Region "控件初始化"
Private Sub Init_Cob_KeyType()
If IsNothing(G_ModeDevType) OrElse G_ModeDevType.Length = 0 Then
Return
End If
Cob_KeyType.Items.AddRange(G_ModeDevType)
Cob_KeyType.SelectedIndex = 0
End Sub
Private Function Init_Cob_CarryOutType() As Boolean
Cob_CarryOutType.Items.Clear()
If IsNothing(G_ConfigActionConcitons) Then
MsgBox("条件基类加载失败,请联系开发者!")
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
Return False
End If
Cob_CarryOutType.Items.AddRange(G_ConfigActionConcitons.ExeMode(0).DataRange.Split(","))
Cob_CarryOutType.SelectedIndex = 0
Return True
End Function
Private Function InitGrid1()
initTable(G_ConfigActionConcitons.Conction)
'InitTableTow(G_ConfigActionConcitons.Conction)
End Function
Public Shared Function CheckDataIsOk(datastr As String, ConfigActionConcitons As ConfigActionConcitons ModeDevType() As String, mytag As TableRowTag, ActionConfiguration As List(Of TableRowTag), Optional Tgrid As Grid = Nothing) As Boolean
If mytag.G_DevNodeName.Equals("语音") AndAlso String.IsNullOrEmpty(datastr) Then Return True
If String.IsNullOrEmpty(datastr) Then Return False
Dim buf() As String = datastr.Split(",")
Dim dicKeyType = ComboBox1DateDropDown(Tgrid, mytag, ActionConfiguration)
If Not IsNothing(dicKeyType) AndAlso dicKeyType.ContainsKey(datastr) Then Return True
If buf.Length <> 3 Then Return False
Dim intbuf(2) As UInt64
If Not UInt64.TryParse(buf(0), intbuf(0)) And UInt64.TryParse(buf(1), intbuf(1)) And UInt64.TryParse(buf(2), intbuf(2)) Then Return False
If IsNothing(ConfigActionConcitons) Then Return False
If IsNothing(ModeDevType) And ModeDevType.Length = 0 Then Return False
Dim abuf() As String = ConfigActionConcitons.ExeMode(0).DataRange.Split(",")
Dim li As New List(Of String)
li.AddRange(abuf)
li.AddRange(joinway)
For Each astr In li
If astr.IndexOf(intbuf(1).ToString) = 0 Then
For Each bstr In ModeDevType
If bstr.IndexOf(intbuf(0).ToString) = 0 Then
Return CheckStatusValue(intbuf(2), ConfigActionConcitons.Conction)
End If
Next
Else
Continue For
End If
Next
Return False
End Function
Public Sub initTablechushen_Grid()
chushen_Grid.NewFile()
chushen_Grid.Rows = 1
chushen_Grid.Cols = 3
chushen_Grid.ExtendLastCol = True
chushen_Grid.Cell(0, 1).Text = "功能名稱"
chushen_Grid.Cell(0, 2).Text = "功能方法"
chushen_Grid.Column(2).CellType = CellTypeEnum.ComboBox
chushen_Grid.Column(1).Width = 100
chushen_Grid.Column(0).Visible = False
chushen_Grid.Column(1).Locked = True
chushen_Grid.Column(0).Locked = True
chushen_Grid.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
chushen_Grid.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
End Sub
Public Sub AddChushen_GridRow(strvalue As String)
Select Case strvalue
Case "1 点按"
DevEvenPar("DIMMING", "控制灯光", 0, "1 开,2 关,")
SplitContainer4.Panel2Collapsed = False
Cob_CarryOutType.Items.AddRange(joinway.ToArray)
Case "3 长按"
DevEvenPar("DIMMING", "循环调光", 0 "9 停止调光,")
SplitContainer4.Panel2Collapsed = False
For Each index In joinway
Try
Cob_CarryOutType.Items.Remove(index)
Catch ex As Exception
End Try
Next
Case "2 长按释放"
DevEvenPar("DIMMING", "循环调光", 0 "7 向上循环,8 向下循环,", ",28 向上循环至上限(仅限亮灯),29 向下循环至下限(仅限亮灯)")
SplitContainer4.Panel2Collapsed = False
For Each index In joinway
Try
Cob_CarryOutType.Items.Remove(index)
Catch ex As Exception
End Try
Next
Case Else
Return
End Select
Setingchushen_Grid()
End Sub
Public Sub Setingchushen_Grid()
If SplitContainer4.Panel2Collapsed = False AndAlso chushen_Grid.Rows > 0 AndAlso G_celltag.Count > 0 Then
Dim key As String = String.Empty
For r = 1 To chushen_Grid.Rows - 1
For Each node In G_celltag
If G_Row = 7 Then
If chushen_Grid.Cell(r, 2).Text.Equals(node.Key) Then
If node.Key.Contains("调光渐变时间") Then
chushen_Grid.Cell(r, 3).Text = NumberTOchushenGridText(node.Value)
Else
chushen_Grid.Cell(r, 3).Text = node.Value
End If
End If
Else
key = FunctionalTransformation(True, node.Key)
If chushen_Grid.Cell(r, 1).Text.Equals(key) Then
chushen_Grid.Cell(r, 2).Text = node.Value
End If
End If
Next
Next
End If
End Sub
Public Function FunctionalTransformation(GTotype As Boolean, val As String) As String
Dim result As String = String.Empty
If GTotype Then
Select Case val
Case "DIMMING"
result = "调光"
End Select
Else
Select Case val
Case "调光"
result = "DIMMING"
End Select
End If
Return result
End Function
Public Sub DevEvenPar(g_nodename As String, nodename As String, parindex As Integer ParamArray delebuf() As String)
For Each node In g_BasicClasses.DeviceClass
If node.Name.ToUpper.Equals(g_nodename) Then
For Each Anode In node.Methods
If Anode.Name.Equals(nodename) Then
chushen_Grid.AddItem("")
Dim key As String = FunctionalTransformation(True, g_nodename.ToUpper)
chushen_Grid.Cell(chushen_Grid.Rows - 1, 1).Text = key
If Anode.Params.Count < parindex Then Return
Dim Index = Anode.Params(parindex)
Dim li As New List(Of String)
li.Add("")
If Index.Name.Equals("") Then
li.Add(0)
Else
If Index.DataType.Equals("List") Then
Dim DataRange As String = Index.DataRange
If Not IsNothingdelebuf And delebuf.Length > 0 Then
For Each delstr In delebuf
DataRange = DataRange.Replace(delstr, "")
Next
End If
Dim tbuf() As String = DataRange.Split(",")
li.AddRange(tbuf)
'li.Remove(tbuf(0))
'li.Insert(0, tbuf0)
ElseIf Index.DataType.Equals("Integer") Then
Dim buf() As String = Index.DataRange.Split(",")
Dim startint As Integer = 0
Dim endint As Integer = 1
Integer.TryParse(buf(0), startint)
Integer.TryParse(buf(1), endint)
li.Add(startint)
For i = startint To endint
li.Add(i)
Next
'li.Remove(Index.DataDefault)
'li.Insert(0, Index.DataDefault)
End If
End If
If Dic_2.ContainsKey(node.Name.ToUpper) Then
Dic_2.Remove(node.Name.ToUpper)
End If
Dic_2.Add(node.Name.ToUpper, li)
'chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = Index.DataDefault
End If
Next
End If
Next
End Sub
Public Sub initTable(Conction As List(Of Conction))
Table_Grid1.Rows = 1
Table_Grid1.Cols = colname.max
Table_Grid1.ExtendLastCol = True
For i = 0 To colname.max - 1
Table_Grid1.Cell(0, i).Text = [Enum].GetName(GetType(colname), i)
Select Case i
Case colname.rowid
With Table_Grid1.Column(i)
.Width = 0
.Visible = True
End With
Case colname.condition
With Table_Grid1.Column(i)
.Width = 110
.Alignment = FlexCell.AlignmentEnum.CenterCenter
.Locked = True
End With
Case colname.switch
With Table_Grid1.Column(i)
.Width = 70
.Alignment = FlexCell.AlignmentEnum.CenterCenter
'.Locked = True
.CellType = CellTypeEnum.ComboBox
End With
Case Else
Exit For
End Select
Next
AddGrid1RowDragDrop(Conction)
End Sub
Private Sub LoadInputText(inputstr As String)
If String.IsNullOrEmpty(inputstr) Then Return
Dim buf() As String = inputstr.Split(",")
If buf.Length > 0 Then
For i As Integer = 0 To Cob_KeyType.Items.Count - 1
If Cob_KeyType.Items(i).ToString.Contains(buf0) Then
Cob_KeyType.SelectedIndex = i
Exit For
End If
Next
ComboBox1_DropDown(Nothing, Nothing)
If Not String.IsNullOrEmpty(buf(0)) AndAlso SceneNumber.ContainsKey(buf(0)) Then
ComboBox1.Text = buf0
End If
End If
If buf.Length > 1 Then
For i As Integer = 0 To Cob_CarryOutType.Items.Count - 1
If Cob_CarryOutType.Items(i).ToString.Contains(buf1) Then
Cob_CarryOutType.SelectedIndex = i
Exit For
End If
Next
End If
If buf.Length > 2 Then
GetStatusValue(buf(2)
End If
End Sub
Public Sub AddGrid1RowDragDrop(Conction As List(Of Conction))
g_DicDragDrop.Clear()
For Each node In Conction
Table_Grid1.AddItem("")
Table_Grid1.Cell(Table_Grid1.Rows - 1, colname.condition).Text = node.Name
Table_Grid1.Cell(Table_Grid1.Rows - 1, colname.switch).Text = node.DataDefault
If g_DicDragDrop.ContainsKey(node.Name) Then
g_DicDragDrop.Item(node.Name) = node.Desc
Else
g_DicDragDrop.Add(node.Name, node.Desc)
End If
Next
End Sub
#End Region
#Region "控件赋值"
Public Sub SetControlVal()
If String.IsNullOrEmpty(G_input) Then
Cob_CarryOutType.SelectedIndex = 0
Else
Dim bufstr As String = G_input.Split(",")
Dim u64 As UInt64 = 0
For index As Integer = 0 To Cob_CarryOutType.Items.Count - 1
Dim name() As String = Cob_CarryOutType.Items(index).ToString.Split(":")
If name(0).Equals(bufstr(0)) Then
Cob_CarryOutType.SelectedIndex = index
Exit For
End If
Next
GetStatusValue(bufstr1)
End If
End Sub
#End Region
Private Sub Grid1_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs) Handles Table_Grid1.ComboDropDown
If e.Row > 0 And e.Col = colname.switch Then
'Console.WriteLine(Grid1.Cell(e.Row, colname.condition).Text.Trim)
If g_DicDragDrop.ContainsKey(Table_Grid1.Cell(e.Row, colname.condition).Text) Then
Dim buf() As String = g_DicDragDrop.Item(Table_Grid1.Cell(e.Row, colname.condition).Text).Split(",")
Me.Table_Grid1.ComboBox(colname.switch).Items.Clear()
Dim cob_text As FlexCell.ComboBox = Me.Table_Grid1.ComboBox(colname.switch)
For Each index In buf
cob_text.Items.Add(index)
Next
End If
End If
End Sub
Private Function Getresult() As UInt64
For i = 1 To Table_Grid1.Rows - 1
Select Case Table_Grid1.Cell(i, colname.condition).Text
Case " 1 动作输出使能"
动作输出使能 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 2 判断房态"
房态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 3 控制取电服务"
控制取电服务 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 4 判断取电状态"
取电状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 5 判断勿扰状态"
勿扰状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 6 判断清理状态"
清理状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 7 判断呼叫状态"
呼叫状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 8 判断洗衣状态"
洗衣状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case " 9 判断退房状态"
退房状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "10 判断稍后状态"
稍后状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "11 判断SOS状态"
SOS状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
' Case "12 判断预约待租状态"
Case "12 判断送餐状态"
预约待租状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "13 判断开锁状态"
开锁状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "14 判断行李状态"
行李状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "15 判断保险箱状态"
保险箱状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "16 判断门磁状态"
门磁状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "17 判断提示音状态"
提示音状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "18 判断背光状态"
背光状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "19 判断季节状态"
季节状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "20 判断时间状态"
时间状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "21 判断起夜状态"
起夜状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case "22 判断锁定状态"
锁定状态 = CInt(GetNodeSelectStringValue(Table_Grid1.Cell(i, colname.switch).Text))
Case Else
'Throw New Exception($"未知条件属性名:{node.Name}")
End Select
Next
Return GetConditionData()
End Function
Private Shared Function CheckStatusValue(u64str As String, Conction As List(Of Conction)) As Boolean
Dim u64 As UInt64 = 0
UInt64.TryParse(u64str, u64)
Dim cu64 As UInt64 = 0
For Each aenunindex In Conction
Dim index As Integer = -1
Dim buf() As String = aenunindex.Desc.Split(",")
Select Case aenunindex.Name
Case " 1 动作输出使能"
index = Getrowu64Val(1, u64, ConditionBits.动作输出使能)
Case " 2 判断房态"
index = Getrowu64Val(7, u64, ConditionBits.房态)
Case " 3 控制取电服务"
index = Getrowu64Val(1, u64, ConditionBits.控制取电服务)
Case " 4 判断取电状态"
index = Getrowu64Val(7, u64, ConditionBits.取电状态)
Case " 5 判断勿扰状态"
index = Getrowu64Val(7, u64, ConditionBits.勿扰状态)
Case " 6 判断清理状态"
index = Getrowu64Val(7, u64, ConditionBits.清理状态)
Case " 7 判断呼叫状态"
index = Getrowu64Val(7, u64, ConditionBits.呼叫状态)
Case " 8 判断洗衣状态"
index = Getrowu64Val(7, u64, ConditionBits.洗衣状态)
Case " 9 判断退房状态"
index = Getrowu64Val(7, u64, ConditionBits.退房状态)
Case "10 判断稍后状态"
index = Getrowu64Val(7, u64, ConditionBits.稍后状态)
Case "11 判断SOS状态"
index = Getrowu64Val(7, u64, ConditionBits.SOS状态)
' Case "12 判断预约待租状态"
Case "12 判断送餐状态"
index = Getrowu64Val(7, u64, ConditionBits.预约待租状态)
Case "13 判断开锁状态"
index = Getrowu64Val(7, u64, ConditionBits.开锁状态)
Case "14 判断行李状态"
index = Getrowu64Val(7, u64, ConditionBits.行李状态)
Case "15 判断保险箱状态"
index = Getrowu64Val(7, u64, ConditionBits.保险箱状态)
Case "16 判断门磁状态"
index = Getrowu64Val(7, u64, ConditionBits.门磁状态)
Case "17 判断提示音状态"
index = Getrowu64Val(7, u64, ConditionBits.提示音状态)
Case "18 判断背光状态"
index = Getrowu64Val(7, u64, ConditionBits.背光状态)
Case "19 判断季节状态"
index = Getrowu64Val(7, u64, ConditionBits.季节状态)
Case "20 判断时间状态"
index = Getrowu64Val(7, u64, ConditionBits.时间状态)
Case "21 判断起夜状态"
index = Getrowu64Val(7, u64, ConditionBits.起夜状态)
Case "22 判断锁定状态"
index = Getrowu64Val(7, u64, ConditionBits.锁定状态)
Case Else
Continue For
'Throw New Exception($"未知条件属性名:{node.Name}")
End Select
If Isinspect(buf, index) Then
Continue For
End If
Return False
Next
Return True
End Function
Public Shared Function Isinspect(buf() As String index As Integer) As Boolean
For Each bstr In buf
If bstr.IndexOf(index.ToString) = 0 Then
Return True
End If
Next
Return False
End Function
Private Sub GetStatusValue(u64str As String)
Dim u64 As UInt64 = 0
UInt64.TryParse(u64str, u64)
Dim cu64 As UInt64 = 0
For i = 1 To Table_Grid1.Rows - 1
Dim index As Integer = 0
Select Case Table_Grid1.Cell(i, colname.condition).Text
Case " 1 动作输出使能"
SetTablecolnameswitch(i, 1, u64, ConditionBits.动作输出使能)
Case " 2 判断房态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.房态)
Case " 3 控制取电服务"
SetTablecolnameswitch(i, 1, u64, ConditionBits.控制取电服务)
Case " 4 判断取电状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.取电状态)
Case " 5 判断勿扰状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.勿扰状态)
Case " 6 判断清理状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.清理状态)
Case " 7 判断呼叫状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.呼叫状态)
Case " 8 判断洗衣状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.洗衣状态)
Case " 9 判断退房状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.退房状态)
Case "10 判断稍后状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.稍后状态)
Case "11 判断SOS状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.SOS状态)
' Case "12 判断预约待租状态"
Case "12 判断送餐状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.预约待租状态)
Case "13 判断开锁状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.开锁状态)
Case "14 判断行李状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.行李状态)
Case "15 判断保险箱状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.保险箱状态)
Case "16 判断门磁状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.门磁状态)
Case "17 判断提示音状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.提示音状态)
Case "18 判断背光状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.背光状态)
Case "19 判断季节状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.季节状态)
Case "20 判断时间状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.时间状态)
Case "21 判断起夜状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.起夜状态)
Case "22 判断锁定状态"
SetTablecolnameswitch(i, 7, u64, ConditionBits.锁定状态)
Case Else
'Throw New Exception($"未知条件属性名:{node.Name}")
End Select
Next
End Sub
Private Sub SetTablecolnameswitch(rowid As Integer, cu64 As UInt64, u64 As UInt64 number As ConditionBits)
u64 = u64 >> number
Dim index As Integer = 0
index = u64 And cu64
For Each nameStr In g_DicDragDrop.Item(Table_Grid1.Cell(rowid, colname.condition).Text).Split(",")
Dim strbuf() As String = nameStr.Split(":")
If strbuf(0).Equals(index.ToString) Then
Table_Grid1.Cell(rowid, colname.switch).Text = nameStr
End If
Next
End Sub
Private Shared Function Getrowu64Val(cu64 As UInt64, u64 As UInt64 number As ConditionBits) As Integer
u64 = u64 >> number
Dim index As Integer = 0
index = u64 And cu64
Return index
End Function
''' <summary>
''' 获取节点选择项对应的数值
''' </summary>
''' <param name="node"></param>
''' <returns></returns>
Private Function GetNodeSelectStringValue(node As String) As String
Dim result() As String
If node.Contains(":") Then
result = node.Trim.Split(":")
ElseIf node.Contains(" ") Then
result = node.Trim.Split(" ")
Else
Return ""
End If
Return result(0)
End Function
Public Function GetConditionData() As UInt64
Dim num As UInt64 = 0
num = num Or (动作输出使能 << ConditionBits.动作输出使能)
num = num Or (房态 << ConditionBits.房态)
num = num Or (控制取电服务 << ConditionBits.控制取电服务)
num = num Or (取电状态 << ConditionBits.取电状态)
num = num Or (勿扰状态 << ConditionBits.勿扰状态)
num = num Or (清理状态 << ConditionBits.清理状态)
num = num Or (呼叫状态 << ConditionBits.呼叫状态)
num = num Or (洗衣状态 << ConditionBits.洗衣状态)
num = num Or (退房状态 << ConditionBits.退房状态)
num = num Or (稍后状态 << ConditionBits.稍后状态)
num = num Or (SOS状态 << ConditionBits.SOS状态)
num = num Or (预约待租状态 << ConditionBits.预约待租状态)
num = num Or (开锁状态 << ConditionBits.开锁状态)
num = num Or (行李状态 << ConditionBits.行李状态)
num = num Or (保险箱状态 << ConditionBits.保险箱状态)
num = num Or (门磁状态 << ConditionBits.门磁状态)
num = num Or (提示音状态 << ConditionBits.提示音状态)
num = num Or (背光状态 << ConditionBits.背光状态)
num = num Or (季节状态 << ConditionBits.季节状态)
num = num Or (时间状态 << ConditionBits.时间状态)
num = num Or (起夜状态 << ConditionBits.起夜状态)
num = num Or (锁定状态 << ConditionBits.锁定状态)
Return num
End Function
Enum ConditionBits
''' <summary>动作输出使能</summary>
动作输出使能 = 0
''' <summary>房态</summary>
房态 = 1
''' <summary>控制取电服务</summary>
控制取电服务 = 4
''' <summary>取电状态</summary>
取电状态 = 5
''' <summary>勿扰状态</summary>
勿扰状态 = 8
''' <summary>清理状态</summary>
清理状态 = 11
''' <summary>呼叫状态</summary>
呼叫状态 = 14
''' <summary>洗衣状态</summary>
洗衣状态 = 17
''' <summary>退房状态</summary>
退房状态 = 20
''' <summary>稍后状态</summary>
稍后状态 = 23
''' <summary>SOS状态</summary>
SOS状态 = 26
''' <summary>预约待租状态</summary>
预约待租状态 = 29
''' <summary>开锁状态</summary>
开锁状态 = 32
''' <summary>行李状态</summary>
行李状态 = 35
''' <summary>保险箱状态</summary>
保险箱状态 = 38
''' <summary>门磁状态</summary>
门磁状态 = 41
''' <summary>提示音状态</summary>
提示音状态 = 44
''' <summary>背光状态</summary>
背光状态 = 47
''' <summary>季节状态</summary>
季节状态 = 50
''' <summary>时间状态</summary>
时间状态 = 53
''' <summary>起夜状态</summary>
起夜状态 = 56
''' <summary>锁定状态</summary>
锁定状态 = 59
''' <summary>保留字段</summary>
保留字段 = 62
End Enum
Private isloadok As Boolean = False
Public Sub GetG_Result()
If isloadok Then
G_Result = String.Empty
Dim strbuf() As String = Cob_CarryOutType.Text.Trim.Split(" ")
Dim u64 As UInt64 = Getresult()
Dim kettypebuf As String = Cob_KeyType.Text.Trim.Split(" ")
G_Result = $"{kettypebuf(0)},{strbuf(0)},{u64}"
Label3.Text = $"{kettypebuf(1)},{strbuf(1)},执行条件 {vbCrLf }{G_Result}"
End If
End Sub
Public Sub GetGTcelltag()
Dim number() As String = ComboBox1.Text.Split(" ")
If IsNothing(G_celltag) OrElse IsNothing(SceneNumber) OrElse String.IsNullOrEmpty(ComboBox1.Text) Then
SetMasterMask(G_Row, number(0))
If G_celltag.ContainsKey("CallRow") Then
G_celltag.Remove("CallRow")
End If
Return
End If
If SceneNumber.ContainsKey(ComboBox1.Text) Then
clearcelltext(G_Row)
If G_celltag.ContainsKey("CallRow") Then
G_celltag.Item("CallRow") = number(0)
Else
G_celltag.Add("CallRow", number(0))
End If
G_Result = ComboBox1.Text
End If
SetMasterMask(G_Row, number(0))
End Sub
Public Sub SetMasterMask(inrow As Integer, newcallrow As String)
'获取旧模板行
If G_celltag.ContainsKey("CallRow") Then
Dim s As String = G_celltag.Item("CallRow")
'旧模板行清空与本行相关反馈灯设置
For r = 7 To G_grid.Rows - 1
If G_grid.Cell(r, 3).Text.Equals(s) Then
Dim rowtag As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(G_grid.Cell(r, 6).Tag)
If Not IsNothing(rowtag) AndAlso rowtag.ContainsKey("CallRowA") Then
Dim buf() As String = rowtag.Item("CallRowA").Split(",")
Dim rtag As String = String.Empty
For Each index In buf
If index.Equals(G_grid.Cell(inrow, 3).Text) Then
Continue For
Else
If String.IsNullOrEmpty(index) Then
Continue For
End If
If String.IsNullOrEmpty(rtag) Then
rtag = $"{index},"
Else
rtag = $"{rtag}{index},"
End If
End If
Next
Console.WriteLine(rtag)
If rtag.Length > 0 Then
rtag = rtag.Substring(0, rtag.Length - 1)
End If
Console.WriteLine(rtag)
rowtag.Item("CallRowA") = rtag
G_grid.Cell(r, 6).Tag = JsonConvert.SerializeObject(rowtag)
End If
End If
Console.WriteLine(G_grid.Cell(r, 3).Text)
If G_grid.Cell(r, 3).Text.Equals(newcallrow) Then
Dim rowtag As Dictionary(Of String, String) = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(G_grid.Cell(r, 6).Tag)
If IsNothing(rowtag) Then
rowtag = New Dictionary(Of String, String)
End If
If Not IsNothing(rowtag) AndAlso rowtag.ContainsKey("CallRowA") Then
Console.WriteLine(rowtag.Item("CallRowA"))
If Not String.IsNullOrEmpty(rowtag.Item("CallRowA")) Then
rowtag.Item("CallRowA") = $"{ rowtag.Item("CallRowA")},{G_grid.Cell(inrow, 3).Text}"
Else
rowtag.Item("CallRowA") = $"{G_grid.Cell(inrow, 3).Text}"
End If
Else
rowtag.Add("CallRowA", G_grid.Cell(inrow, 3).Text)
End If
'rowtag.Item("CallRowA") = rtag
G_grid.Cell(r, 6).Tag = JsonConvert.SerializeObject(rowtag)
End If
Next
End If
End Sub
Public Function chushenGridTextTONumber(text As String) As Integer
Dim result As Integer = 0
Integer.TryParse(text, result)
If result = 0 Then Return result
result = ((result - 1) * 10) + 1
Return result
End Function
Public Function NumberTOchushenGridText(text As String) As String
If String.IsNullOrEmpty(text) Then Return String.Empty
Dim result As Integer = 0
Integer.TryParse(text, result)
If result = 0 Then Return result
result = result / 10
If result = 0 Then
Return 1
Else
result = result + 1
End If
Return result
End Function
Public Sub GetG_celltag()
If SplitContainer4.Panel2Collapsed = False AndAlso chushen_Grid.Rows > 0 Then
'G_celltag.Clear()
If G_Row = 7 Then
For r = 1 To chushen_Grid.Rows - 1
Console.WriteLine(chushen_Grid.Cell(r, 1).Text)
If String.IsNullOrEmpty(chushen_Grid.Cell(r, 1).Text) Then
Dim key As String = chushen_Grid.Cell(r, 2).Text
If key.Contains("调光渐变时间") Then
If G_celltag.ContainsKey(key) Then
G_celltag.Item(key) = chushenGridTextTONumber(chushen_Grid.Cell(r, 3).Text)
Else
G_celltag.Add(key, chushenGridTextTONumber(chushen_Grid.Cell(r, 3).Text))
End If
Else
If G_celltag.ContainsKey(key) Then
G_celltag.Item(key) = chushen_Grid.Cell(r, 3).Text
Else
G_celltag.Add(key, chushen_Grid.Cell(r, 3).Text)
End If
End If
End If
Next
Else
For r = 1 To chushen_Grid.Rows - 1
'If String.IsNullOrEmpty(chushen_Grid.Cell(r, 2).Text) Then Continue For
Dim key As String = FunctionalTransformation(False, chushen_Grid.Cell(r, 1).Text)
' G_celltag.Add(key, chushen_Grid.Cell(r, 2).Text)
If G_celltag.ContainsKey(key) Then
G_celltag.Item(key) = chushen_Grid.Cell(r, 2).Text
Else
G_celltag.Add(key, chushen_Grid.Cell(r, 2).Text)
End If
Next
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
GetG_Result()
GetG_celltag()
GetGTcelltag()
GetNodeResult()
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
Return
End Sub
Public Sub GetNodeResult()
If IsNothing(DicDevicemodel) OrElse DicDevicemodel.Count = 0 Then
Return
End If
If IsNothing(G_grid) And G_Row = 0 Then Return
Dim cta = New CtabRange(G_grid, G_Row, TableColNumber.DeviceName)
If String.IsNullOrEmpty(cta.devname) Then Return
Dim loadtag As TableRowTag = G_ActionConfiguration(G_Row - 7)
If DicDevicemodel.ContainsKey(cta.devname) Then
Dim devmodw As DeviceModel = DicDevicemodel.Item(cta.devname)
For Each node In devmodw.Nodes
If node.Name.Equals(loadtag.G_DevNodeName) Then
For Each index In node.Nodes
If index.LoopAddr.Equals(loadtag.G_DevNodeIndex.ToString) Then
index.DefaultClass = ComboBox2.Text
End If
Next
End If
Next
End If
End Sub
Private Sub Cob_KeyType_TextChanged(sender As Object, e As EventArgs) Handles Cob_KeyType.TextChanged
GetG_Result()
SplitContainer4.Panel2Collapsed = True
Select Case Cob_KeyType.Text
Case "1365 所有卡插入", "2730 所有卡拔入", "1 客人卡插入", "2 客人卡拔入", "4 服务员卡插入",
"8 服务员卡拔入", "256 经理卡插入", "512 经理卡拔入", "1024 工程卡插入", "2048 工程卡拔入",
"4096 总管卡插入", "8192 总管卡拔入", "16384 高频卡插入", "32768 高频卡拔入"
'G_Row = 7
End Select
If G_Row = 7 Then
initTablechushen_Grid1()
Setingchushen_Grid()
Else
initTablechushen_Grid()
AddChushen_GridRow(Cob_KeyType.Text)
End If
ComboBox1_DropDown(Nothing, Nothing)
ComboBox1.Text = ""
ComboBox1.Enabled = True
If G_celltag.ContainsKey("CallRowA") Then
Label5.Text = G_celltag.Item("CallRowA")
ComboBox1.Enabled = False
End If
If G_celltag.ContainsKey("CallRow") Then
Dim callrow As String = G_celltag.Item("CallRow")
Dim buf() As String
For Each index In SceneNumber.Keys
buf = index.Split(" ")
If buf(0).Equals(callrow) Then
ComboBox1.Text = index
End If
Next
End If
End Sub
Public Sub initTablechushen_Grid1()
SplitContainer4.Panel2Collapsed = False
With chushen_Grid
.NewFile()
.Rows = 1
.Cols = 4
.ExtendLastCol = True
'.Cell(0, 1).Text = "功能名稱"
'.Cell(0, 2).Text = "功能方法"
.Column(3).CellType = CellTypeEnum.ComboBox
.Column(1).Width = 100
.Column(2).Width = 200
.Row(0).Visible = True
.Column(0).Visible = True
.Column(0).Visible = False
.Column(1).Locked = True
.Column(2).Locked = True
.Column(0).Locked = True
.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter
.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter
.Column(3).Alignment = FlexCell.AlignmentEnum.CenterCenter
End With
Dim li As New List(Of (String, String))
li.Add(("DIMMING", "调光渐变时间"))
li.Add(("MUSIC", "设置播放音量"))
addchushen_Gridrow(li)
End Sub
Public Sub addchushen_Gridrow(li As List(Of (String, String)))
For Each node In g_BasicClasses.DeviceClass
For Each index In li
If index.Item1.Equals(node.Name.ToUpper) Then
Select Case node.Name.ToUpper
Case "DIMMING"
chushen_Grid.AddItem("")
chushen_Grid.Row(chushen_Grid.Rows - 1).Locked = False
chushen_Grid.Cell(chushen_Grid.Rows - 1, 1).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = "50 可调下限设置(0-100)"
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 0
chushen_Grid.AddItem("")
chushen_Grid.Row(chushen_Grid.Rows - 1).Locked = False
chushen_Grid.Cell(chushen_Grid.Rows - 1, 1).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = "49 可调上限设置(0-100)"
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 90
chushen_Grid.AddItem("")
chushen_Grid.Row(chushen_Grid.Rows - 1).Locked = False
chushen_Grid.Cell(chushen_Grid.Rows - 1, 1).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = "48 主机调光百分比值(0-100)"
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Locked = True
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 80
Dim Nhradrow As Integer = chushen_Grid.Rows
For Each Anode In node.Methods
Select Case Anode.Name
Case "调光渐变时间"
chushen_Grid.AddItem("")
Dim hradrow As Integer = chushen_Grid.Rows - 1
chushen_Grid.Cell(hradrow, 1).Text = index.Item2
Dim valLi() As String
For i = 0 To Anode.Params.Count - 1
If i > 1 Then Return
Dim par As DeviceChildNodeMethodParam = Anode.Params(i)
If i = 1 Then
chushen_Grid.Cell(hradrow, 2 + i).Text = $"{par.Name}( 1(快) 至10 (慢) )"
Else
chushen_Grid.Cell(hradrow, 2 + i).Text = par.Name
End If
If par.Name.Equals("设置状态") Then
valLi = par.DataRange.Split(",")
For Each parval In valLi
chushen_Grid.AddItem("")
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = parval
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Mask = MaskEnum.Digital
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 3
Next
chushen_Grid.Column(1).Locked = False
chushen_Grid.Range(hradrow, 1, chushen_Grid.Rows - 1, 1).MergeCells = True
chushen_Grid.Column(1).Locked = True
chushen_Grid.Row(hradrow).Locked = True
End If
Next
End Select
Next
chushen_Grid.AddItem("")
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = "C8PLC自带恒压调光渐变时间"
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 3
chushen_Grid.AddItem("")
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = "C8PLC外设恒压调光渐变时间"
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 3
chushen_Grid.Row(Nhradrow).Locked = False
chushen_Grid.Column(1).Locked = False
chushen_Grid.Range(Nhradrow, 1, chushen_Grid.Rows - 1, 1).MergeCells = True
chushen_Grid.Column(1).Locked = True
chushen_Grid.Row(Nhradrow).Locked = True
Case "MUSIC"
For Each Anode In node.Methods
Select Case Anode.Name
Case "设置播放音量"
chushen_Grid.AddItem("")
Dim hradrow As Integer = chushen_Grid.Rows - 1
chushen_Grid.Cell(hradrow, 1).Text = index.Item2
Dim valLi() As String
For i = 0 To Anode.Params.Count - 1
If i > 1 Then Return
Dim par As DeviceChildNodeMethodParam = Anode.Params(i)
If i = 1 Then
chushen_Grid.Cell(hradrow, 2 + i).Text = $"{par.Name}(1(小)-10(大))"
Else
chushen_Grid.Cell(hradrow, 2 + i).Text = par.Name
End If
'
If par.Name.Equals("功能设置") Then
valLi = par.DataRange.Split(",")
For Each parval In valLi
If parval.Contains("音量加") OrElse parval.Contains("音量减") Then Continue For
chushen_Grid.AddItem("")
chushen_Grid.Cell(chushen_Grid.Rows - 1, 2).Text = parval
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Mask = MaskEnum.Digital
chushen_Grid.Cell(chushen_Grid.Rows - 1, 3).Text = 6
Next
chushen_Grid.Column(1).Locked = False
chushen_Grid.Range(hradrow, 1, chushen_Grid.Rows - 1, 1).MergeCells = True
chushen_Grid.Column(1).Locked = True
chushen_Grid.Row(hradrow).Locked = True
End If
Next
End Select
Next
End Select
End If
Next
Next
End Sub
Private Sub Cob_CarryOutType_TextChanged(sender As Object, e As EventArgs) Handles Cob_CarryOutType.TextChanged
GetG_Result()
End Sub
Private Sub Table_Grid1_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles Table_Grid1.CellChange
GetG_Result()
End Sub
Private Sub Table_Grid1_SetCellText(Sender As Object, e As Grid.SetCellTextEventArgs) Handles Table_Grid1.SetCellText
GetG_Result()
End Sub
Private Sub chushen_Grid_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs) Handles chushen_Grid.ComboDropDown
If e.Row > 0 Then
Me.chushen_Grid.ComboBox(e.Col).Items.Clear()
If G_Row = 7 Then
If e.Row < 4 Then
For index = 0 To 100
Me.chushen_Grid.ComboBox(e.Col).Items.Add(index)
Next
Else
'If chushen_Grid.Cell(e.Col, 2).Text.Contains("音量") Then
'ElseIf chushen_Grid.Cell(e.Col, 2).Text.Contains("时间") Then
' Me.chushen_Grid.ComboBox(e.Col).Items.AddRange({"5", "10", "20", "50", "80"})
If chushen_Grid.Cell(e.Row, e.Col - 1).Text.Equals("10 设定全局音量上限") Then
Me.chushen_Grid.ComboBox(e.Col).Items.AddRange({"4", "5", "6", "7", "8", "9", "10"})
Else
Me.chushen_Grid.ComboBox(e.Col).Items.AddRange({"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"})
End If
End If
Else
Dim liname As String = chushen_Grid.Cell(e.Row, 1).Text
Dim key As String = FunctionalTransformation(False, liname)
If Dic_2.ContainsKey(key) Then
Dim li As List(Of String) = Dic_2.Item(key)
Me.chushen_Grid.ComboBox(e.Col).Items.AddRange(li.ToArray)
End If
End If
End If
End Sub
'Public Sub IsckeckCelltag(kettype String)
' Select Case kettype
' Case "1 点按"
' DevEvenPar("DIMMING", "控制灯光", 0)
' SplitContainer4.Panel2Collapsed = False
' Case "3 长按"
' DevEvenPar("DIMMING", "循环调光", 0)
' SplitContainer4.Panel2Collapsed = False
' Case "2 长按释放"
' End Select
'End Sub
Private Sub chushen_Grid_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles chushen_Grid.CellChange
Dim liname As String = chushen_Grid.Cell(e.Row, 2).Text
Dim linamekey As String = chushen_Grid.Cell(e.Row, 1).Text
Dim cvalint As Integer = -1
If e.Col = 2 Then
Dim key As String = FunctionalTransformation(False, linamekey)
If String.IsNullOrEmpty(liname) Then Return
If Dic_2.ContainsKey(key) Then
Dim li As List(Of String) = Dic_2.Item(key)
For Each index In li
If index.Equals(liname) Then
Return
End If
Next
chushen_Grid.Cell(e.Row, 2).Text = ""
End If
End If
If e.Col = 3 Then
Dim linameval As String = chushen_Grid.Cell(e.Row, 3).Text
If Integer.TryParse(linameval, cvalint) Then
If e.Row > 4 AndAlso cvalint < 1 Then
chushen_Grid.Cell(e.Row, 3).Text = 1
End If
Dim ctx As String = chushen_Grid.Cell(e.Row, 2).Text
If chushen_Grid.Cell(e.Row, 2).Text.Equals("48 主机调光百分比值(0-100)") AndAlso cvalint > 100 Then
chushen_Grid.Cell(e.Row, 3).Text = 100
ElseIf chushen_Grid.Cell(e.Row, 2).Text.Equals("49 可调上限设置(0-100)") AndAlso cvalint > 100 Then
chushen_Grid.Cell(e.Row, 3).Text = 100
ElseIf chushen_Grid.Cell(e.Row, 2).Text.Equals("50 可调下限设置(0-100)") AndAlso cvalint > 100 Then
chushen_Grid.Cell(e.Row, 3).Text = 100
End If
If Not chushen_Grid.Cell(e.Row, 2).Text.Equals("48 主机调光百分比值(0-100)") AndAlso Not chushen_Grid.Cell(e.Row, 2).Text.Equals("50 可调下限设置(0-100)") AndAlso Not chushen_Grid.Cell(e.Row, 2).Text.Equals("49 可调上限设置(0-100)") AndAlso cvalint > 10 Then
chushen_Grid.Cell(e.Row, 3).Text = 10
End If
Else
If Me.chushen_Grid.ComboBox(e.Col).Items.Count > 0 Then
If Me.chushen_Grid.ComboBox(e.Col).Items.Contains(linameval) Then
Else
chushen_Grid.Cell(e.Row, 3).Text = Me.chushen_Grid.ComboBox(e.Col).Items(0)
End If
End If
End If
End If
End Sub
Public SceneNumber As Dictionary(Of String, String)
Private Sub ComboBox1_DropDown(sender As Object, e As EventArgs) Handles ComboBox1.DropDown
ComboBox1.Items.Clear()
SceneNumber.Clear()
If IsNothing(G_grid) And G_Row = 0 Then Return
Dim kettypebuf As String = Cob_KeyType.Text.Trim.Split(" ")
Dim loadtag As TableRowTag = G_ActionConfiguration(G_Row - 7)
ComboBox1.Items.Add("")
For r = 7 To G_grid.Rows - 1
If r = G_Row OrElse G_grid.Row(r).Locked Then Continue For
Dim rowtag As TableRowTag = G_ActionConfiguration(r - 7)
Dim buf As String = rowtag.G_DicRow(6).Trim.Split(",")
If loadtag.G_DevNodeName.Equals(rowtag.G_DevNodeName) AndAlso rowtag.G_KeyType.Contains(Cob_KeyType.Text) AndAlso kettypebuf(0).Equals(buf(0)) Then
Dim sval As String = $"{G_grid.Cell(r, 3).Text } {G_grid.Cell(r, 5).Text}"
If Not SceneNumber.ContainsKey(sval) Then
ComboBox1.Items.Add(sval)
SceneNumber.Add($"{sval}", r)
End If
End If
Next
End Sub
Public Shared Function ComboBox1DateDropDown(Tgrid As Grid, mytag As TableRowTag, ActionConfiguration As List(Of TableRowTag)) As Dictionary(Of String, String)
Dim dic As New Dictionary(Of String, String)
dic.Clear()
If IsNothing(Tgrid) Then Return dic
For r = 7 To Tgrid.Rows - 1
If Tgrid.Row(r).Locked Then Continue For
Dim rowtag As TableRowTag = ActionConfiguration(r - 7)
Dim kettypebuf As String = mytag.G_DicRow(6).Trim.Split(",")
Dim buf As String = rowtag.G_DicRow(6).Trim.Split(",")
Dim zhixin As String = ""
For Each nindex In rowtag.G_KeyType
If buf(0).Equals(nindex.Substring(0, 1)) Then
zhixin = nindex
Exit For
End If
Next
If kettypebuf.Length > 1 Then
If mytag.G_DevNodeName.Equals(rowtag.G_DevNodeName) AndAlso mytag.G_KeyType.Contains(zhixin) AndAlso kettypebuf(0).Equals(buf(0)) Then
dic.Add($"{Tgrid.Cell(r, 3).Text } {Tgrid.Cell(r, 5).Text}", r)
End If
Else
dic.Add($"{Tgrid.Cell(r, 3).Text } {Tgrid.Cell(r, 5).Text}", r)
End If
Next
Return dic
End Function
Public Sub EnableFrom(isbool As Boolean)
Cob_KeyType.Enabled = isbool
Cob_CarryOutType.Enabled = isbool
SplitContainer4.Enabled = isbool
End Sub
Private Sub ComboBox1_TextChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged
If isloadok Then
If IsNothing(SceneNumber) OrElse SceneNumber.Count = 0 OrElse String.IsNullOrEmpty(ComboBox1.Text) Then
G_grid.Row(G_Row).Locked = False
EnableFrom(True)
Return
End If
If SceneNumber.ContainsKey(ComboBox1.Text) Then
Console.WriteLine(ComboBox1.Text)
' MsgBox("启用并联设置,将清除本行所有设置。请确认!!!" MsgBoxStyle.OkCancel)
Dim row As Integer = SceneNumber.Item(ComboBox1.Text)
If MsgBox("启用并联设置,将清除本行所有设置。请确认!!!" MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
' G_grid.Range(G_Row, 7, G_Row, G_grid.Cols - 5).ClearAll()
G_grid.Row(G_Row).Locked = True
EnableFrom(False)
Else
ComboBox1.SelectedIndex = 0
G_grid.Row(G_Row).Locked = False
EnableFrom(True)
End If
Console.WriteLine(ComboBox1.Text)
Else
EnableFrom(True)
End If
Else
If String.IsNullOrEmpty(ComboBox1.Text) Then
EnableFrom(True)
Else
EnableFrom(False)
End If
End If
End Sub
Public Sub clearcelltext(r As Integer)
For c = 6 To G_grid.Cols - 1
If G_grid.Column(c).Visible = False Then Continue For
G_grid.Cell(r, c).Text = ""
Next
End Sub
End Class