Esempio n. 1
0
        public void ZWaveControllerTryStartPairingAlreadyPairing()
        {
            ZWaveController controller = SetupInitializedController();

            _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty);

            VerifyInitializedController(controller);

            ZWValueID valueId = new ZWValueID(0, 1, ZWValueID.ValueGenre.Basic, 2, 3, 4, ZWValueID.ValueType.Bool, 5);

            RaiseNotificationNoNodes(ZWNotification.Type.DriverReady, valueId);

            _zWaveManager.Setup(s => s.BeginControllerCommand(2, ZWControllerCommand.AddDevice, false, 0)).Returns(true);

            Mock <IZWavePairingMonitor> monitor = new Mock <IZWavePairingMonitor>(MockBehavior.Strict);

            monitor.Setup(m => m.PairingStarted());

            MockZWaveNode node = new MockZWaveNode();

            Assert.IsTrue(controller.TryStartPairing(node, monitor.Object));

            MockZWaveNode node2 = new MockZWaveNode();

            Assert.IsFalse(controller.TryStartPairing(node2, monitor.Object));

            Assert.IsFalse(controller.IsInitialized);
            _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1));
            _zWaveManager.Verify(s => s.BeginControllerCommand(2, ZWControllerCommand.AddDevice, false, 0), Times.Exactly(1));
            monitor.Verify(m => m.PairingStarted(), Times.Exactly(1));
        }
Esempio n. 2
0
 public void AddValueId(ZWValueID valueId)
 {
     if (!_valueIds.Any(v => v.GetCommandClassId() == valueId.GetCommandClassId() && v.GetId() == valueId.GetId()))
     {
         _valueIds.Add(valueId);
     }
 }
Esempio n. 3
0
        private static void ToggleSwitchValue(ZWManager manager, ZWValueID valueId)
        {
            bool switchValue;

            manager.GetValueAsBool(valueId, out switchValue);
            manager.SetValue(valueId, !switchValue);
        }
Esempio n. 4
0
        public void ZWaveNodeSetValueByte()
        {
            uint homeId = 0;
            byte nodeId = 1;

            ZWValueID.ValueGenre genre = ZWValueID.ValueGenre.Basic;
            byte commandClass          = 2;
            byte instance   = 3;
            byte valueIndex = 4;

            ZWValueID.ValueType type = ZWValueID.ValueType.Byte;
            byte      pollIntensity  = 5;
            ZWValueID id             = new ZWValueID(homeId, nodeId, genre, commandClass, instance, valueIndex, type, pollIntensity);

            Mock <IZWaveController> controller = new Mock <IZWaveController>(MockBehavior.Strict);

            controller.Setup(s => s.SetValue(id, 0x25));
            ZWaveNode.SetController(controller.Object);
            Mock <IInternalConfigurationManager> configManager = new Mock <IInternalConfigurationManager>();
            MockZWaveNode node = new MockZWaveNode();

            node.AddValueId(id);

            node.MockSetValue(valueIndex, commandClass, 0x25);

            controller.Verify(s => s.SetValue(id, 0x25), Times.Exactly(1));
        }
Esempio n. 5
0
        public void ZWaveNodesRemoveValueIdNotAvailable()
        {
            Mock <IZWaveController> controller = new Mock <IZWaveController>(MockBehavior.Strict);

            controller.Setup(s => s.IsInitialized).Returns(false);
            ZWaveNode.SetController(controller.Object);
            Mock <IInternalConfigurationManager> configManager = new Mock <IInternalConfigurationManager>();
            MockZWaveNode node = new MockZWaveNode();

            Assert.AreEqual(0, node.MockValueIds.Count());

            uint homeId = 0;
            byte nodeId = 1;

            ZWValueID.ValueGenre genre = ZWValueID.ValueGenre.Basic;
            byte commandClass          = 2;
            byte instance   = 3;
            byte valueIndex = 4;

            ZWValueID.ValueType type = ZWValueID.ValueType.Bool;
            byte      pollIntensity  = 5;
            ZWValueID id             = new ZWValueID(homeId, nodeId, genre, commandClass, instance, valueIndex, type, pollIntensity);

            node.RemoveValueId(id);
            Assert.AreEqual(0, node.MockValueIds.Count());
        }
