form1.cs

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

CS
1,249
字号
//////////////////////////////////////////////////////////////////////////////////////////////// 
//
//          #######
//          #   ##    ####   #####    #####  ##  ##   #####
//             ##    ##  ##  ##  ##  ##      ##  ##  ##
//            ##  #  ######  ##  ##   ####   ##  ##   ####
//           ##  ##  ##      ##  ##      ##   #####      ##
//          #######   ####   ##  ##  #####       ##  #####
//                                           #####
//          Z-Wave, the wireless language.
//
//          Copyright Zensys A/S, 2003
//
//          All Rights Reserved
//
//          Description:   This source file includes functions for the Z-Wave Controller. 
//
//          Author:   Jette Christensen
//
//          Last Changed By:  $Author: jrm $
//          Revision:         $Revision: 1.22 $
//          Last Changed:     $Date: 2007/03/21 10:35:53 $
//
//////////////////////////////////////////////////////////////////////////////////////////////

#region Using directives
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Zensys.ZWave.Communication;
using System.Threading;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Text;
using System.Globalization;
using System.Security; // CodeAccessPermission
using System.Security.Permissions;  // RegistryPermission
using System.Resources;
using Microsoft.Win32; //Microsoft.Win32.RegistryKey
using ZWaveCmdClass;
using Zensys.ZWave.Logging;
using Zensys.ZCmdClass;
#endregion Using directives

