New file |
| | |
| | | using Shared.Common;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 设备的其他逻辑(目前用来存放郭雪城的代码)
|
| | | /// </summary>
|
| | | public class HdlDeviceOtherLogic
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备的其他逻辑
|
| | | /// </summary>
|
| | | private static HdlDeviceOtherLogic m_Current = null;
|
| | | /// <summary>
|
| | | /// 设备的其他逻辑
|
| | | /// </summary>
|
| | | public static HdlDeviceOtherLogic Current
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_Current == null)
|
| | | {
|
| | | m_Current = new HdlDeviceOtherLogic();
|
| | | }
|
| | | return m_Current;
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 控制延时默认反馈的线程列表
|
| | | /// </summary>
|
| | | private List<System.Threading.Thread> ListThreads = new List<System.Threading.Thread> { };
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 发送控制命令延时反馈_______________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送控制命令延时反馈
|
| | | /// </summary>
|
| | | /// <param name="commonDevice">Common device.</param>
|
| | | /// <param name="action">Action.</param>
|
| | | /// <param name="delayTime">Delay time.</param>
|
| | | public void SendCommandDelayAction(CommonDevice commonDevice, Action action, int delayTime = 3)
|
| | | {
|
| | | var threadName = commonDevice.GetHashCode().ToString();
|
| | | if (ListThreads.Find((obj) => obj.Name == threadName) == null)
|
| | | {
|
| | | var thread = new System.Threading.Thread(() =>
|
| | | {
|
| | | var dateTime = DateTime.Now;
|
| | | while ((DateTime.Now - dateTime).TotalSeconds < delayTime)
|
| | | {
|
| | | System.Threading.Thread.Sleep(100);
|
| | | }
|
| | | lock (ListThreads)
|
| | | {
|
| | | ListThreads.RemoveAll((obj) => obj.Name == threadName);
|
| | | }
|
| | | action?.Invoke();
|
| | | })
|
| | | { IsBackground = true, Name = threadName };
|
| | | lock (ListThreads)
|
| | | {
|
| | | ListThreads.Add(thread);
|
| | | }
|
| | | thread.Start();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 显示控制设备是否成功的提示_________
|
| | |
|
| | | /// <summary>
|
| | | /// 显示控制设备是否成功的提示
|
| | | /// </summary>
|
| | | /// <param name="r">The red component.</param>
|
| | | public void ShowStatuTip(int r)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | string msg = Language.StringByID(r);
|
| | | var tip = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | tip.Show();
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取设备状态的翻译_________________
|
| | |
|
| | | /// <summary>
|
| | | /// GetDeviceStatu
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public string GetDeviceStatu(CommonDevice device)
|
| | | {
|
| | | if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //在网关没有回复之前,默认离线
|
| | | if (device.HadReadDeviceStatu == false)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOffLine);
|
| | | }
|
| | | if ((device as ToggleLight).OnOffStatus == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOpen1);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.Close);
|
| | | }
|
| | | else if (device.Type == DeviceType.AirSwitch)
|
| | | {
|
| | | //在网关没有回复之前,默认离线
|
| | | if (device.HadReadDeviceStatu == false)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOffLine);
|
| | | }
|
| | | if ((device as AirSwitch).OnOffStatus == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOpen1);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.Close);
|
| | | }
|
| | | else if (device.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | //在网关没有回复之前,默认离线
|
| | | if (device.HadReadDeviceStatu == false)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOffLine);
|
| | | }
|
| | | if ((device as DimmableLight).OnOffStatus == 0 || (device as DimmableLight).Level == 0)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.Close);
|
| | | }
|
| | | return $"{(int)((device as DimmableLight).Level * 1.0 / 254 * 100)}%";
|
| | | }
|
| | | else if (device.Type == DeviceType.WindowCoveringDevice)
|
| | | {
|
| | | //在网关没有回复之前,默认离线
|
| | | if (device.HadReadDeviceStatu == false)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOffLine);
|
| | | }
|
| | | if ((device as Rollershade).WcdCurrentPositionLiftPercentage == 0)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.Close);
|
| | | }
|
| | | return $"{(device as Rollershade).WcdCurrentPositionLiftPercentage}%";
|
| | | }
|
| | | else if (device.Type == DeviceType.Thermostat)
|
| | | {
|
| | | //在网关没有回复之前,默认离线
|
| | | if (device.HadReadDeviceStatu == false)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uOffLine);
|
| | | }
|
| | | //温度,模式,风速
|
| | | string tempareture = string.Empty;
|
| | | string model = string.Empty;
|
| | | string wind = string.Empty;
|
| | |
|
| | | var ac = device as AC;
|
| | |
|
| | | if (ac.currentSystemMode == 0)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.Close);
|
| | | }
|
| | | else if (ac.currentSystemMode == 1)
|
| | | {
|
| | | model = Language.StringByID(R.MyInternationalizationString.Mode_Auto);
|
| | | tempareture = $"{ac.currentAutoSetpoint} ℃";
|
| | | }
|
| | | else if (ac.currentSystemMode == 3)
|
| | | {
|
| | | model = Language.StringByID(R.MyInternationalizationString.Mode_Cool);
|
| | | tempareture = $"{ac.currentCoolingSetpoint} ℃";
|
| | | }
|
| | | else if (ac.currentSystemMode == 4)
|
| | | {
|
| | | model = Language.StringByID(R.MyInternationalizationString.Mode_Heat);
|
| | | tempareture = $"{ac.currentHeatingSetpoint} ℃";
|
| | | }
|
| | | else if (ac.currentSystemMode == 7)
|
| | | {
|
| | | model = Language.StringByID(R.MyInternationalizationString.Mode_FanOnly);
|
| | | }
|
| | | else if (ac.currentSystemMode == 8)
|
| | | {
|
| | | model = Language.StringByID(R.MyInternationalizationString.Mode_Dry);
|
| | | tempareture = $"{ac.currentCoolingSetpoint} ℃";
|
| | | }
|
| | |
|
| | | if (ac.currentFanMode == 1)
|
| | | {
|
| | | wind = Language.StringByID(R.MyInternationalizationString.Fan_Low);
|
| | | }
|
| | | else if (ac.currentFanMode == 2)
|
| | | {
|
| | | wind = Language.StringByID(R.MyInternationalizationString.Fan_Middle);
|
| | | }
|
| | | else
|
| | | {
|
| | | wind = Language.StringByID(R.MyInternationalizationString.Fan_Height);
|
| | | }
|
| | |
|
| | | if (string.IsNullOrEmpty(tempareture))
|
| | | {
|
| | | return $"{model},{wind}";
|
| | | }
|
| | | return $"{model},{wind},{tempareture}";
|
| | | }
|
| | | else if (device.Type == DeviceType.IASZone)
|
| | | {
|
| | | var ias = device as IASZone;
|
| | | //区分传感器具体类型
|
| | | var info = LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { device });
|
| | | if (info.ConcreteType == DeviceConcreteType.Sensor_Infrared)
|
| | | {
|
| | | //红外
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HavePerson);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_NoPerson);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_Water)
|
| | | {
|
| | | //水浸
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HaveWater);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_DoorWindow)
|
| | | {
|
| | | //门窗
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Open);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Close);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_CarbonMonoxide)
|
| | | {
|
| | | //燃气
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_Fire)
|
| | | {
|
| | | //烟雾
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_Pir)
|
| | | {
|
| | | //pir
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_Keyfob)
|
| | | {
|
| | | //钥匙扣
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_Motion)
|
| | | {
|
| | | //运动传感器
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal);
|
| | | }
|
| | | else if (info.ConcreteType == DeviceConcreteType.Sensor_EmergencyButton)
|
| | | {
|
| | | //紧急按钮
|
| | | if (ias.iASInfo?.Alarm1 == 1)
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm);
|
| | | }
|
| | | return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | else if (device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | var tempera = device as TemperatureSensor;
|
| | | if (tempera.SensorDiv == 1)
|
| | | {
|
| | | if (tempera.Temperatrue == 0)
|
| | | {
|
| | | return "--℃";
|
| | | }
|
| | | return $"{tempera.Temperatrue}℃";
|
| | | }
|
| | | else if (tempera.SensorDiv == 2)
|
| | | {
|
| | | if (tempera.Humidity == 0)
|
| | | {
|
| | | return "--%";
|
| | | }
|
| | | return $"{tempera.Humidity}%";
|
| | | }
|
| | | return null;
|
| | | }
|
| | | else
|
| | | {
|
| | | return null;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | | }
|
| | | }
|