| | |
| | | |
| | | Button roomListBtn; |
| | | |
| | | Button temperatureText; |
| | | Button temperatureText; |
| | | |
| | | Button humidityText; |
| | | |
| | |
| | | { |
| | | //return; |
| | | } |
| | | |
| | | |
| | | //if (common.Type == DeviceType.TemperatureSensor) |
| | | //{ |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityText.Text = "--%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = int.Parse(strValue) * 0.1; |
| | | } |
| | | //0℃ |
| | | temperatureText.Text = "0.0℃"; |
| | | room.Temperatrue = 0; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | } |
| | | else if (common.DeviceStatusReport.CluterID == 1029) |
| | | } |
| | | else if (common.DeviceStatusReport.CluterID == 1029) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityText.Text = "--%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = int.Parse(strValue) * 0.1; |
| | | } |
| | | //0 |
| | | humidityText.Text = "--%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | |
| | | |
| | | var roomName = new Button() |
| | | { |
| | | X = Application.GetRealWidth(5), |
| | | X = Application.GetRealWidth(29), |
| | | Width = Application.GetRealWidth(190), |
| | | Text = room.Name, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | TextSize=10, |
| | | IsBold=true |
| | | TextSize = 10, |
| | | TextAlignment=TextAlignment.CenterLeft, |
| | | IsBold = true |
| | | }; |
| | | roomNameBackground.AddChidren(roomName); |
| | | |
| | | roomNameBackground.Width = (roomName.GetTextWidth() + Application.GetRealWidth(100)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : roomName.GetTextWidth() + Application.GetRealWidth(100); |
| | | roomName.Width = roomNameBackground.Width - Application.GetRealWidth(40); |
| | | |
| | | roomTemperatureBackground = new FrameLayout |
| | | { |
| | |
| | | { |
| | | X = Application.GetRealWidth(69), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(58), |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = Math.Abs(room.Temperatrue) <= 0 ? "--℃" : $"{room.Temperatrue}℃", |
| | | TextSize=14 |
| | | Text = room.Temperatrue == 0 ? "--℃" : $"{room.Temperatrue}℃", |
| | | TextSize = 14, |
| | | TextAlignment=TextAlignment.CenterLeft |
| | | }; |
| | | roomTemperatureBackground.AddChidren(temperatureText); |
| | | temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60); |
| | | |
| | | var humidityIcon = new Button |
| | | { |
| | | X = Application.GetRealWidth(200), |
| | | X = temperatureText.Right, |
| | | Width = Application.GetMinRealAverage(58), |
| | | Height = Application.GetMinRealAverage(58), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | |
| | | humidityText = new Button |
| | | { |
| | | X = Application.GetRealWidth(260), |
| | | X = humidityIcon.Right, |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(58), |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = Math.Abs(room.Temperatrue) <= 0 ? "--%" : $"{room.Humidity}%", |
| | | TextSize=14 |
| | | Text = room.Humidity == 0 ? "--%" : $"{room.Humidity}%", |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | roomTemperatureBackground.AddChidren(humidityText); |
| | | |
| | | humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60); |
| | | roomTemperatureBackground.Width = (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)); |
| | | |
| | | if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) |
| | | { |
| | |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev); |
| | | } |
| | | |
| | | |
| | | roomListBtn = new Button() |
| | | { |