Esempio n. 1
0
        public void Initialise(string ZWaveConfigPath, string ZWaveSerialPort, int ZWavePollInterval, string LogPath)
        {
            logPath = LogPath;

            // Configuration details
            ZWaveConfigPath = BuildConfigPath(ZWaveConfigPath);
            System.IO.FileInfo logDirectory = new System.IO.FileInfo(ZWaveConfigPath);

            // Create the Options
            Log("Building ZWOptions with " + ZWaveConfigPath);
            m_options = new ZWOptions();
            m_options.Create(ZWaveConfigPath, @"", @"");

            // Lock the options
            m_options.Lock();

            // Create the OpenZWave Manager
            m_manager = new ZWManager();
            m_manager.Create();

            // Add an event handler for all the Z-Wave notifications
            m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);
            if (ZWavePollInterval > 0)
            {
                m_manager.SetPollInterval(ZWavePollInterval);
            }

            // Add a driver, this will start up the z-wave network
            m_manager.AddDriver(ZWaveSerialPort);
        }
Esempio n. 2
0
        private static void ConfigureOptions()
        {
            if (optionsConfigured)
            {
                return;
            }

            var path = Path.GetFullPath(ConfigurationPath);

            if (!Directory.Exists(path))
            {
                throw new HomeAutomationException("Open Z-Wave configuration path not found at " + path);
            }

            optionsConfigured = true;

            var options = new ZWOptions();

            options.Create(path, string.Empty, string.Empty);

            // Add any app specific options here...
            options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.Error);                // ordinarily, just write "Detail" level messages to the log
            options.AddOptionInt("QueueLogLevel", (int)ZWLogLevel.Debug);               // save recent messages with "Debug" level messages to be dumped if an error occurs
            options.AddOptionInt("DumpTriggerLevel", (int)ZWLogLevel.Error);            // only "dump" Debug  to the log emessages when an error-level message is logged

            // Lock the options
            options.Lock();
        }
Esempio n. 3
0
 public MainForm()
 {
     InitializeComponent();
     if (Properties.Settings.Default.SpeechRecognitionEnabled)
     {
         try
         {
             engine.LoadGrammar(new DictationGrammar());
             engine.SetInputToDefaultAudioDevice();
             engine.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(engine_RecognizeCompleted);
         }
         catch (Exception ex)
         {
             MessageBox.Show("Unable to load Speech Recognition: " + ex.ToString());
         }
     }
     if (Properties.Settings.Default.ZWaveEnabled)
     {
         m_options = new ZWOptions();
         m_options.Create(@"C:\Users\Kevin\Documents\Visual Studio 2010\Projects\OpenZWave\config\", @"", @"");
         m_options.Lock();
         m_manager = new ZWManager();
         m_manager.Create();
         m_manager.AddDriver(@"\\.\COM4");
         m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);
     }
 }
Esempio n. 4
0
        private static void SetOptions()
        {
            var options = new ZWOptions();

            options.Create(@"C:\work\OSS\ZBuildLights\lib\OpenZWave_1-3-Release\config", @"c:\temp\OzwDemo\UserData",
                           string.Empty);
            options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.None);
            options.Lock();
        }
        public static void SetUp()
        {
            if (USE_ZWAVE)
            {
                // Create the Options
                m_options = new ZWOptions();
                m_options.Create(zWaveConfigPath, @"", @"");
                m_options.Lock();

                // Create the OpenZWave Manager
                m_manager = new ZWManager();
                m_manager.Create();
                m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);
                m_manager.AddDriver(zWaveSerialPortName);

                // Wait for Z-wave.
                do
                {
                    SleepForThreeSeconds();
                }while (m_nodesReady == false);
            }
        }
