| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind");
|
| | | var listBind = TemplateData.TemplateDeviceDataLogic.Current.GetDeviceBindList(device);
|
| | | return new BindObj.GetDeviceBindResponseAllData()
|
| | | {
|
| | | getAllBindResponseData = new BindObj.GetDeviceBindResponseData
|
| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, null);
|
| | | }
|
| | |
|
| | | var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
|
| | |
| | | }
|
| | |
|
| | | //修改缓存
|
| | | ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
|
| | |
|
| | | TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]);
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
|
| | | return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
|
| | | }
|
| | |
| | | jObject.Add("Data", data);
|
| | | 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
|
| | |
|
| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
|
| | | }
|
| | | var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint);
|
| | | //获取需要发送的数据
|
| | |
| | | }
|
| | |
|
| | | //修改缓存
|
| | | ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
|
| | | TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
|
| | |
|
| | | return responseData;
|
| | | }
|
| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device);
|
| | | }
|
| | |
|
| | | var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } };
|
| | |
| | | }
|
| | |
|
| | | //修改缓存
|
| | | ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
|
| | | TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device);
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.ClearBindInfoResponseData>(result.ReceiptData);
|
| | | return new BindObj.ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData };
|
| | |
| | | return reResult;
|
| | | }
|
| | | //网关ID
|
| | | string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway);
|
| | | string gatewayID = device.Gateway.GwId;
|
| | | //错误主题
|
| | | string errorTopic = gatewayID + "/" + "Error_Respon";
|
| | | //检测对象的主题
|
| | |
| | | }
|
| | |
|
| | | bool canbreak = false;
|
| | | BindObj.DelDeviceBindResponseData delDeviceBindData = null;
|
| | | BindObj.RemoveBindResultResponseData removeBindResult = null;
|
| | |
|
| | | Action<string, string> receiptAction = (topic, message) =>
|
| | | {
|
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
|
| | |
| | | return;
|
| | | }
|
| | | reResult.listReceiptData[i] = jobject["Data"].ToString();
|
| | |
|
| | | if (i == 0)
|
| | | {
|
| | | //只有是Bind/RemoveBind_Respon主题,才能中断
|
| | | //"Bind/RemoveBind_Respon"主题
|
| | | delDeviceBindData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.DelDeviceBindResponseData>(reResult.listReceiptData[i]);
|
| | | }
|
| | | else if (i == 1)
|
| | | {
|
| | | //"Bind/RemoveBindResult"主题
|
| | | removeBindResult = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.RemoveBindResultResponseData>(reResult.listReceiptData[i]);
|
| | | }
|
| | |
|
| | | if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 1).Count)
|
| | | {
|
| | | canbreak = true;
|
| | | }
|
| | | else if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
|
| | | {
|
| | | if (removeBindResult != null)
|
| | | {
|
| | | canbreak = true;
|
| | | }
|
| | | }
|
| | | else if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count)
|
| | | {
|
| | | if (removeBindResult != null)
|
| | | {
|
| | | canbreak = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | canbreak = true;
|
| | | }
|
| | | }
|
| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, null);
|
| | | }
|
| | | //获取发送数据
|
| | | var sendData = this.GetConfigureHdlKeyCommandText(device.DeviceAddr, device.DeviceEpoint, value, clusterID);
|
| | |
| | | }
|
| | |
|
| | | //修改缓存
|
| | | ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
|
| | | TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, result.JsonData[0]);
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData);
|
| | | return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData };
|
| | |
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device);
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.ReadPanelConfigureKeyModel(device);
|
| | | }
|
| | |
|
| | | var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint },
|