Esempio n. 6
0
        public ValuePanelList(ZWValueID valueID) : base(valueID)
        {
            InitializeComponent();

            ValueListLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueListComboBox.Enabled = false;
            }

            String[] items;
            if (MainForm.Manager.GetValueListItems(valueID, out items))
            {
                ValueListComboBox.Items.Clear();
                foreach (String item in items)
                {
                    ValueListComboBox.Items.Add(item);
                }
            }

            String value;

            if (MainForm.Manager.GetValueListSelection(valueID, out value))
            {
                ValueListComboBox.Text = value;
            }

            SendChanges = true;
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValuePanelList"/> class.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public ValuePanelList( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            ValueListLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueListComboBox.Enabled = false;
            }

            String[] items;
            if (MainForm.Manager.GetValueListItems(valueID, out items))
            {
                ValueListComboBox.Items.Clear();
                foreach (String item in items)
                {
                    ValueListComboBox.Items.Add(item);
                }
            }

            String value;
            if (MainForm.Manager.GetValueListSelection(valueID, out value))
            {
                ValueListComboBox.Text = value;
            }

            SendChanges = true;
        }
Esempio n. 8
0
 private void RaiseNotification(ZWNotification.Type type, ZWValueID valueId, MockZWaveNode node)
 {
     _configManager.Setup(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>()).Returns(new List <ZWaveNode> {
         node
     });
     _zWaveManager.Raise(s => s.OnNotification += null, new NotificationEventArgs(_zWaveManager.Object, (byte)1, type, valueId, 2));
 }
Esempio n. 9
0
 public NotificationEventArgs(IZWaveManager manager, byte nodeId, ZWNotification.Type notificationType, ZWValueID valueId, UInt32 homeId)
 {
     Manager          = manager;
     NodeId           = nodeId;
     NotificationType = notificationType;
     ValueId          = valueId;
     HomeId           = homeId;
 }
Esempio n. 10
0
        public void RemoveValueId(ZWValueID valueId)
        {
            ZWValueID valueIdForRemoval = _valueIds.SingleOrDefault(v => v.GetCommandClassId() == valueId.GetCommandClassId() && v.GetIndex() == valueId.GetIndex());

            if (valueIdForRemoval != null)
            {
                _valueIds.Remove(valueIdForRemoval);
            }
        }
Esempio n. 11
0
        private object GetValue(ZWValueID valueId)
        {
            string valueString;
            bool   valueBool;
            byte   valueByte;
            double valueDouble;
            int    valueInt;
            short  valueShort;

            if (valueId.Type == ZWValueType.Bool && _manager.GetValueAsBool(valueId, out valueBool))
            {
                return(valueBool);
            }

            if (valueId.Type == ZWValueType.List && _manager.GetValueListSelection(valueId, out valueString))
            {
                return(valueString);
            }

            if (valueId.Type == ZWValueType.Byte && _manager.GetValueAsByte(valueId, out valueByte))
            {
                return((double)valueByte);
            }

            if (valueId.Type == ZWValueType.Decimal && _manager.GetValueAsString(valueId, out valueString) && double.TryParse(valueString, out valueDouble))
            {
                return(valueDouble);
            }

            if (valueId.Type == ZWValueType.Int && _manager.GetValueAsInt(valueId, out valueInt))
            {
                return((double)valueInt);
            }

            if (valueId.Type == ZWValueType.Short && _manager.GetValueAsShort(valueId, out valueShort))
            {
                return((double)valueShort);
            }

            if (_manager.GetValueAsString(valueId, out valueString))
            {
                if (!string.IsNullOrEmpty(valueString) && double.TryParse(valueString, out valueDouble))
                {
                    return(valueDouble);
                }

                if (!string.IsNullOrEmpty(valueString) && bool.TryParse(valueString, out valueBool))
                {
                    return(valueBool);
                }

                return(valueString);
            }

            return(null);
        }
