Work in progress: Diverter calibration
This commit is contained in:
@@ -11,7 +11,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
public bool ShowMore { get { return true; } }
|
||||
|
||||
DiverterCfg config;
|
||||
public IComponentCfg Config
|
||||
@@ -45,11 +45,18 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
}
|
||||
}
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
|
||||
Redraw();
|
||||
StartResponseHandler();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
StopResponseHandler();
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
@@ -60,6 +67,8 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
nameTextBox.Text = config.Name;
|
||||
bitPositionTextBox.Text = config.BitPosition.ToString();
|
||||
startingEdgeTextBox.Text = config.StartingEdge.ToString();
|
||||
stoppingEdgeTextBox.Text = config.StoppingEdge.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
@@ -67,6 +76,8 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
bitPositionTextBox.Enabled = true;
|
||||
startingEdgeTextBox.Enabled = true;
|
||||
stoppingEdgeTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
@@ -84,6 +95,16 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
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";
|
||||
}
|
||||
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";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -96,8 +117,94 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.BitPosition = int.Parse(bitPositionTextBox.Text);
|
||||
config.StartingEdge = int.Parse(startingEdgeTextBox.Text);
|
||||
config.StoppingEdge = int.Parse(stoppingEdgeTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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;
|
||||
}
|
||||
|
||||
private void stopButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
lastTestedEdge = EdgeSel.StopEdge;
|
||||
updateButton.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
public static void OnCmdResponse(object sender, CmdResponseArgs args)
|
||||
{
|
||||
if (CmdResponseHandler == null) return;
|
||||
try { CmdResponseHandler(sender, args); }
|
||||
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
|
||||
}
|
||||
|
||||
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
|
||||
|
||||
public void StartResponseHandler()
|
||||
{
|
||||
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();
|
||||
//}
|
||||
};
|
||||
}
|
||||
|
||||
public void StopResponseHandler()
|
||||
{
|
||||
CmdResponseHandler = null;
|
||||
}
|
||||
|
||||
#endregion Configuration Change Handling
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user