Beispiel #1
0
        public void UnixStampConvert_FromDateToUnixTimeStamp()
        {
            string format         = "dd.MM.yyyy_HH:mm:ss";
            string expectedoutput = "01.01.2018_12:00:00";

            string date = UnixStampConvert.UnixTimeToDateTime(1514808000).ToString(format);

            Assert.AreEqual(expectedoutput, date);
        }
        /// <summary>
        /// To poplulate LiveChart in the GUI is only used by btn_Showdata_Click event
        /// </summary>
        private void PopulateCharts()
        {
            DataContext = null;
            DateTime date = dp_datestampfrom.SelectedDate.Value;

            string clvl = null;

            switch (cb_CompressionLVL.SelectedIndex)
            {
            case 0: clvl = "1"; break;

            case 1: clvl = "2"; break;

            case 2: clvl = "3"; break;

            case 3: clvl = "4"; break;

            default: break;
            }

            string unitID = null;

            foreach (var unit in units)
            {
                if (unit.name == cb_UnitID.Text)
                {
                    unitID = unit.id;
                }
            }

            string          climatestringdata = HttpApiRequest.GetClimateData(UserInformation.ApiKey, UserInformation.Mail, unitID, date.ToString("yyyy.MM.dd"), clvl);
            List <unitData> ClimateDataList   = JsonDataConverter.deserializedClimateData(climatestringdata);

            string format = "HH:mm";

            int x = ClimateDataList.Count();

            TimeLabel = new string[x];
            List <double> TemperaturValues = new List <double>();
            List <double> HeatIndexValues  = new List <double>();
            List <double> HumidityValues   = new List <double>();

            for (int i = 0; i < x; i++)
            {
                TimeLabel[i] = UnixStampConvert.UnixTimeToDateTime(ClimateDataList[i].datestamp).ToString(format);
                TemperaturValues.Add(Math.Round(ClimateDataList[i].climatedata.temperature, 2));
                HeatIndexValues.Add(Math.Round(ClimateDataList[i].climatedata.heatindex, 2));
                HumidityValues.Add(Math.Round(ClimateDataList[i].climatedata.humidity, 2));
            }

            var TempLineColor = Colors.Red;
            var HeatLineColor = Colors.Yellow;
            var HumiLineColor = Colors.Blue;

            SolidColorBrush TempLineColorfil = new SolidColorBrush();

            TempLineColorfil.Color   = TempLineColor;
            TempLineColorfil.Opacity = 0.2;

            SolidColorBrush HeatLineColorfil = new SolidColorBrush();

            HeatLineColorfil.Color   = HeatLineColor;
            HeatLineColorfil.Opacity = 0.2;

            SolidColorBrush HumiLineColorfil = new SolidColorBrush();

            HumiLineColorfil.Color   = HumiLineColor;
            HumiLineColorfil.Opacity = 0.2;

            TempSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Temperatur",
                    Values            = TemperaturValues.AsChartValues(),
                    LineSmoothness    = 1,
                    PointGeometrySize = 0,
                    Stroke            = Brushes.Red,
                    Fill = TempLineColorfil
                },
                new LineSeries
                {
                    Title             = "HeatIndex",
                    Values            = HeatIndexValues.AsChartValues(),
                    LineSmoothness    = 1,
                    PointGeometrySize = 0,
                    Stroke            = Brushes.Yellow,
                    Fill = HeatLineColorfil
                }
            };

            HumiSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Humidity",
                    Values            = HumidityValues.AsChartValues(),
                    LineSmoothness    = 1,
                    PointGeometrySize = 0,
                    Stroke            = Brushes.Blue,
                    Fill = HumiLineColorfil
                }
            };

            DataContext = this;
        }