| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Logic |
| | | { |
| | | public class LogicIfon |
| | | { |
| | | #region ----逻辑条件输入---- |
| | | #region ----逻辑条件输入---- |
| | | /// <summary> |
| | | /// 添加设备条件的方法 |
| | | /// </summary> |
| | | /// <param name="common">Common.</param> |
| | | /// <param name="objecttype">Objecttype.</param> |
| | | public static void AddDeviceconditions(ZigBee.Device.CommonDevice common, Dictionary<string, string> objecttype) |
| | | public static void AddDeviceconditions(CommonDevice common, Dictionary<string, string> objecttype) |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++) |
| | | { |
| | |
| | | { |
| | | if ((Common.Logic.CurrentLogic.Conditions[i]["MacAddr"] == common.DeviceAddr) && (Common.Logic.CurrentLogic.Conditions[i]["Epoint"] == common.DeviceEpoint.ToString())) |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); |
| | | return; |
| | | if (common.Type == DeviceType.TemperatureSensor)//设备温度传感器有点特别 |
| | | { |
| | | var dev = common as TemperatureSensor; |
| | | string str = ""; |
| | | if (dev.SensorDiv == 1) |
| | | { |
| | | str = "1026"; |
| | | } |
| | | else |
| | | { |
| | | str = "1029"; |
| | | } |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Cluster_ID"] == str) |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); |
| | | return; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "2") |
| | | { |
| | | |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Condition_LogicId"] ==logic.LogicId.ToString()) |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Condition_LogicId"] == logic.LogicId.ToString()) |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); |
| | |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++) |
| | | { |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "7") |
| | | if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == objecttype["Type"]) |
| | | { |
| | | |
| | | Common.Logic.CurrentLogic.Conditions.RemoveAt(i); |
| | |
| | | Common.Logic.CurrentLogic.Conditions.Add(objecttype); |
| | | } |
| | | #endregion |
| | | |
| | | #region ----逻辑输出目标---- |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "0") |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() ==common.DeviceAddr&& Common.Logic.CurrentLogic.Actions[i]["Epoint"].ToString() ==common.DeviceEpoint.ToString()) |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == common.DeviceAddr && Common.Logic.CurrentLogic.Actions[i]["Epoint"].ToString() == common.DeviceEpoint.ToString()) |
| | | { |
| | | Common.Logic.CurrentLogic.Actions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo); |
| | |
| | | /// </summary> |
| | | /// <param name="Scene">Common.</param> |
| | | /// <param name="actionsInfo">Objecttype.</param> |
| | | public static void AddSceneactions(Shared.Common.SceneUI Scene,Dictionary<string, object> actionsInfo) |
| | | public static void AddSceneactions(Shared.Common.SceneUI Scene, Dictionary<string, object> actionsInfo) |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++) |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "2") |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() ==Scene.Id.ToString()) |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == Scene.Id.ToString()) |
| | | { |
| | | Common.Logic.CurrentLogic.Actions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo); |
| | |
| | | /// </summary> |
| | | /// <param name="objecttype">Objecttype.</param> |
| | | /// <param name="o">O.</param> |
| | | public static void AddLogicactions(Common.Logic logic,Dictionary<string, object> actionsInfo) |
| | | public static void AddLogicactions(Common.Logic logic, Dictionary<string, object> actionsInfo) |
| | | { |
| | | |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++) |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "4") |
| | | { |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() ==logic.LogicId.ToString()) |
| | | if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == logic.LogicId.ToString()) |
| | | { |
| | | Common.Logic.CurrentLogic.Actions.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo); |
| | |
| | | |
| | | } |
| | | #endregion |
| | | #region ----关联app账号---- |
| | | /// <summary> |
| | | /// 关联app账号 |
| | | /// </summary> |
| | | /// <param name="accountsInfo"></param> |
| | | public static void Addaccounts(Dictionary<string, string> accountsInfo) |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.Accounts.Count; i++) |
| | | { |
| | | if (Common.Logic.CurrentLogic.Accounts[i]["Type"] == accountsInfo["Type"]) |
| | | { |
| | | Common.Logic.CurrentLogic.Accounts.RemoveAt(i); |
| | | Common.Logic.CurrentLogic.Accounts.Insert(i, accountsInfo); |
| | | return; |
| | | } |
| | | } |
| | | Common.Logic.CurrentLogic.Accounts.Add(accountsInfo); |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | |
| | | |
| | | } |