ProcessTabPageCtrl-Test data displed, ProcessData.Mass and RefPulses are properties, ClearProcessValues() at the beginning of each test, etc, ver. 3.1.1896

This commit is contained in:
Milan Hanajik 2022-04-21 20:02:51 +02:00
parent c5d550259f
commit 4361227975
11 changed files with 358 additions and 103 deletions

View File

@ -5,8 +5,8 @@ namespace SchematicDrawing
{
public interface IDrawingItCmpntWithMeasuredVal : IDrawingItCmpnt
{
bool MsrmntAvailable { get; }
double MeasuredVal { get; }
string AltString { get; }
bool MsrmntAvailable { get; } /// true when there is a valid measurement
double MeasuredVal { get; } /// Measured value in default unit (not converted)
string AltString { get; } /// String to be displayed when MsrdFormat is an empty string or null
}
}

View File

@ -174,14 +174,10 @@ namespace TBF
/// Process
public int ProcessSplitDist1;
public int ProcessSplitDist2;
[XmlArrayAttribute("MetersColWidths")]
[XmlArrayAttribute("ProcMetersColWidths")]
public int[] ProcMetersColWidths;
[XmlIgnore]
public int ProcMetersColCount { get { return (ProcMetersColWidths != null) ? ProcMetersColWidths.Length : 0; } }
[XmlArrayAttribute("TestDataColWidths")]
[XmlArrayAttribute("ProcTestDataColWidths")]
public int[] ProcTestDataColWidths;
[XmlIgnore]
public int ProcTestDataColCount { get { return (ProcTestDataColWidths != null) ? ProcTestDataColWidths.Length : 0; } }
/// Procedures
public bool ProceduresDlgMaximized;

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.1.1886.0")]
[assembly: AssemblyFileVersion("3.1.1886.0")]
[assembly: AssemblyVersion("3.1.1896.0")]
[assembly: AssemblyFileVersion("3.1.1896.0")]

View File

@ -12,7 +12,7 @@ namespace TBF.Rig.ControlBoard
void SpecifyInvertedValves(UInt128 valvesToInvert);
/// <summary>
/// Called on beginning of a test
/// Called from ProcessData.ClearProcessValues() at the beginning of each test
/// </summary>
void ClearProcessValues();

View File

@ -335,7 +335,9 @@ namespace TBF.Rig.ControlBoard.Papouch
public int PulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= ProcessData.WMsCount) ? 0 : 0; }
public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= ProcessData.WMsCount) ? 1.0 : 1.0; }
/// <summary>
/// Called from ProcessData.ClearProcessValues() at the beginning of each test
/// </summary>
public void ClearProcessValues() { }
/// <summary>

View File

@ -601,7 +601,7 @@ namespace TBF.Rig.ControlBoard.Uni
///
/// Interface functions
///
public void ClearProcessValues() { }
public void ClearProcessValues() { } /// Called from ProcessData.ClearProcessValues() at the beginning of each test
public double TestTimeWM(int wmNr1)
{

View File

@ -1326,7 +1326,7 @@ namespace TBF.Rig.Sequences
///
/// Clear a file with interim test results
///
ClearProcessData();
ClearProcessDataFile();
Program.LocalSettings.BatchNr++;
Program.LocalSettings.Save();

View File

@ -32,6 +32,13 @@ namespace TBF.Rig.Sequences
public static int LinesCount { get { return BenchInfo != null ? BenchInfo.LinesCount : 2; } }
public static int LineSize { get { return BenchInfo != null ? BenchInfo.WaterMetersCount / Math.Max(1, BenchInfo.LinesCount) : 10; } }
public static int CompoundWMsCount { get { return BenchInfo != null ? BenchInfo.CompoundMetersCount : 1; } }
///
public static Unit VolumeUnit { get { return BenchInfo != null ? BenchInfo.VolumeUnit : Unit.l; } }
public static Unit FlowUnit { get { return BenchInfo != null ? BenchInfo.FlowUnit : Unit.m3ph; } }
public static Unit MassUnit { get { return BenchInfo != null ? BenchInfo.MassUnit : Unit.kg; } }
public static Unit TempUnit { get { return BenchInfo != null ? BenchInfo.TempUnit : Unit.C; } }
public static Unit PressUnit { get { return BenchInfo != null ? BenchInfo.PressUnit : Unit.bar; } }
public static Unit LengthUnit { get { return BenchInfo != null ? BenchInfo.LengthUnit : Unit.mm; } }
///
/// Procedure related state variables
@ -217,7 +224,7 @@ namespace TBF.Rig.Sequences
}
}
public static void ClearProcessData()
public static void ClearProcessDataFile()
{
File.Delete(PDataFileName);
}
@ -239,13 +246,19 @@ namespace TBF.Rig.Sequences
public static DoubleBox PressDelta = new DoubleBox() { Name = "Pressure Delta", Format = "F2" }; /// [bar]
public static FloatBox Conductivity = new FloatBox(750) { Name = "Conductivity", Format = "F0" }; /// [uS/cm], default is 750
public static double LtrPerRefPulse; /// to calculate the ref.volume
public static int RefPulses;
public static int RefPulsesDelta;
public static double LtrPerRefPulse; /// to calculate the ref.volume
//{
// get { return (Devices != null && Devices.FlowMeter != null) ? Devices.FlowMeter.LtrPerPulseCorrected : 0; }
//}
public static int RefPulses { get { return StateMachine.ControlBoard.RefPulses; } }
public static int RefPulsesDelta;
public static DoubleBox RefFrequency = new DoubleBox() { Name = "RefFreq", Format = "F2" };
public static DoubleBox RefFlow = new DoubleBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h]
public static DoubleBox Mass = new DoubleBox() { Name = "Mass", Format = "F3" }; /// [kg]
public static double Mass
{
get { return (Devices != null && Devices.Scale is IScale) ? (Devices.Scale as IScale).Mass : 0; } /// [kg]
}
public static DoubleBox StartMass = new DoubleBox() { Name = "Start Mass", Format = "F3" }; /// [kg]
public static DoubleBox EndMass = new DoubleBox() { Name = "End Mass", Format = "F3" }; /// [kg]
public static double FlowFromMassIncrease;
@ -263,16 +276,14 @@ namespace TBF.Rig.Sequences
/// <summary>
/// To clear process values at the beginning of each test
/// To be called at the beginning of each test to clear process values
/// </summary>
protected void ClearProcessValues()
public static void ClearProcessValues()
{
StateMachine.ControlBoard.ClearProcessValues();
if (StateMachine.ControlBoard != null) StateMachine.ControlBoard.ClearProcessValues();
RefPulses = 0;
RefFrequency.Clear();
RefFlow.Clear();
Mass.Clear();
StartMass.Clear();
EndMass.Clear();
}

