Beispiel #1
0
        private void EnqueueNotification(OpenZWaveNotification notification)
        {
            lock (_notification)
            {
                _notification.Enqueue(notification);
            }

            _event.Set();
        }
Beispiel #2
0
        private void OnNotification(ZWNotification notification)
        {
            var notification2 = new OpenZWaveNotification(_network, notification);

            if (_log)
            {
                _network.Log("controller notification: " + notification2.Type + ", " + notification2.NodeId);
            }

            EnqueueNotification(notification2);
        }
        private void Nodification(string operation, OpenZWaveNotification notification)
        {
            string deviceString;
            var    device = notification.Device;
            var    id     = notification.NodeId;

            if (device != null)
            {
                deviceString = device.BuildVirtualAddress(false, false);
            }
            else if (id > 0)
            {
                deviceString = "device id " + id;
            }
            else
            {
                deviceString = "unknown device";
            }

            var message = string.Format("Node {0}: {1}", operation, deviceString);

            _network.Log(message);
        }
        public void Process(OpenZWaveNotification notification)
        {
            if (_network.HomeId == null)
            {
                _network.SetHomeId(notification.HomeId);
            }

            if (_network.HomeId != notification.HomeId)
            {
                throw new Exception("Unexpected Home ID");
            }

            Debug.WriteLine(notification.NodeId + "\t" + notification.Type + "\t" + notification.Event + "\t" + notification.Value.GetValue());

            //TODO: fill in other cases
            switch (notification.Type)
            {
            case NotificationType.AllNodesQueried:
                _network.Log("All nodes queried");
                break;

            case NotificationType.AllNodesQueriedSomeDead:
                _network.Log("All nodes queried, some dead");
                break;

            case NotificationType.AwakeNodesQueried:
                _network.Log("All awake nodes queried");
                break;

            case NotificationType.ButtonOff:
            case NotificationType.ButtonOn:
            case NotificationType.ControllerCommand:
            case NotificationType.CreateButton:
            case NotificationType.DeleteButton:
            case NotificationType.DriverFailed:
            case NotificationType.DriverReady:
            case NotificationType.DriverRemoved:
            case NotificationType.DriverReset:
            case NotificationType.EssentialNodeQueriesComplete:
            case NotificationType.Group:
                break;

            case NotificationType.NodeAdded:
                var newDevice = new OpenZWaveDevice(_network, _network.Manager, notification.NodeId);
                _network.AddDevice(newDevice);
                break;

            case NotificationType.NodeEvent:
                var device = notification.Device;

                HandleDeviceConnected(device, true);

                device.Event.Update(notification.Event);
                break;

            case NotificationType.NodeNaming:
                Nodification("node named", notification);
                break;

            case NotificationType.NodeNew:
                Nodification("new device", notification);
                break;

            case NotificationType.NodeProtocolInfo:
                Nodification("protocol info", notification);
                break;

            case NotificationType.NodeQueriesComplete:
                Nodification("queries complete", notification);
                break;

            case NotificationType.NodeRemoved:
                Nodification("removed", notification);
                break;

            case NotificationType.Notification:
                HandleDeviceConnected(notification.Device, false);
                break;

            case NotificationType.PollingDisabled:
                Nodification("polling disabled", notification);
                break;

            case NotificationType.PollingEnabled:
                Nodification("polling enabled", notification);
                break;

            case NotificationType.SceneEvent:
                break;

            case NotificationType.ValueAdded:
                notification.Device.Values.Add(notification.Value);
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Add);
                break;

            case NotificationType.ValueRefreshed:
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Refresh);
                break;

            case NotificationType.ValueChanged:
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Change);
                break;

            case NotificationType.ValueRemoved:
                notification.Device.Values.Remove(notification.Value);
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Remove);
                break;

            default:
                throw new Exception("Unexpected notification type " + notification.Type);
            }
        }
Beispiel #5
0
        private void OnNotification(ZWNotification notification)
        {
            var notification2 = new OpenZWaveNotification(this, notification);

            _notificationProcessor.Process(notification2);
        }
