| | |
| | | /// </summary>
|
| | | private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
|
| | | /// <summary>
|
| | | /// 设备Mac顺序
|
| | | /// 设备Mac顺序(里面是Mac地址)
|
| | | /// </summary>
|
| | | private Dictionary<string, List<string>> dicDeviceSort = null;
|
| | | /// <summary>
|
| | |
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="deviceComingAction">接收到设备时的事件,设备对象为null时,代表接收完成</param>
|
| | | /// <returns>一直返回true</returns>
|
| | | public async Task<bool> SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
|
| | | public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
|
| | | {
|
| | | //从网关获取全部的设备
|
| | | List<CommonDevice> listDevice = new List<CommonDevice>();
|
| | | List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
|
| | | List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
|
| | |
|
| | | if (list == null)
|
| | | {
|
| | |
| | | this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
|
| | |
|
| | | btnIcon.UnSelectedImagePath = unSelectFilePath;
|
| | | btnIcon.SelectedImagePath = selectFilePath;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public List<CommonDevice> SortDevice(List<CommonDevice> listDevice)
|
| | | {
|
| | | var dic = new Dictionary<string, CommonDevice>();
|
| | | var dic = new Dictionary<string, List<CommonDevice>>();
|
| | | for (int i = 0; i < listDevice.Count; i++)
|
| | | {
|
| | | dic[(this.GetDeviceMainKeys(listDevice[i]))] = listDevice[i];
|
| | | if (dic.ContainsKey(listDevice[i].DeviceAddr) == false)
|
| | | {
|
| | | dic[listDevice[i].DeviceAddr] = new List<CommonDevice>();
|
| | | }
|
| | | dic[listDevice[i].DeviceAddr].Add(listDevice[i]);
|
| | | }
|
| | | var list = new List<CommonDevice>();
|
| | | var listCheck = new HashSet<string>();
|
| | | foreach (var listSort in this.dicDeviceSort.Values)
|
| | | {
|
| | | for (int i = 0; i < listSort.Count; i++)
|
| | | {
|
| | | if (dic.ContainsKey(listSort[i]) == true)
|
| | | if (dic.ContainsKey(listSort[i]) == true && listCheck.Contains(listSort[i]) == false)
|
| | | {
|
| | | list.Add(dic[listSort[i]]);
|
| | | listCheck.Add(listSort[i]);
|
| | | dic[listSort[i]].Sort((obj1, obj2) =>
|
| | | {
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | });
|
| | | list.AddRange(dic[listSort[i]]);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | /// <param name="deviceComingAction">接收到设备时的事件</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | /// <returns></returns> |
| | | public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES) |
| | | public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES) |
| | | {
|
| | | if (ignoreTime == false)
|
| | | {
|
| | |
| | | try
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
|
| | | await realWay.Send("GetDeviceInfo", jObject.ToString());
|
| | | realWay.Send("GetDeviceInfo", jObject.ToString());
|
| | | }
|
| | | catch { canBreak = true; }
|
| | |
|
| | | while (canBreak == false && TimeOut < 60)
|
| | | {
|
| | | await Task.Delay(100);
|
| | | System.Threading.Thread.Sleep(100);
|
| | | TimeOut++;
|
| | | }
|
| | |
|
| | |
| | | this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//智能门锁(H06C)
|
| | |
|
| | | //=========★★空调类(3600-3899)★★=========
|
| | | this.dicDeviceModelIdEnum["MAC/GW-ZB.431"] = "3600-3600";//zigbee空调网关模块
|
| | | this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee空调网关模块
|
| | |
|
| | | //=========★★中继器类(3900-3999)★★=========
|
| | | this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900"; //zigbee中继器
|