View File

@ -30,7 +30,8 @@
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.processListViewEx = new Common.Forms.ListViewEx();
this.metersListView = new System.Windows.Forms.ListView();
this.testDataListView = new System.Windows.Forms.ListView();
this.processDrawingCtrl = new SchematicDrawing.SchematicDrawingCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@ -38,6 +39,7 @@
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.SuspendLayout();
//
@ -61,35 +63,55 @@
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer2.IsSplitterFixed = true;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.processListViewEx);
this.splitContainer2.Panel1.Controls.Add(this.testDataListView);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.metersListView);
this.splitContainer2.Size = new System.Drawing.Size(250, 580);
this.splitContainer2.SplitterDistance = 300;
this.splitContainer2.SplitterDistance = 200;
this.splitContainer2.SplitterWidth = 15;
this.splitContainer2.TabIndex = 0;
//
// processListViewEx
// metersListView
//
this.processListViewEx.AllowColumnReorder = true;
this.processListViewEx.Dock = System.Windows.Forms.DockStyle.Fill;
this.processListViewEx.DoubleClickActivation = false;
this.processListViewEx.FullRowSelect = true;
this.processListViewEx.GridLines = true;
this.processListViewEx.Location = new System.Drawing.Point(0, 0);
this.processListViewEx.Name = "processListViewEx";
this.processListViewEx.Size = new System.Drawing.Size(250, 300);
this.processListViewEx.TabIndex = 0;
this.processListViewEx.UseCompatibleStateImageBehavior = false;
this.processListViewEx.View = System.Windows.Forms.View.Details;
this.metersListView.AllowColumnReorder = true;
this.metersListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.metersListView.FullRowSelect = true;
this.metersListView.GridLines = true;
this.metersListView.Location = new System.Drawing.Point(0, 0);
this.metersListView.Name = "metersListView";
this.metersListView.Size = new System.Drawing.Size(250, 365);
this.metersListView.TabIndex = 0;
this.metersListView.UseCompatibleStateImageBehavior = false;
this.metersListView.View = System.Windows.Forms.View.Details;
//
// testDataListView
//
this.testDataListView.AllowColumnReorder = true;
this.testDataListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.testDataListView.FullRowSelect = true;
this.testDataListView.GridLines = true;
this.testDataListView.Location = new System.Drawing.Point(0, 0);
this.testDataListView.Name = "testDataListView";
this.testDataListView.Size = new System.Drawing.Size(250, 200);
this.testDataListView.TabIndex = 0;
this.testDataListView.UseCompatibleStateImageBehavior = false;
this.testDataListView.View = System.Windows.Forms.View.Details;
//
// processDrawingCtrl
//
this.processDrawingCtrl.AltStrings = null;
this.processDrawingCtrl.BenchControlMode = false;
this.processDrawingCtrl.CustomBitmaps = null;
this.processDrawingCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.processDrawingCtrl.EditMode = false;
this.processDrawingCtrl.Location = new System.Drawing.Point(0, 0);
@ -119,6 +141,7 @@
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.ResumeLayout(false);
@ -128,8 +151,9 @@
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private Common.Forms.ListViewEx processListViewEx;
private System.Windows.Forms.ListView metersListView;
private System.Windows.Forms.SplitContainer splitContainer2;
private SchematicDrawing.SchematicDrawingCtrl processDrawingCtrl;
private System.Windows.Forms.ListView testDataListView;
}
}

View File

