private void addToArrayB_Click(object sender, EventArgs e) { var x = (double)xArrayPosNUD.Value; var timez = (int)arrayTimerNUD.Value; xes.Add(new mvmt(x, timez)); ResponseBox.AppendText("Value: " + x + " Time: " + timez + "\r\n"); }
private void buildSineB_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); Pen pen = new Pen(Brushes.Black, 1.0F); float x1 = 0; float y1 = 0; float y2 = 0; float yEx = 450; float eF = 100; var amplitude = (double)amplitudeNUD.Value; var period = (double)periodNUD.Value; var phase = (double)phaseNUD.Value; var shift = (double)shiftNUD.Value; var largest = 0f; for (float x = 0; x < period; x += 0.01F) { y2 = Siner(amplitude, x, period, Math.PI, 0); if (y2 > largest) { largest = y2; } } sineVals2.Clear(); for (float x = 0; x < Width; x += 0.01F) { y2 = Siner(amplitude, x, period, Math.PI, shift); if (x < period) { sineVals2.Add(y2); } y2 = y2 - (float)shift; y2 /= largest; g.DrawLine(pen, x1 * eF, y1 * eF + yEx, x * eF, y2 * eF + yEx); x1 = x; y1 = y2; } largest = 0; for (int i = 1; i < (sineVals2.Count); i++) { var temp = Math.Abs(sineVals2[i] - sineVals2[i - 1]); if (temp > largest) { largest = temp; } } if (largest > 1) { sineStatusTB.Text = "BAD: " + largest.ToString(); sineStatusTB.BackColor = System.Drawing.Color.Red; } else { sineStatusTB.Text = "GOOD: " + largest.ToString(); sineStatusTB.BackColor = System.Drawing.Color.Green; } foreach (float val in sineVals2) { ResponseBox.AppendText(val.ToString() + ", "); } //ResponseBox.Text = sineVals2.Count.ToString(); maxLBL.Text = "MAX: " + (amplitude + shift).ToString(); minLBL.Text = "MIN: " + ((amplitude + shift) * -1).ToString(); g.DrawLine(pen, 0, yEx, Width, yEx); g.DrawLine(pen, 0, yEx - eF, Width, yEx - eF); g.DrawLine(pen, 0, yEx + eF, Width, yEx + eF); }
private async void SendButton_Click(object sender, EventArgs e) { delayStart = TimeSpan.FromMilliseconds(1300); period = TimeSpan.FromMilliseconds(10); Func <CancellationToken, Task> func; string response; if (x13Button.Checked) { hexapod.udpHex.functionCode = 0x1301; } else { hexapod.udpHex.functionCode = 0x1401; } if (tabControl1.SelectedTab == tabPage1) { if (mvmtCB.Checked) { for (int i = 0; i < xes.Count; i++) { var x = xes[i].xPos; var t = xes[i].timer; response = await hexapod.asyncMove(x, x, x, x, x, x, t); } } else { if (useSineCB.Checked) { var x = sineVals2[0]; response = await hexapod.asyncMove(x, x, x, x, x, x, 1300); func = t => Doer2(); } else { var x = sineVals[0]; response = await hexapod.asyncMove(x, x, x, x, x, x, 1300); func = t => Doer(); } ctr++; tAsync = new TimerAsync(func, delayStart, period, false); tAsync.Start(); //for (int i = 0; i < 30; i++) //{ // var x = sineVals[i]; // if (i == 0) // { // response = await hexapod.asyncMove(x, x, x, x, x, x, 1000); // Thread.Sleep(2000); // } // else // { // response = await hexapod.asyncMove(x, x, x, x, x, x, 1000); // } //} } } else { response = await hexapod.ReadSetting("FN", 28, 1); ResponseBox.AppendText(response + "\r\n"); } }