/// <summary> /// Update control time /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CtrlTimer_Tick(object sender, EventArgs e) { if (GlbVars.tempReadTimer.Enabled) { TimeSpan ts = DateTime.Now - GlbVars.ctrlStartTime; this.LblCtrlTimeShow.Invoke(new EventHandler(delegate { LblCtrlTimeShow.Text = String.Format("{0}:{1}:{2}", ts.Hours, ts.Minutes, ts.Seconds); })); } else { this.LblCtrlTimeShow.Invoke(new EventHandler(delegate { LblCtrlTimeShow.Text = "N/A"; })); } float fluc = 0; string flucString = "N/A"; if (GlbVars.GetFluc(GlbVars.tempFlucLen_10min, out fluc)) { flucString = fluc.ToString("0.000"); } else { flucString = "N/A"; } this.LblFlucShow.Invoke(new EventHandler(delegate { LblFlucShow.Text = flucString; })); }
/// <summary> /// Check if the fluctuation is in range /// </summary> /// <param name="count">Count used to calculate fluctuation</param> /// <returns>If in range</returns> public bool CheckFluc(out float temperature) { // Improve: Need remove all uart error judgement? if (GlbVars.uartCom.ReadData(UartProtocol.Commands_t.TempShow, out temperature) != UartProtocol.Errors_t.NoError) { Exception e = new Exception(" Communication command is in error !!!"); throw e; } // Add temperature data into list GlbVars.AddTemperature(temperature); float fluctuation = 0; // If there not enough temperature point to check fluctuation, consider it not in range if (!GlbVars.GetFluc(checkCount, out fluctuation)) { return(false); } // If temperature and fluctuation are both in range, return true if (Math.Abs(temperature - this.tempSetCurrent) < GlbVars.paraValues[(int)GlbVars.Paras_t.TempThr] && fluctuation < GlbVars.paraValues[(int)GlbVars.Paras_t.FlucThr]) { return(true); } return(false); }