Esempio n. 6
0
        public void RunInterface(string pluginName)
        {
            pName = pluginName;
            int poll = 60;
            if (osae.GetObjectPropertyValue(pName, "Polling Interval").Value != "")
                poll = Int32.Parse(osae.GetObjectPropertyValue(pName, "Polling Interval").Value);

            string port = osae.GetObjectPropertyValue(pName, "Port").Value;

            osae.AddToLog("Port: " + port, true);
            try
            {
                if (port != "")
                {
                    // Create the Options
                    m_options = new ZWOptions();
                    m_options.Create(osae.APIpath + @"\AddIns\ZWave\config\", osae.APIpath + @"\AddIns\ZWave\", @"");

                    // Add any app specific options here...
                    m_options.AddOptionBool("ConsoleOutput", false);
                    m_options.AddOptionBool("IntervalBetweenPolls", true);
                    m_options.AddOptionInt("PollInterval", 50);

                    // Lock the options
                    m_options.Lock();

                    // Create the OpenZWave Manager
                    m_manager = new ZWManager();
                    m_manager.Create();
                    m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

                    // Add a driver
                    m_manager.AddDriver(@"\\.\COM" + port);

                    //osae.AddToLog("Setting poll interval: " + poll.ToString(), true);
                    //m_manager.SetPollInterval(poll);
                    osae.AddToLog(osae.APIpath + @"\AddIns\ZWave\Config", true);
                    osae.AddToLog("Zwave plugin initialized", true);
                }

                osae.ObjectTypeUpdate("ZWAVE DIMMER", "ZWAVE DIMMER", "ZWave Dimmer", pName, "MULTILEVEL SWITCH", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE BINARY SWITCH", "ZWAVE BINARY SWITCH", "ZWave Binary Switch", pName, "BINARY SWITCH", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE THERMOSTAT", "ZWAVE THERMOSTAT", "ZWave Thermostat", pName, "THERMOSTAT", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE REMOTE", "ZWAVE REMOTE", "ZWave Remote", pName, "ZWAVE REMOTE", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE MULTISENSOR", "ZWAVE MULTISENSOR", "ZWave MultiSensor", pName, "ZWAVE MULTISENSOR", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE HOME ENERGY METER", "ZWAVE HOME ENERGY METER", "ZWave Home Energy Meter", pName, "ZWAVE HOME ENERGY METER", 0, 0, 0, 1);
                osae.ObjectTypeUpdate("ZWAVE SMART ENERGY SWITCH", "ZWAVE SMART ENERGY SWITCH", "ZWave Smart Energy Switch", pName, "ZWAVE SMART ENERGY SWITCH", 0, 0, 0, 1);

                #region Screen Init
                //osae.ObjectPropertySet("Screen - ZWave Manager - ZWave - ADD CONTROLLER", "Object Name", pName);
                //osae.ObjectPropertySet("Screen - ZWave Manager - ZWave - ADD DEVICE", "Object Name", pName);
                //osae.ObjectPropertySet("Screen - ZWave Manager - ZWave - REMOVE CONTROLLER", "Object Name", pName);
                //osae.ObjectPropertySet("Screen - ZWave Manager - ZWave - REMOVE DEVICE", "Object Name", pName);
                #endregion
            }
            catch (Exception ex)
            {
                osae.AddToLog("Error initalizing plugin: " + ex.Message, true);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            // Initialize the form
            InitializeComponent();

            // Add the columns to the grid view
            // Data Grid
            NodeGridView.AutoGenerateColumns      = false;
            NodeGridView.AllowUserToResizeColumns = true;
            NodeGridView.AutoSizeColumnsMode      = DataGridViewAutoSizeColumnsMode.DisplayedCells;

            DataGridViewTextBoxColumn column;

            //DataGridViewCheckBoxColumn check;

            // Id
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "ID";
            column.Name             = "Node";
            column.ReadOnly         = true;
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "The Z-Wave node ID of the device.\nThis value is not editable.";
            NodeGridView.Columns.Add(column);

            // Location
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Location";
            column.Name             = "Location";
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "The user-defined location of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Name
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Name";
            column.Name             = "Name";
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "The user-defined name for the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Device Type
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Label";
            column.Name             = "Type";
            column.ReadOnly         = true;
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "The Z-Wave device type.\nThis value is not editable.";
            NodeGridView.Columns.Add(column);

            // Manufacturer
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Manufacturer";
            column.Name             = "Manufacturer";
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "The manufacturer of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Product
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Product";
            column.Name             = "Product";
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            column.ToolTipText      = "The product name of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

/*            // Poll Interval
 *          column = new DataGridViewTextBoxColumn();
 *          column.DataPropertyName = "PollInterval";
 *          column.Name = "Poll Interval";
 *          column.ReadOnly = false;
 *          column.Frozen = false;
 *          column.Resizable = DataGridViewTriState.True;
 *          column.SortMode = DataGridViewColumnSortMode.NotSortable;
 *          column.ToolTipText = "Polling interval in seconds, or zero for no polling.\nNewer devices should not need to be polled for\nyour PC to know their current state.\nFor those that do requre polling, the interval should\nbe as long as possible to reduce network traffic.";
 *          NodeGridView.Columns.Add(column);
 */
/*            // Schema
 *          column = new DataGridViewTextBoxColumn();
 *          column.DataPropertyName = "Schema";
 *          column.Name = "Schema";
 *          column.ReadOnly = true;
 *          column.Frozen = false;
 *          column.Resizable = DataGridViewTriState.True;
 *          column.SortMode = DataGridViewColumnSortMode.NotSortable;
 *          column.ToolTipText = "The xPL message schema family that will be used\nif the 'Use zwave.basic' option is not checked.\nThe schema is chosen automatically according to\nthe Z-Wave device type, and cannot be changed.";
 *          NodeGridView.Columns.Add(column);
 *
 *          // ZWaveBasic
 *          //check = new DataGridViewCheckBoxColumn();
 *          //check.DataPropertyName = "ZWaveBasic";
 *          //check.Name = "Use zwave.basic";
 *          //check.Frozen = false;
 *          //check.Resizable = DataGridViewTriState.True;
 *          //check.SortMode = DataGridViewColumnSortMode.NotSortable;
 *          //check.ToolTipText = "If the box is checked, the device will send and respond to\nnative zwave.basic messages rather than those of the\ngeneric schema family listed under the Schema column.";
 *          //NodeGridView.Columns.Add(check);
 */
            // Level
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Level";
            column.Name             = "Level";
            column.Frozen           = false;
            column.Resizable        = DataGridViewTriState.True;
            column.SortMode         = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText      = "Current level of the device";
            NodeGridView.Columns.Add(column);

            // On-Off button
            DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn();

            buttonColumn.DataPropertyName = "ButtonText";
            buttonColumn.Name             = "Power";
            buttonColumn.Frozen           = false;
            buttonColumn.Resizable        = DataGridViewTriState.True;
            buttonColumn.SortMode         = DataGridViewColumnSortMode.NotSortable;
            buttonColumn.ToolTipText      = "Click a button to turn a light on or off";
            NodeGridView.Columns.Add(buttonColumn);

            BindingSource bs = new BindingSource();

            bs.DataSource           = m_nodeList;
            NodeGridView.DataSource = bs;

            // Create the Options
            m_options = new ZWOptions();
            m_options.Create(@"C:\code\open-zwave\config", @"", @"");

            // Add any app specific options here...
            m_options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.Detail);
            // ordinarily, just write "Detail" level messages to the log
            m_options.AddOptionInt("QueueLogLevel", (int)ZWLogLevel.Debug);
            // save recent messages with "Debug" level messages to be dumped if an error occurs
            m_options.AddOptionInt("DumpTriggerLevel", (int)ZWLogLevel.Error);
            // only "dump" Debug  to the log emessages when an error-level message is logged

            // Lock the options
            m_options.Lock();

            // Create the OpenZWave Manager
            m_manager = new ZWManager();
            m_manager.Create();
            m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

            // Add a driver
            m_driverPort = @"\\.\COM5";
            m_manager.AddDriver(m_driverPort);
//			m_manager.AddDriver(@"HID Controller", ZWControllerInterface.Hid);
        }
        private void StopOpenzwave()
        {
            if (!isShuttingDown)
            {
                isShuttingDown = true;
                
                if (m_manager != null)
                {
                    m_manager.OnNotification -= NotificationHandler;
                    m_manager.RemoveDriver(@"\\.\COM" + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Port").Value);
                    m_manager.Destroy();
                    m_manager = null;
                }

                if (m_options != null)
                {
                    m_options.Destroy();
                    m_options = null;
                }

                isShuttingDown = false;
            }
        }
        private Task StartOpenzwaveAsync()
        {
            if (isShuttingDown)
            {
                Log.Info("ZWave driver cannot start because it is still shutting down");
                return Task.FromResult(0);
            }

            try
            {
                string port = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Port").Value;
                if (port != "")
                {
                    // Create the Options
                    m_options = new ZWOptions();
                    m_options.Create(Common.ApiPath + @"\Plugins\ZWave\config\", Common.ApiPath + @"\Plugins\ZWave\", @"");
                    // Lock the options
                    m_options.Lock();

                    // Create the OpenZWave Manager
                    m_manager = new ZWManager();
                    m_manager.Create();
                    m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

                    // Add a driver
                    m_manager.AddDriver(@"\\.\COM" + port);

                    int poll = 60;
                    if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value != string.Empty)
                        poll = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value);
                    {
                        Log.Info("Setting poll interval: " + poll.ToString());
                        m_manager.SetPollInterval(poll * 1000, true);
                    }

                    Log.Info(Common.ApiPath + @"\Plugins\ZWave\Config");
                    Log.Info("Zwave plugin initialized");
                }
            }
            catch (Exception e)
            {
                Log.Error("Error initalizing plugin", e);
            }

            return Task.FromResult(0);
        }
Esempio n. 10
0
 protected override bool StopPlugin()
 {
     WriteToLog(Urgency.INFO, Friendly_Name + " plugin stopped.");
     m_manager.OnNotification -= NotificationHandler;
     string comPort = GetSettingValue("COMPORT");
     m_manager.RemoveDriver(@"\\.\COM" + comPort);
     m_manager.Destroy();
     m_options.Destroy();
     m_options = null;
     m_manager = null;
     IsReady = false;
     return true;
 }
Esempio n. 11
0
        protected override bool StartPlugin()
        {
            try
            {
                WriteToLog(Urgency.INFO, this.Friendly_Name + " plugin started.");

                // Environment.CurrentDirectory returns wrong directory in Service env. so we have to make a trick
                string directoryName = System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
                // Create the Options
                m_options = new ZWOptions();
                m_options.Create(directoryName + @"\config\",
                                 directoryName + @"\", @"");
                m_options.Lock();
                m_manager = new ZWManager();
                m_manager.Create();
                m_manager.OnNotification += NotificationHandler;

                bool useHID = false;
                //bool.TryParse(GetSettingValue("HID"), out useHID);

                if (!useHID)
                {
                    string comPort = GetSettingValue("COMPORT");
                    if (comPort != "0")
                    {
                        m_manager.AddDriver(@"\\.\COM" + comPort);
                    }
                }
                else
                {

                    //m_manager.AddHidDriver();
                }

                int pollint = 0;
                int.TryParse(GetSettingValue("POLLINT"), out pollint);
                if (pollint != 0)
                {
                    m_manager.SetPollInterval(pollint);
                }
            }
            catch (Exception e)
            {
                WriteToLog(Urgency.ERROR, e.Message);
                return false;
            }

            return true;
        }
        private async Task StartOpenzwaveAsync()
        {
            if (CancellationToken.IsCancellationRequested)
            {
                await Log.ReportInfoFormatAsync(CancellationToken, "{0} driver cannot start because it is still shutting down", Name);
                return;
            }

            PropertyChanged += OpenZWaveAdapter_PropertyChanged;
            try
            {
                await Log.ReportInfoFormatAsync(CancellationToken, "OpenZwave driver starting on {0}", UseHidSetting ? "HID" : "COM" + ComportSetting);

                // Environment.CurrentDirectory returns wrong directory in Service environment so we have to make a trick
                var directoryName = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

                // Create the Options                
                MOptions = new ZWOptions();
                MOptions.Create(directoryName + @"\config\",
                                        LogPath,
                                        @"");
                MOptions.Lock();
                MManager = new ZWManager();


                MManager.Create();
                MManager.OnNotification += NotificationHandler;

                if (!UseHidSetting)
                {
                    if (ComportSetting != "0")
                    {
                        MManager.AddDriver(@"\\.\COM" + ComportSetting);
                    }
                }
                else
                {
                    MManager.AddDriver("HID Controller", ZWControllerInterface.Hid);
                }


                if (PollingIntervalSetting != 0)
                {
                    MManager.SetPollInterval(PollingIntervalSetting, true);
                }
            }
            catch (Exception e)
            {
                Log.ReportErrorFormatAsync(CancellationToken, "Error initializing Openzwave {0}", e.Message).Wait();
            }
        }
Esempio n. 13
0
        private static void ConfigureOptions()
        {
            if (optionsConfigured)
            {
                return;
            }

            var path = Path.GetFullPath(ConfigurationPath);

            if (!Directory.Exists(path))
            {
                throw new HomeAutomationException("Open Z-Wave configuration path not found at " + path);
            }

            optionsConfigured = true;

            var options = new ZWOptions();
            options.Create(path, string.Empty, string.Empty);

            // Add any app specific options here...
            options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.Error);			// ordinarily, just write "Detail" level messages to the log
            options.AddOptionInt("QueueLogLevel", (int)ZWLogLevel.Debug);			// save recent messages with "Debug" level messages to be dumped if an error occurs
            options.AddOptionInt("DumpTriggerLevel", (int)ZWLogLevel.Error);		// only "dump" Debug  to the log emessages when an error-level message is logged

            // Lock the options
            options.Lock();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Begin");
            _mre = new ManualResetEvent(false);

            OpenZWaveDotNet.ZWManager manager = new OpenZWaveDotNet.ZWManager();

            var options = new ZWOptions();
            options.Create(@"..\..\config", @"", @"");

            // Add any app specific options here...
            options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.None);
            // ordinarily, just write "Detail" level messages to the log
            options.AddOptionInt("QueueLogLevel", (int)ZWLogLevel.None);
            // save recent messages with "Debug" level messages to be dumped if an error occurs
            options.AddOptionInt("DumpTriggerLevel", (int)ZWLogLevel.None);
            // only "dump" Debug  to the log emessages when an error-level message is logged

            // Lock the options
            options.Lock();

            _manager = new ZWManager();

            _manager.Create();

            _manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

            var driverPort = @"\\.\COM3";
            _manager.AddDriver(driverPort);

            _mre.WaitOne();

            var sensor = PrintValuesForDevice("Routing Binary Sensor");
            _manager.SetNodeProductName(sensor.HomeId, sensor.Id, "Garage Door Sensor");

            foreach (var n in _nodeList)
            {
                Console.WriteLine("======================================");
                Console.WriteLine("Label: " + n.Label);
                Console.WriteLine("location: " + n.Location);
                Console.WriteLine("Manufacturer: " + n.ManufacturerName);

                var name = _manager.GetNodeName(sensor.HomeId, n.Id);
                n.Name = name;

                Console.WriteLine("Name: " + n.Name);
                Console.WriteLine("Product: " + n.Product);
                Console.WriteLine("Node Id: " + n.Id);
                Console.WriteLine("======================================");
            }

            // var node = _nodeList.FirstOrDefault(x => x.Product == "45609 On/Off Relay Switch");

            // _manager.SetPollInterval(1000, true);
            var node = PrintValuesForDevice("Binary Power Switch");

            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Getting value of basement light switch:");
            ZWValueID v = node.ValueIds.First(x => _manager.GetValueLabel(x) == "Switch");
            bool ret;
            bool b;
            ret = _manager.GetValueAsBool(v, out b);
            Console.WriteLine("SWITCH: Got bool value of " + b + ", success: " + ret);

            var v2 = sensor.ValueIds.First(x => _manager.GetValueLabel(x) == "Sensor");
            ret = _manager.GetValueAsBool(v2, out b);
            Console.WriteLine("SENSOR: Got bool value of " + b + ", success: " + ret);

            //int i;
            //ret = _manager.GetValueAsInt(v, out i);
            //Console.WriteLine("got in value of " + i + ", success: " + ret);

            //string str;
            //ret = _manager.GetValueAsString(v, out str);
            //Console.WriteLine("got string value of " + str + ", success: " + ret);

            // ret = _manager.SetValue(v, true);
            //Console.WriteLine("Set bool value to false, success: " + ret);

            Console.WriteLine("Press enter...");
            Console.ReadLine();
        }
Esempio n. 15
0
 public ZWaveOptions()
 {
     _options = new ZWOptions();
 }
Esempio n. 16
0
        public MainForm()
        {
            // Initialize the form
            InitializeComponent();

            // Add the columns to the grid view
            // Data Grid
            NodeGridView.AutoGenerateColumns = false;
            NodeGridView.AllowUserToResizeColumns = true;
            NodeGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

            DataGridViewTextBoxColumn column;
            //DataGridViewCheckBoxColumn check;

            // Id
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "ID";
            column.Name = "Node";
            column.ReadOnly = true;
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The Z-Wave node ID of the device.\nThis value is not editable.";
            NodeGridView.Columns.Add(column);

            // Location
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Location";
            column.Name = "Location";
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The user-defined location of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Name
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Name";
            column.Name = "Name";
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The user-defined name for the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Device Type
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Label";
            column.Name = "Type";
            column.ReadOnly = true;
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The Z-Wave device type.\nThis value is not editable.";
            NodeGridView.Columns.Add(column);

            // Manufacturer
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Manufacturer";
            column.Name = "Manufacturer";
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The manufacturer of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            // Product
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Product";
            column.Name = "Product";
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            column.ToolTipText = "The product name of the Z-Wave device.";
            NodeGridView.Columns.Add(column);

            /*            // Poll Interval
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "PollInterval";
            column.Name = "Poll Interval";
            column.ReadOnly = false;
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "Polling interval in seconds, or zero for no polling.\nNewer devices should not need to be polled for\nyour PC to know their current state.\nFor those that do requre polling, the interval should\nbe as long as possible to reduce network traffic.";
            NodeGridView.Columns.Add(column);
            */
            /*            // Schema
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Schema";
            column.Name = "Schema";
            column.ReadOnly = true;
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "The xPL message schema family that will be used\nif the 'Use zwave.basic' option is not checked.\nThe schema is chosen automatically according to\nthe Z-Wave device type, and cannot be changed.";
            NodeGridView.Columns.Add(column);

            // ZWaveBasic
            //check = new DataGridViewCheckBoxColumn();
            //check.DataPropertyName = "ZWaveBasic";
            //check.Name = "Use zwave.basic";
            //check.Frozen = false;
            //check.Resizable = DataGridViewTriState.True;
            //check.SortMode = DataGridViewColumnSortMode.NotSortable;
            //check.ToolTipText = "If the box is checked, the device will send and respond to\nnative zwave.basic messages rather than those of the\ngeneric schema family listed under the Schema column.";
            //NodeGridView.Columns.Add(check);
            */
            // Level
            column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Level";
            column.Name = "Level";
            column.Frozen = false;
            column.Resizable = DataGridViewTriState.True;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.ToolTipText = "Current level of the device";
            NodeGridView.Columns.Add(column);

            // On-Off button
            DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn();
            buttonColumn.DataPropertyName = "ButtonText";
            buttonColumn.Name = "Power";
            buttonColumn.Frozen = false;
            buttonColumn.Resizable = DataGridViewTriState.True;
            buttonColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
            buttonColumn.ToolTipText = "Click a button to turn a light on or off";
            NodeGridView.Columns.Add(buttonColumn);

            BindingSource bs = new BindingSource();
            bs.DataSource = m_nodeList;
            NodeGridView.DataSource = bs;

            // Create the Options
            m_options = new ZWOptions();
            m_options.Create(@"..\..\..\..\..\..\..\config\", @"", @"");

            // Add any app specific options here...
            m_options.AddOptionInt("SaveLogLevel", (int)ZWLogLevel.Detail);			// ordinarily, just write "Detail" level messages to the log
            m_options.AddOptionInt("QueueLogLevel", (int)ZWLogLevel.Debug);			// save recent messages with "Debug" level messages to be dumped if an error occurs
            m_options.AddOptionInt("DumpTriggerLevel", (int)ZWLogLevel.Error);		// only "dump" Debug  to the log emessages when an error-level message is logged

            // Lock the options
            m_options.Lock();

            // Create the OpenZWave Manager
            m_manager = new ZWManager();
            m_manager.Create();
            m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

            // Add a driver
            m_driverPort = @"\\.\COM4";
            m_manager.AddDriver(m_driverPort);
            //			m_manager.AddDriver(@"HID Controller", ZWControllerInterface.Hid);
        }
Esempio n. 17
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            int poll = 60;
            if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value != string.Empty)
                poll = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value);

            string port = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Port").Value;

            logging.AddToLog("Port: " + port, true);
            try
            {
                if (port != "")
                {
                    // Create the Options
                    m_options = new ZWOptions();
                    m_options.Create(Common.ApiPath + @"\Plugins\ZWave\config\", Common.ApiPath + @"\Plugins\ZWave\", @"");

                    // Add any app specific options here...
                    m_options.AddOptionBool("ConsoleOutput", false);
                    m_options.AddOptionBool("IntervalBetweenPolls", true);
                    m_options.AddOptionInt("PollInterval", poll);

                    // Lock the options
                    m_options.Lock();

                    // Create the OpenZWave Manager
                    m_manager = new ZWManager();
                    m_manager.Create();
                    m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);

                    // Add a driver
                    m_manager.AddDriver(@"\\.\COM" + port);

                    //logging.AddToLog("Setting poll interval: " + poll.ToString(), true);
                    //m_manager.SetPollInterval(poll);
                    logging.AddToLog(Common.ApiPath + @"\Plugins\ZWave\Config", true);
                    logging.AddToLog("Zwave plugin initialized", true);
                }

            }
            catch (Exception ex)
            {
                logging.AddToLog("Error initalizing plugin: " + ex.Message, true);
            }
        }
Esempio n. 18
0
        public static void SetUp()
        {
            if (USE_ZWAVE)
            {
                // Create the Options
                m_options = new ZWOptions();
                m_options.Create(zWaveConfigPath, @"", @"");
                m_options.Lock();

                // Create the OpenZWave Manager
                m_manager = new ZWManager();
                m_manager.Create();
                m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler);
                m_manager.AddDriver(zWaveSerialPortName);

                // Wait for Z-wave.
                do
                {
                    SleepForThreeSeconds();
                }
                while (m_nodesReady == false);
            }
        }