| | |
| | |
|
| | | if (device == null || device.CurrentGateWayId == null)
|
| | | {
|
| | | #if DEBUG
|
| | | //调查,为什么它会把全部设备删掉?
|
| | | string file1 = UserCenterLogic.CombinePath(file);
|
| | | string file2 = UserCenterLogic.CombinePath("Back_" + file);
|
| | | System.IO.File.Copy(file1, file2, true);
|
| | | #endif
|
| | | //失效的文件,没有网关id的都删除掉
|
| | | Global.DeleteFilebyHomeId(file);
|
| | | continue;
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | #if DEBUG
|
| | | //调查,为什么它会把全部设备删掉?
|
| | | string file1 = UserCenterLogic.CombinePath(file);
|
| | | string file2 = UserCenterLogic.CombinePath("Back_" + file);
|
| | | System.IO.File.Copy(file1, file2, true);
|
| | | #endif
|
| | | //如果是主人,或者管理员,那么这个文件是非法的,直接删除
|
| | | Global.DeleteFilebyHomeId(file);
|
| | | continue;
|
| | |
| | | var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
|
| | | foreach (var gateway in listGateway)
|
| | | {
|
| | | string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway);
|
| | | string gwId = gateway.GwId;
|
| | | if (listId.Contains(gwId) == false)
|
| | | {
|
| | | //这个网关对于当前这个成员来说是非法的
|
| | |
| | | listDevice.AddRange(list);
|
| | |
|
| | | //获取这个网关的本地所有设备
|
| | | string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
|
| | | string gwID = zbGateway.GwId;
|
| | | List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
|
| | | //获取ota设备
|
| | | foreach (var ota in this.dicOTADevice.Values)
|
| | |
| | | /// <param name="listdevice">设备对象(MAC地址必须要相同)</param>
|
| | | public async Task<bool> DeleteDevice(List<CommonDevice> listdevice)
|
| | | {
|
| | | var data = new CommonDevice.RemoveDeviceData();
|
| | | var info = new CommonDevice.RemoveDeviceListInfo();
|
| | | info.DeviceAddr = listdevice[0].DeviceAddr;
|
| | | data.DeviceAddrList.Add(info);
|
| | |
|
| | | //删一次的时候,它会把MAC地址下面全部的设备都删除
|
| | | var result = await listdevice[0].DeleteDeviceAsync(data);
|
| | | if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
|
| | | //虚拟住宅的话,不需要删除网关的设备
|
| | | if (Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | //设备删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | | var data = new CommonDevice.RemoveDeviceData();
|
| | | var info = new CommonDevice.RemoveDeviceListInfo();
|
| | | info.DeviceAddr = listdevice[0].DeviceAddr;
|
| | | data.DeviceAddrList.Add(info);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | //删一次的时候,它会把MAC地址下面全部的设备都删除
|
| | | var result = await listdevice[0].DeleteDeviceAsync(data);
|
| | | if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
|
| | | {
|
| | | //设备删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //删除缓存的Ota设备
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取简约面板全部回路的设备对象
|
| | | /// </summary>
|
| | | /// <param name="listDevice"></param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
|
| | | {
|
| | | //和彪哥、设备和产品部同事确认:
|
| | | //简约多功能面板[不显示多余的回路,只显示携带的2个继电器和1个温湿度传感器
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (var dev in listDevice)
|
| | | {
|
| | | if (dev.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | if (dev.DeviceEpoint == 64)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | }
|
| | | else if (dev.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | }
|
| | |
|
| | | if (sort == false)
|
| | | {
|
| | | return list;
|
| | | }
|
| | | list.Sort((obj1, obj2) =>
|
| | | {
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | });
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr">Mac地址</param>
|
| | |
| | | {
|
| | | return dName;
|
| | | }
|
| | | if (this.IsMiniLight(device) == true)
|
| | | {
|
| | | //Mini夜灯
|
| | | return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
|
| | | }
|
| | |
|
| | | //如果这个设备只有一个回路的话,返回Mac名字给它
|
| | | if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | if (device.Type == DeviceType.OnOffOutput
|
| | | || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight)
|
| | | || device.Type == DeviceType.DimmableLight |
| | | || device.Type == DeviceType.ColorDimmableLight
|
| | | || device.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | //继电器,掉光器都叫回路
|
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo;
|
| | |
| | | if (string.IsNullOrEmpty(dName) == false)
|
| | | {
|
| | | return dName;
|
| | | }
|
| | | if (this.IsMiniLight(device) == true)
|
| | | {
|
| | | //Mini夜灯
|
| | | return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
|
| | | }
|
| | |
|
| | | //获取设备类型
|
| | |
| | | info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
|
| | | info.ObjectTypeNameId = 60000;//传感器
|
| | | }
|
| | | //16色温灯
|
| | | else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000;
|
| | | info.BeloneType = DeviceBeloneType.A彩灯;
|
| | | info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
|
| | | info.ObjectTypeNameId = 60007;//调光模块
|
| | | }
|
| | |
|
| | | int value = (int)info.BeloneType;
|
| | | if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
|
| | |
| | | {
|
| | | //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
|
| | | if (room == null)
|
| | | if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId)
|
| | | {
|
| | | this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
|
| | | save = true;
|
| | |
| | | if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch)
|
| | | {
|
| | | //2020.03.23追加式样:未指定类型的继电器,不显示
|
| | | if (i_device.DfunctionType == DeviceFunctionType.A未定义)
|
| | | if (i_device.DfunctionType == DeviceFunctionType.A未定义
|
| | | || i_device.DfunctionType == DeviceFunctionType.A不指定)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | | else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | //新风的湿度传感器不显示
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | public bool IsHdlDevice(CommonDevice device)
|
| | | {
|
| | | return device.ManufacturerName == "HDL";
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 是否是Mini夜灯
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool IsMiniLight(CommonDevice device)
|
| | | {
|
| | | return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public string AppendVersion(int versionValue)
|
| | | {
|
| | | //10101 3个byte 显示为:ver.1.01.01
|
| | | //中间那个byte为奇数时,代表是测试版本,在显示最新版本时,不需要显示,但是在历史版本那里可以显示
|
| | | //中间那个byte为偶数时, 代表是正式版本
|
| | |
|
| | | //直接是10进制
|
| | | string txt10 = Convert.ToString(versionValue).PadLeft(4, '0');
|
| | | //这个是小数点前面的值
|
| | | int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2));
|
| | | //这个是小数点后面的值
|
| | | int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2));
|
| | | string txt10 = Convert.ToString(versionValue).PadLeft(6, '0');
|
| | | //这个是第一位
|
| | | int value1 = Convert.ToInt32(txt10.Substring(0, 2));
|
| | | //这个是第二位
|
| | | string value2 = txt10.Substring(2, 2);
|
| | | //这个是第三位
|
| | | string value3 = txt10.Substring(4, 2);
|
| | |
|
| | | //Ver.
|
| | | string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
|
| | | return ver + value1 + "." + value2.ToString().PadLeft(2, '0');
|
| | | return ver + value1 + "." + value2 + "." + value3;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | //不无视时间,返回本地设备列表
|
| | | statu = 1;
|
| | | return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
|
| | | return this.GetDeviceByGatewayID(zbGateway.GwId);
|
| | | }
|
| | | }
|
| | | zbGateway.LastDateTime = DateTime.Now;
|
| | |
| | | //是否达成中断的时机
|
| | | bool canBreak = false;
|
| | | //网关ID
|
| | | string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
|
| | | string gatewayID = zbGateway.GwId;
|
| | | //超时时间
|
| | | int TimeOut = 0;
|
| | | //设备总数
|
| | |
| | | /// <returns></returns>
|
| | | private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway)
|
| | | {
|
| | | string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
|
| | | string gwId = zbGateway.GwId;
|
| | |
|
| | | //根据设备类型创建设备对象的实例
|
| | | CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType);
|
| | |
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | | //如果是色温灯
|
| | | else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLightTemperature.png";
|
| | | }
|
| | | }
|
| | | //如果是三路继电器的回路的话,默认为灯光
|
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | |
| | | else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
|
| | | else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
|
| | | else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
|
| | | else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); }
|
| | | else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); }
|
| | | else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
|
| | | else { return null; }
|
| | |
|
| | |
| | | this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//方悦新风面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//方悦环境面板
|
| | | this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//窗帘面板
|
| | | this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//简约多功能面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//简约环境面板
|
| | |
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
|
| | |
| | | this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//红外传感器
|
| | | this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//水浸传感器
|
| | | this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键
|
| | | this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
|
| | | this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
|
| | |
|
| | | //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
|
| | | this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5空气质量传感器 |
| | | this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5空气质量传感器 |
| | |
|
| | | //=========★★继电器类(2300-2499)★★=========
|
| | | this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块
|
| | |
| | | /// 窗帘面板 镜像id:256
|
| | | /// </summary>
|
| | | ButtonPanel_Curtain = 256,
|
| | | /// <summary>
|
| | | /// 简约多功能面板 镜像ID:212
|
| | | /// </summary>
|
| | | ButtonPanel_SimpleMultifunction = 212,
|
| | | /// <summary>
|
| | | /// 简约环境面板
|
| | | /// </summary>
|
| | | ButtonPanel_SimpleEnvironment = 230,
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | /// <summary>
|
| | |
| | | /// 彩灯
|
| | | /// </summary>
|
| | | ColorLight = -10,
|
| | | /// <summary>
|
| | | /// 色温灯(它的镜像ID未定,暂定20000)
|
| | | /// </summary>
|
| | | ColorLight_Temperature = 20000,
|
| | |
|
| | | //=========★★空调(3600-3899)★★=========
|
| | | /// <summary>
|