Пример #1
0
        public void SaveResults(trans_calc_input_text strin, trans_calc_result_text result, string fileName)
        {
            TransCalcInput input = new TransCalcInput(tc);

            input.ConvertTextToInput(strin);

            using (StreamWriter sw = new StreamWriter(fileName))
            {
                sw.WriteLine("Input:\n");

                sw.WriteLine($"Core size  WxHxL     : {strin.core_W} x {strin.core_H} x {strin.core_L} cm");
                sw.WriteLine($"Ae, WxH              : {strin.Ae_W} x {strin.Ae_H} cm");
                if (strin.window_size != "")
                {
                    sw.WriteLine($"Window size          : {strin.window_size} mm");
                }
                if (input.common.mpath_l_cm > 0.0000001)
                {
                    sw.WriteLine($"Mpath, WxH           : {strin.mpath_W} x {strin.mpath_H} cm");
                }
                if (strin.Bmax != "")
                {
                    sw.WriteLine($"Bmax                 : {strin.Bmax} T");
                }
                if (strin.H != "")
                {
                    sw.WriteLine($"H                    : {strin.H} " + tc.HUnitlsLabel);
                }
                if (strin.permeability != "")
                {
                    sw.WriteLine($"u/u0                 : {strin.permeability}");
                }
                if (strin.I_ex != "")
                {
                    sw.WriteLine($"Iex                  : {strin.I_ex} A");
                }

                sw.WriteLine($"L1/L2 coupling coeff : {strin.coupling_coeff}");
                sw.WriteLine($"Stacking factor      : {strin.stackingFactor}");
                if (strin.insulationThickness != "")
                {
                    sw.WriteLine($"Insulation           : {strin.insulationThickness} mm");
                }
                if (strin.Vout != "")
                {
                    string fullLoad = strin.isVoutAtFullLoad ? "(full load)" : "(idle)";
                    sw.WriteLine($"Vout                 : {strin.Vout} {fullLoad}");
                }
                if (strin.Iout_max != "")
                {
                    sw.WriteLine($"Iout max             : {strin.Iout_max} A");
                }
                sw.WriteLine($"Max temperature      : {strin.maxTemp} " + tc.TempUnitsLabel);
                if (strin.max_eq_R != "")
                {
                    sw.WriteLine($"Max equivalent R     : {strin.max_eq_R}");
                }
                sw.WriteLine();

                sw.WriteLine($"Primary   : {strin.awg1} AWG, Wfactor: {strin.wfactor1}, N: {strin.N1}, " +
                             $"N per layer: {strin.N_per_layer1} C.M. per amp: {strin.ampacity1}");

                if (input.processSecondary)
                {
                    sw.WriteLine($"Secondary : {strin.awg2} AWG, Wfactor: {strin.wfactor2}, N: {strin.N2}, " +
                                 $"N per layer: {strin.N_per_layer2} C.M. per amp: {strin.ampacity2}");
                }

                sw.WriteLine($"\nMains: {input.common.Vin.ToString()}V / {input.common.Freq.ToString()}Hz");

                sw.WriteLine("\n=== Results: =====================================\n");
                sw.WriteLine("Primary:\n");
                sw.WriteLine($"AWG                  : {result.AWG1}");
                sw.WriteLine($"Turns                : {result.N_1}");
                sw.WriteLine($"Turns per layer      : {result.N_per_layer_1}");
                sw.WriteLine($"Total layers         : {result.totalLayers_1}");
                sw.WriteLine($"Last layer turns     : {result.lastLayerTurns_1}");
                sw.WriteLine($"Wire length          : {result.length_m_1} m / {result.length_ft_1} ft");
                sw.WriteLine($"Build-up             : {result.buildup_mm_1} mm");
                sw.WriteLine($"R                    : {result.R_1}");
                if (result.mpath_l_m != Constants.EmptyValue)
                {
                    sw.WriteLine($"Magnetic path        : {result.mpath_l_m} m");
                }
                if (result.L_1 != Constants.EmptyValue)
                {
                    sw.WriteLine($"L                    : {result.L_1} H");
                }
                sw.WriteLine($"Bmax                 : {result.B_max} T");
                if (result.permeability != Constants.EmptyValue)
                {
                    sw.WriteLine($"u/u0                 : {result.permeability}");
                }
                if (result.H != Constants.EmptyValue)
                {
                    sw.WriteLine($"H                    : {result.H} " + tc.HUnitlsLabel);
                }
                if (result.I_ex != Constants.EmptyValue)
                {
                    sw.WriteLine($"Iex                  : {result.I_ex} A");
                }
                if (result.Ip_full_load != Constants.EmptyValue)
                {
                    sw.WriteLine($"Ip, full load        : {result.Ip_full_load} A");
                }
                if (result.awg_max_current_amp_1 != Constants.EmptyValue)
                {
                    sw.WriteLine($"AWG max current      : {result.awg_max_current_amp_1} A");
                }
                sw.WriteLine($"Weight               : {result.weight_1} " + tc.MassUnitsLabel);

                if (input.processSecondary)
                {
                    sw.WriteLine("\nSecondary:\n");
                    sw.WriteLine($"AWG                  : {result.AWG2}");
                    sw.WriteLine($"Turns                : {result.N_2}");
                    sw.WriteLine($"Turns per layer      : {result.N_per_layer_2}");
                    sw.WriteLine($"Total layers         : {result.totalLayers_2}");
                    sw.WriteLine($"Last layer turns     : {result.lastLayerTurns_2}");
                    sw.WriteLine($"Wire length          : {result.length_m_2} m / {result.length_ft_2} ft");
                    sw.WriteLine($"Build-up             : {result.buildup_mm_2} mm");
                    sw.WriteLine($"R                    : {result.R_2}");
                    sw.WriteLine($"Total build-up       : {result.total_thickness_mm} mm");
                    sw.WriteLine($"L                    : {result.L_2} H");
                    sw.WriteLine($"Vout idle            : {result.Vout_idle} V");
                    sw.WriteLine($"Vout full load       : {result.Vout_load} V");
                    sw.WriteLine($"Iout full load       : {result.Iout_max} A");
                    sw.WriteLine($"AWG max current      : {result.awg_max_current_amp_2} A");
                    sw.WriteLine($"Weight               : {result.weight_2} " + tc.MassUnitsLabel);

                    sw.WriteLine($"\nTurns ratio          : {result.turns_ratio}");
                    sw.WriteLine($"Wire c.s.a ratio     : {result.wire_csa_ratio}");
                    sw.WriteLine($"Total weight         : {result.wire_total_weight} " + tc.MassUnitsLabel);
                    sw.WriteLine($"Weight ratio         : {result.wire_weight_ratio}");
                    sw.WriteLine($"Output Power         : {result.power_VA} VA");
                    sw.WriteLine($"Total equivalent R   : {result.total_eq_R}");
                    sw.WriteLine($"% Regulation         : {result.regulation}");
                }
                if (result.warnings.Count > 0)
                {
                    sw.WriteLine("\nWarnings:\n");
                    foreach (string msg in result.warnings)
                    {
                        sw.WriteLine(msg);
                    }
                }
            }
        }
Пример #2
0
 public void SaveResults(trans_calc_input_text strin, trans_calc_result_text result, string fileName)
 {
     _filePersistence.SaveResults(strin, result, fileName);
 }