private void button1_Click(object sender, EventArgs e) { double pi = Math.PI; double X2 = 0; double totalinertia = 0; //Outputs double y1 = 0, y2 = 0, y3, y4 = 0, y5 = 0, y6 = 0, y7 = 0, y8 = 0, y16 = 0, y17 = 0, y13 = 0, y12 = 0, y11 = 0, y20 = 0, y9 = 0, y10 = 0, y18 = 0, y19 = 0; int unit = 0, ch1 = 0, ch2 = 0, vso = 0, pso = 0, tgreq = 0; //Inputs double x3 = 0; double x36 = 0; double x2 = System.Convert.ToDouble(numericUpDown1.Value); double x7 = System.Convert.ToDouble(numericUpDown5.Value); double x9; ///// !MATERIAL! double x6 = System.Convert.ToDouble(numericUpDown4.Value); double x5 = System.Convert.ToDouble(numericUpDown3.Value); double x12 = System.Convert.ToDouble(numericUpDown9.Value); double x16 = System.Convert.ToDouble(numericUpDown12.Value); double x13 = System.Convert.ToDouble(numericUpDown10.Value); double x17 = System.Convert.ToDouble(numericUpDown11.Value); double x15; ///// !MATERIAL! double x14 = System.Convert.ToDouble(numericUpDown13.Value); double x19; ///// !MATERIAL! double x18 = System.Convert.ToDouble(numericUpDown14.Value); double x24 = System.Convert.ToDouble(numericUpDown16.Value); double x26 = System.Convert.ToDouble(numericUpDown19.Value); double x27 = System.Convert.ToDouble(numericUpDown20.Value); double x34 = System.Convert.ToDouble(numericUpDown27.Value); double x30 = System.Convert.ToDouble(numericUpDown23.Value); double x31 = System.Convert.ToDouble(numericUpDown24.Value); double x33 = System.Convert.ToDouble(numericUpDown26.Value); double x35 = System.Convert.ToDouble(numericUpDown28.Value); double x11 = System.Convert.ToDouble(numericUpDown8.Value); double x20 = System.Convert.ToDouble(numericUpDown15.Value); double x10 = System.Convert.ToDouble(numericUpDown7.Value); double x8 = System.Convert.ToDouble(numericUpDown6.Value); double x25 = System.Convert.ToDouble(numericUpDown17.Value); double x37 = System.Convert.ToDouble(numericUpDown18.Value); double x32 = System.Convert.ToDouble(numericUpDown18.Value); double x28 = System.Convert.ToDouble(numericUpDown21.Value); double x29 = System.Convert.ToDouble(numericUpDown22.Value); // ********************************************************************************** // * ERRORS * // ********************************************************************************** int error = 0; if (x2 == 0) { MessageBox.Show("Please select the weight of the loads and table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (comboBox1.SelectedIndex == 0 || (comboBox1.SelectedIndex == 5 && numericUpDown2.Value == 0)) { MessageBox.Show("Please select the friction coefficient of the guide", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x5 == 0) { MessageBox.Show("Please enter the diameter for Ball/Lead screw", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x6 == 0) { MessageBox.Show("Please enter the total length for Ball/Lead screw", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x7 == 0) { MessageBox.Show("Please enter the Lead pitch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x8 == 0) { MessageBox.Show("Please enter the efficiency", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (comboBox2.SelectedIndex == 0) { MessageBox.Show("Please select the material for Ball/Lead screw", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x10 == 0) { MessageBox.Show("Please select the breakaway torque of the screw", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x11 == 0) { MessageBox.Show("Please enter external force", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x12 != 0 && (x13 == 0 && x14 == 0 && comboBox3.SelectedIndex == 0)) { MessageBox.Show("Please fill all the required fields for the Primary Pulley", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if ((x13 != 0 || (x14 != 0 && comboBox3.SelectedIndex != 0)) && x12 == 0) { MessageBox.Show("Please fill all the required fields for the Primary Pulley", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x12 == 0 && (x16 != 0 || x17 != 0 || comboBox4.SelectedIndex != 0)) { MessageBox.Show("Please fill all the required fields for the Primary Pulley", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x16 != 0 && (x17 == 0 && x18 == 0 && comboBox4.SelectedIndex == 0)) { MessageBox.Show("Please fill all the required fields for the Secondary Pulley", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if ((x17 != 0 || (x18 != 0 && comboBox4.SelectedIndex != 0)) && x16 == 0) { MessageBox.Show("Please fill all the required fields for the Secondary Pulley", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x20 == 0) { MessageBox.Show("Please enter the Mechanism angle", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (!radioButton1.Checked && !radioButton2.Checked && !radioButton3.Checked) { MessageBox.Show("Please choose an operating condition", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton1.Checked && numericUpDown16.Value == 0) { MessageBox.Show("Please enter the operating speed for Fixed speed operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton1.Checked && numericUpDown17.Value == 0) { MessageBox.Show("Please enter the Accelearation/Deceleration for Fixed speed operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton2.Checked && (numericUpDown19.Value == 0 || numericUpDown20.Value == 0)) { MessageBox.Show("Please enter the operating speeds for Variable speed operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton2.Checked && numericUpDown18.Value == 0) { MessageBox.Show("Please enter the Accelearation/Deceleration for Variable speed operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton3.Checked && x30 == 0) { MessageBox.Show("Please enter the positioning distance for Positioning operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (radioButton3.Checked && x31 == 0) { MessageBox.Show("Please enter the positioning time for Positioning operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x35 == 0) { MessageBox.Show("Please enter the stopping accuracy", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (comboBox5.SelectedIndex == 0) { MessageBox.Show("Please select a safety factor", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } else if (x34 != 0) { //specific operating speed is given. //if x[34] is entered, x[33] has to be entered too. if (x33 == 0) { MessageBox.Show("Please enter the acceleration/deceleration time", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); error = 1; } } if (error == 0) { // ********************************************************************************** // * CALCULATIONS * // ********************************************************************************** //When transmission gear is required tgreq = (x12 != 0) && (x16 != 0) ? 1 : 0; double ratio = tgreq == 1 ? (x16 / x12) : 1; //Densities if (Imperial.Checked) { unit = 1; // Material 1 if (comboBox2.SelectedIndex == 1) { x9 = 0.284; } else if (comboBox2.SelectedIndex == 2) { x9 = 0.289; } else if (comboBox2.SelectedIndex == 3) { x9 = 0.098; } else if (comboBox2.SelectedIndex == 4) { x9 = 0.31; } else if (comboBox2.SelectedIndex == 5) { x9 = 0.06; } else { x9 = 0; } //Material 2 if (comboBox3.SelectedIndex == 1) { x15 = 0.284; } else if (comboBox3.SelectedIndex == 2) { x15 = 0.289; } else if (comboBox3.SelectedIndex == 3) { x15 = 0.098; } else if (comboBox3.SelectedIndex == 4) { x15 = 0.31; } else if (comboBox3.SelectedIndex == 5) { x15 = 0.06; } else { x15 = 0; } //Material 3 if (comboBox4.SelectedIndex == 1) { x19 = 0.284; } else if (comboBox4.SelectedIndex == 2) { x19 = 0.289; } else if (comboBox4.SelectedIndex == 3) { x19 = 0.098; } else if (comboBox4.SelectedIndex == 4) { x19 = 0.31; } else if (comboBox4.SelectedIndex == 5) { x19 = 0.06; } else { x19 = 0; } } else if (Metric.Checked) { unit = 2; // Material 1 if (comboBox2.SelectedIndex == 1) { x9 = 7849.8; } else if (comboBox2.SelectedIndex == 2) { x9 = 7999.493; } else if (comboBox2.SelectedIndex == 3) { x9 = 2712.631; } else if (comboBox2.SelectedIndex == 4) { x9 = 8580.771; } else if (comboBox2.SelectedIndex == 5) { x9 = 1660.794; } else { x9 = 0; } // Material 2 if (comboBox3.SelectedIndex == 1) { x15 = 7849.8; } else if (comboBox3.SelectedIndex == 2) { x15 = 7999.493; } else if (comboBox3.SelectedIndex == 3) { x15 = 2712.631; } else if (comboBox3.SelectedIndex == 4) { x15 = 8580.771; } else if (comboBox3.SelectedIndex == 5) { x15 = 1660.794; } else { x15 = 0; } // Material 3 if (comboBox4.SelectedIndex == 1) { x19 = 7849.8; } else if (comboBox4.SelectedIndex == 2) { x19 = 7999.493; } else if (comboBox4.SelectedIndex == 3) { x19 = 2712.631; } else if (comboBox4.SelectedIndex == 4) { x19 = 8580.771; } else if (comboBox4.SelectedIndex == 5) { x19 = 1660.794; } else { x19 = 0; } } else { x9 = 0; x15 = 0; x19 = 0; } //friction coefficience if (comboBox1.SelectedIndex == 1) { x3 = 0.05; } else if (comboBox1.SelectedIndex == 2) { x3 = 0.1; } else if (comboBox1.SelectedIndex == 3) { x3 = 0.3; } else if (comboBox1.SelectedIndex == 4) { x3 = 0.5; } else if (comboBox1.SelectedIndex == 5) { x3 = System.Convert.ToDouble(numericUpDown2.Value); } //y1, y2, y3, y4, y5 y1 = x2 * 16 * Math.Pow((x7 / (2 * pi)), 2); y1 = (Metric.Checked) ? y1 / (16 * 1000000) : y1; //FOR METRIC THERE IS NO '16' AND TO CONVERT IT FROM mm TO m, DIVIDE BY 1000 y2 = (pi / 32) * (x9) * (x6) * Math.Pow(x5, 4); y2 = (Metric.Checked) ? y2 / Math.Pow(1000, 5) : y2; //convert x6 and x5 from mm to m if (tgreq == 1) { // PRIMARY GEAR y3 if (x13 != 0) { //user knows the primary pulley gear weight. y3 = (1 / 8) * (x13) * 16 * Math.Pow(x12, 2); y3 = (Metric.Checked) ? y3 / (16 * 1000000) : y3; // convert x12 to m and remove 16. } else { //the user is not sure about the primary pulley gear weight, so we ask for thickness and the material type y3 = (pi / 32) * (x15) * (x14) * Math.Pow(x12, 4); y3 = (Metric.Checked) ? y3 / Math.Pow(1000, 5) : y3; //convert x14 &x12 to m. } // SECONDARY GEAR y4 if (x17 != 0) { //user knows the secondary pulley gear weight. y4 = (1 / 8) * x17 * 16 * Math.Pow(x16, 2); y4 = (Metric.Checked) ? y4 / (16 * 1000000) : y4; //convert x16 to m. } else { //the user is not sure about the secondary pulley gear weight, so we ask for thickness and the material type. y4 = (pi / 32) * x19 * (x18) * Math.Pow(x16, 4); y4 = (Metric.Checked) ? y4 / Math.Pow(1000, 5) : y4; //convert x18 & x16 to m. } y5 = (y1 + y2 + y4) * Math.Pow((x12 / x16), 2) + y3; } else { y5 = y1 + y2; } //Required Speed if (radioButton1.Checked) {//Fixed Speed Operation - Y6 y6 = (x24) * (60 / x7) * ratio; //Acceleration Torque (oz-in unit) y9 = y5 * (y6 / (9.55 * x25)); y9 = (Metric.Checked) ? y9 : y9 / (386 * 16); //return isNotApplicable(Ta); } else if (radioButton3.Checked) {//Positioning Operation - Y[6] pso = 1; if (x34 != 0) { //specific operating speed is given. y6 = (x34 / x7) * 60 * ratio; y18 = -1; y19 = -1; } else { x33 = x33 != 0 ? x33 : x31 * 0.25; y6 = ((x30 * ratio) / (x31 - x33)) * (60 / x7); } //totalinertia if ((x28 != 0) && (x29 != 0)) { //when Jo and i are entered (JO*(i^2)) totalinertia = x28 * Math.Pow(x29, 2) + y5; } else if ((x28 != 0) && (x29 == 0)) { // Jo is entered but i(rotor inertia) is entered but gear ratio empty totalinertia = x28 + y5; } else { // When Jo not entered or both Jo and i not entered. totalinertia = 1.2 * y5; } //Acceleration Torque (oz-in unit) y9 = totalinertia * (y6 / (9.55 * x33)); y9 = (Metric.Checked) ? y9 : y9 / (386 * 16); } else if (radioButton3.Checked) {//Variable Speed Operation - Y[7], Y[8] vso = 1; y7 = x26 * (60 / x7) * ratio; y8 = x27 * (60 / x7) * ratio; double Vm = y6 = y7 > y8 ? y7 : y8; //Acceleration Torque (oz-in unit) y9 = y5 * (Vm / (9.55 * x37)); y9 = (Metric.Checked) ? y9 : y9 / (386 * 16); } //Acceleration Torque. y10 = (y9 == -1) ? y9 : y9 * 16;//For imperial only converted to (lb-in unit) //Force X2 = (Metric.Checked) ? x2 * 9.8 : x2; //for metric x2 (which is mass), is multiplied by gravity(9.8). y11 = x11 + (X2 * Math.Sin(x20 * pi / 180)) + (x3 * Math.Cos(x20 * pi / 180)); //Load Torque Tl (lb-in unit). double leadPitch = (Metric.Checked) ? x7 / 1000 : x7; //convert to m for Metric unit. y12 = (((y11 * leadPitch) / (2 * pi)) * 1.1) + x10 * (1 / (x8 * 0.01)) * (1 / ratio); //Load Torque Tl (oz-in unit). y20 = y12 * 16; //converting lb to oz //Required Stopping Accuracy y13 = x35 * (360 / x7) * (ratio); //Required Torque y16 = (y9 + y12) * x36; //Required Torque, (oz-in). Only for imperial. y17 = (y16 == -1) ? y16 : y16 * 16; if (radioButton3.Checked && (x34 == 0)) {//specific operating speed is not required and we have t0, ts and L. x32 = x32 != 0 ? x32 : 0; //Root Mean Square(RMS)Torque, (lb-in), Y[18] y18 = Math.Sqrt(((Math.Pow(y9 + y12, 2) * x33) + (Math.Pow(y12, 2) * (x31 - 2 * x33)) + (Math.Pow(y9 - y12, 2) * x33)) / (x31 + x32)) * x36; if (!double.IsNaN(System.Convert.ToDouble(y18)) && !double.IsInfinity(System.Convert.ToDouble(y18))) { if (Imperial.Checked) { y19 = 16 * y18; } } else { y18 = -1; y19 = -1; } ////Root Mean Square(RMS)Torque, (oz-in), Y[19]. Only for imperial //Y[19] = (Y[18] == "N/A") ? Y[18] : Number(Y[18]) * 16; } //Other Requirement(s) if (checkBox1.Checked) { ch1 = 1; } if (checkBox2.Checked) { ch2 = 1; } if (Metric.Checked) { unit = 2; } else { unit = 1; } //Pressing Button Actions Form2 frm2 = new Form2(y5, y6, y16, y17, y9, y10, y12, y20, y13, unit, ch1, ch2, vso, y7, y8, pso, y18, y19); frm2.Show(); //this.Hide(); } }
private void ToolStripButton3_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); }
private void Button2_Click(object sender, EventArgs e) { Form2 form2 = new Form2(conn); form2.Show(); }
private void button5_Click(object sender, EventArgs e) { Form2 form2 = new Form2(order); form2.Show(); }
private void button1_Click_2(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.ShowDialog(); }
public Form3(Form2 form2) { this.form2 = form2; InitializeComponent(); }
private void add_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(); }
private void cPUTestToolStripMenuItem_Click(object sender, EventArgs e) { Form2 win2 = new Form2(); win2.Show(); }
private void button2_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.ShowDialog(); }
private void FindNumbersToolStripMenuItem_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { Form2 fm = new Form2(); DialogResult dialogResult2 = fm.ShowDialog(); }
private void pictureBox2_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.Show(); }
private void button2_Click(object sender, EventArgs e) { Form2 reg = new Form2(); reg.Show(); }
private void form2NewObject() { form2 = new Form2(); }
private void button1_Click(object sender, EventArgs e) { Form2 newForm = new Form2(this); newForm.Show(); }
private void button4_Click(object sender, EventArgs e) { WindowsFormsApp1.Form2 form = new WindowsFormsApp1.Form2(); form.Show(); }