Esempio n. 12
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="v">The v.</param>
        /// <returns></returns>
        private string GetValue(ZWValueID v)
        {
            switch (v.Type)
            {
            case ZWValueType.Bool:
                bool r1;
                ZWManager.Instance.GetValueAsBool(v, out r1);
                return(r1.ToString());

            case ZWValueType.Byte:
                byte r2;
                ZWManager.Instance.GetValueAsByte(v, out r2);
                return(r2.ToString());

            case ZWValueType.Decimal:
                decimal r3;
                string  r3s;
                ZWManager.Instance.GetValueAsString(v, out r3s);
                return(r3s);

            //throw new NotImplementedException("Decimal");
            //m_manager.GetValueAsDecimal(v, out r3);
            //return r3.ToString();
            case ZWValueType.Int:
                Int32 r4;
                ZWManager.Instance.GetValueAsInt(v, out r4);
                return(r4.ToString());

            case ZWValueType.List:
                string[] r5;
                ZWManager.Instance.GetValueListItems(v, out r5);
                string r6 = "";
                foreach (string s in r5)
                {
                    r6 += s;
                    r6 += "/";
                }
                return(r6);

            case ZWValueType.Schedule:
                return("Schedule");

            case ZWValueType.Short:
                short r7;
                ZWManager.Instance.GetValueAsShort(v, out r7);
                return(r7.ToString());

            case ZWValueType.String:
                string r8;
                ZWManager.Instance.GetValueAsString(v, out r8);
                                                    return(r8);

                                                default:
                                                    return("");
            }
        }
Esempio n. 13
0
        private ZWValueID GetValueId(byte index, byte commandClassId)
        {
            ZWValueID valueId = _valueIds.SingleOrDefault(v => v.GetCommandClassId() == commandClassId && v.GetIndex() == index);

            if (valueId == null)
            {
                throw new ArgumentException("The index and CommandClassID do not match any available values!");
            }
            return(valueId);
        }
Esempio n. 14
0
        public void DisablePoll(byte NodeID, String ValueLabel)
        {
            ZWValueID id = GetValueID(m_nodeList[3], ValueLabel);

            if (id != null)
            {
                Log("Message", "Enabled poll on " + id.GetId().ToString());
                m_manager.EnablePoll(id);
            }
        }
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="v">The v.</param>
        /// <returns></returns>
        private string GetValue(ZWValueID v)
        {
            var manager = ZWManager.Instance;

            switch (v.Type)
            {
            case ZWValueType.Bool:
                bool r1;
                manager.GetValueAsBool(v, out r1);
                return(r1.ToString());

            case ZWValueType.Byte:
                byte r2;
                manager.GetValueAsByte(v, out r2);
                return(r2.ToString());

            case ZWValueType.Decimal:
                decimal r3;
                string  r3s;
                manager.GetValueAsString(v, out r3s);
                return(r3s);

            //throw new NotImplementedException("Decimal");
            //m_manager.GetValueAsDecimal(v, out r3);
            //return r3.ToString();
            case ZWValueType.Int:
                Int32 r4;
                manager.GetValueAsInt(v, out r4);
                return(r4.ToString());

            case ZWValueType.List:
                string value;
                manager.GetValueListSelection(v, out value);
                return(value);

            // string[] r5;
            // m_manager.GetValueListItems(v, out r5);
            // return string.Join("|", r5);
            case ZWValueType.Schedule:
                return("Schedule");

            case ZWValueType.Short:
                short r7;
                manager.GetValueAsShort(v, out r7);
                return(r7.ToString());

            case ZWValueType.String:
                string r8;
                manager.GetValueAsString(v, out r8);
                return(r8);

            default:
                return("");
            }
        }
Esempio n. 16
0
        private static string GetValue(ZWValueID value, ZWManager manager)
        {
            switch (value.GetType())
            {
            case ZWValueID.ValueType.Bool:
                bool boolValue;
                manager.GetValueAsBool(value, out boolValue);
                return(boolValue.ToString());

            case ZWValueID.ValueType.Byte:
                byte byteValue;
                manager.GetValueAsByte(value, out byteValue);
                return(byteValue.ToString());

            case ZWValueID.ValueType.Decimal:
                decimal decimalValue;
                manager.GetValueAsDecimal(value, out decimalValue);
                return(decimalValue.ToString());

            case ZWValueID.ValueType.Int:
                int intValue;
                manager.GetValueAsInt(value, out intValue);
                return(intValue.ToString());

            case ZWValueID.ValueType.List:
                string[] listValues;
                manager.GetValueListItems(value, out listValues);
                string listValue = "";
                if (listValues != null)
                {
                    foreach (string s in listValues)
                    {
                        listValue += s;
                        listValue += "/";
                    }
                }
                return(listValue);

            case ZWValueID.ValueType.Schedule:
                return("Schedule");

            case ZWValueID.ValueType.Short:
                short shortValue;
                manager.GetValueAsShort(value, out shortValue);
                return(shortValue.ToString());

            case ZWValueID.ValueType.String:
                string stringValue;
                manager.GetValueAsString(value, out stringValue);
                return(stringValue);

            default:
                return("");
            }
        }
