Compare commits

..
Author SHA1 Message Date
Milan Hanajik 9fe64b4438 Reconfigured for WARSAW-END 2019-08-07 15:22:56 +02:00
370 changed files with 5372 additions and 9216 deletions
-1
View File
@@ -29,6 +29,5 @@ Users/obj/
UserManagement/bin/
UserManagement/obj/
Doc/
.vs/
*.suo
*.bak
+2 -2
View File
@@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;DEBUG;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
-3
View File
@@ -56,9 +56,6 @@ namespace Config.Entities
public virtual string RelTransAfter { get; set; }
public virtual string TransitionAfter { get; set; }
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
public virtual IList<ComponentTest> MoreParams { get; set; }
public virtual Procedure Procedure { get; set; }
+2 -5
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -11,11 +11,8 @@ namespace Config.Entities
public virtual int Id { get; protected set; }
public virtual string UserName { get; set; } /// = name, alias, abbreviation
public virtual string FullName { get; set; } /// = description
public virtual string Tag { get; set; }
public virtual int Number { get; set; }
public virtual int Number { get; set; }
public virtual string Password { get; set; }
public virtual string Password2 { get; set; }
public virtual string Password3 { get; set; }
public virtual DateTime LastPwChange { get; set; }
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
+1 -4
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
@@ -12,9 +12,6 @@ namespace Config.Mappings
Id(x => x.Id);
Map(x => x.UserName).Column("Name");
Map(x => x.Number);
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
Map(x => x.Tag);
#endif
Map(x => x.Password);
Map(x => x.FullName).Column("Description");
Map(x => x.LastPwChange);
+2 -10
View File
@@ -85,15 +85,7 @@ namespace Config
/// <summary>
/// Extract and return a DB server from a MySQL connection string.
/// </summary>
public static string GetDBServer(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "SERVER=" });
}
/// <summary>
/// Extract and return a DB name from a MySQL connection string.
/// Extract and return a database name from a MySQL connection string.
/// </summary>
public static string GetDBName(string connectionString)
{
@@ -113,7 +105,7 @@ namespace Config
/// </summary>
public static string GetDBPassword(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=", "PWD=" });
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=" });
}
/// <summary>
+10 -9
View File
@@ -7,6 +7,7 @@ using System.Threading;
using System.Windows.Forms;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using System.Xml.Serialization;
@@ -26,11 +27,11 @@ namespace DeviceTest
IComponentCfg component2Cfg;
IComponentCfg component3Cfg;
static IList<IDevice> tbfDevices;
static IList<IComponent> tbfComponents;
static IComponent tbfComponent1forOp;
static IComponent tbfComponent2forOp;
static IComponent tbfComponent3forOp;
static IList<TBF.BenchControl.Generic.IDevice> tbfDevices;
static IList<TBF.BenchControl.Generic.IComponent> tbfComponents;
static TBF.BenchControl.Generic.IComponent tbfComponent1forOp;
static TBF.BenchControl.Generic.IComponent tbfComponent2forOp;
static TBF.BenchControl.Generic.IComponent tbfComponent3forOp;
static Thread workerThread;
static bool workerThreadRunning;
@@ -425,7 +426,7 @@ namespace DeviceTest
cfgControl.Config = parentCfg;
cfgControl.Config.ItemNr = 0;
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
cfgForm.TbfComponents = new List<Config.Entities.Component>();
cfgForm.ComponentCfgCtrl = cfgControl;
@@ -454,7 +455,7 @@ namespace DeviceTest
cfgControl.Config = component1Cfg;
cfgControl.Config.ItemNr = 1;
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -488,7 +489,7 @@ namespace DeviceTest
cfgControl.Config = component2Cfg;
cfgControl.Config.ItemNr = 1;
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -523,7 +524,7 @@ namespace DeviceTest
cfgControl.Config = component3Cfg;
cfgControl.Config.ItemNr = 1;
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
+5 -11
View File
@@ -130,19 +130,13 @@ namespace Results
public static BatchResults FromBatch(Batch batch)
{
if (batch.WaterMeters == null || batch.WaterMeters.Count == 0) return null;
int wmCount = batch.WaterMeters.Count;
if (wmCount == 0) return null;
int wmPosMax = 0;
foreach (var wm in batch.WaterMeters) if (wm.WMPosition > wmPosMax) wmPosMax = wm.WMPosition;
BatchResults batchResults = new BatchResults(wmPosMax);
BatchResults batchResults = new BatchResults(wmCount);
batchResults.Batch = batch;
batchResults.WaterMeters = new WaterMeter[wmPosMax];
for (int i = 0; i < batch.WaterMeters.Count; i++)
{
WaterMeter wm = batch.WaterMeters[i];
batchResults.WaterMeters[wm.WMPosition - 1] = wm;
}
batchResults.WaterMeters = new WaterMeter[wmCount];
for (int i = 0; i < wmCount; i++) batchResults.WaterMeters[i] = batch.WaterMeters[i];
return batchResults;
}
-1
View File
@@ -135,7 +135,6 @@ namespace Results.Entities
public virtual double TargetTime() { return TestData.TargetTime; }
public virtual string Method() { return TestData.Method; }
public virtual string RefFlowmeter() { return (Components != null) ? Components.Flowmeter : string.Empty; }
public virtual string Scale() { return (Components != null) ? Components.Scale : string.Empty; }
public virtual bool IsRelErrTest() { return (MethodClass != null) ? (MethodClass.Contains("FixedStart") || MethodClass.Contains("FlyingStart") || MethodClass.Contains("CombinedWithDetection") || MethodClass.Contains("DiverterTest")) : true; }
public virtual bool IsPMaxTest() { return (MethodClass != null) ? (MethodClass.Contains("PMaxTest") || MethodClass.Contains("LeakTest")) : true; }
public virtual bool IsStartStop() { return (MethodClass != null) ? MethodClass.Contains("FixedStart") : true; }
-6
View File
@@ -528,12 +528,6 @@ namespace Results.Entities
return NokColor;
}
}
else if (Disabled)
{
/// Water meter was not completed yet => did not pass, did not fail
message = Strings.This_position_is_disabled;
return NotCompletedColor;
}
else
{
/// Water meter was not completed yet => did not pass, did not fail
+298 -197
View File
@@ -1,5 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using log4net;
using Config.Entities;
@@ -13,33 +18,43 @@ namespace Results.Forms
{
static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsDlg));
DateTime lastRedraw;
DateTime lastSizeChange;
bool loaded;
///
/// Public members
///
public Results.BatchResults Results;
public IList<Results.WMeterRsltItemSpec> Items;
public MetersArrangement MetersArrangement;
public TestsArrangement TestsArrangement;
public int NrMetersInOneGroup;
public bool ShowDisabledPositions;
public int MinWidth;
public int MinHeight;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_SingleWM;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_CombinedWM;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_HeatM;
public int[] RsltsClmnWidths { set { rsltsClmnWidths = value; } }
public int PopupResultsLeft;
public int PopupResultsTop;
public int PopupResultsWidth;
public int PopupResultsHeight;
public int[] RsltsClmnWidths;
public Results.BatchResults Results { set { Display(value); } }
///
/// Private members
///
IOneWMResultsCtrl[] wmRsltsCtrl; /// An array of controls with water meter results.
IOneWMResultsCtrl firstEnabledControl;
DateTime lastRedraw;
DateTime lastSizeChange;
int metersInOneGroup;
int nrGroups;
Results.BatchResults results;
MetersKind metersKind;
OneWMResultsCtrl firstListView;
public int[] rsltsClmnWidths;
int rsltsClmnCount { get { return (rsltsClmnWidths != null) ? rsltsClmnWidths.Length : 0; } }
int lvWidth;
int lvHeight;
Timer timer;
@@ -47,196 +62,310 @@ namespace Results.Forms
public BatchResultsDlg()
{
InitializeComponent();
Text = Strings.Results;
firstEnabledControl = null;
lastSizeChange = DateTime.Now;
nrGroups = 1;
metersInOneGroup = 1;
/// Create a timer with one second interval.
// Create a timer with a ten second interval.
timer = new Timer();
timer.Interval = 1000; /// ms
timer.Interval = 500; /// ms
timer.Tick += new EventHandler(OnTimer);
timer.Start();
}
private void BatchResultsDlg_Load(object sender, EventArgs e)
{
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
if (PopupResultsTop != 0) Top = PopupResultsTop;
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
if (PopupResultsTop != 0) Top = PopupResultsTop;
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
if (PopupResultsHeight != 0) Height = PopupResultsHeight;
CreateControlsAndFillPanel(Results);
UpdateColumnWidths(RsltsClmnWidths);
UpdateResults(Results);
loaded = true;
if (results != null) Redraw();
}
public void Display(Results.BatchResults results)
{
this.results = results;
if (loaded) Redraw();
}
///
/// Handle double-click inside a water meter results control
///
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
IList<Results.WMeterRsltItemSpec> GetRsltItems(MetersKind metersKind)
{
if (Results.WaterMeters != null && args.WMPosition > 0)
IList<Results.WMeterRsltItemSpec> srcItems;
switch (metersKind)
{
foreach (var wm in Results.WaterMeters)
{
if ((wm != null) && (wm.WMPosition == args.WMPosition))
{
ShowMoreWMResults(wm);
return;
}
}
default:
case MetersKind.Single: srcItems = RsltItems_Screen_SingleWM; break;
case MetersKind.Combined: srcItems = RsltItems_Screen_CombinedWM; break;
case MetersKind.HeatMeter: srcItems = RsltItems_Screen_HeatM; break;
}
MessageBox.Show(Strings.No_water_meter);
return;
}
void UpdateColumnWidths(int[] columnWidths)
{
foreach (var ctrl in wmRsltsCtrl) ctrl.Update(columnWidths);
}
void UpdateScrollpositions(int scrollStart)
{
/// TODO
IList<Results.WMeterRsltItemSpec> copiedItems = new List<Results.WMeterRsltItemSpec>();
foreach (var it in srcItems) copiedItems.Add(it.Clone());
return copiedItems;
}
/// <summary>
/// Re-draw the results. Apply new settings if they changed.
/// </summary>
void CreateControlsAndFillPanel(Results.BatchResults results)
public void Redraw()
{
if ((results == null) || (results.WMPositionsCount == 0))
lastRedraw = DateTime.Now;
this.SuspendLayout();
try
{
/// There are no water meters at all
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
enabledWMsCount++;
}
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + metersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
wmRsltsCtrl = new OneWMResultsRowsCtrl[0];
firstEnabledControl = null;
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
OneWMResultsCtrl lview = (TestsArrangement == TestsArrangement.Rows)
? GetResultsTestsAreRows(results.WaterMeters[i], i + 1)
: GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
if (lview != null)
{
flowLayoutPanel.Controls.Add(lview);
if (first)
{
firstListView = lview;
first = false;
}
lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args)
{
if (InvokeRequired)
{
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), sender, args);
}
else
{
OnDoubleClick(sender, args);
}
};
}
}
}
}
catch (Exception e)
{
log.FatalFormat("Redrawing results failed : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
}
this.ResumeLayout(false);
}
/// <summary>
/// Get an empty ListView control with appropriate parameters.
/// </summary>
/// <returns>ListView control</returns>
OneWMResultsCtrl GetListView(Color backColor, Results.Entities.WaterMeter wm)
{
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm);
}
///
OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm)
{
return GetListView(Color.White, wm);
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
OneWMResultsCtrl GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
string message = string.Empty;
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
#if ORACLE_DB
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int col = 1;
foreach (var item in items)
{
lview.Columns.Add(item.Caption, (rsltsClmnCount > col) ? rsltsClmnWidths[col] : 70);
col++;
}
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
int ix = 0;
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
&& mtr.Publish() != Config.Entities.Publish.Internal)
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
for (int i = 0; i < items.Count; i++)
{
string str = items[i].Print(wMtr, mtr.Name());
/// Extract and use color information
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
lview.Items.Add(lvi);
}
}
return lview;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
OneWMResultsCtrl GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
#if ORACLE_DB
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
lview.Columns.Add(str, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
i++;
}
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Caption);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lview.Items.Add(lvi);
}
return lview;
}
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
{
if ( args.WM == null || args.WM.Disabled)
{
MessageBox.Show(Strings.No_water_meter);
return;
}
///
/// Determine water meter positions count
///
int displayedControlsCount = 0;
for (int i = 0; i < results.WaterMeters.Length; i++)
else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr))
{
if (((results.WaterMeters[i] != null) && !results.WaterMeters[i].Disabled) || ShowDisabledPositions)
{
displayedControlsCount++;
}
}
///
/// Calculate geometry
///
metersInOneGroup = Math.Max(1, Math.Min(displayedControlsCount, NrMetersInOneGroup));
nrGroups = Math.Max(1, (displayedControlsCount + metersInOneGroup - 1) / metersInOneGroup);
int oneWidth;
int oneHeight;
///
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
}
///
/// Create controls and fill the FlowLayoutPanel
///
flowLayoutPanel.SuspendLayout();
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
wmRsltsCtrl = new IOneWMResultsCtrl[displayedControlsCount];
int ix = 0;
firstEnabledControl = null;
for (int i = 0; i < results.WaterMeters.Length; i++)
{
if (((results.WaterMeters[i] != null) && !results.WaterMeters[i].Disabled) || ShowDisabledPositions)
{
/// Create one water meter position / control
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
? new OneWMResultsRowsCtrl() as IOneWMResultsCtrl
: new OneWMResultsColumnsCtrl() as IOneWMResultsCtrl;
wmRsltsCtrl[ix].Width = oneWidth;
wmRsltsCtrl[ix].Height = oneHeight;
if ((results.WaterMeters[i] != null) && !results.WaterMeters[i].Disabled)
{
if ((firstEnabledControl == null) && (results.WaterMeters[i] != null) && !results.WaterMeters[i].Disabled)
{
firstEnabledControl = wmRsltsCtrl[ix];
}
//wmRsltsCtrl[ix].Update(results.WaterMeters[i].WMPosition);
wmRsltsCtrl[ix].Update(Items);
wmRsltsCtrl[ix].WMResultsClickedHandler += delegate(object s, Results.Forms.WaterMeterEventArgs args)
{
if (InvokeRequired)
{
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), s, args);
}
else
{
OnDoubleClick(s, args);
}
};
}
flowLayoutPanel.Controls.Add(wmRsltsCtrl[ix] as UserControl);
ix++;
}
}
flowLayoutPanel.ResumeLayout();
lastRedraw = DateTime.Now;
}
void UpdateResults(Results.BatchResults results)
{
if ((results != null) && (results.WaterMeters != null))
{
int ctrlIx = 0;
for (int i = 0; i < results.WaterMeters.Length; i++)
{
if (((results.WaterMeters[i] != null) && !results.WaterMeters[i].Disabled) || ShowDisabledPositions)
{
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(results.WaterMeters[i]);
}
}
}
}
void ShowMoreWMResults(Results.Entities.WaterMeter wm)
{
if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(wm.SerialNr))
{
new Results.Forms.MoreWMResultsDlg(wm, null).ShowDialog();
new Results.Forms.MoreWMResultsDlg( args.WM, null).ShowDialog();
}
else
{
using (ISession session = TracingDB.DB.SessionFactory.OpenSession())
{
IList<ReferenceRecord> refRecords = session.QueryOver<ReferenceRecord>()
.Where(x => (x.Code == wm.SerialNr))
.Where(x => (x.Code == args.WM.SerialNr))
.OrderBy(x => x.TimeStamp).Desc
.List();
for (int i = 0; i < refRecords.Count; i++)
@@ -262,7 +391,7 @@ namespace Results.Forms
}
}
new Results.Forms.MoreWMResultsDlg(wm, refRecords).ShowDialog();
new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog();
}
}
}
@@ -276,7 +405,6 @@ namespace Results.Forms
PopupResultsHeight = Height;
}
private void flowLayoutPanel_SizeChanged(object sender, EventArgs e)
{
lastSizeChange = DateTime.Now;
@@ -286,40 +414,13 @@ namespace Results.Forms
{
if (DateTime.Compare(lastSizeChange, lastRedraw) > 0)
{
/// The last size change was more recent then the last redraw
/// The last size change was later then the last redraw
DateTime now = DateTime.Now;
if (DateTime.Compare(lastSizeChange + new TimeSpan(0, 0, 1), now) < 0)
{
/// More then 1 second since the last panel size change
/// Calculate geometry
int oneWidth;
int oneHeight;
///
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
}
/// Update size of controls
flowLayoutPanel.SuspendLayout();
///
foreach (var oneCtrl in wmRsltsCtrl)
{
oneCtrl.Width = oneWidth;
oneCtrl.Height = oneHeight;
}
///
flowLayoutPanel.ResumeLayout();
/// More then 1s since the last size change
Redraw();
}
}
}
-25
View File
@@ -1,25 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Results.Forms
{
public interface IOneWMResultsCtrl
{
event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
bool Disabled { get; } /// true when water meter position is disabled
int WMPosition { get; } /// 1-based WM position
int Width { get; set; } /// Control width
int Height { get; set; } /// Control height
ListView.ColumnHeaderCollection Columns { get; } /// Embedded ListView control columns
void Update(int[] columnWidths);
void Update(IList<Results.WMeterRsltItemSpec> items);
void Update(Results.Entities.WaterMeter wMtr);
}
}
+24 -11
View File
@@ -29,13 +29,15 @@
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.graphsTabPage = new System.Windows.Forms.TabPage();
this.productionTracingTabPage = new System.Windows.Forms.TabPage();
this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer();
this.messageLabel = new System.Windows.Forms.Label();
this.tracingResultsListView = new System.Windows.Forms.ListView();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsCtrl();
this.tabControl1.SuspendLayout();
this.allResultsTabPage.SuspendLayout();
this.productionTracingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
this.productionTracingSplitContainer.Panel1.SuspendLayout();
@@ -55,6 +57,17 @@
this.tabControl1.Size = new System.Drawing.Size(1195, 448);
this.tabControl1.TabIndex = 0;
//
// allResultsTabPage
//
this.allResultsTabPage.Controls.Add(this.oneWMResultsCtrl);
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// graphsTabPage
//
this.graphsTabPage.Location = new System.Drawing.Point(4, 22);
@@ -120,15 +133,14 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// allResultsTabPage
// oneWMResultsCtrl
//
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
this.oneWMResultsCtrl.Caption = "";
this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3);
this.oneWMResultsCtrl.Name = "oneWMResultsCtrl";
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
this.oneWMResultsCtrl.TabIndex = 0;
//
// MoreWMResultsDlg
//
@@ -140,6 +152,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Water meter results";
this.tabControl1.ResumeLayout(false);
this.allResultsTabPage.ResumeLayout(false);
this.productionTracingTabPage.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.PerformLayout();
@@ -153,12 +166,12 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage allResultsTabPage;
private OneWMResultsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage graphsTabPage;
private System.Windows.Forms.TabPage productionTracingTabPage;
private System.Windows.Forms.SplitContainer productionTracingSplitContainer;
private System.Windows.Forms.Label messageLabel;
private System.Windows.Forms.ListView tracingResultsListView;
private System.Windows.Forms.TabPage allResultsTabPage;
}
}
+46 -46
View File
@@ -26,7 +26,7 @@ namespace Results.Forms
if (refRecords == null)
{
tabControl1.SelectTab(1);
tabControl1.TabPages.RemoveAt(2);
tabControl1.TabPages[2].Hide();
}
else
{
@@ -51,57 +51,57 @@ namespace Results.Forms
/// <param name="wMtr">Water meter entity</param>
void ShowAllResults(Results.Entities.WaterMeter wMtr)
{
// string message;
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
//#if ORACLE_DB
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
//#else
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
//#endif
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
#if ORACLE_DB
oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// // Header
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
// int i = 1;
// foreach (var str in wMtr.GetAllDecoratedTestNames())
// {
// oneWMResultsCtrl.Columns.Add(str, 100);
// i++;
// }
// Header
oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
oneWMResultsCtrl.Columns.Add(str, 100);
i++;
}
// foreach (var item in items)
// {
// ListViewItem lvi = new ListViewItem(item.Name);
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Name);
// foreach (var mtr in wMtr.MeterTestRslts)
// {
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
// mtr.Publish() != Config.Entities.Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.Name());
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
// string[] texts = str.Split(new char[] { '|' });
// if (texts.Length == 1)
// {
// lvi.SubItems.Add(str);
// }
// else if (texts.Length == 2)
// {
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
// lvi.UseItemStyleForSubItems = false;
// lvi.SubItems.Add(texts[0]);
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
// }
// else
// {
// lvi.SubItems.Add(string.Empty);
// }
// }
// }
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
// oneWMResultsCtrl.Items.Add(lvi);
// }
oneWMResultsCtrl.Items.Add(lvi);
}
}
-103
View File
@@ -1,103 +0,0 @@
namespace Results.Forms
{
partial class OneWMResultsColumnsCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tBox = new System.Windows.Forms.TextBox();
this.lView = new System.Windows.Forms.ListView();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tBox);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.lView);
this.splitContainer1.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.SplitterDistance = 25;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 0;
//
// tBox
//
this.tBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.tBox.Location = new System.Drawing.Point(0, 0);
this.tBox.Name = "tBox";
this.tBox.Size = new System.Drawing.Size(352, 20);
this.tBox.TabIndex = 0;
this.tBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tBox_MouseDoubleClick);
//
// lView
//
this.lView.Dock = System.Windows.Forms.DockStyle.Fill;
this.lView.FullRowSelect = true;
this.lView.GridLines = true;
this.lView.Location = new System.Drawing.Point(0, 0);
this.lView.Name = "lView";
this.lView.Size = new System.Drawing.Size(352, 292);
this.lView.TabIndex = 0;
this.lView.UseCompatibleStateImageBehavior = false;
this.lView.View = System.Windows.Forms.View.Details;
//
// OneWMResultsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "OneWMResultsCtrl";
this.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TextBox tBox;
private System.Windows.Forms.ListView lView;
}
}
-159
View File
@@ -1,159 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace Results.Forms
{
public partial class OneWMResultsColumnsCtrl : UserControl, IOneWMResultsCtrl
{
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
///
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
}
catch (Exception)
{
}
}
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
public int WMPosition { get { return wmPosition; } } /// Read only
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
public OneWMResultsColumnsCtrl()
{
InitializeComponent();
disabled = false;
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
public void Update(int[] columnWidths)
{
this.columnWidths = columnWidths;
/// Always update ListView column widths
int col = 0;
foreach (ColumnHeader column in lView.Columns)
{
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
col++;
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
}
public void Update(Results.Entities.WaterMeter wMtr)
{
if (wMtr == null || wMtr.Disabled)
{
/// Water meter position is disabled
this.disabled = true;
lView.Items.Clear();
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
return;
}
/// Update background color
string message = string.Empty;
Update(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
/// Header
lView.Columns.Add(wmPosition.ToString(), (columnWidths != null && columnWidths.Length > 0) ? columnWidths[0] : 40);
int col = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
lView.Columns.Add(str, (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : 70);
col++;
}
lView.Items.Clear();
if (items == null || items.Count == 0) return;
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Caption);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lView.Items.Add(lvi);
}
}
///
/// Private
///
void Update(int wmPosition)
{
this.wmPosition = wmPosition;
if (lView.Columns.Count > 0)
{
lView.Columns[0].Text = wmPosition.ToString();
}
}
void Update(Color backColor)
{
if (this.bkColor != backColor)
{
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
}
}
}
}
@@ -1,6 +1,6 @@
namespace Results.Forms
{
partial class OneWMResultsRowsCtrl
partial class OneWMResultsCtrl
{
/// <summary>
/// Required designer variable.
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using log4net;
namespace Results.Forms
{
public partial class OneWMResultsCtrl : UserControl
{
static readonly ILog log = LogManager.GetLogger(typeof(OneWMResultsCtrl));
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
public OneWMResultsCtrl()
{
InitializeComponent();
}
public OneWMResultsCtrl(Color backColor, int lvWidth, int lvHeight, Results.Entities.WaterMeter wm)
: this()
{
lView.BackColor = backColor;
tBox.BackColor = backColor;
Size = new System.Drawing.Size(lvWidth, lvHeight);
WM = wm;
}
public Results.Entities.WaterMeter WM;
public string Caption { get { return tBox.Text; } set { tBox.Text = value; } }
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } }
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
public Color BColor { set { lView.BackColor = value; tBox.BackColor = value; } }
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (WMResultsClickedHandler == null) return;
try { WMResultsClickedHandler(sender, new WaterMeterEventArgs(WM)); }
catch (Exception exc) { log.Error("WMResultsClickedHandler(...) failed", exc); }
}
}
}
-169
View File
@@ -1,169 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace Results.Forms
{
public partial class OneWMResultsRowsCtrl : UserControl, IOneWMResultsCtrl
{
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
///
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
}
catch (Exception)
{
}
}
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
public int WMPosition { get { return wmPosition; } } /// Read only
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
public OneWMResultsRowsCtrl()
{
InitializeComponent();
disabled = false;
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
public void Update(int[] columnWidths)
{
this.columnWidths = columnWidths;
/// Always update ListView column widths
int col = 0;
foreach (ColumnHeader column in lView.Columns)
{
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
col++;
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
/// Always draw ListView header
lView.Columns.Clear();
lView.Columns.Add(wmPosition.ToString(), (columnWidths != null && columnWidths.Length > 0) ? columnWidths[0] : 40);
if (items == null || items.Count == 0) return;
int col = 1;
foreach (var item in items)
{
lView.Columns.Add(item.Caption, (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : 70);
col++;
}
}
public void Update(Results.Entities.WaterMeter wMtr)
{
if (wMtr == null || wMtr.Disabled)
{
/// Water meter position is disabled
this.disabled = true;
lView.Items.Clear();
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
return;
}
/// Update background color
string message = string.Empty;
Update(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
Update(wMtr.WMPosition);
/// Update test results
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
int ix = 0;
lView.Items.Clear();
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
&& mtr.Publish() != Config.Entities.Publish.Internal)
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
if (items != null)
{
for (int i = 0; i < items.Count; i++)
{
string str = items[i].Print(wMtr, mtr.Name());
/// Extract and use color information
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lView.Items.Add(lvi);
}
}
}
///
/// Private
///
void Update(int wmPosition)
{
this.wmPosition = wmPosition;
if (lView.Columns.Count > 0)
{
lView.Columns[0].Text = wmPosition.ToString();
}
}
void Update(Color backColor)
{
if (this.bkColor != backColor)
{
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
}
}
}
}
+2 -2
View File
@@ -7,8 +7,8 @@ namespace Results.Forms
{
public class WaterMeterEventArgs : EventArgs
{
public int WMPosition;
public Results.Entities.WaterMeter WM;
public WaterMeterEventArgs(int wmPosition) { WMPosition = wmPosition; }
public WaterMeterEventArgs(Results.Entities.WaterMeter wm) { WM = wm; }
}
}
-13
View File
@@ -318,19 +318,6 @@ namespace Results
TimeBtwnMassMsrmnts, /// 270
TestTimeCorrection, /// 271
ThreeState, /// 272
Conduct, /// 273
Conduct_start, /// 274
Conduct_end, /// 275
Conduct_avg, /// 276
Conduct_min, /// 277
Conduct_max, /// 278
InfoFlags, /// 279
Scale, /// 280
Count,
}
}
+12 -45
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms.DataVisualization.Charting;
using Config.Entities;
using Results.Entities;
@@ -13,25 +14,17 @@ namespace Results.Output
{
public static Chart GetChart(WaterMeter wm, bool isPrinter)
{
return GetChart(wm, isPrinter, Config.Unit.lph);
return GetChart(wm, isPrinter, Config.Unit.lph, false);
}
public static Chart GetChart(WaterMeter wm, bool isPrinter, Config.Unit flowUnit)
public static Chart GetChart(WaterMeter wm, bool isPrinter, Config.Unit flowUnit, bool isQ4)
{
double maxFlow_m3h = 0;
IList<PointF> unsortedPoints = new List<PointF>();
foreach (var mtr in wm.MeterTestRslts)
{
if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestRslt.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0))
if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0))
{
double flow_m3h = (mtr.TestTime != 0)
? (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestTime * mtr.PulsesMaster / mtr.TestRslt.PulsesMaster)
: (3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime);
if (flow_m3h > maxFlow_m3h) maxFlow_m3h = flow_m3h;
double flow = Config.Units.ConvertTo(flowUnit, flow_m3h); /// Convert to specified units
double flow = Config.Units.ConvertTo(flowUnit, mtr.TestRslt.VolumeCTV / mtr.TestTime * 3.6 * mtr.PulsesMaster / mtr.TestRslt.PulsesMaster);
if (flow > 0)
{
unsortedPoints.Add(new PointF((float)flow, (float)mtr.Error));
@@ -40,8 +33,6 @@ namespace Results.Output
}
IEnumerable<PointF> sortedPoints = unsortedPoints.OrderBy(x => x.X);
bool isQ4 = (maxFlow_m3h > 1.1 * wm.WaterMeterData.Q3_Qn);
Chart chart = new Chart
{
Name = "chart",
@@ -56,7 +47,7 @@ namespace Results.Output
chArea.AxisX.Title = Strings.Flow;
chArea.AxisX.IsLogarithmic = true;
chArea.AxisX.LogarithmBase = 10;
chArea.AxisX.IsLabelAutoFit = true;
chArea.AxisX.IsLabelAutoFit = false;
List<double> xs = new List<double>() { 0.0001, 0.0002, 0.0005,
0.001, 0.002, 0.005,
@@ -68,43 +59,19 @@ namespace Results.Output
1000, 2000, 5000,
10000, 20000, 50000,
100000, 200000, 500000,
1000000, 2000000, 5000000,
10000000 };
1000000, 2000000, 5000000 };
double spacer = 0.8;
double from = Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin);
double to = Config.Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn);
bool inRange = false;
for (int i = 0; i < xs.Count - 3; i += 3)
for (int i = 1; i < xs.Count - 1; i++)
{
if (xs[i] <= from && from < xs[i + 3])
if ((xs[i + 1] > from) && (xs[i - 1] < to))
{
chArea.AxisX.Minimum = xs[i];
inRange = true;
}
if (inRange)
{
for (int j = i; j < i + 3; j++)
{
CustomLabel cl = new CustomLabel();
cl.Text = string.Format("{0} {1}", xs[j], flowUnit.ToDescription());
cl.FromPosition = Math.Log10(xs[j] * spacer);
cl.ToPosition = Math.Log10(xs[j] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
}
}
if (xs[i] < to && to <= xs[i + 3])
{
chArea.AxisX.Maximum = xs[i + 3];
CustomLabel cl = new CustomLabel();
cl.Text = string.Format("{0} {1}", xs[i + 3], flowUnit.ToDescription());
cl.FromPosition = Math.Log10(xs[i + 3] * spacer);
cl.ToPosition = Math.Log10(xs[i + 3] / spacer);
cl.Text = string.Format("{0} {1}", xs[i], flowUnit.ToDescription());
cl.FromPosition = Math.Log10(xs[i] * spacer);
cl.ToPosition = Math.Log10(xs[i] / spacer);
chArea.AxisX.CustomLabels.Add(cl);
break;
}
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.1290.0")]
[assembly: AssemblyFileVersion("2.18.1290.0")]
[assembly: AssemblyVersion("2.18.1278.0")]
[assembly: AssemblyFileVersion("2.18.1278.0")]
-9
View File
@@ -1230,15 +1230,6 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to This position is disabled.
/// </summary>
internal static string This_position_is_disabled {
get {
return ResourceManager.GetString("This_position_is_disabled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to to.
/// </summary>
-3
View File
@@ -333,7 +333,4 @@
<data name="Flow" xml:space="preserve">
<value>Průtok</value>
</data>
<data name="This_position_is_disabled" xml:space="preserve">
<value>Taro pozice je vypnuta</value>
</data>
</root>
-3
View File
@@ -816,7 +816,4 @@
<data name="Relative_error" xml:space="preserve">
<value>Relative error</value>
</data>
<data name="This_position_is_disabled" xml:space="preserve">
<value>This position is disabled</value>
</data>
</root>
+7 -17
View File
@@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;DEBUG;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -27,7 +27,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -75,7 +75,6 @@
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
@@ -88,17 +87,11 @@
<Compile Include="Forms\MoreWMResultsDlg.Designer.cs">
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\OneWMResultsColumnsCtrl.cs">
<Compile Include="Forms\OneWMResultsCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\OneWMResultsColumnsCtrl.designer.cs">
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Forms\OneWMResultsRowsCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\OneWMResultsRowsCtrl.Designer.cs">
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
<Compile Include="Forms\OneWMResultsCtrl.Designer.cs">
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ResultsConfigCtrl.cs">
<SubType>UserControl</SubType>
@@ -194,11 +187,8 @@
<EmbeddedResource Include="Forms\MoreWMResultsDlg.resx">
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\OneWMResultsColumnsCtrl.resx">
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\OneWMResultsRowsCtrl.resx">
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
<EmbeddedResource Include="Forms\OneWMResultsCtrl.resx">
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ResultsConfigCtrl.resx">
<DependentUpon>ResultsConfigCtrl.cs</DependentUpon>
-1
View File
@@ -325,7 +325,6 @@ namespace Results
: ((w.GetMeterTestRslt(t) == null) ? "" : w.GetMeterTestRslt(t).PassedColorStr(f))));
AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Scale, "Scale", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).Scale()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
///
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ResultsBrowser.Resources;
using TBF.BenchControl;
namespace ResultsBrowser.Forms
{
+1 -1
View File
@@ -91,7 +91,7 @@ namespace ResultsBrowser.Forms
cfgControl.Config = printerCfg;
cfgControl.Config.ItemNr = 0;
TBF.BenchControl.ComponentParametersDlg cfgForm = new TBF.BenchControl.ComponentParametersDlg();
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
cfgForm.TbfComponents = new List<Component>();
cfgForm.ComponentCfgCtrl = cfgControl;
+2 -2
View File
@@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;DEBUG;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -31,7 +31,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;BADGER_STREDNA_TRAT;LANG_CS</DefineConstants>
<DefineConstants>TRACE;WARSAW_END;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+176
View File
@@ -0,0 +1,176 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace TBF
{
/// <summary>
/// Data types and orientation of the table layout panel attached data.
/// </summary>
public enum Arrangement
{
RowOfIntegers,
RowOfDoubles,
RowOfStrings,
ColumnOfIntegers,
ColumnOfDoubles,
ColumnOfStrings,
}
/// <summary>
/// This class represents TextBox controls and data modified by them
/// that are attached to (=displayed inside) a TableLayoutPanel control.
/// </summary>
public class AttachedTextBoxes
{
///
/// Private fields
///
int count; /// Number of attached TextBoxes / cells
Arrangement arngmnt; /// Type of attachemnt (see above)
bool isRow; /// true if it is a row
TextBox[] textBoxes; /// TextBox controls to be aded to TableLayoutPanel
int[] intData; /// integer data |
double[] doubleData; /// double data |-> one of these three arrays is used
string[] stringData; /// string data |
/// <summary>
/// Constructor, which creates TextBox controls and adds them to the table layout panel.
/// </summary>
public AttachedTextBoxes(TableLayoutPanel tblLtPnl, Arrangement arngmnt, int firstColumn, int firstRow, int size)
{
this.count = size;
this.arngmnt = arngmnt;
isRow = (arngmnt == Arrangement.RowOfIntegers || arngmnt == Arrangement.RowOfDoubles || arngmnt == Arrangement.RowOfStrings);
textBoxes = new TextBox[count];
intData = new int[count];
doubleData = new double[count];
stringData = new string[count];
for (int i = 0; i < count; i++)
{
textBoxes[i] = new TextBox(); /// Crete a new TextBox control
if (isRow)
{
tblLtPnl.Controls.Add(textBoxes[i], firstColumn + i, firstRow);
}
else
{
tblLtPnl.Controls.Add(textBoxes[i], firstColumn, firstRow + i);
}
}
}
/// <summary>
/// Attached data array size
/// </summary>
public int Count { get { return count; } }
/// <summary>
/// Indexer returning a TextBox
/// </summary>
/// <param name="index">Index</param>
/// <returns>TextBox object reference</returns>
public TextBox this[int index]
{
get
{
if (index < 0 || index >= count)
{
return null;
}
else
{
return textBoxes[index];
}
}
}
/// <summary>
/// Retrieves data from the controls or detects a format error.
/// Wrong format in a cell interrupts data retrieving, so when the first control
/// contains data with wrong format, no data are retrieved at all.
/// </summary>
/// <returns>true if all data have correct format</returns>
public bool ValidateData()
{
switch (arngmnt)
{
case Arrangement.RowOfIntegers:
case Arrangement.ColumnOfIntegers:
for (int i = 0; i < count; i++)
{
if (!Int32.TryParse(textBoxes[i].Text, out intData[i])) return false;
}
return true;
case Arrangement.RowOfDoubles:
case Arrangement.ColumnOfDoubles:
for (int i = 0; i < count; i++)
{
if (!Double.TryParse(textBoxes[i].Text, out doubleData[i])) return false;
}
return true;
case Arrangement.RowOfStrings:
case Arrangement.ColumnOfStrings:
default:
return true;
}
}
/// <summary>
/// The following three methods provide initialization of controls with original data.
/// </summary>
public void SetData(int index, int value)
{
if (index < 0 || index >= count) return;
intData[index] = value;
textBoxes[index].Text = value.ToString();
}
public void SetData(int index, double value)
{
if (index < 0 || index >= count) return;
doubleData[index] = value;
textBoxes[index].Text = value.ToString();
}
public void SetData(int index, string value)
{
if (index < 0 || index >= count) return;
stringData[index] = value;
textBoxes[index].Text = value;
}
/// <summary>
/// The following three methods provide retrieving data from controls.
/// ValidateData() must be called first. The return value must be true.
/// </summary>
public int GetIntData(int index)
{
if (index < 0 || index >= count) return 0;
return intData[index];
}
public double GetDoubleData(int index)
{
if (index < 0 || index >= count) return 0;
return doubleData[index];
}
public string GetStringData(int index)
{
if (index < 0 || index >= count) return null;
return textBoxes[index].Text;
}
}
}
+75
View File
@@ -0,0 +1,75 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Drawing;
using System.Windows.Forms;
namespace TBF
{
public class BarGraph
{
int originX; /// Left coordinate of the bar
int originY; /// Top coordinate of the bar
int barWidth; /// Bar width, the bar is actualy 1 pixel wider
int barHeight; /// Bar height the bat is actualy 1 pixel higher
Color barColor; /// Bar color
Color backColor; /// Background color (above the bar)
/// Bar border is always black, 1 pixel wide
int barValue; /// The actual bar size (the bar is drawn from bottom)
System.Windows.Forms.Control control;
Rectangle rect;
/// Use this setter to update the bar size
public float FValue
{
get { return (float)barValue/(float)barHeight; }
set
{
Value = (int)(value * (float)barHeight);
control.Invalidate();
}
}
/// Use this setter to update the bar size
public int Value
{
get { return barValue; }
set
{
if (value < 0) barValue = 0;
else if (value >= barHeight) barValue = barHeight;
else barValue = value;
control.Invalidate();
}
}
/// <summary>
/// Constructor
/// </summary>
public BarGraph(System.Windows.Forms.Control control, int originX, int originY, int barWidth, int barHeight, Color barColor, Color backColor)
{
this.control = control;
this.originX = originX;
this.originY = originY;
this.barWidth = barWidth;
this.barHeight = barHeight;
this.barColor = barColor;
this.backColor = backColor;
rect = new Rectangle(originX, originY, barWidth + 1, barHeight + 1);
barValue = 0;
}
/// <summary>
/// Call this function in Form1_Paint(..), pass the arguments without any modifications
/// </summary>
public void Paint(Graphics g)
{
g.FillRectangle(new SolidBrush(backColor), originX + 1, originY + 1, barWidth, barHeight - barValue);
g.FillRectangle(new SolidBrush(barColor), originX + 1, originY + barHeight + 1 - barValue, barWidth, barValue);
g.DrawRectangle(new Pen(Color.Black, 2.0F), originX, originY, barWidth + 1, barHeight + 1);
}
}
}
@@ -1,38 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using Users;
using log4net;
namespace TBF.BenchControl.BackupAndSecurity.Default
{
/// <summary>
/// Holds backup and security options.
/// </summary>
public class Component : ComponentBase, GenericDevices.IBackupAndSecurity
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("BackupAndSecurity.Default({0})", Cfg.ToString(1)); }
readonly ComponentCfg myCfg;
public int MinPasswdLength { get { return myCfg.MinPasswdLength; } }
public int PasswdExpirationPeriodDays { get { return myCfg.PasswdExpirationPeriodDays; } }
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as ComponentCfg;
GlobalData.MinPasswdLength = myCfg.MinPasswdLength;
GlobalData.PasswdExpirationPeriodDays = myCfg.PasswdExpirationPeriodDays;
log.Debug(this.ToString());
}
}
}
@@ -1,125 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BackupAndSecurity.Default
{
/// <summary>
/// Holds backup and security options - serializable configuration.
/// </summary>
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
///
/// Serialized parameters
///
public int MinPasswdLength;
public int PasswdExpirationPeriodDays; /// 0 = validity is not limited
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
public ComponentCfg(IComponentFactory factory)
: this()
{
Factory = factory;
Name = "BackupAndSecurity";
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
MinPasswdLength = 6;
PasswdExpirationPeriodDays = 0;
}
string[] paramNames = new string[]
{
"Minimum password length (characters)",
"Password expiration period (days)",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public IList<string> ParamValues(int i)
{
return null;
}
public string ToString(int i)
{
if (i == -1)
{
return string.Format("{0}: Min. password length = {1} characters, Password expiration period = {2} days", Name, MinPasswdLength, PasswdExpirationPeriodDays);
}
switch (i)
{
case 0: return MinPasswdLength.ToString();
case 1: return PasswdExpirationPeriodDays.ToString();;
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: MinPasswdLength = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd;
case 1: PasswdExpirationPeriodDays = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int idummy;
switch (i)
{
case 0:
case 1:
/// Positive integers and zero are allowed
if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ComponentCfg prms)
{
prms.MinPasswdLength = this.MinPasswdLength;
prms.PasswdExpirationPeriodDays = this.PasswdExpirationPeriodDays;
}
public Config.Entities.IParamsProvider Clone()
{
ComponentCfg pars = new ComponentCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
@@ -1,26 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BackupAndSecurity.Default
{
public class ComponentFactory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Component(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(ComponentCfg.Serializer, component, this);
}
}
}
+1 -5
View File
@@ -20,11 +20,7 @@ namespace TBF.BenchControl
public int ItemNr { get { return cfg.ItemNr; } }
public DebugMode DebugLevel { get { return cfg.DebugLevel; } set { cfg.DebugLevel = value; } }
public LogLevel LogLevel { get { return cfg.LogLevel; } }
public IList<MeasurementCorrection> Corrections
{
get { return cfg.Corrections; }
set { cfg.Corrections = value; }
}
public IList<MeasurementCorrection> Corrections { get { return cfg.Corrections; } }
/// Constructor, components created in this way is used by
@@ -134,7 +134,7 @@ namespace TBF.BenchControl.DataEntry.Standard6
private void batchRemarkButton_Click(object sender, EventArgs e)
{
TBF.UI.Shared.RemarkDlg dlg = new TBF.UI.Shared.RemarkDlg() { Remark = ((BatchRemark == null) ? string.Empty : BatchRemark) };
TBF.Forms.RemarkDlg dlg = new TBF.Forms.RemarkDlg() { Remark = ((BatchRemark == null) ? string.Empty : BatchRemark) };
if (dlg.ShowDialog() == DialogResult.OK)
{
BatchRemark = dlg.Remark;
@@ -471,20 +471,17 @@ namespace TBF.BenchControl.DataEntry.StandardCamera
///
void UpdateExclamation(int uiCtrlPos) /// uiCtrlPos = 0 .. TextBoxesCount-1
{
if ((mode == Tst.End) || (mode == Tst.Both))
{
try
{
double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err);
}
catch
{
exclamations[uiCtrlPos].Visible = false;
}
}
try
{
double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (err > warningLimHi);
}
catch
{
exclamations[uiCtrlPos].Visible = false;
}
}
+4 -4
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2017 Sensus Slovensko a.s.
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -40,19 +40,19 @@ namespace TBF.BenchControl.Dummy.Balance
public float BuoyancyPress { get { return 1.013f; } }
public float BuoyancyHumi { get { return 50.0f; } }
public IOperation TaringOp(ref Boxes.DoubleBox tara)
public IOperation TaringOp(ref TBF.Boxes.DoubleBox tara)
{
tara.Val = 0;
return this;
}
public IOperation ReadMassOp(ref Boxes.DoubleBox mass)
public IOperation ReadMassOp(ref TBF.Boxes.DoubleBox mass)
{
mass.Val = 0;
return this;
}
public IOperation ReadStableMassOp(ref Boxes.DoubleBox mass, int readingsCount, double maxSpread, Config.Entities.MassMethod method)
public IOperation ReadStableMassOp(ref TBF.Boxes.DoubleBox mass, int readingsCount, double maxSpread, Config.Entities.MassMethod method)
{
mass.Val = 0;
return this;
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.BenchControl.GenericDevices;
using TBF.Boxes;
namespace TBF.BenchControl.Dummy.Diverter
{
@@ -18,11 +17,6 @@ namespace TBF.BenchControl.Dummy.Diverter
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
}
FloatBox switchTimeStart;
FloatBox switchTimeEnd;
public FloatBox SwitchTimeStart { get { return switchTimeStart; } }
public FloatBox SwitchTimeEnd { get { return switchTimeEnd; } }
public Component()
{
}
@@ -30,8 +24,6 @@ namespace TBF.BenchControl.Dummy.Diverter
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
switchTimeStart = new FloatBox();
switchTimeEnd = new FloatBox();
log.Debug(this.ToString());
}
@@ -2,11 +2,11 @@
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Dummy.FlowMeter
{
public partial class FlowMeterCfgCtrl : UserControl, IComponentCfgCtrl
+5 -7
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Text;
@@ -43,9 +43,7 @@ namespace TBF.BenchControl.Elde
public StatusP StatusP { get { return controlCom.StatusP; } }
public int EtPulses(int wmNr1) { return controlCom.EtPulses(wmNr1); }
public int EtPulsesK { get { return controlCom.EtPulsesK; } }
public int EtPulses2 { get { return controlCom.EtPulses2; } } /// DEWA_300: pulses from I12
public int EtPulses3 { get { return controlCom.EtPulses3; } } /// DEWA_300: pulses from I13
public UInt16 WMeterPulses(int wmNr1) { return controlCom.WMeterPulses(wmNr1); }
public UInt16 WMeterPulses(int wmNr1) { return controlCom.WMeterPulses(wmNr1); }
public int WMeterReference(int wmNr0) { return controlCom.WMeterReference(wmNr0); }
public uint RegulValveDAC(int rvNr0) { return controlCom.RegulValveDAC(rvNr0); }
public float Pressure(int prsNr0) { return controlCom.Pressure(prsNr0); }
@@ -503,7 +501,7 @@ namespace TBF.BenchControl.Elde
///
void ShowEmergencyStopForm()
{
(new TBF.UI.Shared.EmergencyStopForm()).Show();
(new TBF.Forms.EmergencyStopForm()).Show();
}
@@ -654,7 +652,7 @@ namespace TBF.BenchControl.Elde
/// <param name="testName">Test name (without repetitions)</param>
/// <param name="repetition">Repetition number</param>
/// <returns>Created operation</returns>
public IOperation ReadDiverterTransitionOp(IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, bool toTank,
public IOperation ReadDiverterTransitionOp(IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, TBF.Boxes.FloatBox transitionTimeSec,
Sequences.Statistics plotter, int batchNr, string testName, int repetition)
{
if (controlBoardCfg.DebugLevel == DebugMode.Simulate)
@@ -663,7 +661,7 @@ namespace TBF.BenchControl.Elde
}
else
{
return new ReadDiverterTransitionOp(this, div, runsCountWhenSendingCmd, runsCountWhenReadingDiv, toTank, plotter, batchNr, testName, repetition);
return new ReadDiverterTransitionOp(this, div, runsCountWhenSendingCmd, runsCountWhenReadingDiv, transitionTimeSec, plotter, batchNr, testName, repetition);
}
}
+1 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -28,8 +28,6 @@ namespace TBF.BenchControl.Elde
}
public int EtPulsesK { get { return 1; } }
public int EtPulses2 { get { return 0; } }
public int EtPulses3 { get { return 0; } }
double[] errFactor = new double[Config.Data.WMsCount + 1]; /// Internal
double[] wMeterPulsesF = new double[Config.Data.WMsCount + 1]; /// Internal
-7
View File
@@ -50,13 +50,6 @@ namespace TBF.BenchControl.Elde
public int EtPulsesK { get { return (int)ctrlBrdComponent.etPulsesK; } }
#endif
#if DEWA_300
public int EtPulses2 { get { return (int)ctrlBrdComponent.EtPulses2; } }
public int EtPulses3 { get { return (int)ctrlBrdComponent.EtPulses3; } }
#else
public int EtPulses2 { get { return 0; } }
public int EtPulses3 { get { return 0; } }
#endif
public UInt16 WMeterPulses(int wmNr1) { return (UInt16)ctrlBrdComponent.wMeterPuls[wmNr1]; }
public int WMeterReference(int wmNr0) { return (int)ctrlBrdComponent.wMeterReference[wmNr0]; }
+1 -7
View File
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using log4net;
using Dirichlet.Numerics;
using TBF.BenchControl.Generic;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.BenchControl.Elde.Diverter
@@ -46,10 +45,6 @@ namespace TBF.BenchControl.Elde.Diverter
public int ThresholdLo { get { return diverterCfg.ThresholdLo; } }
public int ThresholdHi { get { return diverterCfg.ThresholdHi; } }
FloatBox switchTimeStart;
FloatBox switchTimeEnd;
public FloatBox SwitchTimeStart { get { return switchTimeStart; } }
public FloatBox SwitchTimeEnd { get { return switchTimeEnd; } }
/// <summary>
/// For a given flow in [m3/h] returns a test time correction in [s]
@@ -75,8 +70,7 @@ namespace TBF.BenchControl.Elde.Diverter
if (diverterCfg.BitPosition < 0 || diverterCfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((UInt128)1) << diverterCfg.BitPosition);
switchTimeStart = new FloatBox(diverterCfg.DfltSwithTimeStartMs / 1000.0f);
switchTimeEnd = new FloatBox(diverterCfg.DfltSwithTimeEndMs / 1000.0f);
diverterNr0 = nextIdx++;
///
@@ -19,15 +19,13 @@ 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 ThresholdLo; /// 0..100 in %, threshold for low level when diverter transition time is measured
public int ThresholdHi; /// 0..100 in %, threshold for high level when diverter transition time is measured
public int DfltSwithTimeStartMs; /// Default diverter transition time 'start' or 'to tank' in ms
public int DfltSwithTimeEndMs; /// Default diverter transition time 'end' or 'to sink' in ms
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 ThresholdLo; /// 0..100 in %, threshold for low level when diverter transition time is measured
public int ThresholdHi; /// 0..100 in %, threshold for high level when diverter transition time is measured
/// Calibration info serialized parameters displayed in Metrology tab page
string calibCertificateNr;
+22 -92
View File
@@ -73,12 +73,6 @@ namespace TBF.BenchControl.Elde.Diverter
this.label8 = new System.Windows.Forms.Label();
this.thresholdHiTextBox = new System.Windows.Forms.TextBox();
this.thresholdHiLabel = new System.Windows.Forms.Label();
this.dfltSwitchTimeEndTextBox = new System.Windows.Forms.TextBox();
this.dfltSwitchTimeEndLabel = new System.Windows.Forms.Label();
this.dfltSwitchTimeStartTextBox = new System.Windows.Forms.TextBox();
this.dfltSwitchTimeStartLabel = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -87,7 +81,7 @@ namespace TBF.BenchControl.Elde.Diverter
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(144, 41);
this.nameTextBox.Location = new System.Drawing.Point(137, 41);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
@@ -95,7 +89,7 @@ namespace TBF.BenchControl.Elde.Diverter
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(21, 44);
this.nameLabel.Location = new System.Drawing.Point(27, 44);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
@@ -104,7 +98,7 @@ namespace TBF.BenchControl.Elde.Diverter
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(141, 17);
this.classNameLabel.Location = new System.Drawing.Point(134, 17);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
@@ -113,7 +107,7 @@ namespace TBF.BenchControl.Elde.Diverter
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(21, 67);
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;
@@ -122,7 +116,7 @@ namespace TBF.BenchControl.Elde.Diverter
// bitPositionLabel
//
this.bitPositionLabel.AutoSize = true;
this.bitPositionLabel.Location = new System.Drawing.Point(21, 91);
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;
@@ -131,7 +125,7 @@ namespace TBF.BenchControl.Elde.Diverter
// bitPositionTextBox
//
this.bitPositionTextBox.Enabled = false;
this.bitPositionTextBox.Location = new System.Drawing.Point(144, 88);
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;
@@ -140,7 +134,7 @@ namespace TBF.BenchControl.Elde.Diverter
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(144, 64);
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;
@@ -148,7 +142,7 @@ namespace TBF.BenchControl.Elde.Diverter
// startingEdgeTextBox
//
this.startingEdgeTextBox.Enabled = false;
this.startingEdgeTextBox.Location = new System.Drawing.Point(144, 180);
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 = 14;
@@ -156,7 +150,7 @@ namespace TBF.BenchControl.Elde.Diverter
// startingEdgeLabel
//
this.startingEdgeLabel.AutoSize = true;
this.startingEdgeLabel.Location = new System.Drawing.Point(21, 183);
this.startingEdgeLabel.Location = new System.Drawing.Point(27, 183);
this.startingEdgeLabel.Name = "startingEdgeLabel";
this.startingEdgeLabel.Size = new System.Drawing.Size(68, 13);
this.startingEdgeLabel.TabIndex = 13;
@@ -165,7 +159,7 @@ namespace TBF.BenchControl.Elde.Diverter
// thresholdLoTextBox
//
this.thresholdLoTextBox.Enabled = false;
this.thresholdLoTextBox.Location = new System.Drawing.Point(144, 203);
this.thresholdLoTextBox.Location = new System.Drawing.Point(137, 203);
this.thresholdLoTextBox.Name = "thresholdLoTextBox";
this.thresholdLoTextBox.Size = new System.Drawing.Size(46, 20);
this.thresholdLoTextBox.TabIndex = 17;
@@ -173,7 +167,7 @@ namespace TBF.BenchControl.Elde.Diverter
// thresholdLoLabel
//
this.thresholdLoLabel.AutoSize = true;
this.thresholdLoLabel.Location = new System.Drawing.Point(21, 206);
this.thresholdLoLabel.Location = new System.Drawing.Point(27, 206);
this.thresholdLoLabel.Name = "thresholdLoLabel";
this.thresholdLoLabel.Size = new System.Drawing.Size(69, 13);
this.thresholdLoLabel.TabIndex = 16;
@@ -182,7 +176,7 @@ namespace TBF.BenchControl.Elde.Diverter
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(197, 205);
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 = 18;
@@ -191,7 +185,7 @@ namespace TBF.BenchControl.Elde.Diverter
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(197, 183);
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 = 15;
@@ -231,7 +225,7 @@ namespace TBF.BenchControl.Elde.Diverter
// adcToTankTextBox
//
this.adcToTankTextBox.Enabled = false;
this.adcToTankTextBox.Location = new System.Drawing.Point(144, 157);
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;
@@ -239,7 +233,7 @@ namespace TBF.BenchControl.Elde.Diverter
// adcTankLabel
//
this.adcTankLabel.AutoSize = true;
this.adcTankLabel.Location = new System.Drawing.Point(21, 160);
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;
@@ -248,7 +242,7 @@ namespace TBF.BenchControl.Elde.Diverter
// adcToSinkTextBox
//
this.adcToSinkTextBox.Enabled = false;
this.adcToSinkTextBox.Location = new System.Drawing.Point(144, 134);
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;
@@ -256,7 +250,7 @@ namespace TBF.BenchControl.Elde.Diverter
// adcSinkLabel
//
this.adcSinkLabel.AutoSize = true;
this.adcSinkLabel.Location = new System.Drawing.Point(21, 137);
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;
@@ -425,7 +419,7 @@ namespace TBF.BenchControl.Elde.Diverter
// adcNrTextBox
//
this.adcNrTextBox.Enabled = false;
this.adcNrTextBox.Location = new System.Drawing.Point(144, 111);
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;
@@ -433,7 +427,7 @@ namespace TBF.BenchControl.Elde.Diverter
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(21, 114);
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;
@@ -442,7 +436,7 @@ namespace TBF.BenchControl.Elde.Diverter
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(197, 228);
this.label8.Location = new System.Drawing.Point(190, 228);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(15, 13);
this.label8.TabIndex = 29;
@@ -451,7 +445,7 @@ namespace TBF.BenchControl.Elde.Diverter
// thresholdHiTextBox
//
this.thresholdHiTextBox.Enabled = false;
this.thresholdHiTextBox.Location = new System.Drawing.Point(144, 226);
this.thresholdHiTextBox.Location = new System.Drawing.Point(137, 226);
this.thresholdHiTextBox.Name = "thresholdHiTextBox";
this.thresholdHiTextBox.Size = new System.Drawing.Size(46, 20);
this.thresholdHiTextBox.TabIndex = 28;
@@ -459,74 +453,16 @@ namespace TBF.BenchControl.Elde.Diverter
// thresholdHiLabel
//
this.thresholdHiLabel.AutoSize = true;
this.thresholdHiLabel.Location = new System.Drawing.Point(21, 229);
this.thresholdHiLabel.Location = new System.Drawing.Point(27, 229);
this.thresholdHiLabel.Name = "thresholdHiLabel";
this.thresholdHiLabel.Size = new System.Drawing.Size(67, 13);
this.thresholdHiLabel.TabIndex = 27;
this.thresholdHiLabel.Text = "Threshold Hi";
//
// dfltSwitchTimeEndTextBox
//
this.dfltSwitchTimeEndTextBox.Enabled = false;
this.dfltSwitchTimeEndTextBox.Location = new System.Drawing.Point(144, 272);
this.dfltSwitchTimeEndTextBox.Name = "dfltSwitchTimeEndTextBox";
this.dfltSwitchTimeEndTextBox.Size = new System.Drawing.Size(46, 20);
this.dfltSwitchTimeEndTextBox.TabIndex = 33;
//
// dfltSwitchTimeEndLabel
//
this.dfltSwitchTimeEndLabel.AutoSize = true;
this.dfltSwitchTimeEndLabel.Location = new System.Drawing.Point(21, 275);
this.dfltSwitchTimeEndLabel.Name = "dfltSwitchTimeEndLabel";
this.dfltSwitchTimeEndLabel.Size = new System.Drawing.Size(117, 13);
this.dfltSwitchTimeEndLabel.TabIndex = 32;
this.dfltSwitchTimeEndLabel.Text = "Default switch time end";
//
// dfltSwitchTimeStartTextBox
//
this.dfltSwitchTimeStartTextBox.Enabled = false;
this.dfltSwitchTimeStartTextBox.Location = new System.Drawing.Point(144, 249);
this.dfltSwitchTimeStartTextBox.Name = "dfltSwitchTimeStartTextBox";
this.dfltSwitchTimeStartTextBox.Size = new System.Drawing.Size(46, 20);
this.dfltSwitchTimeStartTextBox.TabIndex = 31;
//
// dfltSwitchTimeStartLabel
//
this.dfltSwitchTimeStartLabel.AutoSize = true;
this.dfltSwitchTimeStartLabel.Location = new System.Drawing.Point(21, 252);
this.dfltSwitchTimeStartLabel.Name = "dfltSwitchTimeStartLabel";
this.dfltSwitchTimeStartLabel.Size = new System.Drawing.Size(119, 13);
this.dfltSwitchTimeStartLabel.TabIndex = 30;
this.dfltSwitchTimeStartLabel.Text = "Default switch time start";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(197, 252);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(20, 13);
this.label9.TabIndex = 34;
this.label9.Text = "ms";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(197, 275);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(20, 13);
this.label10.TabIndex = 35;
this.label10.Text = "ms";
//
// DiverterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.dfltSwitchTimeEndTextBox);
this.Controls.Add(this.dfltSwitchTimeEndLabel);
this.Controls.Add(this.dfltSwitchTimeStartTextBox);
this.Controls.Add(this.dfltSwitchTimeStartLabel);
this.Controls.Add(this.label8);
this.Controls.Add(this.thresholdHiTextBox);
this.Controls.Add(this.thresholdHiLabel);
@@ -613,11 +549,5 @@ namespace TBF.BenchControl.Elde.Diverter
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox thresholdHiTextBox;
private System.Windows.Forms.Label thresholdHiLabel;
private System.Windows.Forms.TextBox dfltSwitchTimeEndTextBox;
private System.Windows.Forms.Label dfltSwitchTimeEndLabel;
private System.Windows.Forms.TextBox dfltSwitchTimeStartTextBox;
private System.Windows.Forms.Label dfltSwitchTimeStartLabel;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
}
}
@@ -80,8 +80,6 @@ namespace TBF.BenchControl.Elde.Diverter
startingEdgeTextBox.Text = config.StartingLevel.ToString();
thresholdLoTextBox.Text = config.ThresholdLo.ToString();
thresholdHiTextBox.Text = config.ThresholdHi.ToString();
dfltSwitchTimeStartTextBox.Text = config.DfltSwithTimeStartMs.ToString();
dfltSwitchTimeEndTextBox.Text = config.DfltSwithTimeEndMs.ToString();
adcTextBox1.Text = adc1.ToString();
adcTextBox2.Text = adc2.ToString();
@@ -100,8 +98,6 @@ namespace TBF.BenchControl.Elde.Diverter
startingEdgeTextBox.Enabled = true;
thresholdLoTextBox.Enabled = true;
thresholdHiTextBox.Enabled = true;
dfltSwitchTimeStartTextBox.Enabled = true;
dfltSwitchTimeEndTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -164,16 +160,6 @@ namespace TBF.BenchControl.Elde.Diverter
message += Environment.NewLine + "'Threshold HI' should be between 0 and 100%";
}
}
if (!int.TryParse(dfltSwitchTimeStartTextBox.Text, out dummy) || dummy <= 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Default switch time start' should be positive integer";
}
if (!int.TryParse(dfltSwitchTimeEndTextBox.Text, out dummy) || dummy <= 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Default switch time end' should be positive integer";
}
return flags;
}
@@ -246,20 +232,6 @@ namespace TBF.BenchControl.Elde.Diverter
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(dfltSwitchTimeStartTextBox.Text);
if (config.DfltSwithTimeStartMs != tmp)
{
config.DfltSwithTimeStartMs = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(dfltSwitchTimeEndTextBox.Text);
if (config.DfltSwithTimeEndMs != tmp)
{
config.DfltSwithTimeEndMs = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
return flags;
}
@@ -8,19 +8,19 @@ namespace TBF.BenchControl.Elde.Diverter
public class SwitchDiverterOp : IOperation
{
ControlBoardDev controlBoard;
bool toTank;
bool start;
int flowMtrNr;
public SwitchDiverterOp(ControlBoardDev controlBoard, bool toTank, int flowMtrNr)
public SwitchDiverterOp(ControlBoardDev controlBoard, bool start, int flowMtrNr)
{
this.controlBoard = controlBoard;
this.toTank = toTank;
this.start = start;
this.flowMtrNr = flowMtrNr;
}
public void Start()
{
if (toTank)
if (start)
{
controlBoard.DiverterToTank(flowMtrNr);
}
@@ -22,6 +22,8 @@ namespace TBF.BenchControl.Elde.FlowMeter
public double LtrPerPulseCorrected(double flow, int rangeIx)
{
if (flow < 0.1 * NominalFlow) return LtrPerPulse; /// No correction for small flow
/// Apply correction
var rangeCorrections = new List<Config.Entities.MeasurementCorrection>();
foreach (var corr in Corrections)
@@ -2,6 +2,8 @@
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Configs;
using TBF.BenchControl.Generic;
@@ -28,66 +28,22 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa
public double NominalFlow { get { return nominalFlow; } }
public double LtrPerPulse { get { return ltrPerPulse; } }
double[] refFreq; /// 0..sum, 1..I11, 2..I12, 3..I13
int[] refPulses;
double[] refFreq;
public double LtrPerPulseCorrected(double flow, int rangeIx)
{
log.DebugFormat("LtrPerPulseCorrected({0}, {1}) started", flow, rangeIx);
if (flow < 0.1 * NominalFlow) return LtrPerPulse; /// No correction for small flow
refFreq[0] = controlBoard.ReferenceFreqs(0);
refFreq[1] = controlBoard.ReferenceFreqs(1);
refFreq[2] = controlBoard.ReferenceFreqs(2);
refFreq[3] = controlBoard.ReferenceFreqs(3);
log.DebugFormat("refFreq[] = ({0}, {1}, {2}, {3})", refFreq[0], refFreq[1], refFreq[2], refFreq[3]);
refFreq[1] = refFreq[0] - refFreq[2] - refFreq[3];
refPulses[0] = controlBoard.EtPulses(0);
refPulses[2] = controlBoard.EtPulses2;
refPulses[3] = controlBoard.EtPulses3;
refPulses[1] = refPulses[0] - refPulses[2] - refPulses[3];
log.DebugFormat("refPulses[] = ({0}, {1}, {2}, {3})", refPulses[0], refPulses[1], refPulses[2], refPulses[3]);
double flow1, flow2, flow3;
double contribution1, contribution2, contribution3;
if (refFreq[0] != 0)
{
double ltrPerPulseCorrected = 0;
if (flowMeter1 != null)
{
double ratio = (double)refPulses[flowMeter1.Idx1] / (double)refPulses[0];
flow1 = flow * ratio;
contribution1 = flowMeter1.LtrPerPulseCorrected(flow1, rangeIx) * ratio;
ltrPerPulseCorrected += contribution1;
log.DebugFormat("flowmeter1 = {0}, flow1 = {1}, contribution1 = {2}", flowMeter1.Name, flow1, contribution1);
}
if (flowMeter2 != null)
{
double ratio = (double)refPulses[flowMeter2.Idx1] / (double)refPulses[0];
flow2 = flow * ratio;
contribution2 = flowMeter2.LtrPerPulseCorrected(flow2, rangeIx) * ratio;
ltrPerPulseCorrected += contribution2;
log.DebugFormat("flowmeter2 = {0}, flow2 = {1}, contribution2 = {2}", flowMeter2.Name, flow2, contribution2);
}
if (flowMeter3 != null)
{
double ratio = (double)refPulses[flowMeter3.Idx1] / (double)refPulses[0];
flow3 = flow * ratio;
contribution3 = flowMeter3.LtrPerPulseCorrected(flow3, rangeIx) * ratio;
ltrPerPulseCorrected += contribution3;
log.DebugFormat("flowmeter3 = {0}, flow3 = {1}, contribution3 = {2}", flowMeter3.Name, flow3, contribution3);
}
log.DebugFormat("LtrPerPulseCorrected() returns {0}", ltrPerPulseCorrected);
return ltrPerPulseCorrected;
}
else
{
log.DebugFormat("LtrPerPulseCorrected() returns 1");
return 1;
}
double ltrPerPulseCorrected = 0;
if (flowMeter1 != null) ltrPerPulseCorrected += refFreq[1] * flowMeter1.LtrPerPulseCorrected(flow * refFreq[1] / refFreq[0], rangeIx);
if (flowMeter2 != null) ltrPerPulseCorrected += refFreq[2] * flowMeter2.LtrPerPulseCorrected(flow * refFreq[2] / refFreq[0], rangeIx);
if (flowMeter3 != null) ltrPerPulseCorrected += refFreq[3] * flowMeter3.LtrPerPulseCorrected(flow * refFreq[3] / refFreq[0], rangeIx);
return ltrPerPulseCorrected / refFreq[0];
}
@@ -100,9 +56,7 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa
public FlowMeter()
{
refFreq = new double[4];
refPulses = new int[4];
}
}
public FlowMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
@@ -126,7 +80,6 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa
ltrPerPulse = nominalFlow / (flowMetersCount * 7200.0); /// Nominal freq. is flowMetersCount * 2000 Hz (2000, 4000 or 6000 Hz)
refFreq = new double[4];
refPulses = new int[4];
log.Debug(this.ToString());
}
@@ -2,6 +2,8 @@
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Configs;
using TBF.BenchControl.Generic;
@@ -22,6 +22,8 @@ namespace TBF.BenchControl.Elde.FlowMeterTriplet
public double LtrPerPulseCorrected(double flow, int rangeIx)
{
if (flow < 0.1 * NominalFlow) return LtrPerPulse; /// No correction for small flow
/// Apply correction
double correctedFlow = Config.Formulas.CorrectedValue(flow, Corrections);
return (LtrPerPulse * correctedFlow / flow);
@@ -2,6 +2,7 @@
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using log4net;
using TBF.BenchControl;
using TBF.Boxes;
namespace TBF.BenchControl.Elde.FlowMeterTwins
@@ -16,8 +15,8 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
readonly FlowMeterCfg flowMeterCfg;
readonly ControlBoardDev controlBoard;
public readonly Elde.FlowMeter.FlowMeter FlowMeter1;
public readonly Elde.FlowMeter.FlowMeter FlowMeter2;
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter1;
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter2;
public int Idx1 { get { return 0; } }
public double NominalFlow { get { return flowMeterCfg.NominalFlow; } }
@@ -45,10 +44,10 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
FlowMeter1 = TbfComponents.FindComponent(flowMeterCfg.FlowMeter1, components) as Elde.FlowMeter.FlowMeter;
FlowMeter1 = (TBF.BenchControl.Elde.FlowMeter.FlowMeter)TbfComponents.FindComponent(flowMeterCfg.FlowMeter1, components);
if (FlowMeter1 == null) throw new Exception("Cannot find FlowMeter1 component");
FlowMeter2 = TbfComponents.FindComponent(flowMeterCfg.FlowMeter2, components) as Elde.FlowMeter.FlowMeter;
FlowMeter2 = (TBF.BenchControl.Elde.FlowMeter.FlowMeter)TbfComponents.FindComponent(flowMeterCfg.FlowMeter2, components);
if (FlowMeter2 == null) throw new Exception("Cannot find FlowMeter2 component");
controlBoard.EtCalib[Idx1] = (float)flowMeterCfg.NominalFlow; /// Idx1==0 for FlowMeterTwins
@@ -2,6 +2,7 @@
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
+2 -4
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using Dirichlet.Numerics;
@@ -11,9 +11,7 @@ namespace TBF.BenchControl.Elde
StatusP StatusP { get; }
int EtPulses(int wmNr1);
int EtPulsesK { get; }
int EtPulses2 { get; }
int EtPulses3 { get; }
UInt16 WMeterPulses(int wmNr1);
UInt16 WMeterPulses(int wmNr1);
int WMeterReference(int wmNr0);
uint RegulValveDAC(int rvNr0);
float Pressure(int prsNr0);
@@ -2,6 +2,7 @@
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
@@ -21,9 +21,9 @@ namespace TBF.BenchControl.Elde
/// Set by the constructor
readonly ControlBoardDev controlBoard;
readonly GenericDevices.IDiverter div;
readonly bool toTank;
readonly int runsCountWhenSendingCmd;
readonly int runsCountWhenReadingDiv;
readonly FloatBox transitionTimeSec;
readonly Sequences.Statistics plotter;
readonly int batchNr;
readonly string testName;
@@ -43,19 +43,19 @@ namespace TBF.BenchControl.Elde
/// <param name="method">Test method</param>
/// <param name="refPulses">Test duration in number of reference flowmeter pulses</param>
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
public ReadDiverterTransitionOp(ControlBoardDev controlBoard, GenericDevices.IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, bool toTank,
Sequences.Statistics plotter, int batchNr, string testName, int repetition)
public ReadDiverterTransitionOp(ControlBoardDev controlBoard, GenericDevices.IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv,
FloatBox transitionTimeSec, Sequences.Statistics plotter, int batchNr, string testName, int repetition)
{
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
if (div == null) throw new ArgumentNullException("div");
if (runsCountWhenSendingCmd < 0) throw new ArgumentNullException("runsCountWhenSendingCmd");
if (runsCountWhenReadingDiv <= runsCountWhenSendingCmd) throw new ArgumentNullException("runsCountWhenReadingDiv");
if (transitionTimeSec == null) throw new ArgumentNullException("transitionTimeSec");
this.controlBoard = controlBoard;
this.div = div;
this.runsCountWhenSendingCmd = runsCountWhenSendingCmd;
this.runsCountWhenReadingDiv = runsCountWhenReadingDiv;
this.toTank = toTank;
this.transitionTimeSec = transitionTimeSec;
this.plotter = plotter;
this.batchNr = batchNr;
this.testName = testName;
@@ -102,7 +102,7 @@ namespace TBF.BenchControl.Elde
if (plotter == null)
{
ReadDiverterTransitionTimes();
log.DebugFormat("Run() ... Reading diverter {0} transition times: {1}s", div.Name, (toTank ? div.SwitchTimeStart : div.SwitchTimeEnd).Val);
log.DebugFormat("Run() ... Reading diverter {0} transition times: {1}s", div.Name, transitionTimeSec.Val);
}
else
{
@@ -115,7 +115,7 @@ namespace TBF.BenchControl.Elde
}
plotter.Stop();
log.DebugFormat("Run() ... Calculating diverter {0} transition times: {1}s", div.Name, (toTank ? div.SwitchTimeStart : div.SwitchTimeEnd).Val);
log.DebugFormat("Run() ... Calculating diverter {0} transition times: {1}s", div.Name, transitionTimeSec.Val);
CalculateDiverterTransitionTimes();
}
}
@@ -142,7 +142,7 @@ namespace TBF.BenchControl.Elde
/// <returns>true (always)</returns>
bool ReadDiverterTransitionTimes()
{
(toTank ? div.SwitchTimeStart : div.SwitchTimeEnd).Val = (float)controlBoard.DivTime(2) - (float)controlBoard.DivTime(1);
transitionTimeSec.Val = (float)controlBoard.DivTime(2) - (float)controlBoard.DivTime(1);
return true;
}
@@ -191,7 +191,7 @@ namespace TBF.BenchControl.Elde
if ((startedRising || startedFalling) && stopped)
{
(toTank ? div.SwitchTimeStart : div.SwitchTimeEnd).Val = 0.002f * (float)(transitionEndIdx - transitionStartIdx); /// 2 ms per sample
transitionTimeSec.Val = 0.002f * (float)(transitionEndIdx - transitionStartIdx); /// 2 ms per sample
return true;
}
else
+7 -11
View File
@@ -385,24 +385,20 @@ namespace TBF.BenchControl.Elde.RegulValve
}
else if (opState == OpState.SettingFlow)
{
/// Regulation valve is setting flow to the required value
if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi))
///
/// Repeated untill the required flow is reached
///
if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi))
{
/// Flow is within range
if (flowWithinBoundsTime++ >= regulValve.FlowStableSec)
if (flowWithinBoundsTime++ >= regulValve.FlowStableSec)
{
/// Flow is within range for sufficiently long time
if (regulValve.RegulValveCfg.StoredPositionReuse)
if (regulValve.RegulValveCfg.StoredPositionReuse)
{
float storedPosition;
if (regulValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
{
/// update the stored valve position
StoreTargetPosition(reqFlowAve, (rvPosition + storedPosition) / 2.0f);
StoreTargetPosition(reqFlowAve, (rvPosition + storedPosition) / 2.0f);
log.InfoFormat("Run(): rv#={0} reqFlow={1} pos={2}% stored={3} <--- Updating a stored position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
}
@@ -2,6 +2,7 @@
/// Copyright (c) 2015 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
-4
View File
@@ -1,8 +1,6 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System.Collections.Generic;
namespace TBF.BenchControl.Generic
{
public interface IComponent
@@ -19,8 +17,6 @@ namespace TBF.BenchControl.Generic
IComponentCfg Cfg { get; }
IList<Config.Entities.MeasurementCorrection> Corrections { get; set; }
void StartChangeHandler();
void StopChangeHandler();
@@ -1,17 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.GenericDevices
{
/// <summary>
/// Backup and security options
/// </summary>
public interface IBackupAndSecurity : IComponent
{
int MinPasswdLength { get; }
int PasswdExpirationPeriodDays { get; }
}
}
@@ -2,7 +2,6 @@
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
///
using TBF.BenchControl.Generic;
using TBF.Boxes;
namespace TBF.BenchControl.GenericDevices
{
@@ -34,9 +33,6 @@ namespace TBF.BenchControl.GenericDevices
/// </summary>
int ThresholdHi { get; }
FloatBox SwitchTimeStart { get; }
FloatBox SwitchTimeEnd { get; }
/// <summary>
/// For a given flow in [m3/h] returns a test time correction in [s]
/// </summary>
@@ -32,9 +32,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
this.GetType().Namespace.Substring(17),
CameraCfg.Name,
CameraCfg.HardwareAddress,
CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : ((ipAddress == null) ? "not detected" : ipAddress.ToString()),
CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr),
CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer));
ipAddress == null ? "not detected" : ipAddress.ToString(),
string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr,
string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer);
}
@@ -161,16 +161,13 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
cameraIdx = GetCameraIdx();
if (CameraCfg.DebugLevel == DebugMode.Simulate)
{
UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} s/n {1} si simulated", Name, CameraCfg.HardwareAddress));
return;
}
if (CameraCfg.DebugLevel == DebugMode.Simulate) return;
/// Detect a camera
bool cameraDetected = DetectCamera(CameraCfg.HardwareAddress % 100, ref ipAddress, true,
out cpuHardware, out cpuRevision, out cpuSerialNr, out sdCardVer);
if (CameraCfg.DebugLevel == DebugMode.AutoDetect)
{
CameraCfg.DebugLevel = cameraDetected ? DebugMode.DetectedOn : DebugMode.DetectedOff;
@@ -222,55 +219,46 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void StopDevice()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
running = false;
running = false;
stopScpThreadFlag = true;
stopRtpListenerFlag = true;
stopMsrmntListenerFlag = true;
stopScpThreadFlag = true;
stopRtpListenerFlag = true;
stopMsrmntListenerFlag = true;
if (Telnet != null)
{
Telnet.Dispose();
Telnet = null;
}
}
if (Telnet != null)
{
Telnet.Dispose();
Telnet = null;
}
}
public void StopDevice2()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
if (scpThread != null) scpThread.Join(50);
if (rtpListenerThread != null) rtpListenerThread.Join(50);
if (msrmntListenerThread != null) msrmntListenerThread.Join(50);
if (scpThread != null) scpThread.Join(50);
if (rtpListenerThread != null) rtpListenerThread.Join(50);
if (msrmntListenerThread != null) msrmntListenerThread.Join(50);
if (rtpUdpClient != null)
{
rtpUdpClient.Close();
rtpUdpClient = null;
}
if (rtpUdpClient != null)
{
rtpUdpClient.Close();
rtpUdpClient = null;
}
if (msrmntUdpClient != null)
{
msrmntUdpClient.Close();
msrmntUdpClient = null;
}
}
if (msrmntUdpClient != null)
{
msrmntUdpClient.Close();
msrmntUdpClient = null;
}
}
public void RunDeviceBefore()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
if (sha1sumResponse != null && !sha1sumResponseProcessed)
{
scpThread = new Thread(new ThreadStart(ScpWorker));
scpThread.Start();
sha1sumResponseProcessed = true;
}
if (sha1sumResponse != null && !sha1sumResponseProcessed)
{
scpThread = new Thread(new ThreadStart(ScpWorker));
scpThread.Start();
sha1sumResponseProcessed = true;
}
}
public void RunDeviceAfter() { }
@@ -50,13 +50,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
grabImageCommandSent = false;
transferringGrabbedImage = false;
if (camera.DebugLevel == DebugMode.Normal || camera.DebugLevel == DebugMode.DetectedOn)
{
telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a)
{
OnPromptReceived(sndr, a);
};
}
telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a)
{
OnPromptReceived(sndr, a);
};
}
void OnPromptReceived(object sndr, PromptReceivedEventArgs a)
@@ -68,58 +65,33 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void Start()
{
if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return;
grabImageCommandSent = false;
transferringGrabbedImage = false;
if ((imgFileNames != null) && (imgFileNames.Length > 0) && File.Exists(imgFileNames[0]))
{
///
/// An image specified, (1) delete previous image, (2) check if this is a simulation
///
File.Delete(imgFileNames[0]);
if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate || camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.DetectedOff)
{
///
/// Camera is in simulation mode => create a simulated image
///
File.Copy(string.Format("{0}\\Pictures\\sample.jpg", Program.ExecutableDir), imgFileNames[0]);
}
}
if (File.Exists(imgFileNames[0])) File.Delete(imgFileNames[0]);
}
public Event Run()
{
if ((imgFileNames == null) || (imgFileNames.Length < 1) || (imgFileNames[0] == null))
if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return Event.None;
if (imgFileNames.Length < 1 || imgFileNames[0] == null)
{
///
/// No images to be grabbed => Done
///
return Event.GrabPassed;
return Event.GrabPassed;
}
else if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate ||
camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.DetectedOff)
{
///
/// Camera is in simulation mode => create a simulated image and complete
///
return Event.GrabPassed;
}
else if (!grabImageCommandSent)
else if (!grabImageCommandSent)
{
///
/// Normal operation, no command sent yet => (1) wait until telnet state = Inactive, (2) send a command
///
if (camera.Running && (telnet.State == TelnetClient.TelnetState.Inactive))
{
///
/// State variables
///
//
// State variables
//
response = null;
///
/// Prepare a command
///
//
// Prepare command
//
int rotation = 0;
if (imageRotation == ImageRotation.Deg90)
rotation = 90;
@@ -147,10 +119,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
else if (grabPassed)
{
///
/// Normal operation, grab passed => transfer/transferring the image
///
if (transferringGrabbedImage)
if (transferringGrabbedImage)
{
/// Grab passed and image transfer is in progress
return Event.GrabPassed;
@@ -169,17 +138,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
else if (grabFailed)
{
///
/// Normal operation, grab failed => there in no image to transfer
///
/// Grab failed, there in no image to transfer
return Event.GrabFailed;
}
else if (response != null)
{
///
/// Normal operation
///
if (response.Contains("completed"))
if (response.Contains("completed"))
{
grabPassed = true;
@@ -9,7 +9,7 @@ namespace TBF.BenchControl.Network.Camera
/// </summary>
public class JpegFrame : RtpFrame
{
static readonly ILog log = LogManager.GetLogger(typeof(TBF.UI.MainWnd));
static readonly ILog log = LogManager.GetLogger(typeof(MainWnd));
#region Statics
@@ -127,11 +127,17 @@ namespace TBF.BenchControl.Network.Camera.RoiForFixedStart
public IOperation GrabImageOp(string imageFileName)
{
return GrabImageOp(imageFileName, roiCfg.BlackAndWhite, roiCfg.LowResolution, roiCfg.ImageRotation);
if (NetCamera != null)
{
/// TODO: Implement support for sharing one camera by multiple ROI-s
return NetCamera.GrabImagesOp(new string[] { imageFileName }, roiCfg.BlackAndWhite, roiCfg.LowResolution, roiCfg.ImageRotation);
}
else
return null;
}
public IOperation GrabImageOp(string imageFileName,
bool blackAndWhite, bool lowResolution, Config.Entities.ImageRotation imageRotation)
public IOperation GrabImageOp(string imageFileName, bool blackAndWhite,
bool lowResolution, Config.Entities.ImageRotation imageRotation)
{
if (NetCamera != null)
{
@@ -75,7 +75,7 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
}
IList<MeasurementCorrection> CalculateCorrectionsFromResuls(Results.Entities.Batch batch, string diverterName)
IList<MeasurementCorrection> GetCorrections(Results.Entities.Batch batch, string diverterName)
{
/// Create a list of all test flows in this procedure
IList<double> targetFlows = new List<double>();
@@ -115,8 +115,8 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
/// Calculate a correction and add it to the list
try
{
double factor = loTR.PulsesMaster / shTR.PulsesMaster * (loTR.MassEnd - loTR.MassStart) / (shTR.MassEnd - shTR.MassStart);
double correction = (factor - 1.0) * loTR.TestTime / (myCfg.ShortTestDiversionsCount - 1);
double factor = loTR.PulsesMaster / shTR.PulsesMaster * (shTR.MassEnd - shTR.MassStart) / (loTR.MassEnd - loTR.MassStart);
double correction = loTR.TestTime / (myCfg.ShortTestDiversionsCount - 1) * (factor - 1.0);
rslt.Add(new MeasurementCorrection { RangeIx = 0, Measurement = (float)trgtFlow, Correction = (float)correction });
log.InfoFormat("Calculated diverter correction at {0} m3/h: {1} s", trgtFlow, correction);
}
@@ -132,32 +132,29 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt)
void DeleteExistingCorrections(ISession session, Component cmpnt)
{
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
for (int i = cmpnt.Corrections.Count - 1; i >= 0; i--)
{
session.Delete(dbCmpnt.Corrections[i]);
session.Delete(cmpnt.Corrections[i]);
cmpnt.Corrections.RemoveAt(i);
}
dbCmpnt.Corrections = new List<MeasurementCorrection>();
runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
session.SaveOrUpdate(dbCmpnt);
session.SaveOrUpdate(cmpnt);
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, IList<MeasurementCorrection> corrections)
void SaveNewCorrections(ISession session, Component cmpnt, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
if (cmpnt.Corrections == null) cmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = 0;
dbCmpnt.Corrections.Add(mc);
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
cmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibInfoCfg;
ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibInfoCfg;
if (cfg != null)
{
cfg.CalibCertificateNr = string.Format(myCfg.CertificateFmt, batch.StartTime, batch.EndTime, batch.BatchNr);
@@ -165,10 +162,10 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
cfg.CalibValidDate = DateTime.Now + new TimeSpan(myCfg.ValidityDays, 0, 0, 0);
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
cmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
session.SaveOrUpdate(cmpnt);
}
@@ -210,17 +207,15 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
.Where(cmpnt => (cmpnt.Name == diverterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(diverterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
if (cmpntEntities.Count != 1)
{
log.ErrorFormat("No unique diverter named {0}", diverterName);
continue;
}
newCorrections = CalculateCorrectionsFromResuls(batch, diverterName);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, newCorrections);
newCorrections = GetCorrections(batch, diverterName);
DeleteExistingCorrections(session, cmpntEntities[0]);
SaveNewCorrections(session, cmpntEntities[0], newCorrections);
}
}
@@ -2,6 +2,7 @@
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -119,44 +119,32 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx)
void DeleteExistingCorrections(ISession session, Component cmpnt, int rangeIx)
{
/// Delete correction from DB entity
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
for (int i = cmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (dbCmpnt.Corrections[i].RangeIx == rangeIx)
if (cmpnt.Corrections[i].RangeIx == rangeIx)
{
session.Delete(dbCmpnt.Corrections[i]);
dbCmpnt.Corrections.RemoveAt(i);
}
}
session.SaveOrUpdate(dbCmpnt);
/// Delete corrections from runtime flowmeter component
for (int i = runtimeCmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (runtimeCmpnt.Corrections[i].RangeIx == rangeIx)
{
runtimeCmpnt.Corrections.RemoveAt(i);
session.Delete(cmpnt.Corrections[i]);
cmpnt.Corrections.RemoveAt(i);
}
}
session.SaveOrUpdate(cmpnt);
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
void SaveNewCorrections(ISession session, Component cmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
if (cmpnt.Corrections == null) cmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = rangeIx;
dbCmpnt.Corrections.Add(mc);
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
cmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibRangesCfg;
ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibRangesCfg;
if (cfg != null)
{
cfg.SetCalibDate(rangeIx, DateTime.Now);
@@ -172,10 +160,10 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
}
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
cmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
session.SaveOrUpdate(cmpnt);
}
@@ -217,9 +205,7 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
.Where(cmpnt => (cmpnt.Name == flowmeterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(flowmeterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
if (cmpntEntities.Count != 1)
{
log.ErrorFormat("No unique flowmeter named {0}", myCfg.GetFlowmeterName(fmtr));
continue;
@@ -232,8 +218,8 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
double tempRngLo = flowmeter.GetTempLo(rng);
double tempRngHi = flowmeter.GetTempHi(rng);
newCorrections = GetCorrections(batch, flowmeterName, rng, tempRngLo, tempRngHi);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent, rng);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, rng, newCorrections);
DeleteExistingCorrections(session, cmpntEntities[0], rng);
SaveNewCorrections(session, cmpntEntities[0], rng, newCorrections);
}
}
}
@@ -2,6 +2,7 @@
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
@@ -136,7 +136,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
/// <param name="wmTypeId">Water meter type Id</param>
/// <param name="wmTypeRevision">Water meter type revision</param>
/// <returns>SensusTestInfos array</returns>
public static IList<SensusTestInfo> GetOracleTestInfo(OracleConnection conn, int wmTypeId, out int wmTypeRevision, out string wzTyp, out string metrolKlasse, out string zulasszeichen, out string materialNr, out double q3, out DateTime timeStamp, out string remark)
IList<SensusTestInfo> GetOracleTestInfo(OracleConnection conn, int wmTypeId, out int wmTypeRevision)
{
///
/// Read 'incomplete' TestInfo from Oracle database containing only flowId-s ad qBezeichnung-s
@@ -147,15 +147,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
/// For a given 'wmTypeId' find the most recent active 'wmTypeRevision'
///
wmTypeRevision = -1;
wzTyp = string.Empty;
metrolKlasse = string.Empty;
zulasszeichen = string.Empty;
materialNr = string.Empty;
q3 = 0;
timeStamp = DateTime.MinValue;
remark = string.Empty;
OracleCommand cmd = new OracleCommand("select REV_WZTYP, WZTYP, METROLKLASSE, ZULASSZEICHEN, MATERIALNR, QMAX, AENDERUNGSDATUM, BEMERKUNG from VT_WZTYP_SD where ANBID=4 and ID_WZTyp=:1 and AKTIV=:2", conn);
OracleCommand cmd = new OracleCommand("select REV_WZTYP from VT_WZTYP_SD where ANBID=4 and ID_WZTyp=:1 and AKTIV=:2", conn);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wmTypeId }); ///:1
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 1 }); ///:2
///
@@ -163,19 +155,12 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
while (dr.Read())
{
wmTypeRevision = dr.GetInt32(0);
wzTyp = dr.GetString(1);
metrolKlasse = dr.GetString(2);
zulasszeichen = dr.GetString(3);
materialNr = dr.GetString(4);
q3 = dr.GetDouble(5);
timeStamp = dr.GetDateTime(6);
remark = dr.GetString(7);
}
dr.Close();
if (wmTypeRevision == -1) return null; /// No 'wmTypeRevision' found
cmd = new OracleCommand("select PRUEFUNGSNR, Q_SOLL, PRUEFZEIT, POSFEHLERKALT, NEGFEHLERKALT, PRUEFBEREICHMIN, PRUEFBEREICHMAX, QBEZEICHNUNG from VT_PRUEFPUNKT_SOLL_SD where ANBID=4 and ID_WZTyp=:1 and Rev_WZTyp=:2", conn);
cmd = new OracleCommand("select PruefungsNr, PosFehlerKalt, QBezeichnung from VT_PRUEFPUNKT_SOLL_SD where ANBID=4 and ID_WZTyp=:1 and Rev_WZTyp=:2", conn);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wmTypeId }); ///:1
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wmTypeRevision }); ///:2
///
@@ -183,19 +168,9 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
while (dr.Read())
{
int pruefungsNr = dr.GetInt32(0);
double flow = Config.Units.ConvertFrom(Unit.lph, dr.GetDouble(1));
int testTime = dr.GetInt32(2);
double errLimHi = dr.GetDouble(3);
double errLimLo = dr.GetDouble(4);
int flowRangeMin = dr.GetInt32(5);
int flowRangeMax = dr.GetInt32(6);
string qBezeichnung = dr.GetString(7);
Range rng = (flowRangeMin == 90 && flowRangeMax == 100) ? Range.R90_100 :
((flowRangeMin == 95 && flowRangeMax == 105) ? Range.R95_105 :
((flowRangeMin == 100 && flowRangeMax == 110) ? Range.R100_110 : Range.Undefined));
oraDbTinfos.Add(new SensusTestInfo(pruefungsNr, qBezeichnung, flow, testTime, errLimLo, errLimHi, rng));
double errLimHi = dr.GetDouble(1);
string qBezeichnung = dr.GetString(2);
oraDbTinfos.Add(new SensusTestInfo(null, pruefungsNr, qBezeichnung, 0, null, 0, null, Range.Undefined));
}
dr.Close();
@@ -381,14 +356,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
/// Currnet test info. is not walid => Get a new one from Oracle and SensusTestInfo table
///
int wmTR;
string wzTypStr;
string metroKlasse;
string zulasszeichen;
string materialNr;
double q3 = 0;
DateTime timeStamp;
string remark;
IList<SensusTestInfo> rti = GetOracleTestInfo(conn, wm.WaterMeterData.WMTypeId, out wmTR, out wzTypStr, out metroKlasse, out zulasszeichen, out materialNr, out q3, out timeStamp, out remark);
IList<SensusTestInfo> rti = GetOracleTestInfo(conn, wm.WaterMeterData.WMTypeId, out wmTR);
if (rti != null)
{
@@ -753,14 +721,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
if ((oracleTestInfo == null) || (wmTypeId != b.WaterMeters[0].WaterMeterData.WMTypeId) || (wmTypeRevision == 0) || (procedureSignature != procedureSignatureSB.ToString()))
{
int wmTR = 0;
string wzTypStr;
string metroKlasse;
string zulasszeichen;
string materialNr;
double q3 = 0;
DateTime timeStamp;
string remark;
IList<SensusTestInfo> ti = GetOracleTestInfo(conn, b.WaterMeters[0].WaterMeterData.WMTypeId, out wmTR, out wzTypStr, out metroKlasse, out zulasszeichen, out materialNr, out q3, out timeStamp, out remark);
IList<SensusTestInfo> ti = GetOracleTestInfo(conn, b.WaterMeters[0].WaterMeterData.WMTypeId, out wmTR);
if (ti != null)
{
@@ -296,15 +296,12 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
wrtr.Write(leftColumn[i]);
#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
#else
if (!writerCfg.EliminateSpaces)
{
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
}
wrtr.Write(separatorStr);
#endif
wrtr.WriteLine(rightColumn[i]);
}
@@ -389,9 +386,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
string horizontalLine = new String('-', totalWidth);
#if !BADGER_MALA_TRAT && !BADGER_STREDNA_TRAT && !BADGER_VELKA_TRAT
if (!writerCfg.EliminateSpaces)
#endif
{
wr.WriteLine(horizontalLine); /// Horizontal line above the header
}
@@ -418,9 +413,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
}
}
#if !BADGER_MALA_TRAT && !BADGER_STREDNA_TRAT && !BADGER_VELKA_TRAT
if (!writerCfg.EliminateSpaces)
#endif
{
wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
}
@@ -466,9 +459,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
}
}
#if !BADGER_MALA_TRAT && !BADGER_STREDNA_TRAT && !BADGER_VELKA_TRAT
if (!writerCfg.EliminateSpaces)
#endif
{
wr.WriteLine(horizontalLine); /// Horizontal line below the body
}
-31
View File
@@ -49,13 +49,6 @@ namespace TBF.BenchControl.Output
public string QBezeichnungLog; /// Flow name in Oracle database
public Range Range; /// Range.R90_100 or Range.R100_110 (flow range in % of a target flow)
public double Flow;
public int TestTime;
public double ErrLimLoFromDB;
public double ErrLimHiFromDB;
public double Uncertainty;
public string TestMethod;
public SensusTestInfo(string tstName, int pnDB, string qbDB, int pnOpto, string qbOpto, int pnLog, string qbLog, Range range)
{
TestName = tstName;
@@ -66,30 +59,6 @@ namespace TBF.BenchControl.Output
PruefungsNrLog = pnLog;
QBezeichnungLog = qbLog;
Range = range;
Flow = 0;
TestTime = 0;
ErrLimLoFromDB = 0;
ErrLimHiFromDB = 0;
Uncertainty = 0;
TestMethod = string.Empty;
}
public SensusTestInfo(int pnDB, string qbDB, double flow, int testTime, double errLimLo, double errLimHi, Range range)
{
TestName = null;
PruefungsNrDB = pnDB;
QBezeichnungDB = qbDB;
PruefungsNrOpto = 0;
QBezeichnungOpto = null;
PruefungsNrLog = 0;
QBezeichnungLog = null;
Range = range;
Flow = flow;
TestTime = testTime;
ErrLimLoFromDB = errLimLo;
ErrLimHiFromDB = errLimHi;
Uncertainty = 0;
TestMethod = string.Empty;
}
/// <summary>
+11 -27
View File
@@ -331,28 +331,6 @@ namespace TBF.BenchControl.Sequences
}
/// <summary>
/// This function is called after a procedure was selected and all components procedure parameters of components were loaded
/// </summary>
void ClearSessionData()
{
///
/// Clear iperlhead data (including PCB Number, avoid double use)
///
foreach (var cmpnt in StateMachine.Components)
{
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead).ClearData();
}
}
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
}
/// <summary>
/// Main sequence
/// </summary>
@@ -488,10 +466,7 @@ namespace TBF.BenchControl.Sequences
Debug.WriteLine(string.Format("Procedure {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure.MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.MoreParams) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure.Tests {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests) ? "initialized" : "NOT initialized"));
if (StateMachine.Procedure.Tests.Count > 0)
{
Debug.WriteLine(string.Format("Procedure.Tests[0].MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests[0].MoreParams) ? "initialized" : "NOT initialized"));
}
Debug.WriteLine(string.Format("Procedure.Tests[0].MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests[0].MoreParams) ? "initialized" : "NOT initialized"));
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
@@ -505,7 +480,16 @@ namespace TBF.BenchControl.Sequences
int newBatchNr = Program.LocalSettings.BatchNr;
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
ClearSessionData();
///
/// Clear iperlhead data (including PCB Number, avoid double use)
///
foreach (var cmpnt in StateMachine.Components)
{
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead).ClearData();
}
}
if (selection == Selection.RestoreBatch)
{
+1 -10
View File
@@ -7,8 +7,7 @@ namespace TBF.BenchControl.Sequences
{
public class ProcessData
{
public static IBackupAndSecurity BackupAndSecurity;
public static IBenchInfo BenchInfo;
public static IBenchInfo BenchInfo;
public static IErrorFlags ErrorFlagsComp;
public static Output.DB.SensusOracle.Database OracleDB;
public static IList<Output.SensusTestInfo> RawTestInfos; /// Incomplete raw test infos from Oracle DB
@@ -49,10 +48,6 @@ namespace TBF.BenchControl.Sequences
public static Results.BatchResults BatchRslts;
public static IRegisterReader[] RegisterReaders;
public static bool IsQ2PreCorrectionCalculated;
public static int CalculatedQ2PreCorrectionLR;
public static int CalculatedQ2PreCorrectionRL;
///
static ProcessData()
{
@@ -61,10 +56,6 @@ namespace TBF.BenchControl.Sequences
/// RegisterReader[i] where i = 0..Config.Data.WMsCount-1 may be null and should always be tested
///
RegisterReaders = new IRegisterReader[Config.Data.WMsCount];
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
}
@@ -30,8 +30,6 @@ namespace TBF.BenchControl.Sequences
public const int FlowSettingTimeoutSec = 300; /// Flow setting timeout = 5 min.
public const int StableMassMsrmntTimeoutSec = 300; /// Stable mass measurement timeout = 5 min.
public const int CountWhenSendingRdDivCmd = 1; /// Passed to cBrd.ReadDiverterTransitionOp()
public const int CountWhenReadingDiv = 3; /// Passed to cBrd.ReadDiverterTransitionOp()
///------------------------------------------------------------
+1 -2
View File
@@ -228,8 +228,7 @@ namespace TBF.BenchControl
foreach (var cmpnt in components)
{
if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev;
if (cmpnt is IBackupAndSecurity) ProcessData.BackupAndSecurity = cmpnt as IBackupAndSecurity;
if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo;
if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo;
if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags;
if ((cmpnt is Output.DB.SensusOracle.Database) && (ProcessData.OracleDB == null))
{
+1 -4
View File
@@ -15,8 +15,7 @@ namespace TBF.BenchControl
{
Factories = new List<IComponentFactory>();
Factories.Add(new BackupAndSecurity.Default.ComponentFactory());
Factories.Add(new BenchInfo.Munich.ComponentFactory());
Factories.Add(new BenchInfo.Munich.ComponentFactory());
Factories.Add(new BenchInfo.Extended.ComponentFactory());
Factories.Add(new BenchInfo.iPerl.ComponentFactory());
Factories.Add(new Elde.ControlBoardFactory());
@@ -56,7 +55,6 @@ namespace TBF.BenchControl
Factories.Add(new TestMethods.CombinedWithDetection.TestMethodFactory());
Factories.Add(new TestMethods.Counter.Factory());
Factories.Add(new TestMethods.DiverterTest.Factory());
Factories.Add(new TestMethods.Dummy.Factory());
Factories.Add(new TestMethods.Endurance.Factory());
Factories.Add(new TestMethods.FixedStart.Single.Factory());
Factories.Add(new TestMethods.FixedStart.Compound.Factory());
@@ -95,7 +93,6 @@ namespace TBF.BenchControl
Factories.Add(new TestMethods.PMaxTest.TestMethodFactory());
Factories.Add(new TestMethods.PulsesTest.Factory());
Factories.Add(new TestMethods.PulsesTestManual.Factory());
Factories.Add(new TestMethods.Q2CorrectionFromHistory.Factory());
Factories.Add(new TestMethods.SensitivityTest.Factory());
Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication
Factories.Add(new TestMethods.RoiDetection.RoiDetectionFactory());
@@ -96,6 +96,10 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
if(benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if(benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
@@ -491,7 +495,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(scale.ReadMassOp(ref Mass))
//.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
//.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -607,7 +611,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.EnterState();
@@ -689,7 +693,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
tstRslt.VolumeCTV = 1000 * tstRslt.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.DensityLine; /// [l] commercially true volume
if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon))
{
tstRslt.TestTimeCorrection = testParams.DivRepetitions * outPath.Diverter.TestTimeCorrection(tstRslt.FlowVolume);
tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(tstRslt.FlowVolume);
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
tstRslt.VolumeCTV /= tstRslt.TestTime;
}
@@ -706,11 +710,11 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -1,64 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.Dummy
{
public class DummySeq : Sequences.SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(DummySeq));
/// <summary>
/// Adjustment method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// Event.Done . . . . . . . OK
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
/// Event.OpArgumentError . Target flow is out of range
/// Event.Error . . . . . . Unspecified error
/// </returns>
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition, DebugMode mode)
{
IList<Event> e = new List<Event>(); /// Events from currently running operations
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, 0));
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
///
/// Show a dialog with OK button and an appropriate message
///
Bridge.OnAdjustmentInProgress(this, new AdjustmentInProgressEventArgs(testName));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnActivity(this, test.Method);
State.Create(string.Format("{0}({1}) : Dummy", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.BenchWaitingOp)
.AddOperation(new Operations.MessageBoxOp(string.Format("Dummy test {0}", test.Name)))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
if (e.Contains(Event.Error)) goto stopTest;
if (TestAndLogUiCmdStop(test, e)) goto stopTest;
}
while (!e.Contains(Event.OK));
return new List<Event> { Event.Done };
stopTest:
return new List<Event> { Event.UiCmdStop };
}
}
}
@@ -1,30 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
using TBF.BenchControl.Configs.NameOnly;
namespace TBF.BenchControl.TestMethods.Dummy
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); }
public IComponent DummyComponent() { return new TestMethod(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TestMethod(cfg); }
public IComponentCfg DefaultConfig()
{
return new TestMethodCfg(this.GetType().Namespace.Substring(29), this);
}
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
}
}
}
@@ -1,35 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.BenchControl;
namespace TBF.BenchControl.TestMethods.Dummy
{
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString() { return string.Format("TestMethods.ChangeFlowDirection({0})", Cfg.ToString(1)); }
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return true; }
public TestMethod()
{
}
public TestMethod(Generic.IComponentCfg cfg)
: base(cfg)
{
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
return (new DummySeq()).Execute(test, repetNr, isLastRepetition, DebugLevel);
}
}
}
@@ -7,11 +7,10 @@ using System.Windows.Forms;
using log4net;
using TBF.BenchControl.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
namespace TBF.BenchControl.TestMethods.Endurance
{
public partial class CycleDlg : Form, IParentOfListViewEx
public partial class CycleDlg : Form, TBF.UiControls.IParentOfListViewEx
{
static readonly ILog log = LogManager.GetLogger(typeof(CycleDlg));
@@ -31,7 +30,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
public IList<IValve> Valves;
ITabWithListViewEx seqStepsCtrl;
TBF.UiControls.ITabWithListViewEx seqStepsCtrl;
public CycleDlg()
@@ -48,10 +47,10 @@ namespace TBF.BenchControl.TestMethods.Endurance
/// SharedDlgButtons configuration
sharedButtons.RequiredGroupMembership = new Users.Grp.GID[] { Users.Grp.GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up |
SharedButtons.Buttons.Down;
sharedButtons.OptionalButtons = TBF.UiControls.SharedButtons.Buttons.Add |
TBF.UiControls.SharedButtons.Buttons.Remove |
TBF.UiControls.SharedButtons.Buttons.Up |
TBF.UiControls.SharedButtons.Buttons.Down;
sharedButtons.Unlocked += Unlocked;
sharedButtons.OKClicked += okButton_Click;
sharedButtons.CancelClicked += cancelButton_Click;
@@ -60,7 +59,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
sharedButtons.UpClicked += upButton_Click;
sharedButtons.DownClicked += downButton_Click;
seqStepsCtrl = new CycleStepsCtrl() as ITabWithListViewEx;
seqStepsCtrl = new CycleStepsCtrl();
/// Prepare a list of valves for the endurance test
TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config));
@@ -99,7 +98,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
{
Localize();
LocalSettings ls = Program.LocalSettings;
TBF.LocalSettings ls = Program.LocalSettings;
Width = (ls.EnduranceDlgWidth > 0) ? ls.EnduranceDlgWidth : 1050;
Height = (ls.EnduranceDlgHeight > 0) ? ls.EnduranceDlgHeight : 360;
Left = (ls.EnduranceDlgLeft != 0) ? ls.EnduranceDlgLeft : 150;
@@ -178,8 +177,8 @@ namespace TBF.BenchControl.TestMethods.Endurance
seqStepsCtrl.OkBtnClicked();
}
slctdTab = tabControl.SelectedIndex;
sharedButtons.EnableButtons(SharedButtons.Buttons.Add);
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove);
sharedButtons.EnableButtons(TBF.UiControls.SharedButtons.Buttons.Add);
sharedButtons.DisableButtons(TBF.UiControls.SharedButtons.Buttons.Remove);
RefreshAllTabs();
}
@@ -203,32 +202,32 @@ namespace TBF.BenchControl.TestMethods.Endurance
if (seqStepsCtrl != null) seqStepsCtrl.MoveDownSelected();
}
public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos)
public void UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos selectedItemPos)
{
if (selectedItemPos == SharedButtons.SelectedItemPos.None)
if (selectedItemPos == TBF.UiControls.SharedButtons.SelectedItemPos.None)
{
sharedButtons.DisableButtons(SharedButtons.Buttons.Up |
SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(TBF.UiControls.SharedButtons.Buttons.Up |
TBF.UiControls.SharedButtons.Buttons.Down);
}
else if (selectedItemPos == SharedButtons.SelectedItemPos.First)
else if (selectedItemPos == TBF.UiControls.SharedButtons.SelectedItemPos.First)
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up);
sharedButtons.EnableButtons(TBF.UiControls.SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(TBF.UiControls.SharedButtons.Buttons.Up);
}
else if (selectedItemPos == SharedButtons.SelectedItemPos.Last)
else if (selectedItemPos == TBF.UiControls.SharedButtons.SelectedItemPos.Last)
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Up);
sharedButtons.DisableButtons(SharedButtons.Buttons.Down);
sharedButtons.EnableButtons(TBF.UiControls.SharedButtons.Buttons.Up);
sharedButtons.DisableButtons(TBF.UiControls.SharedButtons.Buttons.Down);
}
else if (selectedItemPos == SharedButtons.SelectedItemPos.FirstAndLast)
else if (selectedItemPos == TBF.UiControls.SharedButtons.SelectedItemPos.FirstAndLast)
{
sharedButtons.DisableButtons(SharedButtons.Buttons.Up |
SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(TBF.UiControls.SharedButtons.Buttons.Up |
TBF.UiControls.SharedButtons.Buttons.Down);
}
else
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Up |
SharedButtons.Buttons.Down);
sharedButtons.EnableButtons(TBF.UiControls.SharedButtons.Buttons.Up |
TBF.UiControls.SharedButtons.Buttons.Down);
}
}
@@ -241,23 +240,23 @@ namespace TBF.BenchControl.TestMethods.Endurance
Results.Forms.ListViewEx listViewEx = sender as Results.Forms.ListViewEx;
if (listViewEx.SelectedItems.Count != 1)
{
UpdateButtonStates(SharedButtons.SelectedItemPos.None);
UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.None);
}
else if (listViewEx.Items.Count == 1)
{
UpdateButtonStates(SharedButtons.SelectedItemPos.FirstAndLast);
UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.FirstAndLast);
}
else if (listViewEx.SelectedIndices[0] == 0)
{
UpdateButtonStates(SharedButtons.SelectedItemPos.First);
UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.First);
}
else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1))
{
UpdateButtonStates(SharedButtons.SelectedItemPos.Last);
UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.Last);
}
else
{
UpdateButtonStates(SharedButtons.SelectedItemPos.Middle);
UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.Middle);
}
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleDlg));
this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
this.tabControl = new System.Windows.Forms.TabControl();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
this.sharedButtons = new TBF.UiControls.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
this.mainSplitContainer.Panel1.SuspendLayout();
this.mainSplitContainer.Panel2.SuspendLayout();
@@ -86,6 +86,6 @@ namespace TBF.BenchControl.TestMethods.Endurance
private System.Windows.Forms.SplitContainer mainSplitContainer;
private System.Windows.Forms.TabControl tabControl;
private TBF.UI.Shared.SharedButtons sharedButtons;
private UiControls.SharedButtons sharedButtons;
}
}
@@ -7,11 +7,10 @@ using System.Windows.Forms;
using log4net;
using TBF.BenchControl.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
namespace TBF.BenchControl.TestMethods.Endurance
{
public partial class CycleStepsCtrl : BaseWithListViewEx<CycleStep>, ITabWithListViewEx
public partial class CycleStepsCtrl : TBF.UiControls.BaseWithListViewEx<CycleStep>, TBF.UiControls.ITabWithListViewEx
{
static readonly ILog log = LogManager.GetLogger(typeof(CycleStepsCtrl));
@@ -55,13 +54,13 @@ namespace TBF.BenchControl.TestMethods.Endurance
///
/// ListViewEx columns
///
Columns.Add(Strings.Duration_ms, 100 * parent.Dpi / UI.Constants.Dpi100pct);
//Columns.Add(Strings.Message, 100 * parent.Dpi / UI.Constants.Dpi100pct);
Columns.Add(Strings.Duration_ms, 100 * parent.Dpi / PathsDlg.Dpi100pct);
//Columns.Add(Strings.Message, 100 * parent.Dpi / PathsDlg.Dpi100pct);
///
vCount = 0;
foreach (var vlv in parent.Valves)
{
Columns.Add(vlv.Cfg.Name, 50 * parent.Dpi / UI.Constants.Dpi100pct);
Columns.Add(vlv.Cfg.Name, 50 * parent.Dpi / PathsDlg.Dpi100pct);
vCount++;
}
@@ -257,7 +256,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
bool lastItemRemoved = base.RemoveSelected();
if (lastItemRemoved && parent != null)
{
parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None);
parent.UpdateButtonStates(TBF.UiControls.SharedButtons.SelectedItemPos.None);
}
}
@@ -113,6 +113,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
float nextTestVolume = (singleTestParams != null) ? singleTestParams.NextTestVolume
: ((compoundTestParams != null) ? compoundTestParams.NextTestVolume
: heatMetersTestParams.NextTestVolume);
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
//====================================
loop:
@@ -563,7 +566,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation((repetitionNr == 1) ? scale.ReadMassOp(ref Mass) : null)
.AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null)
.AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null)
.AddOperation(queryEnd1)
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -664,7 +667,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null)
.AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null)
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.EnterState();
@@ -757,11 +760,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
/// Calculated master pulses per liter
tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -131,6 +131,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
@@ -669,7 +672,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -768,7 +771,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -862,11 +865,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -119,6 +119,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
Event retVal = Event.Done;
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int targetTotalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
int targetMassPulses = (int)(volumeToTank / LtrPerRefPulse + 0.5f);
@@ -563,7 +567,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -662,7 +666,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.EnterState();
@@ -759,11 +763,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -112,6 +112,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
@@ -553,7 +557,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -654,7 +658,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.EnterState();
@@ -748,11 +752,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -107,6 +107,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
@@ -361,7 +364,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -441,7 +444,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
State.Create(string.Format("{0}({1}) : Waiting before the water level measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -522,11 +525,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
@@ -1,74 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class Component : ComponentBase, GenericDevices.ISimultTestMethod, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("TestMethods.GrabImage({0})", Cfg.ToString(1)); }
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return false; }
readonly FromHistoryCfg cfg;
public bool SimultWithPrevious { get { return true; } }
public bool SimultWithNext { get { return false; } }
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
FromHistoryCfg tmpcfg = args.Cfg as FromHistoryCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
cfg.UseLocalDB = tmpcfg.UseLocalDB;
cfg.ProcedureName = tmpcfg.ProcedureName;
cfg.ProcedureNameAlt1 = tmpcfg.ProcedureNameAlt1;
cfg.ProcedureNameAlt2 = tmpcfg.ProcedureNameAlt2;
cfg.UseWebService = tmpcfg.UseWebService;
}
}
};
}
#endregion Configuration Change Handling
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
this.cfg = cfg as FromHistoryCfg;
StartChangeHandler();
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition)
{
return (new FromHistorySeq()).Execute(test, repetitionNr, isLastRepetition, cfg);
}
}
}
@@ -1,26 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Component(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new FromHistoryCfg(this, this.GetType().Namespace.Substring(29)); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(FromHistoryCfg.Serializer, component, this);
}
}
}
@@ -1,49 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class FromHistoryCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(FromHistoryCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new FromHistoryCfgCtrl(); }
public bool UseWebService;
public bool UseLocalDB;
public string ProcedureName;
public string ProcedureNameAlt1;
public string ProcedureNameAlt2;
public bool UseDefaultValues;
/// Private parameterless constructor invoked by all other (public) constructors
FromHistoryCfg() {}
public FromHistoryCfg(IComponentFactory factory, string name)
: this()
{
this.Factory = factory;
Name = name;
ParentName = string.Empty;
UseWebService = false;
UseLocalDB = true;
ProcedureName = "iPERL Smart Suez DN15 Q3_2.5 R800";
ProcedureNameAlt1 = "iPERL Suez DN15 Q3_2.5 R800";
ProcedureNameAlt2 = string.Empty;
UseDefaultValues = true;
}
public string ToString(int i)
{
return string.Format("Name={0}, UseLocalDB={1}, UseWebService={2}", Name, UseLocalDB, UseWebService);
}
}
}
@@ -1,289 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public partial class FromHistoryCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(FromHistoryCfgCtrl));
private Label classNameLabel;
private Label nameLabel;
private TextBox nameTextBox;
private CheckBox useLocalDBCheckBox;
private Label procedureNameLabel;
private TextBox procedureNameTextBox;
private Label procedureNameAlt1Label;
private TextBox procedureNameAlt1TextBox;
private Label procedureNameAlt2Label;
private TextBox procedureNameAlt2TextBox;
private CheckBox useWebServiceCheckBox;
private CheckBox useDefaultValuesCheckBox;
public bool ShowMore { get { return false; } }
FromHistoryCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as FromHistoryCfg;
Redraw();
}
}
public FromHistoryCfgCtrl()
{
InitializeComponent();
}
private void GrabImageCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
useWebServiceCheckBox.Checked = config.UseWebService;
useLocalDBCheckBox.Checked = config.UseLocalDB;
procedureNameTextBox.Text = config.ProcedureName;
procedureNameAlt1TextBox.Text = config.ProcedureNameAlt1;
procedureNameAlt2TextBox.Text = config.ProcedureNameAlt2;
useDefaultValuesCheckBox.Checked = config.UseDefaultValues;
}
public void Unlock()
{
nameTextBox.Enabled = true;
useWebServiceCheckBox.Enabled = true;
useLocalDBCheckBox.Enabled = true;
procedureNameTextBox.Enabled = true;
procedureNameAlt1TextBox.Enabled = true;
procedureNameAlt2TextBox.Enabled = true;
useDefaultValuesCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
if (config.UseWebService != useWebServiceCheckBox.Checked)
{
config.UseWebService = useWebServiceCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseLocalDB != useLocalDBCheckBox.Checked)
{
config.UseLocalDB = useLocalDBCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureName != procedureNameTextBox.Text)
{
config.ProcedureName = procedureNameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt1 != procedureNameAlt1TextBox.Text)
{
config.ProcedureNameAlt1 = procedureNameAlt1TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt2 != procedureNameAlt2TextBox.Text)
{
config.ProcedureNameAlt2 = procedureNameAlt2TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseDefaultValues != useDefaultValuesCheckBox.Checked)
{
config.UseDefaultValues = useDefaultValuesCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Component.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void InitializeComponent()
{
this.procedureNameTextBox = new System.Windows.Forms.TextBox();
this.procedureNameLabel = new System.Windows.Forms.Label();
this.useLocalDBCheckBox = new System.Windows.Forms.CheckBox();
this.useWebServiceCheckBox = new System.Windows.Forms.CheckBox();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.procedureNameAlt1TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt1Label = new System.Windows.Forms.Label();
this.procedureNameAlt2TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt2Label = new System.Windows.Forms.Label();
this.useDefaultValuesCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// procedureNameTextBox
//
this.procedureNameTextBox.Enabled = false;
this.procedureNameTextBox.Location = new System.Drawing.Point(190, 124);
this.procedureNameTextBox.Name = "procedureNameTextBox";
this.procedureNameTextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameTextBox.TabIndex = 6;
//
// procedureNameLabel
//
this.procedureNameLabel.AutoSize = true;
this.procedureNameLabel.Location = new System.Drawing.Point(65, 127);
this.procedureNameLabel.Name = "procedureNameLabel";
this.procedureNameLabel.Size = new System.Drawing.Size(85, 13);
this.procedureNameLabel.TabIndex = 5;
this.procedureNameLabel.Text = "Procedure name";
//
// useLocalDBCheckBox
//
this.useLocalDBCheckBox.AutoSize = true;
this.useLocalDBCheckBox.Enabled = false;
this.useLocalDBCheckBox.Location = new System.Drawing.Point(38, 103);
this.useLocalDBCheckBox.Name = "useLocalDBCheckBox";
this.useLocalDBCheckBox.Size = new System.Drawing.Size(129, 17);
this.useLocalDBCheckBox.TabIndex = 4;
this.useLocalDBCheckBox.Text = "2. Use local database";
this.useLocalDBCheckBox.UseVisualStyleBackColor = true;
//
// useWebServiceCheckBox
//
this.useWebServiceCheckBox.AutoSize = true;
this.useWebServiceCheckBox.Enabled = false;
this.useWebServiceCheckBox.Location = new System.Drawing.Point(38, 78);
this.useWebServiceCheckBox.Name = "useWebServiceCheckBox";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(117, 17);
this.useWebServiceCheckBox.TabIndex = 3;
this.useWebServiceCheckBox.Text = "1. Use web service";
this.useWebServiceCheckBox.UseVisualStyleBackColor = true;
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(190, 45);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(171, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(132, 48);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(187, 16);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComponentName";
//
// procedureNameAlt1TextBox
//
this.procedureNameAlt1TextBox.Enabled = false;
this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(190, 147);
this.procedureNameAlt1TextBox.Name = "procedureNameAlt1TextBox";
this.procedureNameAlt1TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt1TextBox.TabIndex = 8;
//
// procedureNameAlt1Label
//
this.procedureNameAlt1Label.AutoSize = true;
this.procedureNameAlt1Label.Location = new System.Drawing.Point(65, 150);
this.procedureNameAlt1Label.Name = "procedureNameAlt1Label";
this.procedureNameAlt1Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt1Label.TabIndex = 7;
this.procedureNameAlt1Label.Text = "Procedure name Alt1";
//
// procedureNameAlt2TextBox
//
this.procedureNameAlt2TextBox.Enabled = false;
this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(190, 170);
this.procedureNameAlt2TextBox.Name = "procedureNameAlt2TextBox";
this.procedureNameAlt2TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt2TextBox.TabIndex = 10;
//
// procedureNameAlt2Label
//
this.procedureNameAlt2Label.AutoSize = true;
this.procedureNameAlt2Label.Location = new System.Drawing.Point(65, 173);
this.procedureNameAlt2Label.Name = "procedureNameAlt2Label";
this.procedureNameAlt2Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt2Label.TabIndex = 9;
this.procedureNameAlt2Label.Text = "Procedure name Alt2";
//
// useDefaultValuesCheckBox
//
this.useDefaultValuesCheckBox.AutoSize = true;
this.useDefaultValuesCheckBox.Enabled = false;
this.useDefaultValuesCheckBox.Location = new System.Drawing.Point(38, 202);
this.useDefaultValuesCheckBox.Name = "useDefaultValuesCheckBox";
this.useDefaultValuesCheckBox.Size = new System.Drawing.Size(126, 17);
this.useDefaultValuesCheckBox.TabIndex = 11;
this.useDefaultValuesCheckBox.Text = "3. Use default values";
this.useDefaultValuesCheckBox.UseVisualStyleBackColor = true;
//
// FromHistoryCfgCtrl
//
this.Controls.Add(this.useDefaultValuesCheckBox);
this.Controls.Add(this.procedureNameAlt2TextBox);
this.Controls.Add(this.procedureNameAlt2Label);
this.Controls.Add(this.procedureNameAlt1TextBox);
this.Controls.Add(this.procedureNameAlt1Label);
this.Controls.Add(this.procedureNameTextBox);
this.Controls.Add(this.procedureNameLabel);
this.Controls.Add(this.useLocalDBCheckBox);
this.Controls.Add(this.useWebServiceCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "FromHistoryCfgCtrl";
this.Size = new System.Drawing.Size(400, 250);
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
@@ -1,164 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using NHibernate;
using log4net;
using Results.Entities;
using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class FromHistorySeq : Sequences.SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(FromHistorySeq));
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, FromHistoryCfg cfg)
{
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
bool success = false;
/// 1. Use a web service if enabled
if (cfg.UseWebService)
{
success = ReadCorrectionsFromWebService(cfg);
}
/// 2. Calculate pre-corrections from a local database if enabled
if (!success && cfg.UseLocalDB)
{
success = ReadCorrectionsFromLocalDB(cfg);
}
/// 3. Use pre-defined values (IperlHead procedure parameters) if enabled
if (!success && cfg.UseDefaultValues)
{
success = true;
}
///
/// Populate TestResult data entity with data
///
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now;
tstRslt.TestDone = true;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
if (meterRslt != null)
{
meterRslt.TestDone = true;
meterRslt.Passed = success;
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed));
return new List<Event> { success ? Event.Done : Event.RecoverableError };
}
bool ReadCorrectionsFromWebService(FromHistoryCfg cfg)
{
/// Invalidate any previous Q2 Pre-Corrections
IsQ2PreCorrectionCalculated = false;
try
{
return false;
/// TODO: Use webservice
//IsQ2PreCorrectionCalculated = true;
//return true;
}
catch (Exception exc)
{
log.ErrorFormat("Failed to calculate Q2 corrections: {0}", exc.Message);
return false;
}
}
bool ReadCorrectionsFromLocalDB(FromHistoryCfg cfg)
{
/// Invalidate any previous Q2 Pre-Corrections
IsQ2PreCorrectionCalculated = false;
try
{
using (ISession session = Results.DB.CreateSession())
{
Batch btc = null;
var batches = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureName))
.List();
if (!string.IsNullOrEmpty(cfg.ProcedureNameAlt1))
{
IList<Batch> batches2 = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureNameAlt1))
.List();
foreach (var b in batches2) batches.Add(b);
}
if (!string.IsNullOrEmpty(cfg.ProcedureNameAlt2))
{
IList<Batch> batches3 = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureNameAlt2))
.List();
foreach (var b in batches3) batches.Add(b);
}
int samplesCount = 0;
double q2CorrLRsum = 0;
double q2CorrRLsum = 0;
var sortedBatches = batches.OrderByDescending(b => b.EndTime);
foreach (var b in sortedBatches)
{
foreach (var wm in b.WaterMeters)
{
if ((wm != null) && !wm.Disabled && wm.Passed)
{
#if IPERL
q2CorrLRsum += wm.Q2CorrLR;
q2CorrRLsum += wm.Q2CorrRL;
#endif
samplesCount++;
}
}
if (samplesCount >= 200) break;
}
if (samplesCount >= 200)
{
IsQ2PreCorrectionCalculated = true;
CalculatedQ2PreCorrectionLR = (int)Math.Round(q2CorrLRsum / samplesCount);
CalculatedQ2PreCorrectionRL = (int)Math.Round(q2CorrRLsum / samplesCount);
log.WarnFormat("Q2 corrections calculated OK: LR = {0}, RL = {1}", CalculatedQ2PreCorrectionLR, CalculatedQ2PreCorrectionRL);
return true;
}
else
{
log.ErrorFormat("Not enough samples to calculate Q2 corrections ({0})", samplesCount);
return false;
}
}
}
catch (Exception exc)
{
log.ErrorFormat("Failed to calculate Q2 corrections: {0}", exc.Message);
return false;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More