private void button1_Click(object sender, EventArgs e) { if (!double.TryParse(textBox1.Text, out pid.sp)) { MessageBox.Show("目标值输入有误"); return; } if (!double.TryParse(textBox2.Text, out pid.pgain)) { MessageBox.Show("P值输入有误"); return; } if (!double.TryParse(textBox3.Text, out pid.igain)) { MessageBox.Show("I值输入有误"); return; } if (!double.TryParse(textBox4.Text, out pid.dgain)) { MessageBox.Show("D值输入有误"); return; } if (type == 1) { iniFileOP.Write("System Setting", "NiuZhen_sp", pid.sp.ToString()); iniFileOP.Write(R2.ToString(), R2.ToString() + "_pgain", pid.pgain.ToString()); iniFileOP.Write(R2.ToString(), R2.ToString() + "_igain", pid.igain.ToString()); iniFileOP.Write(R2.ToString(), R2.ToString() + "_dgain", pid.dgain.ToString()); } else if (type == 2) { iniFileOP.Write("System Setting", "NiuJu_sp", pid.sp.ToString()); iniFileOP.Write("System Setting", "NiuJu_pgain", pid.pgain.ToString()); iniFileOP.Write("System Setting", "NiuJu_igain", pid.igain.ToString()); iniFileOP.Write("System Setting", "NiuJu_dgain", pid.dgain.ToString()); } DialogResult = DialogResult.OK; }
private void R2Combox_SelectedIndexChanged(object sender, EventArgs e) { R2 = (_R2)R2Combox.SelectedIndex; fKp.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_pgain"); fKi.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_igain"); fKd.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_dgain"); AllTime1.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime1"); AllTime2.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime2"); OpenTime.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_OpenTime"); }
private void SettingForm_Load(object sender, EventArgs e) { nKp.Text = iniFileOP.Read("System Setting", "NiuJu_pgain"); nKi.Text = iniFileOP.Read("System Setting", "NiuJu_igain"); nKd.Text = iniFileOP.Read("System Setting", "NiuJu_dgain"); njK.Text = iniFileOP.Read("System Setting", "deweNiuJu_k"); njB.Text = iniFileOP.Read("System Setting", "deweNiuJu_b"); nzK.Text = iniFileOP.Read("System Setting", "deweNiuZhen_k"); nzB.Text = iniFileOP.Read("System Setting", "deweNiuZhen_b"); R2Combox.SelectedIndex = 0; R2 = _R2.R160; fKp.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_pgain"); fKi.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_igain"); fKd.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_dgain"); AllTime1.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime1"); AllTime2.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime2"); OpenTime.Text = iniFileOP.Read(R2.ToString(), R2.ToString() + "_OpenTime"); }
private void button4_Click(object sender, EventArgs e) { double x; int t; if (!double.TryParse(fKp.Text, out x)) { MessageBox.Show(R2.ToString() + "_pgain输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_pgain", x.ToString()); if (!double.TryParse(fKi.Text, out x)) { MessageBox.Show(R2.ToString() + "_igain输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_igain", x.ToString()); if (!double.TryParse(fKd.Text, out x)) { MessageBox.Show(R2.ToString() + "_dgain输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_dgain", x.ToString()); if (!int.TryParse(AllTime1.Text, out t)) { MessageBox.Show(R2.ToString() + "_AllTime1输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_AllTime1", t.ToString()); if (!int.TryParse(AllTime2.Text, out t)) { MessageBox.Show(R2.ToString() + "_AllTime2输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_AllTime2", t.ToString()); if (!int.TryParse(OpenTime.Text, out t)) { MessageBox.Show(R2.ToString() + "_OpenTime输入有误"); return; } iniFileOP.Write(R2.ToString(), R2.ToString() + "_OpenTime", t.ToString()); MessageBox.Show("设定质量块参数成功"); }