| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 网关中场景设备列表 |
| | | /// </summary> |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public List<GetSceneDeviceListInfo> SceneDeviceList = new List<GetSceneDeviceListInfo>(); |
| | | |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | ErrorResponData errResponData; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ErrorResponData |
| | | { |
| | | /// <summary> |
| | | /// Error参数含义 |
| | | ///<para>1:网关无法解析命令数据。</para> |
| | | ///<para>2:协调器正在升级或备份/恢复数据 |
| | | ///<para>3:操作设备/组/场景不存在</para> |
| | | ///<para>4:其他错误</para> |
| | | ///<para>5:数据传输错误(在某次客户端向网关发送数据的过程中,网关在合理时间范围内接收客户端数据不完整导致该错误发生。如客户端向网关一次发送100个字节的数据,但网关等待接收了一秒只接收了80个字节。发生该错误,网关将主动关闭客户端连接)</para> |
| | | /// </summary> |
| | | public int Error; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 等待从网关接收数据的时间 |
| | | /// </summary> |
| | | /// <value>The wait receive data time.</value> |
| | |
| | | /// <para>sceneName:取该场景的名字</para> |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<GetSceneIdAllData> GetSceneNewIdAsync(string sceneName) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | GetSceneIdAllData d = null; |
| | | var mainGateway = ZbGateway.MainGateWay; |
| | | if (mainGateway == null) |
| | | { |
| | | d = new GetSceneIdAllData {errorMessageBase = "当前没有主网关" }; |
| | | d = new GetSceneIdAllData {errorMessageBase = "当前没有主网关" }; |
| | | return d; |
| | | } |
| | | |
| | | |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/GetNewId_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.getSceneIdData = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene.GetSceneIdData>(jobject["Data"].ToString()); |
| | | if (scene.getSceneIdData == null) |
| | | var getSceneIdData = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene.GetSceneIdData>(jobject["Data"].ToString()); |
| | | if (getSceneIdData == null) |
| | | { |
| | | d = new GetSceneIdAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | GetSceneAllInfoAsync(); |
| | | d = new GetSceneIdAllData { getSceneIdData = scene.getSceneIdData }; |
| | | d = new GetSceneIdAllData { getSceneIdData = getSceneIdData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | |
| | | if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | { |
| | | d = new GetSceneIdAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | |
| | | |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/GetNewId_Actions 退出" + System.DateTime.Now.ToString()); |
| | |
| | | /// 创建一个空场景返回的数据,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneIdAllData |
| | | public class GetSceneIdAllData:CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 创建一个空场景返回的数据 |
| | | /// </summary> |
| | |
| | | ///获取一个场景的所有信息 . |
| | | ///</summary> |
| | | public static async System.Threading.Tasks.Task<GetSceneAllData> GetSceneAllInfoAsync() |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => { |
| | | GetSceneAllData d = null; |
| | | var mainGateway = ZbGateway.MainGateWay; |
| | |
| | | d = new GetSceneAllData { errorMessageBase = "当前没有主网关" }; |
| | | return d; |
| | | } |
| | | ZbGateway.AllSceneList.Clear(); |
| | | |
| | | var dateTime = DateTime.Now; |
| | | Action<string, string> action = (topic, message) => { |
| | | var gatewayID = topic.Split('/')[0]; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | { |
| | | d = new GetSceneAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error)}; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/GetAllInfo_Respon") |
| | | { |
| | | dateTime = DateTime.Now; |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.sceneGetAllInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneAllInfo>(jobject["Data"].ToString()); |
| | | var sceneGetAllInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneAllInfo>(jobject["Data"].ToString()); |
| | | |
| | | if (scene.sceneGetAllInfo == null) |
| | | if (sceneGetAllInfo == null) |
| | | { |
| | | d = new GetSceneAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | var info = ZbGateway.AllSceneList.Find(obj => obj.ScenesId == scene.sceneGetAllInfo.ScenesId); |
| | | if (info == null) |
| | | { |
| | | ZbGateway.AllSceneList.Add(scene.sceneGetAllInfo); |
| | | } |
| | | else |
| | | { |
| | | info.DeviceList = scene.sceneGetAllInfo.DeviceList; |
| | | info.DeviceSum = scene.sceneGetAllInfo.DeviceSum; |
| | | info.IsOpen = scene.sceneGetAllInfo.IsOpen; |
| | | info.ScenesId = scene.sceneGetAllInfo.ScenesId; |
| | | info.ScenesName = scene.sceneGetAllInfo.ScenesName; |
| | | info.ScenesNum = scene.sceneGetAllInfo.ScenesNum; |
| | | info.ScenesSum = scene.sceneGetAllInfo.ScenesSum; |
| | | } |
| | | d = new GetSceneAllData { getSceneAllInfo = scene.sceneGetAllInfo }; |
| | | d = new GetSceneAllData { getSceneAllInfo = sceneGetAllInfo }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | |
| | | /// 获取所有场景的所有信息,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneAllData |
| | | public class GetSceneAllData:CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 获取所有场景的所有信息 |
| | | /// </summary> |
| | |
| | | /// 获取所有场景的所有信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneAllInfo:CommonDevice |
| | | public class GetSceneAllInfo |
| | | { |
| | | /// <summary> |
| | | ///场景总数 |
| | |
| | | ///<para>2:延时成员</para> |
| | | /// </summary> |
| | | public int Type; |
| | | |
| | | /// <summary> |
| | | /// 设备mac地址 , |
| | | ///<para>当Type=0时存在。</para> |
| | |
| | | /// </summary> |
| | | public int Epoint; |
| | | /// <summary> |
| | | /// 设备名称 |
| | | /// </summary> |
| | | public string DeviceName; |
| | | /// <summary> |
| | | /// 设备列表 |
| | | /// 当Type=0时存在 |
| | | /// </summary> |
| | | public List<TaskListInfo> TaskList = new List<TaskListInfo>(); |
| | | |
| | | public List<Safeguard.TaskListInfo> TaskList = new List<Safeguard.TaskListInfo>(); |
| | | /// <summary> |
| | | /// 场景成员的场景id |
| | | /// <para>当Type=1时存在</para> |
| | | /// </summary> |
| | | public int ElseScenesId; |
| | | |
| | | /// <summary> |
| | | ///延时执行时间,单位秒。 |
| | | /// </summary> |
| | |
| | | /// 场景动作序号,表示第几个动作 |
| | | /// </summary> |
| | | public int MemberNumber; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 任务列表中的数据 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class TaskListInfo |
| | | { |
| | | /// <summary> |
| | | /// 任务类型。 |
| | | ///<para>1:开关 (设备具有开关功能时可用)</para> |
| | | ///<para>3:亮度调整(设备具有亮度调节功能时可用)</para> |
| | | ///<para>4:颜色调整 (设备具有颜色调节功能时可用)</para> |
| | | ///<para>5:恒温器(设备具有恒温器功能时可用)</para> |
| | | ///<para>6: 窗帘设备(设备具有窗帘功能时可用)</para> |
| | | ///<para>7:设备identify识别。</para> |
| | | ///<para>8:开关报警模式 </para> |
| | | ///<para>9:squawk command</para> |
| | | ///</summary> |
| | | public int TaskType; |
| | | /// <summary> |
| | | /// Data1取值 |
| | | /// <para>开关 :Data1(数值): 0关/1开</para> |
| | | ///<para>亮度调整 Data1(数值):亮度值</para> |
| | | ///<para>颜色调整 Data1(数值):色调</para> |
| | | /// <para>恒温器 Data1(数值): 0加热/1制冷/2自动调节/3 设置工作模式/4 设置加热度数 5/设置制冷度数 6/设置风扇模式</para> |
| | | /// <para>窗帘设备 Data1(数值): 0 打开/ 1关闭/ 2 停止转动/ 4 调整到指定高度/ 5 调整到指定的百分比处位置 / 7 调整到指定倾斜角/ 8 调整到指定的百分比倾斜度</para> |
| | | /// <para>设备identify识别。Data1为identify闪烁闪烁时间(0-65535秒)。</para> |
| | | /// <para>开关报警模式 Data1(数值,4字节整型)第1字节(bit0-bit7)表示报警模式,字节值0:停止蜂鸣器1:盗窃报警 2:火灾报警 3:紧急情况报警 4:警车发出的报警 5:消防车发出的报警 6:备用的报警。第2字节(bit8-bit15)表示是否启用报警灯,字节值 0:不启用 1:启用。第3字节(bit16-bit23)表示报警音量,字节值0:Low,1:Medium,2:high,3:very high。</para> |
| | | /// <para>squawk command Data1(数值,4字节整型)第1字节(bit0-bit7)表示报警模式,字节值0:安防系统“布防”音效” ,1:安防系统“撤防”音效。第2字节(bit8-bit15)表示是否启动报警灯,字节值0:不启动,1:启动。第3字节(bit16-bit23)表示报警音量,字节值0:Low ,1:Medium ,2:high ,3: very high。</para> |
| | | /// </summary> |
| | | public int Data1; |
| | | /// <summary> |
| | | /// Data2取值 |
| | | /// <para>开关 Data2(数值): 0</para> |
| | | /// <para>亮度调整 Data2(数值): 0</para> |
| | | /// <para>颜色调整 Data2(数值):饱和度 </para> |
| | | ///<para> 恒温器Data2数值如下: |
| | | /// 【当Data1=0|1|2时,Data2为要变化的度数,单位:0.1℃ 。】 |
| | | ///【若Data1=3,Data2为要设定的空调模式(0-9),0:off,1:auto,3:cool, 4:heat ,5:emergency heating, 6:precooling,7:fan only ,8:dry,9:sleep。】 |
| | | ///【若Data1=4|5,Data2为加热或制冷度数,单位0.01摄氏度。】 |
| | | ///【若Data1=6,Data2为要设定的风扇模式(0-6),0:off,1:low,2:medium,3:high,4:on,5:auto,6:smart】 </para> |
| | | ///<para>窗帘设备,Data2数值如下 |
| | | ///【当Data1=4或7,Data2为调整的高度或倾斜角度 倾斜角度单位为0.1°】。 |
| | | ///【当Data1=5 或 8,Data2为百分比,0-100表示0%-100%】</para> |
| | | ///<para>设备identify识别。Data2(数值): 0 </para> |
| | | ///<para>开关报警模式 Data2(数值,4字节整型)第1、2字节(bit0-bit15)表示报警时长,字节值 0-65535,单位:秒。第3字节(bit16-bit23)表示闪烁占空比,字节值0-100。第4字节(bit16-bit23)表示报警灯亮度,字节值0:Low ,1:Medium ,2:high ,3: very high。</para> |
| | | ///<para>squawk command:Data2(数值): 0 </para> |
| | | /// </summary> |
| | | /// <value>The type of the task.</value> |
| | | public int Data2; |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 获取场景列表 |
| | | ///<summary > |
| | | ///获取场景列表 |
| | | ///</summary> |
| | | public static async System.Threading.Tasks.Task<List<GetSceneAllInfo>> GetSceneListAsync() |
| | | { |
| | | ZbGateway.AllSceneList.Clear(); |
| | | return await System.Threading.Tasks.Task.Run(async () => { |
| | | var dateTime = DateTime.Now; |
| | | GetSceneAllData d = null; |
| | | var mainGateway = ZbGateway.MainGateWay; |
| | | if (mainGateway == null) |
| | | { |
| | | d = new GetSceneAllData { errorMessageBase = "当前没有主网关" }; |
| | | return null; |
| | | } |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/GetAllInfo_Respon") |
| | | { |
| | | dateTime = DateTime.Now; |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.sceneGetAllInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneAllInfo>(jobject["Data"].ToString()); |
| | | |
| | | var info = ZbGateway.AllSceneList.Find(obj => obj.ScenesId == scene.sceneGetAllInfo.ScenesId); |
| | | if (info == null) |
| | | { |
| | | ZbGateway.AllSceneList.Add(scene.sceneGetAllInfo); |
| | | } |
| | | else |
| | | { |
| | | info.DeviceList = scene.sceneGetAllInfo.DeviceList; |
| | | info.DeviceSum = scene.sceneGetAllInfo.DeviceSum; |
| | | info.IsOpen = scene.sceneGetAllInfo.IsOpen; |
| | | info.ScenesId = scene.sceneGetAllInfo.ScenesId; |
| | | info.ScenesName = scene.sceneGetAllInfo.ScenesName; |
| | | info.ScenesNum = scene.sceneGetAllInfo.ScenesNum; |
| | | info.ScenesSum = scene.sceneGetAllInfo.ScenesSum; |
| | | } |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/GetAllInfo_Actions 启动" + System.DateTime.Now.ToString()); |
| | | try |
| | | { |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 807 } }; |
| | | mainGateway.Send(("Scene/GetAllInfo"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch { } |
| | | |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | { |
| | | await System.Threading.Tasks.Task.Delay(10); |
| | | } |
| | | |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/GetAllInfo_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | return ZbGateway.AllSceneList; |
| | | }); |
| | | } |
| | | #endregion |
| | | |
| | | #region 只能获取场景信息,没有场景中的设备信息 |
| | |
| | | |
| | | //if (topic == gatewayID + "/" + "Error_Respon") |
| | | //{ |
| | | // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID }; |
| | | // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.GwId }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | |
| | | /// <summary> |
| | | ///获取场景信息,网关反馈信息 |
| | | /// </summary> |
| | | GetOnlySceneAllData getOnlySceneAllData; |
| | | /// <summary> |
| | | ///获取场景信息,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | class GetOnlySceneAllData |
| | | class GetOnlySceneAllData:CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 获取场景信息 |
| | | /// </summary> |
| | |
| | | /// 场景列表中的具体信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ScenesListInfo:CommonDevice |
| | | public class ScenesListInfo:CommonDevice |
| | | { |
| | | /// <summary> |
| | | /// 场景ID |
| | |
| | | ///获取当前场景中的设备列表信息 |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<GetSceneDeviceListAllInfo> GetSceneDeviceListAsync(int scenesId) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | GetSceneDeviceListAllInfo d = null; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/GetDeviceList_Respon") |
| | | { |
| | | var sceneTemp = new Scene() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | sceneTemp.sceneGetDeviceListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneDeviceListInfo>(jobject["Data"].ToString()); |
| | | |
| | | if (sceneTemp.sceneGetDeviceListObj == null) |
| | | var sceneGetDeviceListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneDeviceListInfo>(jobject["Data"].ToString()); |
| | | |
| | | if (sceneGetDeviceListObj == null) |
| | | { |
| | | d = new GetSceneDeviceListAllInfo { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | var sDev = mainGateway.SceneDeviceList.Find(obj => obj.ScenesId == sceneTemp.sceneGetDeviceListObj.ScenesId); |
| | | if (sDev == null) |
| | | { |
| | | ZbGateway.MainGateWay.SceneDeviceList.Add(sceneTemp.sceneGetDeviceListObj); |
| | | } |
| | | else |
| | | { |
| | | sDev.DeviceList = sceneTemp.sceneGetDeviceListObj.DeviceList; |
| | | } |
| | | |
| | | d = new GetSceneDeviceListAllInfo { getSceneDeviceListInfo = sceneTemp.sceneGetDeviceListObj }; |
| | | d = new GetSceneDeviceListAllInfo { getSceneDeviceListInfo = sceneGetDeviceListObj }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | |
| | | mainGateway.Send(("Scene/GetDeviceList"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch { } |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | | |
| | | |
| | | await System.Threading.Tasks.Task.Delay(10); |
| | | |
| | | |
| | | if (d != null) |
| | | { |
| | | break; |
| | |
| | | ///获取场景的设备列表信息,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneDeviceListAllInfo |
| | | public class GetSceneDeviceListAllInfo : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 获取场景的设备列表信息 |
| | | /// </summary> |
| | |
| | | ///场景ID |
| | | /// </summary> |
| | | public int ScenesId; |
| | | |
| | | |
| | | /// <summary> |
| | | ///场景是否处于开启状态 |
| | | ///0:场景没有开启 |
| | |
| | | /// <summary> |
| | | /// 添加目标到网关到场景中。 |
| | | /// <para>返回结果Result 1 加入成功</para> |
| | | /// <para>返回结果Result 0 加入失败</para> |
| | | /// <para>返回结果Result 0 加入失败</para> |
| | | /// </summary> |
| | | /// <returns>The scene member.</returns> |
| | | /// <param name="scenesId">Scenes identifier.</param> |
| | | public static async System.Threading.Tasks.Task<AddSceneMemberResponseAllData> AddSceneMemberAsync(AddSceneMemberData sceneMemberData) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | AddSceneMemberResponseAllData d = null; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/AddMember_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.addSceneMemberData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddSceneMemberResponseData>(jobject["Data"].ToString()); |
| | | var addSceneMemberData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddSceneMemberResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (scene.addSceneMemberData == null) |
| | | if (addSceneMemberData == null) |
| | | { |
| | | d = new AddSceneMemberResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new AddSceneMemberResponseAllData { addSceneMemberResponseData = scene.addSceneMemberData }; |
| | | d = new AddSceneMemberResponseAllData { addSceneMemberResponseData = addSceneMemberData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | |
| | | /// 获取场景中添加的成员,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class AddSceneMemberResponseAllData |
| | | public class AddSceneMemberResponseAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 获取场景中添加的成员 |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取场景中添加的成员 |
| | | /// 获取场景中添加的成员 |
| | | /// </summary> |
| | | public AddSceneMemberResponseData addSceneMemberData; |
| | | /// <summary> |
| | |
| | | public string DeviceAddr; |
| | | |
| | | /// <summary> |
| | | /// 设备端口号 |
| | | /// 设备端口号 |
| | | /// </summary> |
| | | public int Epoint; |
| | | |
| | |
| | | /// </summary> |
| | | public string DeviceAddr; |
| | | /// <summary> |
| | | /// 设备端口号 |
| | | /// 设备端口号 |
| | | /// <para>Type=0时存在</para> |
| | | /// </summary> |
| | | public int Epoint; |
| | |
| | | /// 设备列表 |
| | | /// <para>Type=0时存在</para> |
| | | /// </summary> |
| | | public List<TaskListInfo> TaskList = new List<TaskListInfo>(); |
| | | public List<Safeguard.TaskListInfo> TaskList = new List<Safeguard.TaskListInfo>(); |
| | | } |
| | | #endregion |
| | | |
| | | #region 从网关的场景中移除设备 |
| | | #region 从网关的场景中移除设备 |
| | | /// <summary> |
| | | /// 从网关的场景中移除设备. |
| | | /// <para>返回结果Result/RemoveResult 1:移除失败,成员不存在场景中</para> |
| | | /// <para>返回结果Result/RemoveResult 0:移除成功败</para> |
| | | /// <para>返回结果Result/RemoveResult 0:移除成功败</para> |
| | | /// </summary> |
| | | /// <returns>The scene member.</returns> |
| | | /// <param name="scenesId">Scenes identifier.</param> |
| | | public static async System.Threading.Tasks.Task<RemoveSceneMemberResponseAllData> RemoveSceneMemberAsync(SceneRemoveMemberData sceneRemoveMemberData) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | RemoveSceneMemberResponseAllData d = null; |
| | |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | } |
| | | if (topic == gatewayID + "/" + "Scene/RemoveMember_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.removeSceneMemberResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveSceneMemberResponseData>(jobject["Data"].ToString()); |
| | | var removeSceneMemberResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveSceneMemberResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (scene.removeSceneMemberResponseData == null) |
| | | if (removeSceneMemberResponseData == null) |
| | | { |
| | | d = new RemoveSceneMemberResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new RemoveSceneMemberResponseAllData { removeSceneMemberResponseData = scene.removeSceneMemberResponseData }; |
| | | d = new RemoveSceneMemberResponseAllData { removeSceneMemberResponseData = removeSceneMemberResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/RemoveMember_Actions 启动" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/RemoveMember_Actions 启动" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | try{ |
| | | if (sceneRemoveMemberData != null) |
| | |
| | | } |
| | | } |
| | | catch{} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | d = new RemoveSceneMemberResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/RemoveMember_Actions 退出" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/RemoveMember_Actions 退出" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | |
| | | /// 移除场景成员信息反馈,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class RemoveSceneMemberResponseAllData |
| | | public class RemoveSceneMemberResponseAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 移除场景成员信息反馈 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public int ElseScenesId; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 修改场景名称 |
| | | ///<summary > |
| | | /// 修改场景名称. |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<SceneRenameResponseAllData> RenameSceneAsync(int scenesId, string scenesName) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | SceneRenameResponseAllData d = null; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/Rename_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("DataID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.sceneRenameResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneRenameResponseData>(jobject["Data"].ToString()); |
| | | var sceneRenameResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneRenameResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (scene.sceneRenameResponseData == null) |
| | | if (sceneRenameResponseData == null) |
| | | { |
| | | d = new SceneRenameResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SceneRenameResponseAllData { sceneRenameResponseData = scene.sceneRenameResponseData }; |
| | | d = new SceneRenameResponseAllData { sceneRenameResponseData = sceneRenameResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/Rename_Actions 启动" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Rename_Actions 启动" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | try{ |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 804 } }; |
| | | var data = new JObject { { "ScenesId", scenesId }, { "ScenesName", scenesName } }; |
| | |
| | | mainGateway.Send(("Scene/Rename"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | d = new SceneRenameResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/Rename_Actions 退出" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Rename_Actions 退出" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | |
| | | /// 修改场景名称 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class SceneRenameResponseAllData |
| | | public class SceneRenameResponseAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 修改场景名称 |
| | | /// </summary> |
| | |
| | | ///<para>返回结果 2 没有该场景</para> |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<RemoveSceneAllData> DeleteSceneAsync(int scenesId) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | RemoveSceneAllData d =null; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/Remove_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.removeSceneData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveSceneData>(jobject["Data"].ToString()); |
| | | if (scene.removeSceneData == null) |
| | | var removeSceneData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveSceneData>(jobject["Data"].ToString()); |
| | | if (removeSceneData == null) |
| | | { |
| | | d = new RemoveSceneAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | for (int listCount = 0; listCount < ZigBee.Device.ZbGateway.AllSceneList.Count; listCount++) |
| | | { |
| | | var sc = ZbGateway.AllSceneList[listCount]; |
| | | |
| | | if (scene.removeSceneData.ScenesId == sc.ScenesId) |
| | | { |
| | | ZigBee.Device.ZbGateway.AllSceneList.RemoveAt(listCount); |
| | | listCount--; |
| | | } |
| | | } |
| | | d = new RemoveSceneAllData { removeSceneData = scene.removeSceneData }; |
| | | d = new RemoveSceneAllData { removeSceneData = removeSceneData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/Remove_Actions 启动" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Remove_Actions 启动" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | try{ |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 803 } }; |
| | | var data = new JObject { { "ScenesId", scenesId } }; |
| | |
| | | mainGateway.Send(("Scene/Remove"),jObject.ToString()); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | d = new RemoveSceneAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/Remove_Actions 退出" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Remove_Actions 退出" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | |
| | | /// 移除场景,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class RemoveSceneAllData |
| | | public class RemoveSceneAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 移除场景 |
| | | /// </summary> |
| | |
| | | /// <para>DelayTime:延时执行时间,单位秒</para> |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<SceneOpenAllData> ControlSceneAsync(int ScenesId,int delayTime) |
| | | { |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | SceneOpenAllData d = null; |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/Open_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.sceneOpen = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneOpenData>(jobject["Data"].ToString()); |
| | | if (scene.sceneOpen == null) |
| | | var sceneOpen = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneOpenData>(jobject["Data"].ToString()); |
| | | if (sceneOpen == null) |
| | | { |
| | | d = new SceneOpenAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SceneOpenAllData { sceneOpenData = scene.sceneOpen }; |
| | | d = new SceneOpenAllData { sceneOpenData = sceneOpen }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/Open_Actions 启动" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Open_Actions 启动" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | try{ |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 821 } }; |
| | | var data = new JObject { { "ScenesId", ScenesId }, { "DelayTime", delayTime } }; |
| | |
| | | mainGateway.Send(("Scene/Open"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime ) |
| | | { |
| | |
| | | d = new SceneOpenAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/Open_Actions退出" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/Open_Actions退出" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | |
| | | /// 调用场景,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class SceneOpenAllData |
| | | public class SceneOpenAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 调用场景 |
| | | /// </summary> |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 查看正在延时的场景 |
| | | #region 查看正在延时的场景 |
| | | /// <summary> |
| | | /// 查看正在延时的场景. |
| | | /// </summary> |
| | |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); |
| | | if (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | |
| | | } |
| | | if (topic == gatewayID + "/" + "Scene/CatDelayScene_Respon") |
| | | { |
| | | var scene = new Scene() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; |
| | | scene.catDelaySceneResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CatDelaySceneResponseData>(jobject["Data"].ToString()); |
| | | var catDelaySceneResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CatDelaySceneResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (scene.catDelaySceneResponseData == null) |
| | | if (catDelaySceneResponseData == null) |
| | | { |
| | | d = new CatDelaySceneResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new CatDelaySceneResponseAllData { catDelaySceneResponseData = scene.catDelaySceneResponseData }; |
| | | d = new CatDelaySceneResponseAllData { catDelaySceneResponseData = catDelaySceneResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | mainGateway.Actions += action; |
| | | System.Console.WriteLine("Scene/CatDelayScene_Actions 启动" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/CatDelayScene_Actions 启动" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | try |
| | | { |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 811 } }; |
| | |
| | | d = new CatDelaySceneResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/CatDelayScene_Actions 退出" + "_" + mainGateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | System.Console.WriteLine("Scene/CatDelayScene_Actions 退出" + "_" + mainGateway.GwId + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查看正在延时的场景信息信息反馈,网关反馈信息 |
| | | /// </summary> |
| | |
| | | /// 查看正在延时的场景信息反馈,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class CatDelaySceneResponseAllData |
| | | public class CatDelaySceneResponseAllData : CommonDevice.ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 查看正在延时的场景信息信息反馈 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class CatDelaySceneResponseData |
| | | { |
| | | { |
| | | /// <summary> |
| | | /// 正在延时执行的场景 |
| | | /// 正在延时执行的场景 |
| | | /// </summary> |
| | | public List<DelayScenesListResponseInfo> DelayScenesList = new List<DelayScenesListResponseInfo>(); |
| | | } |
| | |
| | | /// </summary> |
| | | public int RemainTime; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | ///<summary > |
| | | /// 场景被破坏反馈 |
| | |
| | | public int ScenesId; |
| | | |
| | | } |
| | | |
| | | //public static string SceneFilePath = "SceneFile"; |
| | | |
| | | //static Scene() |
| | | //{ |
| | | // if (null == Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(SceneFilePath)))) |
| | | // { |
| | | // //初始化场景列表 |
| | | // Shared.IO.FileUtils.WriteFileByBytes(SceneFilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(new List<string>()))); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 保存当前场景 |
| | | ///// </summary> |
| | | ///// <param name="scenceFilePath">Scence file path.</param> |
| | | //public void Save(string scenceFilePath) |
| | | //{ |
| | | // Shared.IO.FileUtils.WriteFileByBytes(scenceFilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 根据场景路径恢复场景对象 |
| | | /// </summary> |
| | | /// <returns>The by file path.</returns> |
| | | /// <param name="sceneFilePath">Room file path.</param> |
| | | //public static Scene GetSceneByFilePath(string sceneFilePath) |
| | | //{ |
| | | // try |
| | | // { |
| | | // return Newtonsoft.Json.JsonConvert.DeserializeObject<Scene>(System.Text.Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(sceneFilePath))); |
| | | // } |
| | | // catch |
| | | // { |
| | | // return new Scene(); |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 场景标识 |
| | | /// </summary> |
| | | //public bool SceneLabel = false; |
| | | |
| | | /// <summary> |
| | | /// 控制目标的文件路径,格式如:RoomScene_+DeviceID_Mac_Epoint |
| | | /// </summary> |
| | | //public readonly List<string> DeviceFilePathList = new List<string>(); |
| | | |
| | | /// <summary> |
| | | /// 场景的背景图 |
| | | /// </summary> |
| | | //public string BackgroundImagePath = "Scene/s1.png"; |
| | | |
| | | /// <summary> |
| | | /// 场景中的设备列表 |
| | | /// </summary> |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public List<Scene> sceneDeviceList = new List<Scene>(); |
| | | |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public List<Scene> LocalSceneList = new List<Scene>(); |
| | | |
| | | //public SceneId SceneID; |
| | | |
| | | ///<summary > |
| | | /// 从网关的场景中移除设备 |
| | | /// </summary> |
| | | //public static void SceneRemoveMember1(ZigBee.Device.ZbGateway gateway, int ScenesId, string DeviceAddr, int Epoint) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 802 } }; |
| | | // var DeviceList = new JArray |
| | | // { |
| | | // new JObject { |
| | | // { "Type", 0}, |
| | | // { "DeviceAddr",DeviceAddr}, |
| | | // { "Epoint",Epoint} |
| | | // } |
| | | // }; |
| | | // var data = new JObject { |
| | | // {"ScenesId",ScenesId}, |
| | | // { "DeviceList", DeviceList } |
| | | // }; |
| | | // jobject.Add("Data", data); |
| | | // gateway.Send(("Scene/RemoveMember"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | |
| | | //} |
| | | |
| | | ///<summary > |
| | | /// 删除场景 |
| | | /// </summary> |
| | | //public static void SceneRemove1(ZigBee.Device.ZbGateway gateway, int scenesId) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 803 } }; |
| | | // var data = new JObject { { "ScenesId", scenesId } }; |
| | | // jobject.Add("Data", data); |
| | | // gateway.Send(("Scene/Remove"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | |
| | | ///<summary > |
| | | /// 修改场景名称 |
| | | /// </summary> |
| | | //public static void SceneRename1(ZigBee.Device.ZbGateway gateway, int scenesId, string scenesName) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 804 } }; |
| | | // var data = new JObject { { "ScenesId", scenesId }, { "ScenesName", scenesName } }; |
| | | // jobject.Add("Data", data); |
| | | // gateway.Send(("Scene/Rename"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | |
| | | ///<summary > |
| | | /// 获取网关中场景信息 |
| | | /// </summary> |
| | | //public static void SceneGetInfo1(ZigBee.Device.ZbGateway gateway) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } }; |
| | | // gateway.Send(("Scene/GetInfo"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | |
| | | ///<summary > |
| | | ///获取网关中场景的设备列表 |
| | | /// </summary> |
| | | //public static void SceneGetDeviceList1(ZigBee.Device.ZbGateway gateway, int ScenesId) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 806 } }; |
| | | // var data = new JObject { { "ScenesId", ScenesId } }; |
| | | // jobject.Add("Data", data); |
| | | // gateway.Send(("Scene/GetDeviceList"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | |
| | | ///<summary > |
| | | /// 获取所有场景信息(包括场景设备列表) |
| | | /// </summary> |
| | | //public static void SceneGetAllInfo1(ZigBee.Device.ZbGateway gateway) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 807 } }; |
| | | // gateway.Send(("Scene/GetAllInfo"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | |
| | | ///<summary > |
| | | ///调用场景 |
| | | /// </summary> |
| | | //public static void SceneOpen1(ZigBee.Device.ZbGateway gateway, int ScenesId) |
| | | //{ |
| | | // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 808 } }; |
| | | // var data = new JObject { { "ScenesId", ScenesId } }; |
| | | // jobject.Add("Data", data); |
| | | // gateway.Send(("Scene/Open"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | } |
| | | } |
| | | } |