private void timer2_Tick(object sender, EventArgs e) { sw = new System.Diagnostics.Stopwatch(); sw.Start(); float torqueVoltageValue; float troque = float.Parse(pc.AnalogInput(1, out torqueVoltageValue)); //troque = troque / 100; troque_trans = (troque - 2048) / 2048 * 80; settingDegree += 1.8f * oritation; if (settingDegree >= 135) { oritation = -1; } if (settingDegree <= -135) { oritation = 1; } this.lblPositionValue.Text = settingDegree.ToString(); this.lblTorqueValue.Text = troque.ToString(); this.lblTroqueTransValue.Text = troque_trans.ToString(); lpf1.Add(settingDegree); lpf2.Add(troque_trans); //lpf1.Add(180); //lpf2.Add(10); if (lpf1.Count == 400) { lpf1.Remove(lpf1[0]); } if (lpf2.Count == 400) { lpf2.Remove(lpf2[0]); } this.pictureBox1.CreateGraphics().DrawImage(dp1.drawSignalCurve(lpf1, lpf2), 0, 0); this.vf.pbCanvas.CreateGraphics().DrawImage(vf.getImage(settingDegree), 0, 0); this.vf.simpleOpenGlControl1.Refresh(); sw.Stop(); TimeSpan ts = sw.Elapsed; this.lblDebugTime.Text = ts.Milliseconds.ToString(); }
private void timer1_Tick(object sender, EventArgs e) { position = float.Parse(pc.AnalogInput(0, out positionVoltageValue)); troque = float.Parse(pc.AnalogInput(1, out torqueVoltageValue)); tacho = float.Parse(pc.AnalogInput(2, out tachoVoltageValue)); this.lblPosition.Text = position.ToString(); this.lblTorque.Text = troque.ToString(); this.lblTacho.Text = tacho.ToString(); this.lblPositionVoltageValue.Text = positionVoltageValue.ToString("0.000"); this.lblTorqueVoltageValue.Text = torqueVoltageValue.ToString("0.000"); this.lblTachoVoltageValue.Text = tachoVoltageValue.ToString("0.000"); }
private void myTimer() { timeBeginPeriod(1); uint start = timeGetTime(); uint newStart; while (!isTheardCircleClosed) { float positionVoltageValue; endPosition = float.Parse(pc.AnalogInput(0, out positionVoltageValue)); timeCount++; if (timeCount > 100) { if (UpOrDown) { if (endPosition > iniPosition && Math.Abs(endPosition - iniPosition) > 100) { isTheardCircleClosed = true; newStart = timeGetTime(); timeSpent = newStart - start; this.lblTimespan.Text = timeSpent.ToString(); pc.VOutput(0, 2.5f); Close(); timer1.Stop(); t.Abort(); } } else { if (endPosition < iniPosition && Math.Abs(endPosition - iniPosition) > 100) { isTheardCircleClosed = true; newStart = timeGetTime(); timeSpent = newStart - start; this.lblTimespan.Text = timeSpent.ToString(); pc.VOutput(0, 2.5f); Close(); timer1.Stop(); t.Abort(); } } } } }
private void timer1_Tick(object sender, EventArgs e) { position = float.Parse(pc.AnalogInput(0, out positionVoltageValue)); troque = float.Parse(pc.AnalogInput(1, out torqueVoltageValue)); tacho = float.Parse(pc.AnalogInput(2, out tachoVoltageValue)); if (ifStartDebugMode) { position = position / 100; troque = troque / 100; } this.lblPosition.Text = position.ToString(); this.lblTorque.Text = troque.ToString(); this.lblTacho.Text = tacho.ToString(); this.lblPositionVoltageValue.Text = positionVoltageValue.ToString("0.000"); this.lblTorqueVoltageValue.Text = torqueVoltageValue.ToString("0.000"); this.lblTachoVoltageValue.Text = tachoVoltageValue.ToString("0.000"); lpf1.Add(position); lpf2.Add(troque); if (lpf1.Count == 300) { lpf1.Remove(lpf1[0]); } if (lpf2.Count == 300) { lpf2.Remove(lpf2[0]); } this.CreateGraphics().DrawImage(dpl.drawSignalCurve(lpf1, lpf2), 540, 60); this.CreateGraphics().DrawImage(dpl.drawPosition(troque), 540, 420); }
private void timer1_Tick(object sender, EventArgs e) { float positionVoltageValue; float torqueVoltageValue; float position = float.Parse(pc.AnalogInput10(0, out positionVoltageValue)); float troque = float.Parse(pc.AnalogInput(1, out torqueVoltageValue)); //if (true) //{ // position = 1744; // troque = 2862; //} this.lblPositionValue.Text = positionRawData[ii].ToString(); this.lblTorqueValue.Text = torqueRawData[ii].ToString(); if (ii < positionRawData.Count) { lpf1.Add(positionRawData[ii]); lpf2.Add(torqueRawData[ii]); } else { lpf1.Add(positionRawData[0]); lpf2.Add(torqueRawData[0]); } if (lpf1.Count == 900) { lpf1.Remove(lpf1[0]); } if (lpf2.Count == 900) { lpf2.Remove(lpf2[0]); } ii++; this.pictureBox1.CreateGraphics().DrawImage(dp.drawSignalCurve(lpf1, lpf2), 0, 0); }
private void timer2_Tick(object sender, EventArgs e) { float positionVoltageValue; float torqueVoltageValue; float position = float.Parse(pc.AnalogInput10(0, out positionVoltageValue)); float troque = float.Parse(pc.AnalogInput(1, out torqueVoltageValue)); positionForEverySequence[sequenceIndexForExperiment].Add(position); torqueForEverySequence[sequenceIndexForExperiment].Add(troque); if (trainOrTestUsed[sequenceIndexForExperiment]) { if (rbUpT.Checked) { if ((position > 1488 & position < 2000) || (position > 2516 || position < 976)) { punishmentByHeat(); lblPunishmentStateValue.Text = "True"; } else { unPunishmentByHeat(); lblPunishmentStateValue.Text = "False"; } } else { if ((position > 1488 & position < 2000) || (position > 2516 || position < 976)) { unPunishmentByHeat(); lblPunishmentStateValue.Text = "False"; } else { punishmentByHeat(); lblPunishmentStateValue.Text = "True"; } } } else { unPunishmentByHeat(); lblPunishmentStateValue.Text = "False"; } timeIndex++; if (timeIndex == experimentTimeUsed[sequenceIndexForExperiment] * 10) { timeIndex = 0; sequenceIndexForExperiment++; dp2.clearCommunitivePosition(); lpf3.Clear(); lpf4.Clear(); if (sequenceIndexForExperiment == experimentTimeUsed.Count) { timer2.Stop(); this.btnStep3Start.Enabled = true; pc.ClearALLDigitalPort(); OpenLoop(); cbOpenOrClosed.Checked = false; cbOpenOrClosed.Text = "Open"; DataSave(); } else { positionForEverySequence.Add(new List <float>()); torqueForEverySequence.Add(new List <float>()); controls[sequenceIndexForExperiment].BackColor = Color.DarkCyan; } Bitmap imageHere = new Bitmap(imageNow); PictureBox pb = new PictureBox(); float width = this.flpBottomForImageList.Size.Width - 30; float height = (int)(((float)this.pictureBox3.Size.Height / (float)this.pictureBox3.Size.Width) * width); pb.Size = new Size((int)width, (int)height); pb.Image = imageHere; pb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.flpBottomForImageList.Controls.Add(pb); } ////debug mode // position = 721; // troque = 100; lpf3.Add(position); lpf4.Add(troque); if (lpf3.Count == 150) { lpf3.Remove(lpf3[0]); } if (lpf4.Count == 150) { lpf4.Remove(lpf4[0]); } this.pictureBox2.CreateGraphics().DrawImage(dp1.drawSignalCurve(lpf3, lpf4), 0, 0); imageNow = dp2.drawCommunitivePoint(position, ifStartDebugMode, sequenceIndexForExperiment); this.pictureBox3.CreateGraphics().DrawImage(imageNow, 0, 0); }