public void addLoadPoint(double time, double value, string tempUnitsIfTemp) { //checking the point time is higher than the highest time // 13/01/2014 if temperature, value should be UTI if (lastTimeInFile >= time) { throw (new CerrorRegister(CerrorRegister.ERROR_SERIE_BAD_POINT_TIME)); } try { // 13/01/2014 convert temperature to UTI, if required if ((int)myAxis == Cplot.TEMPERATURE) { CTemperature auxTemp = new CTemperature(0); if (tempUnitsIfTemp == ManRegGlobal.tempunitCELSIUS) { auxTemp.InCelsius(System.Convert.ToInt32(value)); value = auxTemp.UTI; } else if (tempUnitsIfTemp == ManRegGlobal.tempunitFAHRENHEIT) { auxTemp.InFahrenheit(System.Convert.ToInt32(value)); value = auxTemp.UTI; } } //adding the point to the list of points points.Add(new System.Drawing.PointF((float)time, (float)value)); nPoints++; //setting the last point time in the file lastTimeInFile = time; //if the point list is at its maximum capacity, writting into the temp file if (points.Count >= NUM_POINTS_IN_MEMORY) { string text = ""; foreach (System.Drawing.PointF p in points) { text = p.X.ToString() + ";" + p.Y.ToString(); fWriteLoad.WriteLine(text); } points.Clear(); } } catch (Exception ex) { Console.WriteLine("Cserie::addLoadPoint . error:" + ex.Message); } }
private void setMinTemp() { if (curStation != long.MaxValue) { CTemperature T = new CTemperature(0); if (JBC.GetStationTempUnits(curStation) == CTemperature.TemperatureUnit.Celsius) { T.InCelsius(Convert.ToInt32(txtMinTemp.Text)); } if (JBC.GetStationTempUnits(curStation) == CTemperature.TemperatureUnit.Fahrenheit) { T.InFahrenheit(Convert.ToInt32(txtMinTemp.Text)); } JBC.SetStationMinTemp(curStation, T); txtMinTemp.Text = ""; } }
private void setPortSelecTemp(int port) { if (curStation != long.MaxValue) { MaskedTextBox txt = (MaskedTextBox)(this.Controls.Find("txtPort" + System.Convert.ToString(port) + "SelecTemp", true)[0]); CTemperature T = new CTemperature(0); if (JBC.GetStationTempUnits(curStation) == CTemperature.TemperatureUnit.Celsius) { T.InCelsius(Convert.ToInt32(txt.Text)); } if (JBC.GetStationTempUnits(curStation) == CTemperature.TemperatureUnit.Fahrenheit) { T.InFahrenheit(Convert.ToInt32(txt.Text)); } JBC.SetPortToolSelectedTemp(curStation, (Port)(port - 1), T); txt.Text = ""; } }
public void addPoint(double time, double value, string tempUnitsIfTemp) { //checking the point time is higher than the highest time if (lastTimeInFile >= time) { throw (new CerrorRegister(CerrorRegister.ERROR_SERIE_BAD_POINT_TIME)); } try { // 13/01/2014 convert temperature to UTI, if required if ((int)myAxis == Cplot.TEMPERATURE) { CTemperature auxTemp = new CTemperature(0); if (tempUnitsIfTemp == ManRegGlobal.tempunitCELSIUS) { auxTemp.InCelsius(System.Convert.ToInt32(value)); value = auxTemp.UTI; } else if (tempUnitsIfTemp == ManRegGlobal.tempunitFAHRENHEIT) { auxTemp.InFahrenheit(System.Convert.ToInt32(value)); value = auxTemp.UTI; } } //point time is correct, adding it //Dim initTime As ULong = Environment.TickCount And Int32.MaxValue string text = time.ToString() + ";" + value.ToString(); System.IO.StreamWriter fWrite = new System.IO.StreamWriter(tempFile, true); fWrite.WriteLine(text); fWrite.Flush(); fWrite.Close(); //If (Environment.TickCount And Int32.MaxValue) - initTime > 0 Then Debug.Print("saveFile: " & (Environment.TickCount And Int32.MaxValue) - initTime) //adjusting the point list to the end of the sequence and adding the point //initTime = Environment.TickCount And Int32.MaxValue if (points.Count > 0) { if (Math.Round(lastTimeInFile, 3) > Math.Round(System.Convert.ToDouble(points.Last().X), 3)) { //Debug.Print("times: " & lastTimeInFile & " - " & points.Last.X) //point list is not at the end of the sequence loadPointsFromFile(-1, lastTimeInFile); } } //If (Environment.TickCount And Int32.MaxValue) - initTime > 0 Then Debug.Print("loadFile: " & (Environment.TickCount And Int32.MaxValue) - initTime) //adding the point to the list of points points.Add(new System.Drawing.PointF((float)time, (float)value)); nPoints++; //setting the last point time in the file lastTimeInFile = time; //deleting the precious points if memory exceded if (points.Count > NUM_POINTS_IN_MEMORY) { points.RemoveRange(0, points.Count - NUM_POINTS_IN_MEMORY); } } catch (Exception ex) { Console.WriteLine("Cserie::addPoint . error:" + ex.Message); } }