示例#1
0
    private IEnumerator TimerCoroutine()
    {
        while (isTimerOn)
        {
            UpdateStats();

            var time = DateTime.Now;
            m_Target.Origin.time = time;
            energyText.text      = WindMathController.GetEnergyNow(m_Target.Origin).ToString("F3") + " kVt*h";
            timeText.text        = time.ToString("HH:mm:ss");
            yield return(new WaitForSeconds(1.0f));
        }
    }
示例#2
0
 private IEnumerator UpdateServerCoroutine()
 {
     while (isTimerOn)
     {
         var request = new WeatherRequest(m_Target.Origin.Coordinates);
         Server.Instance.Post <WeatherRequest, WeatherResponce>(request, x =>
         {
             if (x.status == Status.OK)
             {
                 m_Target.Origin.temperature = x.main.temp;
                 m_Target.Origin.windSpeed   = x.wind.speed;
                 m_Target.Origin.pressure    = x.main.pressure;
                 windDirection.text          = x.wind.deg.ToString("F2") + " °";
                 windSpeed.text   = x.wind.speed.ToString("F2") + " m/s";
                 temperature.text = (x.main.temp - 273.15f).ToString("F2") + " °С";
                 pressure.text    = (x.main.pressure).ToString("F1") + " mBar";
                 windmill.transform.eulerAngles = new Vector3(0, -x.wind.deg, 0);
                 energyText.text = WindMathController.GetEnergyNow(m_Target.Origin).ToString("F2");
             }
         });
         yield return(new WaitForSeconds(REFRESH_CD));
     }
 }
    private IEnumerator UpdateRoutine()
    {
        while (m_IsRunning)
        {
            var items = m_Layer.UIItems;
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i].Origin;
                item.time = DateTime.Now;

                var energy = WindMathController.GetEnergyNow(item);

                var row = m_Table.CreateRow();
                row[COORDINATES_COLUMN_NAME].text = item.Coordinates.ToString();
                row[ENERGY_COLUMN_NAME].text      = energy.ToString();
                row[HEIGHT_COLUMN_NAME].text      = item.heightWindmill.ToString();
                row[RADIUS_COLUMN_NAME].text      = item.radius.ToString();
                row[SPEED_COLUMN_NAME].text       = item.windSpeed.ToString();
            }
            yield return(new WaitForSeconds(UPDATE_RATE));

            m_Table.Clear();
        }
    }