示例#1
0
        public void Read_User_Input()
        {
            #region USER DATA

            List <string> lst_content = new List <string>(File.ReadAllLines(user_input_file));
            string        kStr        = "";
            MyList        mList       = null;
            string        VarName     = "";

            #endregion
            int indx = -1;
            try
            {
                for (int i = 0; i < lst_content.Count; i++)
                {
                    kStr    = MyList.RemoveAllSpaces(lst_content[i]);
                    mList   = new MyList(kStr, '=');
                    VarName = MyList.RemoveAllSpaces(mList.StringList[0]);

                    #region SWITCH
                    switch (VarName)
                    {
                    case "D":
                        D          = mList.GetDouble(1);
                        txt_D.Text = D.ToString();
                        break;

                    case "CW":
                        CW          = mList.GetDouble(1);
                        txt_CW.Text = CW.ToString();
                        break;

                    case "FP":
                        FP          = mList.GetDouble(1);
                        txt_FP.Text = FP.ToString();
                        break;

                    case "L":
                        L          = mList.GetDouble(1);
                        txt_L.Text = L.ToString();
                        break;

                    case "support_width":
                        support_width          = mList.GetDouble(1);
                        txt_width_support.Text = support_width.ToString();
                        break;

                    case "W":
                        W1          = mList.GetDouble(1);
                        txt_W1.Text = W1.ToString();
                        break;

                    case "conc_grade":
                        conc_grade = mList.GetDouble(1);
                        txt_concrete_grade.Text = conc_grade.ToString();
                        break;

                    case "st_grade":
                        st_grade             = mList.GetDouble(1);
                        txt_steel_grade.Text = st_grade.ToString();
                        break;

                    case "sigma_cb":
                        sigma_cb          = mList.GetDouble(1);
                        txt_sigma_cb.Text = sigma_cb.ToString();
                        break;

                    case "sigma_st":
                        sigma_st          = mList.GetDouble(1);
                        txt_sigma_st.Text = sigma_st.ToString();
                        break;

                    case "m":
                        m          = mList.GetDouble(1);
                        txt_m.Text = m.ToString();
                        break;

                    case "j":
                        j          = mList.GetDouble(1);
                        txt_j.Text = j.ToString();
                        break;

                    case "Q":
                        Q          = mList.GetDouble(1);
                        txt_Q.Text = Q.ToString();
                        break;

                    case "a1":
                        a1          = mList.GetDouble(1);
                        txt_a1.Text = a1.ToString();
                        break;

                    case "b1":
                        b1          = mList.GetDouble(1);
                        txt_b1.Text = b1.ToString();
                        break;

                    case "W1":
                        W1          = mList.GetDouble(1);
                        txt_W1.Text = W1.ToString();
                        break;

                    case "cover":
                        cover          = mList.GetDouble(1);
                        txt_cover.Text = cover.ToString();
                        break;

                    case "delta_c":
                        delta_c          = mList.GetDouble(1);
                        txt_delta_c.Text = delta_c.ToString();
                        break;

                    case "delta_wc":
                        delta_wc          = mList.GetDouble(1);
                        txt_delta_wc.Text = delta_wc.ToString();
                        break;
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            lst_content.Clear();
        }
示例#2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            #region machine parameters
            if (!((50 <= P12) && (P12 <= 2e5)))
            {
                errors.Add(new ValidationResult(errorP12));
            }
            if (!((48 <= U1) && (U1 <= 660)))
            {
                errors.Add(new ValidationResult(errorU1));
            }
            if (!((10 <= f1) && (f1 <= 400)))
            {
                errors.Add(new ValidationResult(errorf1));
            }
            //if (p < 0) errors.Add(new ValidationResult("Error p")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if (!((0 <= Pмех) && (Pмех <= PмехBoundRight(P12))))
            {
                errors.Add(new ValidationResult($"Значение параметра Pмех должно принадлежать [0 : {PмехBoundRight(P12)}]."));
            }
            #endregion
            #region stator parameters
            if (!((50 < Di) && (Di <= 800)))
            {
                errors.Add(new ValidationResult(errorDi));
            }
            if ((!(0 <= ΔГ1) && (ΔГ1 <= 0)))
            {
                errors.Add(new ValidationResult(errorΔГ1));
            }
            if ((Z1 < 0) || !int.TryParse(Z1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorZ1));
            }
            if (!((Get_DaBounds(Di).left <= Da) && (Da < Get_DaBounds(Di).right)))
            {
                errors.Add(new ValidationResult($"Значение параметра Da должно принадлежать [{Math.Round(Get_DaBounds(Di).left, 2)} : {Math.Round(Get_DaBounds(Di).right, 2)})."));
            }
            if ((a1 < 0) || !int.TryParse(a1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errora1));
            }
            if (!int.TryParse(a2.ToString(), out _))
            {
                errors.Add(new ValidationResult(errora2));
            }
            if (!((0 <= a2) && (a2 <= 30)))
            {
                errors.Add(new ValidationResult(errora2));
            }
            if ((W1 < 0) || !int.TryParse(W1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorW1));
            }
            if (W1 % 2 != 0)
            {
                errors.Add(new ValidationResult(errorW1parity));
            }
            if ((Wc < 0) || !int.TryParse(Wc.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorWc));
            }
            if (!((3 <= Δкр) && (Δкр <= 40)))
            {
                errors.Add(new ValidationResult(errorΔкр));
            }
            if ((dиз < 0) || double.IsNaN(dиз))
            {
                errors.Add(new ValidationResult(errordиз));
            }
            if ((qГ < 0) || double.IsNaN(qГ))
            {
                errors.Add(new ValidationResult(errorqГ));
            }
            if (!((3.5 <= bz1) && (bz1 <= 15)))
            {
                errors.Add(new ValidationResult(errorbz1));
            }
            if (!((0 <= h8) && (h8 <= 20)))
            {
                errors.Add(new ValidationResult(errorh8));
            }
            if (!((0 <= h7) && (h7 <= 2)))
            {
                errors.Add(new ValidationResult(errorh7));
            }
            if (!((0 <= h6) && (h6 <= 20)))
            {
                errors.Add(new ValidationResult(errorh6));
            }
            if (!((0.1 <= h5) && (h5 <= 5)))
            {
                errors.Add(new ValidationResult(errorh5));
            }
            if (!((0 <= h3) && (h3 <= 5)))
            {
                errors.Add(new ValidationResult(errorh3));
            }
            if (!((5 <= h4) && (h4 <= 50)))
            {
                errors.Add(new ValidationResult(errorh4));
            }
            //if (!((dиз < ac) && (ac < 2 * dиз))) errors.Add(new ValidationResult($"Значение параметра расчета ac должно принадлежать ({dиз} : {2 * dиз})."));
            if (!(dиз < ac))
            {
                errors.Add(new ValidationResult($"Значение параметра ac должно быть > {dиз}."));
            }
            if (!((0 <= bПН) && (bПН <= bП1Calc(Di, h8, h7, h6, bz1, Z1))))
            {
                errors.Add(new ValidationResult($"Значение параметра bПН должно принадлежать [0 : {Math.Round(bП1Calc(Di, h8, h7, h6, bz1, Z1), 2)}]."));
            }
            if (h1 < 0 || double.IsNaN(h1))
            {
                errors.Add(new ValidationResult(errorh1));
            }
            if (h2 < 0 || double.IsNaN(h2))
            {
                errors.Add(new ValidationResult(errorh2));
            }
            if (!((0.5 <= li) && (li >= 3)))
            {
                errors.Add(new ValidationResult($"Значение параметра li должно принадлежать [{Get_liBounds(U1, I1(P12, U1), Di).left} : " +
                                                $"{Get_liBounds(U1, I1(P12, U1), Di).right}]."));
            }
            if (!((0 <= cз) && (cз <= 200)))
            {
                errors.Add(new ValidationResult(errorcз));
            }
            if (bП < 0 || double.IsNaN(bП))
            {
                errors.Add(new ValidationResult(errorbП));
            }
            if (bП1 < 0 || double.IsNaN(bП1))
            {
                errors.Add(new ValidationResult(errorbП1));
            }
            //if (!((0.36 <= Kзап) && (Kзап <= 0.76))) errors.Add(new ValidationResult(errorKзап));
            if (!((1 <= y1) && (y1 <= 0.5 * Z1 / Convert.ToDouble(p))))
            {
                errors.Add(new ValidationResult($"Значение параметра расчета y1 должно принадлежать [1 : {0.5 * Z1 / Convert.ToDouble(p)}]."));
            }
            if (!((0.5 <= β) && (β <= 0.95)))
            {
                errors.Add(new ValidationResult(errorβ));
            }
            if ((K2 < 0) || double.IsNaN(K2))
            {
                errors.Add(new ValidationResult(errorK2));
            }
            //if (string.IsNullOrEmpty(PR)) errors.Add(new ValidationResult("Error PR.")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if (!((0 <= d1) && (d1 <= bП1Calc(Di, h8, h7, h6, bz1, Z1))))
            {
                errors.Add(
                    new ValidationResult($"Значение параметра расчета d1 должно принадлежать [0 : {Math.Round(bП1Calc(Di, h8, h7, h6, bz1, Z1), 2)}]."));
            }
            if (!((0.9 <= Kfe1) && (Kfe1 <= 1)))
            {
                errors.Add(new ValidationResult(errorKfe1));
            }
            if (!((0.002 <= ρ1x) && (ρ1x <= 0.05)))
            {
                errors.Add(new ValidationResult(errorρ1x));
            }
            if ((ρРУБ < 0) || double.IsNaN(ρРУБ))
            {
                errors.Add(new ValidationResult(errorρРУБ));
            }
            if (!((ρ1x <= ρ1Г) && (ρ1Г <= 0.1235)))
            {
                errors.Add(new ValidationResult($"Значение параметра расчета ρ1Г должно принадлежать [{ρ1x} : 0.1235]."));
            }
            if (!((0 <= B) && (B <= 20)))
            {
                errors.Add(new ValidationResult(errorB));
            }
            if ((p10_50 < 0) || double.IsNaN(p10_50))
            {
                errors.Add(new ValidationResult(errorp10_50));
            }
            #endregion
            #region rotor parameters
            if (!((0 <= ΔГ2) && (ΔГ2 <= 5)))
            {
                errors.Add(new ValidationResult(errorΔГ2));
            }
            //if (!((DpстBoundCalculation - 5 <= Dpст) && (Dpст < DpстBoundCalculation - 0.1)))
            //    errors.Add(new ValidationResult($"Значение параметра Dp.ст должно принадлежать [{ Math.Round(DpстBoundCalculation - 5, 2) } : { Math.Round(DpстBoundCalculation - 0.1, 2)})."));
            if (double.IsNaN(Dpст) || Dpст < 0)
            {
                errors.Add(new ValidationResult(errorDpст));
            }
            //if (string.IsNullOrEmpty(bСК)) errors.Add(new ValidationResult("Error bСК.")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if ((Z2 < 0) || !int.TryParse(Z2.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorZ2));
            }

            if (!((0.01 <= ρ2Г) && (ρ2Г <= 0.2)))
            {
                errors.Add(new ValidationResult(errorρ2Г));
            }
            if (!((0.9 <= Kfe2) && (Kfe2 <= 1)))
            {
                errors.Add(new ValidationResult(errorKfe2));
            }
            //if (!((0.125 * Get_Dp(Dpст, ΔГ2) <= hp) && (hp <= 0.375 * Get_Dp(Dpст, ΔГ2))))
            //    errors.Add(new ValidationResult($"Значение параметра hp должно принадлежать {Get_hpBounds(Dpст, ΔГ2)}."));
            if (hp < 0 || double.IsNaN(hp))
            {
                errors.Add(new ValidationResult(errorhp));
            }
            #endregion

            return(errors);
        }
 public override string ToString()
 {
     return(string.Format("{0},{1},{2}", Q1.ToString("G3"), W1.ToString("G3"), W2.ToString("G3")));
 }