HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-05-15 3f87bf0ae7394cdd7d52428f1f6b4361434c7cc4
ZigbeeApp/Shared/Common/Device.cs
@@ -1954,26 +1954,10 @@
        /// <param name="saveRoadDevice">如果只有一个回路,是否把回路的房间一起修改</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
        {
            if (listDevice != null)
            if (listDevice == null)
            {
                if (roomId == string.Empty)
                {
                    //选择的是未分配
                    this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
                }
                else
                {
                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                }
                return;
            }
            //保存记录
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
            {
@@ -1983,6 +1967,31 @@
                    return;
                }
                HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
            }
            bool save = false;
            if (roomId == string.Empty)
            {
                //选择的是未分配
                this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
                save = true;
            }
            else
            {
                if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false)
                {
                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                    save = true;
                }
            }
            if (save == true)
            {
                //保存记录
                string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
                UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            }
        }
@@ -2149,26 +2158,15 @@
                listDevice = this.GetDeviceByGatewayID(gwId);
            }
            var dicDevice = new Dictionary<string, CommonDevice>();
            var listCheck = new HashSet<string>();
            var listReturn = new List<CommonDevice>();
            foreach (var device in listDevice)
            {
                if (dicDevice.ContainsKey(device.DeviceAddr) == false)
                if (listCheck.Contains(device.DeviceAddr) == false)
                {
                    dicDevice[device.DeviceAddr] = device;
                    continue;
                    listCheck.Add(device.DeviceAddr);
                    listReturn.Add(device);
                }
                //设备是否处于在线状态
                bool online = this.CheckDeviceIsOnline(device);
                if (online == true)
                {
                    //如果设备回路在线,则优先使用在线的回路,后来的直接覆盖
                    dicDevice[device.DeviceAddr] = device;
                }
            }
            var listReturn = new List<CommonDevice>();
            foreach (var device in dicDevice.Values)
            {
                listReturn.Add(device);
            }
            return listReturn;
        }
@@ -2184,8 +2182,18 @@
        /// <returns></returns>
        public bool CheckDeviceIsOnline(CommonDevice i_device)
        {
            //0:离线 1:在线 2:正在刷新状态
            return i_device.IsOnline == 1 || i_device.IsOnline == 2;
            var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
            foreach (var device in listDevice)
            {
                //0:离线 1:在线 2:正在刷新状态
                bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2;
                if (statu == true)
                {
                    //有一个回路在线,即在线
                    return true;
                }
            }
            return false;
        }
        /// <summary>
@@ -2415,8 +2423,14 @@
                                if (listCheck.Contains(mainkeys) == false)
                                {
                                    listDevice.Add(device);
                                    listCheck.Add(mainkeys);
                                    //刷新一下本地缓存
                                    var localDevice = this.GetDevice(mainkeys);
                                    if (localDevice != null)
                                    {
                                        //刷新属性
                                        this.SetDeviceInfoToMain(localDevice, device);
                                    }
                                }
                            }
                        }
@@ -2596,8 +2610,9 @@
            //如果是三路继电器的回路的话,默认为灯光
            else if (mainDevice.Type == DeviceType.OnOffOutput)
            {
                var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
                if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
                //2020.05.13变更:继电器都默认为灯光
                //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
                //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
                {
                    if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                    {