zwaveupnpbridgeform.cs

来自「zwave 无线通讯协议 PC controller 控制器源码」· CS 代码 · 共 1,362 行 · 第 1/5 页

CS
1,362
字号

                case ZensysBridgedDevice.ZWaveDeviceTypes.SWITCH_MULTILEVEL:
                    {
                        nameStr = "Dimmable Light " + node.ToString("000") + " (" + labelHomeID.Text + ", " + labelNodeID.Text + ")";
                        if (down)
                        {
                            device = ZensysUPnPAddRootDevice((ZensysBridgedDevice.ZWaveDeviceTypes)nodeType, nameStr, node, (bridgeIt) ? ZensysBridgedDevice.ZWaveBridgeDeviceState.Started : ZensysBridgedDevice.ZWaveBridgeDeviceState.Stopped);
                        }
                        break;
                    }

                default:
                    break;
            }
            ZensysZWaveAddDevice(node, nodeType, (ZensysBridgedDevice.ZWaveDeviceTypes)nodeType, device, !down);
        }


        // TODO - BRIDGEWORK
        /// <summary>
        /// Called when a ZWave node has been removed from the ZWave network
        /// </summary>
        /// <param name="nodeID">node Id on the removed ZWave node</param>
        private void ZensysRemoveDevice(byte nodeId)
        {
            if (ZWaveNodes.ContainsKey(nodeId))
            {
                ZensysBridgedDevice dev = ((ZWaveNode)ZWaveNodes[nodeId]).DevBridge;
                // If any device attached then we must stop and
                if (dev != null)
                {
                    switch (dev.BridgeType)
                    {
                        case ZensysBridgedDevice.ZWaveBridgeTypes.UPnP:
                            {
                                ZWaveUPnPDeviceStop(dev);
                                UPnPdownDeviceList.Remove(dev);
                                break;
                            }

                        case ZensysBridgedDevice.ZWaveBridgeTypes.UPnP2ZWave:
                            if (((ZensysUPnPDevice)dev).DeviceUPnPType == ZensysUPnPDevice.UPnPDeviceTypes.AVRenderer)
                            {
                                StopAVRendererBridging(null, (ZensysUPnPAvRendererDevice)dev, (ZensysUPnPDevice)dev);
                            }
                            UPnPupDeviceList.Remove(dev);
                            break;

                        default:
                            mainLog.Write("Unknown Z-Wave Bridge Device Type " + dev.BridgeType.ToString());
                            break;
                    }
                }
                ZWaveNodes.Remove(nodeId);
            }
            // Remove node from listViewZWaveNodes if present
            foreach (ListViewItem lvitem in listViewZWaveNodes.Items)
            {
                if (nodeId == Convert.ToByte(lvitem.SubItems[0].Text))
                {
                    listViewZWaveNodes.Items.Remove(lvitem);
                    break;
                }
            }
        }


        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZWaveBridgeForm));
            this.buttonExit = new System.Windows.Forms.Button();
            this.checkBoxAutoScroll = new System.Windows.Forms.CheckBox();
            this.listViewDeviceList = new System.Windows.Forms.ListView();
            this.columnHeaderNodeID = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderDevice = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderUPnPDevice = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderUPnPFriendlyName = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderStreamDirection = new System.Windows.Forms.ColumnHeader();
            this.contextBridgedDeviceMenu = new System.Windows.Forms.ContextMenu();
            this.menuItemStop = new System.Windows.Forms.MenuItem();
            this.listViewLog = new System.Windows.Forms.ListView();
            this.columnHeaderTime = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderLogText = new System.Windows.Forms.ColumnHeader();
            this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
            this.trayContextMenu = new System.Windows.Forms.ContextMenu();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.menuItem3 = new System.Windows.Forms.MenuItem();
            this.buttonPlay = new System.Windows.Forms.Button();
            this.treeViewRenderer = new System.Windows.Forms.TreeView();
            this.contextMenuUPnPRendererCP = new System.Windows.Forms.ContextMenu();
            this.menuItemBridgeUPnPdevice = new System.Windows.Forms.MenuItem();
            this.tabControlZensysBridge = new System.Windows.Forms.TabControl();
            this.tabPageZWaveNodes = new System.Windows.Forms.TabPage();
            this.groupBoxVirtualNode = new System.Windows.Forms.GroupBox();
            this.buttonDelVirtualNode = new System.Windows.Forms.Button();
            this.buttonCreateVirtualNode = new System.Windows.Forms.Button();
            this.buttonNewNode = new System.Windows.Forms.Button();
            this.buttonSendInfo = new System.Windows.Forms.Button();
            this.buttonAbort = new System.Windows.Forms.Button();
            this.checkBoxAutoBridge = new System.Windows.Forms.CheckBox();
            this.labelZWaveStatusText = new System.Windows.Forms.Label();
            this.labelZWaveStatus = new System.Windows.Forms.Label();
            this.listViewZWaveNodes = new System.Windows.Forms.ListView();
            this.columnHeaderNode = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderZWaveDeviceType = new System.Windows.Forms.ColumnHeader();
            this.ColumnHeaderStatus = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderBridgeStatus = new System.Windows.Forms.ColumnHeader();
            this.columnHeaderVirtualNode = new System.Windows.Forms.ColumnHeader();
            this.contextMenuZWaveNodes = new System.Windows.Forms.ContextMenu();
            this.menuItemBridge = new System.Windows.Forms.MenuItem();
            this.groupBoxController = new System.Windows.Forms.GroupBox();
            this.buttonReceiveReplication = new System.Windows.Forms.Button();
            this.buttonAddNode = new System.Windows.Forms.Button();
            this.buttonResetNode = new System.Windows.Forms.Button();
            this.buttonResetController = new System.Windows.Forms.Button();
            this.buttonRequestUpdate = new System.Windows.Forms.Button();
            this.groupBoxNodes = new System.Windows.Forms.GroupBox();
            this.buttonRequestNeighborUpdate = new System.Windows.Forms.Button();
            this.buttonGetReport = new System.Windows.Forms.Button();
            this.buttonOff = new System.Windows.Forms.Button();
            this.buttonOn = new System.Windows.Forms.Button();
            this.tabPageUPnPBridgedDev = new System.Windows.Forms.TabPage();
            this.tabPageUPnPAvRendererCP = new System.Windows.Forms.TabPage();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.buttonNext = new System.Windows.Forms.Button();
            this.buttonPrev = new System.Windows.Forms.Button();
            this.buttonStop = new System.Windows.Forms.Button();
            this.buttonPause = new System.Windows.Forms.Button();
            this.labelTitleText = new System.Windows.Forms.Label();
            this.labelTitle = new System.Windows.Forms.Label();
            this.buttonReScan = new System.Windows.Forms.Button();
            this.labelStateText = new System.Windows.Forms.Label();
            this.labelState = new System.Windows.Forms.Label();
            this.labelStatusText = new System.Windows.Forms.Label();
            this.labelStatus = new System.Windows.Forms.Label();
            this.tabPageUPnPBinaryLightCP = new System.Windows.Forms.TabPage();
            this.listViewUPnPBinaryLight = new System.Windows.Forms.ListView();
            this.columnHeaderUPnPName = new System.Windows.Forms.ColumnHeader();
            this.contextMenuUPnPBinaryLightCP = new System.Windows.Forms.ContextMenu();
            this.menuItemToggleLight = new System.Windows.Forms.MenuItem();
            this.imageList1 = new System.Windows.Forms.ImageList(this.components);
            this.tabPageUPnPDeviceScanner = new System.Windows.Forms.TabPage();
            this.treeViewDeviceScanner = new System.Windows.Forms.TreeView();
            this.contextMenuDeviceScanner = new System.Windows.Forms.ContextMenu();
            this.menuItemRemoveUPnPDevice = new System.Windows.Forms.MenuItem();
            this.menuItemRescanUPnP = new System.Windows.Forms.MenuItem();
            this.buttonDeviceScannerReScan = new System.Windows.Forms.Button();
            this.toolTipApp = new System.Windows.Forms.ToolTip(this.components);
            this.buttonHide = new System.Windows.Forms.Button();
            this.labelNodeID = new System.Windows.Forms.Label();
            this.labelHomeID = new System.Windows.Forms.Label();
            this.checkBoxComDebug = new System.Windows.Forms.CheckBox();
            this.labelSUCID = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.labelNodeIDText = new System.Windows.Forms.Label();
            this.labelHomeIDText = new System.Windows.Forms.Label();
            this.labelSUCIDText = new System.Windows.Forms.Label();
            this.statusBarMain = new System.Windows.Forms.StatusBar();
            this.statusBarPanelVersion = new System.Windows.Forms.StatusBarPanel();
            this.statusBarPanelLogLines = new System.Windows.Forms.StatusBarPanel();
            this.statusBarPanelBridgedDevicesCount = new System.Windows.Forms.StatusBarPanel();
            this.statusBarPanelUpTime = new System.Windows.Forms.StatusBarPanel();
            this.timerAppUpTime = new System.Windows.Forms.Timer(this.components);
            this.tabControlZensysBridge.SuspendLayout();
            this.tabPageZWaveNodes.SuspendLayout();
            this.groupBoxVirtualNode.SuspendLayout();
            this.groupBoxController.SuspendLayout();
            this.groupBoxNodes.SuspendLayout();
            this.tabPageUPnPBridgedDev.SuspendLayout();
            this.tabPageUPnPAvRendererCP.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.tabPageUPnPBinaryLightCP.SuspendLayout();
            this.tabPageUPnPDeviceScanner.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelVersion)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelLogLines)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelBridgedDevicesCount)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanelUpTime)).BeginInit();
            this.SuspendLayout();
            // 
            // buttonExit
            // 
            this.buttonExit.Cursor = System.Windows.Forms.Cursors.Hand;
            this.buttonExit.Location = new System.Drawing.Point(712, 424);
            this.buttonExit.Name = "buttonExit";
            this.buttonExit.Size = new System.Drawing.Size(56, 32);
            this.buttonExit.TabIndex = 2;
            this.buttonExit.Text = "Exit";
            this.toolTipApp.SetToolTip(this.buttonExit, "Stop Bridging and exit ZWaveBridge");
            this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
            // 
            // checkBoxAutoScroll
            // 
            this.checkBoxAutoScroll.Checked = true;
            this.checkBoxAutoScroll.CheckState = System.Windows.Forms.CheckState.Checked;
            this.checkBoxAutoScroll.Location = new System.Drawing.Point(16, 16);
            this.checkBoxAutoScroll.Name = "checkBoxAutoScroll";
            this.checkBoxAutoScroll.Size = new System.Drawing.Size(88, 24);
            this.checkBoxAutoScroll.TabIndex = 4;
            this.checkBoxAutoScroll.Text = "Auto Scroll";
            this.toolTipApp.SetToolTip(this.checkBoxAutoScroll, "Automaticaly scroll log window, so that new loglines are in view");
            this.checkBoxAutoScroll.CheckedChanged += new System.EventHandler(this.checkBoxAutoScroll_CheckedChanged);
            // 
            // listViewDeviceList
            // 
            this.listViewDeviceList.AllowDrop = true;
            this.listViewDeviceList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeaderNodeID,
            this.columnHeaderDevice,
            this.columnHeaderUPnPDevice,
            this.columnHeaderUPnPFriendlyName,
            this.columnHeaderStreamDirection});
            this.listViewDeviceList.ContextMenu = this.contextBridgedDeviceMenu;
            this.listViewDeviceList.FullRowSelect = true;
            this.listViewDeviceList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
            this.listViewDeviceList.HideSelection = false;
            this.listViewDeviceList.ImeMode = System.Windows.Forms.ImeMode.NoControl;
            this.listViewDeviceList.Location = new System.Drawing.Point(8, 8);
            this.listViewDeviceList.Name = "listViewDeviceList";
            this.listViewDeviceList.Size = new System.Drawing.Size(744, 216);
            this.listViewDeviceList.Sorting = System.Windows.Forms.SortOrder.Ascending;
            this.listViewDeviceList.TabIndex = 6;
            this.toolTipApp.SetToolTip(this.listViewDeviceList, "Z-Wave <-> UPnp Bridged devices");
            this.listViewDeviceList.UseCompatibleStateImageBehavior = false;
            this.listViewDeviceList.View = System.Windows.Forms.View.Details;
            // 
            // columnHeaderNodeID
            // 
            this.columnHeaderNodeID.Text = "Node Id";
            this.columnHeaderNodeID.Width = 52;
            // 
            // columnHeaderDevice
            // 
            this.columnHeaderDevice.Text = "Z-Wave Device";
            this.columnHeaderDevice.Width = 114;
            // 
            // columnHeaderUPnPDevice
            // 
            this.columnHeaderUPnPDevice.Text = "UPnP Device";
            this.columnHeaderUPnPDevice.Width = 126;
            // 
            // columnHeaderUPnPFriendlyName
            // 
            this.columnHeaderUPnPFriendlyName.Text = "UPnP Name";
            this.columnHeaderUPnPFriendlyName.Width = 391;
            // 
            // columnHeaderStreamDirection
            // 
            this.columnHeaderStreamDirection.Text = "Direction";
            this.columnHeaderStreamDirection.Width = 54;
            // 
            // contextBridgedDeviceMenu
            // 
            this.contextBridgedDeviceMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItemStop});
            // 
            // menuItemStop
            // 
            this.menuItemStop.Index = 0;
            this.menuItemStop.Shortcut = System.Windows.Forms.Shortcut.Del;
            this.menuItemSt

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?