| | |
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //修改设备名字的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | //修改设备名字的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
|
| | | {
|
| | | //删除缓存设备的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | if (deleteRoom == true)
|
| | | {
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 同步设备___________________________
|
| | | /// <summary>
|
| | | /// 同步设备并且刷新缓存(同步失败时,会显示信息)
|
| | | /// </summary>
|
| | | /// <param name="litdevice">设备对象(MAC地址必须要相同)</param>
|
| | | public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice)
|
| | | {
|
| | | //虚拟住宅的话,不需要删除网关的设备
|
| | | if (Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | //同步
|
| | | var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint);
|
| | | if (result == null || result.result != 0)
|
| | | {
|
| | | //同步删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | | #region ■ 测试设备___________________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | //传感器除了Pir都没有定位功能
|
| | | return true;
|
| | | }
|
| | | else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion)
|
| | | {
|
| | | //球型移动传感器虽然是电池设备,但是它有定位功能
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 检测设备是否拥有一键同步功能
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool DeviceIsCanSynchronization(CommonDevice device)
|
| | | {
|
| | | //获取设备类型的
|
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | | if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
| | | if (sort == false)
|
| | | {
|
| | | return list;
|
| | | } |
| | | list.Sort((obj1, obj2) => {
|
| | | }
|
| | | list.Sort((obj1, obj2) =>
|
| | | {
|
| | |
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint)
|
| | | {
|
| | |
| | | public List<string> GetAllDeviceFile()
|
| | | {
|
| | | List<string> listDeviceFile = new List<string>();
|
| | | List<string> listAllFile = Global.FileListByHomeId(); |
| | | List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile(); |
| | | |
| | | foreach (string file in listAllFile)
|
| | | {
|
| | |
| | | private void InitRealDeviceRoomId()
|
| | | {
|
| | | this.dicDeviceRoomId = new Dictionary<string, string>();
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | string fullName = DirNameResourse.DeviceRoomIdFile;
|
| | | var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
|
| | | if (strData != null)
|
| | | {
|
| | | this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取全部物理设备所属房间的记录
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public Dictionary<string, string> GetAllRealDeviceRoomData()
|
| | | {
|
| | | return this.dicDeviceRoomId;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (save == true)
|
| | | {
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | return HdlRoomLogic.Current.GetFloorRoomName(room);
|
| | | return HdlRoomLogic.Current.GetRoomName(room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return;
|
| | | }
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | | //如果是新风面板的新风设备,则不显示
|
| | | else if (i_device.Type == DeviceType.FreshAir)
|
| | | {
|
| | | var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | if (myInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //2020.03.30追加式样:如果是面板的温度探头,不显示
|
| | | else if (i_device.Type == DeviceType.TemperatureSensor && ((TemperatureSensor)i_device).SensorDiv == 1)
|
| | | {
|
| | |
| | | {
|
| | | //新风的湿度传感器不显示
|
| | | return false;
|
| | | }
|
| | |
|
| | | //如果是新风面板或环境面板,则都不显示任何回路
|
| | | var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | if (i_device.Type != DeviceType.OnOffOutput)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //2020.05.13变更:继电器都默认为灯光
|
| | | //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
|
| | | //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是空气开关的话
|
| | | else if (mainDevice.Type == DeviceType.AirSwitch)
|
| | |
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Switch.png";
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是彩灯的话
|
| | | else if (mainDevice.Type == DeviceType.ColorDimmableLight)
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据功能类型,重新设置设备回路图标
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ResetIconPathByDeviceFunctionType(CommonDevice device)
|
| | | {
|
| | | if (device.IsCustomizeImage == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据设备Type创建对应的设备对象
|
| | | /// </summary>
|
| | | /// <param name="deviceType">设备Type</param>
|