Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Form1()
- {
- InitializeComponent();
- }
- System.Data.SqlClient.SqlConnection con;
- System.Data.SqlClient.SqlDataAdapter da;
- DataSet ds1;
- DataSet ds2;
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- con = new System.Data.SqlClient.SqlConnection();
- ds1 = new DataSet();
- // ds2 = new DataSet();
- con.ConnectionString ="Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\tabela_awg.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
- double variavel_indutor;
- double variavel_corrente;
- double variavel_fluxo;
- double variavel_densidade;
- double variavel_razao;
- double resposta;
- double espiras;
- double Ae=0;
- double entreferro;
- string nucleo="none";
- double area_fio;
- variavel_indutor = double.Parse(texto_indutor.Text);
- variavel_corrente = double.Parse(texto_ipico.Text);
- variavel_fluxo = double.Parse(texto_fluxo.Text);
- variavel_densidade = double.Parse(texto_densidade.Text);
- variavel_razao = double.Parse(texto_razao.Text);
- resposta = (variavel_indutor * variavel_corrente * variavel_corrente * 10 * 10 * 10 * 10) / (variavel_razao * variavel_fluxo * variavel_densidade);
- if (resposta <= 0.08)
- {
- Ae = 0.312;
- nucleo = "E-20";
- }
- else if (resposta <= 0.48)
- {
- Ae = 0.6;
- nucleo = "E-30/7";
- }
- else if (resposta <= 1.02)
- {
- Ae = 1.2;
- nucleo = "E-30/14";
- }
- else if (resposta <= 2.84)
- {
- Ae = 1.81;
- nucleo = "E-42/15";
- }
- else if (resposta <= 3.77)
- {
- Ae = 2.4;
- nucleo = "E-42/20";
- }
- else if (resposta > 3.77)
- {
- Ae = 3.54;
- nucleo = "E-55";
- }
- espiras = (variavel_indutor * variavel_corrente * 10 * 10 * 10 * 10) / (variavel_fluxo * Ae);
- entreferro = ((espiras*espiras*4*3.1415*Ae)/(variavel_indutor*10*10*10*10*10*10*10*10*10));
- area_fio = (variavel_corrente / variavel_densidade);
- double area_selected=0;
- string leitura = "SELECT ABS(Area-" +area_fio +") as Dist FROM AWG ORDER BY Dist";
- da = new System.Data.SqlClient.SqlDataAdapter(leitura, con);
- con.Open();
- da.Fill(ds1, "Area");
- con.Close();
- con.Dispose();
- //double variavel_linha;
- // string nome_do_fio;
- //int linha_quero = 0;
- //foreach (DataRow dr in ds1.Tables[0].Rows)
- //{
- // int i;
- // for (i = 1; i <= ds1.Tables[0].Columns.Count; i++)
- // {
- // variavel_linha = Convert.ToDouble(dr[i -1]);
- // if (variavel_linha >= area_fio)
- // {
- // area_selected = variavel_linha;
- // linha_quero = i;
- // }
- // }
- //}
- double espiras_round = Math.Round(espiras) + 1;
- double resposta_round = Math.Round(resposta, 3, MidpointRounding.ToEven);
- double entreferro_round = Math.Round(entreferro, 3, MidpointRounding.ToEven);
- MessageBox.Show("AwAe = " + resposta_round.ToString() + " cm^4\nNúcleo = "
- + nucleo + "\nEspiras = "
- + espiras_round.ToString() + " espiras\nEntreferro = "
- + entreferro_round.ToString() + " cm" +
- "\nArea fio = " + area_fio +
- "\nArea normalizada = " + ds1, "Vai enrolar fio!");
Add Comment
Please, Sign In to add comment