| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///设备绑定【一对一 绑定,一个按键回路只能绑定一个设备】
|
| | | /// </summary>
|
| | | public BindObj.AddedDeviceBindResponseAllData AddDeviceSingleBindAsync(BindObj.AddBindData addBindData)
|
| | | {
|
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
|
| | | }
|
| | |
|
| | | var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
|
| | | //获取发送的命令字符
|
| | | var sendData = this.GetAddDeviceListBindCommandText(addBindData);
|
| | | //发送 |
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetSingleBind", sendData, "Bind/SetSingleBind_Respon", 20);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | //修改缓存
|
| | | TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]);
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
|
| | | return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取添加设备绑定的命令字符
|
| | | /// </summary>
|
| | | /// <param name="addBindData"></param>
|
| | |
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///设备绑定【一对一 绑定,一个按键回路只能绑定一个设备】
|
| | | /// </summary>
|
| | | public BindObj.AddedDeviceSingleBindResponseAllData AddDeviceSingleBindAsync(BindObj.AddSingleBindData addSingleBindData)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(addSingleBindData.DeviceAddr, addSingleBindData.Epoint);
|
| | | //获取发送的命令字符
|
| | | var sendData = this.GetAddDeviceListSingleBindCommandText(addSingleBindData);
|
| | | //发送 |
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetSingleBind", sendData, "Bind/SetSingleBind_Respon", 20);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceSingleBindResponseData>(result.ReceiptData);
|
| | | return new BindObj.AddedDeviceSingleBindResponseAllData() { addedDeviceSingleBindResponseData = tempData };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取添加设备绑定的命令字符
|
| | | /// </summary>
|
| | | /// <param name="addBindData"></param>
|
| | | /// <returns></returns>
|
| | | public string GetAddDeviceListSingleBindCommandText(BindObj.AddSingleBindData addSingleBindData)
|
| | | {
|
| | | var jObject = new JObject { { "DeviceAddr", addSingleBindData.DeviceAddr }, { "Epoint", addSingleBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5020 } };
|
| | | var data = new JObject { };
|
| | | var bindClusterList = new JArray { };
|
| | | foreach (var cluster in addSingleBindData.BindClusterList)
|
| | | {
|
| | | bindClusterList.Add(cluster);
|
| | | }
|
| | | if (addSingleBindData.BindType == 0)
|
| | | {
|
| | | data = new JObject { { "BindName", addSingleBindData.BindName }, { "BindType", addSingleBindData.BindType }, { "BindClusterList", bindClusterList }, { "BindMacAddr", addSingleBindData.BindMacAddr }, { "BindEpoint", addSingleBindData.BindEpoint } };
|
| | | }
|
| | | else if (addSingleBindData.BindType == 1)
|
| | | {
|
| | | data = new JObject { { "BindName", addSingleBindData.BindName }, { "BindType", addSingleBindData.BindType }, { "BindClusterList", bindClusterList }, { "BindScenesId", addSingleBindData.BindScenesId } };
|
| | |
|
| | | }
|
| | | jObject.Add("Data", data);
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 删除设备绑定的目标_________________
|