Transition sequences with PumpsFM[%] are OK in UI and in DB, not yet in the control code

This commit is contained in:
Milan Hanajik 2014-09-07 17:01:30 +02:00
parent 46861530a8
commit d98762aaf8
5 changed files with 147 additions and 72 deletions

View File

@ -349,7 +349,7 @@ namespace TBF.BenchControl.Sequences
if (transitionSequence == null)
{
///
/// Default action when no transition sequence is selected
/// No transition sequence defined --> Default action
///
if (context == TransitionContext.TestStart)
{
@ -380,7 +380,7 @@ namespace TBF.BenchControl.Sequences
else
{
///
/// Execute an existing transition sequence
/// Execute the transition sequence
///
IList<Entities.TransitionStep> transitionSteps = StateMachine.WtSession
.CreateQuery("FROM TransitionStep WHERE TransitionSequence = :tsId ORDER BY ItemNr")

View File

@ -3,7 +3,7 @@
namespace TBF.Entities
{
/// <summary>
/// Stores one transition sequence
/// Stores one transition sequence containing a list of transition steps
/// </summary>
public class TransitionSequence : IHasItemNr
{

View File

@ -11,6 +11,7 @@ namespace TBF.Entities
public virtual string ValvesOpen { get; set; } /// List of valves to be opened
public virtual string ValvesClose { get; set; } /// List of valves to be closed
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';'
public virtual TransitionSequence TransitionSequence { get; set; }
@ -35,7 +36,8 @@ namespace TBF.Entities
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
result.RegulValvesPct = RegulValvesPct;
return result;
result.PumpWithFMPcts = PumpWithFMPcts;
return result;
}
public virtual string ToString(string indent)
@ -45,8 +47,9 @@ namespace TBF.Entities
result += indent + "Duration = " + Duration.ToString() + ", ";
result += indent + "ValvesOpen = " + ValvesOpen.ToString() + ", ";
result += indent + "ValvesClose = " + ValvesClose.ToString() + ", ";
result += indent + "RegulValvesPct = " + RegulValvesPct.ToString() + Environment.NewLine;
return result;
result += indent + "RegulValvesPct = " + RegulValvesPct.ToString() + ", ";
result += indent + "PumpsWithFMPct = " + RegulValvesPct.ToString() + Environment.NewLine;
return result;
}
}
}

View File

@ -17,6 +17,7 @@ namespace TBF.Mappings
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.RegulValvesPct);
Map(x => x.PumpWithFMPcts);
References(x => x.TransitionSequence);
}

View File

