| | |
| | | /// <summary> |
| | | /// 逻辑存储数据对象 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class Logic |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 逻辑列表 |
| | | /// </summary> |
| | | public static List<Logic> LogicList = new List<Logic>(); |
| | | /// <summary> |
| | | /// 当前逻辑 |
| | | /// </summary> |
| | | public static Logic currlogic; |
| | | /// <summary> |
| | | /// 云端唯一id |
| | | /// </summary> |
| | | public string userLogicId = ""; |
| | | /// <summary> |
| | | /// 逻辑唯一标识 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 逻辑名称 |
| | | /// </summary> |
| | | public string name = "逻辑一"; |
| | | public string name = "自动化"; |
| | | /// <summary> |
| | | /// 逻辑条件关系(与and:,或:or) |
| | | /// </summary> |
| | | public string relation = "or"; |
| | | public string relation = "and"; |
| | | /// <summary> |
| | | /// 逻辑状态(true,false) |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public List<Output> output = new List<Output>(); |
| | | /// <summary> |
| | | /// 生成逻辑sid方法 |
| | | /// 通知配置 |
| | | /// </summary> |
| | | public string NewSid() |
| | | { |
| | | string logicId = ""; |
| | | try |
| | | { |
| | | string sOidBeginsWith = "000101";//厂商 + 通讯方式 |
| | | DateTime dt = DateTime.Now; |
| | | DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1)); |
| | | long m = (long)((dt - startTime).TotalMilliseconds / 10); |
| | | string sTimeSpan = "00000000"; |
| | | public NoticeConfig noticeConfig = new NoticeConfig(); |
| | | /// <summary> |
| | | /// 推送配置 |
| | | /// </summary> |
| | | public List<PushConfigs> pushConfigs = new List<PushConfigs>(); |
| | | |
| | | byte[] arry = new byte[4]; |
| | | arry[0] = (byte)(m & 0xFF); |
| | | arry[1] = (byte)((m & 0xFF00) >> 8); |
| | | arry[2] = (byte)((m & 0xFF0000) >> 16); |
| | | arry[3] = (byte)((m >> 24) & 0xFF); |
| | | sTimeSpan = arry[0].ToString("X2") + arry[1].ToString("X2") + arry[2].ToString("X2") + arry[3].ToString("X2"); |
| | | |
| | | |
| | | if (sTimeSpan.Length > 8) |
| | | { |
| | | sTimeSpan = sTimeSpan.Substring(0, 8); |
| | | } |
| | | else |
| | | { |
| | | sTimeSpan = "00000000"; |
| | | } |
| | | |
| | | logicId = sOidBeginsWith + sTimeSpan; |
| | | |
| | | logicId += "0A"; |
| | | logicId += "0A01"; |
| | | //0A01 物模型为逻辑, 0001 表示 1 号逻辑功能 |
| | | int iTopLogicId = 1; |
| | | |
| | | Random random = new Random(); |
| | | iTopLogicId = random.Next(0, 255); |
| | | iTopLogicId += random.Next(0, 255); |
| | | |
| | | logicId += iTopLogicId.ToString("X4");//逻辑号 两个byte |
| | | logicId += "1100"; |
| | | } |
| | | catch |
| | | { |
| | | return logicId; |
| | | } |
| | | return logicId; |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 执行周期对象 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class Cycle |
| | | { |
| | | /// <summary> |
| | | /// 时间类型 |
| | | /// (执行一次:once,每天:day,每月:mon,星期:week,日期段:date_to_date) |
| | | /// </summary> |
| | | public string type = ""; |
| | | public string type = "day"; |
| | | public List<string> value = new List<string>(); |
| | | } |
| | | /// <summary> |
| | | /// 输入条件对象 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class Input |
| | | { |
| | | /// <summary> |
| | |
| | | /// 云端天气条件=6; |
| | | /// 某个逻辑/场景的输出条件=7; |
| | | /// 地理围栏=8; |
| | | /// 空气质量=9; |
| | | /// 场景=10; |
| | | /// </summary> |
| | | public string condition_type = ""; |
| | | public List<Dictionary<string, string>> condition = new List<Dictionary<string, string>>(); |
| | | /// <summary> |
| | | /// 地理围栏配置 |
| | | /// </summary> |
| | | public Fence geo_fence = new Fence(); |
| | | } |
| | | /// <summary> |
| | | /// 输出目标对象 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class Output |
| | | { |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public string sid = ""; |
| | | /// <summary> |
| | | /// 逻辑输出目标延时间(单位用秒) |
| | | /// </summary> |
| | | public string delay = "0"; |
| | | /// <summary> |
| | | /// 逻辑输出目标类型 |
| | | /// 设备=1; |
| | | /// 场景=2; |
| | | /// 安防=3; |
| | | /// 延时=4; |
| | | /// </summary> |
| | | public string target_type = ""; |
| | | public List<Dictionary<string, string>> status = new List<Dictionary<string, string>>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 地理围栏配置 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class Fence |
| | | { |
| | | /// <summary> |
| | | /// 经度 |
| | | /// </summary> |
| | | public string longitude = string.Empty; |
| | | /// <summary> |
| | | /// 纬度 |
| | | /// </summary> |
| | | public string latitude = string.Empty; |
| | | /// <summary> |
| | | /// 单位米 |
| | | /// </summary> |
| | | public string radius = string.Empty; |
| | | } |
| | | /// <summary> |
| | | /// 通知配置 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class NoticeConfig |
| | | { |
| | | /// <summary> |
| | | /// 是否开启通知 |
| | | /// </summary> |
| | | public bool enable = false; |
| | | /// <summary> |
| | | /// 通知内容 |
| | | /// </summary> |
| | | public string noticeContent = "自动化已经执行";//string.Empty; |
| | | } |
| | | /// <summary> |
| | | /// 推送配置 |
| | | /// </summary> |
| | | [Serializable] |
| | | public class PushConfigs |
| | | { |
| | | /// <summary> |
| | | /// 推送方式(APP/SMS) |
| | | /// </summary> |
| | | public string pushMethod = "APP"; |
| | | /// <summary> |
| | | /// 推送内容 |
| | | /// </summary> |
| | | //public string pushContent = string.Empty; |
| | | /// <summary> |
| | | /// 推送目标 |
| | | /// </summary> |
| | | public List<string> pushTarget = new List<string> {}; |
| | | } |
| | | |
| | | } |
| | | |