Beispiel #6
0
        private void OnNotification(ZWNotification notification)
        {
            var notification2 = new OpenZWaveNotification(this, notification);

            _notificationProcessor.Process(notification2);
        }
        private void OnNotification(ZWNotification notification)
        {
            var notification2 = new OpenZWaveNotification(_network, notification);

            if (_log)
            {
                _network.Log("controller notification: " + notification2.Type + ", " + notification2.NodeId);
            }

            EnqueueNotification(notification2);
        }
        private void EnqueueNotification(OpenZWaveNotification notification)
        {
            lock (_notification)
            {
                _notification.Enqueue(notification);
            }

            _event.Set();
        }
        public void Process(OpenZWaveNotification notification)
        {
            if (_network.HomeId == null)
            {
                _network.SetHomeId(notification.HomeId);

            }

            if (_network.HomeId != notification.HomeId)
            {
                throw new Exception("Unexpected Home ID");
            }

            Debug.WriteLine(notification.NodeId + "\t" + notification.Type + "\t" + notification.Event + "\t" + notification.Value.GetValue());

            //TODO: fill in other cases
            switch (notification.Type)
            {
                case NotificationType.AllNodesQueried:
                    _network.Log("All nodes queried");
                    break;

                case NotificationType.AllNodesQueriedSomeDead:
                    _network.Log("All nodes queried, some dead");
                    break;

                case NotificationType.AwakeNodesQueried:
                    _network.Log("All awake nodes queried");
                    break;

                case NotificationType.ButtonOff:
                case NotificationType.ButtonOn:
                case NotificationType.ControllerCommand:
                case NotificationType.CreateButton:
                case NotificationType.DeleteButton:
                case NotificationType.DriverFailed:
                case NotificationType.DriverReady:
                case NotificationType.DriverRemoved:
                case NotificationType.DriverReset:
                case NotificationType.EssentialNodeQueriesComplete:
                case NotificationType.Group:
                    break;

                case NotificationType.NodeAdded:
                    var newDevice = new OpenZWaveDevice(_network, _network.Manager, notification.NodeId);
                    _network.AddDevice(newDevice);
                    break;

                case NotificationType.NodeEvent:
                    var device = notification.Device;

                    HandleDeviceConnected(device, true);

                    device.Event.Update(notification.Event);
                    break;

                case NotificationType.NodeNaming:
                    Nodification("node named", notification);
                    break;

                case NotificationType.NodeNew:
                    Nodification("new device", notification);
                    break;

                case NotificationType.NodeProtocolInfo:
                    Nodification("protocol info", notification);
                    break;

                case NotificationType.NodeQueriesComplete:
                    Nodification("queries complete", notification);
                    break;

                case NotificationType.NodeRemoved:
                    Nodification("removed", notification);
                    break;

                case NotificationType.Notification:
                    HandleDeviceConnected(notification.Device, false);
                    break;

                case NotificationType.PollingDisabled:
                    Nodification("polling disabled", notification);
                    break;

                case NotificationType.PollingEnabled:
                    Nodification("polling enabled", notification);
                    break;

                case NotificationType.SceneEvent:
                    break;

                case NotificationType.ValueAdded:
                    notification.Device.Values.Add(notification.Value);
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Add);
                    break;

                case NotificationType.ValueRefreshed:
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Refresh);
                    break;

                case NotificationType.ValueChanged:
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Change);
                    break;

                case NotificationType.ValueRemoved:
                    notification.Device.Values.Remove(notification.Value);
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Remove);
                    break;

                default:
                    throw new Exception("Unexpected notification type " + notification.Type);
            }
        }
        private void Nodification(string operation, OpenZWaveNotification notification)
        {
            string deviceString;
            var device = notification.Device;
            var id = notification.NodeId;

            if (device != null)
            {
                deviceString = device.BuildVirtualAddress(false, false);
            }
            else if (id > 0)
            {
                deviceString = "device id " + id;
            }
            else
            {
                deviceString = "unknown device";
            }

            var message = string.Format("Node {0}: {1}", operation, deviceString);

            _network.Log(message);
        }