Exemplo n.º 1
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            NiuJuPID.ResetPIDParam();
            NiuZhenPID.ResetPIDParam();
            WorkSetForm f = new WorkSetForm();

            if (f.ShowDialog() == DialogResult.OK)
            {
                ReadSystemParam();
                SetAllTime(AllTime1, AllTime2);
                wpStart             = new WaitingProc();
                wpStart.MaxProgress = 10;
                WaitingProcFunc wpf = new WaitingProcFunc(WaitingStart);
                if (wpStart.Execute(wpf, "等待电机启动", WaitingType.WithCancel, ""))
                {
                    startDT = DateTime.Now;
                    DateTime dt = DateTime.Now;
                    TimeSpan ts = dt.Subtract(startDT);
                    tbTime1.Visible          = true;
                    tbTime.Visible           = true;
                    tbTime.Text              = ts.ToString(@"hh\:mm\:ss");
                    timer1.Enabled           = true;
                    toolStripButton4.Enabled = false;
                    splitContainer1.Enabled  = true;
                }
            }
        }
Exemplo n.º 2
0
 private void waitTimer_Tick(object sender, EventArgs e)
 {
     ReadDeweData();
     this.Invoke((EventHandler)(delegate
     {
         motorRev = NiuZhenPID.PIDCalc(deweNiuZhen);
         chart1.Series[0].Points.AddY(deweNiuZhen);
         chart1.Series[1].Points.AddY(NiuZhenPID.sp);
         motorTorque = NiuJuPID.PIDCalc(deweNiuJu);
         chart2.Series[0].Points.AddY(deweNiuJu);
         chart2.Series[1].Points.AddY(NiuJuPID.sp);
         listView1.Items[6].SubItems[1].Text = motorRev.ToString("F3");
         listView1.Items[1].SubItems[1].Text = deweNiuZhen.ToString();
         listView2.Items[6].SubItems[1].Text = motorTorque.ToString();
         listView2.Items[1].SubItems[1].Text = deweNiuJu.ToString();
         listView1.Items[2].SubItems[1].Text = (100 * (NiuZhenPID.sp - deweNiuZhen) / NiuZhenPID.sp).ToString("F1");
         listView2.Items[2].SubItems[1].Text = (100 * (NiuJuPID.sp - deweNiuJu) / NiuJuPID.sp).ToString("F1");
         if (NiuZhenPID.bOk)
         {
             listView1.BackColor = Color.GreenYellow;
         }
         else
         {
             listView1.BackColor = SystemColors.Window;
         }
         if (NiuJuPID.bOk)
         {
             listView2.BackColor = Color.GreenYellow;
         }
         else
         {
             listView2.BackColor = SystemColors.Window;
         }
     }));
     SetMotor(motorRev, motorTorque);
     checkPLC();
 }