| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared.Common; |
| | | using ZigBee.Device; |
| | | using Shared.Phone.Device.AC; |
| | | using System.Text; |
| | |
|
| | | namespace Shared.Phone.UserView |
| | |
| | | /// <summary> |
| | | /// User page. |
| | | /// </summary> |
| | | public class UserPage : FrameLayout, ZigBee.Common.IStatus |
| | | public class UserPage : FrameLayout |
| | | { |
| | | #region ◆ 变量_______________________ |
| | | /// <summary> |
| | |
| | | private static readonly int tabBarEnumName_Y = 98; |
| | | #endregion |
| | | |
| | | #region ◆ 接口____________________________ |
| | | |
| | | /// <summary> |
| | | /// 该接口将弃用 !!!!!! |
| | | /// 改用DeviceInfoChange() |
| | | /// </summary> |
| | | /// <returns>The changed.</returns> |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | { |
| | | |
| | | } |
| | | |
| | | /// <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) |
| | | { |
| | | var myDevice = LocalDevice.Current.GetDevice(common.DeviceAddr, common.DeviceEpoint); |
| | | if (myDevice == null)
|
| | | {
|
| | | return;
|
| | | } |
| | | //设备上报状态中 当CluterID=3,就证明该设备在线,直接标记 |
| | | if (typeTag == "DeviceStatusReport") |
| | | { |
| | | try |
| | | {
|
| | | if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | switch (myDevice.Type)
|
| | | {
|
| | | case DeviceType.OnOffOutput:
|
| | | //开关功能
|
| | | if (common.DeviceStatusReport.CluterID == 6)
|
| | | {
|
| | | var onOffOutputLight = (ToggleLight)myDevice;
|
| | | onOffOutputLight.DeviceStatusReport = common.DeviceStatusReport;
|
| | | onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | onOffOutputLight.LastDateTime = DateTime.Now;
|
| | | }
|
| | | //当CluterID=3,就证明该设备在线,直接标记
|
| | | if (common.DeviceStatusReport.CluterID == 3)
|
| | | {
|
| | | myDevice.IsOnline = 1;
|
| | | myDevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | | break;
|
| | |
|
| | | case DeviceType.AirSwitch:
|
| | | //开关功能
|
| | | if (common.DeviceStatusReport.CluterID == 6)
|
| | | {
|
| | | var airSwitch = (AirSwitch)myDevice;
|
| | | airSwitch.DeviceStatusReport = common.DeviceStatusReport;
|
| | | airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | airSwitch.LastDateTime = DateTime.Now;
|
| | | }
|
| | | //当CluterID=3,就证明该设备在线,直接标记
|
| | | if (common.DeviceStatusReport.CluterID == 3)
|
| | | {
|
| | | myDevice.IsOnline = 1;
|
| | | myDevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | | break;
|
| | |
|
| | | case DeviceType.WindowCoveringDevice:
|
| | | if (common.DeviceStatusReport.CluterID == 258)
|
| | | {
|
| | | var rollershade = (Rollershade)myDevice;
|
| | | rollershade.DeviceStatusReport = common.DeviceStatusReport;
|
| | | var attriButeList = rollershade.DeviceStatusReport.AttriBute;
|
| | | switch (attriButeList[0].AttributeId)
|
| | | {
|
| | | case 0:
|
| | | rollershade.WcdType = attriButeList[0].AttriButeData;
|
| | | rollershade.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (common.DeviceStatusReport.CluterID == 3)
|
| | | {
|
| | | myDevice.IsOnline = 1;
|
| | | myDevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | | break;
|
| | |
|
| | | case DeviceType.Thermostat:
|
| | | //AC功能
|
| | | if (common.DeviceStatusReport.CluterID == 513)
|
| | | {
|
| | | var ac = (AC)myDevice;
|
| | | ac.DeviceStatusReport = common.DeviceStatusReport;
|
| | | var attriButeList = ac.DeviceStatusReport.AttriBute;
|
| | | foreach (var attList in attriButeList)
|
| | | {
|
| | | //此属性表明室内当前的温度 * 100,实际温度为“LocalTemperature / 100”,单位:℃ |
| | | var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default; |
| | | switch (attList.AttributeId)
|
| | | {
|
| | | case 0:
|
| | | ac.currentLocalTemperature = curTemp;
|
| | | ac.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | case 17:
|
| | | ac.currentCoolingSetpoint = curTemp;
|
| | | ac.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | case 18:
|
| | | ac.currentHeatingSetpoint = curTemp;
|
| | | ac.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | case 4096:
|
| | | ac.currentAutoSetpoint = curTemp;
|
| | | ac.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | case 28:
|
| | | ac.currentSystemMode = attList.AttriButeData;
|
| | | ac.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | case 4097: |
| | | ac.CleanStatu = attList.AttriButeData == 42; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
|
| | | if (common.DeviceStatusReport.CluterID == 514) |
| | | { |
| | | var ac = (AC)myDevice; |
| | | var attriButeList = common.DeviceStatusReport.AttriBute; |
| | | ac.DeviceStatusReport = common.DeviceStatusReport; |
| | | foreach (var attList in attriButeList) |
| | | { |
| | | switch (attList.AttributeId) |
| | | {
|
| | | case 0: |
| | | ac.currentFanMode = attList.AttriButeData; |
| | | ac.LastDateTime = DateTime.Now; |
| | | break; |
| | | case 4096: |
| | | ac.currentFanSwingMode = attList.AttriButeData; |
| | | ac.LastDateTime = DateTime.Now; |
| | | break; |
| | | } |
| | | } |
| | | }
|
| | | |
| | | //当CluterID=3,就证明该设备在线,直接标记
|
| | | if (common.DeviceStatusReport.CluterID == 3)
|
| | | {
|
| | | myDevice.IsOnline = 1;
|
| | | myDevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | | break;
|
| | |
|
| | | case DeviceType.DimmableLight:
|
| | | //调光灯功能
|
| | | //开关功能
|
| | | if (common.DeviceStatusReport.CluterID == 6)
|
| | | {
|
| | | var dimmableLight = (DimmableLight)myDevice;
|
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
|
| | | dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | dimmableLight.LastDateTime = DateTime.Now;
|
| | | }
|
| | | //亮度
|
| | | if (common.DeviceStatusReport.CluterID == 8)
|
| | | {
|
| | | var dimmableLight = (DimmableLight)myDevice;
|
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
|
| | | var attriButeList = dimmableLight.DeviceStatusReport.AttriBute;
|
| | | switch (attriButeList[0].AttributeId)
|
| | | {
|
| | | case 0:
|
| | | dimmableLight.Level = attriButeList[0].AttriButeData;
|
| | | dimmableLight.LastDateTime = DateTime.Now;
|
| | | break;
|
| | | }
|
| | | }
|
| | | //当CluterID=3,就证明该设备在线,直接标记
|
| | | if (common.DeviceStatusReport.CluterID == 3)
|
| | | {
|
| | | myDevice.IsOnline = 1;
|
| | | myDevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | | break;
|
| | | |
| | | case DeviceType.TemperatureSensor: |
| | | //温度 |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | { |
| | | var tempera = (TemperatureSensor)myDevice; |
| | | 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, ".")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //湿度 |
| | | if (common.DeviceStatusReport.CluterID == 1029) |
| | | { |
| | | var tempera = (TemperatureSensor)myDevice; |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"Error:{ex.Message}"); |
| | | } |
| | | } |
| | | //设备在线状态上报 |
| | | else if (typeTag == "OnlineStatusChange") |
| | | {
|
| | | myDevice.IsOnline = common.IsOnline;
|
| | | //记录回复时间
|
| | | myDevice.LastDateTime = DateTime.Now; |
| | | } |
| | | else if (typeTag == "IASInfoReport") |
| | | { |
| | | try |
| | | { |
| | | switch (myDevice.Type) |
| | | { |
| | | case DeviceType.IASZone: |
| | | var iAS = (IASZone)myDevice; |
| | | iAS.iASInfo = (common as IASZone).iASInfo; |
| | | iAS.LastDateTime = DateTime.Now; |
| | | break; |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | } |
| | | /// <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(); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 用户界面 |
| | | /// </summary> |
| | |
| | | public UserPage() |
| | | { |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor; |
| | | ZbGateway.StatusList.Add(this); |
| | | Shared.Application.LocationAction += (lon, lat) => |
| | | { |
| | | Login.AccountLogic.Instance.ReceiveAppLatAndLon(lon.ToString(), lat.ToString()); |
| | |
| | | SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2, |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextSize = 10 |
| | | }; |
| | | };
|
| | | #endregion |
| | |
|
| | | #region 强制显示自动化界面 |
| | | |
| | | /// <summary>
|
| | | /// 强制显示自动化列表界面
|
| | | /// </summary> |
| | | public void ShowCategoryAutoListForm()
|
| | | {
|
| | | //关闭全部界面,直到主页为止
|
| | | UserCenter.UserCenterLogic.CloseAllOpenForm();
|
| | | //强制显示自动化列表界面
|
| | | UserCenter.UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 2;
|
| | | BottomEventHandler(Instance.categoryIMG, null);
|
| | | } |
| | | |
| | | #endregion |
| | |
|
| | | EventHandler<MouseEventArgs> BottomEventHandler = (sender, e) => |
| | | { |
| | | if (sender == Instance.homePageIMG || sender == Instance.homePageName) |
| | | { |
| | |
|
| | | {
|
| | | if (Instance.homePageName.IsSelected == true && e != null)
|
| | | {
|
| | | //只有是手动点击的时候才处理
|
| | |
| | | Instance.settingName.IsSelected = false;
|
| | | Instance.settingIMG.IsSelected = false; |
| | | |
| | | var home = new MainPage.UserHomeView2(); |
| | | var home = new MainPage.HomeMainPageForm(); |
| | | Instance.BodyView.AddChidren(home); |
| | | home.ShowForm(); |
| | | |
| | |
| | | Instance.settingName.IsSelected = false;
|
| | | Instance.settingIMG.IsSelected = false; |
| | | |
| | | var category = new Phone.Device.Category.Category { }; |
| | | var category = new Category.CategoryMainForm { }; |
| | | Instance.BodyView.AddChidren(category); |
| | | category.Show(); |
| | | category.ShowForm(); |
| | | } |
| | | else if (sender == Instance.settingIMG || sender == Instance.settingName) |
| | | {
|