Esempio n. 17
0
 public Value GetValue(ZWValueID zwv)
 {
     foreach (Value value in m_values)
     {
         if (value.CommandClassID == zwv.GetCommandClassId().ToString() && value.Index == zwv.GetIndex().ToString())
         {
             return(value);
         }
     }
     return(new Value());
 }
Esempio n. 18
0
 public Value GetValue(ZWValueID zwv)
 {
     foreach (Value value in m_values)
     {
         if (value.CommandClassID == zwv.GetCommandClassId().ToString() && value.Index == zwv.GetIndex().ToString())
         {
             return value;
         }
     }
     return new Value();
 }
Esempio n. 19
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="v">The v.</param>
        /// <returns></returns>
        private string GetValue(ZWValueID v)
        {
            switch (v.GetType())
            {
            case ZWValueID.ValueType.Bool:
                bool r1;
                m_manager.GetValueAsBool(v, out r1);
                return(r1.ToString());

            case ZWValueID.ValueType.Byte:
                byte r2;
                m_manager.GetValueAsByte(v, out r2);
                return(r2.ToString());

            case ZWValueID.ValueType.Decimal:
                decimal r3;
                m_manager.GetValueAsDecimal(v, out r3);
                return(r3.ToString());

            case ZWValueID.ValueType.Int:
                Int32 r4;
                m_manager.GetValueAsInt(v, out r4);
                return(r4.ToString());

            case ZWValueID.ValueType.List:
                string[] r5;
                m_manager.GetValueListItems(v, out r5);
                string r6 = "";
                foreach (string s in r5)
                {
                    r6 += s;
                    r6 += "/";
                }
                return(r6);

            case ZWValueID.ValueType.Schedule:
                return("Schedule");

            case ZWValueID.ValueType.Short:
                short r7;
                m_manager.GetValueAsShort(v, out r7);
                return(r7.ToString());

            case ZWValueID.ValueType.String:
                string r8;
                m_manager.GetValueAsString(v, out r8);
                return(r8);

            default:
                return("");
            }
        }
Esempio n. 20
0
        public ValuePanelButton(ZWValueID valueID) : base(valueID)
        {
            InitializeComponent();

            ValueButtonButton.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueButtonButton.Enabled = false;
            }

            SendChanges = true;
        }
Esempio n. 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValuePanelButton"/> class.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public ValuePanelButton( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            ValueButtonButton.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueButtonButton.Enabled = false;
            }

            SendChanges = true;
        }
Esempio n. 22
0
        public void ZWaveControllerSetByteValueId()
        {
            ZWaveController controller = SetupInitializedController();

            _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty);

            VerifyInitializedController(controller);

            ZWValueID valueId = new ZWValueID(1, 2, ZWValueID.ValueGenre.Basic, 3, 4, 5, ZWValueID.ValueType.Byte, 6);

            _zWaveManager.Setup(s => s.SetValue(valueId, 0x25));
            controller.SetValue(valueId, 0x25);
            _zWaveManager.Verify(s => s.SetValue(valueId, 0x25), Times.Exactly(1));
        }
Esempio n. 23
0
        private void HandleNodeValueNotification(ZwaveDevice device, ZWValueID valueId)
        {
            if (valueId.CommandClassId == 112)
            {
                // command class configuration
                return;
            }

            if (valueId.CommandClassId == 134)
            {
                // command class version
                return;
            }

            if (valueId.CommandClassId == 37)
            {
                // command class switch binary
                device.IsSwitchBinary = true;
            }

            var valueUnit  = _manager.GetValueUnits(valueId) ?? string.Empty;
            var valueLabel = _manager.GetValueLabel(valueId);
            var valueValue = GetValue(valueId);

            if (valueId.CommandClassId == 128 && valueValue is double)
            {
                // command class battery
                var battery = (double)valueValue;
                if (battery > 90)
                {
                    device.BatteryStatus = DeviceBatteryStatus.Full;
                }
                else if (battery > 25)
                {
                    device.BatteryStatus = DeviceBatteryStatus.Good;
                }
                else
                {
                    device.BatteryStatus = DeviceBatteryStatus.Low;
                }
                return;
            }

            if (valueValue != null)
            {
                valueLabel = valueLabel.Replace(' ', '_');
                OnVariableChanged(device, valueLabel, valueValue, valueUnit);
            }
        }
