Config change handler for Diverter, it should be possible to calibrate the analog input.
This commit is contained in:
@@ -8,13 +8,13 @@ namespace TBF.BenchControl
|
||||
public class CmdResponseArgs : EventArgs
|
||||
{
|
||||
public CfgChangeCmd Command;
|
||||
public int Idx1;
|
||||
public int Id; /// Either Idx1(RV) or BitPosition (Div) to identify the component
|
||||
public int Response;
|
||||
|
||||
public CmdResponseArgs(CfgChangeCmd command, int idx1, int response)
|
||||
public CmdResponseArgs(CfgChangeCmd command, int id, int response)
|
||||
{
|
||||
Command = command;
|
||||
Idx1 = idx1;
|
||||
Id = id;
|
||||
Response = response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
/// <summary> Number of water meters </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
/// To be retrieved after the form is closed
|
||||
@@ -25,6 +25,7 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
public bool Completed { get { return completed; } }
|
||||
bool completed;
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
int TextBoxesCount;
|
||||
Label[] labels;
|
||||
ComboBox[] comboBoxes;
|
||||
|
||||
@@ -60,8 +60,12 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.CfgChange)
|
||||
{
|
||||
//diverterCfg.StableTimeMs = tmpcfg.StableTimeMs;
|
||||
//diverterCfg.FlowStableSec = tmpcfg.FlowStableSec;
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
|
||||
{
|
||||
int adc = (int)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
|
||||
// TOTEST
|
||||
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitPosition, adc));
|
||||
}
|
||||
//else if (args.Command == CfgChangeCmd.RVOpenStep)
|
||||
//{
|
||||
@@ -75,12 +79,6 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// // TODO: avoid conflicts
|
||||
// // TOTEST
|
||||
//}
|
||||
//else if (args.Command == CfgChangeCmd.GetRVAdc1 || args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
//{
|
||||
// int adc = (int)controlBoard.AnalogInputRaw(Idx1 - 1, 0);
|
||||
// // TOTEST
|
||||
// DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, adc));
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int BitPosition; /// 0..63
|
||||
public int AdcNr; /// 0..15(?), number of the analog input
|
||||
public int AdcValueToSink; /// 0..1023
|
||||
public int AdcValueToTank; /// 0..1023
|
||||
public int StartingLevel; /// 0..100 in %, threshold for the ADC value to start the test
|
||||
public int StoppingLevel; /// 0..100 in %, threshold for the ADC value to start the test
|
||||
|
||||
@@ -26,6 +29,9 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
Name = "Div";
|
||||
ParentName = "CB";
|
||||
BitPosition = 0;
|
||||
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6
|
||||
AdcValueToSink = 100;
|
||||
AdcValueToTank = 500;
|
||||
StartingLevel = 50;
|
||||
StoppingLevel = 50;
|
||||
}
|
||||
@@ -38,10 +44,13 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}, StartEdge={3}%, StopEdge={4}%",
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}, ADC#={3}, ADC2Sink={4}, ADC2Tank={5}, StartingLevel={6}%, StoppingLevel={7}%",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
BitPosition,
|
||||
AdcNr,
|
||||
AdcValueToSink,
|
||||
AdcValueToTank,
|
||||
StartingLevel,
|
||||
StoppingLevel);
|
||||
}
|
||||
|
||||
+300
-25
@@ -49,6 +49,32 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.leftButton = new System.Windows.Forms.Button();
|
||||
this.rightButton = new System.Windows.Forms.Button();
|
||||
this.updateButton = new System.Windows.Forms.Button();
|
||||
this.adcToTankTextBox = new System.Windows.Forms.TextBox();
|
||||
this.adcTankLabel = new System.Windows.Forms.Label();
|
||||
this.adcToSinkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.adcSinkLabel = new System.Windows.Forms.Label();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.adcTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.setButton2 = new System.Windows.Forms.Button();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.getButton2 = new System.Windows.Forms.Button();
|
||||
this.pctTextBox2 = new System.Windows.Forms.TextBox();
|
||||
this.adcTextBox2 = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.setButton1 = new System.Windows.Forms.Button();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.ADC = new System.Windows.Forms.Label();
|
||||
this.getButton1 = new System.Windows.Forms.Button();
|
||||
this.pctTextBox1 = new System.Windows.Forms.TextBox();
|
||||
this.adcTextBox1 = new System.Windows.Forms.TextBox();
|
||||
this.adcNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
@@ -80,7 +106,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// parentNameLabel
|
||||
//
|
||||
this.parentNameLabel.AutoSize = true;
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(27, 70);
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(27, 67);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
@@ -89,7 +115,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// bitPositionLabel
|
||||
//
|
||||
this.bitPositionLabel.AutoSize = true;
|
||||
this.bitPositionLabel.Location = new System.Drawing.Point(27, 96);
|
||||
this.bitPositionLabel.Location = new System.Drawing.Point(27, 91);
|
||||
this.bitPositionLabel.Name = "bitPositionLabel";
|
||||
this.bitPositionLabel.Size = new System.Drawing.Size(59, 13);
|
||||
this.bitPositionLabel.TabIndex = 5;
|
||||
@@ -98,7 +124,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// bitPositionTextBox
|
||||
//
|
||||
this.bitPositionTextBox.Enabled = false;
|
||||
this.bitPositionTextBox.Location = new System.Drawing.Point(137, 93);
|
||||
this.bitPositionTextBox.Location = new System.Drawing.Point(137, 88);
|
||||
this.bitPositionTextBox.Name = "bitPositionTextBox";
|
||||
this.bitPositionTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.bitPositionTextBox.TabIndex = 6;
|
||||
@@ -107,7 +133,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
//
|
||||
this.parentNameComboBox.Enabled = false;
|
||||
this.parentNameComboBox.FormattingEnabled = true;
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(137, 67);
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(137, 64);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
@@ -115,53 +141,53 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// startingEdgeTextBox
|
||||
//
|
||||
this.startingEdgeTextBox.Enabled = false;
|
||||
this.startingEdgeTextBox.Location = new System.Drawing.Point(137, 118);
|
||||
this.startingEdgeTextBox.Location = new System.Drawing.Point(137, 180);
|
||||
this.startingEdgeTextBox.Name = "startingEdgeTextBox";
|
||||
this.startingEdgeTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.startingEdgeTextBox.TabIndex = 8;
|
||||
this.startingEdgeTextBox.TabIndex = 14;
|
||||
//
|
||||
// startingEdgeLabel
|
||||
//
|
||||
this.startingEdgeLabel.AutoSize = true;
|
||||
this.startingEdgeLabel.Location = new System.Drawing.Point(27, 121);
|
||||
this.startingEdgeLabel.Location = new System.Drawing.Point(27, 183);
|
||||
this.startingEdgeLabel.Name = "startingEdgeLabel";
|
||||
this.startingEdgeLabel.Size = new System.Drawing.Size(71, 13);
|
||||
this.startingEdgeLabel.TabIndex = 7;
|
||||
this.startingEdgeLabel.Text = "Starting Edge";
|
||||
this.startingEdgeLabel.Size = new System.Drawing.Size(68, 13);
|
||||
this.startingEdgeLabel.TabIndex = 13;
|
||||
this.startingEdgeLabel.Text = "Starting level";
|
||||
//
|
||||
// stoppingEdgeTextBox
|
||||
//
|
||||
this.stoppingEdgeTextBox.Enabled = false;
|
||||
this.stoppingEdgeTextBox.Location = new System.Drawing.Point(137, 143);
|
||||
this.stoppingEdgeTextBox.Location = new System.Drawing.Point(137, 203);
|
||||
this.stoppingEdgeTextBox.Name = "stoppingEdgeTextBox";
|
||||
this.stoppingEdgeTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.stoppingEdgeTextBox.TabIndex = 10;
|
||||
this.stoppingEdgeTextBox.TabIndex = 17;
|
||||
//
|
||||
// stoppingEdgeLabel
|
||||
//
|
||||
this.stoppingEdgeLabel.AutoSize = true;
|
||||
this.stoppingEdgeLabel.Location = new System.Drawing.Point(27, 146);
|
||||
this.stoppingEdgeLabel.Location = new System.Drawing.Point(27, 206);
|
||||
this.stoppingEdgeLabel.Name = "stoppingEdgeLabel";
|
||||
this.stoppingEdgeLabel.Size = new System.Drawing.Size(77, 13);
|
||||
this.stoppingEdgeLabel.TabIndex = 9;
|
||||
this.stoppingEdgeLabel.Text = "Stopping Edge";
|
||||
this.stoppingEdgeLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.stoppingEdgeLabel.TabIndex = 16;
|
||||
this.stoppingEdgeLabel.Text = "Stopping level";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(190, 145);
|
||||
this.label2.Location = new System.Drawing.Point(190, 205);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(15, 13);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.TabIndex = 18;
|
||||
this.label2.Text = "%";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(190, 121);
|
||||
this.label1.Location = new System.Drawing.Point(190, 183);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(15, 13);
|
||||
this.label1.TabIndex = 12;
|
||||
this.label1.TabIndex = 15;
|
||||
this.label1.Text = "%";
|
||||
//
|
||||
// startButton
|
||||
@@ -169,7 +195,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.startButton.Location = new System.Drawing.Point(10, 457);
|
||||
this.startButton.Name = "startButton";
|
||||
this.startButton.Size = new System.Drawing.Size(55, 31);
|
||||
this.startButton.TabIndex = 13;
|
||||
this.startButton.TabIndex = 22;
|
||||
this.startButton.Text = "Start";
|
||||
this.startButton.UseVisualStyleBackColor = true;
|
||||
this.startButton.Click += new System.EventHandler(this.startButton_Click);
|
||||
@@ -179,7 +205,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.stopButton.Location = new System.Drawing.Point(71, 457);
|
||||
this.stopButton.Name = "stopButton";
|
||||
this.stopButton.Size = new System.Drawing.Size(55, 31);
|
||||
this.stopButton.TabIndex = 14;
|
||||
this.stopButton.TabIndex = 23;
|
||||
this.stopButton.Text = "Stop";
|
||||
this.stopButton.UseVisualStyleBackColor = true;
|
||||
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
|
||||
@@ -189,7 +215,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.leftButton.Location = new System.Drawing.Point(132, 457);
|
||||
this.leftButton.Name = "leftButton";
|
||||
this.leftButton.Size = new System.Drawing.Size(31, 31);
|
||||
this.leftButton.TabIndex = 15;
|
||||
this.leftButton.TabIndex = 24;
|
||||
this.leftButton.Text = "<--";
|
||||
this.leftButton.UseVisualStyleBackColor = true;
|
||||
this.leftButton.Click += new System.EventHandler(this.leftButton_Click);
|
||||
@@ -199,7 +225,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.rightButton.Location = new System.Drawing.Point(169, 457);
|
||||
this.rightButton.Name = "rightButton";
|
||||
this.rightButton.Size = new System.Drawing.Size(31, 31);
|
||||
this.rightButton.TabIndex = 16;
|
||||
this.rightButton.TabIndex = 25;
|
||||
this.rightButton.Text = "-->";
|
||||
this.rightButton.UseVisualStyleBackColor = true;
|
||||
this.rightButton.Click += new System.EventHandler(this.rightButton_Click);
|
||||
@@ -210,15 +236,235 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.updateButton.Location = new System.Drawing.Point(206, 457);
|
||||
this.updateButton.Name = "updateButton";
|
||||
this.updateButton.Size = new System.Drawing.Size(85, 31);
|
||||
this.updateButton.TabIndex = 17;
|
||||
this.updateButton.TabIndex = 26;
|
||||
this.updateButton.Text = "Update Edge";
|
||||
this.updateButton.UseVisualStyleBackColor = true;
|
||||
this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
|
||||
//
|
||||
// adcToTankTextBox
|
||||
//
|
||||
this.adcToTankTextBox.Enabled = false;
|
||||
this.adcToTankTextBox.Location = new System.Drawing.Point(137, 157);
|
||||
this.adcToTankTextBox.Name = "adcToTankTextBox";
|
||||
this.adcToTankTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.adcToTankTextBox.TabIndex = 12;
|
||||
//
|
||||
// adcTankLabel
|
||||
//
|
||||
this.adcTankLabel.AutoSize = true;
|
||||
this.adcTankLabel.Location = new System.Drawing.Point(27, 160);
|
||||
this.adcTankLabel.Name = "adcTankLabel";
|
||||
this.adcTankLabel.Size = new System.Drawing.Size(94, 13);
|
||||
this.adcTankLabel.TabIndex = 11;
|
||||
this.adcTankLabel.Text = "ADC when to tank";
|
||||
//
|
||||
// adcToSinkTextBox
|
||||
//
|
||||
this.adcToSinkTextBox.Enabled = false;
|
||||
this.adcToSinkTextBox.Location = new System.Drawing.Point(137, 134);
|
||||
this.adcToSinkTextBox.Name = "adcToSinkTextBox";
|
||||
this.adcToSinkTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.adcToSinkTextBox.TabIndex = 10;
|
||||
//
|
||||
// adcSinkLabel
|
||||
//
|
||||
this.adcSinkLabel.AutoSize = true;
|
||||
this.adcSinkLabel.Location = new System.Drawing.Point(27, 137);
|
||||
this.adcSinkLabel.Name = "adcSinkLabel";
|
||||
this.adcSinkLabel.Size = new System.Drawing.Size(92, 13);
|
||||
this.adcSinkLabel.TabIndex = 9;
|
||||
this.adcSinkLabel.Text = "ADC when to sink";
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.label4);
|
||||
this.groupBox4.Controls.Add(this.adcTextBox);
|
||||
this.groupBox4.Location = new System.Drawing.Point(10, 252);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(279, 40);
|
||||
this.groupBox4.TabIndex = 19;
|
||||
this.groupBox4.TabStop = false;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(11, 17);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(32, 13);
|
||||
this.label4.TabIndex = 22;
|
||||
this.label4.Text = "ADC:";
|
||||
//
|
||||
// adcTextBox
|
||||
//
|
||||
this.adcTextBox.Location = new System.Drawing.Point(47, 14);
|
||||
this.adcTextBox.Name = "adcTextBox";
|
||||
this.adcTextBox.Size = new System.Drawing.Size(44, 20);
|
||||
this.adcTextBox.TabIndex = 21;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.setButton2);
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.label5);
|
||||
this.groupBox2.Controls.Add(this.getButton2);
|
||||
this.groupBox2.Controls.Add(this.pctTextBox2);
|
||||
this.groupBox2.Controls.Add(this.adcTextBox2);
|
||||
this.groupBox2.Location = new System.Drawing.Point(10, 362);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(280, 59);
|
||||
this.groupBox2.TabIndex = 21;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Measured value 2";
|
||||
//
|
||||
// setButton2
|
||||
//
|
||||
this.setButton2.Location = new System.Drawing.Point(229, 17);
|
||||
this.setButton2.Name = "setButton2";
|
||||
this.setButton2.Size = new System.Drawing.Size(38, 33);
|
||||
this.setButton2.TabIndex = 5;
|
||||
this.setButton2.Text = "Set";
|
||||
this.setButton2.UseVisualStyleBackColor = true;
|
||||
this.setButton2.Click += new System.EventHandler(this.setButton_Click);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(209, 28);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(15, 13);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "%";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(11, 27);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(32, 13);
|
||||
this.label5.TabIndex = 3;
|
||||
this.label5.Text = "ADC:";
|
||||
//
|
||||
// getButton2
|
||||
//
|
||||
this.getButton2.Location = new System.Drawing.Point(101, 18);
|
||||
this.getButton2.Name = "getButton2";
|
||||
this.getButton2.Size = new System.Drawing.Size(38, 33);
|
||||
this.getButton2.TabIndex = 2;
|
||||
this.getButton2.Text = "Get";
|
||||
this.getButton2.UseVisualStyleBackColor = true;
|
||||
this.getButton2.Click += new System.EventHandler(this.getButton2_Click);
|
||||
//
|
||||
// pctTextBox2
|
||||
//
|
||||
this.pctTextBox2.Location = new System.Drawing.Point(160, 24);
|
||||
this.pctTextBox2.Name = "pctTextBox2";
|
||||
this.pctTextBox2.Size = new System.Drawing.Size(46, 20);
|
||||
this.pctTextBox2.TabIndex = 1;
|
||||
//
|
||||
// adcTextBox2
|
||||
//
|
||||
this.adcTextBox2.Location = new System.Drawing.Point(47, 24);
|
||||
this.adcTextBox2.Name = "adcTextBox2";
|
||||
this.adcTextBox2.Size = new System.Drawing.Size(44, 20);
|
||||
this.adcTextBox2.TabIndex = 0;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.setButton1);
|
||||
this.groupBox1.Controls.Add(this.label6);
|
||||
this.groupBox1.Controls.Add(this.ADC);
|
||||
this.groupBox1.Controls.Add(this.getButton1);
|
||||
this.groupBox1.Controls.Add(this.pctTextBox1);
|
||||
this.groupBox1.Controls.Add(this.adcTextBox1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(10, 298);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(280, 59);
|
||||
this.groupBox1.TabIndex = 20;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Measured value 1";
|
||||
//
|
||||
// setButton1
|
||||
//
|
||||
this.setButton1.Location = new System.Drawing.Point(229, 17);
|
||||
this.setButton1.Name = "setButton1";
|
||||
this.setButton1.Size = new System.Drawing.Size(38, 33);
|
||||
this.setButton1.TabIndex = 5;
|
||||
this.setButton1.Text = "Set";
|
||||
this.setButton1.UseVisualStyleBackColor = true;
|
||||
this.setButton1.Click += new System.EventHandler(this.setButton_Click);
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(209, 28);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(15, 13);
|
||||
this.label6.TabIndex = 4;
|
||||
this.label6.Text = "%";
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
this.ADC.AutoSize = true;
|
||||
this.ADC.Location = new System.Drawing.Point(11, 28);
|
||||
this.ADC.Name = "ADC";
|
||||
this.ADC.Size = new System.Drawing.Size(32, 13);
|
||||
this.ADC.TabIndex = 3;
|
||||
this.ADC.Text = "ADC:";
|
||||
//
|
||||
// getButton1
|
||||
//
|
||||
this.getButton1.Location = new System.Drawing.Point(101, 18);
|
||||
this.getButton1.Name = "getButton1";
|
||||
this.getButton1.Size = new System.Drawing.Size(38, 33);
|
||||
this.getButton1.TabIndex = 2;
|
||||
this.getButton1.Text = "Get";
|
||||
this.getButton1.UseVisualStyleBackColor = true;
|
||||
this.getButton1.Click += new System.EventHandler(this.getButton1_Click);
|
||||
//
|
||||
// pctTextBox1
|
||||
//
|
||||
this.pctTextBox1.Location = new System.Drawing.Point(160, 24);
|
||||
this.pctTextBox1.Name = "pctTextBox1";
|
||||
this.pctTextBox1.Size = new System.Drawing.Size(46, 20);
|
||||
this.pctTextBox1.TabIndex = 1;
|
||||
//
|
||||
// adcTextBox1
|
||||
//
|
||||
this.adcTextBox1.Location = new System.Drawing.Point(47, 24);
|
||||
this.adcTextBox1.Name = "adcTextBox1";
|
||||
this.adcTextBox1.Size = new System.Drawing.Size(44, 20);
|
||||
this.adcTextBox1.TabIndex = 0;
|
||||
//
|
||||
// adcNrTextBox
|
||||
//
|
||||
this.adcNrTextBox.Enabled = false;
|
||||
this.adcNrTextBox.Location = new System.Drawing.Point(137, 111);
|
||||
this.adcNrTextBox.Name = "adcNrTextBox";
|
||||
this.adcNrTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.adcNrTextBox.TabIndex = 8;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(27, 114);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(76, 13);
|
||||
this.label7.TabIndex = 7;
|
||||
this.label7.Text = "Analog input #";
|
||||
//
|
||||
// DiverterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.adcNrTextBox);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.adcToTankTextBox);
|
||||
this.Controls.Add(this.adcTankLabel);
|
||||
this.Controls.Add(this.adcToSinkTextBox);
|
||||
this.Controls.Add(this.adcSinkLabel);
|
||||
this.Controls.Add(this.updateButton);
|
||||
this.Controls.Add(this.rightButton);
|
||||
this.Controls.Add(this.leftButton);
|
||||
@@ -240,6 +486,12 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.Name = "DiverterCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 500);
|
||||
this.Load += new System.EventHandler(this.DiverterCfgCtrl_Load);
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -265,5 +517,28 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
private System.Windows.Forms.Button leftButton;
|
||||
private System.Windows.Forms.Button rightButton;
|
||||
private System.Windows.Forms.Button updateButton;
|
||||
private System.Windows.Forms.TextBox adcToTankTextBox;
|
||||
private System.Windows.Forms.Label adcTankLabel;
|
||||
private System.Windows.Forms.TextBox adcToSinkTextBox;
|
||||
private System.Windows.Forms.Label adcSinkLabel;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox adcTextBox;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Button setButton2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Button getButton2;
|
||||
private System.Windows.Forms.TextBox pctTextBox2;
|
||||
private System.Windows.Forms.TextBox adcTextBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button setButton1;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label ADC;
|
||||
private System.Windows.Forms.Button getButton1;
|
||||
private System.Windows.Forms.TextBox pctTextBox1;
|
||||
private System.Windows.Forms.TextBox adcTextBox1;
|
||||
private System.Windows.Forms.TextBox adcNrTextBox;
|
||||
private System.Windows.Forms.Label label7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,10 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
/// TODO
|
||||
adc1 = config.AdcValueToSink;
|
||||
pct1 = 0;
|
||||
adc2 = config.AdcValueToTank;
|
||||
pct2 = 100;
|
||||
}
|
||||
|
||||
Redraw();
|
||||
@@ -70,6 +73,9 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
nameTextBox.Text = config.Name;
|
||||
bitPositionTextBox.Text = config.BitPosition.ToString();
|
||||
adcNrTextBox.Text = config.AdcNr.ToString();
|
||||
adcToSinkTextBox.Text = config.AdcValueToSink.ToString();
|
||||
adcToTankTextBox.Text = config.AdcValueToTank.ToString();
|
||||
startingEdgeTextBox.Text = config.StartingLevel.ToString();
|
||||
stoppingEdgeTextBox.Text = config.StoppingLevel.ToString();
|
||||
}
|
||||
@@ -79,6 +85,9 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
bitPositionTextBox.Enabled = true;
|
||||
adcNrTextBox.Enabled = true;
|
||||
adcToSinkTextBox.Enabled = true;
|
||||
adcToTankTextBox.Enabled = true;
|
||||
startingEdgeTextBox.Enabled = true;
|
||||
stoppingEdgeTextBox.Enabled = true;
|
||||
}
|
||||
@@ -93,39 +102,153 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
|
||||
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy > 63)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
|
||||
if (!int.TryParse(adcNrTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Analog input #' should be between 0 and 15";
|
||||
}
|
||||
|
||||
if (!int.TryParse(adcToSinkTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'ADC when to sink' should be between 0 and 1023";
|
||||
}
|
||||
|
||||
if (!int.TryParse(adcToTankTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'ADC when to tank' should be between 0 and 1023";
|
||||
}
|
||||
|
||||
if (!int.TryParse(startingEdgeTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Starting Edge' should be between 0 and 100";
|
||||
message += Environment.NewLine + "'Starting Edge' should be between 0 and 100%";
|
||||
}
|
||||
if (!int.TryParse(stoppingEdgeTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Stopping Edge' should be between 0 and 100";
|
||||
message += Environment.NewLine + "'Stopping Edge' should be between 0 and 100%";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
// CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.BitPosition = int.Parse(bitPositionTextBox.Text);
|
||||
config.StartingLevel = int.Parse(startingEdgeTextBox.Text);
|
||||
config.StoppingLevel = int.Parse(stoppingEdgeTextBox.Text);
|
||||
if (!config.Name.Equals(nameTextBox.Text))
|
||||
{
|
||||
config.Name = nameTextBox.Text;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
string parentname = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
if (!config.ParentName.Equals(parentname))
|
||||
{
|
||||
config.ParentName = parentname;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
int tmp = int.Parse(bitPositionTextBox.Text);
|
||||
if (config.BitPosition != tmp)
|
||||
{
|
||||
config.BitPosition = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(adcNrTextBox.Text);
|
||||
if (config.AdcNr != tmp)
|
||||
{
|
||||
config.AdcNr = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(adcToSinkTextBox.Text);
|
||||
if (config.AdcValueToSink != tmp)
|
||||
{
|
||||
config.AdcValueToSink = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(adcToTankTextBox.Text);
|
||||
if (config.AdcValueToTank != tmp)
|
||||
{
|
||||
config.AdcValueToTank = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(startingEdgeTextBox.Text);
|
||||
if (config.StartingLevel != tmp)
|
||||
{
|
||||
config.StartingLevel = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(stoppingEdgeTextBox.Text);
|
||||
if (config.StoppingLevel != tmp)
|
||||
{
|
||||
config.StoppingLevel = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
int adc1;
|
||||
int pct1;
|
||||
|
||||
int adc2;
|
||||
int pct2;
|
||||
|
||||
|
||||
private void getButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc1, config));
|
||||
}
|
||||
|
||||
private void getButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc2, config));
|
||||
}
|
||||
|
||||
private void setButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int tmpPct1;
|
||||
int tmpPct2;
|
||||
if ((int.TryParse(pctTextBox1.Text, out tmpPct1) && (tmpPct1 >= 0) && (tmpPct1 <= 100)) &&
|
||||
(int.TryParse(pctTextBox2.Text, out tmpPct2) && (tmpPct2 >= 0) && (tmpPct2 <= 100)))
|
||||
{
|
||||
pct1 = tmpPct1;
|
||||
pct2 = tmpPct2;
|
||||
UpdateDivAdc();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDivAdc()
|
||||
{
|
||||
if ((adc1 == adc2) || (pct1 == pct2)) return;
|
||||
|
||||
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
|
||||
int adcToSink = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
int adcToTank = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
|
||||
if ((adcToSink >= 0) && (adcToTank >= 0))
|
||||
{
|
||||
adcToSinkTextBox.Text = adcToSink.ToString();
|
||||
adcToTankTextBox.Text = adcToTank.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Do some stuff here
|
||||
@@ -188,18 +311,24 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
public void StartResponseHandler()
|
||||
{
|
||||
Handlers.AdcChangedHandler += delegate(object sndr, CmdResponseArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<CmdResponseArgs>(OnAdcChanged), sndr, args); }
|
||||
else OnAdcChanged(sndr, args);
|
||||
};
|
||||
|
||||
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
|
||||
{
|
||||
//if (args.Command == CfgChangeCmd.GetRVAdc1)
|
||||
//{
|
||||
// adc1 = args.Response;
|
||||
// adcTextBox1.Text = adc1.ToString();
|
||||
//}
|
||||
//else if (args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
//{
|
||||
// adc2 = args.Response;
|
||||
// adcTextBox2.Text = adc2.ToString();
|
||||
//}
|
||||
if (args.Command == CfgChangeCmd.GetAdc1)
|
||||
{
|
||||
adc1 = args.Response;
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetAdc2)
|
||||
{
|
||||
adc2 = args.Response;
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -208,6 +337,14 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
CmdResponseHandler = null;
|
||||
}
|
||||
|
||||
void OnAdcChanged(object sender, CmdResponseArgs data)
|
||||
{
|
||||
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.BitPosition)
|
||||
{
|
||||
adcTextBox.Text = data.Response.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Configuration Change Handling
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
public readonly ControlBoardDev ControlBoard;
|
||||
|
||||
public int Idx1 { get { return RegulValveCfg.Idx1; } } /// 1..7
|
||||
public int DacValueClosed { get { return RegulValveCfg.DacValueClosed; } } /// 0..1023
|
||||
public int DacValueOpen { get { return RegulValveCfg.DacValueOpen; } } /// 0..1023
|
||||
public int DacValueClosed { get { return RegulValveCfg.AdcValueClosed; } } /// 0..1023
|
||||
public int DacValueOpen { get { return RegulValveCfg.AdcValueOpen; } } /// 0..1023
|
||||
public int StableTime { get { return RegulValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
|
||||
public int FlowStableSec { get { return RegulValveCfg.FlowStableSec; } } /// 0..60 sec
|
||||
///
|
||||
@@ -68,7 +68,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
// TODO: avoid conflicts
|
||||
// TOTEST
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetRVAdc1 || args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
|
||||
{
|
||||
int adc = (int)ControlBoard.AnalogInputRaw(Idx1 - 1, 0);
|
||||
RegulValveCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, Idx1, adc));
|
||||
@@ -100,7 +100,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
int adc = (int)ControlBoard.AnalogInputRaw(Idx1 - 1, 0);
|
||||
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetRVAdc, Idx1, adc));
|
||||
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, Idx1, adc));
|
||||
}
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int Idx1; /// 1..8
|
||||
public int DacValueClosed; /// 0..1023
|
||||
public int DacValueOpen; /// 0..1023
|
||||
public int AdcValueClosed; /// 0..1023
|
||||
public int AdcValueOpen; /// 0..1023
|
||||
public int StableTimeMs; /// 200..1500 ms
|
||||
public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions
|
||||
public int FlowStableSec; /// 0..60 sec
|
||||
@@ -35,8 +35,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
Name = "RegulationValve";
|
||||
ParentName = "CB";
|
||||
Idx1 = 1;
|
||||
DacValueClosed = 100;
|
||||
DacValueOpen = 500;
|
||||
AdcValueClosed = 100;
|
||||
AdcValueOpen = 500;
|
||||
StableTimeMs = 500;
|
||||
StoredPositionReuse = false;
|
||||
FlowStableSec = 5;
|
||||
@@ -54,8 +54,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Idx1,
|
||||
DacValueClosed,
|
||||
DacValueOpen,
|
||||
AdcValueClosed,
|
||||
AdcValueOpen,
|
||||
StableTimeMs,
|
||||
StoredPositionReuse,
|
||||
FlowStableSec);
|
||||
|
||||
+44
-44
@@ -37,10 +37,10 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenLabel = new System.Windows.Forms.Label();
|
||||
this.adcClosedLabel = new System.Windows.Forms.Label();
|
||||
this.adcClosedTextBox = new System.Windows.Forms.TextBox();
|
||||
this.adcOpenTextBox = new System.Windows.Forms.TextBox();
|
||||
this.adcOpenLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.stableTimeTextBox = new System.Windows.Forms.TextBox();
|
||||
@@ -125,39 +125,39 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComponentName";
|
||||
//
|
||||
// dacClosedLabel
|
||||
// adcClosedLabel
|
||||
//
|
||||
this.dacClosedLabel.AutoSize = true;
|
||||
this.dacClosedLabel.Location = new System.Drawing.Point(28, 115);
|
||||
this.dacClosedLabel.Name = "dacClosedLabel";
|
||||
this.dacClosedLabel.Size = new System.Drawing.Size(93, 13);
|
||||
this.dacClosedLabel.TabIndex = 7;
|
||||
this.dacClosedLabel.Text = "DAC when Closed";
|
||||
this.adcClosedLabel.AutoSize = true;
|
||||
this.adcClosedLabel.Location = new System.Drawing.Point(28, 115);
|
||||
this.adcClosedLabel.Name = "adcClosedLabel";
|
||||
this.adcClosedLabel.Size = new System.Drawing.Size(93, 13);
|
||||
this.adcClosedLabel.TabIndex = 7;
|
||||
this.adcClosedLabel.Text = "ADC when Closed";
|
||||
//
|
||||
// dacClosedTextBox
|
||||
// adcClosedTextBox
|
||||
//
|
||||
this.dacClosedTextBox.Enabled = false;
|
||||
this.dacClosedTextBox.Location = new System.Drawing.Point(138, 112);
|
||||
this.dacClosedTextBox.Name = "dacClosedTextBox";
|
||||
this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacClosedTextBox.TabIndex = 8;
|
||||
this.adcClosedTextBox.Enabled = false;
|
||||
this.adcClosedTextBox.Location = new System.Drawing.Point(138, 112);
|
||||
this.adcClosedTextBox.Name = "adcClosedTextBox";
|
||||
this.adcClosedTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.adcClosedTextBox.TabIndex = 8;
|
||||
//
|
||||
// dacOpenTextBox
|
||||
// adcOpenTextBox
|
||||
//
|
||||
this.dacOpenTextBox.Enabled = false;
|
||||
this.dacOpenTextBox.Location = new System.Drawing.Point(138, 135);
|
||||
this.dacOpenTextBox.Name = "dacOpenTextBox";
|
||||
this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacOpenTextBox.TabIndex = 10;
|
||||
this.adcOpenTextBox.Enabled = false;
|
||||
this.adcOpenTextBox.Location = new System.Drawing.Point(138, 135);
|
||||
this.adcOpenTextBox.Name = "adcOpenTextBox";
|
||||
this.adcOpenTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.adcOpenTextBox.TabIndex = 10;
|
||||
//
|
||||
// dacOpenLabel
|
||||
// adcOpenLabel
|
||||
//
|
||||
this.dacOpenLabel.AutoSize = true;
|
||||
this.dacOpenLabel.Location = new System.Drawing.Point(28, 138);
|
||||
this.dacOpenLabel.Name = "dacOpenLabel";
|
||||
this.dacOpenLabel.Size = new System.Drawing.Size(87, 13);
|
||||
this.dacOpenLabel.TabIndex = 9;
|
||||
this.dacOpenLabel.Text = "DAC when Open";
|
||||
this.adcOpenLabel.AutoSize = true;
|
||||
this.adcOpenLabel.Location = new System.Drawing.Point(28, 138);
|
||||
this.adcOpenLabel.Name = "adcOpenLabel";
|
||||
this.adcOpenLabel.Size = new System.Drawing.Size(87, 13);
|
||||
this.adcOpenLabel.TabIndex = 9;
|
||||
this.adcOpenLabel.Text = "ADC when Open";
|
||||
//
|
||||
// parentNameComboBox
|
||||
//
|
||||
@@ -221,7 +221,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.groupBox1.Controls.Add(this.getButton1);
|
||||
this.groupBox1.Controls.Add(this.pctTextBox1);
|
||||
this.groupBox1.Controls.Add(this.adcTextBox1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(17, 298);
|
||||
this.groupBox1.Location = new System.Drawing.Point(10, 298);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(280, 59);
|
||||
this.groupBox1.TabIndex = 18;
|
||||
@@ -236,7 +236,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.setButton1.TabIndex = 5;
|
||||
this.setButton1.Text = "Set";
|
||||
this.setButton1.UseVisualStyleBackColor = true;
|
||||
this.setButton1.Click += new System.EventHandler(this.setButton1_Click);
|
||||
this.setButton1.Click += new System.EventHandler(this.setButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@@ -288,7 +288,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.groupBox2.Controls.Add(this.getButton2);
|
||||
this.groupBox2.Controls.Add(this.pctTextBox2);
|
||||
this.groupBox2.Controls.Add(this.adcTextBox2);
|
||||
this.groupBox2.Location = new System.Drawing.Point(17, 362);
|
||||
this.groupBox2.Location = new System.Drawing.Point(10, 362);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(280, 59);
|
||||
this.groupBox2.TabIndex = 19;
|
||||
@@ -303,7 +303,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.setButton2.TabIndex = 5;
|
||||
this.setButton2.Text = "Set";
|
||||
this.setButton2.UseVisualStyleBackColor = true;
|
||||
this.setButton2.Click += new System.EventHandler(this.setButton2_Click);
|
||||
this.setButton2.Click += new System.EventHandler(this.setButton_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@@ -351,7 +351,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.closeButton);
|
||||
this.groupBox3.Controls.Add(this.openButton);
|
||||
this.groupBox3.Location = new System.Drawing.Point(17, 427);
|
||||
this.groupBox3.Location = new System.Drawing.Point(10, 427);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(280, 60);
|
||||
this.groupBox3.TabIndex = 20;
|
||||
@@ -389,7 +389,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.label4);
|
||||
this.groupBox4.Controls.Add(this.adcTextBox);
|
||||
this.groupBox4.Location = new System.Drawing.Point(17, 252);
|
||||
this.groupBox4.Location = new System.Drawing.Point(10, 252);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(279, 40);
|
||||
this.groupBox4.TabIndex = 22;
|
||||
@@ -418,10 +418,10 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
this.Controls.Add(this.stableTimeLabel);
|
||||
this.Controls.Add(this.storedPosReuseCheckBox);
|
||||
this.Controls.Add(this.parentNameComboBox);
|
||||
this.Controls.Add(this.dacOpenTextBox);
|
||||
this.Controls.Add(this.dacOpenLabel);
|
||||
this.Controls.Add(this.dacClosedTextBox);
|
||||
this.Controls.Add(this.dacClosedLabel);
|
||||
this.Controls.Add(this.adcOpenTextBox);
|
||||
this.Controls.Add(this.adcOpenLabel);
|
||||
this.Controls.Add(this.adcClosedTextBox);
|
||||
this.Controls.Add(this.adcClosedLabel);
|
||||
this.Controls.Add(this.positionTextBox);
|
||||
this.Controls.Add(this.positionLabel);
|
||||
this.Controls.Add(this.parentNameLabel);
|
||||
@@ -451,10 +451,10 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.Label dacClosedLabel;
|
||||
private System.Windows.Forms.TextBox dacClosedTextBox;
|
||||
private System.Windows.Forms.TextBox dacOpenTextBox;
|
||||
private System.Windows.Forms.Label dacOpenLabel;
|
||||
private System.Windows.Forms.Label adcClosedLabel;
|
||||
private System.Windows.Forms.TextBox adcClosedTextBox;
|
||||
private System.Windows.Forms.TextBox adcOpenTextBox;
|
||||
private System.Windows.Forms.Label adcOpenLabel;
|
||||
private System.Windows.Forms.ComboBox parentNameComboBox;
|
||||
private System.Windows.Forms.CheckBox storedPosReuseCheckBox;
|
||||
private System.Windows.Forms.TextBox stableTimeTextBox;
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
adc1 = config.DacValueClosed;
|
||||
adc1 = config.AdcValueClosed;
|
||||
pct1 = 0;
|
||||
adc2 = config.DacValueOpen;
|
||||
adc2 = config.AdcValueOpen;
|
||||
pct2 = 100;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
nameTextBox.Text = config.Name;
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
positionTextBox.Text = config.Idx1.ToString();
|
||||
dacClosedTextBox.Text = config.DacValueClosed.ToString();
|
||||
dacOpenTextBox.Text = config.DacValueOpen.ToString();
|
||||
adcClosedTextBox.Text = config.AdcValueClosed.ToString();
|
||||
adcOpenTextBox.Text = config.AdcValueOpen.ToString();
|
||||
stableTimeTextBox.Text = config.StableTimeMs.ToString();
|
||||
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
|
||||
flowStableSecTextBox.Text = config.FlowStableSec.ToString();
|
||||
@@ -90,8 +90,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
positionTextBox.Enabled = true;
|
||||
dacClosedTextBox.Enabled = true;
|
||||
dacOpenTextBox.Enabled = true;
|
||||
adcClosedTextBox.Enabled = true;
|
||||
adcOpenTextBox.Enabled = true;
|
||||
stableTimeTextBox.Enabled = true;
|
||||
storedPosReuseCheckBox.Enabled = true;
|
||||
flowStableSecTextBox.Enabled = true;
|
||||
@@ -114,16 +114,16 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
message += Environment.NewLine + "'Position' should be between 1 and 8";
|
||||
}
|
||||
|
||||
if (!int.TryParse(dacClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
if (!int.TryParse(adcClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'DAC when Closed' should be between 0 and 1023";
|
||||
message += Environment.NewLine + "'ADC when Closed' should be between 0 and 1023";
|
||||
}
|
||||
|
||||
if (!int.TryParse(dacOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
if (!int.TryParse(adcOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'DAC when Open' should be between 0 and 1023";
|
||||
message += Environment.NewLine + "'ADC when Open' should be between 0 and 1023";
|
||||
}
|
||||
|
||||
if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0)
|
||||
@@ -167,17 +167,17 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(dacClosedTextBox.Text);
|
||||
if (config.DacValueClosed != tmp)
|
||||
tmp = int.Parse(adcClosedTextBox.Text);
|
||||
if (config.AdcValueClosed != tmp)
|
||||
{
|
||||
config.DacValueClosed = tmp;
|
||||
config.AdcValueClosed = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
tmp = int.Parse(dacOpenTextBox.Text);
|
||||
if (config.DacValueOpen != tmp)
|
||||
tmp = int.Parse(adcOpenTextBox.Text);
|
||||
if (config.AdcValueOpen != tmp)
|
||||
{
|
||||
config.DacValueOpen = tmp;
|
||||
config.AdcValueOpen = tmp;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
@@ -229,20 +229,15 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
//
|
||||
private void getButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc1, config));
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc1, config));
|
||||
}
|
||||
|
||||
private void getButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc2, config));
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc2, config));
|
||||
}
|
||||
|
||||
private void setButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
setButton2_Click(sender, e); /// Both Save buttons have the same effect
|
||||
}
|
||||
|
||||
private void setButton2_Click(object sender, EventArgs e)
|
||||
private void setButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int tmpPct1;
|
||||
int tmpPct2;
|
||||
@@ -260,13 +255,13 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
if ((adc1 == adc2) || (pct1 == pct2)) return;
|
||||
|
||||
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
|
||||
int dacClosed = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
int dacOpen = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
int adcClosed = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
int adcOpen = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
|
||||
if ((dacClosed >= 0) && (dacOpen >= 0))
|
||||
if ((adcClosed >= 0) && (adcOpen >= 0))
|
||||
{
|
||||
dacClosedTextBox.Text = dacClosed.ToString();
|
||||
dacOpenTextBox.Text = dacOpen.ToString();
|
||||
adcClosedTextBox.Text = adcClosed.ToString();
|
||||
adcOpenTextBox.Text = adcOpen.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,12 +286,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.GetRVAdc1)
|
||||
if (args.Command == CfgChangeCmd.GetAdc1)
|
||||
{
|
||||
adc1 = args.Response;
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
else if (args.Command == CfgChangeCmd.GetAdc2)
|
||||
{
|
||||
adc2 = args.Response;
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
@@ -311,7 +306,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
void OnAdcChanged(object sender, CmdResponseArgs data)
|
||||
{
|
||||
if (data.Command == CfgChangeCmd.GetRVAdc && data.Idx1 == config.Idx1)
|
||||
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.Idx1)
|
||||
{
|
||||
adcTextBox.Text = data.Response.ToString();
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace TBF.BenchControl
|
||||
ValveClose, /// Close a valve
|
||||
RVOpenStep, /// Open a regulation valve
|
||||
RVCloseStep, /// Close a regulation valve
|
||||
GetRVAdc, /// Get regulation valve ADC
|
||||
GetRVAdc1, /// Get regulation valve ADC feedback value #1
|
||||
GetRVAdc2, /// Get regulation valve ADC feedback value #2
|
||||
GetAdc, /// Get regul.valve or diverter ADC
|
||||
GetAdc1, /// Get regul.valve or diverter ADC feedback value #1
|
||||
GetAdc2, /// Get regul.valve or diverter ADC feedback value #2
|
||||
}
|
||||
|
||||
public enum ValveCategory
|
||||
|
||||
Reference in New Issue
Block a user