public async Task <IActionResult> CalculateInitAsync([FromBody] TransverzalneSileEc2Model model)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(BadRequest(
                           new
                {
                    message = "Invalid model",
                    error = allErrors.Select(v => v.ErrorMessage),
                    modelExp = new
                    {
                        Vg = 35,
                        Vq = 50,
                        Ved = 0,
                        b = 25,
                        h = 40,
                        d1 = 4,
                        armLongitudinal = new
                        {
                            kom = 2,
                            diametar = 16,
                        },
                        armtype = "B500B",
                        betonClass = "C25/30",
                        s = 0,
                        m = 0,
                        u_diametar = 0,
                        addArm = new
                        {
                            kom = 1,
                            diametar = 16
                        }
                    }
                }));
            }
            try
            {
                if (model == null)
                {
                    throw new ArgumentException("Pogresno uneti podaci!");
                }
                var Result = new TransverzalneSileEc2ResultModel();
                await Task.Run(() =>
                {
                    Result = trans.CalculateInit(model);
                });

                return(Ok(Result));
            }
            catch (Exception e)
            {
                return(BadRequest(new { error = "Greska: " + e.Message }));
            }
        }
        public async Task <IActionResult> CalculateInitAsync([FromBody] TransverzalneSileEc2Model model)
        {
            try
            {
                if (model == null)
                {
                    throw new ArgumentException("Pogresno uneti podaci!");
                }
                var Result = new TransverzalneSileEc2ResultModel();
                await Task.Run(() =>
                {
                    Result = trans.CalculateInit(model);
                });

                //await Task.Delay(1000);
                return(Ok(Result));
            }
            catch (Exception e)
            {
                return(BadRequest(new { error = "Greska: " + e.Message }));
            }
        }
예제 #3
0
        public TransverzalneSileEc2ResultModel CalculateInit(TransverzalneSileEc2Model trans)
        {
            TransverzalneSileEc2ResultModel Result;
            var beton = new BetonModelEC(trans.betonClass, 1);
            var arm   = ReinforcementType.GetArmatura().Where(n => n.name == trans.armtype).SingleOrDefault();

            if (trans.settings != null)
            {
                beton = new BetonModelEC(trans.betonClass, trans.settings.alfa_cc, trans.settings.alfa_ct, trans.settings.y_c);
                arm   = ReinforcementType.GetArmatura(trans.settings.y_s).Where(n => n.name == trans.armtype).SingleOrDefault();
            }


            beton.ni = 0.85;

            var  armLong = new ReinforcementModelEC(trans.armLongitudinal.diametar, trans.armLongitudinal.kom);
            bool armCalc = false;

            if (trans.u_diametar != 0 && trans.m != 0 && trans.s != 0)
            {
                armCalc = true;
            }


            var g = new ElementGeometryTransversal()
            {
                b    = trans.b,
                h    = trans.h,
                d1   = trans.d1,
                d2   = trans.d1,
                As1  = new ReinforcementModelEC(trans.armLongitudinal.diametar, trans.armLongitudinal.kom),
                unit = UnitDimesionType.cm
            };
            var f = new ForcesTransversal()
            {
                Ved = trans.Ved,
                Vg  = trans.Vg,
                Vq  = trans.Vq
            };
            var m = new Material()
            {
                beton    = beton,
                armatura = arm,
            };

            using (var t = new TransversalCalcEC2(g, f, m))
            {
                if (armCalc)
                {
                    if (trans.alfa == null)
                    {
                        t.CalculateArmature(trans.m, trans.s, new ReinforcementModelEC(trans.u_diametar, 1));
                    }
                    else
                    {
                        t.CalculateArmature(trans.m, trans.s, new ReinforcementModelEC(trans.u_diametar, 1), trans.teta, (double)trans.alfa);
                    }
                }
                Result = new TransverzalneSileEc2ResultModel()
                {
                    Result       = t.ToString(),
                    s            = t.Asw_min == 0 ? trans.s : t.s,
                    ListS        = t.List_s,
                    ListM        = t.List_m,
                    m            = t.Asw_min == 0 ? trans.m : t.m,
                    teta         = t.Θ,
                    alfa         = t.alfa,
                    u_diametar   = trans.u_diametar,
                    addArm_pot   = t.As_add,
                    TransArm_pot = t.Asw,
                    minArm_pot   = t.Asw_min,
                    IskorArm     = t.IskoriscenostArmature / 100,
                    IskorBeton   = t.IskoriscenostBetona / 100,
                    Errors       = t.Errors
                };
            }
            return(Result);
        }
