示例#1
0
        private static BitmapEx Draw(WeatherStationData weatherInfo, LayoutContext layoutContext)
        {
            var indoorDevice = weatherInfo.Devices.First();
            var temperature  = WeatherHelpers.TempToStr(indoorDevice.Temperature.Value);
            var co2          = indoorDevice.Co2Measure.Value.ToString();

            var bitmap = layoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawTexts(bitmap, layoutContext.Options.Theme.FontFamily, co2, temperature, "+88", layoutContext.Options.Theme.ForegroundColor);

            return(bitmap);
        }
示例#2
0
    public static Weather UpdateWeather(Weather localWeather, Weather[] nWeathers, Vector3[] nVectors, ITransform localTransform)
    {
        var nWindDirections = nWeathers.Select(n => n.windDirection);
        var nWindSpeeds     = nWeathers.Select(n => n.windSpeed);
        var nAirPressures   = nWeathers.Select(n => n.airPressure);

        // OLD METHOD
        // var (newWindSpeed, newWindDirection) = localWeather.isWindSource
        //     ? (localWeather.windSpeed, localWeather.windDirection)
        //     : WeatherHelpers.UpdateWind(
        //         localTransform,
        //         nWindDirections.ToArray(),
        //         nWindSpeeds.ToArray(),
        //         nVectors);
        if (localWeather.isWindSource)
        {
            return(localWeather);
        }
        Weather newWeather = localWeather.ShallowCopy();

        var(newWindSpeed, newWindDirection) = WeatherHelpers.UpdateWind(
            localWeather.airPressure,
            nAirPressures.ToArray(),
            localWeather.windDirection,
            localWeather.windSpeed,
            nWindDirections.ToArray(),
            nWindSpeeds.ToArray(),
            nVectors);

        newWeather.windSpeed     = newWindSpeed;
        newWeather.windDirection = newWindDirection;

        newWeather.airPressure = UpdateAirPressure(
            localWeather.airPressure,
            nAirPressures.ToArray(),
            localWeather.windDirection,
            localWeather.windSpeed,
            nWindDirections.ToArray(),
            nWindSpeeds.ToArray(),
            nVectors
            );

        return(newWeather);
    }
示例#3
0
        public void Init()
        {
            _weatherStationService = _globalContext.GetServices <IWeatherStationService>().FirstOrDefault();
            if (_weatherStationService == null)
            {
                throw new ApplicationException("Weather station service is not available.");
            }

            _elements.Add(new WeatherStationDataSource(new Location(0, 0), s => s.Devices[0].Temperature.Value, d => WeatherHelpers.TempToDecStr(d), "     °C"));
            _elements.Add(new WeatherStationDataSource(new Location(1, 0), s => s.Devices[0].HumidityPercent.Value, d => (d / 100).ToString("P0"), ""));
            _elements.Add(new WeatherStationDataSource(new Location(2, 0), s => s.Devices[0].Pressure.Value, d => d.ToString("F1"), "mmHg"));
            _elements.Add(new WeatherStationDataSource(new Location(3, 0), s => s.Devices[0].Co2Measure.Value, d => d.ToString("F0"), "ppm"));
            _elements.Add(new WeatherStationDataSource(new Location(4, 0), s => s.Devices[0].Noise.Value, d => d.ToString("F0"), "dB"));

            _elements.Add(new WeatherStationDataSource(new Location(0, 1), s => s.Devices[1].Temperature.Value, d => WeatherHelpers.TempToDecStr(d), "     °C"));
            _elements.Add(new WeatherStationDataSource(new Location(1, 1), s => s.Devices[1].HumidityPercent.Value, d => (d / 100).ToString("P0"), ""));
        }