Esempio n. 24
0
        public void ZWaveSwitchTurnOff()
        {
            ZWValueID valueId = new ZWValueID(1, 3, ZWValueID.ValueGenre.User, 0x25, 10, 0, ZWValueID.ValueType.Bool, 2);
            Mock <IZWaveController> zWaveController = new Mock <IZWaveController>();

            zWaveController.Setup(s => s.SetValue(valueId, false));
            ZWaveNode.SetController(zWaveController.Object);
            ZWaveSwitch zWaveSwitch = new ZWaveSwitch();

            zWaveSwitch.AddValueId(valueId);

            zWaveSwitch.TurnOff();

            zWaveController.Verify(s => s.SetValue(valueId, false), Times.Exactly(1));
        }
Esempio n. 25
0
        /// <summary>
        /// Adds the value.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public void AddValue(ZWValueID valueID)
        {
            IList <ZWValueID> list = GetValues(valueID.Genre);

            var id = list.Where(v => v.CommandClassId == valueID.CommandClassId && v.Id == valueID.Id).FirstOrDefault();

            if (id != null)
            {
                list[list.IndexOf(id)] = valueID;
            }
            else
            {
                list.Add(valueID);
            }
        }
Esempio n. 26
0
        public void ZWaveDimmableSwitchSetLevel()
        {
            ZWValueID valueId = new ZWValueID(1, 3, ZWValueID.ValueGenre.User, 0x26, 10, 0, ZWValueID.ValueType.Byte, 2);
            Mock <IZWaveController> zWaveController = new Mock <IZWaveController>(MockBehavior.Strict);

            zWaveController.Setup(s => s.SetValue(valueId, 63));
            ZWaveNode.SetController(zWaveController.Object);
            ZWaveDimmableSwitch zWaveSwitch = new ZWaveDimmableSwitch();

            zWaveSwitch.AddValueId(valueId);

            zWaveSwitch.SetLightLevel(0.25);

            zWaveController.Verify(s => s.SetValue(valueId, 63), Times.Exactly(1));
        }
Esempio n. 27
0
        private void TestNoChangeAfterNotification(ZWNotification.Type notificationType)
        {
            ZWaveController controller = SetupInitializedController();

            _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty);

            VerifyInitializedController(controller);

            ZWValueID valueId = new ZWValueID(0, 1, ZWValueID.ValueGenre.Basic, 2, 3, 4, ZWValueID.ValueType.Bool, 5);

            RaiseNotificationNoNodes(ZWNotification.Type.ValueChanged, valueId);

            Assert.IsFalse(controller.IsInitialized);
            _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1));
        }
Esempio n. 28
0
        public void ZWaveControllerValueAdded()
        {
            ZWaveController controller = SetupInitializedController();

            _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty);

            VerifyInitializedController(controller);

            ZWValueID     valueId = new ZWValueID(0, 1, ZWValueID.ValueGenre.Basic, 2, 3, 4, ZWValueID.ValueType.Bool, 5);
            MockZWaveNode node    = RaiseNotification(ZWNotification.Type.ValueAdded, false, valueId);

            Assert.IsFalse(controller.IsInitialized);
            Assert.AreEqual(1, node.MockValueIds.Count());
            Assert.AreSame(valueId, node.MockValueIds.First());
            _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1));
        }
Esempio n. 29
0
        private ZWaveSwitch GetZWaveSwitch(ZWValueID value, Node node)
        {
            bool switchValue;
            var  successfullyReadValue = _manager.GetValueAsBool(value, out switchValue);
            var  zWaveSwitch           = new ZWaveSwitch(new ZWaveValueIdentity(node.HomeId, node.NodeId, value.GetId()));

            if (successfullyReadValue)
            {
                zWaveSwitch.SwitchState = switchValue ? SwitchState.On : SwitchState.Off;
            }
            else
            {
                zWaveSwitch.SwitchState = SwitchState.Unknown;
            }
            return(zWaveSwitch);
        }
