Ejemplo n.º 1
0
 public static decimal LRasch(decimal Kf, decimal brasch)
 {
     return
         (KfLowStrategy.LRasch(Kf * brasch));
 }
Ejemplo n.º 2
0
        public void Strat()
        {
            for (int i = 0; i < db.Resistors.Count; i++)
            {
                decimal Kf = Decimal.Parse(db.Resistors[i].Kf, CultureInfo.InvariantCulture);
                decimal P  = Decimal.Parse(db.Resistors[i].P, CultureInfo.InvariantCulture);
                if (10 >= Kf && Kf >= 1)
                {
                    if (db.Resistors[i].GroupNumber == 1)
                    {
                        decimal btochn = KfHighStrategy.BTochn(Kf, YkfDopIgroup);
                        decimal bmochn = KfHighStrategy.BMochn(Kf,
                                                               P, PoIgroup);
                        decimal maximum = KfHighStrategy.Maximum(btochn, bmochn);
                        decimal mil     = KfHighStrategy.Mil(maximum);
                        decimal brasch  = KfHighStrategy.BRasch(mil);
                        decimal lrasch  = KfHighStrategy.LRasch(Kf, brasch);
                        decimal lpoln   = KfHighStrategy.LPoln(lrasch);
                        decimal square  = KfHighStrategy.Square(lpoln, brasch);

                        ws.Cell($"A{i + 2}").Value = db.Resistors[i].Number;
                        ws.Cell($"B{i + 2}").Value = db.Resistors[i].R;
                        ws.Cell($"C{i + 2}").Value = Kf;
                        ws.Cell($"H{i + 2}").Value = brasch;
                        ws.Cell($"I{i + 2}").Value = Math.Round(lrasch, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"J{i + 2}").Value = Math.Round(lpoln, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"K{i + 2}").Value = Math.Round(square, 3, MidpointRounding.AwayFromZero);

                        ws.Cell($"D{i + 2}").Value = Math.Round(btochn, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"E{i + 2}").Value = Math.Round(bmochn, 3, MidpointRounding.AwayFromZero);

                        Console.WriteLine(
                            $"{db.Resistors[i].Number}: bточн: {btochn} | bмощн: {bmochn} | maximum: {maximum} | bрасч: {brasch} | lрасч: {lrasch} | lполн: {lpoln} | lsq: {square}");
                    }
                    else
                    {
                        decimal btochn = KfHighStrategy.BTochn(Kf, YkfDopIIgroup);
                        decimal bmochn = KfHighStrategy.BMochn(Kf,
                                                               P, PoIIgroup);
                        decimal maximum = KfHighStrategy.Maximum(btochn, bmochn);
                        decimal mil     = KfHighStrategy.Mil(maximum);
                        decimal brasch  = KfHighStrategy.BRasch(mil);
                        decimal lrasch  = KfHighStrategy.LRasch(Kf, brasch);
                        decimal lpoln   = KfHighStrategy.LPoln(lrasch);
                        decimal square  = KfHighStrategy.Square(lpoln, brasch);

                        ws.Cell($"A{i + 2}").Value = db.Resistors[i].Number;
                        ws.Cell($"B{i + 2}").Value = db.Resistors[i].R;
                        ws.Cell($"C{i + 2}").Value = Kf;
                        ws.Cell($"H{i + 2}").Value = brasch;
                        ws.Cell($"I{i + 2}").Value = Math.Round(lrasch, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"J{i + 2}").Value = Math.Round(lpoln, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"K{i + 2}").Value = Math.Round(square, 3, MidpointRounding.AwayFromZero);

                        ws.Cell($"D{i + 2}").Value = Math.Round(btochn, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"E{i + 2}").Value = Math.Round(bmochn, 3, MidpointRounding.AwayFromZero);

                        Console.WriteLine(
                            $"{db.Resistors[i].Number}: bточн: {btochn} | bмощн: {bmochn} | maximum: {maximum} | bрасч: {brasch} | lрасч: {lrasch} | lполн: {lpoln} | lsq: {square}");
                    }
                }
                else if ((decimal)0.1 <= Kf && Kf < 1)
                {
                    if (db.Resistors[i].GroupNumber == 1)
                    {
                        decimal ltochn = KfLowStrategy.LTochn(Kf, YkfDopIgroup);
                        decimal lmochn = KfLowStrategy.LMochn(Kf, P, PoIgroup);

                        decimal maximum = KfLowStrategy.Maximum(ltochn, lmochn);
                        decimal mil     = KfLowStrategy.Mil(maximum);
                        decimal lrasch  = KfLowStrategy.LRasch(mil);
                        decimal brasch  = KfLowStrategy.Brasch(lrasch, Kf);
                        decimal lpoln   = KfLowStrategy.LPoln(lrasch);
                        decimal square  = KfLowStrategy.Square(lpoln, brasch);

                        ws.Cell($"A{i + 2}").Value = db.Resistors[i].Number;
                        ws.Cell($"B{i + 2}").Value = db.Resistors[i].R;
                        ws.Cell($"C{i + 2}").Value = Kf;
                        ws.Cell($"H{i + 2}").Value = Math.Round(brasch, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"I{i + 2}").Value = lrasch;
                        ws.Cell($"J{i + 2}").Value = Math.Round(lpoln, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"K{i + 2}").Value = Math.Round(square, 3, MidpointRounding.AwayFromZero);

                        ws.Cell($"F{i + 2}").Value = Math.Round(ltochn, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"G{i + 2}").Value = Math.Round(lmochn, 3, MidpointRounding.AwayFromZero);

                        Console.WriteLine(
                            $"{db.Resistors[i].Number}: lточн: {ltochn} | lмощн: {lmochn} | maximum: {maximum} | lрасч: {lrasch} | bрасч: {brasch} | lполн: {lpoln} | lsq: {square}");
                    }
                    else
                    {
                        decimal ltochn  = KfLowStrategy.LTochn(Kf, YkfDopIIgroup);
                        decimal lmochn  = KfLowStrategy.LMochn(Kf, P, PoIIgroup);
                        decimal maximum = KfLowStrategy.Maximum(ltochn, lmochn);
                        decimal mil     = KfLowStrategy.Mil(maximum);
                        decimal lrasch  = KfLowStrategy.LRasch(mil);
                        decimal brasch  = KfLowStrategy.Brasch(lrasch, Kf);
                        decimal lpoln   = KfLowStrategy.LPoln(lrasch);
                        decimal square  = KfLowStrategy.Square(lpoln, brasch);

                        ws.Cell($"A{i + 2}").Value = db.Resistors[i].Number;
                        ws.Cell($"B{i + 2}").Value = db.Resistors[i].R;
                        ws.Cell($"C{i + 2}").Value = Kf;
                        ws.Cell($"H{i + 2}").Value = Math.Round(brasch, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"I{i + 2}").Value = lrasch;
                        ws.Cell($"J{i + 2}").Value = Math.Round(lpoln, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"K{i + 2}").Value = Math.Round(square, 3, MidpointRounding.AwayFromZero);

                        ws.Cell($"F{i + 2}").Value = Math.Round(ltochn, 3, MidpointRounding.AwayFromZero);
                        ws.Cell($"G{i + 2}").Value = Math.Round(lmochn, 3, MidpointRounding.AwayFromZero);

                        Console.WriteLine(
                            $"{db.Resistors[i].Number}: lточн: {ltochn} | lмощн: {lmochn} | maximum: {maximum} | lрасч: {lrasch} | bрасч: {brasch} | lполн: {lpoln} | lsq: {square}");
                    }
                }
            }
        }