/// <summary> /// Tworzy nowe obliczenia /// </summary> /// <param name="diving">Zestaw paramertrów nurkowania</param> /// <param name="type">Zestaw tkanek teoretycznych które będą brane pod uwagę</param> public Calculation(ref Data.Diving diving, Compartments.CompartmentsType type) { // Naczytujemy zestaw tkanek na potzreby obliczeń compartments = Compartments.ListOfCompartment.createListOfCompartment(type); if (diving.IsTmxDiving()) { if (compartments.IsHeliumData()) { compartments = null; throw new Exception("Nurkowanie z użyciem mieszanek tlenowych dla zestawu tkanek teoretycznych nie zawierajacych danych dotyczących helu"); } else { bTmx = true; } } calcDiving = diving; upperResultSerch = 0; lowerResultSerch = 0; }
public bool SaveToExcel(string filename, DataType type, Data.Diving diving, Compartments.ListOfCompartment compartments, List <Result.PPraeasureForCompartment> result) { bool ret = true; System.Text.StringBuilder sb = new System.Text.StringBuilder(); XMLSpreadsheet2003Heder(ref sb); if (DataType.All == type || DataType.Gases == type) { addGassesToXMLSpreadsheet2003(ref sb, diving.GasesList); } if (DataType.All == type || DataType.Profile == type) { addProfileToXMLSpreadsheet2003(ref sb, diving.SegmentsList); } if (DataType.All == type || DataType.Compartments == type) { addCompatmentsToXMLSpreadsheet2003(ref sb, compartments, result); } XMLSpreadsheet2003Footer(ref sb); try { StreamWriter streamWriter = new StreamWriter(filename); streamWriter.Write(sb.ToString()); if (null != streamWriter) { streamWriter.Dispose(); } else { ret = false; } } catch (Exception e) { ret = false; } return(ret); }
private void addCompatmentsToXMLSpreadsheet2003(ref System.Text.StringBuilder stringBuilder, Compartments.ListOfCompartment compartments, List <Result.PPraeasureForCompartment> result) { stringBuilder.Append("<Worksheet ss:Name=\"" + AnalizatorNurkowaniaWFA.Properties.Resources.compartmentName + "\">\n"); stringBuilder.Append(" <Table>\n"); stringBuilder.Append(" <Row>\n"); stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.timeWithUnit)); stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.depthWithUnit)); stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.ambientPreasureExcel)); stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.pPN2Excel)); foreach (Compartments.Compartment compartment in compartments.compartment) { stringBuilder.Append(cellXMLSpreadsheet2003(compartment.Name + " HT=" + compartment.HalfTimeN2.ToString("0.0"))); } stringBuilder.Append(" </Row>\n"); foreach (Result.PPraeasureForCompartment ppCompartment in result) { stringBuilder.Append(" <Row>\n"); stringBuilder.Append(cellXMLSpreadsheet2003(ppCompartment.Time)); stringBuilder.Append(cellXMLSpreadsheet2003(ppCompartment.Depth)); stringBuilder.Append(cellXMLSpreadsheet2003(ppCompartment.AmbientPreasure)); stringBuilder.Append(cellXMLSpreadsheet2003(ppCompartment.PreasureN2)); for (int i = 0; i < compartments.compartment.Count(); i++) { stringBuilder.Append(cellXMLSpreadsheet2003(ppCompartment.getN2(i))); } stringBuilder.Append(" </Row>\n"); } stringBuilder.Append(" </Table>\n"); stringBuilder.Append("</Worksheet>\n"); }
private void modifChartCompartments() { List <Result.PPraeasureForCompartment> calculationResult = calculation.result; Compartments.ListOfCompartment compartments = calculation.compartments; chartCompartments.Series.Clear(); System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea = chartCompartments.ChartAreas.First(); chartArea.AxisY.Crossing = 0; chartArea.AxisX.IsStartedFromZero = true; chartArea.AxisY.IsReversed = true; System.Windows.Forms.DataVisualization.Charting.Series series; int i = 0; checkPoints.Enabled = false; foreach (Compartments.Compartment c in compartments.compartment) { chartCompartments.Series.Add(c.Name); series = chartCompartments.Series.Last(); series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; foreach (Result.PPraeasureForCompartment ppfc in calculationResult) { series.Points.AddXY(ppfc.Time, ppfc.getN2(i)); } i++; } if (checkPPN2.Checked) { checkPoints.Enabled = true; chartCompartments.Series.Add("pPN2"); series = chartCompartments.Series.Last(); if (checkPoints.Checked) { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Star10; } else { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.None; } series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; foreach (Result.PPraeasureForCompartment ppfc in calculationResult) { series.Points.AddXY(ppfc.Time, ppfc.PreasureN2); } } if (checkAP.Checked) { checkPoints.Enabled = true; chartCompartments.Series.Add("aP"); series = chartCompartments.Series.Last(); if (checkPoints.Checked) { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Star5; } else { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.None; } series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; foreach (Result.PPraeasureForCompartment ppfc in calculationResult) { series.Points.AddXY(ppfc.Time, ppfc.AmbientPreasure); } } if (checkCeiling.Checked) { checkPoints.Enabled = true; chartCompartments.Series.Add("sufit dekompresyjny"); series = chartCompartments.Series.Last(); if (checkPoints.Checked) { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Cross; } else { series.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.None; } series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; foreach (Result.PPraeasureForCompartment ppfc in calculationResult) { double minCeiling = -Double.MaxValue; i = 0; foreach (Compartments.Compartment c in compartments.compartment) { minCeiling = Math.Max(minCeiling, ppfc.getCeiling(i)); i++; } series.Points.AddXY(ppfc.Time, minCeiling); } } numericUpDownCzas.Maximum = (decimal)calculationResult.Last().Time; if (numericUpDownCzas.Maximum < 1) { numericUpDownCzas.Value = 0; numericUpDownCzas.Enabled = false; } else { numericUpDownCzas.Value = 1; numericUpDownCzas.Enabled = true; } compartmentChart(); chartArea.AxisX.IsLabelAutoFit = false; chartCompartments.Titles.Clear(); chartCompartments.Titles.Add("0").Text = calculation.compartments.Description; chartArea.AxisX.Maximum = (Math.Floor(calculationResult.Last().Time) + 1.0); chartArea.AxisX.Minimum = 0; chartArea.AxisX.Crossing = 0; chartArea.AxisX.MajorGrid.Interval = Math.Ceiling((0.1 * (chartArea.AxisX.Maximum - chartArea.AxisX.Minimum))); chartArea.AxisX.LabelStyle.Interval = chartArea.AxisX.MajorGrid.Interval; chartArea.AxisX.Interval = chartArea.AxisX.MajorGrid.Interval; chartArea.AxisX.Title = AnalizatorNurkowaniaWFA.Properties.Resources.timeWithUnit; chartArea.AxisY.Title = AnalizatorNurkowaniaWFA.Properties.Resources.preasureBar; }