Esempio n. 30
0
        public byte NodeLevel(byte NodeID)
        {
            byte      valueByte = 0;
            ZWValueID valueID   = GetValueID(NodeID, "Level");

            if (valueID == null)
            {
                return(0);
            }

            if (m_manager.GetValueAsByte(valueID, out valueByte))
            {
                Log(String.Format("Got level value for node {0}, and it's {1}", NodeID, valueByte));
            }

            return(valueByte);
        }
Esempio n. 31
0
 internal static string GetValue(ZWValueID v)
 {
     switch (v.GetType())
     {
         case ZWValueID.ValueType.Bool:
             bool r1;
             MainForm.Manager.GetValueAsBool(v, out r1);
             return r1.ToString();
         case ZWValueID.ValueType.Byte:
             byte r2;
             MainForm.Manager.GetValueAsByte(v, out r2);
             return r2.ToString();
         case ZWValueID.ValueType.Decimal:
             decimal r3;
             MainForm.Manager.GetValueAsDecimal(v, out r3);
             return r3.ToString();
         case ZWValueID.ValueType.Int:
             Int32 r4;
             MainForm.Manager.GetValueAsInt(v, out r4);
             return r4.ToString();
         case ZWValueID.ValueType.List:
             string[] r5;
             MainForm.Manager.GetValueListItems(v, out r5);
             string r6 = "";
             foreach (string s in r5)
             {
                 r6 += s;
                 r6 += "/";
             }
             return r6;
         case ZWValueID.ValueType.Schedule:
             return "Schedule";
         case ZWValueID.ValueType.Short:
             short r7;
             MainForm.Manager.GetValueAsShort(v, out r7);
             return r7.ToString();
         case ZWValueID.ValueType.String:
             string r8;
             MainForm.Manager.GetValueAsString(v, out r8);
             return r8;
         default:
             return "";
     }
 }
Esempio n. 32
0
        public ValuePanelBool( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueCheckBox.Enabled = false;
            }

            ValueCheckBox.Text = MainForm.Manager.GetValueLabel(valueID);
            
            bool state;
            if (MainForm.Manager.GetValueAsBool(valueID, out state))
            {
                ValueCheckBox.Checked = state;
            }

            SendChanges = true;
        }
Esempio n. 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValuePanelString"/> class.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public ValuePanelString( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            ValueStringLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueStringTextBox.Enabled = false;
            }

            String value;
            if (MainForm.Manager.GetValueAsString(valueID, out value))
            {
                ValueStringTextBox.Text = value;
            }

            SendChanges = true;
        }
Esempio n. 34
0
        public byte NodeBasic(byte NodeID)
        {
            byte      valueByte = 0;
            ZWValueID valueID   = GetValueID(NodeID, "Basic");

            if (valueID == null)
            {
                return(0);
            }


            m_manager.GetNodeBasic(m_homeId, NodeID);

            if (m_manager.GetValueAsByte(valueID, out valueByte))
            {
                Log(String.Format("Got basic value for node {0}, and it's {1}", NodeID, valueByte));
            }

            return(valueByte);
        }
Esempio n. 35
0
        public ValuePanelBool(ZWValueID valueID) : base(valueID)
        {
            InitializeComponent();

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueCheckBox.Enabled = false;
            }

            ValueCheckBox.Text = MainForm.Manager.GetValueLabel(valueID);

            bool state;

            if (MainForm.Manager.GetValueAsBool(valueID, out state))
            {
                ValueCheckBox.Checked = state;
            }

            SendChanges = true;
        }
Esempio n. 36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValuePanelDecimal"/> class.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public ValuePanelDecimal( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            ValueDecimalLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueDecimalTextBox.Enabled = false;
				ValueDecimalButtonSet.Enabled = false;
            }

            Decimal value;
            if (MainForm.Manager.GetValueAsDecimal(valueID, out value))
            {
                ValueDecimalTextBox.Text = value.ToString();
            }

            SendChanges = true;
        }
