| | |
| | | using System.Globalization; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.DeviceLogic; |
| | | using Shared.Phone.UserCenter; |
| | | using Shared.Phone.UserView; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Room |
| | | { |
| | | public class EditRoom : FrameLayout |
| | | public class EditRoom : FrameLayout, ZigBee.Common.IStatus |
| | | { |
| | | #region ◆ 变量____________________________ |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public int OldIconPathType; |
| | | |
| | | |
| | | CommonDevice temperDevice; |
| | | |
| | | CommonDevice humidDevice; |
| | | |
| | | DeviceInfoRow temperatureRow; |
| | | |
| | | DeviceInfoRow humidityRow; |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 接口__________________________ |
| | | /// <summary> |
| | | /// 处理变化事件 --将弃用 改用DeviceInfoChange() |
| | | /// </summary> |
| | | /// <returns>The changed.</returns> |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | { |
| | | |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IL ogic status. |
| | | /// </summary> |
| | | /// <param name="logic">Logic.</param> |
| | | public void ChangedILogicStatus(ZigBee.Device.Logic logic) |
| | | { |
| | | //throw new NotImplementedException(); |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IS cene status. |
| | | /// </summary> |
| | | /// <param name="scene">Scene.</param> |
| | | public void ChangedISceneStatus(Scene scene) |
| | | { |
| | | //throw new NotImplementedException(); |
| | | } |
| | | /// <summary> |
| | | /// 设备状态更新接口 |
| | | /// <para>type:如果为 DeviceInComingRespon:设备新上报</para> |
| | | /// <para>type:如果为 IASInfoReport:RemoveDeviceRespon</para> |
| | | /// <para>type:如果为 DeviceStatusReport:设备上报</para> |
| | | /// <para>type:如果为 IASInfoReport:IAS安防信息上报</para> |
| | | /// <para>type:如果为 OnlineStatusChange: 设备在线状态更新</para> |
| | | /// </summary> |
| | | /// <param name="common">Common.</param> |
| | | /// <param name="typeTag">Type tag.</param> |
| | | public void DeviceInfoChange(CommonDevice common, string typeTag) |
| | | { |
| | | if (typeTag == "DeviceStatusReport") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if ((temperDevice?.DeviceEpoint != common.DeviceEpoint || temperDevice?.DeviceAddr != common.DeviceAddr) && (humidDevice?.DeviceEpoint != common.DeviceEpoint || humidDevice?.DeviceAddr != common.DeviceAddr)) |
| | | { |
| | | //return; |
| | | } |
| | | |
| | | //if (common.Type == DeviceType.TemperatureSensor) |
| | | //{ |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "--℃"; |
| | | room.Temperatrue = 0; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) * 0.1; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) * 0.1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (common.DeviceStatusReport.CluterID == 1029) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "--%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = int.Parse(strValue) * 0.1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"Error:{ex.Message}"); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | public EditRoom() |
| | | { |
| | | ZbGateway.StatusList.Add(this); |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | } |
| | | |
| | |
| | | |
| | | public override void RemoveFromParent()
|
| | | {
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
|
| | |
|
| | | ZbGateway.StatusList.Remove(this);
|
| | | CommonPage.Instance.IsDrawerLockMode = false; |
| | | base.RemoveFromParent();
|
| | | } |
| | |
| | | }; |
| | | |
| | | |
| | | var temperatureRow = new DeviceInfoRow(446); |
| | | temperatureRow = new DeviceInfoRow(446); |
| | | temperatureRow.Init(); |
| | | temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature); |
| | | temperatureRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | |
| | | } |
| | | room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | temperatureRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A设备属性上报, ((report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.TemperatrueDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "0.0℃"; |
| | | room.Temperatrue = 0; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) * 0.1; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) *0.1; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | //发送获取温度的命令 |
| | | (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(selectTemp); |
| | | }; |
| | | }; |
| | | if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) |
| | | { |
| | | temperatureRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A设备属性上报, (Action<ZigBee.Device.CommonDevice>)((report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.TemperatrueDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "0.0℃"; |
| | | room.Temperatrue = 0; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) * 0.1; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | room.Temperatrue = int.Parse(strValue) * 0.1; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | //发送获取温度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | var humidityRow = new DeviceInfoRow(585); |
| | | humidityRow = new DeviceInfoRow(585); |
| | | humidityRow.Init(); |
| | | humidityRow.SetTipTitle(R.MyInternationalizationString.Humidity); |
| | | humidityRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | |
| | | room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | humidityRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); |
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A设备属性上报, (report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.HumidityDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "0.0%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = int.Parse(strValue) * 0.1; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //发送获取湿度的命令 |
| | | (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(selectTemp); |
| | | }; |
| | | }; |
| | | if (string.IsNullOrEmpty(room.HumidityDevice) == false) |
| | | { |
| | | humidityRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); |
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A设备属性上报, (report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.HumidityDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "0.0%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = int.Parse(strValue) * 0.1; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //发送获取湿度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev); |
| | | } |
| | | else |
| | | { |
| | |
| | | Height = Application.GetRealHeight(450), |
| | | Width = Application.GetRealWidth(selectRow_Width), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Radius = (uint)Application.GetRealHeight(17), |
| | | Radius = (uint)Application.GetRealHeight(35), |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | selectFL.AddChidren(itemFL); |
| | | itemFL.Animate = Animate.DownToUp; |
| | | //itemFL.Animate = Animate.DownToUp; |
| | | |
| | | var selectLocalPicture = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.LocalPicture, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectLocalPicture); |
| | | var selectLocalLine = new Button() |
| | | { |
| | | Y = selectLocalPicture.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 |
| | | }; |
| | | itemFL.AddChidren(selectLocalLine); |
| | | |
| | |
| | | Y = selectLocalLine.Bottom, |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.Photograph, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectPhotographBtn); |
| | | var selectPhotographLine = new Button() |
| | | { |
| | | Y = selectPhotographBtn.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2, |
| | | }; |
| | | itemFL.AddChidren(selectPhotographLine); |
| | | |
| | |
| | | Y = selectPhotographLine.Bottom, |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.MyAblums, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectAblumsBtn); |
| | | |
| | |
| | | TextID = R.MyInternationalizationString.Cancel, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(17) |
| | | Radius = (uint)Application.GetRealHeight(35), |
| | | TextSize = 17 |
| | | }; |
| | | selectFL.AddChidren(cancelBtn); |
| | | |