| | |
| | | #region ■ 添加设备___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 将指定网关的设备存入缓存中(从新获取镜像)
|
| | | /// <para>将指定网关的设备存入缓存中(从新获取镜像)</para>
|
| | | /// <para>-1:异常 1:正常 2:设备信息缺损</para>
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="deviceComingAction">接收到设备时的事件,设备对象为null时,代表接收完成</param>
|
| | | /// <returns>一直返回true</returns>
|
| | | public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
|
| | | public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
|
| | | {
|
| | | //从网关获取全部的设备
|
| | | int statu = 0;
|
| | | List<CommonDevice> listDevice = new List<CommonDevice>();
|
| | | List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
|
| | |
|
| | | List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
|
| | | if (list == null)
|
| | | {
|
| | | return false;
|
| | | return -1;
|
| | | }
|
| | | listDevice.AddRange(list);
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //如果本地和网关的设备不一致的时候,暂时删除本地的设备
|
| | | //注意:只是删除设备文件,房间内容什么的还存在着
|
| | | //只有完全获取的时候,才会去处理删除的问题
|
| | | if (statu == 1)
|
| | | {
|
| | | //如果本地和网关的设备不一致的时候,删除本地的设备
|
| | | foreach (var device in dicExist.Values)
|
| | | {
|
| | | this.DeleteMemmoryDevice(device, false);
|
| | | this.DeleteMemmoryDevice(device, true);
|
| | | }
|
| | | }
|
| | |
|
| | | return true;
|
| | | return statu;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | //不存在则使用共通图片
|
| | | string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None);
|
| | | if (arry.Length == 1)
|
| | | {
|
| | | //如果它自己就是共通图片的话,不再处理
|
| | | return;
|
| | | }
|
| | | if (arry.Length > 1)
|
| | | {
|
| | | imageFilePath = "Device/" + arry[0] + ".png";
|
| | | imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
|
| | | }
|
| | | }
|
| | | //如果那款设备连共通图片都没有的话
|
| | | if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
|
| | | {
|
| | | imageFilePath = "Device/ThirdPartyDevice.png";
|
| | | imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png";
|
| | | }
|
| | | //设置图片
|
| | | unSelectPath = imageFilePath;
|
| | |
| | | #region ■ 获取设备列表的接口_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 从网关重新获取设备列表(★★★★★★★接收到设备时的事件★★★★★★★)
|
| | | /// <para>从网关重新获取设备列表(返回的设备为虚拟出来的)</para>
|
| | | /// <para>statu状态 -1:异常,会返回null, 1:没有异常, 2:数据接收不全</para>
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="ignoreTime">是否无视时间,true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
|
| | | /// <param name="deviceComingAction">接收到设备时的事件</param>
|
| | | /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
|
| | | /// <param name="ignoreTime">是否无视时间(此变量是给获取在线状态用的),true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | /// <returns></returns> |
| | | public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES) |
| | | public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES) |
| | | {
|
| | | if (ignoreTime == false)
|
| | | {
|
| | | if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
|
| | | {
|
| | | //不无视时间,返回本地设备列表
|
| | | var listTemp = this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
|
| | | if (deviceComingAction != null)
|
| | | {
|
| | | for (int i = 0; i < listTemp.Count; i++)
|
| | | {
|
| | | try
|
| | | {
|
| | | //回调函数
|
| | | deviceComingAction.Invoke(listTemp[i]);
|
| | | }
|
| | | //Log出力
|
| | | catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
|
| | | }
|
| | | }
|
| | | deviceComingAction = null;
|
| | | return listTemp;
|
| | | statu = 1;
|
| | | return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
|
| | | }
|
| | | }
|
| | | zbGateway.LastDateTime = DateTime.Now;
|
| | |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | statu = -1;
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | //网关里面有可能会有重复的回路
|
| | | if (listCheck.Contains(mainkeys) == false)
|
| | | {
|
| | | //回调函数
|
| | | deviceComingAction?.Invoke(device);
|
| | | listDevice.Add(device);
|
| | |
|
| | | listCheck.Add(mainkeys);
|
| | |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时", false);
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | statu = -1;
|
| | | return null;
|
| | | }
|
| | | else
|
| | |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | statu = 2;
|
| | | }
|
| | | }
|
| | |
|
| | | //回调函数(接收完成) |
| | | deviceComingAction = null; |
| | | |
| | | return listDevice; |
| | | }
|
| | |
|
| | |
| | | this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200";//2按键触摸面板
|
| | | this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200";//12按键触摸面板
|
| | | this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200";//4按键触摸面板(只带电源底座)
|
| | | this.dicDeviceModelIdEnum["MPT4R4L/S-ZB1.8"] = "220-200";//简约4按键面板
|
| | | this.dicDeviceModelIdEnum["MPT3R3L/S-ZB1.8"] = "221-200";//简约3按键面板
|
| | | this.dicDeviceModelIdEnum["MPT2R2L/S-ZB1.8"] = "222-200";//简约2按键面板
|
| | | this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//简约4按键面板
|
| | | this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//简约3按键面板
|
| | | this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//简约2按键面板
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir传感器220
|
| | |
| | | this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200";//zigbee转buspro协议转换器
|
| | | this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200";//zigbee转485协议转换器
|
| | |
|
| | |
|
| | |
|
| | | //✩✩✩✩✩需要交换的模块ID✩✩✩✩✩
|
| | | this.dicDeviceModelIdChanged = new Dictionary<string, string>();
|
| | | //=========★★安防类传感器类★★=========
|
| | |
| | | this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//水浸传感器
|
| | | this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//紧急按键
|
| | |
|
| | |
|
| | |
|
| | | //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
|
| | | this.dicPictrueShard = new Dictionary<string, string>();
|
| | | this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//简约4按键面板 沿用 4按键的图标
|