namespace ZWavePCController
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {

        #region Windows.Forms Fields
        private System.Windows.Forms.TabControl tabControl1;
        private System.Windows.Forms.TabPage tabPageNode;
        private System.Windows.Forms.ListView listViewNodes;
        private System.Windows.Forms.ColumnHeader columnHeaderNode;
        private System.Windows.Forms.ColumnHeader columnHeaderDeviceType;
        private System.Windows.Forms.ColumnHeader columnHeaderStatus;
        private System.Windows.Forms.Button buttonExit;
        private System.Windows.Forms.Button buttonAbort;
        private System.Windows.Forms.Button buttonAllOff;
        private System.Windows.Forms.Button buttonAllOn;
        private System.Windows.Forms.Button buttonReplaceFailedNode;
        private System.Windows.Forms.Button buttonRemFail;
        private System.Windows.Forms.Button buttonOff;
        private System.Windows.Forms.Button buttonGetReport;
        private System.Windows.Forms.Button buttonOn;
        private System.Windows.Forms.Button buttonExcludeNode;
        private System.Windows.Forms.Button buttonAddNode;
        private System.Windows.Forms.Button buttonGetNodeInfo;
        private System.Windows.Forms.Button buttonSendCmd;
        private System.Windows.Forms.Button buttonRequestUpdate;
        private System.Windows.Forms.Button buttonNewPrimary;
        private System.Windows.Forms.Button buttonResetController;
        private System.Windows.Forms.Button buttonControllerShift;
        private System.Windows.Forms.Button buttonReceive;
        private System.Windows.Forms.Button buttonEnableOptionalAssignment;
        private System.Windows.Forms.Button buttonGetAssociation;
        private System.Windows.Forms.Button buttonRemoveAssociation;
        private System.Windows.Forms.Button buttonAddAssociation;
        private System.Windows.Forms.Button buttonDeleteRoute;
        private System.Windows.Forms.Button buttonAssignRoute;
        private System.Windows.Forms.Button buttonWakeUpSet;

        private System.Windows.Forms.Label labelHomeIDField;
        private System.Windows.Forms.Label labelControllerField;
        private System.Windows.Forms.Label labelStatusField;
        private System.Windows.Forms.Label labelHomeID;
        private System.Windows.Forms.Label labelController;
        private System.Windows.Forms.Label labelStatus;
        private System.Windows.Forms.Label labelNodesInQueue;
        private System.Windows.Forms.Label NumberOfNodesQueued;
        private System.Windows.Forms.Label about_ChipRevField;
        private System.Windows.Forms.Label about_ChipRev;
        private System.Windows.Forms.Label about_ChipTypeField;
        private System.Windows.Forms.Label about_ChipType;
        private System.Windows.Forms.Label about_dll_version;
        private System.Windows.Forms.Label labelDLL;
        private System.Windows.Forms.Label about_BaudRateField;
        private System.Windows.Forms.Label about_ConnectionField;
        private System.Windows.Forms.Label about_LibraryField;
        private System.Windows.Forms.Label about_VersionField;
        private System.Windows.Forms.Label about_Version;
        private System.Windows.Forms.Label about_Library;
        private System.Windows.Forms.Label about_BaudRate;
        private System.Windows.Forms.Label about_Connection;
        private System.Windows.Forms.Label labelWakeUpTimeField;
        private System.Windows.Forms.Label labelWakeUpTime;
        private System.Windows.Forms.Label labelVal;
        private System.Windows.Forms.Label labelCmd;
        private System.Windows.Forms.Label labelCls;
        private System.Windows.Forms.Label labelAssociationInGroup;
        private System.Windows.Forms.Label labelDst;
        private System.Windows.Forms.Label labelSource;
        private System.Windows.Forms.Label labelGroups;
        private System.Windows.Forms.Label labelDest;
        private System.Windows.Forms.Label labelCmdClassRxed;
        private System.Windows.Forms.Label label1;

        private System.Windows.Forms.TabPage tabPageAbout;
        private System.Windows.Forms.TabPage tabPageNetworkInfo;
        private System.Windows.Forms.TabPage tabPageCmdClass;
        private System.Windows.Forms.TabPage tabPageController;
        private System.Windows.Forms.TabPage tabPageWakeUp;
        private System.Windows.Forms.TabPage tabPageAssociation;
        private System.Windows.Forms.TabPage tabPageRouting;

        private System.Windows.Forms.ListView listViewNodeInfo;
        private System.Windows.Forms.ColumnHeader columnNodeInfo1;
        private System.Windows.Forms.ColumnHeader columnNodeInfo2;
        private System.Windows.Forms.TextBox textBoxVal;
        private System.Windows.Forms.TextBox textBoxWakeupTime;

        private System.Windows.Forms.ComboBox comboBoxCmd;
        private System.Windows.Forms.ComboBox comboBoxCls;

        private System.Windows.Forms.GroupBox groupBoxOptionalAssignment;

        private System.Windows.Forms.RadioButton select_None;
        private System.Windows.Forms.RadioButton select_SUC;
        private System.Windows.Forms.RadioButton select_SIS;

        private System.Windows.Forms.ListBox listBoxAssociationGroups;
        private System.Windows.Forms.ListBox listBoxAssociationInGroup;
        private System.Windows.Forms.ListBox listBoxAssocSup;
        private System.Windows.Forms.ListBox listBoxDst;
        private System.Windows.Forms.ListBox listBoxSrc;
        private System.Windows.Forms.CheckBox checkBoxDebug;

        private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.MenuItem menuSettings;
        private System.Windows.Forms.MenuItem menuPort;

        private System.Windows.Forms.MainMenu mainMenu;

        private System.Windows.Forms.NotifyIcon notifyIcon;
        private System.ComponentModel.IContainer components;
        private string[] portNames;
        private System.Threading.Timer onWakeUpTimer;
        private System.Threading.Timer wakeUpTimer;

        private struct regEntries
        {
            public const string PORT = "port";
            public const string BAUDRATE = "baudrate";
        }

        #endregion Windows.Forms Fields

        #region Fields constants
        /// <summary>
        /// SUC capabilities used in ZW_EnableSUC - Enable basic SUC functionality
        /// </summary>
        private const int ZW_SUC_FUNC_BASIC_SUC = 0x00;             //    ZW_SUC_FUNC_BASIC_SUC
        /// <summary>
        /// SUC capabilities used in ZW_EnableSUC - Enable basis SUC and NodeID
        /// Server functionalities
        /// </summary>
        private const int ZW_SUC_FUNC_NODEID_SERVER = 0x01;  // ZW_SUC_FUNC_NODEID_SERVER
        /// <summary>
        /// Identifier for a node broadcast
        /// </summary>
        private const int NODE_BROADCAST = 0xFF;
        private const int ZW_MAX_NODES = 232;
        private const byte UPDATE_STATE_SUC_ID = 0x10;
        #endregion Fields constants

        #region Fields
        public static IApplicationLayer applicationLayer;
        private static string portName;
        // Default value if nothing else has been set.
        private static string baudRate = "115200";
        private static byte controllerNode;

        private ResourceManager resourceFormManager = new ResourceManager("ZWavePCController.Properties.Resources", typeof(Form1).Assembly);


        private RegistryKey OurKey = Registry.CurrentUser;
        private enum RegEntries
        {
            COMPORT,
            INSTALL_PATH
        }

        private delegate void TwoBooleansDelegate(bool bEnabled, bool bAbortEnabled);
        private delegate void StringDelegate(string text);
        private delegate string StringVoidDelegate();

        private Association associationTable = new Association();
        private Device dev = new Device();
        private Node node;
        private Node ctrlNodeInfo;
        private Node[] nodes;

        private Thread formThread;
        private Library lib;
        private String ver;
        private CmdClassStorage SupportedClasses;
        private ZW_cmd_classes.ZWaveCmdClass CmdsCls;

        private ArrayList nodeList = new ArrayList();
        private ArrayList LastSUCRouteTo = new ArrayList();
        private Hashtable custclscmd;

        private bool slaveController;
        private bool changedTab;
        private bool closePort;

        private int homeId;
        private int LastChanged;
        private int allOnOffFailedFlag;

        private byte[] command;
        private string[] itemString;

        private byte SUC;
        private byte nextNodeId;
        private byte startNode;
        private byte endNode;
        private byte failednode;
        private byte select_SUC_or_SIS;

        private Button buttonIsFailed;

        private Button btnShowSerialAPICapabilities;
        private CheckBox chkAssignRoutes;

⌨️ 快捷键说明

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