@ -28,6 +28,7 @@ namespace TBF.UiControls
Control[] editors;
int vCount; /// Number of valves
int fmPumpCount; /// Number of pumps with FM control
int regvCount; /// Number of regulating valves
public TransitionStepsCtrl()
@ -46,31 +47,56 @@ namespace TBF.UiControls
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
vCount = parent.Valves.Count;
vCount = 0;
fmPumpCount = 0;
regvCount = parent.RegulValves.Count;
///
/// ListViewEx columns
///
Columns.Add(Strings.Duration_s, 60 * parent.Dpi / PathsDlg.Dpi100pct);
foreach (var vlv in parent.Valves)
Columns.Add(Strings.Duration_s, 70 * parent.Dpi / PathsDlg.Dpi100pct);
foreach (var vlv in parent.Valves)
{
if (vlv is BenchControl.GenericDevices.IPumpFM)
{
Columns.Add(vlv.Cfg.Name + " [%]", 45 * parent.Dpi / PathsDlg.Dpi100pct);
fmPumpCount++;
}
}
foreach (var rvlv in parent.RegulValves)
{
Columns.Add(rvlv.Cfg.Name + " [%]", 55 * parent.Dpi / PathsDlg.Dpi100pct);
}
foreach (var vlv in parent.Valves)
{
Columns.Add(vlv.Cfg.Name, 50 * parent.Dpi / PathsDlg.Dpi100pct);
}
foreach (var rvlv in parent.RegulValves)
{
Columns.Add(rvlv.Cfg.Name + " [%]", 50 * parent.Dpi / PathsDlg.Dpi100pct);
if (!(vlv is BenchControl.GenericDevices.IPumpFM))
{
Columns.Add(vlv.Cfg.Name, 40 * parent.Dpi / PathsDlg.Dpi100pct);
vCount++;
}
}
///
/// Prepare valve combo-boxes (max. 64 valves)
/// Prepare valve combo-boxes
///
editors = new Control[fixedCount + vCount + regvCount];
editors = new Control[fixedCount + vCount + fmPumpCount + regvCount];
editors[0] = new TextBox(); /// Duration
parent.Controls.Add(editors[0]);
for (int i = fixedCount; i < fixedCount + vCount; i++)
for (int i = fixedCount; i < fixedCount + fmPumpCount; i++)
{
editors[i] = new TextBox();
parent.Controls.Add(editors[i]);
}
for (int i = fixedCount + fmPumpCount; i < fixedCount + fmPumpCount + regvCount; i++)
{
editors[i] = new TextBox();
parent.Controls.Add(editors[i]);
}
for (int i = fixedCount + fmPumpCount + regvCount; i < fixedCount + fmPumpCount + regvCount + vCount; i++)
{
ComboBox cb = new ComboBox();
cb.Items.Add("---");
@ -80,12 +106,6 @@ namespace TBF.UiControls
parent.Controls.Add(cb);
}
for (int i = fixedCount + vCount; i < fixedCount + vCount + regvCount; i++)
{
editors[i] = new TextBox();
parent.Controls.Add(editors[i]);
}
base.RedrawAll();
}
@ -128,27 +148,37 @@ namespace TBF.UiControls
ListViewItem lvi = new ListViewItem(step.Duration.ToString());
foreach (var valve in parent.Valves)
{
if (valvesOpen != null && valvesOpen.Contains(valve))
{
lvi.SubItems.Add(Strings.open);
}
else if (valvesClose != null && valvesClose.Contains(valve))
{
lvi.SubItems.Add(Strings.close);
}
else
{
lvi.SubItems.Add("---");
}
}
string[] fmPumpsStr = (step.PumpWithFMPcts != null) ? step.PumpWithFMPcts.Split(new char[] { ';' })
: new string[0];
for (int i = 0; i < fmPumpCount; i++)
{
lvi.SubItems.Add((i < fmPumpsStr.Length) ? fmPumpsStr[i] : "---");
}
string[] rvPosStr = (step.RegulValvesPct != null) ? step.RegulValvesPct.Split(new char[] { ';' })
: new string[0];
for (int i = 0; i < regvCount; i++)
string[] rvPosStr = (step.RegulValvesPct != null) ? step.RegulValvesPct.Split(new char[] { ';' })
: new string[0];
for (int i = 0; i < regvCount; i++)
{
lvi.SubItems.Add((i < rvPosStr.Length) ? rvPosStr[i] : "---");
}
foreach (var valve in parent.Valves)
{
lvi.SubItems.Add((i < rvPosStr.Length) ? rvPosStr[i] : "---");
if (!(valve is BenchControl.GenericDevices.IPumpFM))
{
if (valvesOpen != null && valvesOpen.Contains(valve))
{
lvi.SubItems.Add(Strings.open);
}
else if (valvesClose != null && valvesClose.Contains(valve))
{
lvi.SubItems.Add(Strings.close);
}
else
{
lvi.SubItems.Add("---");
}
}
}
lvi.Tag = step;
@ -160,46 +190,87 @@ namespace TBF.UiControls
{
Entities.TransitionStep step = (Entities.TransitionStep)myItem;
/// Duration
/// Duration
try
{
step.Duration = int.Parse(lvi.Text);
if (step.Duration < 2) throw (new System.Exception());
}
catch { lvi.Text = step.Duration.ToString(); }
catch
{
lvi.Text = step.Duration.ToString();
}
string valvesOpen = string.Empty;
string valvesClose = string.Empty;
string regulValvesPct = string.Empty;
string fmPumpsPcts = string.Empty;
/// Pumps with FM control
int i = 0;
foreach (var valve in parent.Valves)
{
if (valve is BenchControl.GenericDevices.IPumpFM)
{
string lviSubitText = lvi.SubItems[fixedCount + i++].Text;
if (fmPumpsPcts.Length > 0) fmPumpsPcts += ";";
float fdummy;
if (lviSubitText.Equals("---"))
{
fmPumpsPcts += lviSubitText;
}
else if(Utils.TryParseUFloat(lviSubitText, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f))
{
fmPumpsPcts += lviSubitText;
if (fdummy > 0)
{
if (valvesOpen != string.Empty) valvesOpen += ";";
valvesOpen += valve.Cfg.Name;
}
else
{
if (valvesClose != string.Empty) valvesClose += ";";
valvesClose += valve.Cfg.Name;
}
}
}
}
/// Regulation valves
for (int k = fixedCount + fmPumpCount; k < fixedCount + fmPumpCount + regvCount; k++)
{
if (regulValvesPct.Length > 0) regulValvesPct += ";";
float fdummy;
if (lvi.SubItems[k].Text.Equals("---") ||
(Utils.TryParseUFloat(lvi.SubItems[k].Text, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f)))
{
regulValvesPct += lvi.SubItems[k].Text;
}
}
/// Valves
string valvesOpen = string.Empty;
string valvesClose = string.Empty;
for (int j = 0; j < vCount; j++)
for (int j = 0, k = 0; j < vCount; j++)
{
string text = lvi.SubItems[fixedCount + j].Text;
if (text.Equals(Strings.open))
{
if (valvesOpen != string.Empty) valvesOpen += ";";
valvesOpen += parent.Valves[j].Cfg.Name;
}
if (text.Equals(Strings.close))
{
if (valvesClose != string.Empty) valvesClose += ";";
valvesClose += parent.Valves[j].Cfg.Name;
}
if (!(parent.Valves[j] is BenchControl.GenericDevices.IPumpFM))
{
string lviSubitText = lvi.SubItems[fixedCount + fmPumpCount + regvCount + k++].Text;
if (lviSubitText.Equals(Strings.open))
{
if (valvesOpen != string.Empty) valvesOpen += ";";
valvesOpen += parent.Valves[j].Cfg.Name;
}
if (lviSubitText.Equals(Strings.close))
{
if (valvesClose != string.Empty) valvesClose += ";";
valvesClose += parent.Valves[j].Cfg.Name;
}
}
}
step.ValvesOpen = valvesOpen;
step.ValvesClose = valvesClose;
string regulValvesPct = string.Empty;
for (int j = fixedCount + vCount; j < fixedCount + vCount + regvCount; j++)
{
if (regulValvesPct.Length > 0) regulValvesPct += ";";
float fdummy;
if (lvi.SubItems[j].Text.Equals("---") ||
(Utils.TryParseUFloat(lvi.SubItems[j].Text, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f)))
{
regulValvesPct += lvi.SubItems[j].Text;
}
}
step.RegulValvesPct = regulValvesPct;
step.PumpWithFMPcts = fmPumpsPcts;
step.RegulValvesPct = regulValvesPct;
step.ValvesOpen = valvesOpen;
step.ValvesClose = valvesClose;
}
public void AddOne()