@ -37,12 +37,17 @@ namespace TBF.UI.Process
Count
}
int startMassIx;
int massIx;
int volumeIx;
int refErrorIx;
MetersKind currentMetersKind;
public ProcessTabPageCtrl()
{
InitializeComponent();
InitializeTableOfWatermeters(processListViewEx, ProcessData.WMsCount);
InitializeTableOfMeters(metersListView, ProcessData.WMsCount);
InitializeDrawing();
Bridge.ProcedureSelectedHandler += delegate(object sender, ProcedureSelectedEventArgs args)
@ -94,16 +99,22 @@ namespace TBF.UI.Process
TBF.LocalSettings ls = Program.LocalSettings;
/// Splitter distances
splitContainer1.SplitterDistance = ls.ProcessSplitDist1;
splitContainer2.SplitterDistance = ls.ProcessSplitDist2;
splitContainer1.SplitterDistance = Math.Max(150, Math.Min(ls.ProcessSplitDist1, 500));
/// ListViewEx columns
processListViewEx.Columns.Add(Strings.Nr, (ls.ProcessColumnCount > 0) ? ls.ProcessColumnWidths[0] : 30 * MainWnd.Dpi / Constants.Dpi100pct);
processListViewEx.Columns.Add(Strings.Error, (ls.ProcessColumnCount > 1) ? ls.ProcessColumnWidths[1] : 50 * MainWnd.Dpi / Constants.Dpi100pct);
processListViewEx.Columns.Add(Strings.Volume, (ls.ProcessColumnCount > 2) ? ls.ProcessColumnWidths[2] : 50 * MainWnd.Dpi / Constants.Dpi100pct);
processListViewEx.Columns.Add(Strings.Pulses, (ls.ProcessColumnCount > 3) ? ls.ProcessColumnWidths[3] : 60 * MainWnd.Dpi / Constants.Dpi100pct);
processListViewEx.Columns.Add(Strings.Ref_pulses, (ls.ProcessColumnCount > 4) ? ls.ProcessColumnWidths[4] : 75 * MainWnd.Dpi / Constants.Dpi100pct);
processListViewEx.Columns.Add(Strings.SerialNr, (ls.ProcessColumnCount > 5) ? ls.ProcessColumnWidths[5] : 100 * MainWnd.Dpi / Constants.Dpi100pct);
/// metersListViewEx columns
var cols = ls.ProcMetersColWidths;
metersListView.Columns.Add(Strings.Nr, (cols != null && cols.Length > 0) ? cols[0] : 30 * MainWnd.Dpi / Constants.Dpi100pct);
metersListView.Columns.Add(Strings.Error, (cols != null && cols.Length > 1) ? cols[1] : 50 * MainWnd.Dpi / Constants.Dpi100pct);
metersListView.Columns.Add(Strings.Volume, (cols != null && cols.Length > 2) ? cols[2] : 50 * MainWnd.Dpi / Constants.Dpi100pct);
metersListView.Columns.Add(Strings.Pulses, (cols != null && cols.Length > 3) ? cols[3] : 60 * MainWnd.Dpi / Constants.Dpi100pct);
metersListView.Columns.Add(Strings.Ref_pulses, (cols != null && cols.Length > 4) ? cols[4] : 75 * MainWnd.Dpi / Constants.Dpi100pct);
metersListView.Columns.Add(Strings.SerialNr, (cols != null && cols.Length > 5) ? cols[5] : 100 * MainWnd.Dpi / Constants.Dpi100pct);
/// testDataListViewEx columns
cols = ls.ProcTestDataColWidths;
testDataListView.Columns.Add(Strings.Name, (cols != null && cols.Length > 0) ? cols[0] : 225 * MainWnd.Dpi / Constants.Dpi100pct);
testDataListView.Columns.Add(Strings.Value, (cols != null && cols.Length > 1) ? cols[1] : 80 * MainWnd.Dpi / Constants.Dpi100pct);
testDataListView.Columns.Add(Strings.Unit, (cols != null && cols.Length > 2) ? cols[2] : 60 * MainWnd.Dpi / Constants.Dpi100pct);
}
/// <summary>
@ -115,31 +126,53 @@ namespace TBF.UI.Process
{
LocalSettings ls = Program.LocalSettings;
bool anyChange = splitContainer1.SplitterDistance != ls.ProcessSplitDist1
|| splitContainer2.SplitterDistance != ls.ProcessSplitDist2;
bool anyChange = splitContainer1.SplitterDistance != ls.ProcessSplitDist1;
if (anyChange)
{
ls.ProcessSplitDist1 = splitContainer1.SplitterDistance;
ls.ProcessSplitDist2 = splitContainer2.SplitterDistance;
}
/// Compare list view column widths with the saved ones
if (processListViewEx.Columns.Count != ls.ProcessColumnCount)
if (ls.ProcMetersColWidths == null ||
ls.ProcMetersColWidths.Length != metersListView.Columns.Count)
{
ls.ProcessColumnWidths = new int[processListViewEx.Columns.Count];
for (int i = 0; i < ls.ProcessColumnCount; i++)
ls.ProcMetersColWidths = new int[metersListView.Columns.Count];
for (int i = 0; i < metersListView.Columns.Count; i++)
{
ls.ProcessColumnWidths[i] = processListViewEx.Columns[i].Width;
ls.ProcMetersColWidths[i] = metersListView.Columns[i].Width;
}
anyChange = true;
}
else
{
for (int i = 0; i < ls.ProcessColumnCount; i++)
for (int i = 0; i < metersListView.Columns.Count; i++)
{
if (processListViewEx.Columns[i].Width != ls.ProcessColumnWidths[i])
if (metersListView.Columns[i].Width != ls.ProcMetersColWidths[i])
{
ls.ProcessColumnWidths[i] = processListViewEx.Columns[i].Width;
ls.ProcMetersColWidths[i] = metersListView.Columns[i].Width;
anyChange = true;
}
}
}
/// Compare list view column widths with the saved ones
if (ls.ProcTestDataColWidths == null ||
ls.ProcTestDataColWidths.Length != testDataListView.Columns.Count)
{
ls.ProcTestDataColWidths = new int[testDataListView.Columns.Count];
for (int i = 0; i < testDataListView.Columns.Count; i++)
{
ls.ProcTestDataColWidths[i] = testDataListView.Columns[i].Width;
}
anyChange = true;
}
else
{
for (int i = 0; i < testDataListView.Columns.Count; i++)
{
if (testDataListView.Columns[i].Width != ls.ProcTestDataColWidths[i])
{
ls.ProcTestDataColWidths[i] = testDataListView.Columns[i].Width;
anyChange = true;
}
}
@ -149,6 +182,85 @@ namespace TBF.UI.Process
}
/// <summary>
/// Initializes test data table - ListView control.
/// Table is filled with dots "."
/// </summary>
/// <param name="lv">ListView control</param>
void InitializeTestDataTable(ListView lv, TestSelectedEventArgs args)
{
lv.Items.Clear();
ListViewItem lvi;
lv.Items.Add(lvi = new ListViewItem(new string[] {
Strings.Test,
args.Test.Name,
string.Empty
}));
lv.Items.Add(lvi = new ListViewItem(new string[] {
Strings.Repetition,
string.Format("{0} / {1}", args.RepetitionNr, args.Test.Repeats),
string.Empty
}));
lv.Items.Add(new ListViewItem(new string[] {
Strings.Q_from,
Units.ConvertTo(ProcessData.FlowUnit, args.Test.Qfrom).ToString(),
ProcessData.FlowUnit.ToDescription()
}));
lv.Items.Add(new ListViewItem(new string[] {
Strings.Q_to,
Units.ConvertTo(ProcessData.FlowUnit, args.Test.Qto).ToString(),
ProcessData.FlowUnit.ToDescription()
}));
lv.Items.Add(new ListViewItem(new string[] {
Strings.Target_volume,
Units.ConvertTo(ProcessData.VolumeUnit, args.Test.Volume).ToString(),
ProcessData.VolumeUnit.ToDescription()
}));
lv.Items.Add(new ListViewItem(new string[] {
Strings.Test_time,
args.Test.TestTime.ToString(),
Unit.s.ToDescription()
}));
startMassIx = lv.Items.Count;
lv.Items.Add(new ListViewItem(new string[] {
Strings.Start_mass,
"---",
ProcessData.MassUnit.ToDescription()
}));
massIx = lv.Items.Count;
lv.Items.Add(new ListViewItem(new string[] {
Strings.Mass,
"---",
ProcessData.MassUnit.ToDescription()
}));
volumeIx = lv.Items.Count;
lv.Items.Add(new ListViewItem(new string[] {
Strings.Volume,
"---",
ProcessData.VolumeUnit.ToDescription()
}));
refErrorIx = lv.Items.Count;
lv.Items.Add(new ListViewItem(new string[] {
Strings.Ref_flowmeter_error,
"---",
Unit.Pct.ToDescription()
}));
log.DebugFormat("InitializeTestDataTable: startMassIx={0} massIx={1} volumeIx={2} refErrorIx={3} itemsCount={4}",
startMassIx, massIx, volumeIx, refErrorIx, lv.Items.Count);
}
/// <summary>
/// Initializes water meters table - ListView control.
/// Table is filled with dots "."
@ -156,7 +268,7 @@ namespace TBF.UI.Process
/// <param name="listView">ListView control</param>
/// <param name="wmsCount">Water meters count</param>
/// <param name="waterMeters">Optional water meters to be used as list view item tags</param>
void InitializeTableOfWatermeters(ListView listView, int wmsCount, IList<Results.Entities.WaterMeter> waterMeters = null)
void InitializeTableOfMeters(ListView listView, int wmsCount, IList<Results.Entities.WaterMeter> waterMeters = null)
{
if (listView.Items.Count != wmsCount)
{
@ -239,6 +351,7 @@ namespace TBF.UI.Process
int setpIx = 0;
int bmpIx = 0;
/// Tank
processDrawingCtrl.AddItem(
tankCfg = new TBF.Rig.Various.Drawing.Tank.Configuration("Tank", new TBF.Rig.Various.Drawing.Tank.Factory())
{
@ -247,6 +360,7 @@ namespace TBF.UI.Process
LblX = 33, LblY = 22, LblOrient = Orient.R,
});
/// Pump
pumpSetpIx = setpIx++;
processDrawingCtrl.AddItem(
pumpCfg = new TBF.Rig.Modbus.PumpFM.DanfossVLT.PumpCfg(new TBF.Rig.Modbus.PumpFM.DanfossVLT.Factory())
@ -259,6 +373,11 @@ namespace TBF.UI.Process
Inverted = false,
});
/// Junctions
processDrawingCtrl.AddItem(new Configuration("J1", new Factory()) { Id=(j1=id++), Shape=Shape.Junction, X=50, Y=490, Sz=Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J2", new Factory()) { Id=(j2=id++), Shape=Shape.Junction, X=50, Y=370, Sz=Sz.L, });
/// T up
tempMtrUpMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
tempInCfg = new TBF.Rig.Modbus.TempMeter.Groch.TempMeterCfg(new TBF.Rig.Modbus.TempMeter.Groch.Factory())
@ -270,6 +389,7 @@ namespace TBF.UI.Process
MsrdValLimLo = 5, MsrdValLimHi = 95,
});
/// Pr up
pressMtrUpMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
pressUpCfg = new TBF.Rig.Modbus.PressureMeter.Meret.PressureMeterCfg(new TBF.Rig.Modbus.PressureMeter.Meret.Factory())
@ -281,6 +401,7 @@ namespace TBF.UI.Process
MsrdValLimLo = -0.1, MsrdValLimHi = 25,
});
/// WM 1
processDrawingCtrl.AddItem(
wm1Cfg = new TBF.Rig.WaterMeters.WaterMeter.WaterMeterCfg(new TBF.Rig.WaterMeters.WaterMeter.WaterMeterFactory())
{
@ -289,6 +410,7 @@ namespace TBF.UI.Process
LblX = 0, LblY = -24, LblOrient = Orient.R,
});
/// WM 2
processDrawingCtrl.AddItem(
wm2Cfg = new TBF.Rig.WaterMeters.WaterMeter.WaterMeterCfg(new TBF.Rig.WaterMeters.WaterMeter.WaterMeterFactory())
{
@ -297,14 +419,16 @@ namespace TBF.UI.Process
LblX = 0, LblY = -24, LblOrient = Orient.R,
});
/// WM last
processDrawingCtrl.AddItem(
wmLastCfg = new TBF.Rig.WaterMeters.WaterMeter.WaterMeterCfg(new TBF.Rig.WaterMeters.WaterMeter.WaterMeterFactory())
{
Id = (wmLastId = id++), Name = "WM3",
Id = (wmLastId = id++), Name = "WMn",
X = 310, Y = 360, Shape = Shape.WaterM, Sz = Sz.L, Orient = Orient.R, Flip = false,
LblX = 0, LblY = -24, LblOrient = Orient.R,
});
/// T down
tempMtrDownMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
tempOutCfg = new TBF.Rig.Modbus.TempMeter.Groch.TempMeterCfg(new TBF.Rig.Modbus.TempMeter.Groch.Factory())
@ -316,6 +440,7 @@ namespace TBF.UI.Process
MsrdValLimLo = 5, MsrdValLimHi = 95,
});
/// Pr down
pressMtrDownMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
pressDnCfg = new TBF.Rig.Modbus.PressureMeter.Meret.PressureMeterCfg(new TBF.Rig.Modbus.PressureMeter.Meret.Factory())
@ -327,6 +452,10 @@ namespace TBF.UI.Process
MsrdValLimLo = -0.1, MsrdValLimHi = 25,
});
/// Junction
processDrawingCtrl.AddItem(new Configuration("J3", new Factory()) { Id=(j3=id++), Shape=Shape.Junction, X=460, Y=370, Sz=Sz.L, });
/// Start valve
processDrawingCtrl.AddItem(
startValveCfg = new TBF.Rig.BuiltIn.Valve.ValveCfg(new TBF.Rig.BuiltIn.Valve.ValveFactory())
{
@ -337,6 +466,7 @@ namespace TBF.UI.Process
Inverted = false,
});
/// Flow meter
flowMeterMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
flowMeterCfg = new TBF.Rig.Uni.FlowMeter.FlowMeterCfg(new TBF.Rig.Uni.FlowMeter.Factory(), "I")
@ -347,6 +477,7 @@ namespace TBF.UI.Process
MsrdX = 46, MsrdY = 22, MsrdOrient = Orient.R, MsrdFormat = "{0:F3} m2/h", MsrdUnit = Common.Unit.m3ph,
});
/// Regulation valve
regValveSetpIx = setpIx++;
processDrawingCtrl.AddItem(
regValveCfg = new TBF.Rig.Uni.RegValve.RegValveCfg("VR", new TBF.Rig.Uni.RegValve.Factory())
@ -357,6 +488,11 @@ namespace TBF.UI.Process
SetpX = 46, SetpY = 22, SetpOrient = Orient.R,
});
/// Junctions
processDrawingCtrl.AddItem(new Configuration("J4", new Factory()) { Id=(j4=id++), Shape=Shape.Junction, X=460, Y=80, Sz=Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J5", new Factory()) { Id=(j5=id++), Shape=Shape.Junction, X=630, Y=40, Sz=Sz.L, });
/// T div
tempMtrDivMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
tempDivCfg = new TBF.Rig.Modbus.TempMeter.Groch.TempMeterCfg(new TBF.Rig.Modbus.TempMeter.Groch.Factory())
@ -368,6 +504,7 @@ namespace TBF.UI.Process
MsrdValLimLo = 5, MsrdValLimHi = 95,
});
/// Diverter
processDrawingCtrl.AddItem(
diverterCfg = new TBF.Rig.Uni.Diverter.DiverterCfg(new TBF.Rig.Uni.Diverter.Factory())
{
@ -379,6 +516,7 @@ namespace TBF.UI.Process
Inverted = false,
});
/// Scale
scaleMsrdIx = msrdIx++;
processDrawingCtrl.AddItem(
scaleCfg = new TBF.Rig.Scales.MettlerToledo.ScaleCfg("WT", new TBF.Rig.Scales.MettlerToledo.Factory())
@ -389,6 +527,7 @@ namespace TBF.UI.Process
MsrdX = 16, MsrdY = 64, MsrdOrient = Orient.R, MsrdFormat = "{0:F3}", MsrdUnit = Common.Unit.kg,
});
/// Drain valve
processDrawingCtrl.AddItem(
drainValveCfg = new TBF.Rig.BuiltIn.Valve.ValveCfg(new TBF.Rig.BuiltIn.Valve.ValveFactory())
{
@ -400,13 +539,8 @@ namespace TBF.UI.Process
});
/// Junctions
processDrawingCtrl.AddItem(new Configuration("J1", new Factory()) { Id = (j1 = id++), Shape = Shape.Junction, X = 50, Y = 490, Sz = Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J2", new Factory()) { Id = (j2 = id++), Shape = Shape.Junction, X = 50, Y = 370, Sz = Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J3", new Factory()) { Id = (j3 = id++), Shape = Shape.Junction, X = 460, Y = 370, Sz = Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J4", new Factory()) { Id = (j4 = id++), Shape = Shape.Junction, X = 460, Y = 80, Sz = Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J5", new Factory()) { Id = (j5 = id++), Shape = Shape.Junction, X = 630, Y = 40, Sz = Sz.L, });
processDrawingCtrl.AddItem(new Configuration("J6", new Factory()) { Id = (j6 = id++), Shape = Shape.Junction, X = 680, Y = 390, Sz = Sz.None, });
processDrawingCtrl.AddItem(new Configuration("J7", new Factory()) { Id = (j7 = id++), Shape = Shape.Junction, X = 620, Y = 390, Sz = Sz.None, });
processDrawingCtrl.AddItem(new Configuration("J6", new Factory()) { Id=(j6=id++), Shape=Shape.Junction, X=680, Y=390, Sz=Sz.None, });
processDrawingCtrl.AddItem(new Configuration("J7", new Factory()) { Id=(j7=id++), Shape=Shape.Junction, X=620, Y=390, Sz=Sz.None, });
processDrawingCtrl.MsrmntAvailableFlags = new bool[msrdIx];
processDrawingCtrl.MeasuredValues = new double[msrdIx];
@ -455,7 +589,8 @@ namespace TBF.UI.Process
void OnTestSelected(object sender, TestSelectedEventArgs args)
{
InitializeTableOfWatermeters(processListViewEx, ProcessData.WMsCount, ProcessData.BatchRslts.Batch.WaterMeters);
InitializeTestDataTable(testDataListView, args);
InitializeTableOfMeters(metersListView, ProcessData.WMsCount, ProcessData.BatchRslts.Batch.WaterMeters);
processDrawingCtrl.SupressRedraws = true;
@ -463,24 +598,76 @@ namespace TBF.UI.Process
pumpCfg.Name = (args.FeedingPath != null && args.FeedingPath.Pump != null) ? args.FeedingPath.Pump.Name : "n/a";
/// Bench path
tempInCfg.Name = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.Name : "n/a";
tempOutCfg.Name = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.Name : "n/a";
pressUpCfg.Name = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.Name : "n/a";
pressDnCfg.Name = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.Name : "n/a";
tempInCfg.Name = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.Name : "n/a";
tempInCfg.MsrdFormat = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.MsrdFormat : "{0:F1} °C";
tempInCfg.MsrdUnit = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.MsrdUnit : Unit.C;
tempInCfg.MsrdValLimLo = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.MsrdValLimLo : 5;
tempInCfg.MsrdValLimHi = (args.BenchPath != null && args.BenchPath.TempMtrUp != null) ? args.BenchPath.TempMtrUp.MsrdValLimHi : 95;
pressUpCfg.Name = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.Name : "n/a";
pressUpCfg.MsrdFormat = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.MsrdFormat : "{0:F2} bar";
pressUpCfg.MsrdUnit = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.MsrdUnit : Unit.bar;
pressUpCfg.MsrdValLimLo = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.MsrdValLimLo : 0;
pressUpCfg.MsrdValLimHi = (args.BenchPath != null && args.BenchPath.PressMtrUp != null) ? args.BenchPath.PressMtrUp.MsrdValLimHi : 15;
tempOutCfg.Name = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.Name : "n/a";
tempOutCfg.MsrdFormat = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.MsrdFormat : "{0:F1} °C";
tempOutCfg.MsrdUnit = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.MsrdUnit : Unit.C;
tempOutCfg.MsrdValLimLo = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.MsrdValLimLo : 5;
tempOutCfg.MsrdValLimHi = (args.BenchPath != null && args.BenchPath.TempMtrDown != null) ? args.BenchPath.TempMtrDown.MsrdValLimHi : 95;
pressDnCfg.Name = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.Name : "n/a";
pressDnCfg.MsrdFormat = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.MsrdFormat : "{0:F2} bar";
pressDnCfg.MsrdUnit = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.MsrdUnit : Unit.bar;
pressDnCfg.MsrdValLimLo = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.MsrdValLimLo : 0;
pressDnCfg.MsrdValLimHi = (args.BenchPath != null && args.BenchPath.PressMtrDown != null) ? args.BenchPath.PressMtrDown.MsrdValLimHi : 15;
/// Output path
scaleCfg.Name = (args.OutputPath != null && args.OutputPath.Scale != null) ? args.OutputPath.Scale.Name : "n/a";
drainValveCfg.Name = (args.OutputPath != null && args.OutputPath.Scale != null && args.OutputPath.Scale.DrainValve != null) ? args.OutputPath.Scale.DrainValve.Name : "n/a";
diverterCfg.Name = (args.OutputPath != null && args.OutputPath.Diverter != null) ? args.OutputPath.Diverter.Name : "n/a";
regValveCfg.Name = (args.OutputPath != null && args.OutputPath.RegValve != null) ? args.OutputPath.RegValve.Name : "n/a";
flowMeterCfg.Name = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.Name : "n/a";
startValveCfg.Name = (args.OutputPath != null && args.OutputPath.StartValve1 != null) ? args.OutputPath.StartValve1.Name : "n/a";
tempDivCfg.Name = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.Name : "n/a";
flowMeterCfg.Name = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.Name : "n/a";
flowMeterCfg.MsrdFormat = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.MsrdFormat : "{0:F3} m3/h";
flowMeterCfg.MsrdUnit = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.MsrdUnit : Unit.m3ph;
flowMeterCfg.MsrdValLimLo = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.MsrdValLimLo : 0;
flowMeterCfg.MsrdValLimHi = (args.OutputPath != null && args.OutputPath.FlowMeter != null) ? args.OutputPath.FlowMeter.MsrdValLimHi : 1600;
regValveCfg.Name = (args.OutputPath != null && args.OutputPath.RegValve != null) ? args.OutputPath.RegValve.Name : "n/a";
tempDivCfg.Name = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.Name : "n/a";
tempDivCfg.MsrdFormat = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.MsrdFormat : "{0:F1} °C";
tempDivCfg.MsrdUnit = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.MsrdUnit : Unit.C;
tempDivCfg.MsrdValLimLo = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.MsrdValLimLo : 5;
tempDivCfg.MsrdValLimHi = (args.OutputPath != null && args.OutputPath.TempMtrDiv != null) ? args.OutputPath.TempMtrDiv.MsrdValLimHi : 95;
diverterCfg.Name = (args.OutputPath != null && args.OutputPath.Diverter != null) ? args.OutputPath.Diverter.Name : "n/a";
scaleCfg.Name = (args.OutputPath != null && args.OutputPath.Scale != null) ? args.OutputPath.Scale.Name : "n/a";
scaleCfg.Capacity = (args.OutputPath != null && args.OutputPath.Scale != null) ? args.OutputPath.Scale.Capacity : 100.0;
drainValveCfg.Name = (args.OutputPath != null && args.OutputPath.Scale != null && args.OutputPath.Scale.DrainValve != null)
? args.OutputPath.Scale.DrainValve.Name : "n/a";
/// Meters path
//wm1.Name = args.BenchPath;
//wm2.Name = args.BenchPath;
//wmLast.Name = args.BenchPath;
if (args.MetersPath != null && args.MetersPath.RegisterReaders != null)
{
var rrs = args.MetersPath.RegisterReaders;
int first = 0;
int last = ProcessData.WMsCount;
for (int i = 0; i < rrs.Length; i++)
{
if (first == 0 && rrs[i] != null) first = i + 1;
if (first != 0 && rrs[i] == null) { last = i; break; }
}
wm1Cfg.Name = string.Format("WM{0}", first);
wm2Cfg.Name = string.Format("WM{0}", first + 1);
wmLastCfg.Name = string.Format("WM{0}", last);
}
else
{
wm1Cfg.Name = "WM1";
wm2Cfg.Name = "WM2";
wmLastCfg.Name = "WMn";
}
/// Route based - pump
if (args.FeedingPath != null && args.FeedingPath.Pump != null &&
@ -570,28 +757,52 @@ namespace TBF.UI.Process
/// <param name="args"></param>
void OnStateMachineTick(object sender, StateMachineTickEventArgs args)
{
log.DebugFormat("OnStateMachineTick: startMassIx={0} massIx={1} volumeIx={2} refErrorIx={3} itemsCount={4}",
startMassIx, massIx, volumeIx, refErrorIx, testDataListView.Items.Count);
try
{
/// Redraw schematic drawing
UpdateRouteMsrdValuesAndSetpoints(args.Route);
///
/// Update test data
///
double density = Formulas.WaterDensityFromTempPress((ProcessData.TempUp.Val + ProcessData.TempDown.Val) / 2,
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2);
double volumeCtv = 1000 * Formulas.Buoyancy() * (ProcessData.Mass - ProcessData.StartMass.Val) / density;
//double refVolume = cBrd.RefPulses * cBrd.Devices.FlowMeter.LtrPerPulse;
double refVolume = ProcessData.LtrPerRefPulse * ProcessData.RefPulses;
double refError = Formulas.ErrorFromVolumes(refVolume, volumeCtv);
//if (ProcessData.RegisterReaders == null || ProcessData.BatchRslts == null ||
// ProcessData.BatchRslts.Batch == null || ProcessData.BatchRslts.Batch.WaterMeters == null)
//{
// return;
//}
if (refErrorIx != 0 && testDataListView.Items.Count > refErrorIx)
{
if (ProcessData.StartMass.Valid)
{
double converted = Units.ConvertTo(ProcessData.MassUnit, ProcessData.StartMass.Val);
testDataListView.Items[startMassIx].SubItems[1].Text = converted.ToString(Common.Utils.SignificantDigitsToFmt(converted, 6));
converted = Units.ConvertTo(ProcessData.MassUnit, ProcessData.Mass - ProcessData.StartMass.Val);
testDataListView.Items[massIx].SubItems[1].Text = converted.ToString(Common.Utils.SignificantDigitsToFmt(converted, 6));
converted = Units.ConvertTo(ProcessData.VolumeUnit, volumeCtv);
testDataListView.Items[volumeIx].SubItems[1].Text = converted.ToString(Common.Utils.SignificantDigitsToFmt(converted, 5));
testDataListView.Items[refErrorIx].SubItems[1].Text = refError.ToString(Common.Utils.SignificantDigitsToFmt(refError, 3));
}
else
{
testDataListView.Items[startMassIx].SubItems[1].Text = "---";
testDataListView.Items[massIx].SubItems[1].Text = "---";
testDataListView.Items[volumeIx].SubItems[1].Text = "---";
testDataListView.Items[refErrorIx].SubItems[1].Text = "---";
}
}
///
/// Update water meter states
///
TBF.Rig.ControlBoard.IControlBoard cBrd = TBF.Rig.StateMachine.ControlBoard;
if (cBrd != null && cBrd.Devices != null && cBrd.Devices.FlowMeter != null && ProcessData.RegisterReaders != null)
if (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null && ProcessData.RegisterReaders != null)
{
double refVolume = cBrd.RefPulses * cBrd.Devices.FlowMeter.LtrPerPulse;
for (int i = 0; i < Math.Min(processListViewEx.Items.Count, ProcessData.RegisterReaders.Length); i++)
for (int i = 0; i < Math.Min(metersListView.Items.Count, ProcessData.RegisterReaders.Length); i++)
{
var lvi = processListViewEx.Items[i];
var lvi = metersListView.Items[i];
var rr = ProcessData.RegisterReaders[i];
if (rr != null && Math.Abs(rr.WMVolume) > float.Epsilon && refVolume > float.Epsilon)
@ -616,6 +827,11 @@ namespace TBF.UI.Process
}
}
}
///
/// Redraw schematic drawing
///
UpdateRouteMsrdValuesAndSetpoints(args.Route);
}
catch (Exception e)
{
@ -627,6 +843,10 @@ namespace TBF.UI.Process
void UpdateRouteMsrdValuesAndSetpoints(UInt128 route)
{
//if (route != processDrawingCtrl.Route)
//{
// int a = 5;
//}
processDrawingCtrl.Route = route;
for (int i = 0; i < cmpntWithMeasuredVal.Length; i++)
@ -647,7 +867,7 @@ namespace TBF.UI.Process
for (int i = 0; i < cmpntWithSetpoint.Length; i++)
{
processDrawingCtrl.Setpoints[0] = (cmpntWithSetpoint[i] != null) ? cmpntWithSetpoint[i].SetpointVal : 0;
processDrawingCtrl.Setpoints[i] = (cmpntWithSetpoint[i] != null) ? cmpntWithSetpoint[i].SetpointVal : 0;
}
}
@ -662,10 +882,10 @@ namespace TBF.UI.Process
int wmsCount = Math.Min(ProcessData.RegisterReaders.Length, ProcessData.BatchRslts.Batch.WaterMeters.Count);
if (processListViewEx.Items.Count != wmsCount)
if (metersListView.Items.Count != wmsCount)
{
/// Invoked only when the number of water meters or register readers changes
processListViewEx.Items.Clear();
metersListView.Items.Clear();
for (int i = 0; i < wmsCount; i++)
{
var lvi = new ListViewItem((i + 1).ToString()); /// Column 0
@ -674,7 +894,7 @@ namespace TBF.UI.Process
lvi.SubItems.Add(".");
}
lvi.Tag = ProcessData.BatchRslts.Batch.WaterMeters[i];
processListViewEx.Items.Add(lvi);
metersListView.Items.Add(lvi);
}
}
@ -682,13 +902,13 @@ namespace TBF.UI.Process
{
for (int i = 0; i < wmsCount; i++)
{
var wm = processListViewEx.Items[i].Tag as Results.Entities.WaterMeter;
var wm = metersListView.Items[i].Tag as Results.Entities.WaterMeter;
if (wm != null && !wm.Disabled)
{
Results.Entities.MeterTestRslt mtr = wm.MeterTestRslts.FirstOrDefault(x => x.TestRslt == args.TestRslt);
if (mtr != null)
{
var lvi = processListViewEx.Items[i];
var lvi = metersListView.Items[i];
/// Update a list view item
lvi.SubItems[(int)Column.Error].Text = mtr.Error.ToString("F1");

View File

@ -68,6 +68,8 @@ namespace TBF.UiBridge
/// </summary>
public static void OnTestSelected(object sender, TestSelectedEventArgs data)
{
TBF.Rig.Sequences.ProcessData.ClearProcessValues();
if (TestSelectedHandler == null) return;
try { TestSelectedHandler(sender, data); }
catch (Exception e) { log.Error("TestSelectedHandler(...) failed", e); }