From d4811b7d34b45ff6b21b97f11da128b5572ec526 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 03 三月 2021 16:03:03 +0800
Subject: [PATCH] 20210303-1

---
 HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs |  152 +++++++++-----------------------------------------
 1 files changed, 28 insertions(+), 124 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs
index c382507..594196b 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs
@@ -27,7 +27,7 @@
         /// <summary>
         /// 褰撳墠鏌ヨ绫诲瀷
         /// </summary>
-        QueryType curQueryType = QueryType.NowDay;
+        string curQueryType = "hour";
 
         List<uint> tipColorList = new List<uint>()
         {
@@ -163,9 +163,9 @@
             };
             diagramView.AddChidren(tipTextView);
 
-            switch (sensor.functionType)
+            switch (sensor.spk)
             {
-                case FunctionType.PM25:
+                case SPK.SensorPm25:
                     tipValuesView.AddChidren(new Button()
                     {
                         Width = Application.GetRealWidth(101),
@@ -223,7 +223,7 @@
                         TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                     });
                     break;
-                //case FunctionType.PM25:
+                //case SPK.SensorPm25:
                 //_intervalValue.Add("0 ~ 35");
                 //_intervalValue.Add("36 ~ 75");
                 //_intervalValue.Add("76 ~ 115");
@@ -233,7 +233,7 @@
                 //_levelTextList.Add(StringId.MildPollution);
                 //_levelTextList.Add(StringId.HeavyPollution);
                 //break;
-                case FunctionType.CO2:
+                case SPK.SensorCO2:
                     tipValuesView.AddChidren(new Button()
                     {
                         Width = Application.GetRealWidth(101),
@@ -291,7 +291,7 @@
                         TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                     });
                     break;
-                case FunctionType.Temp:
+                case SPK.SensorTemperature:
                     tipValuesView.AddChidren(new Button()
                     {
                         Width = Application.GetRealWidth(50),
@@ -411,7 +411,7 @@
                     //_levelTextList.Add(StringId.);
                     //_levelTextList.Add(StringId.ExtremeHeat);
                     break;
-                case FunctionType.TVOC:
+                case SPK.SensorTVOC:
                     tipValuesView.AddChidren(new Button()
                     {
                         Width = Application.GetRealWidth(101),
@@ -469,7 +469,7 @@
                         TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                     });
                     break;
-                case FunctionType.Humidity:
+                case SPK.SensorHumidity:
                     tipValuesView.AddChidren(new Button()
                     {
                         Width = Application.GetRealWidth(151),
@@ -648,7 +648,7 @@
                 {
                     continue;
                 }
-                if (tempSensor.functionType != sensor.functionType)
+                if (tempSensor.spk != sensor.spk)
                 {
                     continue;
                 }
@@ -801,14 +801,6 @@
     //------------
     public partial class EnvironmentalSensorPage
     {
-       public  enum QueryType
-        {
-            NowDay = 0,//褰撳ぉ
-            NowMonth = 1,//鎸囧畾鏈�
-            NowYear = 2,//浠婂勾
-            LatelySevenDay = 3//鏈�杩戜竷澶�
-        }
-
         /// <summary>
         /// 璇诲彇浼犳劅鍣ㄥ巻鍙叉暟鎹�
         /// </summary>
@@ -828,74 +820,13 @@
                 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;
-
-//#if DEBUG
-//                    var sItem = new EchartSeriesItem
-//                    {
-//                        name = sensor.GetRoomListName(),
-//                        data = new List<int>(),
-//                        lineStyle = new EchartLineStyle()
-//                        {
-//                            color = tipColorStringList[i],
-//#if __IOS__
-//                            width = 5,
-//#elif __ANDROID__
-//                                        width = 2,
-//#endif
-//                        },
-//                    };
-//                    Random random = new Random();
-//                    double level = 0.0;
-//                    int countddd = 24;
-//                    for (int j = 0; j < countddd; j++)
-//                    {
-//                        switch (sensor.functionType)
-//                        {
-//                            case FunctionType.PM25:
-//                                level = Math.Round(random.NextDouble() * 130, 0);
-//                                break;
-//                            case FunctionType.CO2:
-//                                level = Math.Round(random.NextDouble() * 6000, 0);
-//                                break;
-//                            case FunctionType.Temp:
-//                                level = Math.Round(random.NextDouble() * 40, 0);
-//                                break;
-//                            case FunctionType.TVOC:
-//                                level = Math.Round(random.NextDouble() * 10, 1);
-//                                break;
-//                            case FunctionType.Humidity:
-//                                level = Math.Round(random.NextDouble() * 100, 0);
-//                                break;
-//                        }
-//                        sItem.data.Add((int)level);
-//                    }
-//                        seriesList.Add(sItem);
-//                    echartRootJson.series = seriesList;
-//#if __IOS__
-//                    echartRootJson.xAxis.axisLabel.fontSize = 22;
-//                    echartRootJson.yAxis.axisLabel.fontSize = 22;
-//#else
-//                    echartRootJson.xAxis.axisLabel.fontSize = 8;
-//                    echartRootJson.yAxis.axisLabel.fontSize = 8;
-//#endif
-//                    echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson);
-//                    Application.RunOnMainThread(() =>
-//                    {
-//                        myEchartsView.ShowWithOptionJsonString(echartRootJsonString);
-//                    });
-//#endif
-
+      
                     foreach (var sr in FunctionList.List.sensorsEnvironmentalScience)
                     {
-                        if (sr.functionType != sensor.functionType)
+                        if (sr.spk != sensor.spk)
                         {
                             continue;
                         }
@@ -904,15 +835,15 @@
                             i++;
                             continue;
                         }
-                        var revertObj = new HttpServerRequest().GetSensorHistory(sr.bus.SubnetID, sr.bus.DeviceID,
-                               5, (int)(sr.functionType) % 256, (int)curQueryType, sr.bus.loopId, curMonth,
-                               DB_ResidenceData.Instance.residenceGatewayMAC);
+
+                        var sensorType = sr.spk.Split(".")[0];
+                        var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, sr.deviceId,sensorType);
 
                         if (revertObj != null)
                         {
-                            if (revertObj.StateCode == 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
                                 {
@@ -929,34 +860,10 @@
                                     },
                                 };
 
-                                int ass = 0;
-                                for (int j = 0; j < revertData.Count; j++)
+                                foreach (var d in revertData)
                                 {
-                                    if (curQueryType == QueryType.NowMonth && revertData[j].CreatedOnUtc.Day > DateTime.Now.Day)
-                                    {
-                                        continue;
-                                    }
-                                    if (revertData[j].TargetValue.ToString() != "NaN")
-                                    {
-                                        ass = Convert.ToInt32(revertData[j].TargetValue);
-                                    }
-                                    else
-                                    {
-                                        ass = 0;
-                                    }
-                                    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);
                             }
@@ -1010,7 +917,7 @@
                 btnShowHistroyData_Day.IsSelected = true;
                 btnShowHistroyData_Month.IsSelected = false;
                 btnShowHistroyData_Week.IsSelected = false;
-                curQueryType = QueryType.NowDay;
+                curQueryType = "hour";
                 LoadMothed_GetSensorHistoryData();
             };
 
@@ -1020,7 +927,7 @@
                 btnShowHistroyData_Day.IsSelected = false;
                 btnShowHistroyData_Month.IsSelected = true;
                 btnShowHistroyData_Week.IsSelected = false;
-                curQueryType = QueryType.NowMonth;
+                curQueryType = "week";
                 LoadMothed_GetSensorHistoryData();
             };
             btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) =>
@@ -1029,7 +936,7 @@
                 btnShowHistroyData_Day.IsSelected = false;
                 btnShowHistroyData_Month.IsSelected = false;
                 btnShowHistroyData_Week.IsSelected = true;
-                curQueryType = QueryType.LatelySevenDay;
+                curQueryType = "month";
                 LoadMothed_GetSensorHistoryData();
             };
 
@@ -1041,17 +948,14 @@
         }
     }
 
-    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; }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0