private void Calc_Click(object sender, RoutedEventArgs e)
        {
            bool condDataSet, electricAppDataSet;

            //Condenser
            condDataSet = SetCondenserData();

            // Electrical appliances
            electricAppDataSet = SetElectricalApplianceData();

            if (!condDataSet || !electricAppDataSet)
            {
                ErrorPrinting.PrintError("Couldn't set data");
                return;
            }

            var systemResult = _systemCalculation.CalculateSystem();

            if (!systemResult.HasValue)
            {
                return;
            }

            SystemCOPResultTextBox.Text  = SystemCalculation.GetSysCOP.ToString("F1");
            CondenserPResultTextBox.Text = systemResult.Value.Phe.ToString("F1");

            SetEvaporator();

            _calculationDone = true;
        }
示例#2
0
        public static void ReplaceDot(object sender, TextChangedEventArgs e)
        {
            if (!(sender is TextBox tb))
            {
                ErrorPrinting.PrintError("Replace Dot " + sender.ToString() + " not a TextBox!");
                return;
            }

            using (tb.DeclareChangeBlock())
            {
                foreach (var c in e.Changes)
                {
                    if (c.AddedLength == 0)
                    {
                        continue;
                    }
                    tb.Select(c.Offset, c.AddedLength);
                    if (tb.SelectedText.Contains("."))
                    {
                        tb.SelectedText = tb.SelectedText.Replace('.', ',');
                    }

                    tb.Select(c.Offset + c.AddedLength, 0);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Calculates the (consumed) Electrical capacity
 /// </summary>
 /// <param name="U">Voltage</param>
 /// <param name="I">Current</param>
 /// <returns>Electrical capacity. <see cref="T:null" /> if DLL is not found.</returns>
 public static double?CalcPe(double U, double I)
 {
     try
     {
         return(CalculatePe(U, I));
     }
     catch (DllNotFoundException dllNotFound)
     {
         ErrorPrinting.PrintError(dllNotFound.Message);
         return(null);
     }
 }
示例#4
0
 /// <summary>
 /// Calculates the Heat Capacity of given substance
 /// </summary>
 /// <param name="Qm">mass flow rate [kg/s]</param>
 /// <param name="Cp">specific thermal capacity of given substance [J/KgK]</param>
 /// <param name="T1">temperature [T] or [°C]</param>
 /// <param name="T2">temperature [T] or [°C]</param>
 /// <returns>- Heat Capacity [W]. <see cref="T:null" /> if DLL is not found.</returns>
 public static double?CalcPhe(double Qm, double Cp, double T1, double T2)
 {
     try
     {
         return(CalculatePhe(Qm, Cp, T1, T2));
     }
     catch (DllNotFoundException dllNotFoundException)
     {
         ErrorPrinting.PrintError(dllNotFoundException.Message);
         return(null);
     }
 }
示例#5
0
 /// <summary>
 /// Calculates the COP (Coefficient of Performance)
 /// </summary>
 /// <param name="Phe">Phe Heat Capacity [W]</param>
 /// <param name="Pe">Pe Electrical Capacity [W]</param>
 /// <returns>The COP of the system [-]. <see cref="T:null" /> if DLL is not found.</returns>
 public static double?CalcCOP(double Phe, double Pe)
 {
     try
     {
         return(CalculateCOP(Phe, Pe));
     }
     catch (DllNotFoundException dllNotFound)
     {
         ErrorPrinting.PrintError(dllNotFound.Message);
         return(null);
     }
 }
示例#6
0
 /// <summary>
 /// Calculate the air density
 /// </summary>
 /// <param name="h">height over see</param>
 /// <param name="humidity">humidity in %</param>
 /// <param name="temperature">air temperature in °C</param>
 /// <returns>Calculated density of the air</returns>
 public static double?CalculateAirRho(double h, double humidity, double temperature)
 {
     try
     {
         return(GetAirRho(h, humidity, temperature));
     }
     catch (DllNotFoundException dllNotFound)
     {
         ErrorPrinting.PrintError(dllNotFound.Message);
         throw;
     }
 }
示例#7
0
        /// <summary>
        /// Tries to parse the text of text box to double.
        /// </summary>
        /// <param name="textBox">Text box to parse</param>
        /// <param name="result">Result of the parse</param>
        /// <param name="showWindow">Show error window?</param>
        /// <returns><see cref="T:True" /> if the parse was successful</returns>
        public static bool TryGetValue(TextBox textBox, out uint result, bool showWindow = true)
        {
            if (uint.TryParse(textBox.Text, out uint parseResult))
            {
                result = parseResult;
                return(true);
            }

            if (showWindow)
            {
                ErrorPrinting.PrintError("Couldn't parse " + textBox.Text + " of " + textBox.Name + "!");
            }

            result = 0;
            return(false);
        }
        private void ShowCompareWindowButton_Click(object sender, RoutedEventArgs e)
        {
            if (_compareWindow != null && _compareWindow.IsVisible)
            {
                _compareWindow.Activate();
                return;
            }

            if (_calculationDone)
            {
                _compareWindow = new CompareWindow(SystemCalculation.GetSysCOP, SystemCalculation.GetSysPhe,
                                                   SystemCalculation.GetSysPe);
                _compareWindow.Show();
            }
            else
            {
                ErrorPrinting.PrintError("First Calculate system.");
            }
        }