黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
 
namespace ZigBee.Device
{
    public class TemperatureSensor: CommonDevice
    {
        /// <summary>
        /// 因为这两个东西共用同一个设备ID,所以 1:温度传感器  2:湿度传感器
        /// </summary>
        public int SensorDiv = 1;
 
        /// <summary>
        /// 温度
        /// </summary>
        public decimal currentTemperature = 0;
        /// <summary>
        /// 湿度
        /// </summary>
        public decimal currentHumidity = 0;
 
        public TemperatureSensor()
        {
            this.Type = DeviceType.TemperatureSensor ;
        }
 
        /// <summary>
        /// 读取温/湿度
        /// </summary>
        public void ReadTemperatureOrHumidity()
        {
            if (SensorDiv == 1)
            {
                ReadAttri(Device.Cluster_ID.TemperatureMeasurement, AttriButeId.MeasuredValue);
            }
            else if (SensorDiv == 2)
            {
                ReadAttri(Device.Cluster_ID.RelativeHumidityMeasurement, AttriButeId.MeasuredValue);
            }
        }
    }
}