| | |
| | | { |
| | | /// <summary> |
| | | /// Error参数含义 |
| | | ///<para>1:网关无法解析命令数据。</para> |
| | | ///<para>1:网关无法解析命令数据。</para> |
| | | ///<para>2:协调器正在升级或备份/恢复数据 |
| | | ///<para>3:操作设备/组/场景不存在</para> |
| | | ///<para>4:其他错误</para> |
| | | ///<para>5:数据传输错误(在某次客户端向网关发送数据的过程中,网关在合理时间范围内接收客户端数据不完整导致该错误发生。如客户端向网关一次发送100个字节的数据,但网关等待接收了一秒只接收了80个字节。发生该错误,网关将主动关闭客户端连接)</para> |
| | | ///<para>3:操作设备/组/场景不存在</para> |
| | | ///<para>4:其他错误</para> |
| | | ///<para>5:数据传输错误(在某次客户端向网关发送数据的过程中,网关在合理时间范围内接收客户端数据不完整导致该错误发生。如客户端向网关一次发送100个字节的数据,但网关等待接收了一秒只接收了80个字节。发生该错误,网关将主动关闭客户端连接)</para> |
| | | /// </summary> |
| | | public int Error; |
| | | } |
| | |
| | | /// <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 ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | { |
| | | d = new GetSceneIdAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | |
| | | |
| | | } |
| | | mainGateway.Actions -= action; |
| | | System.Console.WriteLine("Scene/GetNewId_Actions 退出" + System.DateTime.Now.ToString()); |
| | |
| | | ///获取一个场景的所有信息 . |
| | | ///</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 { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error)}; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "Scene/GetAllInfo_Respon") |
| | | { |
| | |
| | | /// 获取所有场景的所有信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneAllInfo:CommonDevice |
| | | public class GetSceneAllInfo:CommonDevice |
| | | { |
| | | /// <summary> |
| | | ///场景总数 |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | |
| | | { |
| | | /// <summary> |
| | | /// 任务类型。 |
| | | ///<para>1:开关 (设备具有开关功能时可用)</para> |
| | | ///<para>3:亮度调整(设备具有亮度调节功能时可用)</para> |
| | | ///<para>4:颜色调整 (设备具有颜色调节功能时可用)</para> |
| | | ///<para>5:恒温器(设备具有恒温器功能时可用)</para> |
| | | ///<para>6: 窗帘设备(设备具有窗帘功能时可用)</para> |
| | | ///<para>7:设备identify识别。</para> |
| | | ///<para>8:开关报警模式 </para> |
| | | ///<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> |
| | | /// <summary> |
| | | /// Data1取值 |
| | | /// <para>开关 :Data1(数值): 0关/1开</para> |
| | | ///<para>亮度调整 Data1(数值):亮度值</para> |
| | |
| | | /// </summary> |
| | | public int Data1; |
| | | /// <summary> |
| | | /// Data2取值 |
| | | /// Data2取值 |
| | | /// <para>开关 Data2(数值): 0</para> |
| | | /// <para>亮度调整 Data2(数值): 0</para> |
| | | /// <para>颜色调整 Data2(数值):饱和度 </para> |
| | | ///<para> 恒温器Data2数值如下: |
| | | ///<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数值如下 |
| | | ///<para>窗帘设备,Data2数值如下 |
| | | ///【当Data1=4或7,Data2为调整的高度或倾斜角度 倾斜角度单位为0.1°】。 |
| | | ///【当Data1=5 或 8,Data2为百分比,0-100表示0%-100%】</para> |
| | | ///<para>设备identify识别。Data2(数值): 0 </para> |
| | |
| | | /// 场景列表中的具体信息 |
| | | /// </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; |
| | |
| | | { |
| | | 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) |
| | | { |
| | | d = new GetSceneDeviceListAllInfo { errorMessageBase = "网关返回的数据为空" }; |
| | |
| | | { |
| | | sDev.DeviceList = sceneTemp.sceneGetDeviceListObj.DeviceList; |
| | | } |
| | | |
| | | |
| | | d = new GetSceneDeviceListAllInfo { getSceneDeviceListInfo = sceneTemp.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; |
| | |
| | | ///场景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; |
| | |
| | | } |
| | | |
| | | /// <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; |
| | |
| | | } |
| | | #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; |
| | |
| | | } |
| | | } |
| | | catch{} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | /// </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; |
| | |
| | | mainGateway.Send(("Scene/Rename"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | ///<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; |
| | |
| | | mainGateway.Send(("Scene/Remove"),jObject.ToString()); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | |
| | | /// <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; |
| | |
| | | mainGateway.Send(("Scene/Open"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); |
| | | } |
| | | catch {} |
| | | |
| | | |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime ) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 查看正在延时的场景 |
| | | #region 查看正在延时的场景 |
| | | /// <summary> |
| | | /// 查看正在延时的场景. |
| | | /// </summary> |
| | |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查看正在延时的场景信息信息反馈,网关反馈信息 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class CatDelaySceneResponseData |
| | | { |
| | | { |
| | | /// <summary> |
| | | /// 正在延时执行的场景 |
| | | /// 正在延时执行的场景 |
| | | /// </summary> |
| | | public List<DelayScenesListResponseInfo> DelayScenesList = new List<DelayScenesListResponseInfo>(); |
| | | } |
| | |
| | | /// </summary> |
| | | public int RemainTime; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | ///<summary > |
| | | /// 场景被破坏反馈 |
| | |
| | | // gateway.Send(("Scene/Open"), Common.SecuritySet.Encryption((jobject.ToString()))); |
| | | //} |
| | | } |
| | | } |
| | | } |