| | |
| | | <meta-data android:name="OPPO_APPID" android:value="OP-30619979" /> |
| | | <meta-data android:name="OPPO_APPSECRET" android:value="OP-11d511c42f654cafac99588322681003" /> |
| | | <!-- 极光推送结束 --> |
| | | <!-- 设置高德地图key --> |
| | | <meta-data android:name="com.amap.api.v2.apikey" android:value="9901dd06e30b229efdd4c5bf5e076224" /> |
| | | <!-- 设置高德地图key --> |
| | | <meta-data android:name="com.amap.api.v2.apikey" android:value="9901dd06e30b229efdd4c5bf5e076224" /> |
| | | </application> |
| | | </manifest> |
| | |
| | | /// 启用禁用自动化 |
| | | /// </summary> |
| | | public const string API_POST_Logic_Enable = "/home-wisdom/app/logic/enable"; |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报 |
| | | /// </summary> |
| | | public const string API_POST_Logic_GeoFenceStateReport = "/home-wisdom/app/logic/geoFenceStateReport"; |
| | | #endregion |
| | | |
| | | #region -- 第三方设备相关接口___________________________ |
| | |
| | | //室外变化 |
| | | shiwaiView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0) |
| | | { |
| | | new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured); |
| | | return; |
| | | } |
| | | //if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0) |
| | | //{ |
| | | // new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured); |
| | | // return; |
| | | //} |
| | | Weather weather = new Weather(); |
| | | MainPage.BasePageView.AddChidren(weather); |
| | | weather.Show(); |
| | |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.condition_type = "9"; |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "air_quality"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "airquality"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input); |
| | | AddCondition(input, "airquality" ,"="); |
| | | } |
| | | /// <summary> |
| | | /// 添加条件 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | private void AddCondition(Input input) |
| | | private void AddCondition(Input input, string keyValue, string comparator) |
| | | { |
| | | ///记录索引值 |
| | | int index = -1; |
| | | for (var i = 0; i < Logic.currlogic.input.Count; i++) |
| | | { |
| | | var condition_type = Logic.currlogic.input[i].condition_type; |
| | | if (condition_type == "9") |
| | | if (condition_type == "6") |
| | | { |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | | var dicList = Logic.currlogic.input[i].condition; |
| | | if (ExistKey(dicList, keyValue, comparator)) |
| | | { |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (index != -1) |
| | |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断是否存在Key |
| | | /// </summary> |
| | | /// <param name="dicList"></param> |
| | | /// <param name="keyValue"></param> |
| | | /// <param name="comparator">比较关系</param> |
| | | /// <returns></returns> |
| | | private bool ExistKey(List<Dictionary<string, string>> dicList, string keyValue, string comparator) |
| | | { |
| | | for (int i = 0; i < dicList.Count; i++) |
| | | { |
| | | var dic = dicList[i]; |
| | | string key = dic["key"]; |
| | | string comparatorValue = dic["comparator"]; |
| | | if (key == keyValue && comparatorValue == comparator) |
| | | { |
| | | //判断是否存在 |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | |
| | | case SPK.CurtainRoller: |
| | | case SPK.CurtainTrietex: |
| | | //空调 |
| | | case SPK.AcStandard:case SPK.HvacAC: |
| | | case SPK.AcStandard: |
| | | case SPK.HvacAC: |
| | | //地热 |
| | | case SPK.HvacFloorHeat:case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | //新风 |
| | | case SPK.AirFreshStandard: |
| | | case SPK.HvacAirFresh: |
| | |
| | | break; |
| | | case SPK.SensorTemperature: |
| | | { |
| | | |
| | | string str =new InpOrOutLogicMethod { }.GetText(dicList, "temperature"); |
| | | |
| | | string str = new InpOrOutLogicMethod { }.GetText(dicList, "temperature"); |
| | | inputView.btnState.Text = str; |
| | | } |
| | | break; |
| | |
| | | } |
| | | } |
| | | break; |
| | | case "4": |
| | | case "6": |
| | | { |
| | | //inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; |
| | | inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; |
| | | string strtext = ""; |
| | | string strvalue = ""; |
| | |
| | | |
| | | switch (key) |
| | | { |
| | | case "outdoor_temp": |
| | | case "temperature": |
| | | { |
| | | //云端天气条件 城市温度触发 |
| | | strvalue = value + "℃"; |
| | | if (comparator == ">") |
| | | { |
| | |
| | | |
| | | } |
| | | break; |
| | | case "outdoor_humity": |
| | | case "humidity": |
| | | { |
| | | //云端天气条件 城市湿度触发 |
| | | strvalue = value + "%"; |
| | | if (comparator == ">") |
| | | { |
| | |
| | | |
| | | } |
| | | break; |
| | | case "pm2.5": |
| | | case "pm25": |
| | | { |
| | | //云端天气条件 城市pm2.5触发 |
| | | strtext = Language.StringByID(StringId.PM25); |
| | | strvalue = new PublicInterface { }.GetString("pm25", value); |
| | | } |
| | | break; |
| | | case "weather": |
| | | { |
| | | //云端天气条件 城市天气触发 |
| | | strtext = Language.StringByID(StringId.tianqibianhua); |
| | | switch (value) |
| | | { |
| | | case "sunny": |
| | | { |
| | | strtext = Language.StringByID(StringId.clearday); |
| | | |
| | | } |
| | | break; |
| | | case "cloudy": |
| | | { |
| | | |
| | | strtext = Language.StringByID(StringId.cloudy); |
| | | |
| | | } |
| | | break; |
| | | case "rainy": |
| | | { |
| | | strtext = Language.StringByID(StringId.rain); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case "airquality": |
| | | { |
| | | //云端天气条件 城市空气质量 |
| | | strtext = Language.StringByID(StringId.kongqizhiliang); |
| | | switch (value) |
| | | { |
| | | case "excellent": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqiyou); |
| | | |
| | | } |
| | | break; |
| | | case "good": |
| | | { |
| | | |
| | | strtext = Language.StringByID(StringId.kongqiliang); |
| | | |
| | | } |
| | | break; |
| | | case "poor": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqicha); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | |
| | | } |
| | | inputView.btnText.Text = strtext; |
| | | inputView.btnState.Text = strvalue; |
| | | } |
| | | break; |
| | | case "6": |
| | | { |
| | | inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string strtext = ""; |
| | | string value = dic["value"]; |
| | | switch (value) |
| | | { |
| | | case "sunny": |
| | | { |
| | | strtext = Language.StringByID(StringId.clearday); |
| | | |
| | | } |
| | | break; |
| | | case "cloudy": |
| | | { |
| | | |
| | | strtext = Language.StringByID(StringId.cloudy); |
| | | |
| | | } |
| | | break; |
| | | case "rainy": |
| | | { |
| | | strtext = Language.StringByID(StringId.rain); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | inputView.btnText.TextID = StringId.tianqibianhua; |
| | | inputView.btnState.Text = strtext; |
| | | } |
| | | } |
| | | break; |
| | | case "8": |
| | |
| | | break; |
| | | } |
| | | inputView.btnText.TextID = StringId.likiadaoda; |
| | | inputView.btnState.Text = strtext; |
| | | } |
| | | } |
| | | break; |
| | | case "9": |
| | | { |
| | | inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; |
| | | foreach (var dic in dicList) |
| | | { |
| | | string strtext = ""; |
| | | string value = dic["value"]; |
| | | switch (value) |
| | | { |
| | | case "excellent": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqiyou); |
| | | |
| | | } |
| | | break; |
| | | case "good": |
| | | { |
| | | |
| | | strtext = Language.StringByID(StringId.kongqiliang); |
| | | |
| | | } |
| | | break; |
| | | case "poor": |
| | | { |
| | | strtext = Language.StringByID(StringId.kongqicha); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | inputView.btnText.TextID = StringId.kongqizhiliang; |
| | | inputView.btnState.Text = strtext; |
| | | } |
| | | } |
| | |
| | | else if (device.spk == SPK.SensorTemperature) |
| | | { |
| | | |
| | | new InpOrOutLogicMethod().SensorView(thisView, device, "temperature", indexVulae); |
| | | new InpOrOutLogicMethod().SensorView(thisView, device, "temperature", indexVulae); |
| | | |
| | | } |
| | | else if ( device.spk == SPK.SensorHumidity) |
| | | else if (device.spk == SPK.SensorHumidity) |
| | | { |
| | | |
| | | new InpOrOutLogicMethod().SensorView(thisView, device, "humidity", indexVulae); |
| | |
| | | } |
| | | } |
| | | break; |
| | | case "4": |
| | | case "6": |
| | | { |
| | | ///当前的索引值数据对象 |
| | | Input inputedit = Logic.currlogic.input[indexVulae]; |
| | |
| | | stateValue = dic["value"]; |
| | | switch (key) |
| | | { |
| | | case "outdoor_temp": |
| | | case "temperature": |
| | | { |
| | | if (comparator == ">") |
| | | { |
| | |
| | | |
| | | } |
| | | break; |
| | | case "outdoor_humity": |
| | | case "humidity": |
| | | { |
| | | |
| | | if (comparator == ">") |
| | |
| | | |
| | | } |
| | | break; |
| | | case "pm2.5": |
| | | case "pm25": |
| | | { |
| | | intValue = StringId.PM25; |
| | | } |
| | | break; |
| | | case "weather": |
| | | { |
| | | intValue = StringId.tianqibianhua; |
| | | } |
| | | break; |
| | | case "airquality": |
| | | { |
| | | intValue = StringId.kongqizhiliang; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | OutdoorEnvironment outdoorEnvironment = new OutdoorEnvironment(); |
| | | if (intValue == StringId.PM25) |
| | | if (intValue == StringId.tianqibianhua) |
| | | { |
| | | //城市天气(晴天,下雨) |
| | | WeatherCondition weatherCondition = new WeatherCondition(); |
| | | MainPage.BasePageView.AddChidren(weatherCondition); |
| | | weatherCondition.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | else if (intValue == StringId.PM25) |
| | | { |
| | | //城市天气(pm2.5) |
| | | outdoorEnvironment.PmAction(thisView, stateValue); |
| | | } |
| | | else if (intValue == StringId.kongqizhiliang) |
| | | { |
| | | //城市天气(空气质量) |
| | | AirQuality airQuality = new AirQuality(); |
| | | MainPage.BasePageView.AddChidren(airQuality); |
| | | airQuality.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | else |
| | | { |
| | | //城市天气(温湿度) |
| | | outdoorEnvironment.InputBoxAction(intValue, stateValue); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case "6": |
| | | { |
| | | |
| | | WeatherCondition weatherCondition = new WeatherCondition(); |
| | | MainPage.BasePageView.AddChidren(weatherCondition); |
| | | weatherCondition.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | } |
| | | break; |
| | | |
| | | case "8": |
| | | { |
| | | AddInputType addInputType = new AddInputType(); |
| | | addInputType.LocationView(thisView,true); |
| | | } |
| | | break; |
| | | case "9": |
| | | { |
| | | |
| | | AirQuality airQuality = new AirQuality(); |
| | | MainPage.BasePageView.AddChidren(airQuality); |
| | | airQuality.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | addInputType.LocationView(thisView, true); |
| | | } |
| | | break; |
| | | |
| | |
| | | /// 时间点条件=1; |
| | | /// 时间段条件=2; |
| | | /// 设备状态变化条件=3; |
| | | /// 环境信息条件=4; |
| | | /// 环境信息条件=4(废弃); |
| | | /// 安防条件=5; |
| | | /// 云端天气条件=6; |
| | | /// 某个逻辑/场景的输出条件=7; |
| | | /// 地理围栏=8; |
| | | /// 空气质量=9; |
| | | /// 空气质量=9(废弃); |
| | | /// 场景=10; |
| | | /// </summary> |
| | | public string condition_type = ""; |
| | |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报云端 |
| | | /// </summary> |
| | | /// <param name="out_lng">APP经度</param> |
| | | /// <param name="out_lat">APP纬度</param> |
| | | /// <param name="out_lng">APP GPS经度</param> |
| | | /// <param name="out_lat">APP GPS纬度</param> |
| | | private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat) |
| | | { |
| | | List<LogicData> logicDataList = new List<LogicData>(); |
| | | logicDataList.Clear(); |
| | | //获取逻辑ID列表 |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | |
| | | ///自动化没有配置地理围栏不处理 |
| | | if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude)) |
| | | { |
| | | //经纬度为空,不处理 |
| | | //经纬度为空,认为自动化没有配置地理围栏,不处理; |
| | | continue; |
| | | } |
| | | //自动化纬度 |
| | | double lat = Convert.ToDouble(logicDate.geo_fence.latitude); |
| | | //自动化经度 |
| | | double lon = Convert.ToDouble(logicDate.geo_fence.longitude); |
| | | //自动化半径<单位米> |
| | | //自动化配置输入条件<地理围栏半径><单位,公里、千米.米> |
| | | int radius = int.Parse(logicDate.geo_fence.radius); |
| | | //计算2个经纬度之间的距离 |
| | | int r =Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon); |
| | | //定义一个局部变量 |
| | | string direction = string.Empty; |
| | | //两点距离小于配置距离<既自动化配置输入条件地理围栏半径>,说明进入区域 |
| | | if (r<radius) { |
| | | //到达某地 |
| | | direction = "arrive"; |
| | | } else { |
| | | //离开 |
| | | direction = "leave"; |
| | | } |
| | | bool f= Send.GeoFenceStateReport(logicDate.userLogicId,logicDate.sid, direction); |
| | | //if () { } |
| | | |
| | | //Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | case StringId.wendugaoyu: |
| | | { |
| | | keyValue = "outdoor_temp"; |
| | | keyValue = "temperature"; |
| | | comparator = ">"; |
| | | } |
| | | break; |
| | | case StringId.wendudiyu: |
| | | { |
| | | keyValue = "outdoor_temp"; |
| | | keyValue = "temperature"; |
| | | comparator = "<"; |
| | | } |
| | | break; |
| | | case StringId.shidugaoyu: |
| | | { |
| | | keyValue = "outdoor_humity"; |
| | | keyValue = "humidity"; |
| | | comparator = ">"; |
| | | } |
| | | break; |
| | | case StringId.shidudiyu: |
| | | { |
| | | keyValue = "outdoor_humity"; |
| | | keyValue = "humidity"; |
| | | comparator = "<"; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | AddDic(keyValue, comparator, value); |
| | | AddDic(keyValue, comparator, value,"float"); |
| | | }); |
| | | } |
| | | /// <summary> |
| | |
| | | , (text) => |
| | | { |
| | | var value= pmView.GetValue("pm25", text); |
| | | AddDic("pm2.5", "in", value); |
| | | AddDic("pm25", "in", value, "integer"); |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// 封装数据 |
| | | /// </summary> |
| | | /// <param name="keyValue">类型值(pm2.5;outdoor_temp;outdoor_humity)</param> |
| | | /// <param name="keyValue">类型值(pm25;temperature;humidity)</param> |
| | | /// <param name="comparator">比较关系</param> |
| | | /// <param name="value">值</param> |
| | | private void AddDic(string keyValue, string comparator, string value) |
| | | public void AddDic(string keyValue, string comparator,string value,string data_type) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.condition_type = "4"; |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", keyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "float"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", data_type); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input, keyValue, comparator); |
| | |
| | | for (var i = 0; i < Logic.currlogic.input.Count; i++) |
| | | { |
| | | var condition_type = Logic.currlogic.input[i].condition_type; |
| | | if (condition_type == "4") |
| | | if (condition_type == "6") |
| | | { |
| | | var dicList = Logic.currlogic.input[i].condition; |
| | | if (ExistKey(dicList, keyValue, comparator)) |
| | |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报 |
| | | /// </summary> |
| | | /// <param name="userLogicId">自动化云端id<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="logicSid">自动化sid<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="direction">arrive:到达(进入) leave:离开</param> |
| | | /// <returns></returns> |
| | | public static bool GeoFenceStateReport(string userLogicId, string logicSid, string direction) |
| | | { |
| | | var jObject = new JObject(); |
| | | jObject.Add("homeId", LogicMethod.CurrLogicMethod.HomeId); |
| | | jObject.Add("userLogicId", userLogicId); |
| | | jObject.Add("sid", logicSid); |
| | | jObject.Add("direction", direction); |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_GeoFenceStateReport); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GeoFenceStateReport(userLogicId, logicSid, direction); |
| | | } |
| | | if (responsePackNew.Code == "0") |
| | | { |
| | | //成功 |
| | | return true; |
| | | } |
| | | //失败 |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input); |
| | | AddCondition(input, "weather", "="); |
| | | } |
| | | /// <summary> |
| | | /// 添加条件 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | private void AddCondition(Input input) |
| | | private void AddCondition(Input input, string keyValue, string comparator) |
| | | { |
| | | ///记录索引值 |
| | | int index = -1; |
| | |
| | | var condition_type = Logic.currlogic.input[i].condition_type; |
| | | if (condition_type == "6") |
| | | { |
| | | var dicList = Logic.currlogic.input[i].condition; |
| | | if (ExistKey(dicList, keyValue, comparator)) |
| | | { |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | | } |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 判断是否存在Key |
| | | /// </summary> |
| | | /// <param name="dicList"></param> |
| | | /// <param name="keyValue"></param> |
| | | /// <param name="comparator">比较关系</param> |
| | | /// <returns></returns> |
| | | private bool ExistKey(List<Dictionary<string, string>> dicList, string keyValue, string comparator) |
| | | { |
| | | for (int i = 0; i < dicList.Count; i++) |
| | | { |
| | | var dic = dicList[i]; |
| | | string key = dic["key"]; |
| | | string comparatorValue = dic["comparator"]; |
| | | if (key == keyValue && comparatorValue == comparator) |
| | | { |
| | | //判断是否存在 |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |