00001 using System;
00002 using System.Collections.Generic;
00003 using System.ComponentModel;
00004 using System.Data;
00005 using System.Drawing;
00006 using System.Linq;
00007 using System.Text;
00008 using System.Windows.Forms;
00009
00010 namespace PlatformController {
00011 public partial class PidTuner : Form {
00012
00013 PlatformStrategy _strategy;
00014
00015 public PidTuner(ref PlatformStrategy strategy) {
00016 _strategy = strategy;
00017 _strategy.Data.setAutoAvoid(false);
00018
00019 InitializeComponent();
00020 setPointTextBox.Text = _strategy.Data.ThrottleSetpoint.ToString();
00021 kpTextBox.Text = PidControl.Kp.ToString();
00022 kiTextBox.Text = PidControl.Ki.ToString();
00023 kdTextBox.Text = PidControl.Kd.ToString();
00024 }
00025
00026 private void setPidButton_Click(object sender, EventArgs e) {
00027 try {
00028 _strategy.Data.ThrottleSetpoint = int.Parse(setPointTextBox.Text);
00029 PidControl.setPidCoefficients(double.Parse(kpTextBox.Text)
00030 , double.Parse(kiTextBox.Text), double.Parse(kdTextBox.Text));
00031 toolStripStatusLabel1.Text = "ok";
00032 } catch (Exception ex) {
00033 toolStripStatusLabel1.Text = "non-numeric entry";
00034 }
00035 }
00036
00037 private void updateTimer_Tick(object sender, EventArgs e) {
00038 processVariableTextBox.Text = _strategy.Data.CountsPerSecond.ToString();
00039 manipulatedVariableTextBox.Text = _strategy.ManualThrottle.ToString();
00040 pComponentTextBox.Text = PidControl.PComponent.ToString();
00041 iComponentTextBox.Text = PidControl.IComponent.ToString();
00042 dComponentTextBox.Text = PidControl.DComponent.ToString();
00043 }
00044 }
00045 }