using System;
using System.Collections.Generic;
namespace Shared.Phone.Device.Logic
{
public class LogicIfon
{
#region ----逻辑条件输入----
///
/// 添加设备条件的方法
///
/// Common.
/// Objecttype.
public static void AddDeviceconditions(ZigBee.Device.CommonDevice common, Dictionary objecttype)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
{
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "1")
{
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;
}
}
}
Common.Logic.CurrentLogic.Conditions.Add(objecttype);
}
///
/// 添加Logic条件的方法
///
/// Common.
/// Objecttype.
public static void AddLogicconditions(Common.Logic logic, Dictionary objecttype)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
{
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "2")
{
if (Common.Logic.CurrentLogic.Conditions[i]["Condition_LogicId"] ==logic.LogicId.ToString())
{
Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
return;
}
}
}
Common.Logic.CurrentLogic.Conditions.Add(objecttype);
}
///
/// 添加安防条件的方法
///
/// Objecttype.
public static void AddSecurityconditions(Dictionary objecttype)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
{
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "6")
{
Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
return;
}
}
Common.Logic.CurrentLogic.Conditions.Add(objecttype);
}
///
/// 添加地理位置条件的方法
///
/// Objecttype.
public static void AddLocationconditions(Dictionary objecttype)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
{
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "7")
{
Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
return;
}
}
Common.Logic.CurrentLogic.Conditions.Add(objecttype);
}
#endregion
#region ----逻辑输出目标----
///
/// 添加设备输出的方法
///
/// Common.
/// Objecttype.
public static void AddDeviceactions(ZigBee.Device.CommonDevice common, Dictionary actionsInfo)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
{
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())
{
Common.Logic.CurrentLogic.Actions.RemoveAt(i);
Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
return;
}
}
}
Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
}
///
/// 添加Scene输出的方法
///
/// Common.
/// Objecttype.
public static void AddSceneactions(Shared.Common.SceneUI Scene,Dictionary 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())
{
Common.Logic.CurrentLogic.Actions.RemoveAt(i);
Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
return;
}
}
}
Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
}
///
/// 添加安防输出的方法
///
/// Objecttype.
/// O.
public static void AddSecurityactions(Dictionary actionsInfo)
{
for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
{
if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "6")
{
Common.Logic.CurrentLogic.Actions.RemoveAt(i);
Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
return;
}
}
Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
}
///
/// 添加自动化输出的方法
///
/// Objecttype.
/// O.
public static void AddLogicactions(Common.Logic logic,Dictionary 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())
{
Common.Logic.CurrentLogic.Actions.RemoveAt(i);
Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
return;
}
}
}
Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
}
#endregion
}
}