Esempio n. 1
0
        private void OnSaveResults(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title            = "Save settings in a tc file";
            saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.Filter           = "Tc output file|*.tcout";
            saveFileDialog.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (saveFileDialog.FileName != "")
            {
                trans_calc_input_text  strin  = buildInput();
                trans_calc_result_text result = new trans_calc_result_text();
                result.length_m_1            = res_length_m_1.Text;
                result.length_ft_1           = res_length_ft_1.Text;
                result.buildup_mm_1          = res_thickness_mm_1.Text;
                result.R_1                   = res_resistance_1.Text;
                result.N_1                   = res_turns_1.Text;
                result.N_per_layer_1         = res_turns_per_layer_1.Text;
                result.totalLayers_1         = res_totalLayers_1.Text;
                result.lastLayerTurns_1      = res_lastLayerTurns_1.Text;
                result.mpath_l_m             = res_mpath_m.Text;
                result.awg_max_current_amp_1 = res_max_current_1.Text;
                result.L_1                   = res_L1.Text;
                result.B_max                 = res_Bmax.Text;
                result.H                     = res_H.Text;
                result.I_ex                  = res_Iex.Text;
                result.permeability          = res_permeability.Text;
                result.weight_1              = res_weight_g1.Text;
                result.length_m_2            = res_length_m_2.Text;
                result.length_ft_2           = res_length_ft_2.Text;
                result.buildup_mm_2          = res_thickness_mm_2.Text;
                result.R_2                   = res_resistance_2.Text;
                result.N_2                   = res_turns_2.Text;
                result.N_per_layer_2         = res_turns_per_layer_2.Text;
                result.totalLayers_2         = res_totalLayers_2.Text;
                result.lastLayerTurns_2      = res_lastLayerTurns_2.Text;
                result.awg_max_current_amp_2 = res_max_current_2.Text;
                result.L_2                   = res_L2.Text;
                result.Vout_idle             = res_Vout_idle.Text;
                result.Vout_load             = res_Vout_imax.Text;
                result.Iout_max              = res_Iout.Text;
                result.total_thickness_mm    = res_total_thickness_mm.Text;
                result.weight_2              = res_weight_g2.Text;
                result.turns_ratio           = res_turns_ratio.Text;
                result.wire_csa_ratio        = res_csa_ratio.Text;
                result.wire_total_weight     = res_wire_total_mass.Text;
                result.wire_weight_ratio     = res_wire_weight_ratio.Text;
                result.Ip_full_load          = res_Ip_full_load.Text;
                result.power_VA              = res_powerVA.Text;
                result.total_eq_R            = res_total_eq_R.Text;
                result.regulation            = res_regulation.Text;
                result.AWG1                  = res_AWG1.Text;
                result.AWG2                  = res_AWG2.Text;
                result.warnings              = tc_warnings;
                tc.SaveResults(strin, result, saveFileDialog.FileName);
            }
        }
Esempio n. 2
0
        private void runTransCalc()
        {
            ClearResults();
            try
            {
                res_warnings.Text = "";
                if (edit_max_temp.Text == "")
                {
                    edit_max_temp.Text = "20";
                }

                if (edit_couplingCoeff.Text == "")
                {
                    edit_couplingCoeff.Text = "1";
                }

                if (edit_stackingFactor.Text == "")
                {
                    edit_stackingFactor.Text = "1";
                }

                trans_calc_input_text strin = buildInput();

                trans_calc_result_text result = tc.Calculate(strin);

                SetResultUnits();

                res_length_m_1.Text        = result.length_m_1;
                res_length_ft_1.Text       = result.length_ft_1;
                res_thickness_mm_1.Text    = result.buildup_mm_1;
                res_resistance_1.Text      = result.R_1;
                res_turns_1.Text           = result.N_1;
                res_turns_per_layer_1.Text = result.N_per_layer_1;
                res_totalLayers_1.Text     = result.totalLayers_1;
                res_lastLayerTurns_1.Text  = result.lastLayerTurns_1;
                res_mpath_m.Text           = result.mpath_l_m;
                res_max_current_1.Text     = result.awg_max_current_amp_1;
                res_L1.Text                 = result.L_1;
                res_Bmax.Text               = result.B_max;
                res_H.Text                  = result.H;
                res_Iex.Text                = result.I_ex;
                res_permeability.Text       = result.permeability;
                res_weight_g1.Text          = result.weight_1;
                res_length_m_2.Text         = result.length_m_2;
                res_length_ft_2.Text        = result.length_ft_2;
                res_thickness_mm_2.Text     = result.buildup_mm_2;
                res_resistance_2.Text       = result.R_2;
                res_turns_2.Text            = result.N_2;
                res_turns_per_layer_2.Text  = result.N_per_layer_2;
                res_totalLayers_2.Text      = result.totalLayers_2;
                res_lastLayerTurns_2.Text   = result.lastLayerTurns_2;
                res_max_current_2.Text      = result.awg_max_current_amp_2;
                res_L2.Text                 = result.L_2;
                res_Vout_idle.Text          = result.Vout_idle;
                res_Vout_imax.Text          = result.Vout_load;
                res_Iout.Text               = result.Iout_max;
                res_total_thickness_mm.Text = result.total_thickness_mm;
                res_weight_g2.Text          = result.weight_2;
                res_turns_ratio.Text        = result.turns_ratio;
                res_csa_ratio.Text          = result.wire_csa_ratio;
                res_wire_total_mass.Text    = result.wire_total_weight;
                res_wire_weight_ratio.Text  = result.wire_weight_ratio;
                res_Ip_full_load.Text       = result.Ip_full_load;
                res_powerVA.Text            = result.power_VA;
                res_total_eq_R.Text         = result.total_eq_R;
                res_regulation.Text         = result.regulation;
                res_AWG1.Text               = result.AWG1;
                res_AWG2.Text               = result.AWG2;

                tc_warnings = new List <string>();
                tc_warnings = result.warnings;
                foreach (string msg in result.warnings)
                {
                    res_warnings.Text += msg + "\n";
                }

                if (res_total_thickness_mm.Text != Constants.EmptyValue)
                {
                    res_total_thickness_mm.ForeColor =
                        result.IsWindowExceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                }

                if (res_total_eq_R.Text != Constants.EmptyValue)
                {
                    res_total_eq_R.ForeColor =
                        result.IsMaxResistanceExceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                }

                if (res_Ip_full_load.Text != Constants.EmptyValue)
                {
                    res_Ip_full_load.ForeColor =
                        result.IsAmpacity1Exceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                    res_max_current_1.ForeColor =
                        result.IsAmpacity1Exceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                }

                if (res_Iout.Text != Constants.EmptyValue)
                {
                    res_Iout.ForeColor =
                        result.IsAmpacity2Exceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                    res_max_current_2.ForeColor =
                        result.IsAmpacity2Exceeded ? Color.Red : Color.FromArgb(0, 180, 0);
                }

                button_saveResults.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }