| | |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.CSS; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.DAL.Server; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | |
| | | /// <summary> |
| | | /// 当前查询类型 |
| | | /// </summary> |
| | | QueryType curQueryType = QueryType.NowDay; |
| | | string curQueryType = "hour"; |
| | | |
| | | List<uint> tipColorList = new List<uint>() |
| | | { |
| | |
| | | TextColor = CSS_Color.PromptingColor2, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | TextID = StringId.month, |
| | | Text = DateTime.Now.Month.ToString() + Language.StringByID(StringId.month), |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Month); |
| | | #endregion |
| | |
| | | }; |
| | | diagramView.AddChidren(tipTextView); |
| | | |
| | | switch (sensor.functionType) |
| | | switch (sensor.spk) |
| | | { |
| | | case FunctionType.PM10: |
| | | case FunctionType.PM25: |
| | | case SPK.SensorPm25: |
| | | tipValuesView.AddChidren(new Button() |
| | | { |
| | | Width = Application.GetRealWidth(101), |
| | |
| | | TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | }); |
| | | break; |
| | | //case FunctionType.PM25: |
| | | //case SPK.SensorPm25: |
| | | //_intervalValue.Add("0 ~ 35"); |
| | | //_intervalValue.Add("36 ~ 75"); |
| | | //_intervalValue.Add("76 ~ 115"); |
| | |
| | | //_levelTextList.Add(StringId.MildPollution); |
| | | //_levelTextList.Add(StringId.HeavyPollution); |
| | | //break; |
| | | //case FunctionType.Noise: |
| | | // break; |
| | | case FunctionType.WindPower: |
| | | break; |
| | | case FunctionType.CO2: |
| | | case SPK.SensorCO2: |
| | | tipValuesView.AddChidren(new Button() |
| | | { |
| | | Width = Application.GetRealWidth(101), |
| | |
| | | TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | }); |
| | | break; |
| | | case FunctionType.Temp: |
| | | case SPK.SensorTemperature: |
| | | tipValuesView.AddChidren(new Button() |
| | | { |
| | | Width = Application.GetRealWidth(50), |
| | |
| | | //_levelTextList.Add(StringId.); |
| | | //_levelTextList.Add(StringId.ExtremeHeat); |
| | | break; |
| | | case FunctionType.TVOC: |
| | | case SPK.SensorTVOC: |
| | | tipValuesView.AddChidren(new Button() |
| | | { |
| | | Width = Application.GetRealWidth(101), |
| | |
| | | TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | }); |
| | | break; |
| | | case FunctionType.Humidity: |
| | | case SPK.SensorHumidity: |
| | | tipValuesView.AddChidren(new Button() |
| | | { |
| | | Width = Application.GetRealWidth(151), |
| | |
| | | |
| | | bool initTitleButton = true; |
| | | |
| | | foreach (var tempSensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience) |
| | | foreach (var tempSensor in FunctionList.List.sensorsEnvironmentalScience) |
| | | { |
| | | if (tempSensor.sid == sensor.sid) |
| | | { |
| | | continue; |
| | | } |
| | | if (tempSensor.functionType != sensor.functionType) |
| | | if (tempSensor.spk != sensor.spk) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | //------------ |
| | | public partial class EnvironmentalSensorPage |
| | | { |
| | | public enum QueryType |
| | | { |
| | | NowDay = 0,//当天 |
| | | NowMonth = 1,//指定月 |
| | | NowYear = 2,//今年 |
| | | LatelySevenDay = 3//最近七天 |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取传感器历史数据 |
| | | /// </summary> |
| | |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | loadPage.Start("Loading..."); |
| | | loadPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var curMonth = 0; |
| | | if(curQueryType == QueryType.NowMonth) |
| | | { |
| | | curMonth = DateTime.Now.Month; |
| | | } |
| | | int i = 0; |
| | | foreach (var tempSensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience) |
| | | |
| | | foreach (var sr in FunctionList.List.sensorsEnvironmentalScience) |
| | | { |
| | | if (tempSensor.sid == sensor.sid) |
| | | if (sr.spk != sensor.spk) |
| | | { |
| | | continue; |
| | | } |
| | | if (tempSensor.functionType != sensor.functionType) |
| | | { |
| | | continue; |
| | | } |
| | | var sr = DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience[i]; |
| | | if (showSensors.Find((obj) => obj.sid == sr.sid) == null) |
| | | { |
| | | i++; |
| | | continue; |
| | | } |
| | | var revertObj = new DAL.Server.HttpServerRequest().GetSensorHistory(sr.bus_Data.SubnetID, sr.bus_Data.DeviceID, |
| | | 5, (int)(sr.functionType) % 256, (int)curQueryType, sr.bus_Data.LoopID, curMonth, |
| | | DB_ResidenceData.residenceData.residenceGatewayMAC); |
| | | |
| | | var sensorType = sr.spk.Split(".")[0]; |
| | | var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, sr.deviceId,sensorType); |
| | | |
| | | if (revertObj != null) |
| | | { |
| | | if (revertObj.StateCode == "SUCCESS") |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SensorPushHistoryRes>>(revertObj.ResponseData.ToString()); |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); |
| | | |
| | | var sItem = new EchartSeriesItem |
| | | { |
| | |
| | | }, |
| | | }; |
| | | |
| | | int ass = 0; |
| | | for (int j = 0; j < revertData.Count; j++) |
| | | foreach (var d in revertData) |
| | | { |
| | | if (revertData[j].TargetValue.ToString() != "NaN") |
| | | { |
| | | ass = Convert.ToInt32(revertData[j].TargetValue); |
| | | } |
| | | sItem.data.Add(ass); |
| | | switch (curQueryType) |
| | | { |
| | | case QueryType.NowDay: |
| | | echartRootJson.xAxis.data.Add(revertData[j].CreatedOnUtc.Hour.ToString()); |
| | | break; |
| | | case QueryType.LatelySevenDay: |
| | | echartRootJson.xAxis.data.Add(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(revertData[j].CreatedOnUtc.DayOfWeek)); |
| | | break; |
| | | case QueryType.NowMonth: |
| | | echartRootJson.xAxis.data.Add(revertData[j].CreatedOnUtc.Day.ToString()); |
| | | break; |
| | | } |
| | | echartRootJson.xAxis.data.Add(d.fieldName); |
| | | echartRootJson.yAxis.data.Add(d.fieldValue); |
| | | } |
| | | seriesList.Add(sItem); |
| | | } |
| | |
| | | i++; |
| | | } |
| | | |
| | | //echartRootJson.title.text = "温度(℃)";lineStyle |
| | | //echartRootJson.color = new List<string> { "#80AEFF" };//, "FFD154", "FF9D54", "FE6A6A", "B183C3", "ADE764" |
| | | echartRootJson.series = seriesList; |
| | | |
| | | |
| | |
| | | btnShowHistroyData_Day.IsSelected = true; |
| | | btnShowHistroyData_Month.IsSelected = false; |
| | | btnShowHistroyData_Week.IsSelected = false; |
| | | curQueryType = QueryType.NowDay; |
| | | curQueryType = "hour"; |
| | | LoadMothed_GetSensorHistoryData(); |
| | | }; |
| | | |
| | |
| | | btnShowHistroyData_Day.IsSelected = false; |
| | | btnShowHistroyData_Month.IsSelected = true; |
| | | btnShowHistroyData_Week.IsSelected = false; |
| | | curQueryType = QueryType.NowMonth; |
| | | curQueryType = "week"; |
| | | LoadMothed_GetSensorHistoryData(); |
| | | }; |
| | | btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) => |
| | |
| | | btnShowHistroyData_Day.IsSelected = false; |
| | | btnShowHistroyData_Month.IsSelected = false; |
| | | btnShowHistroyData_Week.IsSelected = true; |
| | | curQueryType = QueryType.LatelySevenDay; |
| | | curQueryType = "month"; |
| | | LoadMothed_GetSensorHistoryData(); |
| | | }; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public class SensorPushHistoryRes |
| | | public class EnvironmentalSensorHistor |
| | | { |
| | | /// <summary> |
| | | /// </summary> |
| | | public string fieldName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 实际目标值 |
| | | /// </summary> |
| | | public float TargetValue { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 查询的时间集群 |
| | | /// </summary> |
| | | public DateTime CreatedOnUtc { get; set; } |
| | | public string fieldValue { get; set; } |
| | | } |
| | | } |