Diverter test from Components -> Edit ... More
This commit is contained in:
@@ -10,6 +10,10 @@ namespace TBF.BenchControl.Elde
|
||||
None = 0, /// Do nothing, just transfer data (route, etc.)
|
||||
Start = 1, /// Start the measurement
|
||||
Stop = 2, /// Stop the measurement
|
||||
ReadDivTransition = 4,
|
||||
ReadExtremasOfPulses = 6,
|
||||
ReadShapesOfPulses = 7,
|
||||
ResetShapesOfPulses = 8,
|
||||
}
|
||||
|
||||
#if FUZHOU300 || PT200IL || TORINO50 || BADGER_MALA_TRAT
|
||||
|
||||
@@ -67,6 +67,42 @@ namespace TBF.BenchControl.Elde
|
||||
bool emergencyStop;
|
||||
bool previousEmergencyStop;
|
||||
|
||||
|
||||
|
||||
private int flowmeterNr4DiverterTest;
|
||||
private bool scheduleDiverterToTank;
|
||||
private bool scheduleDiverterToSink;
|
||||
private bool scheduleReadDiverterTransition;
|
||||
///
|
||||
public void DiverterToTank(int flowmeterNr)
|
||||
{
|
||||
if (!scheduleDiverterToSink && !scheduleReadDiverterTransition && !emergencyStop)
|
||||
{
|
||||
flowmeterNr4DiverterTest = flowmeterNr;
|
||||
scheduleDiverterToTank = true;
|
||||
}
|
||||
}
|
||||
///
|
||||
public void DiverterToSink(int flowmeterNr)
|
||||
{
|
||||
if (!scheduleDiverterToTank && !scheduleReadDiverterTransition && !emergencyStop)
|
||||
{
|
||||
flowmeterNr4DiverterTest = flowmeterNr;
|
||||
scheduleDiverterToSink = true;
|
||||
}
|
||||
}
|
||||
///
|
||||
public void ReadDiverterTransition(int flowmeterNr)
|
||||
{
|
||||
if (!scheduleDiverterToTank && !scheduleDiverterToSink && !emergencyStop)
|
||||
{
|
||||
flowmeterNr4DiverterTest = flowmeterNr;
|
||||
scheduleReadDiverterTransition = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> State of valves sent out - buffered by the last SendCommand() </summary>
|
||||
public ulong Route { get { return route; } }
|
||||
|
||||
@@ -239,7 +275,31 @@ ulong valvesToInvert,
|
||||
this.cmd = Command.Stop;
|
||||
this.stopDevs = StopDevs.All;
|
||||
}
|
||||
else
|
||||
else if (scheduleDiverterToTank)
|
||||
{
|
||||
/// Reset all SendCommand() arguments
|
||||
sendCommandFlag = true;
|
||||
this.cmd = Command.Start;
|
||||
this.stopDevs = 0;
|
||||
scheduleDiverterToTank = false;
|
||||
}
|
||||
else if (scheduleDiverterToSink)
|
||||
{
|
||||
/// Reset all SendCommand() arguments
|
||||
sendCommandFlag = true;
|
||||
this.cmd = Command.Stop;
|
||||
this.stopDevs = StopDevs.Diverter;
|
||||
scheduleDiverterToSink = false;
|
||||
}
|
||||
else if (scheduleReadDiverterTransition)
|
||||
{
|
||||
/// Reset all SendCommand() arguments
|
||||
sendCommandFlag = true;
|
||||
this.cmd = Command.ReadDivTransition;
|
||||
this.stopDevs = 0;
|
||||
scheduleReadDiverterTransition = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Reset all SendCommand() arguments
|
||||
sendCommandFlag = false;
|
||||
|
||||
@@ -67,18 +67,39 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
// TOTEST
|
||||
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitPosition, adc));
|
||||
}
|
||||
//else if (args.Command == CfgChangeCmd.RVOpenStep)
|
||||
//{
|
||||
// controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { 2.0f, 2.0f }, StableTime);
|
||||
// // TODO: avoid conflicts
|
||||
// // TOTEST
|
||||
//}
|
||||
//else if (args.Command == CfgChangeCmd.RVCloseStep)
|
||||
//{
|
||||
// controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { -2.0f, -2.0f }, StableTime);
|
||||
// // TODO: avoid conflicts
|
||||
// // TOTEST
|
||||
//}
|
||||
else if (args.Command == CfgChangeCmd.DivToTank)
|
||||
{
|
||||
if (Name.Contains("1")) /// TODO: Put flowmeter# into config
|
||||
{
|
||||
controlBoard.DiverterToTank(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
controlBoard.DiverterToTank(3);
|
||||
}
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.DivToSink)
|
||||
{
|
||||
if (Name.Contains("1")) /// TODO: Put flowmeter# into config
|
||||
{
|
||||
controlBoard.DiverterToSink(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
controlBoard.DiverterToSink(3);
|
||||
}
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.ReadDivTransition)
|
||||
{
|
||||
if (Name.Contains("1")) /// TODO: Put flowmeter# into config
|
||||
{
|
||||
controlBoard.ReadDiverterTransition(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
controlBoard.ReadDiverterTransition(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.startButton = new System.Windows.Forms.Button();
|
||||
this.stopButton = new System.Windows.Forms.Button();
|
||||
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();
|
||||
@@ -210,26 +208,6 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
this.stopButton.UseVisualStyleBackColor = true;
|
||||
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
|
||||
//
|
||||
// leftButton
|
||||
//
|
||||
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 = 24;
|
||||
this.leftButton.Text = "<--";
|
||||
this.leftButton.UseVisualStyleBackColor = true;
|
||||
this.leftButton.Click += new System.EventHandler(this.leftButton_Click);
|
||||
//
|
||||
// rightButton
|
||||
//
|
||||
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 = 25;
|
||||
this.rightButton.Text = "-->";
|
||||
this.rightButton.UseVisualStyleBackColor = true;
|
||||
this.rightButton.Click += new System.EventHandler(this.rightButton_Click);
|
||||
//
|
||||
// updateButton
|
||||
//
|
||||
this.updateButton.Enabled = false;
|
||||
@@ -466,8 +444,6 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
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);
|
||||
this.Controls.Add(this.stopButton);
|
||||
this.Controls.Add(this.startButton);
|
||||
this.Controls.Add(this.label1);
|
||||
@@ -514,8 +490,6 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button startButton;
|
||||
private System.Windows.Forms.Button stopButton;
|
||||
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;
|
||||
|
||||
@@ -78,6 +78,11 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
adcToTankTextBox.Text = config.AdcValueToTank.ToString();
|
||||
startingEdgeTextBox.Text = config.StartingLevel.ToString();
|
||||
stoppingEdgeTextBox.Text = config.StoppingLevel.ToString();
|
||||
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
pctTextBox1.Text = pct1.ToString();
|
||||
pctTextBox2.Text = pct2.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
@@ -250,51 +255,21 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Do some stuff here
|
||||
///
|
||||
enum EdgeSel { NoEdge, StartEdge, StopEdge };
|
||||
EdgeSel lastTestedEdge = EdgeSel.NoEdge;
|
||||
int cursorPosition = 0;
|
||||
int currentEdgeLevel = 50; /// Edge level 0..100 in %
|
||||
|
||||
private void startButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
lastTestedEdge = EdgeSel.StartEdge;
|
||||
updateButton.Enabled = true;
|
||||
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.DivToTank, config));
|
||||
}
|
||||
|
||||
private void stopButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
lastTestedEdge = EdgeSel.StopEdge;
|
||||
updateButton.Enabled = true;
|
||||
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.DivToSink, config));
|
||||
|
||||
}
|
||||
|
||||
private void leftButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (currentEdgeLevel > 0) currentEdgeLevel--;
|
||||
}
|
||||
|
||||
private void rightButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (currentEdgeLevel < 100) currentEdgeLevel++;
|
||||
}
|
||||
|
||||
private void updateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (lastTestedEdge)
|
||||
{
|
||||
case EdgeSel.StartEdge:
|
||||
startingEdgeTextBox.Text = currentEdgeLevel.ToString();
|
||||
break;
|
||||
case EdgeSel.StopEdge:
|
||||
stoppingEdgeTextBox.Text = currentEdgeLevel.ToString();
|
||||
break;
|
||||
case EdgeSel.NoEdge:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.ReadDivTransition, config));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,9 +32,12 @@ namespace TBF.BenchControl
|
||||
CfgChange, /// COnfiguation change
|
||||
ValveOpen, /// Open a valve
|
||||
ValveClose, /// Close a valve
|
||||
RVOpenStep, /// Open a regulation valve
|
||||
RVCloseStep, /// Close a regulation valve
|
||||
GetAdc, /// Get regul.valve or diverter ADC
|
||||
RVOpenStep, /// Open a regulation valve (RV only)
|
||||
RVCloseStep, /// Close a regulation valve *RV only)
|
||||
DivToTank, /// Diverter to tank (Div only)
|
||||
DivToSink, /// Diverter to sink (Div only)
|
||||
ReadDivTransition, /// Read diverter ADC value transition
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user