| | |
| | | deviceUI.CommonDevice.LastDateTime = DateTime.Now; |
| | | } |
| | | break; |
| | | |
| | | case DeviceType.TemperatureSensor: |
| | | //温度 |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | { |
| | | var tempera = deviceUI.CommonDevice as TemperatureSensor; |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | tempera.Temperatrue = 0; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | var row = rowLayout.GetChildren(0) as CategoryFunctionRow; |
| | | row.SetStatuText(deviceUI.GetDeviceStatu()); |
| | | } |
| | | } |
| | | } |
| | | //湿度 |
| | | if (common.DeviceStatusReport.CluterID == 1029) |
| | | { |
| | | var tempera = deviceUI.CommonDevice as TemperatureSensor; |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | tempera.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | tempera.LastDateTime = DateTime.Now; |
| | | } |
| | | var row = rowLayout.GetChildren(0) as CategoryFunctionRow; |
| | | row.SetStatuText(deviceUI.GetDeviceStatu()); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | delBtn.MouseUpEventHandler += delEvent; |
| | | } |
| | | } |
| | | else if (deviceUI.CommonDevice.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var tempera = deviceUI.CommonDevice as TemperatureSensor; |
| | | if (tempera.Gateway != null) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | System.Threading.Thread.Sleep(100 * i); |
| | | if (tempera.Gateway.IsVirtual) |
| | | { |
| | | UserHomeView.ReadStatus(tempera, () => |
| | | { |
| | | if (tempera.SensorDiv == 1) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); |
| | | } |
| | | else if (tempera.SensorDiv == 2) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - tempera.LastDateTime).TotalSeconds) |
| | | { |
| | | if (tempera.SensorDiv == 1) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); |
| | | } |
| | | else if (tempera.SensorDiv == 2) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | var deviceTypeRowLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(129 + 35), |
| | | LineColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | Tag = deviceUI |
| | | }; |
| | | deviceListScrolView.AddChidren(deviceTypeRowLayout); |
| | | |
| | | var deviceRow = new CategoryFunctionRow(0, 35); |
| | | deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); |
| | | deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); |
| | | deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); |
| | | deviceRow.IsSelected = false; |
| | | deviceRow.HideSwitchBtn(true); |
| | | deviceTypeRowLayout.AddChidren(deviceRow); |
| | | |
| | | var editBtn = new CommonForm.RowLayoutEditButton() |
| | | { |
| | | Tag = deviceUI |
| | | }; |
| | | var delBtn = new Device.CommonForm.RowLayoutDeleteButton() |
| | | { |
| | | Tag = deviceUI |
| | | }; |
| | | if (curRoom.IsSharedRoom == false) |
| | | { |
| | | deviceTypeRowLayout.AddRightView(editBtn); |
| | | editBtn.MouseUpEventHandler += deviceDetailHandler; |
| | | deviceTypeRowLayout.AddRightView(delBtn); |
| | | delBtn.MouseUpEventHandler += delEvent; |
| | | } |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var deviceTypeRowLayout = new RowLayout() |