Imports System.Text Public Class Form1 Public Isoneload As Boolean = False Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '设置界面显示项目名称及版本 Me.Text = "NoCarPowerSupply_" & My.Application.Info.Version.ToString Isoneload = False InitIfGrid1() InitPortTable1() Isoneload = True End Sub Public isxiugai1 As Boolean = False Public Sub InitPortTable1() PortTable.NewFile() PortTable.ExtendLastCol = False PortTable.Cols = 9 PortTable.Rows = 6 PortTable.Cell(0, 0).Text = "端口" PortTable.Cell(0, 1).Text = "别名" PortTable.Cell(0, 2).Text = "输入端口(需要先在主页设置输入回路别名)" PortTable.Cell(0, 3).Text = "无人->有人阈值(百分比)" PortTable.Cell(0, 4).Text = "有人->无人阈值(百分比)" PortTable.Cell(0, 5).Text = "启用" PortTable.Cell(0, 6).Text = "检测时间" PortTable.Cell(0, 7).Text = "检测时间单位" PortTable.Cell(0, 8).Text = "数据" PortTable.Row(0).Locked = True PortTable.Column(0).Width = 100 PortTable.Column(1).Width = 80 PortTable.Column(2).Width = 250 PortTable.Column(3).Width = 150 PortTable.Column(4).Width = 150 PortTable.Column(5).Width = 30 PortTable.Column(6).Width = 60 PortTable.Column(7).Width = 80 PortTable.Column(8).Width = 20 ' PortTable.Column(1).CellType = FlexCell.CellTypeEnum.ComboBox 'PortTable.Column(2).CellType = FlexCell.CellTypeEnum.ComboBox PortTable.Column(3).CellType = FlexCell.CellTypeEnum.ComboBox PortTable.Column(4).CellType = FlexCell.CellTypeEnum.ComboBox PortTable.Column(5).CellType = FlexCell.CellTypeEnum.CheckBox PortTable.Column(6).CellType = FlexCell.CellTypeEnum.ComboBox PortTable.Column(7).CellType = FlexCell.CellTypeEnum.ComboBox PortTable.Column(8).CellType = FlexCell.CellTypeEnum.Button ''PortTable.Column(1).Locked = True 'PortTable.ComboBox(2).Locked = True 'PortTable.ComboBox(3).Locked = True 'PortTable.ComboBox(4).Locked = True ''PortTable.ComboBox(5).Locked = True 'PortTable.ComboBox(6).Locked = True 'PortTable.ComboBox(7).Locked = True PortTable.Column(0).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(3).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(7).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(4).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(5).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(6).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(7).Alignment = FlexCell.AlignmentEnum.CenterCenter PortTable.Column(8).Alignment = FlexCell.AlignmentEnum.CenterCenter isxiugai1 = False Dim sbuf() As String For i = 1 To 5 PortTable.Cell(i, 1).Text = " " If i = 1 Then PortTable.Cell(i, 0).Text = "有卡取电" Else PortTable.Cell(i, 0).Text = $"无卡取电 CH {i - 1}" End If PortTable.Cell(i, 1).Text = GetPortName(i) PortTable.Cell(i, 2).Text = i PortTable.Cell(i, 3).Text = 0 PortTable.Cell(i, 4).Text = 0 PortTable.Cell(i, 5).Text = 0 PortTable.Cell(i, 6).Text = 0 PortTable.Cell(i, 7).Text = "秒" 'If i < 4 Then ' PortTable.Cell(i, 3).Text = 0 ' If i = 2 Or i = 3 Then ' PortTable.Cell(i, 4).Locked = True ' PortTable.Cell(i, 3).Locked = True ' End If 'Else 'PortTable.Cell(i, 3).Text = 50 'If i = 6 Then ' PortTable.Cell(i, 3).Text = 10 ' End If 'End If Next isxiugai1 = True End Sub Public Function GetPortName(rowindex As Integer) Dim result As String = String.Empty Select Case rowindex Case 1 result = "有卡取电" Case 2 result = "开门磁" Case 3 result = "门口红外" Case 4 result = "卫红外" Case 5 result = "浴红外" Case 6 result = "床头红外" Case 7 result = "镜前红外" Case 8 result = "休闲红外" Case 9 result = "客厅红外" Case 10 result = "厅卫红外" Case 11 result = "浴缸红外" End Select Return result End Function Private IfGridRowdic As Dictionary(Of String, List(Of String)) Public Sub InitIfGrid1() IfGrid.NewFile() IfGrid.ExtendLastCol = False IfGrid.Cols = 21 IfGrid.Rows = 1 IfGrid.Cell(0, 1).Text = "条件组" IfGrid.Cell(0, 2).Text = "条件序号" IfGrid.Cell(0, 3).Text = "有无人标记" IfGrid.Cell(0, 4).Text = "端口1" IfGrid.Cell(0, 5).Text = "端口2" IfGrid.Cell(0, 6).Text = "端口3" IfGrid.Cell(0, 7).Text = "端口4" IfGrid.Cell(0, 8).Text = "端口5" IfGrid.Cell(0, 9).Text = "端口6" IfGrid.Cell(0, 10).Text = "端口7" IfGrid.Cell(0, 11).Text = "端口8" IfGrid.Cell(0, 12).Text = "端口9" IfGrid.Cell(0, 13).Text = "端口10" IfGrid.Cell(0, 14).Text = "端口11" IfGrid.Cell(0, 15).Text = "触发阈值" IfGrid.Cell(0, 16).Text = "持续判定时间" IfGrid.Cell(0, 17).Text = "持续判定时间单位" IfGrid.Cell(0, 18).Text = "条件组超时时间" IfGrid.Cell(0, 19).Text = "条件组超时时间单位" IfGrid.Cell(0, 20).Text = "数据" For n = 9 To 14 IfGrid.Column(n).Visible = False Next IfGrid.Column(3).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(4).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(5).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(6).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(7).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(8).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(9).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(10).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(11).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(12).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(13).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(14).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(15).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(16).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(17).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(18).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(19).CellType = FlexCell.CellTypeEnum.ComboBox IfGrid.Column(20).CellType = FlexCell.CellTypeEnum.Button IfGrid.Column(0).Width = 0 IfGrid.Column(1).Width = 50 IfGrid.Column(2).Width = 60 IfGrid.Column(3).Width = 60 IfGrid.Column(4).Width = 60 IfGrid.Column(5).Width = 60 IfGrid.Column(6).Width = 60 IfGrid.Column(7).Width = 60 IfGrid.Column(8).Width = 60 IfGrid.Column(9).Width = 60 IfGrid.Column(10).Width = 60 IfGrid.Column(11).Width = 60 IfGrid.Column(12).Width = 60 IfGrid.Column(13).Width = 60 IfGrid.Column(14).Width = 60 IfGrid.Column(15).Width = 60 IfGrid.Column(16).Width = 60 IfGrid.Column(17).Width = 60 IfGrid.Column(18).Width = 60 IfGrid.Column(19).Width = 60 IfGrid.Column(20).Width = 20 IfGrid.Column(0).Visible = True 'IfGrid.Column(1).Locked = True 'IfGrid.Column(2).Locked = True 'IfGrid.ComboBox(3).Locked = True 'IfGrid.ComboBox(5).Locked = True 'IfGrid.ComboBox(6).Locked = True 'IfGrid.ComboBox(7).Locked = True 'IfGrid.ComboBox(11).Locked = True 'IfGrid.ComboBox(12).Locked = True 'IfGrid.ComboBox(4).Locked = True 'IfGrid.ComboBox(8).Locked = True 'IfGrid.ComboBox(9).Locked = True 'IfGrid.ComboBox(10).Locked = True 'IfGrid.ComboBox(13).Locked = True 'IfGrid.ComboBox(14).Locked = True 'IfGrid.ComboBox(15).Locked = True 'IfGrid.ComboBox(16).Locked = True 'IfGrid.ComboBox(17).Locked = True 'IfGrid.ComboBox(18).Locked = True 'IfGrid.ComboBox(19).Locked = True IfGrid.Column(0).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(3).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(4).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(5).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(6).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(7).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(8).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(9).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(10).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(11).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(12).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(13).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(14).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(15).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(16).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(17).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(18).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(19).Alignment = FlexCell.AlignmentEnum.CenterCenter IfGrid.Column(15).Visible = False ' IfGrid.Column(18).Visible = False BuildTableRow1() End Sub Public Sub BuildTableRow1() IfGridRowdic = New Dictionary(Of String, List(Of String)) IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"开门" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 2 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"关门" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") Dim startR As Integer = IfGrid.Rows - 1 IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 2 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 4 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 5 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 6 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 7 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 8 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 3 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 9 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "无人至有人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"触发" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"1" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"秒" IfGrid.Column(1).Locked = False IfGrid.Range(startR, 1, IfGrid.Rows - 1, 1).Merge() IfGrid.Range(startR, 18, IfGrid.Rows - 1, 18).Merge() IfGrid.Range(startR, 19, IfGrid.Rows - 1, 19).Merge() IfGrid.Column(1).Locked = True IfGrid.AddItem("") startR = IfGrid.Rows - 1 IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 4 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "短暂离开" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"开至关" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 4 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 2 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "短暂离开" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"关门" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" IfGrid.Column(1).Locked = False IfGrid.Range(startR, 1, IfGrid.Rows - 1, 1).Merge() IfGrid.Range(startR, 18, IfGrid.Rows - 1, 18).Merge() IfGrid.Range(startR, 19, IfGrid.Rows - 1, 19).Merge() IfGrid.Column(1).Locked = True IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 5 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "长期离开" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"开门" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = 6 IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = 1 IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "有人至无人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"开门" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"释放" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" IfGridRowdic.Clear() Dim headname As CtabRange Dim keystr As String = String.Empty Dim li As List(Of String) For i = 1 To IfGrid.Rows - 1 headname = New CtabRange(IfGrid, i, 1) ' IfGrid.Cell(i, 1).Tag If IfGridRowdic.ContainsKey(headname.devname) Then li = IfGridRowdic.Item(headname.devname) Else li = New List(Of String) IfGridRowdic.Add(headname.devname, li) End If For j = 2 To IfGrid.Cols - 1 'If IfGrid.Column(j).Locked Then ' Continue For 'End If keystr = $"{keystr},{IfGrid.Cell(i, j).Text}" Next keystr = keystr.Remove(0, 1) li.Add(keystr) keystr = String.Empty Next End Sub Private Sub PortTable_CellChange(Sender As Object, e As FlexCell.Grid.CellChangeEventArgs) Handles PortTable.CellChange If e.Row > 0 AndAlso e.Col = 1 Then Dim headname As String = PortTable.Cell(e.Row, e.Col).Text.Trim IfGrid.Cell(0, e.Row + 3).Text = headname If String.IsNullOrEmpty(headname) Then IfGrid.Column(e.Row + 3).Locked = True Else IfGrid.Column(e.Row + 3).Locked = False End If ElseIf e.Row > 0 AndAlso e.Col = 2 Then 'Dim addr As String = PortTable.Cell(e.Row, e.Col).Text 'If String.IsNullOrEmpty(addr) Then ' PortTable.Cell(e.Row, e.Col).Tag = "" 'Else ' ParseDevDic.Item(PortTable.Cell(e.Row, e.Col - 1).Text).Item(addr).Values(0).ToArray() 'End If 'ElseIf e.Row > 0 AndAlso e.Col = 4 Then ' Dim typestr As String = PortTable.Cell(e.Row, e.Col - 2).Text ' Dim addr As String = PortTable.Cell(e.Row, e.Col - 1).Text ' Dim nloop As String = PortTable.Cell(e.Row, e.Col).Text ' If String.IsNullOrEmpty(addr) OrElse String.IsNullOrEmpty(typestr) Then ' PortTable.Cell(e.Row, e.Col).Text = "" ' MsgBox("请先选择端口类型!") ' Return ' End If ' For Each index In ParseDevDic.Item(typestr).Item(addr).Values(0).ToArray ' If index.Item1.Equals(nloop) AndAlso isxiugai1 Then ' PortTable.Cell(e.Row, 1).Text = index.Item2 ' End If ' Next End If End Sub Private Sub PortTable_ComboDropDown(Sender As Object, e As FlexCell.Grid.ComboDropDownEventArgs) Handles PortTable.ComboDropDown Dim headname As String = PortTable.Cell(0, e.Col).Text Select Case e.Col 'Case 2 ' PortTable.ComboBox(e.Col).Items.Clear() ' PortTable.ComboBox(e.Col).Items.Add(" ") ' PortTable.ComboBox(e.Col).Items.AddRange({"1"}) 'Case "端口地址" ' Dim addr As String = PortTable.Cell(e.Row, e.Col - 1).Text ' If String.IsNullOrEmpty(addr) Then ' MsgBox("请先选择端口类型!") ' Return ' End If ' PortTable.ComboBox(e.Col).Items.Clear() ' PortTable.ComboBox(e.Col).Items.AddRange(ParseDevDic.Item(addr).Keys.ToArray) 'Case "端口回路" ' Dim typestr As String = PortTable.Cell(e.Row, e.Col - 2).Text ' Dim addr As String = PortTable.Cell(e.Row, e.Col - 1).Text ' If String.IsNullOrEmpty(addr) OrElse String.IsNullOrEmpty(typestr) Then ' MsgBox("请先选择端口类型!") ' Return ' End If ' PortTable.ComboBox(e.Col).Items.Clear() ' For Each index In ParseDevDic.Item(typestr).Item(addr).Values(0).ToArray ' PortTable.ComboBox(e.Col).Items.Add(index.Item1) ' Next ' 'PortTable.ComboBox(e.Col).Items.AddRange(ParseDevDic.Item(typestr).Item(addr).Values(0).ToArray) ' PortTable.Cell(e.Row, e.Col).Tag = ParseDevDic.Item(typestr).Item(addr).Keys(0) 'PortTable.Cell(e.Row, 1).Text = Case 3, 4 PortTable.ComboBox(e.Col).Items.Clear() For i = 0 To 100 PortTable.ComboBox(e.Col).Items.Add(i) Next Case 6 PortTable.ComboBox(e.Col).Items.Clear() For i = 0 To 255 PortTable.ComboBox(e.Col).Items.Add(i) Next Case 7 PortTable.ComboBox(e.Col).Items.Clear() PortTable.ComboBox(e.Col).Items.AddRange({"秒", "分", "时"}) End Select End Sub Public IsnotCellChange As Boolean Private Sub IfGrid_CellChange(Sender As Object, e As FlexCell.Grid.CellChangeEventArgs) Handles IfGrid.CellChange If e.Row = 0 Then Return Dim celltext As String = IfGrid.Cell(e.Row, e.Col).Text If celltext.Contains("无人至有人") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.Blue If IsnotCellChange Then Return IsnotCellChange = True Dim ta As CtabRange ta = New CtabRange(IfGrid, e.Row, 1) For i = ta.fr To ta.lr IfGrid.Cell(i, e.Col).Text = "无人至有人" Next IsnotCellChange = False ElseIf celltext.Contains("有人至无人") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.Orange If IsnotCellChange Then Return IsnotCellChange = True Dim ta As CtabRange ta = New CtabRange(IfGrid, e.Row, 1) For i = ta.fr To ta.lr IfGrid.Cell(i, e.Col).Text = "有人至无人" Next IsnotCellChange = False ElseIf celltext.Contains("短暂离开") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.Brown If IsnotCellChange Then Return IsnotCellChange = True Dim ta As CtabRange ta = New CtabRange(IfGrid, e.Row, 1) For i = ta.fr To ta.lr IfGrid.Cell(i, e.Col).Text = "短暂离开" Next '从ta.fr 行往第一行查找 For i = ta.fr To 1 Step -1 If IfGrid.Cell(i, e.Col).Text.Trim.Equals("长期离开") OrElse IfGrid.Cell(i, e.Col).Text.Trim.Equals("有人至无人") Then IfGrid.Cell(i, e.Col).Text = "短暂离开" End If Next If Isoneload Then If ta.lr = IfGrid.Rows - 1 Then MsgBox("短暂离开不能作为最后一行,请以'有人至无人'作为最后一行!") Return End If End If For i = ta.lr To IfGrid.Rows - 1 If IfGrid.Cell(i, e.Col).Text.Trim.Equals("无人至有人") Then IfGrid.Cell(i, e.Col).Text = "有人至无人" End If Next IsnotCellChange = False ElseIf celltext.Contains("长期离开") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.Violet If IsnotCellChange Then Return IsnotCellChange = True Dim ta As CtabRange ta = New CtabRange(IfGrid, e.Row, 1) For i = ta.fr To ta.lr IfGrid.Cell(i, e.Col).Text = "长期离开" Next '从ta.fr 行往第一行查找 For i = ta.fr To 1 Step -1 If IfGrid.Cell(i, e.Col).Text.Trim.Equals("有人至无人") Then IfGrid.Cell(i, e.Col).Text = "长期离开" End If Next If Isoneload Then If ta.lr = IfGrid.Rows - 1 Then MsgBox("长期离开 不能作为最后一行,请以'有人至无人'作为最后一行!") Return End If End If For i = ta.lr + 1 To IfGrid.Rows - 1 If IfGrid.Cell(i, e.Col).Text.Trim.Equals("短暂离开") OrElse IfGrid.Cell(i, e.Col).Text.Trim.Equals("无人至有人") OrElse IfGrid.Cell(i, e.Col).Text.Trim.Equals("长期离开") Then IfGrid.Cell(i, e.Col).Text = "有人至无人" End If Next IsnotCellChange = False ElseIf celltext.Contains("释放") OrElse celltext.Contains("开门") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.Green ElseIf celltext.Contains("不判断") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.LightGray ElseIf celltext.Contains("触发") OrElse celltext.Contains("关门") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.OrangeRed ElseIf celltext.Contains("关至开") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.MediumVioletRed ElseIf celltext.Contains("开至关") Then IfGrid.Cell(e.Row, e.Col).ForeColor = Color.LightGreen End If Dim na, nb As CtabRange na = New CtabRange(IfGrid, e.Row, 18) nb = New CtabRange(IfGrid, e.Row, 19) If String.IsNullOrEmpty(IfGrid.Cell(e.Row, 16).Text) OrElse String.IsNullOrEmpty(IfGrid.Cell(e.Row, 17).Text) OrElse String.IsNullOrEmpty(na.devname) OrElse String.IsNullOrEmpty(nb.devname) Then Else Dim ct, nt As Double IfGrid.Cell(e.Row, 16).BackColor = Color.White IfGrid.Cell(e.Row, 17).BackColor = Color.White IfGrid.Cell(e.Row, 18).BackColor = Color.White IfGrid.Cell(e.Row, 19).BackColor = Color.White ct = GetTableTimeUnit(IfGrid.Cell(e.Row, 16).Text, IfGrid.Cell(e.Row, 17).Text) nt = GetTableTimeUnit(na.devname, nb.devname) If nt = 0 Then MsgBox("条件组超时时间不能为0!") IfGrid.Cell(e.Row, e.Col).BackColor = Color.OrangeRed Return End If If ct > nt Then MsgBox("条件延时时间不能大于条件组超时时间!") IfGrid.Cell(e.Row, e.Col).BackColor = Color.OrangeRed Return End If End If End Sub '将时间单位转换为秒、 Public Function GetTableTimeUnit(ntime As String, timeunit As String) As Integer If ntime.Equals("") OrElse timeunit.Equals("") Then Return 0 '判断时间单位是 时、分、秒 If timeunit.Equals("时") Then Return CInt(ntime) * 3600 ElseIf timeunit.Equals("分") Then Return CInt(ntime) * 60 ElseIf timeunit.Equals("秒") Then Return CInt(ntime) End If End Function Private Sub IfGrid_ComboDropDown(Sender As Object, e As FlexCell.Grid.ComboDropDownEventArgs) Handles IfGrid.ComboDropDown Dim headname As String = IfGrid.Cell(0, e.Col).Text If e.Col = 3 Then IfGrid.ComboBox(e.Col).Items.Clear() IfGrid.ComboBox(e.Col).Items.AddRange({"无人至有人", "有人至无人", "短暂离开", "长期离开"}) ElseIf e.Col = 5 Then IfGrid.ComboBox(e.Col).Items.Clear() IfGrid.ComboBox(e.Col).Items.AddRange({"不判断", "开门", "关门", "关至开", "开至关"}) ElseIf e.Col = 4 OrElse (e.Col >= 6 AndAlso e.Col < 15) Then IfGrid.ComboBox(e.Col).Items.Clear() IfGrid.ComboBox(e.Col).Items.AddRange({"不判断", "触发", "释放"}) ElseIf e.Col = 15 OrElse e.Col = 16 OrElse e.Col = 18 Then IfGrid.ComboBox(e.Col).Items.Clear() For i = 0 To 255 IfGrid.ComboBox(e.Col).Items.Add(i) Next ElseIf e.Col = 17 OrElse e.Col = 19 Then IfGrid.ComboBox(e.Col).Items.Clear() IfGrid.ComboBox(e.Col).Items.AddRange({"秒", "分", "时"}) End If End Sub Private Sub PortTable_ButtonClick(Sender As Object, e As FlexCell.Grid.ButtonClickEventArgs) Handles PortTable.ButtonClick Dim nt As Integer = -1 Integer.TryParse(PortTable.Cell(e.Row, 2).Text.Trim, nt) If nt = -1 Then MsgBox("请输入正确的端口地址!") Return End If Dim Tstr As String = String.Empty For c = 1 To PortTable.Cols - 2 If c = 2 Then Tstr = $"{Tstr}{nt}," Continue For End If Tstr = $"{Tstr}{PortTable.Cell(e.Row, c).Text.Trim}," Next ' "有卡取电,插卡(1),0,0,0,0,秒,1,2,0" Tstr = Tstr.Substring(0, Tstr.Length - 1) Dim buf As Byte() Try buf = GetPortInformation1(e.Row, Tstr) Catch ex As Exception MsgBox("生成数据失败!") Return End Try If buf Is Nothing OrElse buf.Length = 0 Then MsgBox("生成数据失败!") Return End If Dim data As New List(Of Byte()) data.Add(buf) data = FillDataFrames(data) Dim str As String = BytesToHexString(data(0)) Clipboard.SetText(str) End Sub Public Function BytesToHexString(ByVal bytes As Byte()) As String If bytes Is Nothing OrElse bytes.Length = 0 Then Return String.Empty End If Dim hex As New StringBuilder(bytes.Length * 3) ' 每个字节需要2个字符+1个空格 For i As Integer = 0 To bytes.Length - 1 ' 如果不是第一个字节,先添加一个空格 If i > 0 Then hex.Append(" ") End If hex.AppendFormat("{0:x2}", bytes(i)) Next Return hex.ToString() End Function Public Function GetPortInformation1(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(2) Data.Add(1) Data.AddRange(BitConverter.GetBytes(CShort(CInt(strbuf(1))))) 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(4)) OrElse strbuf(4).Equals("0") Then Data.Add(0) Else Data.Add(1) End If If String.IsNullOrEmpty(strbuf(5)) OrElse strbuf(5).Equals("0") Then Data.AddRange(BitConverter.GetBytes(CShort(0))) Else Data.AddRange(BitConverter.GetBytes(CShort(CInt(strbuf(5))))) End If Data.Add(GetGlossary8(strbuf(6))) If String.IsNullOrEmpty(strbuf(3)) Then Data.Add(0) Else Data.Add(CInt(strbuf(3))) End If Return Data.ToArray End Function Public Function GetGlossary8(sb As String) As Byte Dim result As Byte = 0 Select Case sb Case "秒" result = 1 Case "分" result = 2 Case "时" result = 3 Case Else result = 0 End Select Return result End Function Public Function FillDataFrames(data As List(Of Byte())) As List(Of Byte()) Dim result As New List(Of Byte()) Dim index As Short = 1 Dim count As Short = data.Count Dim frameBuf As List(Of Byte) Dim num As Integer = 0 For Each buf As Byte() In data num = num + buf.Length frameBuf = New List(Of Byte) '包头(2位) frameBuf.Add(&HCC) frameBuf.Add(&HC0) '长度(2位) Dim length As Short = buf.Length + 10 frameBuf.AddRange(BitConverter.GetBytes(length)) 'CRC校验(2位) frameBuf.AddRange(New Byte() {0, 0}) '帧号(2位) frameBuf.AddRange(BitConverter.GetBytes(index)) '帧总数(2位) frameBuf.AddRange(BitConverter.GetBytes(count)) ''帧类型(1位) 'frameBuf.Add(type) '帧参数(不定长) frameBuf.AddRange(buf) Dim crc() As Byte = GetCRC16CheckSum(frameBuf.ToArray, frameBuf.Count) frameBuf(4) = crc(0) frameBuf(5) = crc(1) index += 1 result.Add(frameBuf.ToArray) Next 'Dim themore As Integer = num Mod 4 'Console.WriteLine(num) 'For isnum As Integer = 1 To (4 - themore) ' result(result.Count -1).Add({0}) 'Next Return result End Function ''' ''' CRC16校验 ''' ''' ''' ''' Public Function GetCRC16CheckSum(dataBuff() As Byte, length As Integer) As Byte() Dim crc16 As UInteger Dim crcBytes() As Byte crc16 = &HFFFF For i = 0 To length - 1 crc16 = crc16 And &HFFFF crc16 = crc16 Xor dataBuff(i) For bit = 0 To 7 crc16 = IIf((crc16 And 1) = 0, crc16 >> 1, (crc16 >> 1) Xor &HA001) Next Next crc16 = crc16 And &HFFFF crcBytes = BitConverter.GetBytes(UShort.Parse(crc16)) Return crcBytes End Function Private Sub IfGrid_ButtonClick(Sender As Object, e As FlexCell.Grid.ButtonClickEventArgs) Handles IfGrid.ButtonClick Dim buf As Byte() Try buf = GetConditionalInformation1(e) Catch ex As Exception MsgBox("生成数据失败!") Return End Try If buf Is Nothing OrElse buf.Length = 0 Then MsgBox("生成数据失败!") Return End If Dim data As New List(Of Byte()) data.Add(buf) data = FillDataFrames(data) Dim str As String = BytesToHexString(data(0)) Clipboard.SetText(str) End Sub ' IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" 'IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" 'IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" 'IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" 'IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" Public Function GetConditionalInformation1(e As FlexCell.Grid.ButtonClickEventArgs) As Byte() Dim cmd As Byte = &H8 Dim Data = New List(Of Byte) Dim headname = New CtabRange(IfGrid, e.Row, 1) Data.Add(cmd) Data.Add(GetNoCarDataKeyVal(IfGrid.Cell(e.Row, 3).Text.Trim)) Data.Add(CInt(headname.devname)) Data.Add(CInt(IfGrid.Cell(e.Row, 2).Text.Trim)) Data.AddRange(BitConverter.GetBytes(CShort(CInt(IfGrid.Cell(e.Row, 16).Text.Trim)))) Data.Add(GetGlossary8(IfGrid.Cell(e.Row, 17).Text.Trim)) For i = 4 To 8 '11变成10 'nbbuf = strbuf(i + 1).Split(":") Data.Add(GetNoCarDataKeyVal(IfGrid.Cell(e.Row, i).Text.Trim)) 'i 加 1 编程 i+2 Next headname = New CtabRange(IfGrid, e.Row, 18) Data.AddRange(BitConverter.GetBytes(CShort(CInt(headname.devname.Trim)))) headname = New CtabRange(IfGrid, e.Row, 19) Data.Add(GetGlossary8(headname.devname.Trim)) Return Data.ToArray End Function Public Shared Function GetNoCarDataKeyVal(keystr As String) As Integer If keystr.Contains("无人至有人") Then Return 1 ElseIf keystr.Contains("有人至无人") Then Return 2 ElseIf keystr.Contains("释放") OrElse keystr.Contains("开门") Then Return 2 ElseIf keystr.Contains("不判断") Then Return 0 ElseIf keystr.Contains("触发") OrElse keystr.Contains("关门") Then Return 1 ElseIf keystr.Contains("关至开") OrElse keystr.Contains("长期离开") Then Return 4 ElseIf keystr.Contains("开至关") OrElse keystr.Contains("短暂离开") Then Return 3 End If Return 0 End Function Private Sub ToolStripButton4_Click(sender As Object, e As EventArgs) Handles ToolStripButton4.Click Dim headname As CtabRange = New CtabRange(IfGrid, IfGrid.ActiveCell.Row, 1) Dim number As Integer = 0 Dim number1 As Integer = 1 Dim frow As CtabRange For i = headname.fr To headname.lr IfGrid.Row(headname.lr - number).Delete() number = number + 1 Next For i = 2 To IfGrid.Rows - 1 headname = New CtabRange(IfGrid, i, 1) frow = New CtabRange(IfGrid, i - 1, 1) If (CInt(headname.devname) - CInt(frow.devname) > 1) Then number1 = CInt(headname.devname) IfGrid.Cell(headname.fr, headname.fc).Text = (CInt(frow.devname) + 1) Else End If Next 'Isoneload = False ' InitIfGrid1(UniqueDevice.Desc.DevDescription) ' Isoneload = True End Sub Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click Dim headname As String = IfGrid.Cell(IfGrid.ActiveCell.Row, 2).Text If headname.Equals("1") Then Return Dim inrow As Integer = IfGrid.ActiveCell.Row Dim Number = Integer.Parse(IfGrid.Cell(inrow, 2).Text) Dim li As List(Of String) Dim indexstr As CtabRange = New CtabRange(IfGrid, IfGrid.ActiveCell.Row, 1) li = IfGridRowdic.Item(indexstr.devname) li.RemoveAt(Number - 1) IfGrid.Row(IfGrid.ActiveCell.Row).Delete() For i = Number To li.Count IfGrid.Cell(inrow, 2).Text = i inrow = inrow + 1 Next End Sub Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click Dim i As String = (CInt(New CtabRange(IfGrid, IfGrid.Rows - 1, 1).devname) + 1) Dim li As List(Of String) = New List(Of String) IfGrid.AddItem("") IfGrid.Cell(IfGrid.Rows - 1, 1).Text = $"{i}" IfGrid.Cell(IfGrid.Rows - 1, 1).Tag = $"{i}" IfGrid.Cell(IfGrid.Rows - 1, 2).Text = 1 IfGrid.Cell(IfGrid.Rows - 1, 3).Text = "有人至无人" IfGrid.Cell(IfGrid.Rows - 1, 4).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 5).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 6).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 7).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 8).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 9).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 10).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 11).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 12).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 13).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 14).Text = $"不判断" IfGrid.Cell(IfGrid.Rows - 1, 15).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 16).Text = $"0" IfGrid.Cell(IfGrid.Rows - 1, 17).Text = $"秒" IfGrid.Cell(IfGrid.Rows - 1, 18).Text = $"10" IfGrid.Cell(IfGrid.Rows - 1, 19).Text = $"分" li.Add($"{i},1,1,不判断,不判断,不判断,不判断,不判断,不判断,不判断,不判断,不判断,不判断,不判断,0,秒") IfGridRowdic.Add(i, li) End Sub Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click AddIfGridRow() End Sub Public Sub AddIfGridRow() Dim inrow As Integer = IfGrid.ActiveCell.Row IfGrid.InsertRow(inrow, 1) Dim li As List(Of String) Dim nodestr As String = String.Empty Dim number As Integer For i = 0 To IfGrid.Cols - 1 Dim indexstr As String = (New CtabRange(IfGrid, inrow + 1, 1)).devname li = IfGridRowdic.Item(indexstr) IfGrid.Cell(inrow, i).Text = IfGrid.Cell(inrow + 1, i).Text If i = 1 Then IfGrid.Cell(inrow, i).Tag = (New CtabRange(IfGrid, inrow + 1, 1)).devname ElseIf i = 2 Then number = Integer.Parse(IfGrid.Cell(inrow + 1, 2).Text) End If nodestr = $"{nodestr},{ IfGrid.Cell(inrow + 1, i).Text}" Next IfGrid.Column(1).Locked = False IfGrid.Range(inrow, 1, inrow + 1, 1).Merge() If IfGrid.Cols > 19 Then IfGrid.Range(inrow, 18, inrow + 1, 18).Merge() IfGrid.Range(inrow, 19, inrow + 1, 19).Merge() End If IfGrid.Column(1).Locked = True nodestr = nodestr.Remove(0, 1) li.Add(nodestr) For i = number To li.Count IfGrid.Cell(inrow, 2).Text = i inrow = inrow + 1 Next End Sub End Class