Esempio n. 37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValuePanelString"/> class.
        /// </summary>
        /// <param name="valueID">The value identifier.</param>
        public ValuePanelString(ZWValueID valueID) : base(valueID)
        {
            InitializeComponent();

            ValueStringLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueStringTextBox.Enabled = false;
            }

            String value;

            if (MainForm.Manager.GetValueAsString(valueID, out value))
            {
                ValueStringTextBox.Text = value;
            }

            SendChanges = true;
        }
Esempio n. 38
0
        public ValuePanelInt( ZWValueID valueID ): base( valueID )
        {
            InitializeComponent();

            ValueIntLabel.Text = MainForm.Manager.GetValueLabel(valueID);

            if (MainForm.Manager.IsValueReadOnly(valueID))
            {
                ValueIntNumericUpDown.Enabled = false;
                ValueIntButtonSet.Visible = false;
            }

            Int32 value;
            if (MainForm.Manager.GetValueAsInt(valueID, out value))
            {
                ValueIntNumericUpDown.Value = Convert.ToDecimal(value);
            }

            SendChanges = true;
        }
 private string GetValue(ZWValueID zValueId)
 {
     switch (zValueId.GetType())
     {
         case ZWValueID.ValueType.Bool:
             bool r1;
             MManager.GetValueAsBool(zValueId, out r1);
             return r1.ToString();
         case ZWValueID.ValueType.Byte:
             byte r2;
             MManager.GetValueAsByte(zValueId, out r2);
             return r2.ToString(CultureInfo.InvariantCulture);
         case ZWValueID.ValueType.Decimal:
             decimal r3;
             MManager.GetValueAsDecimal(zValueId, out r3);
             return r3.ToString(CultureInfo.InvariantCulture);
         case ZWValueID.ValueType.Int:
             int r4;
             MManager.GetValueAsInt(zValueId, out r4);
             return r4.ToString(CultureInfo.InvariantCulture);
         case ZWValueID.ValueType.List:
             string r6;
             MManager.GetValueListSelection(zValueId, out r6);
             return r6;
         case ZWValueID.ValueType.Schedule:
             return "Schedule";
         case ZWValueID.ValueType.Short:
             short r7;
             MManager.GetValueAsShort(zValueId, out r7);
             return r7.ToString(CultureInfo.InvariantCulture);
         case ZWValueID.ValueType.String:
             string r8;
             MManager.GetValueAsString(zValueId, out r8);
             return r8;
         default:
             return "";
     }
 }
Esempio n. 40
0
 public void RemoveValue(ZWValueID valueID)
 {
     m_values.Remove(valueID);
 }
Esempio n. 41
0
 public void AddValue(ZWValueID valueID)
 {
     m_values.Add(valueID);
 }
Esempio n. 42
0
 public ZWaveValue(ZWValueID valueId, ZWManager manager)
 {
     _valueId = valueId;
     _properties = new ZWaveValueProperties(_valueId, manager);
 }
Esempio n. 43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValuePanel"/> class.
 /// </summary>
 /// <param name="valueID">The value identifier.</param>
 public ValuePanel( ZWValueID valueID )
 {
     m_valueID = valueID;
     InitializeComponent();
 }
        //private async Task UpdateLastHeardFrom(byte NodeId)
        //{
        //    using (zvsContext context = new zvsContext())
        //    {
        //        Device device = await context.Devices.FirstOrDefaultAsync(o => o.Type.Adapter.AdapterGuid == this.AdapterGuid &&
        //                           o.NodeNumber == NodeId);

        //        if (device != null)
        //        {
        //            device.LastHeardFrom = DateTime.Now;
        //        }

        //        var result = await context.TrySaveChangesAsync();
        //        if (result.HasError)
        //            zvsEngine.log.Error(result.Message);
        //    }

        //}

        private static DataType ConvertType(ZWValueID zwValueId)
        {
            var dataType = DataType.NONE;
            var openZwaveVType = zwValueId.GetType();

            switch (openZwaveVType)
            {
                case ZWValueID.ValueType.Bool:
                    dataType = DataType.BOOL;
                    break;
                case ZWValueID.ValueType.Button:
                    dataType = DataType.STRING;
                    break;
                case ZWValueID.ValueType.Byte:
                    dataType = DataType.BYTE;
                    break;
                case ZWValueID.ValueType.Decimal:
                    dataType = DataType.DECIMAL;
                    break;
                case ZWValueID.ValueType.Int:
                    dataType = DataType.INTEGER;
                    break;
                case ZWValueID.ValueType.List:
                    dataType = DataType.LIST;
                    break;
                case ZWValueID.ValueType.Schedule:
                    dataType = DataType.STRING;
                    break;
                case ZWValueID.ValueType.Short:
                    dataType = DataType.SHORT;
                    break;
                case ZWValueID.ValueType.String:
                    dataType = DataType.STRING;
                    break;
            }
            return dataType;
        }
