| | |
| | | }
|
| | | #endregion |
| | |
|
| | | #region 获取所有网关的节点设备信息(用于主网关) |
| | | ///// <summary>
|
| | | ///// 获取所有网关的节点设备信息(用于主网关)
|
| | | ///// </summary>
|
| | | //public static async System.Threading.Tasks.Task<List<CommonDevice>> GetAllGatewayDeviceInfoList()
|
| | | //{
|
| | | // if (ZbGateway.MainGateWay == null)
|
| | | // {
|
| | | // return null;
|
| | | // }
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Clear();
|
| | | // return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<List<CommonDevice>>>)(async () =>
|
| | | // {
|
| | | // var dateTime = DateTime.Now;
|
| | | // Action<string, string> action = (topic, message) =>
|
| | | // {
|
| | |
|
| | | // var gatewayID = topic.Split('/')[0];
|
| | | // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
|
| | | // if (topic == gatewayID + "/" + "DeviceInfoRespon")
|
| | | // {
|
| | | // dateTime = DateTime.Now;
|
| | | // var deviceID = jobject.Value<int>("Device_ID");
|
| | | // switch ((DeviceType)(deviceID))
|
| | | // {
|
| | | // case DeviceType.ColorDimmableLight:
|
| | | // var dimmableLight = new ColorDimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID") };
|
| | | // dimmableLight.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorDimmableLight.AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (dimmableLight.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // dimmableLight.CurrentGateWayId = dimmableLight.getAllGatewayDeviceInfo.GwId;
|
| | | // var light = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
|
| | | // if (light == null)
|
| | | // {
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(dimmableLight);
|
| | | // dimmableLight.DeviceName = dimmableLight.getAllGatewayDeviceInfo.MacName;
|
| | | // dimmableLight.DeviceEpointName = dimmableLight.getAllGatewayDeviceInfo.DeviceName;
|
| | | // dimmableLight.ImgVersion = dimmableLight.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // dimmableLight.IsOnline = dimmableLight.getAllGatewayDeviceInfo.IsOnline;
|
| | | // dimmableLight.IasDeviceType = dimmableLight.getAllGatewayDeviceInfo.DeviceType;
|
| | | // dimmableLight.Profile = dimmableLight.getAllGatewayDeviceInfo.Profile;
|
| | | // dimmableLight.ImgTypeId = dimmableLight.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // dimmableLight.InClusterList = dimmableLight.getAllGatewayDeviceInfo.InClusterList;
|
| | | // dimmableLight.OutClusterList = dimmableLight.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // dimmableLight.AttributeStatus = dimmableLight.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // dimmableLight.Save();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // light.getAllGatewayDeviceInfo = dimmableLight.getAllGatewayDeviceInfo;
|
| | | // light.DeviceName = dimmableLight.getAllGatewayDeviceInfo.MacName;
|
| | | // light.DeviceEpointName = dimmableLight.getAllGatewayDeviceInfo.DeviceName;
|
| | | // light.ImgVersion = dimmableLight.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // light.IsOnline = dimmableLight.getAllGatewayDeviceInfo.IsOnline;
|
| | | // light.IasDeviceType = dimmableLight.getAllGatewayDeviceInfo.DeviceType;
|
| | | // light.Profile = dimmableLight.getAllGatewayDeviceInfo.Profile;
|
| | | // light.ImgTypeId = dimmableLight.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // light.InClusterList = dimmableLight.getAllGatewayDeviceInfo.InClusterList;
|
| | | // light.OutClusterList = dimmableLight.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // light.AttributeStatus = dimmableLight.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // light.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | |
|
| | | // break;
|
| | | // case DeviceType.OnOffOutput:
|
| | | // var toggleLight = new ToggleLight() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID") };
|
| | | // toggleLight.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (toggleLight.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // toggleLight.CurrentGateWayId = toggleLight.getAllGatewayDeviceInfo.GwId;
|
| | |
|
| | | // var localToggleLight = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
|
| | | // if (localToggleLight == null)
|
| | | // {
|
| | | // toggleLight.DeviceName = toggleLight.getAllGatewayDeviceInfo.MacName;
|
| | | // toggleLight.DeviceEpointName = toggleLight.getAllGatewayDeviceInfo.DeviceName;
|
| | | // toggleLight.ImgVersion = toggleLight.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // toggleLight.IsOnline = toggleLight.getAllGatewayDeviceInfo.IsOnline;
|
| | | // toggleLight.IasDeviceType = toggleLight.getAllGatewayDeviceInfo.DeviceType;
|
| | | // toggleLight.Profile = toggleLight.getAllGatewayDeviceInfo.Profile;
|
| | | // toggleLight.ImgTypeId = toggleLight.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // toggleLight.InClusterList = toggleLight.getAllGatewayDeviceInfo.InClusterList;
|
| | | // toggleLight.OutClusterList = toggleLight.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // toggleLight.AttributeStatus = toggleLight.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(toggleLight);
|
| | | // toggleLight.Save();
|
| | |
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // localToggleLight.getAllGatewayDeviceInfo = toggleLight.getAllGatewayDeviceInfo;
|
| | | // localToggleLight.DeviceName = toggleLight.getAllGatewayDeviceInfo.MacName;
|
| | | // localToggleLight.DeviceEpointName = toggleLight.getAllGatewayDeviceInfo.DeviceName;
|
| | | // localToggleLight.ImgVersion = toggleLight.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // localToggleLight.IsOnline = toggleLight.getAllGatewayDeviceInfo.IsOnline;
|
| | | // localToggleLight.IasDeviceType = toggleLight.getAllGatewayDeviceInfo.DeviceType;
|
| | | // localToggleLight.Profile = toggleLight.getAllGatewayDeviceInfo.Profile;
|
| | | // localToggleLight.ImgTypeId = toggleLight.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // localToggleLight.InClusterList = toggleLight.getAllGatewayDeviceInfo.InClusterList;
|
| | | // localToggleLight.OutClusterList = toggleLight.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // localToggleLight.AttributeStatus = toggleLight.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // localToggleLight.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | |
|
| | | // break;
|
| | | // case DeviceType.OnOffSwitch:
|
| | | // var panel = new Panel() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID") };
|
| | | // panel.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (panel.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // panel.CurrentGateWayId = panel.getAllGatewayDeviceInfo.GwId;
|
| | |
|
| | | // var localPanel = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr && obj.DeviceEpoint == panel.DeviceEpoint);
|
| | | // if (localPanel == null)
|
| | | // {
|
| | | // panel.DeviceName = panel.getAllGatewayDeviceInfo.MacName;
|
| | | // panel.DeviceEpointName = panel.getAllGatewayDeviceInfo.DeviceName;
|
| | | // panel.ImgVersion = panel.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // panel.IsOnline = panel.getAllGatewayDeviceInfo.IsOnline;
|
| | | // panel.IasDeviceType = panel.getAllGatewayDeviceInfo.DeviceType;
|
| | | // panel.Profile = panel.getAllGatewayDeviceInfo.Profile;
|
| | | // panel.ImgTypeId = panel.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // panel.InClusterList = panel.getAllGatewayDeviceInfo.InClusterList;
|
| | | // panel.OutClusterList = panel.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // panel.AttributeStatus = panel.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // if (panel.DeviceAddr != null)
|
| | | // {
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(panel);
|
| | | // }
|
| | | // panel.Save();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // localPanel.getAllGatewayDeviceInfo = panel.getAllGatewayDeviceInfo;
|
| | | // localPanel.DeviceName = panel.getAllGatewayDeviceInfo.MacName;
|
| | | // localPanel.DeviceEpointName = panel.getAllGatewayDeviceInfo.DeviceName;
|
| | | // localPanel.ImgVersion = panel.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // localPanel.IsOnline = panel.getAllGatewayDeviceInfo.IsOnline;
|
| | | // localPanel.IasDeviceType = panel.getAllGatewayDeviceInfo.DeviceType;
|
| | | // localPanel.Profile = panel.getAllGatewayDeviceInfo.Profile;
|
| | | // localPanel.ImgTypeId = panel.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // localPanel.InClusterList = panel.getAllGatewayDeviceInfo.InClusterList;
|
| | | // localPanel.OutClusterList = panel.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // localPanel.AttributeStatus = panel.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // localPanel.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | |
|
| | | // break;
|
| | | // case DeviceType.WindowCoveringDevice:
|
| | | // var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>((object)"Device_ID"), DeviceAddr = jobject.Value<string>((object)"DeviceAddr"), DeviceEpoint = jobject.Value<int>((object)"Epoint"), DataID = jobject.Value<int>((object)"Data_ID") };
|
| | | // windowCovering.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (windowCovering.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // windowCovering.CurrentGateWayId = windowCovering.getAllGatewayDeviceInfo.GwId;
|
| | |
|
| | | // var wc = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
|
| | | // if (wc == null)
|
| | | // {
|
| | | // windowCovering.DeviceName = windowCovering.getAllGatewayDeviceInfo.MacName;
|
| | | // windowCovering.DeviceEpointName = windowCovering.getAllGatewayDeviceInfo.DeviceName;
|
| | | // windowCovering.ImgVersion = windowCovering.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // windowCovering.IsOnline = windowCovering.getAllGatewayDeviceInfo.IsOnline;
|
| | | // windowCovering.IasDeviceType = windowCovering.getAllGatewayDeviceInfo.DeviceType;
|
| | | // windowCovering.Profile = windowCovering.getAllGatewayDeviceInfo.Profile;
|
| | | // windowCovering.ImgTypeId = windowCovering.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // windowCovering.InClusterList = windowCovering.getAllGatewayDeviceInfo.InClusterList;
|
| | | // windowCovering.OutClusterList = windowCovering.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // windowCovering.AttributeStatus = windowCovering.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(windowCovering);
|
| | | // windowCovering.Save();
|
| | |
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // wc.getAllGatewayDeviceInfo = windowCovering.getAllGatewayDeviceInfo;
|
| | | // wc.DeviceName = windowCovering.getAllGatewayDeviceInfo.MacName;
|
| | | // wc.DeviceEpointName = windowCovering.getAllGatewayDeviceInfo.DeviceName;
|
| | | // wc.ImgVersion = windowCovering.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // wc.IsOnline = windowCovering.getAllGatewayDeviceInfo.IsOnline;
|
| | | // wc.IasDeviceType = windowCovering.getAllGatewayDeviceInfo.DeviceType;
|
| | | // wc.Profile = windowCovering.getAllGatewayDeviceInfo.Profile;
|
| | | // wc.ImgTypeId = windowCovering.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // wc.InClusterList = windowCovering.getAllGatewayDeviceInfo.InClusterList;
|
| | | // wc.OutClusterList = windowCovering.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // wc.AttributeStatus = windowCovering.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // wc.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | |
|
| | | // break;
|
| | | // case DeviceType.IASZone:
|
| | | // var ias = new IASZone() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID") };
|
| | | // ias.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (ias.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // ias.CurrentGateWayId = ias.getAllGatewayDeviceInfo.GwId;
|
| | |
|
| | | // var infoIAS = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
|
| | | // if (infoIAS == null)
|
| | | // {
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(ias);
|
| | | // ias.DeviceName = ias.getAllGatewayDeviceInfo.MacName;
|
| | | // ias.DeviceEpointName = ias.getAllGatewayDeviceInfo.DeviceName;
|
| | | // ias.ImgVersion = ias.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // ias.IsOnline = ias.getAllGatewayDeviceInfo.IsOnline;
|
| | | // ias.IasDeviceType = ias.getAllGatewayDeviceInfo.DeviceType;
|
| | | // ias.Profile = ias.getAllGatewayDeviceInfo.Profile;
|
| | | // ias.ImgTypeId = ias.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // ias.InClusterList = ias.getAllGatewayDeviceInfo.InClusterList;
|
| | | // ias.OutClusterList = ias.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // ias.AttributeStatus = ias.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ias.Save();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // infoIAS.DeviceName = ias.getAllGatewayDeviceInfo.MacName;
|
| | | // infoIAS.DeviceEpointName = ias.getAllGatewayDeviceInfo.DeviceName;
|
| | | // infoIAS.getAllGatewayDeviceInfo = ias.getAllGatewayDeviceInfo;
|
| | | // infoIAS.ImgVersion = ias.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // infoIAS.IsOnline = ias.getAllGatewayDeviceInfo.IsOnline;
|
| | | // infoIAS.IasDeviceType = ias.getAllGatewayDeviceInfo.DeviceType;
|
| | | // infoIAS.Profile = ias.getAllGatewayDeviceInfo.Profile;
|
| | | // infoIAS.ImgTypeId = ias.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // infoIAS.InClusterList = ias.getAllGatewayDeviceInfo.InClusterList;
|
| | | // infoIAS.OutClusterList = ias.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // infoIAS.AttributeStatus = ias.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ias.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | | // break;
|
| | | // case DeviceType.OtaDevice:
|
| | | // case DeviceType.OtaPanelDevice:
|
| | | // var ota = new OTADevice() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID") };
|
| | | // ota.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AllGatewayDeviceInfo>(jobject["Data"].ToString());
|
| | | // if (ota.getAllGatewayDeviceInfo == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // ota.CurrentGateWayId = ota.getAllGatewayDeviceInfo.GwId;
|
| | |
|
| | | // var infoOta = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == ota.DeviceID && obj.DeviceAddr == ota.DeviceAddr && obj.DeviceEpoint == ota.DeviceEpoint);
|
| | | // if (infoOta == null)
|
| | | // {
|
| | | // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(ota);
|
| | | // ota.DeviceName = ota.getAllGatewayDeviceInfo.MacName;
|
| | | // ota.DeviceEpointName = ota.getAllGatewayDeviceInfo.DeviceName;
|
| | | // ota.ImgVersion = ota.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // ota.IsOnline = ota.getAllGatewayDeviceInfo.IsOnline;
|
| | | // ota.IasDeviceType = ota.getAllGatewayDeviceInfo.DeviceType;
|
| | | // ota.Profile = ota.getAllGatewayDeviceInfo.Profile;
|
| | | // ota.ImgTypeId = ota.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // ota.InClusterList = ota.getAllGatewayDeviceInfo.InClusterList;
|
| | | // ota.OutClusterList = ota.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // ota.AttributeStatus = ota.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ota.Save();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // infoOta.DeviceName = ota.getAllGatewayDeviceInfo.MacName;
|
| | | // infoOta.DeviceEpointName = ota.getAllGatewayDeviceInfo.DeviceName;
|
| | | // infoOta.getAllGatewayDeviceInfo = ota.getAllGatewayDeviceInfo;
|
| | | // infoOta.ImgVersion = ota.getAllGatewayDeviceInfo.ImgVersion;
|
| | | // infoOta.IsOnline = ota.getAllGatewayDeviceInfo.IsOnline;
|
| | | // infoOta.IasDeviceType = ota.getAllGatewayDeviceInfo.DeviceType;
|
| | | // infoOta.Profile = ota.getAllGatewayDeviceInfo.Profile;
|
| | | // infoOta.ImgTypeId = ota.getAllGatewayDeviceInfo.ImgTypeId;
|
| | | // infoOta.InClusterList = ota.getAllGatewayDeviceInfo.InClusterList;
|
| | | // infoOta.OutClusterList = ota.getAllGatewayDeviceInfo.OutClusterList;
|
| | | // infoOta.AttributeStatus = ota.getAllGatewayDeviceInfo.AttributeStatus;
|
| | | // ota.ReSave();
|
| | | // }
|
| | | // System.Console.WriteLine($"收到通知后的主题_{ topic}");
|
| | | // break;
|
| | | // //case DeviceType.Thermostat:
|
| | | // //var thermostat = new ThermostatObj() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
|
| | | // //thermostat.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceInfoData>(jobject["Data"].ToString());
|
| | | // //if (thermostat.DeviceInfo == null)
|
| | | // //{
|
| | | // // return;
|
| | | // //}
|
| | | // // var ther = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == thermostat.DeviceID && obj.DeviceAddr == thermostat.DeviceAddr && obj.DeviceEpoint == thermostat.DeviceEpoint);
|
| | | // //if (ther == null)
|
| | | // //{
|
| | | // // thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
|
| | | // // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(thermostat);
|
| | | // //}
|
| | | // //else
|
| | | // //{
|
| | | // // thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
|
| | | // // ZigBee.IO.LocalFileUtils.SaveDeviceInfo(thermostat, thermostat.DeviceEpoint.ToString());
|
| | | // //}
|
| | | // //break;
|
| | | // //case DeviceType.TemperatureSensor:
|
| | | // // var temperatureSensor = new TemperatureSensor() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
|
| | | // // temperatureSensor.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceInfoData>(jobject["Data"].ToString());
|
| | | // // if (temperatureSensor.DeviceInfo == null)
|
| | | // // {
|
| | | // // return;
|
| | | // // }
|
| | | // // var ts = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceAddr == temperatureSensor.DeviceAddr && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
|
| | | // // if (ts == null)
|
| | | // // {
|
| | | // // temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
|
| | | // // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(temperatureSensor);
|
| | |
|
| | | // // }
|
| | | // // else
|
| | | // // {
|
| | | // // temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
|
| | | // // IO.LocalFileUtils.SaveDeviceInfo(temperatureSensor, temperatureSensor.DeviceEpoint.ToString());
|
| | | // // }
|
| | | // // break;
|
| | |
|
| | | // }
|
| | | // }
|
| | | // };
|
| | |
|
| | | // ZbGateway.MainGateWay.Actions += action;
|
| | | // System.Console.WriteLine("MainGatewayDeviceInfo_Actions 启动" + System.DateTime.Now.ToString());
|
| | |
|
| | | // var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 90 } };
|
| | | // ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
|
| | | // ZbGateway.MainGateWay.Send("GetAllDeviceInfo", Common.SecuritySet.Encryption(jObject.ToString()));
|
| | |
|
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 4000)
|
| | | // {
|
| | | // await System.Threading.Tasks.Task.Delay(100);
|
| | | // }
|
| | |
|
| | | // ZbGateway.MainGateWay.Actions -= action;
|
| | | // System.Console.WriteLine("MainGatewayDeviceInfo_Actions 退出" + System.DateTime.Now.ToString());
|
| | | // return ZbGateway.MainGateWay.AllGatewayDeviceList;
|
| | | // }));
|
| | | //}
|
| | | #endregion |
| | |
|
| | | #region 网关恢复出厂设置 |
| | | /// <summary> |
| | | /// 网关恢复出厂设置返回的数据. |
| | |
| | | } |
| | | #endregion |
| | | |
| | | //#region 获取协调器获取协调器当前发射功率. |
| | | /////<summary > |
| | | ///// 获取协调器获取协调器当前发射功率 |
| | | ///// </summary> |
| | | //public static async System.Threading.Tasks.Task<GwGetPowerResponData> GetPowerAsync(ZigBee.Device.ZbGateway gateway) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // GwGetPowerResponData d = null; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // 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 = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d = new GwGetPowerResponData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GwGetPowerResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/GetPower_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // var power = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Power"].ToString()); |
| | | |
| | | // if (power == 0) |
| | | // { |
| | | // d = new GwGetPowerResponData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GwGetPowerResponData { power = power }; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // gateway.Actions += action; |
| | | // System.Console.WriteLine("GetPower_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 10 } };
|
| | | // gateway.Send(("ZbGw/GetPower"), Common.SecuritySet.Encryption((jObject.ToString()))); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 1000) |
| | | // { |
| | | // d = new GwGetPowerResponData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // System.Console.WriteLine("GetPower_Actions 退出" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 获取协调器获取协调器当前发射功率,网关反馈具体信息 |
| | | ///// </summary> |
| | | //public GwGetPowerResponData gwGetPowerResponData; |
| | | ///// <summary> |
| | | ///// 获取协调器获取协调器当前发射功率,网关反馈具体信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class GwGetPowerResponData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 协调器发射功率 |
| | | // /// </summary> |
| | | // public int power = 999; |
| | | //} |
| | | |
| | | //#endregion |
| | | |
| | | //#region 设置发射功. |
| | | /////<summary > |
| | | /////设置发射功率 |
| | | ///// <para>power:要更改的设备发射功率,可设置8,10,11,13,15,16,18,19,20,21,22(dBm)</para> |
| | | ///// </summary> |
| | | //public static async System.Threading.Tasks.Task<SetPowerResponAllData> GwSetPowerAsync(ZigBee.Device.ZbGateway gateway, int power) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // SetPowerResponAllData d = null; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // 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 = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d = new SetPowerResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new SetPowerResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/SetPower_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // var tempInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SetPoweResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (tempInfo == null) |
| | | // { |
| | | // d = new SetPowerResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new SetPowerResponAllData { setPoweResponData = tempInfo }; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // gateway.Actions += action; |
| | | // System.Console.WriteLine("ZbGw/SetPower_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 11 } }; |
| | | // var data = new JObject { { "Power", power } }; |
| | | // jObject.Add("Data", data);
|
| | | // gateway.Send(("ZbGw/SetPower"), Common.SecuritySet.Encryption(jObject.ToString(),Password)); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 1000) |
| | | // { |
| | | // d = new SetPowerResponAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // System.Console.WriteLine("ZbGw/SetPower_Actions退出" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 设置发射功率,网关反馈具体信息 |
| | | ///// </summary> |
| | | //public SetPowerResponAllData setPoweResponAllData; |
| | | ///// <summary> |
| | | ///// 设置发射功率,网关反馈具体信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class SetPowerResponAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 设置发射功率数据 |
| | | // /// </summary> |
| | | // public SetPoweResponData setPoweResponData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 设置发射功率数据 |
| | | ///// </summary> |
| | | //public SetPoweResponData setPoweResponData; |
| | | ///// <summary> |
| | | ///// 设置发射功率数据 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class SetPoweResponData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 是否配置成功 |
| | | // ///<para>0:成功</para> |
| | | // ///<para>2:配置的信道为无效值</para> |
| | | // /// </summary> |
| | | // public int Status = 999; |
| | | // /// <summary> |
| | | // /// 功率 |
| | | // /// </summary> |
| | | // public int Power = 999; |
| | | //} |
| | | //#endregion |
| | | |
| | | //#region 读取当前局域网的PANID. |
| | | /////<summary > |
| | | ///// 读取当前局域网的PANID |
| | | ///// </summary> |
| | | //public static async System.Threading.Tasks.Task<GetPanIdResponData> ReadPanIdAsync(ZigBee.Device.ZbGateway gateway) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // GetPanIdResponData d = null; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // 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 = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d = new GetPanIdResponData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetPanIdResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/GetPanId_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // var panID = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["PANID"].ToString()); |
| | | |
| | | // if (panID == null) |
| | | // { |
| | | // d = new GetPanIdResponData { errorMessageBase = "网关返回的数据为空" }; |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetPanIdResponData { panID = panID }; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // gateway.Actions += action; |
| | | // System.Console.WriteLine("ZbGw/GetPanId_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 12 } };
|
| | | // gateway.Send(("ZbGw/GetPanId"), Common.SecuritySet.Encryption((jObject.ToString()))); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 1000) |
| | | // { |
| | | // d = new GetPanIdResponData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // System.Console.WriteLine("ZbGw/GetPanId_Actions 退出" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 读取当前局域网的PANID,网关反馈具体信息 |
| | | ///// </summary> |
| | | //public GetPanIdResponData getPanIdResponData; |
| | | ///// <summary> |
| | | ///// 读取当前局域网的PANID,网关反馈具体信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class GetPanIdResponData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 当前网络的PANID |
| | | // /// </summary> |
| | | // public int panID = 999; |
| | | //} |
| | | |
| | | //#endregion |
| | | |
| | | //#region 读取协调器MAC地址. |
| | | /////<summary > |
| | | ///// 读取协调器MAC地址 |
| | | ///// </summary> |
| | | //public static async System.Threading.Tasks.Task<GetMacResponData> ReadMacAsync(ZigBee.Device.ZbGateway gateway) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // GetMacResponData d = null; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // 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 = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d = new GetMacResponData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetMacResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/GetMac_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<MacAddrData>(jobject["Data"].ToString()); |
| | | |
| | | // if (tempData == null) |
| | | // { |
| | | // d = new GetMacResponData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetMacResponData { macAddrData = tempData }; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // gateway.Actions += action; |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
|
| | | // gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jObject.ToString()))); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000) |
| | | // { |
| | | // d = new GetMacResponData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 读取协调器MAC地址,网关反馈具体信息 |
| | | /// </summary> |
| | |
| | | |
| | | //#endregion |
| | | |
| | | #region 添加Install Codes码 |
| | | /////<summary > |
| | | /////添加Install Codes码 |
| | | ///// <para>installCode:InstallCode码 36个字符</para> |
| | | ///// <para>installCodeAddr:InstallCodes码设备的mac地址16个字符</para> |
| | | ///// </summary> |
| | | //public static async System.Threading.Tasks.Task<InstallCodeResponData> InstallCodeAsync(ZigBee.Device.ZbGateway gateway, string installCode, string installCodeAddr) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // var d = new InstallCodeResponData { }; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // 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 = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d.errorMessageBase = "网关错误回复,且数据是空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.errorResponData = temp; |
| | | // d.errorMessageBase = ErrorMess(temp.Error); |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/InstallCode_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // var code = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"].ToString()); |
| | | |
| | | // if (code == null) |
| | | // { |
| | | // d.errorMessageBase = "网关返回的数据为空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.Status = code; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // gateway.Actions += action; |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
|
| | | // gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jObject.ToString()))); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // //if (d.Status != 999) |
| | | // //{ |
| | | // // break; |
| | | // //} |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 1000) |
| | | // { |
| | | // d.errorMessageBase = " 回复超时,请重新操作"; |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 添加Install Codes码,网关反馈具体信息 |
| | | /// </summary> |
| | | public InstallCodeResponData installCodeResponData; |
| | | /// <summary> |
| | | /// 添加Install Codes码,网关反馈具体信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class InstallCodeResponData |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 0:成功,1:失败 |
| | | /// </summary> |
| | | public int Status = 999; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 启用或关闭透传数据上传接口 |
| | | /// <summary> |
| | | /// 透传数据上传接口,网关反馈信息 |
| | |
| | | public string passData; |
| | | } |
| | | #endregion |
| | | |
| | | //#region 协调器通用功能操作接口 |
| | | ///// <summary> |
| | | ///// 协调器通用功能操作接口 |
| | | ///// </summary> |
| | | ///// <returns>The or get all data async.</returns> |
| | | ///// <param name="gateway">Gateway.</param> |
| | | ///// <param name="commandID">Command identifier.</param> |
| | | ///// <param name="payload">Payload.</param> |
| | | //public static async System.Threading.Tasks.Task<SetOrGetAllData> SetOrGetAllDataAsync(ZigBee.Device.ZbGateway gateway, int commandID, string payload) |
| | | //{ |
| | | // if (gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // var d = new SetOrGetAllData { }; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); |
| | | |
| | | // if (topic == gatewayID + "/" + "Error_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d.errorMessageBase = "网关错误回复,且数据是空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.errorResponData = temp; |
| | | // d.errorMessageBase = ErrorMess(temp.Error); |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "ZbGw/SetOrGetData_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<SetOrGetData>(jobject["Data"].ToString()); |
| | | |
| | | // if (gatewayTemp.getGwVersion == null) |
| | | // { |
| | | // d.errorMessageBase = "网关返回的数据为空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.setOrGetData = temp; |
| | | // DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | // gateway.Actions += action; |
| | | // System.Console.WriteLine("ZbDataPassthrough_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 2 } }; |
| | | // var data = new JObject { { "Command_ID", commandID }, { "Payload", payload } }; |
| | | // jObject.Add("Data", data);
|
| | | // gateway.Send("ZbGw/SetOrGetData", Common.SecuritySet.Encryption(jObject.ToString())); |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d.setOrGetData != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000) |
| | | // { |
| | | // d.errorMessageBase = " 回复超时,请重新操作"; |
| | | // } |
| | | // gateway.Actions -= action; |
| | | // System.Console.WriteLine("GetGwVersionData_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// BDB接口,网关反馈信息 |
| | | ///// </summary> |
| | | //public SetOrGetAllData setOrGetAllData; |
| | | ///// <summary> |
| | | ///// BDB接口,网关反馈信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class SetOrGetAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// BDB数据 |
| | | // /// </summary> |
| | | // public SetOrGetData setOrGetData; |
| | | |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// BDB数据 |
| | | ///// </summary> |
| | | //public SetOrGetData setOrGetData; |
| | | ///// <summary> |
| | | ///// BDB数据 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class SetOrGetData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 协调器指令的command_ID。对应《协调器串口通信协议规范》第2章节指令的command_ID |
| | | // /// </summary> |
| | | // public int commandID; |
| | | // /// <summary> |
| | | // /// 已经转换成字符格式的16进制的data数据。对应《协调器串口通信协议规范》第2章节指令的“数据”内容 |
| | | // /// </summary> |
| | | // public string payload; |
| | | //} |
| | | //#endregion |
| | | |
| | | #region 客户端发送文件流到网关 |
| | | /// <summary> |