public RelativeHumidityMeasurement(AttributesCollection coll)
		{
			MeasuredValue = float.NaN;
			MinMeasuredValue = float.NaN;
			MaxMeasuredValue = float.NaN;
			Tolerance = float.NaN;
			if (coll.ContainsKey(0x0000))
			{
				var attr = coll[0x0000];
				if (attr.DataType == ZigbeeDataType.UInt16)
					MeasuredValue = ((ushort)attr.Data) / 100f;
			}
			if (coll.ContainsKey(0x0001))
			{
				var attr = coll[0x0001];
				if (attr.DataType == ZigbeeDataType.UInt16)
					MinMeasuredValue = ((ushort)attr.Data) / 100f;
			}
			if (coll.ContainsKey(0x0002))
			{
				var attr = coll[0x0002];
				if (attr.DataType == ZigbeeDataType.UInt16)
					MaxMeasuredValue = ((ushort)attr.Data) / 100f;
			}
			if (coll.ContainsKey(0x0003))
			{
				var attr = coll[0x0003];
				if (attr.DataType == ZigbeeDataType.UInt16)
					Tolerance = ((ushort)attr.Data) / 100f;
			}
		}
Example #2
0
 public TemperatureMeasurement(AttributesCollection coll)
 {
     MeasuredValue    = float.NaN;
     MinMeasuredValue = float.NaN;
     MaxMeasuredValue = float.NaN;
     Tolerance        = float.NaN;
     if (coll.ContainsKey(0x0000))
     {
         var attr = coll[0x0000];
         if (attr.DataType == ZigbeeDataType.Int16)
         {
             MeasuredValue = ((short)attr.Data) / 100f;
         }
     }
     if (coll.ContainsKey(0x0001))
     {
         var attr = coll[0x0001];
         if (attr.DataType == ZigbeeDataType.Int16)
         {
             MinMeasuredValue = ((short)attr.Data) / 100f;
         }
     }
     if (coll.ContainsKey(0x0002))
     {
         var attr = coll[0x0002];
         if (attr.DataType == ZigbeeDataType.Int16)
         {
             MaxMeasuredValue = ((short)attr.Data) / 100f;
         }
     }
     if (coll.ContainsKey(0x0003))
     {
         var attr = coll[0x0003];
         if (attr.DataType == ZigbeeDataType.UInt16)
         {
             Tolerance = ((ushort)attr.Data) / 100f;
         }
     }
 }
        public void Should_Get_Set_Attribute_Value_By_Expression_Indexer()
        {
            var attrs = new AttributesCollection
            {
                [() => User.Name] = "John"
            };

            attrs[() => User.Name].Should().Be("John");

            ((IReadOnlyDictionary <string, object>)attrs)["User.Name"].Should().Be("John");

            attrs.Count.Should().Be(1);

            attrs.Keys.ToArray().Should().BeEquivalentTo("User.Name");

            attrs.Values.Cast <string>().ToArray().Should().BeEquivalentTo("John");

            attrs.ContainsKey("User.Name").Should().BeTrue();
            attrs.ContainsKey("Document.Revision").Should().BeFalse();

            object value;

            attrs.TryGetValue("User.Name", out value).Should().BeTrue();
            ((string)value).Should().Be("John");

            attrs.ToArray()
            .Should().HaveCount(1);

            IEnumerable a          = attrs;
            var         enumerator = a.GetEnumerator();

            enumerator.MoveNext().Should().BeTrue();
            enumerator.Current.Should().BeOfType <KeyValuePair <string, object> >();
            enumerator.Should().NotBeNull();
            var kvp = (KeyValuePair <string, object>)enumerator.Current;

            kvp.Key.Should().Be("User.Name");
            kvp.Value.Should().Be("John");
        }