예제 #4
0
        public TransverzalneSileEc2ResultModel CalculateInit(TransverzalneSileEc2Model trans)
        {
            TransverzalneSileEc2ResultModel Result;

            var  beton   = TabeleEC2.BetonClasses.GetBetonClassListEC().Where(n => n.name == trans.betonClass).SingleOrDefault();
            var  arm     = TabeleEC2.ReinforcementType.GetArmatura().Where(n => n.name == trans.armtype).SingleOrDefault();
            var  armLong = new TabeleEC2.Model.ReinforcementModelEC(trans.armLongitudinal.diametar, trans.armLongitudinal.kom);
            bool armCalc = false;

            if (trans.u_diametar != 0 && trans.m != 0 && trans.s != 0)
            {
                armCalc = true;
            }
            if (trans.Ved == 0)
            {
                using (var t = new CalculatorEC2Logic.TransverzalneSileEC2(
                           trans.b,
                           trans.h,
                           beton,
                           arm,
                           armLong,
                           trans.Vg,
                           trans.Vq,
                           trans.d1, 0, 0
                           ))
                {
                    if (armCalc)
                    {
                        t.CalculateArmature(trans.m, trans.s, new TabeleEC2.Model.ReinforcementModelEC(trans.u_diametar, 1));
                    }
                    Result = new TransverzalneSileEc2ResultModel()
                    {
                        Result       = t.ToString(),
                        s            = t.Asw_min == 0 ? trans.s : t.s,
                        ListS        = t.List_s,
                        ListM        = t.List_m,
                        m            = t.Asw_min == 0 ? trans.m : t.m,
                        u_diametar   = trans.u_diametar,
                        addArm_pot   = t.As_add,
                        TransArm_pot = t.Asw,
                        minArm_pot   = t.Asw_min,
                        IskorArm     = t.IskoriscenostArmature,
                        IskorBeton   = t.IskoriscenostBetona,
                        Errors       = t.Errors
                    };
                }
            }
            else
            {
                using (var t = new CalculatorEC2Logic.TransverzalneSileEC2(
                           b: trans.b,
                           h: trans.h,
                           beton: beton,
                           armatura: arm,
                           As1_model: armLong,
                           Ved: trans.Ved,
                           d1: trans.d1, Ng: 0, Nq: 0
                           ))
                {
                    if (armCalc)
                    {
                        t.CalculateArmature(trans.m, trans.s, new TabeleEC2.Model.ReinforcementModelEC(trans.u_diametar, 1));
                    }
                    Result = new TransverzalneSileEc2ResultModel()
                    {
                        Result       = t.ToString(),
                        s            = t.Asw_min == 0 ? trans.s : t.s,
                        ListS        = t.List_s,
                        ListM        = t.List_m,
                        m            = t.Asw_min == 0 ? trans.m : t.m,
                        u_diametar   = trans.u_diametar,
                        addArm_pot   = t.As_add,
                        TransArm_pot = t.Asw,
                        minArm_pot   = t.Asw_min,
                        IskorArm     = t.IskoriscenostArmature,
                        IskorBeton   = t.IskoriscenostBetona,
                        Errors       = t.Errors
                    };
                }
            }

            return(Result);
        }
예제 #5
0
 public TransverzalneSileEc2ResultModel CalculateArm(TransverzalneSileEc2Model trans)
 {
     throw new NotImplementedException();
 }