| | |
| | | { |
| | | get |
| | | { |
| | | if(_FunctionList == null) |
| | | if (_FunctionList == null) |
| | | { |
| | | _FunctionList = new FunctionList(); |
| | | #region 恢复数据 |
| | |
| | | /// </summary> |
| | | public List<Function> Functions = new List<Function>(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 空调列表 |
| | | /// </summary> |
| | | public List<AC> aCs = new List<AC>(); |
| | | /// <returns></returns> |
| | | public List<Function> GetAcList() |
| | | { |
| | | var spkList = SPK.AcSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 灯光列表 |
| | | /// </summary> |
| | | public List<Light> lights = new List<Light>(); |
| | | public List<Function> GetLightList() |
| | | { |
| | | var spkList = SPK.LightSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | /// <summary> |
| | | /// 窗帘列表 |
| | | /// </summary> |
| | | public List<Curtain> curtains = new List<Curtain>(); |
| | | public List<Function> GetCurtainList() |
| | | { |
| | | var spkList = SPK.CurtainSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 地热列表 |
| | | /// </summary> |
| | | public List<FloorHeating> floorHeatings = new List<FloorHeating>(); |
| | | public List<Function> GetFloorHeatingList() |
| | | { |
| | | var spkList = SPK.FhSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 新风列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Function> GetAirFreshList() |
| | | { |
| | | var spkList = SPK.AirFreshSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能源列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Function> GetEnergyList() |
| | | { |
| | | var spkList = SPK.EnergySpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | #region 家电列表 electricals |
| | | /// <summary> |
| | | /// 家电列表 |
| | | /// </summary> |
| | | public List<Function> electricals |
| | | public List<Function> GetElectricals() |
| | | { |
| | | get |
| | | { |
| | | if(fans == null) |
| | | { |
| | | fans = new List<Fan>(); |
| | | } |
| | | if(switchSockets == null) |
| | | { |
| | | switchSockets = new List<SwitchSocket>(); |
| | | } |
| | | if(tVs == null) |
| | | { |
| | | tVs = new List<TV>(); |
| | | } |
| | | if (airCleaners == null)
|
| | | {
|
| | | airCleaners = new List<AirCleaner>();
|
| | | }
|
| | | if (weepRobots == null)
|
| | | {
|
| | | weepRobots = new List<WeepRobot>();
|
| | | } |
| | | if(waterValveList == null) |
| | | { |
| | | waterValveList = new List<Function>(); |
| | | } |
| | | if(clothesHangerList == null) |
| | | { |
| | | clothesHangerList = new List<Function>(); |
| | | } |
| | | var list = new List<Function>(); |
| | | list.AddRange(fans); |
| | | list.AddRange(switchSockets); |
| | | list.AddRange(tVs);
|
| | | list.AddRange(airCleaners);
|
| | | list.AddRange(weepRobots); |
| | | list.AddRange(waterValveList); |
| | | list.AddRange(clothesHangerList); |
| | | return list; |
| | | } |
| | | var spkList = SPK.ElectricalSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | /// <summary> |
| | | /// 风扇列表 |
| | | /// </summary> |
| | | public List<Fan> fans = new List<Fan>(); |
| | | /// <summary> |
| | | /// 电视列表 |
| | | /// </summary> |
| | | public List<TV> tVs = new List<TV>(); |
| | | /// <summary> |
| | | /// 家电列表 |
| | | /// </summary> |
| | | public List<SwitchSocket> switchSockets = new List<SwitchSocket>();
|
| | | /// <summary> |
| | | /// 空气净化器列表 |
| | | /// </summary> |
| | | public List<AirCleaner> airCleaners = new List<AirCleaner>();
|
| | | /// <summary> |
| | | /// 扫地机器人列表 |
| | | /// </summary> |
| | | public List<WeepRobot> weepRobots = new List<WeepRobot>(); |
| | | /// <summary> |
| | | /// 水阀列表 |
| | | /// </summary> |
| | | public List<Function> waterValveList = new List<Function>(); |
| | | /// <summary> |
| | | /// 凉霸列表 |
| | | /// </summary> |
| | | public List<Function> clothesHangerList = new List<Function>(); |
| | | |
| | | |
| | | /// <summary> |
| | | /// 红外宝列表 |
| | | /// </summary> |
| | | public List<Function> irModule = new List<Function>(); |
| | | |
| | | public List<Function> GetIrModuleList() |
| | | { |
| | | return Functions.FindAll((obj) => obj.spk == SPK.IrModule); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 音乐列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Function> GetMusicList() |
| | | { |
| | | var spkList = SPK.MusicSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 环境传感器列表 |
| | | /// </summary> |
| | | public List<Sensor> sensorsEnvironmentalScience = new List<Sensor>(); |
| | | public List<Function> GetEnvirSensorsList() |
| | | { |
| | | var spkList = SPK.EnvironSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | /// <summary> |
| | | /// 安防设备列表 |
| | | /// </summary> |
| | | public List<Sensor> sensorsArm = new List<Sensor>(); |
| | | public List<Function> GetArmSensorList() |
| | | { |
| | | var spkList = SPK.ArmSensorSpkList(); |
| | | return Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | |
| | | public List<Scene> scenes = new List<Scene>(); |
| | | /// <summary> |
| | | /// 功能列表 |
| | | /// 可视对讲列表,当为null或size为0则不显示可视对讲icon |
| | | /// </summary> |
| | | List<Function> deviceFunctionList = new List<Function>(); |
| | | // public UI.UI2.FuntionControlView.Video.VideoClouds videoIntercom; |
| | | public List<UI.UI2.FuntionControlView.Video.Video> videoIntercom = new List<UI.UI2.FuntionControlView.Video.Video>(); |
| | | |
| | | List<Function> _OtherBrandFunction; |
| | | /// <summary> |
| | | /// 第三方品牌功能 |
| | | /// </summary> |
| | | public List<Function> OtherBrandFunction |
| | | { |
| | | get |
| | | { |
| | | if(_OtherBrandFunction == null) |
| | | { |
| | | _OtherBrandFunction = new List<Function>(); |
| | | var spkList = SPK.GetAll3tySPK(); |
| | | _OtherBrandFunction = Functions.FindAll((obj) => spkList.Contains(obj.spk)); |
| | | } |
| | | return _OtherBrandFunction; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 场景列表 |
| | | /// </summary> |
| | | public List<Scene> scenes = new List<Scene>(); |
| | | |
| | | /// <summary> |
| | | /// 安防列表 |
| | | /// </summary> |
| | | public List<SecurityAlarm> securities = new List<SecurityAlarm>(); |
| | | |
| | | /// <summary> |
| | | /// 加载功能列表 |
| | | /// todo 需要优化,后期不能保证能使用sid解析出是什么类型的设备 |
| | | /// </summary> |
| | | /// <param name="filePath"></param> |
| | | public void IniFunctionList(string filePath) |
| | | /// <param name="checkRepeat"> |
| | | /// <para>考虑到性能问题追加此变量,是否检测重复,只对function有效</para> |
| | | /// <para>true:当重复存在时,替换掉</para> |
| | | /// <para>false:直接无条件添加</para></param> |
| | | public void IniFunctionList(string filePath, bool checkRepeat = false) |
| | | { |
| | | //MainPage.Log("12346890sdkxghjkl"); |
| | | // todo 增加设备,增加功能进功能列表 |
| | | if (filePath.StartsWith("FunctionData_")) |
| | | { |
| | | var functionDataBytes = Common.FileUtlis.Files.ReadFile(filePath); |
| | | var functionDataBytes = FileUtlis.Files.ReadFile(filePath); |
| | | var functionDataString = System.Text.Encoding.UTF8.GetString(functionDataBytes); |
| | | var tempFunction = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(functionDataString); |
| | | if (tempFunction == null) |
| | | { |
| | | MainPage.Log("null"); |
| | | FileUtlis.Files.DeleteFile(filePath); |
| | | return; |
| | | } |
| | | //音乐部分要修改 |
| | | //if(tempFunction.spk.ToString() == SPK.MusicStandard) |
| | | //{ |
| | | // UI.Music.A31MusicModel.A31MusicModelList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<UI.Music.A31MusicModel>(functionDataString)); |
| | | //} |
| | | if (checkRepeat == true) |
| | | { |
| | | switch (tempFunction.spk) |
| | | //检测重复 |
| | | for (int i = 0; i < Functions.Count; i++) |
| | | { |
| | | case SPK.LightSwitch: |
| | | case SPK.LightDimming: |
| | | case SPK.LightRGB: |
| | | case SPK.LightRGBW: |
| | | case SPK.LightCCT: |
| | | var light = Newtonsoft.Json.JsonConvert.DeserializeObject<Light>(functionDataString); |
| | | List.lights.Add(light); |
| | | deviceFunctionList.Add(light); |
| | | break; |
| | | case SPK.CurtainRoller: |
| | | case SPK.CurtainShades: |
| | | case SPK.CurtainSwitch: |
| | | case SPK.CurtainTrietex: |
| | | var curtain = Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(functionDataString); |
| | | List.curtains.Add(curtain); |
| | | deviceFunctionList.Add(curtain); |
| | | break; |
| | | case SPK.AcStandard: |
| | | var ac = Newtonsoft.Json.JsonConvert.DeserializeObject<AC>(functionDataString); |
| | | List.aCs.Add(ac); |
| | | deviceFunctionList.Add(ac); |
| | | break; |
| | | case SPK.FloorHeatStandard: |
| | | var fh = Newtonsoft.Json.JsonConvert.DeserializeObject<FloorHeating>(functionDataString); |
| | | List.floorHeatings.Add(fh); |
| | | deviceFunctionList.Add(fh); |
| | | break; |
| | | case SPK.SensorPm25: |
| | | case SPK.SensorCO2: |
| | | case SPK.SensorTVOC: |
| | | case SPK.SensorTemperature: |
| | | case SPK.SensorHumidity: |
| | | var sensor = Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(functionDataString); |
| | | List.sensorsEnvironmentalScience.Add(sensor); |
| | | deviceFunctionList.Add(sensor); |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | var ele = Newtonsoft.Json.JsonConvert.DeserializeObject<SwitchSocket>(functionDataString); |
| | | List.switchSockets.Add(ele); |
| | | deviceFunctionList.Add(ele); |
| | | break; |
| | | case SPK.ElectricTV: |
| | | var tv = Newtonsoft.Json.JsonConvert.DeserializeObject<TV>(functionDataString); |
| | | List.tVs.Add(tv); |
| | | deviceFunctionList.Add(tv); |
| | | break; |
| | | case SPK.ElectricFan: |
| | | var fan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString); |
| | | List.fans.Add(fan); |
| | | deviceFunctionList.Add(fan); |
| | | break;
|
| | | case SPK.ElectricTuyaAirCleaner: |
| | | var airCleaner = Newtonsoft.Json.JsonConvert.DeserializeObject<AirCleaner>(functionDataString); |
| | | List.airCleaners.Add(airCleaner); |
| | | deviceFunctionList.Add(airCleaner);
|
| | | break;
|
| | | case SPK.ElectricTuyaFan: |
| | | var tuyaFan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString); |
| | | List.fans.Add(tuyaFan); |
| | | deviceFunctionList.Add(tuyaFan);
|
| | | break;
|
| | | case SPK.ElectricTuyaWeepRobot: |
| | | var tuyaWeepRobot = Newtonsoft.Json.JsonConvert.DeserializeObject<WeepRobot>(functionDataString); |
| | | List.weepRobots.Add(tuyaWeepRobot); |
| | | deviceFunctionList.Add(tuyaWeepRobot); |
| | | break; |
| | | case SPK.ElectricTuyaWaterValve: |
| | | var tuyaWaterValve = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(functionDataString); |
| | | List.waterValveList.Add(tuyaWaterValve); |
| | | deviceFunctionList.Add(tuyaWaterValve); |
| | | break; |
| | | case SPK.SensorSmoke: |
| | | case SPK.SensorWater: |
| | | case SPK.SensorDoorWindow: |
| | | case SPK.SensorPir: |
| | | var ser = Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(functionDataString); |
| | | List.sensorsArm.Add(ser); |
| | | deviceFunctionList.Add(ser); |
| | | break; |
| | | case SPK.ClothesHanger: |
| | | var ch = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(functionDataString); |
| | | List.clothesHangerList.Add(ch); |
| | | deviceFunctionList.Add(ch); |
| | | break; |
| | | case SPK.IrModule: |
| | | var irm = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(functionDataString); |
| | | List.irModule.Add(irm); |
| | | deviceFunctionList.Add(irm); |
| | | break; |
| | | if (Functions[i].deviceId == tempFunction.deviceId) |
| | | { |
| | | //先移除掉再加 |
| | | Functions.RemoveAt(i); |
| | | Functions.Add(tempFunction); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | Functions.Add(tempFunction); |
| | | } |
| | | if (filePath.StartsWith("SceneData_")) |
| | | { |
| | |
| | | var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene>(sceneDataString); |
| | | List.scenes.Add(tempScene); |
| | | } |
| | | else if (filePath.StartsWith("SecurityData_")) |
| | | { |
| | | var dataBytes = FileUtlis.Files.ReadFile(filePath); |
| | | var dataString = System.Text.Encoding.UTF8.GetString(dataBytes); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityAlarm>(dataString); |
| | | if (temp == null) |
| | | { |
| | | MainPage.Log("null"); |
| | | FileUtlis.Files.DeleteFile(filePath); |
| | | return; |
| | | } |
| | | if (checkRepeat == true) |
| | | { |
| | | //检测重复 |
| | | for (int i = 0; i < securities.Count; i++) |
| | | { |
| | | if (securities[i].sid == temp.sid) |
| | | { |
| | | //先移除掉再加 |
| | | securities.RemoveAt(i); |
| | | securities.Add(temp); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | securities.Add(temp); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public List<Function> GetDeviceFunctionList(SPK.BrandType brandType = SPK.BrandType.All) |
| | | { |
| | | if (deviceFunctionList == null || deviceFunctionList.Count == 0) |
| | | { |
| | | deviceFunctionList = new List<Function>(); |
| | | deviceFunctionList.AddRange(aCs); |
| | | deviceFunctionList.AddRange(lights); |
| | | deviceFunctionList.AddRange(curtains); |
| | | deviceFunctionList.AddRange(floorHeatings); |
| | | deviceFunctionList.AddRange(electricals); |
| | | deviceFunctionList.AddRange(sensorsEnvironmentalScience); |
| | | deviceFunctionList.AddRange(sensorsArm); |
| | | deviceFunctionList.AddRange(UI.Music.A31MusicModel.A31MusicModelList); |
| | | try |
| | | { |
| | | deviceFunctionList = deviceFunctionList.OrderByDescending(o => o.controlCounter).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"设备功能排序异常:{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | List<Function> resultFunctions = new List<Function>(); |
| | | if (brandType == SPK.BrandType.All) |
| | | { |
| | |
| | | switch (brandType) |
| | | { |
| | | case SPK.BrandType.Hdl: |
| | | foreach (var function in deviceFunctionList) |
| | | foreach (var function in Functions) |
| | | { |
| | | if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(function.spk)) |
| | | { |
| | |
| | | break; |
| | | |
| | | case SPK.BrandType.Tuya: |
| | | foreach (var function in deviceFunctionList) |
| | | foreach (var function in Functions) |
| | | { |
| | | if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(function.spk)) |
| | | { |
| | |
| | | return resultFunctions; |
| | | } |
| | | |
| | | return deviceFunctionList; |
| | | return Functions; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 清空设备功能列表 |
| | | /// </summary> |
| | | public void Clear() |
| | | { |
| | | List.aCs = new List<AC>(); |
| | | List.lights = new List<Light>(); |
| | | List.curtains = new List<Curtain>(); |
| | | List.floorHeatings = new List<FloorHeating>(); |
| | | List.sensorsEnvironmentalScience = new List<Sensor>(); |
| | | #region 家电 |
| | | List.fans = new List<Fan>(); |
| | | List.switchSockets = new List<SwitchSocket>(); |
| | | List.tVs = new List<TV>(); |
| | | List.airCleaners = new List<AirCleaner>(); |
| | | List.weepRobots = new List<WeepRobot>(); |
| | | List.waterValveList = new List<Function>(); |
| | | List.clothesHangerList = new List<Function>(); |
| | | #endregion |
| | | |
| | | List.scenes = new List<Scene>(); |
| | | List.deviceFunctionList = new List<Function>(); |
| | | Functions = new List<Function>(); |
| | | _FunctionList = null; |
| | | } |
| | | |
| | |
| | | List.scenes.Remove(scene); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除本地功能及文件 |
| | | /// </summary> |
| | | public void DeleteFunction(Function delTemp) |
| | | { |
| | | switch (delTemp.spk) |
| | | { |
| | | case SPK.LightSwitch: |
| | | case SPK.LightDimming: |
| | | case SPK.LightRGB: |
| | | case SPK.LightRGBW: |
| | | case SPK.LightCCT: |
| | | List.lights.Remove(List.lights.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.CurtainRoller: |
| | | case SPK.CurtainShades: |
| | | case SPK.CurtainSwitch: |
| | | case SPK.CurtainTrietex: |
| | | List.curtains.Remove(List.curtains.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.AcStandard: |
| | | List.aCs.Remove(List.aCs.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.FloorHeatStandard: |
| | | List.floorHeatings.Remove(List.floorHeatings.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.SensorPm25: |
| | | case SPK.SensorCO2: |
| | | case SPK.SensorTVOC: |
| | | case SPK.SensorTemperature: |
| | | case SPK.SensorHumidity: |
| | | List.sensorsEnvironmentalScience.Remove(List.sensorsEnvironmentalScience.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | List.switchSockets.Remove(List.switchSockets.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricTV: |
| | | List.tVs.Remove(List.tVs.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricFan: |
| | | case SPK.ElectricTuyaFan: |
| | | List.fans.Remove(List.fans.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricTuyaAirCleaner: |
| | | List.airCleaners.Remove(List.airCleaners.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricTuyaWaterValve: |
| | | List.waterValveList.Remove(List.waterValveList.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ElectricTuyaWeepRobot: |
| | | List.weepRobots.Remove(List.weepRobots.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.ClothesHanger: |
| | | List.clothesHangerList.Remove(List.clothesHangerList.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | case SPK.SensorSmoke: |
| | | case SPK.SensorWater: |
| | | case SPK.SensorDoorWindow: |
| | | case SPK.SensorPir: |
| | | List.sensorsArm.Remove(List.sensorsArm.Find((obj)=>obj.deviceId == delTemp.deviceId)); |
| | | break; |
| | | } |
| | | var removeTemp = deviceFunctionList.Find((obj) => obj.deviceId == delTemp.deviceId); |
| | | if(removeTemp!= null) |
| | | { |
| | | deviceFunctionList.Remove(removeTemp); |
| | | } |
| | | Common.FileUtlis.Files.DeleteFile(delTemp.savePath); |
| | | Functions.Remove(Functions.Find((obj) => obj.deviceId == delTemp.deviceId)); |
| | | FileUtlis.Files.DeleteFile(delTemp.savePath); |
| | | } |
| | | |
| | | bool lockReadFunctionStatus = false; |
| | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #region 场景相关 |
| | | /// <summary> |
| | | /// 添加场景 |