| | |
| | | {
|
| | | lock (dicAllDevice)
|
| | | {
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (var device in dicAllDevice.Values)
|
| | | //先获取全部的Mac
|
| | | var listMac = new List<string>();
|
| | | foreach (var strMac in this.dicDeviceEpoint.Keys)
|
| | | {
|
| | | list.Add(device);
|
| | | listMac.Add(strMac);
|
| | | }
|
| | | return list;
|
| | | //根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | return this.GetDevicesByMac(listMac);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | //获取这个网关的本地所有设备
|
| | | string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
|
| | | List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID, true);
|
| | | List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
|
| | | //获取ota设备
|
| | | foreach (var ota in this.dicOTADevice.Values)
|
| | | {
|
| | | if (ota.CurrentGateWayId == gwID)
|
| | | {
|
| | | listLocalDevices.Add(ota);
|
| | | }
|
| | | }
|
| | |
|
| | | Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
|
| | | foreach (var device in listLocalDevices)
|
| | | {
|
| | |
| | | /// <param name="deleteRoom">是否从房间删除</param>
|
| | | public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
|
| | | {
|
| | | if (deleteRoom == true && Room.CurrentRoom != null)
|
| | | if (deleteRoom == true && HdlRoomLogic.Current.CurrentRoom != null)
|
| | | {
|
| | | //从房间中删除
|
| | | Room.CurrentRoom.DeleteDevice(device);
|
| | | HdlRoomLogic.Current.DeleteDevice(device);
|
| | | //删除我的喜爱的设备
|
| | | Room.CurrentRoom.DeleteLoveDevice(device);
|
| | | HdlRoomLogic.Current.DeleteLoveDevice(device);
|
| | | }
|
| | |
|
| | | //删除缓存
|
| | |
| | | /// <summary>
|
| | | /// 根据网关ID获取所有的设备
|
| | | /// </summary>
|
| | | /// <param name="gwId">网关ID</param>
|
| | | /// <param name="getOtaDevice">是否获取ota设备</param>
|
| | | /// <param name="gwId">网关ID</param>>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetDeviceByGatewayID(string gwId, bool getOtaDevice = false)
|
| | | public List<CommonDevice> GetDeviceByGatewayID(string gwId)
|
| | | {
|
| | | List<CommonDevice> list = new List<CommonDevice>();
|
| | | lock (dicAllDevice)
|
| | | {
|
| | | //各网关的所有设备
|
| | | var listMac = new List<string>();
|
| | | //各网关的所有设备的Mac
|
| | | foreach (CommonDevice device in this.dicAllDevice.Values)
|
| | | {
|
| | | if (gwId == device.CurrentGateWayId)
|
| | | {
|
| | | list.Add(device);
|
| | | listMac.Add(device.DeviceAddr);
|
| | | }
|
| | | }
|
| | | if (getOtaDevice == true)
|
| | | {
|
| | | //获取ota设备
|
| | | foreach (var ota in this.dicOTADevice.Values)
|
| | | {
|
| | | if (ota.CurrentGateWayId == gwId)
|
| | | {
|
| | | list.Add(ota);
|
| | | return this.GetDevicesByMac(listMac);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | | return -1;
|
| | | });
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr">Mac地址</param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr)
|
| | | {
|
| | | //先排序
|
| | | listMacAddr.Sort();
|
| | |
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (string strMac in listMacAddr)
|
| | | {
|
| | | var listEpoint = new List<int>();
|
| | | //获取全部的端点
|
| | | foreach (int epoint in this.dicDeviceEpoint[strMac])
|
| | | {
|
| | | listEpoint.Add(epoint);
|
| | | }
|
| | | //然后排序
|
| | | listEpoint.Sort();
|
| | | foreach (int epoint in listEpoint)
|
| | | {
|
| | | var device = this.GetDevice(strMac, epoint);
|
| | | if (device != null)
|
| | | {
|
| | | list.Add(device);
|
| | | }
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备UI相关_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备所匹配的设备UI对象
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public DeviceUI GetDeviceUI(CommonDevice device)
|
| | | {
|
| | | //创建一个新的东西给过去
|
| | | var deviceUi = new DeviceUI();
|
| | | deviceUi.DeviceAddr = device.DeviceAddr;
|
| | | deviceUi.DeviceEpoint = device.DeviceEpoint;
|
| | | return deviceUi;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备所匹配的设备UI对象
|
| | | /// </summary>
|
| | | /// <param name="filePath"></param>
|
| | | /// <returns></returns>
|
| | | public DeviceUI GetDeviceUI(string filePath)
|
| | | {
|
| | | string[] arry = filePath.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (arry.Length != 4)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | //创建一个新的东西给过去
|
| | | var deviceUi = new DeviceUI();
|
| | | deviceUi.DeviceAddr = arry[2];
|
| | | deviceUi.DeviceEpoint = Convert.ToInt32(arry[3]);
|
| | | return deviceUi;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取自定义的设备类型_______________
|
| | |
|
| | | /// <summary>
|
| | |
| | | return info;
|
| | | }
|
| | | //获取第三方设备的【设备类型】
|
| | | return this.GetNotHdlMyDeviceEnumInfo(listdevice);
|
| | | info = this.GetNotHdlMyDeviceEnumInfo(listdevice);
|
| | | //这里再次判断是否是河东设备,有可能它的模块ID写错了
|
| | | info.IsHdlDevice = this.IsHdlDevice(checkDevice);
|
| | |
|
| | | return info;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | //单纯只是Ota设备则不处理
|
| | | return;
|
| | | }
|
| | | Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false);
|
| | | HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //未分配区域
|
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | var room = Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | if (room != null)
|
| | | {
|
| | | return room.Name;
|
| | |
| | | {
|
| | | return null;
|
| | | }
|
| | | return Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <returns></returns>
|
| | | public string GetDeviceMainKeys(CommonDevice device)
|
| | | {
|
| | | return device.DeviceAddr + device.DeviceEpoint;
|
| | | return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint)
|
| | | {
|
| | | return DeviceAddr + DeviceEpoint;
|
| | | return DeviceAddr + "_" + DeviceEpoint;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | statu = 2;
|
| | | }
|
| | | } |
| | | |
| | | statu = 1; |
| | | return listDevice; |
| | | }
|
| | |
|
| | |
| | | //*********************************************************************
|
| | | //新设备添加方法:
|
| | | //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType
|
| | | //2、然后在最下面添加【设备的具体类型】,【设备的所属类型】
|
| | | //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
|
| | | //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
|
| | | //4、添加R文件,添加Language文件
|
| | | //5、如果需要共有图片,则在这个函数的最底下添加
|
| | | //*********************************************************************
|
| | |
|
| | | //=========★★开合帘类(100-199)★★=========
|
| | |
| | | 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按键面板
|
| | | this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200";//简约4按键场景面板
|
| | | this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200";//简约2路窗帘面板
|
| | | this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200";//方悦2按键轻触式面板
|
| | | this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200";//方悦4按键轻触式面板
|
| | | this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200";//方悦8按键轻触式面板
|
| | |
| | |
|
| | |
|
| | | //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
|
| | | //两者都是DeviceConcreteType
|
| | | //Keys:指定的设备 value:沿用的图片是哪款设备的
|
| | | this.dicPictrueShard = new Dictionary<string, string>();
|
| | | this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//简约4按键面板 沿用 4按键的图标
|
| | | this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//简约3按键面板 沿用 3按键的图标
|
| | |
| | | /// </summary>
|
| | | ButtonPanel_SimpleTwo = 222,
|
| | | /// <summary>
|
| | | /// 简约4按键场景面板 镜像id:224
|
| | | /// </summary>
|
| | | ButtonPanel_FourButtonScene = 224,
|
| | | /// <summary>
|
| | | /// 简约2路窗帘面板 镜像id:226
|
| | | /// </summary>
|
| | | ButtonPanel_TwoButtonCurtain = 226,
|
| | | /// <summary>
|
| | | /// 方悦2按键轻触式面板 镜像id:240
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueTwo = 240,
|