예제 #1
0
파일: WS2300.cs 프로젝트: faina09/WS2300
 private void BtnInTmp_Click(object sender, EventArgs e)
 {
     try
     {
         double ret = ws2300.temperature_indoor(config.temperature_conv);
         lblIntTemp.Text = "TEMP=" + ret.ToString();
     }
     catch (Exception ex)
     {
         lblIntTemp.Text = "ERROR: " + ex.Message;
     }
 }
예제 #2
0
        /// <summary>
        /// Method for ThreadStart delegate
        /// </summary>
        public void RunProcess()
        {
            string[] var;
            string   rVal;
            double   ret;
            int      tempint;

            string[] directions = new string[] { "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
                                                 "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW" };
            short[] winddir = new short[6];

            Thread.CurrentThread.IsBackground = true; //make them a daemon
            try
            {
                var  = m_variables.Split(',');
                rVal = "undef";
                foreach (string s in var)
                {
                    switch (s.Trim().ToUpper())
                    {
                    case "T_IN":
                        rVal = m_ws2300.temperature_indoor(m_config.temperature_conv).ToString("F2");
                        break;

                    case "T_OUT":
                        rVal = m_ws2300.temperature_outdoor(m_config.temperature_conv).ToString("F2");
                        break;

                    case "DEW":
                        rVal = m_ws2300.dewpoint(m_config.temperature_conv).ToString("F2");
                        break;

                    case "H_IN":
                        rVal = m_ws2300.humidity_indoor().ToString();
                        break;

                    case "H_OUT":
                        rVal = m_ws2300.humidity_outdoor().ToString();
                        break;

                    case "WIND":
                        tempint    = -1;
                        winddir[0] = 0xFFF;
                        ret        = m_ws2300.wind_all(m_config.wind_speed_conv_factor, ref tempint, ref winddir);
                        rVal       = "Wind=" + ret.ToString() + " dir:" + winddir[0].ToString() + "° " + directions[tempint];
                        break;

                    case "W_CHILL":
                        rVal = m_ws2300.windchill(m_config.temperature_conv).ToString("F2");
                        break;

                    case "PRESS":
                        rVal = m_ws2300.rel_pressure(m_config.pressure_conv_factor).ToString("F2");
                        break;

                    case "HISTORY":
                        rVal = HistoryRecord();
                        break;
                    }
                    if (rVal != "")
                    {
                        UpdateMessage(rVal, false);
                    }
                }
                UpdateMessage("read ENDED", true);
            }
            catch (Exception ex)
            {
                UpdateMessage("ERROR: " + ex.Message, true);
            }
        }