Esempio n. 45
0
 string GetValue(ZWValueID v)
 {
     switch (v.GetType())
     {
         case ZWValueID.ValueType.Bool:
             bool r1;
             m_manager.GetValueAsBool(v, out r1);
             return r1.ToString();
         case ZWValueID.ValueType.Byte:
             byte r2;
             m_manager.GetValueAsByte(v, out r2);
             return r2.ToString();
         case ZWValueID.ValueType.Decimal:
             decimal r3;
             m_manager.GetValueAsDecimal(v, out r3);
             return r3.ToString();
         case ZWValueID.ValueType.Int:
             Int32 r4;
             m_manager.GetValueAsInt(v, out r4);
             return r4.ToString();
         case ZWValueID.ValueType.List:
            // string[] r5;
           //  m_manager.GetValueListSelection(v, out r5);
             //string r6 = "";
             //foreach (string s in r5)
            // {
            //     r6 += s;
             //    r6 += "/";
             //}
             string r6 = string.Empty;
             m_manager.GetValueListSelection(v, out r6);
             return r6;
         case ZWValueID.ValueType.Schedule:
             return "Schedule";
         case ZWValueID.ValueType.Short:
             short r7;
             m_manager.GetValueAsShort(v, out r7);
             return r7.ToString();
         case ZWValueID.ValueType.String:
             string r8;
             m_manager.GetValueAsString(v, out r8);
             return r8;
         default:
             return "";
     }
 }
 private DataType TranslateDataType(ZWValueID.ValueType type)
 {
     //Set parameter types for command
     switch (type)
     {
         case ZWValueID.ValueType.List:
             return DataType.LIST;
         case ZWValueID.ValueType.Byte:
             return DataType.BYTE;
         case ZWValueID.ValueType.Decimal:
             return DataType.DECIMAL;
         case ZWValueID.ValueType.Int:
             return DataType.INTEGER;
         case ZWValueID.ValueType.String:
             return DataType.STRING;
         case ZWValueID.ValueType.Short:
             return DataType.SHORT;
         case ZWValueID.ValueType.Bool:
             return DataType.BOOL;
         default:
             return DataType.NONE;
     }
 }
Esempio n. 47
0
        public void SetValue(ZWValueID valueID)
        {
            int valueIndex = -1;

            for (int index = 0; index < m_values.Count; index++)
            {
                if (m_values[index].GetId() == valueID.GetId())
                {
                    valueIndex = index;
                    break;
                }
            }

            if (valueIndex >= 0)
            {
                m_values[valueIndex] = valueID;
            }
            else
            {
                AddValue(valueID);
            }
        }
Esempio n. 48
0
        //private readonly ZWValueID _valueId;
        //private readonly ZWManager _manager;
        public ZWaveValueProperties(ZWValueID valueId, ZWManager manager)
        {
            //_manager = manager;
            //_valueId = valueId;

            _commandClassId = (Enums.CommandClass) valueId.GetCommandClassId();
            _genre = valueId.GetGenre();
            _value = valueId.GetValue(manager);
            _help = manager.GetValueHelp(valueId);
            _pollingEnabled = manager.IsValuePolled(valueId);
            _homeId = valueId.GetHomeId();
            _id = valueId.GetId();
            _index = valueId.GetIndex();
            _instance = valueId.GetInstance();
            _label = manager.GetValueLabel(valueId);
            _nodeId = valueId.GetNodeId();
            _type = valueId.GetType();
            _units = manager.GetValueUnits(valueId);
        }
Esempio n. 49
0
 public OpenZWaveDeviceValue(OpenZWaveNetwork network, ZWValueID value)
 {
     _network = network;
     _value = value;
 }