Compare commits

...
Author SHA1 Message Date
Milan Hanajik 4bff6f33de DataEntry.Uni.CycleBgEnForm : 1. autoSNButton --> multiPurposeButton, 2. Initial configuration : Order : Ac.HistoryLast, ver. 2.33.2138 2023-12-12 19:08:09 +01:00
Milan Hanajik e0d10bed71 Bug fixes : 1. UpgradeSelectionDlg (Counter1..5), 2. DataContainer component factories, ver. 2.33.2134 2023-12-01 10:59:15 +01:00
Milan Hanajik a1df68b888 1. PrinterStatus implemented, used by printers, shown in ModelessDlg, 2. 'Simulated' printers, 3. Label.Printer uses wm.PrintLabel. 2023-11-30 17:51:49 +01:00
Milan Hanajik a625e2dfdb bool WaterMeter.PrintLabel (initially set), DataEntry.Uni : 1. "Auto s/n" function, 2. common check box, 3. Ct.PrintLabel (yes/no) 2023-11-28 15:00:48 +01:00
Milan Hanajik 0181294872 ProcedureDlg supports 3 printers. 2023-11-28 14:38:29 +01:00
Milan Hanajik 401828d4c6 Common.Forms.ModelessForm modifications. 2023-11-28 14:27:21 +01:00
Milan Hanajik 2c6e5d3367 Bug fix in Printers.Enhanced.PrinterCfgCtrl. 2023-11-28 14:21:05 +01:00
Milan Hanajik 38983990c2 PL language (Uzytkownici), ver. 2.33.2127 2023-11-09 18:00:52 +01:00
Milan Hanajik e02411d180 ProcedureDlg changes : wider ComboBox-es, PL language, etc., ver. 2.33.2120 2023-11-08 10:06:38 +01:00
Milan Hanajik 69f729b713 ver. 2.33.2113 2023-10-25 11:36:27 +02:00
Milan Hanajik f773e26fa3 SensusOracle.Database.ReadStartInfoFromProcedure( ) bug fix for PT7, ver. 2.33.2112 2023-10-23 14:36:11 +02:00
Milan Hanajik 9fed5148b6 TestWizard improvements 2023-10-23 14:36:11 +02:00
Milan Hanajik ab3a16bdc5 ver. 2.33.2111 2023-10-20 08:53:15 +02:00
Milan Hanajik 6e3f0dad0e iPerlCommunication : simulate iperls 2023-10-19 12:57:21 +02:00
Milan Hanajik ed066a005f MoreWMResultsDlg fixes. 2023-10-19 12:57:21 +02:00
Milan Hanajik d3126bd9ea SendAgain function in PreviousResultsDlg made fool proof for iPERL production, PW protection, etc. 2023-10-19 12:57:20 +02:00
Milan Hanajik 1c638b3f87 Range of q2CorrRL and q2CorrLR limitted to -128 .. +127. 2023-10-19 12:57:20 +02:00
Milan Hanajik f0afcd57a2 Metrology contains links to certificates saved as PDF files, CalibCertificateCtrl, ver. 2.33.2110 2023-10-18 15:32:40 +02:00
Milan Hanajik 769cb230e3 Results.ItemID.cs synchronized with ver. 3 branch. 2023-10-05 12:38:54 +02:00
Milan Hanajik 3c52e54e02 ver. 2.33.2105 2023-09-26 11:04:37 +02:00
Milan Hanajik 068b7fb3a2 Possibility to bypass "production tracing check" for a selected number of cycles, ver. 2.33.2104 2023-09-26 09:31:57 +02:00
Milan Hanajik 2ba6586a0e ver. 2.33.2102 2023-09-25 10:06:36 +02:00
Milan Hanajik fa403a322a TURA_SPECIAL WMsCount = 6, ver. 2.33.2101 2023-09-25 08:54:53 +02:00
Milan Hanajik 30627abc6a iPerlCommunication.OpticalHeadTest rectified. 2023-09-25 08:54:53 +02:00
Milan Hanajik 78772df3a0 Previous results : Possibility to save tracing records into a tracing DB (similarly to saving to Oracle). 2023-08-16 12:13:55 +02:00
Milan Hanajik 426bb0cce9 ProductionTracing : 1. No alternative tracing DB, 2. SaveTracingRecords( ) is public 2023-08-16 12:11:06 +02:00
Milan Hanajik 3da6fcfe73 Q2 correction clean-up, etc. 2023-08-15 17:07:32 +02:00
Milan Hanajik 8f27d1a448 ver. 2.33.2085 2023-08-09 11:39:28 +02:00
Milan Hanajik c5752f21a9 Q2 correction factor calculation bug fix, case when the original factor was not zero and the error target is not zero, ver. 2.33.2084 2023-08-09 11:15:22 +02:00
Milan Hanajik 8c30cb21e2 ver. 2.33.2081 2023-08-08 12:13:39 +02:00
Milan Hanajik 5181f75217 Bug fix in Q2 correction factor calculation when volume = 0, ver. 2.33.2080 2023-08-08 12:08:23 +02:00
Milan Hanajik 7ee41afba2 ver. 2.33.2079 2023-08-08 09:31:44 +02:00
Milan Hanajik 5bb99bbf86 E15 implementation according to MID (for Chennai, Stara Tura) 2023-08-07 16:14:19 +02:00
Milan Hanajik 6fd67cdf08 Q2 correction for standard process and MakeQ2CorrectionFrom(...) modified to satisfy MID, Q2 correction done when OoR. 2023-08-07 12:47:35 +02:00
Milan Hanajik e1bfa71310 iPerlHead.ProcParams.CalibTargetQ2 and WMType_ID removed, clean-up. 2023-08-04 12:34:55 +02:00
Milan Hanajik 2476ed7681 Bug fixes : 1. TestProfileDlg.addButton_Click, 2. TestProfileSelection - conversion to float avoided. 2023-07-14 13:30:51 +02:00
Milan Hanajik e413b55c6a sluprimadev --> deluh1web03 2023-07-12 12:06:02 +02:00
Jan Augustin 7d2da63071 Merge branch 'master-2' of 10.42.130.13:/srv/git/tbf into master-2 2023-07-12 08:46:00 +02:00
Jan Augustin 9aad4a60ab Fixed method DewaRework, add more rfid logs. 2023-07-11 11:30:38 +02:00
Milan Hanajik 6ffbda6e96 ver. 2.33.2070 2023-07-10 13:08:31 +02:00
Milan Hanajik 72a8f1dac6 Correction curve for pressure meters extended for negative pressures, etc., ver. 2.33.2065 2023-06-27 17:52:51 +02:00
Milan Hanajik d2631c8c88 DataEntry.Uni component added, DEUni column items in summary results, ver. 2.33.2064 2023-06-26 15:17:18 +02:00
Milan Hanajik 66b463c468 MainWnd : Procedure selection with filters (profile, DN, Qn, ...) 2023-06-26 14:27:35 +02:00
Milan Hanajik af38dbe81b Clean-up 2023-06-26 14:27:35 +02:00
Milan Hanajik 42010a6c26 Last RFID change reverted. 2023-06-22 14:03:14 +02:00
Milan Hanajik 21d3f5e835 attempt to fix build errors 2023-06-22 14:02:37 +02:00
123 changed files with 7317 additions and 2408 deletions
+7 -4
View File
@@ -1,4 +1,7 @@
using System;
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -53,20 +56,20 @@ namespace Common.Forms
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
void OnUpdateMessage(object sender, MessageEventArgs args)
{
if (args.Message != null) label1.Text = args.Message;
if (args != null && args.Message != null) label1.Text = args.Message;
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public static void CloseForm()
public void CloseForm()
{
if (CloseFormHandler == null) return;
try { CloseFormHandler(null, null); }
catch (Exception) { }
}
static public event EventHandler<EventArgs> CloseFormHandler;
public event EventHandler<EventArgs> CloseFormHandler;
void OnCloseForm(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
+7 -1
View File
@@ -38,12 +38,18 @@ namespace Config
public const int CompoundWMsCount = 3;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif RUM_MOB || TURA_SPECIAL
#elif RUM_MOB
public const int WMsCount = 8;
public const int LineSize = 8;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_SPECIAL
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif DEWA_300 || FUZHOU_100 || ROMA_200 || LUXEMBURG_40
public const int WMsCount = 10;
public const int LineSize = 10;
+2 -2
View File
@@ -214,9 +214,9 @@ namespace Config
/// </summary>
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
{
if (trueVolume <= float.Epsilon)
if (-float.Epsilon <= trueVolume && trueVolume <= float.Epsilon)
{
if (measuredVolume <= float.Epsilon)
if (-float.Epsilon <= measuredVolume && measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
+1 -1
View File
@@ -174,7 +174,7 @@ namespace Results
return Batch.GetTestRslt(name, part);
}
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId)
public MeterTestRslt GetMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId = CompoundMeterId.Single)
{
if (Batch.WaterMeters != null && Batch.WaterMeters.Count > wmNr0 && !Batch.WaterMeters[wmNr0].Disabled)
{
+2
View File
@@ -24,6 +24,8 @@ namespace Results.Entities
public virtual int UserNumber { get; set; }
public virtual string ProcedureName { get; set; }
public virtual bool IsRemoteProcedure { get; set; } /// Stara Tura, not mapped to DB
public virtual string PurchaseOrder { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string Workflow { get; set; } /// Stara Tura, Nanjing, not mapped to DB
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
public virtual int ProcedureRevision { get; set; }
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
+17 -9
View File
@@ -99,8 +99,8 @@ namespace Results.Entities
public virtual int HydrPruefung { get; set; }
#endif
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual int SessionId { get; set; } /// Not mapped to DB !!! 1 (regular tracing DB session) or 2 (alternative tracing DB session)
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual bool PrintLabel { get; set; } /// Not mapped to DB !!!
public virtual WaterMeterData WaterMeterData { get; set; }
public virtual Batch Batch { get; set; }
@@ -109,7 +109,13 @@ namespace Results.Entities
///
/// Wrappers
///
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string GetEndStateAux() { return Compound() ? EndStateAux : string.Empty; }
public virtual void SetEndStateAux(string s) { if (Compound()) EndStateAux = s; }
public virtual string GetStartState() { return Compound() ? string.Empty : EndStateAux; }
public virtual void SetStartState(string s) { if (!Compound()) EndStateAux = s; }
public virtual string ProductName() { return WaterMeterData.ProductName; }
public virtual string Producer() { return WaterMeterData.Producer; }
public virtual string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
public virtual string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
@@ -128,8 +134,10 @@ namespace Results.Entities
public virtual double Q3_Qn_Aux() { return WaterMeterData.Q3_Qn_Aux; }
public virtual string MetrologicalClassAux() { return WaterMeterData.MetrologicalClassAux; }
public virtual string ApprovalInfoAux() { return WaterMeterData.ApprovalInfoAux; }
public virtual int BatchNr() { return Batch.BatchNr; }
#if ORACLE_DB
public virtual int WMTypeId() { return WaterMeterData.WMTypeId; }
#endif
public virtual int BatchNr() { return Batch.BatchNr; }
public virtual int BenchId() { return Batch.TestBenchId; }
public virtual string ProcedureName() { return Batch.ProcedureName; }
public virtual int ProcedureRevision() { return Batch.ProcedureRevision; }
@@ -332,7 +340,7 @@ namespace Results.Entities
return GetMeterTestRslt(testName, CompoundMeterId.SingleOrCompound);
}
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId)
public virtual MeterTestRslt GetMeterTestRslt(string testName, CompoundMeterId meterId = CompoundMeterId.Single)
{
if (string.IsNullOrEmpty(testName)) return null;
if (Disabled) return null;
@@ -450,8 +458,8 @@ namespace Results.Entities
HydrPruefung = 0;
#endif
ProcessId = 0;
SessionId = 0;
LastRecordIsNok = false;
PrintLabel = true;
}
@@ -512,8 +520,8 @@ namespace Results.Entities
HydrPruefung = src.HydrPruefung;
#endif
ProcessId = src.ProcessId; /// Not mapped to DB
SessionId = src.SessionId; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@@ -692,8 +700,8 @@ namespace Results.Entities
writer.Write(HydrPruefung);
#endif
writer.Write(ProcessId);
writer.Write(SessionId);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@@ -772,8 +780,8 @@ namespace Results.Entities
HydrPruefung = reader.ReadInt32();
#endif
ProcessId = reader.ReadInt32();
SessionId = reader.ReadInt32();
LastRecordIsNok = reader.ReadBoolean();
PrintLabel = reader.ReadBoolean();
/// Retrieve TestData
if (reader.ReadBoolean())
+24 -10
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.OneWMResultsRowsCtrl();
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);
@@ -113,6 +126,7 @@
//
this.tracingResultsListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.tracingResultsListView.GridLines = true;
this.tracingResultsListView.HideSelection = false;
this.tracingResultsListView.Location = new System.Drawing.Point(0, 0);
this.tracingResultsListView.Name = "tracingResultsListView";
this.tracingResultsListView.Size = new System.Drawing.Size(1187, 366);
@@ -120,15 +134,14 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// allResultsTabPage
// oneWMResultsRowsCtrl
//
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 = "oneWMResultsRowsCtrl";
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
this.oneWMResultsCtrl.TabIndex = 0;
//
// MoreWMResultsDlg
//
@@ -140,6 +153,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 +167,12 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private OneWMResultsRowsCtrl 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;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
}
}
+45 -45
View File
@@ -59,57 +59,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}", wMtr.SerialNr ?? string.Empty, wMtr.Pruefindex % 100, message);
#else
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", wMtr.SerialNr ?? string.Empty);
#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() != Publish.Never &&
// mtr.Publish() != Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.Name());
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Common.Publish.Never &&
mtr.Publish() != Common.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);
}
}
+7 -4
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
@@ -24,13 +24,16 @@ namespace Results.Forms
}
}
public string Caption { set { caption = value; } get { return caption; } }
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<Results.WMeterRsltItemSpec> items;
IList<WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
@@ -45,7 +48,7 @@ namespace Results.Forms
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
items = new List<WMeterRsltItemSpec>();
columnWidths = new int[0];
}
@@ -62,7 +65,7 @@ namespace Results.Forms
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
public void Update(IList<WMeterRsltItemSpec> items)
{
this.items = items;
+5
View File
@@ -343,6 +343,11 @@ namespace Results
X9, /// 291
RadioAddress, /// 292
OriRadioAddress, /// 293
Pls_per_ltr_aux, /// 294 Compound water meter constant (water meter data, not used in calculations)
Pulses_main, /// 295 Compound main meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Pulses_aux, /// 296 Compound aux meter pulses (recalculated so that the gated ref. pulses for this meter are equal to the total ref. pulses)
Count,
}
+21
View File
@@ -231,6 +231,27 @@ namespace TBF
public string LastText3;
public string LastRemark;
/// DataEntry.Uni history
public string[] LastBgComm1;
public string[] LastBgComm2;
public string[] LastBgComm3;
///
public string[] LastBgColA;
public string[] LastBgColB;
public string[] LastBgColC;
public string[] LastBgColD;
public string[] LastBgColE;
///
public string[] LastEnComm1;
public string[] LastEnComm2;
public string[] LastEnComm3;
///
public string[] LastEnColA;
public string[] LastEnColB;
public string[] LastEnColC;
public string[] LastEnColD;
public string[] LastEnColE;
/// Purchase order history
public string[] PurchaseOrderHistory;
[XmlIgnore]
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.33.2061.0")]
[assembly: AssemblyFileVersion("2.33.2061.0")]
[assembly: AssemblyVersion("2.33.2138.0")]
[assembly: AssemblyFileVersion("2.33.2138.0")]
+55 -10
View File
@@ -19,7 +19,7 @@ namespace TBF.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
@@ -294,6 +294,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to All files.
/// </summary>
internal static string All_files {
get {
return ResourceManager.GetString("All_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All tests must be completed.
/// </summary>
@@ -645,6 +654,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate.
/// </summary>
internal static string Calibration_certificate {
get {
return ResourceManager.GetString("Calibration_certificate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Calibration certificate validity expired.
/// </summary>
@@ -2274,6 +2292,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Get number of cycles to bypass.
/// </summary>
internal static string Get_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Get_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Grab.
/// </summary>
@@ -3615,6 +3642,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to PDF files.
/// </summary>
internal static string PDF_files {
get {
return ResourceManager.GetString("PDF_files", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PID.
/// </summary>
@@ -5091,6 +5127,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Set number of cycles to bypass.
/// </summary>
internal static string Set_number_of_cycles_to_bypass {
get {
return ResourceManager.GetString("Set_number_of_cycles_to_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set route.
/// </summary>
@@ -5424,15 +5469,6 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string String1 {
get {
return ResourceManager.GetString("String1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sun.
/// </summary>
@@ -6273,6 +6309,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Unlock a bypass.
/// </summary>
internal static string Unlock_bypass {
get {
return ResourceManager.GetString("Unlock_bypass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unlock.
/// </summary>
+22 -4
View File
@@ -673,7 +673,7 @@
<value>Tiskárna</value>
</data>
<data name="Procedure" xml:space="preserve">
<value>Prodedura</value>
<value>Procedura</value>
</data>
<data name="Procedures" xml:space="preserve">
<value>Procedury</value>
@@ -1177,7 +1177,7 @@
<value>Tisk výsledků</value>
</data>
<data name="Procedure_name" xml:space="preserve">
<value>Jméno postupu</value>
<value>Jméno procedury</value>
</data>
<data name="Process" xml:space="preserve">
<value>Proces</value>
@@ -1213,7 +1213,7 @@
<value>Objem</value>
</data>
<data name="PrintBtnText" xml:space="preserve">
<value>Vytisknout</value>
<value>Tisknout</value>
</data>
<data name="Do_you_want_to_save_changes" xml:space="preserve">
<value>Chcete uložit změny?</value>
@@ -1675,7 +1675,7 @@
<value>Konfigurace testu {0} : chybí {1}</value>
</data>
<data name="Print" xml:space="preserve">
<value>Vytisknout</value>
<value>Tisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
@@ -1683,4 +1683,22 @@
<data name="default_printer" xml:space="preserve">
<value>předvolená tiskárna</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Zjisti počet cyklů bez kontroly</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Nastav počet cyklů bez kontroly</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Odemknout vypnutí kontroly</value>
</data>
<data name="All_files" xml:space="preserve">
<value>Všechny soubory</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Kalibrační certifikát</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF soubory</value>
</data>
</root>
+21
View File
@@ -2314,4 +2314,25 @@
<data name="default_printer" xml:space="preserve">
<value>default printer</value>
</data>
<data name="Get_number_of_cycles_to_bypass" xml:space="preserve">
<value>Get number of cycles to bypass</value>
</data>
<data name="Set_number_of_cycles_to_bypass" xml:space="preserve">
<value>Set number of cycles to bypass</value>
</data>
<data name="Unlock_bypass" xml:space="preserve">
<value>Unlock a bypass</value>
</data>
<data name="Error_reading_configuration_database" xml:space="preserve">
<value>Error reading configuration database</value>
</data>
<data name="All_files" xml:space="preserve">
<value>All files</value>
</data>
<data name="Calibration_certificate" xml:space="preserve">
<value>Calibration certificate</value>
</data>
<data name="PDF_files" xml:space="preserve">
<value>PDF files</value>
</data>
</root>
+19
View File
@@ -0,0 +1,19 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
namespace TBF.Rig
{
public class DataChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public object Data;
public DataChangeArgs(CfgChangeCmd command, object data)
{
Command = command;
Data = data;
}
}
}
@@ -47,6 +47,7 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -88,6 +89,7 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
MaxTestIndex = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -349,6 +351,10 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
prms.LenghtUnit = this.LenghtUnit;
prms.Side = this.Side;
prms.MaxTestIndex = this.MaxTestIndex;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -27,6 +27,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -50,6 +51,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
Buoyancy = 1.00103;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -112,6 +114,10 @@ namespace TBF.Rig.DataContainers.Buoyancy
void CopyContentTo(ComponentCfg prms)
{
prms.Buoyancy = this.Buoyancy;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Buoyancy
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
@@ -28,6 +28,7 @@ namespace TBF.Rig.DataContainers.Density
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -52,6 +53,7 @@ namespace TBF.Rig.DataContainers.Density
AtTemperature = 20.0; /// °C
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -122,6 +124,10 @@ namespace TBF.Rig.DataContainers.Density
{
prms.RealDensity = this.RealDensity;
prms.AtTemperature = this.AtTemperature;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
public IParamsProvider Clone()
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Density
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
@@ -21,6 +21,7 @@ namespace TBF.Rig.DataContainers.Evaporation
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -42,6 +43,7 @@ namespace TBF.Rig.DataContainers.Evaporation
public void InitializeAll()
{
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
@@ -16,7 +16,7 @@ namespace TBF.Rig.DataContainers.Evaporation
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg DefaultConfig() { return new EvaporationCfg(GetType().Namespace.Substring(23), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
+131
View File
@@ -0,0 +1,131 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using Common;
namespace TBF.Rig.DataEntry
{
/// <summary>
/// Action of a DataEntry field
/// </summary>
public enum Ac
{
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
[Description("Last from history")] HistoryLast,
[Description("Load")] Load, /// Load from water meters when the form is open, save on OK
[Description("Load (readonly)")] LoadReadOnly, /// Load from water meters when the form is open, prevent changes, do not save
[Description("Set")] Set, /// Set to 'yes' when the form is open
Count,
}
/// <summary>
/// Content of a DataEntry field
/// </summary>
public enum Ct
{
[Description("None")] None,
[Description("Serial nr.")] SerialNr,
[Description("Serial nr. aux")] SerialNrAux,
[Description("Radio address")] RadioAddress,
[Description("Year of calibration")] YearOfCalibration,
[Description("Start state")] StartState,
[Description("Start state aux")] StartStateAux,
[Description("End state")] EndState,
[Description("End state aux")] EndStateAux,
[Description("Archive path")] ArchivePath,
[Description("WM Order")] WmOrder,
[Description("Batch order")] BatchOrder,
[Description("Batch and WM order")] BatchAndWmOrder,
[Description("WM Remark")] WmRemark,
[Description("Batch remark")] BatchRemark,
[Description("Batch and WM remark")] BatchAndWmRemark,
[Description("Print label")] PrintLabel,
#if ORACLE_DB
[Description("Prefix")] Prefix,
[Description("Suffix")] Suffix,
#endif
Count
}
/// <summary>
/// Function of the multi purpose button
/// </summary>
public enum MultiPurposeBtnFunction
{
None,
AutoSN,
PrintLabelsOnOff,
}
///
/// Identifies image instance
///
public enum Tst
{
Start,
End,
Both,
}
///
/// Image rotation
///
public enum Rotation
{
R0,
R90,
R180,
R270,
Count
}
public class DEItem
{
public readonly Ct Content;
public readonly string Caption;
public readonly Ac Action;
public readonly int Width;
public DEItem(Ct content, string caption, Ac action, int width)
{
Content = content;
Caption = caption;
Action = action;
Width = width;
}
static IList<DEItem> items = new List<DEItem>();
///
public static void ClearItems() { items.Clear(); }
public static void AddItem(DEItem item) { items.Add(item); }
public static void AddItem(Ct content, string caption, Ac action, int width)
{
items.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetItems() { return items; }
static IList<DEItem> columns = new List<DEItem>();
///
public static void ClearColumns() { columns.Clear(); }
public static void AddColumn(DEItem column) { columns.Add(column); }
public static void AddColumn(Ct content, string caption, Ac action, int width)
{
columns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetColumns() { return columns; }
static IList<DEItem> summaryColumns = new List<DEItem>();
///
public static void ClearSummaryColumns() { summaryColumns.Clear(); }
public static void AddSummaryColumn(DEItem column) { summaryColumns.Add(column); }
public static void AddSummaryColumn(Ct content, string caption, Ac action, int width)
{
summaryColumns.Add(new DEItem(content, caption, action, width));
}
public static IList<DEItem> GetSummaryColumns() { return summaryColumns; }
}
}
+84 -2
View File
@@ -1,13 +1,95 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry
{
public class DEUtils
{
public static string GetContent(Ct content, WaterMeter wm)
{
if (wm == null) return string.Empty;
switch (content)
{
default:
case Ct.None: return string.Empty;
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.StartStateAux: return string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.EndStateAux: return (!wm.Disabled && wm.GetEndStateAux() != null) ? wm.GetEndStateAux() : string.Empty;
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.PrintLabel: return wm.PrintLabel ? Strings.yes : Strings.no;
#if ORACLE_DB
case Ct.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Ct.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
#endif
}
}
public static void PutContent(Ct content, WaterMeter wm, string value)
{
if (wm == null || wm.Disabled) return;
int year;
switch (content)
{
default:
case Ct.None: return;
case Ct.SerialNr: wm.SerialNr = value; return;
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
case Ct.RadioAddress: wm.RadioAddress = value; return;
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
case Ct.StartState: wm.SetStartState(value); return;
case Ct.StartStateAux: return;
case Ct.EndState: wm.EndState = value; return;
case Ct.EndStateAux: wm.SetEndStateAux(value); return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
wm.PurchaseOrder = value;
return;
case Ct.BatchOrder:
case Ct.BatchAndWmOrder:
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
return;
case Ct.WmRemark:
wm.Remark = value;
return;
case Ct.BatchRemark:
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
case Ct.PrintLabel:
wm.PrintLabel = (value == Strings.yes);
return;
#if ORACLE_DB
case Ct.Prefix: wm.Prefix = value; return;
case Ct.Suffix: wm.Suffix = value; return;
#endif
}
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
+909
View File
@@ -0,0 +1,909 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class CycleBgEnForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBgEnForm));
/// Arguments
public readonly IList<WaterMeter> WaterMeters;
readonly int lineSize;
readonly Sz sz;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> commonItems;
readonly IList<DEItem> colItems;
readonly bool isEnd;
readonly string formCloseKeys;
/// Derived from arguments in the constructor
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly int commonItemsCount;
/// Size and layout related values
readonly Font font;
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int buttonsWidth;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] commonLabels;
readonly ComboBox[] commonComboBoxes;
readonly Label[] labels; /// Labels for water meter numbers
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
readonly MultiPurposeBtnFunction multiPurposeButtonFn;
bool multiPurposeButtonFlag;
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public CycleBgEnForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="commonItems">Common items displayed in the upper part of the form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="isEnd">true = This form is displayed at the end of cycle</param>
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
: this()
{
/// Arguments
this.WaterMeters = waterMeters;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.commonItems = commonItems;
this.colItems = colItems;
this.isEnd = isEnd;
/// Preserve column items for use in SummaryResults
if (!isEnd)
{
/// cycle beginning
DEItem.ClearSummaryColumns();
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
else
{
/// cycle end
foreach (var it in colItems) if (it.Content != Ct.SerialNr) DEItem.AddSummaryColumn(it);
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
commonItemsCount = (commonItems == null) ? 0 : commonItems.Count;
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
///
commonLabels = new Label[commonItemsCount];
commonComboBoxes = new ComboBox[commonItemsCount];
labels = new Label[wmsCount];
comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount];
///
/// Determine the multi purpose button function
///
multiPurposeButton.Visible = false;
multiPurposeButtonFn = MultiPurposeBtnFunction.None;
int buttonsWidth = 350;
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = "Auto s/n";
multiPurposeButtonFn = MultiPurposeBtnFunction.AutoSN;
buttonsWidth += 147;
break;
}
if (colItems[k].Content == Ct.PrintLabel)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = string.Format("{0} ({1}/{2})", Strings.Print, Strings.yes, Strings.no);
multiPurposeButtonFn = MultiPurposeBtnFunction.PrintLabelsOnOff;
multiPurposeButtonFlag = false;
buttonsWidth += 147;
break;
}
}
/// Layout related readonly variables derived from argument 'sz'
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
this.buttonsWidth = buttonsWidth;
hdrHeight = 120;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
this.buttonsWidth = buttonsWidth;
hdrHeight = 140;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
this.buttonsWidth = buttonsWidth;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Group box with common items
///
int groupBoxWidth = 0;
int groupBoxHeight = 0;
if (commonItemsCount > 0)
{
var groupBox = new GroupBox();
int labelsWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width);
var oneLabel = new Label
{
Text = commonItems[ix].Caption,
Font = font,
Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(oneLabelWidth + spacing, meterHeight),
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = groupBox,
};
groupBox.Controls.Add(oneLabel);
labelsWidth = Math.Max(labelsWidth, oneLabelWidth);
}
int combosWidth = 0;
for (int ix = 0; ix < commonItemsCount; ix++)
{
var cb = new ComboBox
{
Name = string.Format("-1~{0}", ix + 1),
Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight),
Size = new Size(commonItems[ix].Width, meterHeight),
Enabled = (commonItems[ix].Action != Ac.LoadReadOnly),
Font = font,
TabIndex = tabIndex++,
Parent = groupBox,
};
cb.SelectedIndexChanged += new System.EventHandler(comboBox_SelectedIndexChanged);
cb.TextChanged += new System.EventHandler(comboBox_TextChanged);
cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(comboBox_KeyPress);
switch (ix)
{
case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break;
case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break;
case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break;
}
commonComboBoxes[ix] = cb;
groupBox.Controls.Add(cb);
combosWidth = Math.Max(combosWidth, commonItems[ix].Width);
}
///
groupBox.Location = new Point(margin, margin - spacing);
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing;
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
groupBox.Font = font;
groupBox.TabIndex = tabIndex++;
groupBox.Parent = this;
this.Controls.Add(groupBox);
}
///
/// Table
///
int commonCheckBoxLeft = 0;
int commonCheckBoxTop = 0;
int columnsTop = Math.Max(hdrHeight, groupBoxHeight + 2 * margin + spacing);
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var comboBox = new ComboBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
comboBox.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
comboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
if (ci.Content == Ct.PrintLabel)
{
comboBox.Items.Add(Strings.yes);
comboBox.Items.Add(Strings.no);
}
else
{
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
}
left += ci.Width + spacing;
comboBoxes[k, wmPos0] = comboBox;
this.Controls.Add(comboBox);
}
var checkBox = new CheckBox
{
Location = new Point(left, top + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
checkBoxes[wmPos0] = checkBox;
this.Controls.Add(checkBox);
if (commonCheckBoxLeft == 0)
{
commonCheckBoxLeft = left;
commonCheckBoxTop = columnsTop - meterHeight;
}
}
okButton.TabIndex = tabIndex++;
clearButton.TabIndex = tabIndex++;
var commonCheckBox = new CheckBox
{
Location = new Point(commonCheckBoxLeft, commonCheckBoxTop + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
commonCheckBox.CheckedChanged += new System.EventHandler(commonCheckBox_CheckedChanged);
this.Controls.Add(commonCheckBox);
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + buttonsWidth),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
bool activeControlFound = false;
for (int ix = 0; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
ActiveControl = commonComboBoxes[ix];
activeControlFound = true;
break;
}
}
if (!activeControlFound)
{
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
int k, j;
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
ActiveControl = okButton;
}
else
{
ActiveControl = comboBoxes[k, j];
}
}
}
/// <summary>
/// Add combo box items from a history stored in a string array (obtained usually from LocalSettings)
/// </summary>
/// <param name="comboBox">ComboBox to prepare</param>
/// <param name="history">String array with a history</param>
void AddHistoryToCombo(ComboBox comboBox, string[] history)
{
if (history != null)
{
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
}
}
/// <summary>
/// Returns an array of strings from ls.
/// Never returns null, null is converted to new string[0].
/// </summary>
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
/// <param name="k">Column number (0-based)</param>
/// <returns>Array of strings</returns>
string[] GetHistoryFromLS(bool isEnd, int k)
{
if (isEnd)
{
switch (k)
{
case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA;
case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB;
case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC;
case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD;
case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE;
default: return new string[0];
}
}
else
{
switch (k)
{
case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA;
case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB;
case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC;
case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD;
case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE;
default: return new string[0];
}
}
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
clearButton.Text = Strings.ClearBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Common combo boxes
for (int ix = 0; ix < commonItemsCount; ix++)
{
switch (commonItems[ix].Action)
{
default:
case Ac.Clear:
commonComboBoxes[ix].Text = string.Empty;
break;
case Ac.HistoryLast:
commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0)
? commonComboBoxes[ix].Items[0].ToString()
: string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
break;
case Ac.Set:
commonComboBoxes[ix].Text = Strings.yes;
break;
}
}
/// Table
for (int k = 0; k < colItems.Count; k++)
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
break;
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
}
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
}
break;
case Ac.Set:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = (WaterMeters[i] != null && !WaterMeters[i].Disabled) ? Strings.yes : Strings.no;
}
break;
}
}
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = isEnd ? (WaterMeters[i] != null && !WaterMeters[i].Disabled) : false;
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int ix = 0; ix < commonItemsCount; ix++ )
{
DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text);
if (commonItems[ix].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break;
}
}
else
{
switch (ix)
{
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break;
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break;
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break;
}
}
}
///
/// Propagate common (batch) values to water meters in case of
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
///
foreach (var wm in WaterMeters)
{
if (wm != null && !wm.Disabled)
{
switch (commonItems[ix].Content)
{
case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break;
case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break;
case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break;
case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break;
}
}
}
}
for (int k = 0; k < colItems.Count; k++)
{
/// Store values to water meters and prepare an array for a history in the LocalSettings
var currentVals = new string[wmsCount];
for (int i = 0; i < wmsCount; i++)
{
DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
currentVals[i] = comboBoxes[k, i].Text;
}
/// Update history
if (colItems[k].Action != Ac.LoadReadOnly)
{
if (isEnd)
{
switch (k)
{
case 0: ls.LastEnColA = currentVals; break;
case 1: ls.LastEnColB = currentVals; break;
case 2: ls.LastEnColC = currentVals; break;
case 3: ls.LastEnColD = currentVals; break;
case 4: ls.LastEnColE = currentVals; break;
}
}
else
{
switch (k)
{
case 0: ls.LastBgColA = currentVals; break;
case 1: ls.LastBgColB = currentVals; break;
case 2: ls.LastBgColC = currentVals; break;
case 3: ls.LastBgColD = currentVals; break;
case 4: ls.LastBgColE = currentVals; break;
}
}
}
}
for (int i = 0; i < wmsCount; i++)
{
if (WaterMeters[i] != null) WaterMeters[i].Disabled = !checkBoxes[i].Checked;
}
}
private void commonCheckBox_CheckedChanged(object sender, EventArgs e)
{
bool state = (sender as CheckBox).Checked;
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = state;
}
}
private void okButton_Click(object sender, EventArgs e)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
InitializeBoxes();
}
private void multiPurposeButton_Click(object sender, EventArgs e)
{
if (multiPurposeButtonFn == MultiPurposeBtnFunction.None) return;
if (multiPurposeButtonFn == MultiPurposeBtnFunction.AutoSN)
{
///
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{
if (checkBoxes[firstIx].Checked) break;
}
if (firstIx == wmsCount)
{
return; /// There is not any enabled water meter
}
char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
///
/// Column with serial numbers found => perform an auto s/n assignment
///
string firstSN = comboBoxes[k, firstIx].Text;
int firstSnNr;
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0)
{
int lastDigitPosPlus1 = startIx + 1;
var listOfDigits = new List<char>(digits);
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1]))
{
lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0)
{
for (int ix = firstIx + 1; ix < wmsCount; ix++)
{
if (checkBoxes[ix].Checked)
{
firstSnNr++;
string newSN = firstSnNr.ToString();
int len = newSN.Length;
if (len <= digitsCount)
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
}
else
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
}
}
}
}
}
}
}
}
if (multiPurposeButtonFn == MultiPurposeBtnFunction.PrintLabelsOnOff)
{
///
/// Find a column with Ct.PrintLabel
///
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.PrintLabel)
{
for (int ix = 0; ix < wmsCount; ix++)
{
if (WaterMeters[ix] != null && !WaterMeters[ix].Disabled)
{
comboBoxes[k, ix].Text = multiPurposeButtonFlag ? Strings.yes : Strings.no;
}
}
}
}
multiPurposeButtonFlag = !multiPurposeButtonFlag;
}
}
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
isHandlersEnabled = false;
if (k >= 0 && colItems[k].Content != Ct.PrintLabel && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
{
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = comboBoxes[k, i].Items[0].ToString();
if (!string.IsNullOrEmpty(comboBoxes[k, i].Text)) checkBoxes[i].Checked = true;
}
}
isHandlersEnabled = true;
}
private void comboBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
if (e.KeyChar == '\r')
{
if (k < 0)
{
for (int ix = j; ix < commonItemsCount; ix++)
{
if (commonComboBoxes[ix].Enabled)
{
commonComboBoxes[ix].Focus();
return;
}
}
/// No next enabled common item found:
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
if (isLrOrder) { k = -1; j = 0; }
else { k = 0; j = -1; }
}
/// Change focus
if (FindNextEnabledCombo(comboBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
comboBoxes[k, j].Focus();
}
}
}
private void comboBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as ComboBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
if (k >= 0) checkBoxes[j].Checked = true;
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="comboBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledCombo(ComboBox[,] comboBoxes, ref int k, ref int i, bool isLrOrder)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == comboBoxes.GetLength(0))
{
k = 0;
if (++i == comboBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == comboBoxes.GetLength(1))
{
i = 0;
if (++k == comboBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!comboBoxes[k, i].Enabled);
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
+86
View File
@@ -0,0 +1,86 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class CycleBgEnForm
{
/// <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 Windows Form 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.multiPurposeButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// clearButton
//
resources.ApplyResources(this.clearButton, "clearButton");
this.clearButton.ForeColor = System.Drawing.Color.Black;
this.clearButton.Name = "clearButton";
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// multiPurposeButton
//
resources.ApplyResources(this.multiPurposeButton, "multiPurposeButton");
this.multiPurposeButton.ForeColor = System.Drawing.Color.Black;
this.multiPurposeButton.Name = "multiPurposeButton";
this.multiPurposeButton.UseVisualStyleBackColor = true;
this.multiPurposeButton.Click += new System.EventHandler(this.multiPurposeButton_Click);
//
// CycleBgEnForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.multiPurposeButton);
this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "CycleBgEnForm";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button multiPurposeButton;
}
}
+246
View File
@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="okButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>942, 26</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="clearButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="clearButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="clearButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="clearButton.Location" type="System.Drawing.Point, System.Drawing">
<value>795, 26</value>
</data>
<data name="clearButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="clearButton.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="clearButton.Text" xml:space="preserve">
<value>Clear</value>
</data>
<data name="&gt;&gt;clearButton.Name" xml:space="preserve">
<value>clearButton</value>
</data>
<data name="&gt;&gt;clearButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;clearButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="multiPurposeButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="multiPurposeButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="multiPurposeButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="multiPurposeButton.Location" type="System.Drawing.Point, System.Drawing">
<value>648, 26</value>
</data>
<data name="multiPurposeButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="multiPurposeButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="multiPurposeButton.Text" xml:space="preserve">
<value>Multi purpose</value>
</data>
<data name="multiPurposeButton.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Name" xml:space="preserve">
<value>multiPurposeButton</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;multiPurposeButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;multiPurposeButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1094, 561</value>
</data>
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>10000, 10000</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Batch data</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CycleBgEnForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
+20
View File
@@ -0,0 +1,20 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using TBF.Rig.GenericDevices;
namespace TBF.Rig.DataEntry.Uni
{
public class EntryForm : EntryFormNoStartEnd, IHasWMStatesForm
{
public EntryForm()
: base()
{
}
public EntryForm(Generic.IComponentCfg cfg)
: base(cfg)
{
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,305 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.DataEntry.Uni
{
public class EntryFormNoStartEnd : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm
{
private static readonly ILog log = LogManager.GetLogger(typeof(EntryFormNoStartEnd));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
public bool UsesCameras() { return false; }
readonly EntryFormCfg myCfg;
IRegReader[] regReaders;
/// <summary>
/// Properties set by the Begin, End and WMStates form
/// </summary>
bool[] disabled; /// This array is shared between forms
string[] wmCycleEndState;
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
double[] wmStartState;
public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; }
double[] wmEndState;
public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; }
string[] wmStartStateStr;
System.Windows.Forms.Form modelessDlg;
public bool Completed { get { return (modelessDlg is IHasCompleted) ? (modelessDlg as IHasCompleted).Completed : true; } }
Common.Unit volumeUnit;
double refVolume;
double errLimLo;
double errLimHi;
bool resultSaved; /// Set in Run() when results are saved
IList<Results.Entities.WaterMeter> waterMeters; /// Reference to ...ProcessData.BatchRslts.WaterMeters[]
public enum CurrentOp
{
None,
ShowFormAtCycleBeginning,
ShowFormAtCycleEnd,
EnterTestStartStates,
EnterTestEndStates,
}
CurrentOp currentOp;
public EntryFormNoStartEnd() { }
public EntryFormNoStartEnd(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as EntryFormCfg;
}
public override void Initialize()
{
disabled = new bool[TBF.Data.WMsCount];
wmStartState = new double[TBF.Data.WMsCount];
wmStartStateStr = new string[TBF.Data.WMsCount];
wmEndState = new double[TBF.Data.WMsCount];
wmCycleEndState = new string[TBF.Data.WMsCount];
volumeUnit = (TBF.Rig.Sequences.ProcessData.BenchInfo != null) ? TBF.Rig.Sequences.ProcessData.BenchInfo.VolumeUnit : Common.Unit.l;
currentOp = CurrentOp.None;
log.FatalFormat("{0} initialized: {1}", Name, this);
}
/// <returns>Reference to the operation</returns>
public IOperation ShowCycleBeginFormOp()
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleBeginning;
waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowCycleEndFormOp()
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleEnd;
waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowTestStartFormOp(IRegReader[] regReaders)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.EnterTestStartStates;
this.waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
this.regReaders = regReaders;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowTestEndFormOp(IRegReader[] regReaders, double refVolume, double errLimLo, double errLimHi)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.EnterTestEndStates;
this.waterMeters = TBF.Rig.Sequences.ProcessData.BatchRslts.Batch.WaterMeters;
this.regReaders = regReaders;
this.refVolume = refVolume;
this.errLimLo = errLimLo;
this.errLimHi = errLimHi;
return this;
}
public IOperation ShowAdvancedTestStartFormOp(IRegReader[] regReaders, IList<Results.Entities.WaterMeter> waterMeters, bool isCondOp = false)
{
return null;
}
delegate void EntryFormDlgt(EntryFormNoStartEnd myRef);
///
void OpenBeginningDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearItems();
for (int i = 0; i < myCfg.GetBgItemsCount(); i++)
{
if (myCfg.BgItemContent[i] != Ct.None)
{
DEItem.AddItem(myCfg.BgItemContent[i], myCfg.BgItemCaption[i], myCfg.BgItemAction[i], myCfg.BgItemWidth[i]);
}
}
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetBgColumnsCount(); i++)
{
if (myCfg.BgColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.BgColumnContent[i], myCfg.BgColumnCaption[i], myCfg.BgColumnAction[i], myCfg.BgColumnWidth[i]);
}
}
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.BgTitle, myCfg.BgSize, myCfg.BgIsLrOrder, myCfg.BgFormCloseKeys,
DEItem.GetItems(), DEItem.GetColumns(), false);
modelessDlg.Show();
}
///
void OpenEndDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearItems();
for (int i = 0; i < myCfg.GetEnItemsCount(); i++)
{
if (myCfg.EnItemContent[i] != Ct.None)
{
DEItem.AddItem(myCfg.EnItemContent[i], myCfg.EnItemCaption[i], myCfg.EnItemAction[i], myCfg.EnItemWidth[i]);
}
}
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetEnColumnsCount(); i++)
{
if (myCfg.EnColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.EnColumnContent[i], myCfg.EnColumnCaption[i], myCfg.EnColumnAction[i], myCfg.EnColumnWidth[i]);
}
}
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.EnTitle, myCfg.EnSize, myCfg.EnIsLrOrder, myCfg.EnFormCloseKeys,
DEItem.GetItems(), DEItem.GetColumns(), true);
modelessDlg.Show();
}
///
void OpenTestStartStatesDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetTestColumnsCount(); i++)
{
if (myCfg.TestColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.TestColumnContent[i], myCfg.TestColumnCaption[i], myCfg.TestColumnAction[i], myCfg.TestColumnWidth[i]);
}
}
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
volumeUnit);
modelessDlg.Show();
}
///
void OpenTestEndStatesDlg(EntryFormNoStartEnd myRef)
{
DEItem.ClearColumns();
for (int i = 0; i < myCfg.GetTestColumnsCount(); i++)
{
if (myCfg.TestColumnContent[i] != Ct.None)
{
DEItem.AddColumn(myCfg.TestColumnContent[i], myCfg.TestColumnCaption[i], myCfg.TestColumnAction[i], myCfg.TestColumnWidth[i]);
}
}
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
volumeUnit, wmStartStateStr, refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
/// <summary>Start this operation</summary>
public void Start()
{
resultSaved = false;
switch (currentOp)
{
case CurrentOp.ShowFormAtCycleBeginning:
if (myCfg.BgShowForm)
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
}
break;
case CurrentOp.ShowFormAtCycleEnd:
if (myCfg.EnShowForm)
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this);
}
break;
case CurrentOp.EnterTestStartStates:
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestStartStatesDlg), this);
break;
case CurrentOp.EnterTestEndStates:
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestEndStatesDlg), this);
break;
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
{
return Event.ModelessFormIsOpen;
}
if (!resultSaved) /// This is to save the result only once
{
if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestStartStates)
{
/// Fixed start test - start
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
if (dlg != null)
{
volumeUnit = dlg.VolumeUnit;
for (int i = 0; i < waterMeters.Count; i++)
{
if (!((i < waterMeters.Count && waterMeters[i].Disabled) || (i < regReaders.Length && regReaders[i] == null)))
{
wmStartState[i] = dlg.WMStartState[i];
wmStartStateStr[i] = dlg.WMStartStateStr[i];
}
}
}
}
else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestEndStates)
{
/// Fixed start test - end
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
if (dlg != null)
{
volumeUnit = dlg.VolumeUnit;
for (int i = 0; i < waterMeters.Count; i++)
{
if (!((i < waterMeters.Count && waterMeters[i].Disabled) || (i < regReaders.Length && regReaders[i] == null)))
{
wmEndState[i] = dlg.WMEndState[i];
}
}
}
}
resultSaved = true;
modelessDlg = null;
}
return Event.ModelessFormClosed; /// Form closed
}
/// <summary>Stop this operation</summary>
public void Stop()
{
if (modelessDlg is IHasCompleted)
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
currentOp = CurrentOp.None;
}
}
}
+25
View File
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.Uni
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new EntryFormNoStartEnd(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryForm(cfg); }
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8)); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(EntryFormCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,24 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.DataEntry.Uni
{
public class FactoryNoStartEnd : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8) + "-NoStartEnd"; } }
public IComponent DummyComponent() { return new EntryFormNoStartEnd(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryFormNoStartEnd(cfg); }
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8) + "-NoStartEnd"); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(EntryFormCfg.Serializer, component, this);
}
}
}
+600
View File
@@ -0,0 +1,600 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Common;
using Results.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
namespace TBF.Rig.DataEntry.Uni
{
public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
/// Arguments
public readonly IList<WaterMeter> waterMeters;
readonly IRegReader[] regReaders;
readonly int lineSize;
readonly Sz sz;
readonly bool isStartBoxAlwaysEn;
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
readonly IList<DEItem> colItems;
readonly string formCloseKeys;
public readonly string[] WMStartStateStr;
readonly double refVolume;
readonly double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
readonly double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
/// Derived from arguments in the constructor
readonly bool isEnd;
readonly WaterMeter firstValidWM;
readonly int wmsCount;
readonly int linesCount;
readonly bool fixedErrorLimits; /// false in case of calculated error limits
/// To be retrieved after the form closes
public double[] WMStartState;
public double[] WMEndState;
public Unit VolumeUnit;
int startStateColumn;
int endStateColumn;
/// Size and layout related values
readonly int meterHeight;
readonly int meterWidth;
readonly int margin;
readonly int spacing;
readonly int hdrHeight;
readonly int labelWid;
readonly int checkBoxWid;
/// UI elements
readonly Label[] labels; /// Labels for water meter numbers
readonly TextBox[,] textBoxes; /// Text boxes for values in columns
readonly Label[] exclamations;
readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Parameterless constructor for common functionality
/// </summary>
public TestStartEndForm()
{
InitializeComponent();
ControlBox = false;
completed = false;
StartForceCloseHandler();
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMeters">Water meters</param>
/// <param name="regReaders">Array of register readers</param>
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
/// <param name="title">Form title</param>
/// <param name="sz">Font size</param>
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
/// <param name="formCloseKeys">String containing keys to close this form</param>
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
/// <param name="initialVolumeUnit">Volume unit preset initially</param>
/// <param name="wmStartStateStr">Information entered on test start</param>
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
public TestStartEndForm(IList<WaterMeter> waterMeters, IRegReader[] regReaders, int lineSize, string title, Sz sz,
bool isStartBoxAlwaysEn, bool isLrOrder, string formCloseKeys, IList<DEItem> colItems,
Unit initialVolumeUnit, string[] wmStartStateStr = null,
double refVolume = 0, double errLimLo = 0, double errLimHi = 0)
: this()
{
this.waterMeters = waterMeters;
this.regReaders = regReaders;
this.lineSize = lineSize;
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
this.sz = sz;
this.isStartBoxAlwaysEn = isStartBoxAlwaysEn;
this.isLrOrder = isLrOrder;
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
this.colItems = colItems;
this.VolumeUnit = initialVolumeUnit;
this.WMStartStateStr = wmStartStateStr;
this.refVolume = refVolume;
this.warningLimLo = 2 * errLimLo;
this.warningLimHi = 2 * errLimHi;
if (waterMeters == null || regReaders == null ||
(wmStartStateStr != null && wmStartStateStr.Length != waterMeters.Count))
{
throw new Exception("Invalid argument");
}
ls = Program.LocalSettings;
/// Readonly variables derived from arguments
isEnd = (wmStartStateStr != null);
wmsCount = waterMeters.Count;
if (WMStartStateStr == null) WMStartStateStr = new string[wmsCount];
fixedErrorLimits = (errLimHi > errLimLo);
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
firstValidWM = waterMeters.FirstOrDefault(x => (x != null && !x.Disabled));
WMStartState = new double[wmsCount];
WMEndState = new double[wmsCount];
///
unitComboBox.Text = VolumeUnit.ToDescription();
labels = new Label[wmsCount];
textBoxes = new TextBox[colItems.Count, wmsCount];
exclamations = new Label[wmsCount];
/// Layout related readonly variables derived from argument 'sz'
Font font;
Font exclamationFont;
switch (sz)
{
case Sz.S:
font = new Font("Verdana", 12, FontStyle.Regular);
//exclamationFont = new Font("Verdana", 24F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(238)));
exclamationFont = new Font("Verdana", 18, FontStyle.Bold);
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
hdrHeight = 160;
labelWid = 31;
checkBoxWid = 23;
break;
default:
case Sz.M:
font = new Font("Verdana", 14, FontStyle.Regular);
exclamationFont = new Font("Verdana", 20, FontStyle.Bold);
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
hdrHeight = 160;
labelWid = 34;
checkBoxWid = 23;
break;
case Sz.L:
font = new Font("Verdana", 18, FontStyle.Regular);
exclamationFont = new Font("Verdana", 24, FontStyle.Bold);
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
break;
}
meterWidth = labelWid + checkBoxWid + spacing;
foreach (var ci in colItems) { meterWidth += ci.Width + spacing; }
int tabIndex = 1;
///
/// Table
///
int columnsTop = hdrHeight;
for (int j = 0; j < linesCount; j++)
{
/// Captions
int capX = margin + j * (meterWidth + margin / 2) + labelWid + spacing;
int capY = columnsTop - meterHeight;
for (int k = 0; k < colItems.Count; k++)
{
int labelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(colItems[k].Caption, font).Width);
var label = new Label
{
Text = colItems[k].Caption,
Location = new Point(capX, capY),
Size = new Size(labelWidth + spacing, meterHeight),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
capX += colItems[k].Width + spacing;
}
/// Water meters
for (int i = 0; i < lineSize; i++)
{
int wmPos0 = i + lineSize * j;
if (wmPos0 > wmsCount) continue;
int left = margin + j * (meterWidth + margin / 2);
int top = columnsTop + i * (meterHeight + spacing);
var label = new Label
{
Text = (wmPos0 + 1).ToString(),
Location = new Point(left, top),
Size = new Size(labelWid, meterHeight),
Font = font,
TextAlign = ContentAlignment.MiddleLeft,
TabIndex = tabIndex++,
Parent = this,
};
left += labelWid + spacing / 2;
labels[wmPos0] = label;
this.Controls.Add(label);
/// Columns
for (int k = 0; k < colItems.Count; k++)
{
DEItem ci = colItems[k];
var textBox = new TextBox
{
Name = string.Format("{0}~{1}", k, wmPos0),
Location = new Point(left, top),
Size = new Size(ci.Width, meterHeight),
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
Font = font,
TabIndex = tabIndex++,
Parent = this,
};
textBox.TextChanged += new System.EventHandler(textBox_TextChanged);
textBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox_KeyPress);
textBox.MouseClick += new System.Windows.Forms.MouseEventHandler(textBox_MouseClick);
left += ci.Width + spacing;
textBoxes[k, wmPos0] = textBox;
this.Controls.Add(textBox);
}
var exclamation = new Label
{
AutoSize = true,
Font = exclamationFont,
ForeColor = System.Drawing.Color.Red,
Location = new Point(left, top),
Parent = this,
TabIndex = tabIndex++,
Text = "!",
Visible = false,
};
exclamations[wmPos0] = exclamation;
this.Controls.Add(exclamation);
}
}
///
/// Adjust window size
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), 1300),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
InitializeBoxes();
/// Set focus to the first enabled ComboBox
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
}
/// <summary>
/// Initialize combo boxes state defined by related 'Action'.
/// Clear check boxes.
/// </summary>
void InitializeBoxes()
{
isHandlersEnabled = false;
/// Table
startStateColumn = -1;
endStateColumn = -1;
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.StartState)
{
startStateColumn = k;
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = (!isEnd || waterMeters[i] == null
|| waterMeters[i].Disabled
|| i >= regReaders.Length
|| regReaders[i] == null
|| string.IsNullOrEmpty(WMStartStateStr[i])) ? string.Empty : WMStartStateStr[i];
textBoxes[k, i].Enabled = (isStartBoxAlwaysEn || !isEnd) && waterMeters[i] != null && !waterMeters[i].Disabled
&& i < regReaders.Length && regReaders[i] != null;
}
}
else if (colItems[k].Content == Ct.EndState)
{
endStateColumn = k;
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = string.Empty;
textBoxes[k, i].Enabled = isEnd && waterMeters[i] != null && !waterMeters[i].Disabled
&& i < regReaders.Length && regReaders[i] != null;
}
}
else
{
switch (colItems[k].Action)
{
default:
case Ac.Clear:
case Ac.HistoryLast:
for (int i = 0; i < wmsCount; i++) textBoxes[k, i].Text = string.Empty;
break;
case Ac.Load:
case Ac.LoadReadOnly:
for (int i = 0; i < wmsCount; i++)
{
textBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, waterMeters[i]);
}
break;
}
}
}
if (isEnd && isStartBoxAlwaysEn)
{
int k = 0;
int j = 0;
if (!FindNextEnabledTextBox(textBoxes, ref k, ref j, isLrOrder, true))
{
ActiveControl = textBoxes[k, j];
}
}
isHandlersEnabled = true;
}
/// <summary>
/// When one combo box is updated using drop-down menu, all combo boxes
/// are updated by this function.
/// </summary>
void UpdateWMsFromBoxes()
{
for (int k = 0; k < colItems.Count; k++)
{
for (int i = 0; i < wmsCount; i++)
{
if (colItems[k].Content == Ct.StartState)
{
/// Water meter start state
double startVol;
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out startVol))
{
WMStartStateStr[i] = textBoxes[k, i].Text;
WMStartState[i] = Units.ConvertFrom(VolumeUnit, startVol);
}
}
else if (colItems[k].Content == Ct.EndState)
{
/// Water meter end state
double endVol;
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out endVol))
{
WMEndState[i] = Units.ConvertFrom(VolumeUnit, endVol);
}
}
else
{
/// Other value - store values to a water meter structure
DEUtils.PutContent(colItems[k].Content, waterMeters[i], textBoxes[k, i].Text);
}
}
}
}
private void okButton_Click(object sender, EventArgs eArgs)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void unitComboBox_TextChanged(object sender, EventArgs e)
{
unitComboBox_SelectedIndexChanged(sender, e);
}
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
var newUnit = Units.FromDescription(unitComboBox.Text);
if (Units.IsVolume(newUnit))
{
VolumeUnit = newUnit;
if (!isHandlersEnabled) return;
/// Update exclamation marks
if (isEnd && startStateColumn >= 0 && endStateColumn >= 0)
{
for (int i = 0; i < wmsCount; i++)
{
double startVol, endVol;
if (Utils.TryParseUDouble(textBoxes[startStateColumn, i].Text, out startVol) &&
Utils.TryParseUDouble(textBoxes[endStateColumn, i].Text, out endVol))
{
double startState = Units.ConvertFrom(VolumeUnit, startVol);
double endState = Units.ConvertFrom(VolumeUnit, endVol);
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
}
else
{
exclamations[i].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, i].Text);
}
}
largeTextBox.Text = string.Empty;
largeExclamationLabel.Visible = false;
}
}
}
private void textBox_KeyPress(object sndr, KeyPressEventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as TextBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
/// Close the form if any 'form close key' was pressed
if (!string.IsNullOrEmpty(formCloseKeys))
{
/// Close the form if any 'close form key' was pressed
for (int ix = 0; ix < formCloseKeys.Length; ix++)
{
if (e.KeyChar == formCloseKeys[ix])
{
okButton_Click(sndr, e);
return;
}
}
}
if (e.KeyChar == '\r')
{
/// Change focus
if (FindNextEnabledTextBox(textBoxes, ref k, ref j, isLrOrder))
{
okButton.Focus();
}
else
{
textBoxes[k, j].Focus();
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
largeExclamationLabel.Visible = false;
}
}
}
/// Handle mouse clicks so that the large text box and the large exclamation mark are updated
private void textBox_MouseClick(object sndr, MouseEventArgs e)
{
textBox_TextChanged(sndr, e);
}
private void textBox_TextChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
string[] kj = (sndr as TextBox).Name.Split(new char[] { '~' });
int k = int.Parse(kj[0]);
int j = int.Parse(kj[1]);
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
if (isEnd && (k == startStateColumn || k == endStateColumn))
{
double startVol, endVol;
if (startStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumn, j].Text, out startVol) &&
endStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumn, j].Text, out endVol))
{
double startState = Units.ConvertFrom(VolumeUnit, startVol);
double endState = Units.ConvertFrom(VolumeUnit, endVol);
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
largeExclamationLabel.Visible =
exclamations[j].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
}
else
{
largeExclamationLabel.Visible =
exclamations[j].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, j].Text);
}
}
else
{
largeExclamationLabel.Visible = false;
}
}
/// <summary>
/// Find the next enabled combo box, update k and i.
/// Return true (=pastTheEndOfArray) when there is no such next combo box.
/// </summary>
/// <param name="textBoxes">2-dimensional array of combo boxes</param>
/// <param name="k">0-nased column </param>
/// <param name="i">0-based row</param>
/// <param name="isLrOrder">Order of progress to the next combo: true = left-right, false = top-down</param>
/// <returns>true (=pastTheEndOfArray) when there is no such next combo box, otherwise false</returns>
bool FindNextEnabledTextBox(TextBox[,] textBoxes, ref int k, ref int i, bool isLrOrder, bool skipStartColumn = false)
{
bool pastTheEndOfArray = false;
do
{
if (isLrOrder)
{
if (++k == textBoxes.GetLength(0))
{
k = 0;
if (++i == textBoxes.GetLength(1))
{
i = 0;
pastTheEndOfArray = true;
break;
}
}
}
else
{
if (++i == textBoxes.GetLength(1))
{
i = 0;
if (++k == textBoxes.GetLength(0))
{
k = 0;
pastTheEndOfArray = true;
break;
}
}
}
}
while (!textBoxes[k, i].Enabled || (skipStartColumn && k == startStateColumn));
return pastTheEndOfArray;
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
+114
View File
@@ -0,0 +1,114 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
namespace TBF.Rig.DataEntry.Uni
{
partial class TestStartEndForm
{
/// <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 Windows Form 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.okButton = new System.Windows.Forms.Button();
this.largeTextBox = new System.Windows.Forms.TextBox();
this.largeExclamationLabel = new System.Windows.Forms.Label();
this.unitComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Location = new System.Drawing.Point(1120, 29);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(123, 63);
this.okButton.TabIndex = 100;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// largeTextBox
//
this.largeTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.largeTextBox.Location = new System.Drawing.Point(35, 29);
this.largeTextBox.Name = "largeTextBox";
this.largeTextBox.Size = new System.Drawing.Size(849, 80);
this.largeTextBox.TabIndex = 101;
//
// largeExclamationLabel
//
this.largeExclamationLabel.AutoSize = true;
this.largeExclamationLabel.Font = new System.Drawing.Font("Verdana", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.largeExclamationLabel.ForeColor = System.Drawing.Color.Red;
this.largeExclamationLabel.Location = new System.Drawing.Point(890, 28);
this.largeExclamationLabel.Name = "largeExclamationLabel";
this.largeExclamationLabel.Size = new System.Drawing.Size(59, 78);
this.largeExclamationLabel.TabIndex = 102;
this.largeExclamationLabel.Text = "!";
this.largeExclamationLabel.Visible = false;
//
// unitComboBox
//
this.unitComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.unitComboBox.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.unitComboBox.FormattingEnabled = true;
this.unitComboBox.Location = new System.Drawing.Point(962, 46);
this.unitComboBox.Name = "unitComboBox";
this.unitComboBox.Size = new System.Drawing.Size(123, 31);
this.unitComboBox.TabIndex = 103;
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
this.unitComboBox.TextChanged += new System.EventHandler(this.unitComboBox_TextChanged);
//
// TestStartEndForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.ClientSize = new System.Drawing.Size(1284, 676);
this.Controls.Add(this.unitComboBox);
this.Controls.Add(this.largeExclamationLabel);
this.Controls.Add(this.largeTextBox);
this.Controls.Add(this.okButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "TestStartEndForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "End States";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.TextBox largeTextBox;
private System.Windows.Forms.Label largeExclamationLabel;
private System.Windows.Forms.ComboBox unitComboBox;
}
}
+2
View File
@@ -31,6 +31,7 @@ namespace TBF.Rig.Elde.Diverter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -53,6 +54,7 @@ namespace TBF.Rig.Elde.Diverter
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
+34
View File
@@ -54,6 +54,12 @@ namespace TBF.Rig.Elde.FlowMeter
public string CalibCertificate3;
public string CalibCertificate4;
public string CalibCertificate5;
public string CertPath;
public string CertPath1;
public string CertPath2;
public string CertPath3;
public string CertPath4;
public string CertPath5;
public DateTime CalibDate;
public DateTime CalibDate1;
public DateTime CalibDate2;
@@ -166,6 +172,34 @@ namespace TBF.Rig.Elde.FlowMeter
}
}
public string GetCertPath(int rangeIx1)
{
switch (rangeIx1)
{
default:
case 0: return CertPath;
case 1: return CertPath1;
case 2: return CertPath2;
case 3: return CertPath3;
case 4: return CertPath4;
case 5: return CertPath5;
}
}
public void SetCertPath(int rangeIx1, string certificate)
{
switch (rangeIx1)
{
default:
case 0: CertPath = certificate; return;
case 1: CertPath1 = certificate; return;
case 2: CertPath2 = certificate; return;
case 3: CertPath3 = certificate; return;
case 4: CertPath4 = certificate; return;
case 5: CertPath5 = certificate; return;
}
}
public DateTime GetCalibDate(int rangeIx1)
{
switch (rangeIx1)
+35 -2
View File
@@ -1,9 +1,8 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.Rig.Generic;
@@ -55,6 +54,12 @@ namespace TBF.Rig.Elde.FlowMeterDewa
public string CalibCertificate3;
public string CalibCertificate4;
public string CalibCertificate5;
public string CertPath;
public string CertPath1;
public string CertPath2;
public string CertPath3;
public string CertPath4;
public string CertPath5;
public DateTime CalibDate;
public DateTime CalibDate1;
public DateTime CalibDate2;
@@ -167,6 +172,34 @@ namespace TBF.Rig.Elde.FlowMeterDewa
}
}
public string GetCertPath(int rangeIx1)
{
switch (rangeIx1)
{
default:
case 0: return CertPath;
case 1: return CertPath1;
case 2: return CertPath2;
case 3: return CertPath3;
case 4: return CertPath4;
case 5: return CertPath5;
}
}
public void SetCertPath(int rangeIx1, string certificate)
{
switch (rangeIx1)
{
default:
case 0: CertPath = certificate; return;
case 1: CertPath1 = certificate; return;
case 2: CertPath2 = certificate; return;
case 3: CertPath3 = certificate; return;
case 4: CertPath4 = certificate; return;
case 5: CertPath5 = certificate; return;
}
}
public DateTime GetCalibDate(int rangeIx1)
{
switch (rangeIx1)
+1 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -26,6 +26,7 @@ namespace TBF.Rig.Elde.PressureMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -29,6 +29,7 @@ namespace TBF.Rig.Elde.PressureMeterInternal
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
+2
View File
@@ -29,6 +29,7 @@ namespace TBF.Rig.Elde.TempMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -51,6 +52,7 @@ namespace TBF.Rig.Elde.TempMeter
DefaultTemperature = 20.0;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -29,6 +29,7 @@ namespace TBF.Rig.Elde.TempMeterInternal
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -51,6 +52,7 @@ namespace TBF.Rig.Elde.TempMeterInternal
A5 = 0;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -44,6 +44,7 @@ namespace TBF.Rig.Elde.TempMeterMeret
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -69,6 +70,7 @@ namespace TBF.Rig.Elde.TempMeterMeret
MeretIdx0 = 4;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -172,6 +174,10 @@ namespace TBF.Rig.Elde.TempMeterMeret
prms.TempIdx0 = this.TempIdx0;
prms.ModbusAddress = this.ModbusAddress;
prms.MeretIdx0 = this.MeretIdx0;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
+3 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
namespace TBF.Rig
{
@@ -31,6 +31,8 @@ namespace TBF.Rig
GetAdc, /// Get regul.valve or diverter ADC
GetAdc1, /// Get regul.valve or diverter ADC feedback value #1
GetAdc2, /// Get regul.valve or diverter ADC feedback value #2
SetData, /// Generic set
GetData, /// Generic get
}
public enum ValveCategory
+5 -4
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018 Sensus Metering Systems
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using TBF.Rig.Generic;
@@ -11,8 +11,9 @@ namespace TBF.Rig.GenericDevices
///
/// Parameters displayed in Metrology tab page
///
string CalibCertificateNr { get; set; } /// calibration certificate number
DateTime CalibDate { get; set; } /// date of calibration
DateTime CalibValidDate { get; set; } /// calibration valid until (date)
string CalibCertificateNr { get; set; } /// Calibration certificate ID
string CertPath { get; set; } /// Path to a calibration certificate PDF document
DateTime CalibDate { get; set; } /// Date of calibration
DateTime CalibValidDate { get; set; } /// Calibration is valid until (date)
}
}
+5 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using TBF.Rig.Generic;
@@ -20,11 +20,13 @@ namespace TBF.Rig.GenericDevices
double GetPressHi(int rangeIx1);
string GetCalibCertificate(int rangeIx1); /// Get calibration certificate number
string GetCertPath(int rangeIx1); /// Get path to a calibration certificate PDF document
DateTime GetCalibDate(int rangeIx1); /// Get the date of calibration
DateTime GetCalibValidDate(int rangeIx1); /// Get calibration valid until (date)
void SetCalibCertificate(int rangeIx1, string certificate); /// Set calibration certificate number
void SetCalibDate(int rangeIx1, DateTime date); /// Get the date of calibration
void SetCalibValidDate(int rangeIx1, DateTime date); /// Get calibration valid until (date)
void SetCertPath(int rangeIx1, string certPath); /// Set path to a calibration certificate PDF document
void SetCalibDate(int rangeIx1, DateTime date); /// Set the date of calibration
void SetCalibValidDate(int rangeIx1, DateTime date); /// Set calibration valid until (date)
}
}
+7 -4
View File
@@ -1,13 +1,10 @@
///
/// Copyright (c) 2018-2021 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Hart.Nivotrack
@@ -38,6 +35,7 @@ namespace TBF.Rig.Hart.Nivotrack
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -63,6 +61,7 @@ namespace TBF.Rig.Hart.Nivotrack
Par2 = 8;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -179,6 +178,10 @@ namespace TBF.Rig.Hart.Nivotrack
prms.Address = this.Address;
prms.Par1 = this.Par1;
prms.Par2 = this.Par2;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
}
+2 -2
View File
@@ -1,9 +1,8 @@
///
/// Copyright (c) 2016-2021 Sensus Metering Systems
/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.Rig.Generic;
@@ -37,6 +36,7 @@ namespace TBF.Rig.Keithley.TempMeter
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
+18 -50
View File
@@ -1,8 +1,7 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
@@ -48,56 +47,20 @@ namespace TBF.Rig.MettlerToledo.Multi
public StopBits StopBits;
public Handshake Handshake;
///
/// Buoyancy related serialized parameters - Displayed in Metrology tab page
///
float buoyancyTemp;
float buoyancyPress;
float buoyancyHumi;
float weightStandardDensity;
string calibCertificateNr;
DateTime calibDate;
DateTime calibValidDate;
///
public float BuoyancyTemp
{
get { return buoyancyTemp; }
set { buoyancyTemp = value; }
}
public float BuoyancyPress
{
get { return buoyancyPress; }
set { buoyancyPress = value; }
}
public float BuoyancyHumi
{
get { return buoyancyHumi; }
set { buoyancyHumi = value; }
}
public float WeightStandardDensity
{
get { return weightStandardDensity; }
set { weightStandardDensity = value; }
}
public string CalibCertificateNr
{
get { return calibCertificateNr; }
set { calibCertificateNr = value; }
}
public DateTime CalibDate
{
get { return calibDate; }
set { calibDate = value; }
}
public DateTime CalibValidDate
{
get { return calibValidDate; }
set { calibValidDate = value; }
}
/// Buoyancy related serialized parameters displayed in Metrology tab page
public float BuoyancyTemp { get; set; }
public float BuoyancyPress { get; set; }
public float BuoyancyHumi { get; set; }
public float WeightStandardDensity { get; set; }
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
BalanceCfg()
BalanceCfg()
{
Name = "Balance";
ParentName = string.Empty;
@@ -119,6 +82,11 @@ namespace TBF.Rig.MettlerToledo.Multi
BuoyancyTemp = 20.0f;
BuoyancyPress = 1.0f;
BuoyancyHumi = 40.0f;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
public BalanceCfg(IComponentFactory factory)
+3 -2
View File
@@ -1,8 +1,7 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
@@ -52,6 +51,7 @@ namespace TBF.Rig.MettlerToledo.Standard
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
@@ -88,6 +88,7 @@ namespace TBF.Rig.MettlerToledo.Standard
BuoyancyHumi = 40.0f;
CalibCertificateNr = string.Empty;
CertPath = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
CalibValidDate = TBF.UI.Constants.MaxDate;
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
/// Copyright (c) 2016-2023 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using System.Xml.Serialization;
@@ -19,7 +19,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
public string ConnStr;
public string ConnStr2;
public string NetAdapter;
public bool CheckPreviousRecords;
public bool SaveTracingRecords;
@@ -30,8 +29,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
ParentName = string.Empty;
NetAdapter = string.Empty;
ConnStr = "server=10.42.128.24; database=sledovanie2020; uid=vyroba2020; pwd=qwerty; charset=utf8;";
ConnStr2 = "server=10.42.128.24; database=sledovanie2019; uid=vyroba2019; pwd=qwerty; charset=utf8;";
ConnStr = "server=10.42.128.35; database=sledovanie2019; uid=sledovanie2019; pwd=velka-javorina-970; charset=utf8;";
CheckPreviousRecords = true;
SaveTracingRecords = true;
}
@@ -45,12 +43,11 @@ namespace TBF.Rig.Output.DB.ProductionTracing
public string ToString(int i)
{
return string.Format("Name={0}, CheckPrev.={1}, SaveRecords={2}, ConnStr={3}, , ConnStr2={4}",
return string.Format("Name={0}, CheckPrev={1}, SaveRecords={2}, ConnStr={3}",
Name,
CheckPreviousRecords,
SaveTracingRecords,
ConnStr,
ConnStr2);
ConnStr);
}
}
}
+57 -108
View File
@@ -3,7 +3,6 @@
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using log4net;
using FluentNHibernate.Cfg;
@@ -11,9 +10,7 @@ using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Criterion;
using Common;
using Config.Entities;
using TracingDB.Entities;
using Events.Entities;
namespace TBF.Rig.Output.DB.ProductionTracing
{
@@ -78,17 +75,11 @@ namespace TBF.Rig.Output.DB.ProductionTracing
/// </summary>
Results.Entities.Batch batch;
ISessionFactory sessionFactory; /// Factory to create database sessions that is initialized in the constructor
IList<Process> processes;
Dictionary<int, Process> processDictionary;
Dictionary<int, IList<Workstep>> workstepsDictionary;
ISessionFactory sessionFactory2; /// Factory to create database sessions that is initialized in the constructor
IList<Process> processes2;
Dictionary<int, Process> processDictionary2;
Dictionary<int, IList<Workstep>> workstepsDictionary2;
///
/// Previous workstep verification info
///
@@ -97,7 +88,9 @@ namespace TBF.Rig.Output.DB.ProductionTracing
Workstep verifiedWorkstep;
Part verifiedPart; /// Applicable when verifyReferencePart == false
bool verifyReferencePart;
int CyclesToSkip;
public Tracing() {}
@@ -127,18 +120,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
/// Session factory 2 is used to create the 2nd database sessions
if (!string.IsNullOrEmpty(tracingCfg.ConnStr2))
{
sessionFactory2 = Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr2))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildConfiguration()
.SetProperty("hibernate.connection.connect_timeout", Const.MySqlConnectTimeoutSec)
.BuildSessionFactory();
}
/// Register this test bench in the tracing DB for approx. 2 weeks
var session = sessionFactory.OpenSession();
#if !DEBUG
@@ -155,6 +136,9 @@ namespace TBF.Rig.Output.DB.ProductionTracing
session.Close();
TracingDB.DB.SessionFactory = sessionFactory;
CyclesToSkip = 0;
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
@@ -163,6 +147,35 @@ namespace TBF.Rig.Output.DB.ProductionTracing
}
}
#region Configuration Change Handling
public static void OnDataChange(object sender, DataChangeArgs args)
{
if (DataChangeHandler == null) return;
try { DataChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<DataChangeArgs> DataChangeHandler;
public override void StartChangeHandler()
{
DataChangeHandler += delegate (object sender, DataChangeArgs args)
{
var intbox = args.Data as Boxes.IntBox;
if (args.Command == CfgChangeCmd.SetData && intbox != null)
{
CyclesToSkip = intbox.Val;
}
else if (args.Command == CfgChangeCmd.GetData)
{
TracingCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(CfgChangeCmd.GetData, 0, CyclesToSkip));
}
};
}
#endregion Configuration Change Handling
///
/// IDevice interface implementation
///
@@ -260,7 +273,16 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
log.WarnFormat("{0} : Run() : currentOp = {1}", Name, currentOpState);
opCompleted = true;
if (CheckPreviousRecords(waterMeters) != Retv.OK) anyError = true;
if (CyclesToSkip > 0)
{
CyclesToSkip--;
}
else if (CheckPreviousRecords(waterMeters) != Retv.OK)
{
anyError = true;
}
return anyError ? Event.InfoNotRead : Event.InfoRead;
}
else
@@ -359,7 +381,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
if ((wm != null) && !wm.Disabled)
{
CheckPreviousRecordOfSingleWM(session, wm, 1);
CheckPreviousRecordOfSingleWM(session, wm);
if (wm.LastRecordIsNok)
{
isAtLeastOneNOK = true;
@@ -370,34 +392,15 @@ namespace TBF.Rig.Output.DB.ProductionTracing
retVal = Retv.OK;
}
if (isAtLeastOneNOK && (sessionFactory2 != null))
{
using (ISession session2 = sessionFactory2.OpenSession())
{
for (int i = 0; i < waterMeters.Count; i++)
{
Results.Entities.WaterMeter wm = waterMeters[i];
if ((wm != null) && !wm.Disabled && wm.LastRecordIsNok)
{
CheckPreviousRecordOfSingleWM(session2, wm, 2);
}
}
retVal = Retv.OK;
}
}
return retVal;
}
Retv CheckPreviousRecordOfSingleWM(ISession session, Results.Entities.WaterMeter wm, int sessionId)
Retv CheckPreviousRecordOfSingleWM(ISession session, Results.Entities.WaterMeter wm)
{
if (string.IsNullOrEmpty(wm.SerialNr))
{
/// S/N is missing
wm.ProcessId = 0;
wm.SessionId = 0;
wm.LastRecordIsNok = false; /// OK, this is an RFID comm. error, not a production tracing error
return Retv.OK;
}
@@ -431,7 +434,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
/// No records found
wm.ProcessId = 0;
wm.SessionId = sessionId;
wm.LastRecordIsNok = true; /// NOK
///
return Retv.OK;
@@ -479,7 +481,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
wm.ProcessId = currentProcess.Id;
wm.SessionId = sessionId;
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
foreach (var rcrd in records)
{
@@ -500,7 +501,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
/// </summary>
/// <param name="session">DB session</param>
/// <param name="batch">Batch entity</param>
Retv SaveTracingRecords(Results.Entities.Batch batch)
public Retv SaveTracingRecords(Results.Entities.Batch batch)
{
ITransaction transaction = null;
ISession session = null;
@@ -516,10 +517,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
int writtenRecordsCount = 0;
foreach (var wMtr in batch.WaterMeters)
{
if (wMtr.SessionId == 1)
{
writtenRecordsCount += SaveSingleWM2DB(session, wMtr);
}
writtenRecordsCount += SaveSingleWM2DB(session, wMtr);
}
transaction.Commit();
session.Flush();
@@ -545,51 +543,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
}
}
if (sessionFactory2 != null)
{
///
/// Save to alternative tracing DB
///
transaction = null;
session = null;
try
{
session = sessionFactory2.OpenSession();
transaction = session.BeginTransaction();
int writtenRecordsCount = 0;
foreach (var wMtr in batch.WaterMeters)
{
if (wMtr.SessionId == 2)
{
writtenRecordsCount += SaveSingleWM2DB(session, wMtr);
}
}
transaction.Commit();
session.Flush();
log.ErrorFormat("Batch {0}: {1} of {2} watermeters written to the alternative production tracing DB",
batch.BatchNr, writtenRecordsCount, batch.WaterMeters.Count);
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
log.WarnFormat("Failed to write results of batch {0} to production tracing DB: {1}",
batch.BatchNr, exc.Message);
return Retv.Error;
}
finally
{
if (session != null)
{
session.Close();
session.Dispose();
}
}
}
return Retv.OK;
}
@@ -602,12 +555,12 @@ namespace TBF.Rig.Output.DB.ProductionTracing
/// <returns>Number of written reference record</returns>
int SaveSingleWM2DB(ISession session, Results.Entities.WaterMeter wm)
{
if (string.IsNullOrEmpty(wm.SerialNr) || (wm.ProcessId == 0))
if (string.IsNullOrEmpty(wm.SerialNr))
{
/// Without PCB number there is no DB activity
return 0;
}
else if ((currentProcess != null) && (wm.ProcessId == currentProcess.Id))
else if (wm.ProcessId != 0 && currentProcess != null && wm.ProcessId == currentProcess.Id)
{
/// Process is already loaded => save a reference record for this WM
session.SaveOrUpdate(new ReferenceRecord(currentProcess, currentWorkstep, wm.SerialNr, Users.CurrentUser.UserName(), workplace, wm.Passed ? 0 : 1));
@@ -639,23 +592,19 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
/// Get all already existing reference records with Code == wm.SerialNr, refRecords[0] will be the most recent one
IList<ReferenceRecord> refRecords;
int trialsCount = 0;
do
{
if (trialsCount > 0) ReadProcessesFromDB(session);
ReadProcessesFromDB(session);
refRecords = session.QueryOver<ReferenceRecord>()
var refRecords = session.QueryOver<ReferenceRecord>()
.Where(rr => (rr.Code == wm.SerialNr))
.OrderBy(rr => rr.TimeStamp).Desc
.List();
trialsCount++;
}
while (refRecords.Count == 0 && trialsCount <= 2);
/// Save a new reference record from this test bench if workstep "Test_bench" is defined in the obtained WM process
IList<Workstep> worksteps;
if ((refRecords.Count > 0) && workstepsDictionary.TryGetValue(refRecords[0].Process.Id, out worksteps) && (worksteps.Count == 1))
if (refRecords.Count > 0 &&
workstepsDictionary.TryGetValue(refRecords[0].Process.Id, out worksteps) &&
worksteps != null &&
worksteps.Count == 1)
{
session.SaveOrUpdate(new ReferenceRecord(refRecords[0].Process, worksteps[0], wm.SerialNr, Users.CurrentUser.UserName(), workplace, wm.Passed ? 0 : 1));
return 1;
@@ -1,19 +1,24 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using System.Collections.Generic;
using System.Net;
using System.Windows.Forms;
using log4net;
using Common;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.Elde.Diverter;
using TBF.Boxes;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public partial class TracingCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
static readonly ILog log = LogManager.GetLogger(typeof(TracingCfgCtrl));
public bool ShowMore { get { return false; } }
MonitoringCfg config;
public IComponentCfg Config
@@ -34,21 +39,30 @@ namespace TBF.Rig.Output.DB.ProductionTracing
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
if (config == null) return;
Localize();
Redraw();
}
StartResponseHandler();
}
public void Closing()
public void Closing()
{
}
StopResponseHandler();
}
void Redraw()
void Localize()
{
unlockBypassButton.Text = Strings.Unlock_bypass;
setCyclesToBypassButton.Text = Strings.Set_number_of_cycles_to_bypass;
getCyclesToBypassButton.Text = Strings.Get_number_of_cycles_to_bypass;
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
connStrTextBox.Text = config.ConnStr;
connStr2TextBox.Text = config.ConnStr2;
checkPreviousRecordsCheckBox.Checked = config.CheckPreviousRecords;
saveTracingRecordsCheckBox.Checked = config.SaveTracingRecords;
@@ -104,13 +118,30 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
nameTextBox.Enabled = true;
connStrTextBox.Enabled = true;
connStr2TextBox.Enabled = true;
netAdapterComboBox.Enabled = true;
checkPreviousRecordsCheckBox.Enabled = true;
saveTracingRecordsCheckBox.Enabled = true;
cyclesToBypassTextBox.Enabled = true;
setCyclesToBypassButton.Enabled = true;
unlockBypassButton.Enabled = false;
}
public CfgUpdateFlags VerifyCfg(ref string message)
private void unlockSkipCyclesButton_Click(object sender, EventArgs e)
{
var reqrdGrpMembership = new GID[] { GID.TraceabilityManagement, GID.HeadOfLab };
if (!Users.CurrentUser.IsMemberOf(reqrdGrpMembership))
{
if (new Users.Forms.LoginDlg(TBF.DB.UserSessionFactories, reqrdGrpMembership, ParentForm).ShowDialog() != DialogResult.OK)
return;
}
cyclesToBypassTextBox.Enabled = true;
setCyclesToBypassButton.Enabled = true;
unlockBypassButton.Enabled = false;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
@@ -128,7 +159,6 @@ namespace TBF.Rig.Output.DB.ProductionTracing
}
flags |= UpdateDifferent(ref config.ConnStr, connStrTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ConnStr2, connStr2TextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.CheckPreviousRecords, checkPreviousRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.SaveTracingRecords, saveTracingRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
@@ -144,5 +174,54 @@ namespace TBF.Rig.Output.DB.ProductionTracing
return flags;
}
}
private void setCyclesToSkipButton_Click(object sender, EventArgs e)
{
int cyclesToSkip = 0;
if (!int.TryParse(cyclesToBypassTextBox.Text, out cyclesToSkip) || cyclesToSkip < 0 || cyclesToSkip > 20)
{
MessageBox.Show(string.Format(Strings.Invalid_0, "(0..20)"));
return;
}
Tracing.OnDataChange(this, new DataChangeArgs(CfgChangeCmd.SetData, new IntBox(cyclesToSkip)));
}
private void getCyclesToSkipButton_Click(object sender, EventArgs e)
{
Tracing.OnDataChange(this, new DataChangeArgs(CfgChangeCmd.GetData, null));
}
#region Data Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
CmdResponseHandler += DoCmdResponse;
}
public void StopResponseHandler()
{
CmdResponseHandler -= DoCmdResponse;
}
void DoCmdResponse(object sender, CmdResponseArgs args)
{
if (args.Command == CfgChangeCmd.GetData)
{
cyclesToBypassTextBox2.Text = args.Response.ToString();
}
}
#endregion Configuration Change Handling
}
}
+103 -27
View File
@@ -40,8 +40,15 @@ namespace TBF.Rig.Output.DB.ProductionTracing
this.checkPreviousRecordsCheckBox = new System.Windows.Forms.CheckBox();
this.netAdapterLabel = new System.Windows.Forms.Label();
this.netAdapterComboBox = new System.Windows.Forms.ComboBox();
this.connStr2TextBox = new System.Windows.Forms.TextBox();
this.connStr2Label = new System.Windows.Forms.Label();
this.cyclesToBypassTextBox = new System.Windows.Forms.TextBox();
this.setCyclesToBypassButton = new System.Windows.Forms.Button();
this.getCyclesToBypassButton = new System.Windows.Forms.Button();
this.cyclesToBypassTextBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.bypassGroupBox = new System.Windows.Forms.GroupBox();
this.unlockBypassButton = new System.Windows.Forms.Button();
this.bypassGroupBox.SuspendLayout();
this.SuspendLayout();
//
// nameTextBox
@@ -73,7 +80,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
// connStrTextBox
//
this.connStrTextBox.Enabled = false;
this.connStrTextBox.Location = new System.Drawing.Point(8, 74);
this.connStrTextBox.Location = new System.Drawing.Point(8, 79);
this.connStrTextBox.Name = "connStrTextBox";
this.connStrTextBox.Size = new System.Drawing.Size(435, 20);
this.connStrTextBox.TabIndex = 4;
@@ -81,7 +88,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
// connStrLabel
//
this.connStrLabel.AutoSize = true;
this.connStrLabel.Location = new System.Drawing.Point(5, 58);
this.connStrLabel.Location = new System.Drawing.Point(5, 63);
this.connStrLabel.Name = "connStrLabel";
this.connStrLabel.Size = new System.Drawing.Size(92, 13);
this.connStrLabel.TabIndex = 3;
@@ -91,7 +98,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
//
this.saveTracingRecordsCheckBox.AutoSize = true;
this.saveTracingRecordsCheckBox.Enabled = false;
this.saveTracingRecordsCheckBox.Location = new System.Drawing.Point(117, 221);
this.saveTracingRecordsCheckBox.Location = new System.Drawing.Point(117, 181);
this.saveTracingRecordsCheckBox.Name = "saveTracingRecordsCheckBox";
this.saveTracingRecordsCheckBox.Size = new System.Drawing.Size(177, 17);
this.saveTracingRecordsCheckBox.TabIndex = 10;
@@ -102,7 +109,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
//
this.checkPreviousRecordsCheckBox.AutoSize = true;
this.checkPreviousRecordsCheckBox.Enabled = false;
this.checkPreviousRecordsCheckBox.Location = new System.Drawing.Point(117, 199);
this.checkPreviousRecordsCheckBox.Location = new System.Drawing.Point(117, 159);
this.checkPreviousRecordsCheckBox.Name = "checkPreviousRecordsCheckBox";
this.checkPreviousRecordsCheckBox.Size = new System.Drawing.Size(138, 17);
this.checkPreviousRecordsCheckBox.TabIndex = 9;
@@ -112,7 +119,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
// netAdapterLabel
//
this.netAdapterLabel.AutoSize = true;
this.netAdapterLabel.Location = new System.Drawing.Point(5, 147);
this.netAdapterLabel.Location = new System.Drawing.Point(5, 107);
this.netAdapterLabel.Name = "netAdapterLabel";
this.netAdapterLabel.Size = new System.Drawing.Size(89, 13);
this.netAdapterLabel.TabIndex = 7;
@@ -122,34 +129,95 @@ namespace TBF.Rig.Output.DB.ProductionTracing
//
this.netAdapterComboBox.Enabled = false;
this.netAdapterComboBox.FormattingEnabled = true;
this.netAdapterComboBox.Location = new System.Drawing.Point(8, 163);
this.netAdapterComboBox.Location = new System.Drawing.Point(8, 123);
this.netAdapterComboBox.Name = "netAdapterComboBox";
this.netAdapterComboBox.Size = new System.Drawing.Size(435, 21);
this.netAdapterComboBox.TabIndex = 8;
//
// connStr2TextBox
// cyclesToBypassTextBox
//
this.connStr2TextBox.Enabled = false;
this.connStr2TextBox.Location = new System.Drawing.Point(8, 118);
this.connStr2TextBox.Name = "connStr2TextBox";
this.connStr2TextBox.Size = new System.Drawing.Size(434, 20);
this.connStr2TextBox.TabIndex = 6;
this.cyclesToBypassTextBox.Enabled = false;
this.cyclesToBypassTextBox.Location = new System.Drawing.Point(41, 25);
this.cyclesToBypassTextBox.Name = "cyclesToBypassTextBox";
this.cyclesToBypassTextBox.Size = new System.Drawing.Size(50, 20);
this.cyclesToBypassTextBox.TabIndex = 11;
//
// connStr2Label
// setCyclesToBypassButton
//
this.connStr2Label.AutoSize = true;
this.connStr2Label.Location = new System.Drawing.Point(5, 102);
this.connStr2Label.Name = "connStr2Label";
this.connStr2Label.Size = new System.Drawing.Size(101, 13);
this.connStr2Label.TabIndex = 5;
this.connStr2Label.Text = "Connection string 2:";
this.setCyclesToBypassButton.Enabled = false;
this.setCyclesToBypassButton.Location = new System.Drawing.Point(113, 23);
this.setCyclesToBypassButton.Name = "setCyclesToBypassButton";
this.setCyclesToBypassButton.Size = new System.Drawing.Size(163, 23);
this.setCyclesToBypassButton.TabIndex = 13;
this.setCyclesToBypassButton.Text = "Set number of cycles to bypass";
this.setCyclesToBypassButton.UseVisualStyleBackColor = true;
this.setCyclesToBypassButton.Click += new System.EventHandler(this.setCyclesToSkipButton_Click);
//
// getCyclesToBypassButton
//
this.getCyclesToBypassButton.Location = new System.Drawing.Point(41, 59);
this.getCyclesToBypassButton.Name = "getCyclesToBypassButton";
this.getCyclesToBypassButton.Size = new System.Drawing.Size(163, 23);
this.getCyclesToBypassButton.TabIndex = 14;
this.getCyclesToBypassButton.Text = "Get number of cycles to bypass";
this.getCyclesToBypassButton.UseVisualStyleBackColor = true;
this.getCyclesToBypassButton.Click += new System.EventHandler(this.getCyclesToSkipButton_Click);
//
// cyclesToBypassTextBox2
//
this.cyclesToBypassTextBox2.Location = new System.Drawing.Point(226, 61);
this.cyclesToBypassTextBox2.Name = "cyclesToBypassTextBox2";
this.cyclesToBypassTextBox2.Size = new System.Drawing.Size(50, 20);
this.cyclesToBypassTextBox2.TabIndex = 15;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(93, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(19, 13);
this.label1.TabIndex = 16;
this.label1.Text = "-->";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(205, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(19, 13);
this.label2.TabIndex = 17;
this.label2.Text = "-->";
//
// bypassGroupBox
//
this.bypassGroupBox.Controls.Add(this.getCyclesToBypassButton);
this.bypassGroupBox.Controls.Add(this.label2);
this.bypassGroupBox.Controls.Add(this.cyclesToBypassTextBox);
this.bypassGroupBox.Controls.Add(this.label1);
this.bypassGroupBox.Controls.Add(this.setCyclesToBypassButton);
this.bypassGroupBox.Controls.Add(this.cyclesToBypassTextBox2);
this.bypassGroupBox.Location = new System.Drawing.Point(118, 222);
this.bypassGroupBox.Name = "bypassGroupBox";
this.bypassGroupBox.Size = new System.Drawing.Size(324, 99);
this.bypassGroupBox.TabIndex = 18;
this.bypassGroupBox.TabStop = false;
//
// unlockBypassButton
//
this.unlockBypassButton.Location = new System.Drawing.Point(8, 228);
this.unlockBypassButton.Name = "unlockBypassButton";
this.unlockBypassButton.Size = new System.Drawing.Size(100, 93);
this.unlockBypassButton.TabIndex = 19;
this.unlockBypassButton.Text = "Unlock a bypass";
this.unlockBypassButton.UseVisualStyleBackColor = true;
this.unlockBypassButton.Click += new System.EventHandler(this.unlockSkipCyclesButton_Click);
//
// TracingCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.connStr2TextBox);
this.Controls.Add(this.connStr2Label);
this.Controls.Add(this.unlockBypassButton);
this.Controls.Add(this.bypassGroupBox);
this.Controls.Add(this.netAdapterComboBox);
this.Controls.Add(this.netAdapterLabel);
this.Controls.Add(this.saveTracingRecordsCheckBox);
@@ -160,8 +228,10 @@ namespace TBF.Rig.Output.DB.ProductionTracing
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TracingCfgCtrl";
this.Size = new System.Drawing.Size(450, 250);
this.Size = new System.Drawing.Size(450, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.bypassGroupBox.ResumeLayout(false);
this.bypassGroupBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -178,7 +248,13 @@ namespace TBF.Rig.Output.DB.ProductionTracing
private System.Windows.Forms.CheckBox checkPreviousRecordsCheckBox;
private System.Windows.Forms.Label netAdapterLabel;
private System.Windows.Forms.ComboBox netAdapterComboBox;
private System.Windows.Forms.TextBox connStr2TextBox;
private System.Windows.Forms.Label connStr2Label;
}
private System.Windows.Forms.TextBox cyclesToBypassTextBox;
private System.Windows.Forms.Button setCyclesToBypassButton;
private System.Windows.Forms.Button getCyclesToBypassButton;
private System.Windows.Forms.TextBox cyclesToBypassTextBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox bypassGroupBox;
private System.Windows.Forms.Button unlockBypassButton;
}
}
+38 -33
View File
@@ -16,6 +16,7 @@ using Config.Entities;
using Results.Output;
using System.Text;
using Events.Entities;
using Results;
namespace TBF.Rig.Output.DB.SensusOracle
{
@@ -394,10 +395,42 @@ namespace TBF.Rig.Output.DB.SensusOracle
currentOpState = OpState.None;
}
#if ORACLE_DB
void GetTestInofFromProcedure(string logCaption)
{
///
/// Select or create appropriate test infos
///
IList<LUTestData> testsToSave = new List<LUTestData>();
int maxPruefungsNr = 0;
foreach (var td in Sequences.ProcessData.BatchRslts.Batch.Tests)
{
for (int repNr = 1; repNr <= td.Repeats; repNr++)
{
int testId = td.OraId + (td.Repeats - repNr) * td.OraIdRepetMulti;
if (testId != 0)
{
testsToSave.Add(new LUTestData(td, repNr));
if (Math.Abs(testId) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testId);
}
}
}
LUTestData[] testsToSaveArr = testsToSave.ToArray();
Array.Sort(testsToSaveArr, new LUTestDataComparer());
completeTestInfo = testsToSaveArr;
log.WarnFormat("{0} selected test infos:", logCaption);
foreach (var cti in completeTestInfo)
{
log.WarnFormat(" ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4}",
wmTypeId, wmTypeRevision, cti.TestName, cti.Id, cti.Designation);
}
}
public Retv ReadStartInfoFromDB(OracleConnection conn)
{
GetTestInofFromProcedure("ReadStartInfoFromDB"); /// Create appropriate test infos
bool anyError = false;
try
{
@@ -420,9 +453,9 @@ namespace TBF.Rig.Output.DB.SensusOracle
return anyError ? Retv.Error : Retv.OK;
}
/// <summary>
/// Read start info of one water meter from the database
/// </summary>
/// <summary>
/// Read start info of one water meter from the database
/// </summary>
/// <param name="conn">Oracke DB connection</param>
/// <param name="wm">Water meter entity</param>
/// <returns>Retv.OK when successful, Retv.Error on error</returns>
@@ -790,35 +823,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
throw new Exception(string.Format("Cannot save batch {0} to Oracle, missing entry in VT_WZTYP_SD", bat.BatchNr));
}
///
/// Select or create appropriate test infos
///
IList<LUTestData> testsToSave = new List<LUTestData>();
int maxPruefungsNr = 0;
double totalTestTime = 0;
foreach (var td in bat.Tests)
{
for (int repNr = 1; repNr <= td.Repeats; repNr++)
{
int testId = td.OraId + (td.Repeats - repNr) * td.OraIdRepetMulti;
if (testId != 0)
{
testsToSave.Add(new LUTestData(td, repNr));
if (Math.Abs(testId) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testId);
totalTestTime += td.TargetTime;
}
}
}
LUTestData[] testsToSaveArr = testsToSave.ToArray();
Array.Sort(testsToSaveArr, new LUTestDataComparer());
completeTestInfo = testsToSaveArr;
foreach (var cti in completeTestInfo)
{
log.WarnFormat("Selected test info : ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4}",
wmTypeId, wmTypeRevision, cti.TestName, cti.Id, cti.Designation);
}
GetTestInofFromProcedure("SaveBatchData"); /// Create appropriate test infos
if (dbCfg.DebugLevel == DebugMode.Normal)
{
+73 -30
View File
@@ -3,9 +3,10 @@
///
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Globalization;
using System.Threading;
using Common;
using Common.Forms;
using Results.Output.Printers.Enhanced;
using log4net;
@@ -31,8 +32,12 @@ namespace TBF.Rig.Output.Printers.Enhanced
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -43,10 +48,19 @@ namespace TBF.Rig.Output.Printers.Enhanced
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
header = string.IsNullOrEmpty(printerCfg.Header) ? string.Empty : printerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.CommonItems);
@@ -132,38 +146,67 @@ namespace TBF.Rig.Output.Printers.Enhanced
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, batch.StartTime, batch.EndTime, batch.BatchNr);
}
catch
{
documentName = string.Format("{0:yyyyMMdd-HHmm}", batch.EndTime);
}
PrintResults(batch, documentName);
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, batch.StartTime, batch.EndTime, batch.BatchNr);
}
catch
{
documentName = string.Format("{0:yyyyMMdd-HHmm}", batch.EndTime);
}
PrintResults(batch, documentName);
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
@@ -206,7 +249,7 @@ namespace TBF.Rig.Output.Printers.Enhanced
for (int i = 1; i <= printerCfg.NrOfCopies; i++)
{
string docName = string.Format(((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}-{1}"), documentName, i);
var pd = new Results.Output.Printers.Enhanced.EnhancedPrintDocument(batch, cfg, docName);
var pd = new EnhancedPrintDocument(batch, cfg, docName);
if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName;
pd.Print();
}
@@ -74,7 +74,6 @@ namespace TBF.Rig.Output.Printers.Enhanced
void Localize()
{
classNameLabel.Text = config.ClassName;
nameLabel.Text = Strings.Name;
printerLabel.Text = Strings.Printer;
selectPrinterButton.Text = "Select";
@@ -92,7 +91,9 @@ namespace TBF.Rig.Output.Printers.Enhanced
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
nameTextBox.Text = config.Name;
classNameLabel.Text = config.ClassName;
nameTextBox.Text = config.Name;
printerComboBox.Text = string.IsNullOrEmpty(config.PrinterName) ? Strings.default_printer : config.PrinterName;
templateTextBox.Text = config.Template;
orientationComboBox.Text = config.PageOrientation.ToString();
+69 -32
View File
@@ -6,6 +6,8 @@ using System.Collections.Generic;
using log4net;
using System.Globalization;
using System.Threading;
using Common;
using Common.Forms;
using Results.Output.Printers.Label;
namespace TBF.Rig.Output.Printers.Label
@@ -19,16 +21,13 @@ namespace TBF.Rig.Output.Printers.Label
public bool SupressPrinting { get { return (printerCfg.NrOfCopies == 0); } }
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
Results.Entities.Batch batch; /// Data to print
IList<Results.WMeterRsltItemSpec> commonItems; /// Items to print
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
///
/// Items to print
///
IList<Results.WMeterRsltItemSpec> commonItems;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -39,10 +38,19 @@ namespace TBF.Rig.Output.Printers.Label
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.ItemsToPrint);
}
@@ -108,29 +116,58 @@ namespace TBF.Rig.Output.Printers.Label
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
printingCompleted = false;
statusDlgShown = false;
}
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && (!printerCfg.GoodOnly || wm.Passed))
{
PrintResults(batch, wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition));
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && wm.PrintLabel && (!printerCfg.GoodOnly || wm.Passed))
{
PrintResults(batch, wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition));
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
+66 -22
View File
@@ -3,9 +3,11 @@
///
using System;
using System.Collections.Generic;
using log4net;
using System.Globalization;
using System.Threading;
using log4net;
using Common;
using Common.Forms;
using Results.Output.Printers.MultiLabel;
namespace TBF.Rig.Output.Printers.MultiLabel
@@ -27,8 +29,12 @@ namespace TBF.Rig.Output.Printers.MultiLabel
///
IList<Results.WMeterRsltItemSpec> commonItems;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -39,10 +45,19 @@ namespace TBF.Rig.Output.Printers.MultiLabel
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.ItemsToPrint);
}
@@ -112,27 +127,56 @@ namespace TBF.Rig.Output.Printers.MultiLabel
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
printingCompleted = false;
statusDlgShown = false;
}
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
PrintResults(batch, string.Format("{0}", batch.BatchNr));
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
PrintResults(batch, string.Format("{0}", batch.BatchNr));
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
+67 -24
View File
@@ -2,12 +2,12 @@
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using log4net;
using Config.Entities;
using TBF.Rig;
using Common;
using Common.Forms;
using Results.Output.Printers.Munich;
using System.Globalization;
using System.Threading;
namespace TBF.Rig.Output.Printers.Munich
{
@@ -24,6 +24,10 @@ namespace TBF.Rig.Output.Printers.Munich
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public string Version { get { return printerCfg.Version; } }
@@ -37,14 +41,23 @@ namespace TBF.Rig.Output.Printers.Munich
public override void Initialize()
{
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
/// <summary>Events: ResultsPrinted</summary>
/// <param name="benchId">Procedure to print the results of</param>
/// <param name="results">Results to print</param>
/// <returns>Reference to the operation</returns>
/// <summary>Events: ResultsPrinted</summary>
/// <param name="benchId">Procedure to print the results of</param>
/// <param name="results">Results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
@@ -54,23 +67,53 @@ namespace TBF.Rig.Output.Printers.Munich
/// <summary>Start this operation</summary>
public void Start()
{
foreach (var wm in batch.WaterMeters)
{
var pd = new Results.Output.Printers.Munich.MunichPrintDocument(printerCfg.Version, wm, printerCfg.PageOrientation);
if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName;
pd.Print();
}
}
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
foreach (var wm in batch.WaterMeters)
{
var pd = new MunichPrintDocument(printerCfg.Version, wm, printerCfg.PageOrientation);
if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName;
pd.Print();
}
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
+87 -43
View File
@@ -5,9 +5,11 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using log4net;
using Common;
using Common.Forms;
using Results.Entities;
using Results.Output.Printers.OnePerBatch;
using log4net;
namespace TBF.Rig.Output.Printers.OnePerBatch
{
@@ -31,8 +33,12 @@ namespace TBF.Rig.Output.Printers.OnePerBatch
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -43,10 +49,19 @@ namespace TBF.Rig.Output.Printers.OnePerBatch
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
header = string.IsNullOrEmpty(printerCfg.Header) ? string.Empty : printerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.CommonItems1);
@@ -150,49 +165,78 @@ namespace TBF.Rig.Output.Printers.OnePerBatch
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && (!printerCfg.GoodOnly || wm.Passed))
{
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, wm.StartTime(), wm.EndTime(), wm.BatchNr(), wm.WMPosition, wm.SerialNr);
}
catch
{
documentName = string.Format("{0}", batch.BatchNr, wm.WMPosition);
}
/// The following condition prevents printing empty AutoTest results protocols
if (string.IsNullOrEmpty(printerCfg.AutoTestParam) || wm.AutoMeterTestRslts(printerCfg.AutoTestParam).Count > 0)
{
PrintResults(batch, wm, documentName);
break;
}
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && (!printerCfg.GoodOnly || wm.Passed))
{
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, wm.StartTime(), wm.EndTime(), wm.BatchNr(), wm.WMPosition, wm.SerialNr);
}
catch
{
documentName = string.Format("{0}", batch.BatchNr, wm.WMPosition);
}
/// The following condition prevents printing empty AutoTest results protocols
if (string.IsNullOrEmpty(printerCfg.AutoTestParam) || wm.AutoMeterTestRslts(printerCfg.AutoTestParam).Count > 0)
{
PrintResults(batch, wm, documentName);
break;
}
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
+83 -39
View File
@@ -5,9 +5,11 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using log4net;
using Common;
using Common.Forms;
using Results.Entities;
using Results.Output.Printers.OnePerMeter;
using log4net;
namespace TBF.Rig.Output.Printers.OnePerMeter
{
@@ -31,8 +33,12 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -43,10 +49,19 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
header = string.IsNullOrEmpty(printerCfg.Header) ? string.Empty : printerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.CommonItems1);
@@ -154,45 +169,74 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && (!printerCfg.GoodOnly || wm.Passed))
{
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, wm.StartTime(), wm.EndTime(), wm.BatchNr(), wm.WMPosition, wm.SerialNr, wm.SerialNrAux);
/// {0} {1} {2} {3} {4} {5}
}
catch
{
documentName = string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition);
}
PrintResults(batch, wm, documentName);
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && (!printerCfg.GoodOnly || wm.Passed))
{
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, wm.StartTime(), wm.EndTime(), wm.BatchNr(), wm.WMPosition, wm.SerialNr, wm.SerialNrAux);
/// {0} {1} {2} {3} {4} {5}
}
catch
{
documentName = string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition);
}
PrintResults(batch, wm, documentName);
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
+136
View File
@@ -0,0 +1,136 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Management;
namespace TBF.Rig.Output.Printers
{
public static class PrinterStatus
{
///
/// See also https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-printer
///
public enum DetectedErrorState : UInt16
{
Unknown = 0,
Other = 1,
No_Error = 2,
Low_Paper = 3,
No_Paper = 4,
Low_Toner = 5,
No_Toner = 6,
Door_Open = 7,
Jammed = 8,
Offline = 9,
Service_Requested = 10,
Output_Bin_Full = 11,
}
public enum ExtendedPrinterStatus : UInt16
{
Other = 1,
Unknown = 2,
Idle = 3,
Printing = 4,
Warming_Up = 5,
Stopped_Printing = 6,
Offline = 7,
Paused = 8,
Error = 9,
Busy = 10,
Not_Aavailable = 11,
Waiting = 12,
Processing = 13,
Initialization = 14,
Power_Save = 15,
Pending_Deletion = 16,
IO_Active = 17,
Manual_Feed = 18,
}
public static void GetStatus(string printerName)
{
/// Perform the search for printers and return the listing as a collection
var mgmtSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
var mgmtCollection = mgmtSearcher.Get();
foreach (ManagementObject wmiObj in mgmtCollection)
{
if (wmiObj["Name"].ToString().ToLower() == printerName.ToLower())
{
/// Management object name fits the printer name
var state = (ExtendedPrinterStatus)int.Parse(wmiObj["ExtendedPrinterStatus"].ToString());
if (state == ExtendedPrinterStatus.Other ||
state == ExtendedPrinterStatus.Unknown ||
state == ExtendedPrinterStatus.Offline ||
state == ExtendedPrinterStatus.Error ||
state == ExtendedPrinterStatus.Not_Aavailable)
{
var message = string.Format("Printer '{0}' state is '{1}'", printerName, state.ToString().Replace('_', ' '));
throw new ApplicationException(message);
}
var error = (DetectedErrorState)int.Parse(wmiObj["DetectedErrorState"].ToString());
if (error != DetectedErrorState.No_Error)
{
var message = string.Format("Printer '{0}' error state is '{1}'", printerName, error.ToString().Replace('_', ' '));
throw new ApplicationException(message);
}
}
}
}
/// <summary>
/// Returns true when printer is online, without errors.
/// </summary>
/// <param name="printerName">Printer name</param>
/// <param name="message">Error message when printer is not online</param>
/// <returns>true when online, false when there are any errors or printer is not online</returns>
public static bool IsOnline(string printerName, out string message)
{
// TODO: Uncomment the following line and resolve problems : Unknown status/error always returned
// if (string.IsNullOrEmpty(printerName))
{
/// Default printer
message = string.Empty;
return true;
}
/// Perform the search for printers and return the listing as a collection
var mgmtSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
var mgmtCollection = mgmtSearcher.Get();
foreach (ManagementObject wmiObj in mgmtCollection)
{
if (wmiObj["Name"].ToString().ToLower() == printerName.ToLower())
{
/// Management object name fits the printer name
var state = (ExtendedPrinterStatus)int.Parse(wmiObj["ExtendedPrinterStatus"].ToString());
if (state == ExtendedPrinterStatus.Other ||
state == ExtendedPrinterStatus.Unknown ||
state == ExtendedPrinterStatus.Offline ||
state == ExtendedPrinterStatus.Error ||
state == ExtendedPrinterStatus.Not_Aavailable)
{
message = string.Format("Printer '{0}' state is '{1}'", printerName, state.ToString().Replace('_', ' '));
return false;
}
var error = (DetectedErrorState)int.Parse(wmiObj["DetectedErrorState"].ToString());
if (error != DetectedErrorState.No_Error)
{
message = string.Format("Printer '{0}' error state is '{1}'", printerName, error.ToString().Replace('_', ' '));
return false;
}
}
}
message = string.Empty;
return true;
}
}
}
+77 -33
View File
@@ -5,8 +5,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Results.Output.Printers.Zapiska;
using log4net;
using Common;
using Common.Forms;
using Results.Output.Printers.Zapiska;
namespace TBF.Rig.Output.Printers.Zapiska
{
@@ -30,8 +32,12 @@ namespace TBF.Rig.Output.Printers.Zapiska
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
@@ -42,10 +48,19 @@ namespace TBF.Rig.Output.Printers.Zapiska
public override void Initialize()
{
ApplyConfig();
log.FatalFormat("{0} initialized: {1}", Name, this);
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
void ApplyConfig()
{
header = string.IsNullOrEmpty(printerCfg.Header) ? string.Empty : printerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.CommonItems1);
@@ -137,38 +152,67 @@ namespace TBF.Rig.Output.Printers.Zapiska
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, batch.StartTime, batch.EndTime, batch.BatchNr);
}
catch
{
documentName = string.Format("{0:yyyyMMdd-HHmm}", batch.EndTime);
}
PrintResults(batch, documentName);
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// <summary>Stop this operation</summary>
public void Stop()
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, batch.StartTime, batch.EndTime, batch.BatchNr);
}
catch
{
documentName = string.Format("{0:yyyyMMdd-HHmm}", batch.EndTime);
}
PrintResults(batch, documentName);
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
@@ -215,7 +259,7 @@ namespace TBF.Rig.Output.Printers.Zapiska
Footer = printerCfg.Footer,
};
var pd = new Results.Output.Printers.Zapiska.ZapiskaPrintDocument(batch, cfg, documentName);
var pd = new ZapiskaPrintDocument(batch, cfg, documentName);
if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName;
pd.Print();
}
+2
View File
@@ -273,6 +273,8 @@ namespace TBF.Rig.Sequences
if (cmpnt is ISessionDataMngmnt) (cmpnt as ISessionDataMngmnt).StartSession();
}
DataEntry.DEItem.ClearSummaryColumns();
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
+29 -24
View File
@@ -8,6 +8,7 @@ using log4net;
using Common;
using Config;
using Config.Entities;
using TBF.Rig.DataEntry;
using TBF.Rig.GenericDevices;
using TBF.Rig.Operations;
using TBF.Boxes;
@@ -1352,31 +1353,35 @@ namespace TBF.Rig.Sequences
//sb.Append(";"); sb.Append((tstRslt.TotalPulsesMstr != 0) ? tstRslt.TotalPulsesMstr.ToString() : " "); /// CD - '' - pre druhy (Prolonged : celkovy pocet)
sb.Append(";"); sb.Append(1000 * tstRslt.TestTimeCorrection); /// CD [ms] Diverter test time correction
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
var smryItems = DEItem.GetSummaryColumns();
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (ProcessData.BatchRslts.Batch.WaterMeters != null &&
ProcessData.BatchRslts.Batch.WaterMeters.Count > i &&
ProcessData.BatchRslts.Batch.WaterMeters[i] != null &&
!ProcessData.BatchRslts.Batch.WaterMeters[i].Disabled)
if (BatchRslts.Batch.WaterMeters != null &&
BatchRslts.Batch.WaterMeters.Count > i &&
BatchRslts.Batch.WaterMeters[i] != null &&
!BatchRslts.Batch.WaterMeters[i].Disabled)
{
if (!ProcessData.BatchRslts.Batch.WaterMeters[i].Compound() && !ProcessData.BatchRslts.Batch.WaterMeters[i].HeatMeter())
var wm = BatchRslts.Batch.WaterMeters[i];
if (!wm.Compound() && !wm.HeatMeter())
{
/// If this is a single meter
Results.Entities.MeterTestRslt mtrRslt = ProcessData.BatchRslts.GetMeterTestRslt(tstRslt.Name(), i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt mtrRslt = BatchRslts.GetMeterTestRslt(tstRslt.Name(), i, CompoundMeterId.Single);
if (mtrRslt != null)
{
bool isCamera = (mtrRslt.RegReaderType == (int)RegisterReaderType.Camera);
sb.Append(";"); sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].SerialNr);/// CE WM Ser.No.
sb.Append(";"); sb.Append(wm.SerialNr);/// CE WM Ser.No.
sb.Append(";"); sb.Append(mtrRslt.VolumeStart); /// CF WM Vstart - pociatocny stav pri pevnom starte alebo zachyteny pri data streame
sb.Append(";"); sb.Append(mtrRslt.VolumeEnd); /// CG WM Vend - konecny stav pri pevnom starte alebo zachyteny pri data streame
sb.Append(";"); sb.Append(mtrRslt.VolumeMeter); /// CH WM Vmer - objem namerany vodomerom
sb.Append(";"); sb.Append(mtrRslt.VolumeRef); /// CI WM Vref - objem namerany stanicou
sb.Append(";"); sb.Append(mtrRslt.Error); /// CJ WM Emt - chyba vodomerom nameraneho objemu
#if IPERL
sb.Append(";"); sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].CalibFactor); /// CK iPerl calibration factor used during the test / ...
sb.Append(";"); sb.Append(wm.CalibFactor); /// CK iPerl calibration factor used during the test / ...
#else
sb.Append(";"); sb.Append(" "); /// CK nechat prazdne
#endif
@@ -1391,7 +1396,7 @@ namespace TBF.Rig.Sequences
#endif
sb.Append(";"); sb.Append(isCamera
? mtrRslt.VolumeStart * mtrRslt.PulsesPerLiter /// CQ WM Phi_start (pri hodnotach z kamery)
: ProcessData.BatchRslts.Batch.WaterMeters[i].WMPosition); /// CQ WMPosition (normalne)
: wm.WMPosition); /// CQ WMPosition (normalne)
sb.Append(";"); sb.Append(isCamera
? mtrRslt.VolumeEnd * mtrRslt.PulsesPerLiter /// CR WM Phi_end (pri hodnotach z kamery)
: 0); /// CR not used/spare (normalne)
@@ -1399,15 +1404,15 @@ namespace TBF.Rig.Sequences
sb.Append(";"); sb.Append(mtrRslt.TimestampStart); /// CS WM Time_start - ' ' -
sb.Append(";"); sb.Append(mtrRslt.TimestampEnd); /// CT WM Time_end - ' ' -
sb.Append(";"); sb.Append(isCamera ? mtrRslt.PulsesPerLiter : 0); /// CU WM Degree per liter
sb.Append(";"); sb.Append(0); /// CV Analog out 1 (max mA)
sb.Append(";"); sb.Append(0); /// CW Analog out 2 (V)
sb.Append(";"); sb.Append(0); /// CX Analog out 3 (min mA)
sb.Append(";"); sb.Append(0); /// CY Analog out 4 (max Q)
//sb.Append(";"); sb.Append(isCamera ? mtrRslt.PulsesPerLiter : 0); /// CU camera: WM Degree per liter
sb.Append(";"); sb.Append(smryItems.Count < 1 ? "0" : DEUtils.GetContent(smryItems[0].Content, wm)); /// CU
sb.Append(";"); sb.Append(smryItems.Count < 2 ? "0" : DEUtils.GetContent(smryItems[1].Content, wm)); /// CV
sb.Append(";"); sb.Append(smryItems.Count < 3 ? "0" : DEUtils.GetContent(smryItems[2].Content, wm)); /// CW
sb.Append(";"); sb.Append(smryItems.Count < 4 ? "0" : DEUtils.GetContent(smryItems[3].Content, wm)); /// CX
sb.Append(";"); sb.Append(smryItems.Count < 5 ? "0" : DEUtils.GetContent(smryItems[4].Content, wm)); /// CY
}
}
else if (ProcessData.BatchRslts.Batch.WaterMeters[i].Compound())
else if (wm.Compound())
{
/// Else if this is a compound meter
@@ -1421,13 +1426,13 @@ namespace TBF.Rig.Sequences
switch ((CompoundMeterId)b)
{
case CompoundMeterId.CompoundMain:
sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].SerialNr); /// CE
sb.Append(wm.SerialNr); /// CE
break;
case CompoundMeterId.CompoundAux:
sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].SerialNrAux); /// CE
sb.Append(wm.SerialNrAux); /// CE
break;
case CompoundMeterId.Compound:
sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].SerialNr); /// CE
sb.Append(wm.SerialNr); /// CE
break;
}
sb.Append(";"); sb.Append(mtrRslt.VolumeStart); /// CF WM Vinit - pri pevnom starte pociatocny stav natukany alebo cez inteligentny system
@@ -1456,7 +1461,7 @@ namespace TBF.Rig.Sequences
}
}
}
else /// if (ProcessData.BatchRslts.WaterMeters[i].HeatMeter())
else /// if (wm.HeatMeter())
{
/// Else this is a heat meter
@@ -1465,14 +1470,14 @@ namespace TBF.Rig.Sequences
if (volumeMtr != null)
{
sb.Append(";"); sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].SerialNr); /// WM Ser.No.
sb.Append(";"); sb.Append(wm.SerialNr); /// WM Ser.No.
sb.Append(";"); sb.Append(volumeMtr.VolumeStart); /// WM Vstart - pociatocny stav pri pevnom starte alebo zachyteny pri data streame
sb.Append(";"); sb.Append(volumeMtr.VolumeEnd); /// WM Vend - konecny stav pri pevnom starte alebo zachyteny pri data streame
sb.Append(";"); sb.Append(volumeMtr.VolumeMeter); /// WM Vmer - objem namerany vodomerom
sb.Append(";"); sb.Append(volumeMtr.VolumeRef); /// WM Vref - objem namerany stanicou
sb.Append(";"); sb.Append(volumeMtr.Error); /// WM Emt - chyba vodomerom nameraneho objemu
#if IPERL
sb.Append(";"); sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].CalibFactor); /// iPerl calibration factor used during the test / ...
sb.Append(";"); sb.Append(wm.CalibFactor); /// iPerl calibration factor used during the test / ...
#else
sb.Append(";"); sb.Append(" "); /// nechat prazdne
#endif
@@ -1500,7 +1505,7 @@ namespace TBF.Rig.Sequences
sb.Append(";"); sb.Append(energyMtr.VolumeRef); /// WM Vref - objem namerany stanicou
sb.Append(";"); sb.Append(energyMtr.Error); /// WM Emt - chyba vodomerom nameraneho objemu
#if IPERL
sb.Append(";"); sb.Append(ProcessData.BatchRslts.Batch.WaterMeters[i].CalibFactor); /// iPerl calibration factor used during the test / ...
sb.Append(";"); sb.Append(wm.CalibFactor); /// iPerl calibration factor used during the test / ...
#else
sb.Append(";"); sb.Append(" "); /// nechat prazdne
#endif
+4 -1
View File
@@ -52,6 +52,7 @@ namespace TBF.Rig
/// Public components
public static Elde.ControlBoardDev ControlBoard;
public static IWaterMeter WaterMeterCmpnt;
public static GenericDevices.IAmbient Ambient;
public static IOperation BenchWaitingOp;
public static IOperation BenchErrorOp;
@@ -358,7 +359,9 @@ namespace TBF.Rig
}
}
if (cmpnt is IScaleOrTank)
if (WaterMeterCmpnt == null && cmpnt is IWaterMeter) WaterMeterCmpnt = cmpnt as IWaterMeter;
if (cmpnt is IScaleOrTank)
{
IScaleOrTank tank = cmpnt as IScaleOrTank;
+1
View File
@@ -44,6 +44,7 @@ namespace TBF.Rig
Factories.Add(new DataEntry.Standard48.Factory());
Factories.Add(new DataEntry.Standard48.FactoryNoStartEnd());
Factories.Add(new DataEntry.StandardCamera.Factory());
Factories.Add(new DataEntry.Uni.Factory());
Factories.Add(new DataEntry.WMStates.EntryFormFactory());
Factories.Add(new RegisterReaders.KPackE.DataEntryForRadio.Factory()); /// DataEntry for KPackE radio
Factories.Add(new Dummy.Balance.Factory());
@@ -526,11 +526,11 @@ namespace TBF.Rig.TestMethods.DiverterTest
/// Delay 'TimeFlow2Mass', min. 5 seconds
State.Create(string.Format("{0}({1}) : Delay {2}", test.Method, test.Name, divRepetNr))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(Math.Max(5, test.TimeFlow2Mass)))
.EnterState();
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(Math.Max(5, test.TimeFlow2Mass)))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
@@ -83,7 +83,7 @@ namespace TBF.Rig.TestMethods.Q2CorrectionFromHistory
try
{
GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfg.BaseUrl);
client.GetToken("ReadUser", "sensus", "https://sluprimadev/SensusCore/api/v1/Locations/1/Login2").Wait();
client.GetToken("ReadUser", "sensus", "https://deluh1web03.world.fluidtechnology.net/SensusCore/api/v1/Locations/1/Login2").Wait();
Q2PreCorrection response = client.GetQ2Correction(cfg.RelativeUrl).Result;
if (response != null && response.AreDataCalculated)
{
@@ -1,4 +1,5 @@
using Sensus.iPerl.RfidCom.Helper;
using log4net;
using Sensus.iPerl.RfidCom.Helper;
using Sensus.iPerl.RfidCom.Services;
using Sensus.iPerl.RfidCom.Structures;
using System;
@@ -9,6 +10,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
{
internal class OpticalHeadTest
{
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
internal static string OpenSealing(IperlHead iHead)
{
if (RfidCommands.OpenSealing($"COM{iHead.RfidComPortNr}")) return "OK";
@@ -25,6 +28,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
{
return RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(BitConverter.ToString(pcb).Replace("-", string.Empty))).ToString();
}
rfidDataLogger.Error($"COM{iHead.RfidComPortNr}: ReadRequest_PCB ({MessageID.Configuration},16,5...) <- Error: {readRetVal}");
return "Error";
}
catch (Exception ex)
@@ -43,6 +47,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
return RfidCommands.SetTestMode($"COM{iHead.RfidComPortNr}") ? "OK" : "Error Set Test Mode";
}
#if IPERL
internal static string TurnOffRadio(IperlHead iHead)
{
try
@@ -50,7 +55,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
string payload = "03";
RfidCommunicationService rfidCommunicationService = new RfidCommunicationService { ComPort = $"COM{iHead.RfidComPortNr}", WaitTimeAfterFailure = 2200, PassThroughWaitTime = 1500, MaxRetries = 3, TimeOut = 5000 };
rfidCommunicationService.RfidWrite(Params.u8_WakeUpInterval, payload);
return rfidCommunicationService.RfidRead<string>(Params.u8_WakeUpInterval) == payload? "OK" : "Error";
return rfidCommunicationService.RfidRead<string>(Params.u8_WakeUpInterval).ToString() == payload ? "OK" : "Error";
}
catch (Exception ex)
{
@@ -66,7 +71,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
RfidCommunicationService rfidCommunicationService = new RfidCommunicationService { ComPort = $"COM{iHead.RfidComPortNr}", WaitTimeAfterFailure = 2200, PassThroughWaitTime = 1500, MaxRetries = 3, TimeOut = 5000 };
rfidCommunicationService.RfidWrite(SystemInfo.u8_system_state, payload);
Thread.Sleep(1000); // must be for pass thru params
return rfidCommunicationService.RfidRead<string>(SystemInfo.u8_system_state) == payload ? "OK" : "Error";
return rfidCommunicationService.RfidRead<string>(SystemInfo.u8_system_state).ToString() == payload ? "OK" : "Error";
}
catch (Exception ex)
{
@@ -84,7 +89,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
{
RfidCommunicationService rfidCommunicationService = new RfidCommunicationService { ComPort = $"COM{iHead.RfidComPortNr}", WaitTimeAfterFailure = 2200, PassThroughWaitTime = 1500, MaxRetries = 3, TimeOut = 5000 };
//rfidCommunicationService.RfidWrite(Params.u8_Customer_Text, custText);
return rfidCommunicationService.RfidRead<string>(Params.u8_Customer_Text);
return rfidCommunicationService.RfidRead<string>(Params.u8_Customer_Text).ToString();
}
}
catch (Exception ex)
@@ -93,5 +98,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
return $"Error COM{iHead.RfidComPortNr}";
}
#endif /// IPERL
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
//#define VERIFY_ACTIVE_MODE
//#define VERIFY_Q2_CORR_RESET
@@ -8,24 +8,24 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using log4net;
using Common;
using Config;
using Config.Entities;
using TBF.Resources;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
using Sensus.iPerl.RfidCom;
using Sensus.iPerl.RfidCom.Exceptions;
using Sensus.iPerl.RfidCom.Helper;
using Sensus.iPerl.RfidCom;
using System.Text.RegularExpressions;
using Sensus.iPerl.RfidCom.Model.Enums;
using Sensus.iPerl.RfidCom.Services;
using System.Threading.Tasks;
using Sensus.iPerl.RfidCom.Structures;
using Results.Entities;
using Results;
namespace TBF.Rig.TestMethods.iPerlCommunication
{
@@ -102,6 +102,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
public const string DewaReworkLRStr = "DEWA rework L-R";
public const string StartTestingSealedMetersStr = "Start testing sealed meters";
public const string EndTestingSealedMetersStr = "End testing sealed meters";
public const string SimulateCmd = "simulate ";
public static Color DisabledColor = Color.DarkGray;
public static Color OptoAndDirOKColor = Color.Green;
@@ -248,12 +249,19 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
catch (Exception ex)
{
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Error: {ex.Message}");
Thread.Sleep(cfg.WaitTimeAfterFailure);
if (i > 1)
if (messageID == MessageID.RadioPassthrough || messageID == MessageID.ASICRegisterReadTest)
{
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Reopen the com port.");
writer.ClosePort();
Thread.Sleep(1500);
}
else
{
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Error: {ex.Message}");
Thread.Sleep(cfg.WaitTimeAfterFailure);
if (i > 1)
{
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Reopen the com port.");
writer.ClosePort();
}
}
}
}
@@ -336,6 +344,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
activityLabel.Text = Strings.Optical_heads;
ShuffleTextBoxes(ProcessData.WMsCount, ProcessData.LineSize);
#if IPERL
ContextMenu cm = new ContextMenu();
cm.MenuItems.Add(NewMenuItem("Read PCB Number" , "ReadPCB"));
cm.MenuItems.Add(NewMenuItem("Enter Test Mode" , "StartTestMode"));
@@ -348,6 +357,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
cm.MenuItems.Add(NewMenuItem("Open sealing", "OpenSealing"));
}
this.ContextMenu = cm;
#endif
}
}
@@ -739,7 +749,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
int count = 0;
for (int wmNr0 = 0; wmNr0 < iperlHeads.Count; wmNr0++)
{
Results.Entities.WaterMeter wm = (ProcessData.BatchRslts.Batch.WaterMeters != null && ProcessData.BatchRslts.Batch.WaterMeters.Count > wmNr0)
WaterMeter wm = (ProcessData.BatchRslts.Batch.WaterMeters != null && ProcessData.BatchRslts.Batch.WaterMeters.Count > wmNr0)
? ProcessData.BatchRslts.Batch.WaterMeters[wmNr0] : null;
IperlHead ihead = iperlHeads[wmNr0];
@@ -787,7 +797,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
{
wmFound = true;
Results.Entities.WaterMeter wm = null;
WaterMeter wm = null;
if (ProcessData.BatchRslts.Batch.WaterMeters != null)
{
foreach (var w in ProcessData.BatchRslts.Batch.WaterMeters)
@@ -850,6 +860,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
else if (currentActivity.ToLower() == DewaReworkLRStr.ToLower()) error = DewaRework(ihead, wm, FlowDir.L_R, ref resultStr);
else if (currentActivity.ToLower().Contains(StartTestingSealedMetersStr.ToLower())) error = StartTestingSealedMeter(ihead, wm, ref resultStr);
else if (currentActivity.ToLower().Contains(EndTestingSealedMetersStr.ToLower())) error = EndTestingSealedMeter(ihead, wm, ref resultStr);
else if (currentActivity.ToLower().Contains(SimulateCmd.ToLower())) error = Simulate(ihead, wm, ref resultStr);
#endif
else
{
@@ -948,7 +959,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadConfiguration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr ReadConfiguration(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
///
/// The activity is "Read configuration" (this enables the watermeter, resets error flag)
@@ -1138,7 +1149,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadCalibration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr ReadCalibration(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1172,7 +1183,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadCalibrationV4(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr ReadCalibrationV4(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1210,7 +1221,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr WriteCalibrationFactor(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed || (ihead.CalibrationStruct == null)) return CommErr.CommFailed;
@@ -1345,7 +1356,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteCalibrationV4Factors(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr WriteCalibrationV4Factors(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed || (ihead.CalibrationStructV4 == null)) return CommErr.CommFailed;
@@ -1506,7 +1517,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter</param>
/// <param name="testData">TestData (name and repetitions)</param>
/// <returns>(1) selected MeterTestRslt or (2) average of repeated MTR-s or (3) null when at least one MTR is missing</returns>
static Results.Entities.MeterTestRslt GetAverageTestRslt(Results.Entities.WaterMeter wm, Results.Entities.TestData testData)
static Results.Entities.MeterTestRslt GetAverageTestRslt(WaterMeter wm, Results.Entities.TestData testData)
{
Results.Entities.MeterTestRslt avgTestRslt;
@@ -1538,7 +1549,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr NormalizeCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr NormalizeCalibrationFactor(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed || (ihead.CalibrationStruct == null)) return CommErr.CommFailed;
@@ -1607,7 +1618,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr NormalizeCalibrationV4Factors(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr NormalizeCalibrationV4Factors(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed || (ihead.CalibrationStructV4 == null)) return CommErr.CommFailed;
@@ -1677,7 +1688,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr ReadQ2Correction(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1708,7 +1719,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ResetQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr ResetQ2Correction(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
return WriteQ2Corrections(threadId, ihead, wm, ref resultStr, 0, 0);
}
@@ -1720,7 +1731,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteDefaultQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr WriteDefaultQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1776,7 +1787,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr, int factorLR, int factorRL)
static CommErr WriteQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr, int factorLR, int factorRL)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1821,7 +1832,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
static CommErr InitOrReadQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr InitOrReadQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
if (wm.Pruefindex == 0) return CommErr.CommFailed; /// Unknown pruefindex
@@ -1885,7 +1896,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr Reset2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr Reset2HzCorrection(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -1943,13 +1954,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr CalculateAndWriteQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm,
static CommErr CalculateAndWriteQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm,
Test test, ref string resultStr, Q2CorrType q2CorrType, string restOfLine)
{
var args = string.IsNullOrEmpty(restOfLine) ? new string[0] : restOfLine.Split(new char[] { ' ' });
Results.Entities.MeterTestRslt q2adjResult; /// The only test or the 1st test (the test in R-L direction)
Results.Entities.TestData q2adjTestData;
Results.Entities.TestData q2adjTestData; /// The 2nd test in L-R direction in case tests in both directions are done
///
if (args.Length == 0)
{
@@ -1995,6 +2006,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
}
var q3mtr = wm.MeterTestRslts.FirstOrDefault<Results.Entities.MeterTestRslt>(x => x.Name() == "Q3");
double q3error = (q3mtr != null) ? q3mtr.Error : 0;
Results.Entities.MeterTestRslt q2adjResult2 = null; /// 2nd test name for a test in L-R direction
Results.Entities.TestData q2adjTestData2 = null;
@@ -2053,130 +2066,105 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
return CommErr.None; /// No Q2 correction when doing conditional update and WM passed
}
double errLimitLo = test.ErrLimLo + test.Uncertainty;
double errLimitLo = test.ErrLimLo + test.Uncertainty;
double errLimitHi = test.ErrLimHi - test.Uncertainty;
///
if (q2adjResult.Error < errLimitLo || errLimitHi < q2adjResult.Error ||
(q2adjResult2 != null && (q2adjResult2.Error < errLimitLo || errLimitHi < q2adjResult2.Error)))
{
/// At least one of Q2 errors is out of range for Q2 correction
log.WarnFormat("OoR => no Q2 correction: Pos={0}, PCB#={1}, ***Q2_RL err={2}%***, ***Q2_LR err={3}%***, CalTarget={4}%, [Lo={5}%, Hi={6}%]",
ihead.Name,
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty,
ihead.CalibTargetQ2.ToString("F1"),
errLimitLo.ToString("F2"),
errLimitHi.ToString("F2"));
resultStr = string.Format("Q2 error is out of range => no Q2 correction");
rfidDataLogger.InfoFormat("{0}({1}): Q2 error ({2},{3}) is out of range ({4}..{5}) => Failed",
ihead.Name,
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty,
errLimitLo.ToString("F2"),
errLimitHi.ToString("F2"));
return CommErr.Q2OutOfRange;
}
///
/// Calculate Q2 correction factor(s) from an error measured at Q2
/// Calculate Q2 correction factor(s)
///
double q2Correction = 0;
double q2Correction2 = 0; /// L-R direction in case of Q2CorrType.Update and Q2CorrType.ConditionalUpdate
if (q2CorrType == Q2CorrType.Update || q2CorrType == Q2CorrType.ConditionalUpdate)
{
/// Calculate two Q2 correction factors from two tests done in both directions
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, ihead.CalibTargetQ2, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL);
q2Correction2 = ihead.CalculateQ2CorrectionFactor(q2adjResult2, ihead.CalibTargetQ2, q2adjTestData2.Qfrom, q2adjResult2.Q2CorrLR);
}
else
{
/// Calculate Q2 correction factors from a single test
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, ihead.CalibTargetQ2, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL);
q2Correction2 = ihead.CalculateQ2CorrectionFactor(q2adjResult, ihead.CalibTargetQ2, q2adjTestData.Qfrom, q2adjResult.Q2CorrLR);
}
int q2CorrRL = 0;
int q2CorrLR = 0;
///
if (q2CorrType == Q2CorrType.Standard ||
q2CorrType == Q2CorrType.Standard_incl_05 ||
q2CorrType == Q2CorrType.Standard_plus_incl_05 ||
q2CorrType == Q2CorrType.UpdateBothQ2FactorsTestRLDir)
q2CorrType == Q2CorrType.Standard_plus_incl_05)
{
///
/// Standard process
/// Standard process (RL)
/// No 2nd Q2 test, MakeQ2CorrectedFrom(...) is used to calculate Q2 error
/// Do not forget to modify iPerlCommunicationSeq.MakeQ2CorrectedFrom(...)
///
if (q2CorrType == Q2CorrType.Standard && Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
q2CorrRL = (q2CorrType == Q2CorrType.Standard_plus_incl_05) ? (int)Math.Round(0.9 * q2Correction) : (int)Math.Round(1.1 * q2Correction);
q2CorrLR = (int)Math.Round(0.5 * q2Correction);
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
q2CorrRL = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom, errorTarget))));
}
else if (q2CorrType == Q2CorrType.Dewa ||
q2CorrType == Q2CorrType.Dewa_incl_05 ||
q2CorrType == Q2CorrType.Dewa_plus_incl_05)
{
///
/// Process for DEWA
/// Standard process for the oposite flow direction (LR)
/// No 2nd Q2 test, MakeQ2CorrectedFrom(...) is used to calculate Q2 error
/// Do not forget to modify iPerlCommunicationSeq.MakeQ2CorrectedFrom(...)
///
if (q2CorrType == Q2CorrType.Dewa && Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
q2CorrLR = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom, errorTarget))));
}
else if (q2CorrType == Q2CorrType.RL ||
q2CorrType == Q2CorrType.RL_incl_05 ||
q2CorrType == Q2CorrType.ConditionalUpdateRL)
{
///
/// RL only
/// Assuming the 2nd Q2 test is done afterwards
/// MakeQ2CorrectedFrom(...) is not used
///
if (q2CorrType == Q2CorrType.RL && Math.Abs(q2adjResult.Error) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
/// Use the same correction factor in both directions
q2CorrRL = (q2CorrType == Q2CorrType.Dewa_plus_incl_05) ? (int)Math.Round(0.9 * q2Correction2) : (int)Math.Round(1.0 * q2Correction2);
q2CorrLR = (q2CorrType == Q2CorrType.Dewa_plus_incl_05) ? (int)Math.Round(0.9 * q2Correction2) : (int)Math.Round(1.0 * q2Correction2);
q2CorrRL = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom))));
}
else if (q2CorrType == Q2CorrType.LR ||
q2CorrType == Q2CorrType.LR_incl_05 ||
q2CorrType == Q2CorrType.ConditionalUpdateLR)
{
///
/// LR only
/// Assuming the 2nd Q2 test is done afterwards
/// MakeQ2CorrectedFrom(...) is not used
///
if (q2CorrType == Q2CorrType.LR && Math.Abs(q2adjResult.Error) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
q2CorrLR = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom))));
}
else if (q2CorrType == Q2CorrType.Update || q2CorrType == Q2CorrType.ConditionalUpdate)
{
///
/// After tests in both directions
/// Assuming the 2nd Q2 tests are done afterwards
/// MakeQ2CorrectedFrom(...) is not used
///
q2CorrRL = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom))));
q2CorrLR = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult2, q2adjResult2.Q2CorrLR, q2adjTestData2.Qfrom))));
}
else if (q2CorrType == Q2CorrType.Greece || q2CorrType == Q2CorrType.Greece_incl_05 || q2CorrType == Q2CorrType.UpdateBothQ2FactorsTestLRDir)
{
///
/// Process for Greece
///
if (q2CorrType == Q2CorrType.Greece && Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
if (q2CorrType == Q2CorrType.Greece && Math.Abs(q2adjResult.Error) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
q2CorrRL = (int)Math.Round(2.0 * q2Correction2);
q2CorrLR = (int)Math.Round(1.0 * q2Correction2);
}
else if (q2CorrType == Q2CorrType.RL || q2CorrType == Q2CorrType.RL_incl_05 || q2CorrType == Q2CorrType.ConditionalUpdateRL) /// RL only
{
if (q2CorrType == Q2CorrType.RL && Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
q2CorrRL = (int)Math.Round(q2Correction);
q2CorrLR = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom))));
q2CorrRL = q2CorrLR;
}
else if (q2CorrType == Q2CorrType.LR || q2CorrType == Q2CorrType.LR_incl_05 || q2CorrType == Q2CorrType.ConditionalUpdateLR) /// LR only
else if (q2CorrType == Q2CorrType.UpdateBothQ2FactorsTestRLDir)
{
if (q2CorrType == Q2CorrType.LR && Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
q2CorrLR = (int)Math.Round(q2Correction2);
}
else if ((q2CorrType == Q2CorrType.Update) || (q2CorrType == Q2CorrType.ConditionalUpdate))
{
q2CorrRL = (int)Math.Round(q2Correction);
q2CorrLR = (int)Math.Round(q2Correction2);
///
/// Another strange process
///
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
q2CorrRL = Math.Max(-128, Math.Min(127, Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom, errorTarget))));
q2CorrLR = q2CorrRL;
}
@@ -2186,7 +2174,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
if (ihead.CommFailed) return CommErr.CommFailed;
CommErr error = CommErr.Write;
if (q2CorrType == Q2CorrType.RL || q2CorrType == Q2CorrType.RL_incl_05 || q2CorrType == Q2CorrType.ConditionalUpdateRL)
if (q2CorrType == Q2CorrType.Standard ||
q2CorrType == Q2CorrType.Standard_incl_05 ||
q2CorrType == Q2CorrType.Standard_plus_incl_05 ||
q2CorrType == Q2CorrType.RL ||
q2CorrType == Q2CorrType.RL_incl_05 ||
q2CorrType == Q2CorrType.ConditionalUpdateRL)
{
///
/// Write R-L Q2 correction factor only
@@ -2194,11 +2188,17 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
byte[] wrData = new byte[1] { (byte)q2CorrRL };
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddrRL, wrData.Length, wrData))
{
error = CommErr.None;
wm.Q2CorrRL = ihead.Q2CorrRL = q2CorrRL;
resultStr = string.Format("Q2 correction: RL={0}", q2CorrRL);
error = CommErr.None;
}
}
else if (q2CorrType == Q2CorrType.LR || q2CorrType == Q2CorrType.LR_incl_05 || q2CorrType == Q2CorrType.ConditionalUpdateLR)
else if (q2CorrType == Q2CorrType.Dewa ||
q2CorrType == Q2CorrType.Dewa_incl_05 ||
q2CorrType == Q2CorrType.Dewa_plus_incl_05 ||
q2CorrType == Q2CorrType.LR ||
q2CorrType == Q2CorrType.LR_incl_05 ||
q2CorrType == Q2CorrType.ConditionalUpdateLR)
{
///
/// Write L-R Q2 correction factor only
@@ -2206,8 +2206,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
byte[] wrData = new byte[1] { (byte)q2CorrLR };
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddrLR, wrData.Length, wrData))
{
error = CommErr.None;
wm.Q2CorrLR = ihead.Q2CorrLR = q2CorrLR;
resultStr = string.Format("Q2 correction: LR={0}", q2CorrLR);
error = CommErr.None;
}
}
else
@@ -2218,15 +2219,47 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
byte[] wrData = new byte[2] { (byte)q2CorrLR, (byte)q2CorrRL };
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData))
{
error = CommErr.None;
wm.Q2CorrRL = ihead.Q2CorrRL = q2CorrRL;
wm.Q2CorrLR = ihead.Q2CorrLR = q2CorrLR;
resultStr = string.Format("Q2 correction: RL={0}, LR={1}", q2CorrRL, q2CorrLR);
error = CommErr.None;
}
}
///
/// Verification disabled on 16.02.2016
///
///
/// Q2 correction factor was successfully written to the water meter.
/// Check whether the original error at Q2 was within limits.
///
if (error == CommErr.None &&
(q2adjResult.Error < errLimitLo || errLimitHi < q2adjResult.Error ||
(q2adjResult2 != null && (q2adjResult2.Error < errLimitLo || errLimitHi < q2adjResult2.Error))))
{
resultStr += " (OoR)";
/// At least one of Q2 errors is out of range for Q2 correction
log.WarnFormat("OoR => anyhow Q2 correction was done: Pos={0}, PCB#={1}, ***Q2_RL err={2}%***, ***Q2_LR err={3}%***, [Lo={4}%, Hi={5}%]",
ihead.Name,
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty,
errLimitLo.ToString("F2"),
errLimitHi.ToString("F2"));
rfidDataLogger.InfoFormat("{0}({1}): Q2 error ({2},{3}) is out of range ({4}..{5}) => Failed",
ihead.Name,
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty,
errLimitLo.ToString("F2"),
errLimitHi.ToString("F2"));
error = CommErr.Q2OutOfRange;
}
///
/// Verification disabled on 16.02.2016
///
#if false
if (error == CommErr.None)
{
@@ -2247,30 +2280,18 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
}
#else
if ((q2CorrType != Q2CorrType.Update) && (q2CorrType != Q2CorrType.ConditionalUpdate))
{
wm.Q2ErrWOCorrection = ihead.Q2ErrWOCorrection = q2adjResult.Error;
}
///
/// Update WaterMeter entity and IperlHead
///
if (error == CommErr.None)
{
if (q2CorrType == Q2CorrType.RL)
{
resultStr = string.Format("Q2 correction: RL={0}", q2CorrRL);
}
else if (q2CorrType == Q2CorrType.LR)
{
resultStr = string.Format("Q2 correction: LR={0}", q2CorrLR);
}
else
{
resultStr = string.Format("Q2 correction: RL={0}, LR={1}", q2CorrRL, q2CorrLR);
}
rfidDataLogger.WarnFormat("{0}: {1}", ihead.Name, resultStr);
if ((q2CorrType != Q2CorrType.Update) && (q2CorrType != Q2CorrType.ConditionalUpdate))
{
wm.Q2ErrWOCorrection = ihead.Q2ErrWOCorrection = q2adjResult.Error;
}
rfidDataLogger.WarnFormat("{0}({1}): {2}", ihead.Name, ihead.SerialNr, resultStr);
}
#endif
@@ -2284,7 +2305,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr Write2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr Write2HzCorrection(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -2354,26 +2375,43 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="flowDir">Arrow direction</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr DewaRework(IperlHead ihead, Results.Entities.WaterMeter wm, FlowDir flowDir, ref string resultStr)
static CommErr DewaRework(IperlHead ihead, WaterMeter wm, FlowDir flowDir, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
byte arrow = (flowDir == FlowDir.L_R) ? (byte)1 : (byte)2; /// L-R is reverse flow (=1), R-L is forward flow (=2)(default)
iPerlDataWrite[] dataToBeWritten = new iPerlDataWrite[]
List<iPerlDataWrite> dataToBeWritten = new List<iPerlDataWrite>
{
new iPerlDataWrite(MessageID.MetrologyMemory, 0x19A1, new byte[] { (byte)0xA5 }, "Open Sealing"),
new iPerlDataWrite(MessageID.RadioPassthrough, 0x1804, new byte[] { (byte)1 }, "System Status"),
new iPerlDataWrite(MessageID.MetrologyMemory, 0x1985, new byte[] { arrow }, "Arrow"),
new iPerlDataWrite(MessageID.MetrologyMemory, 0x199C, new byte[5], "Clear S/N"),
new iPerlDataWrite(MessageID.Command, 0x0000, new byte[] { (byte)Command.SetActiveMode }, "Set active mode"),
new iPerlDataWrite(MessageID.Configuration, 0x0015, new byte[] { (byte)0xA0 }, "Test mode config = A0"),
new iPerlDataWrite(MessageID.MetrologyMemory, 0x198E, new byte[] { (byte)(2510 & 0xFF), (byte)((2510 >> 8) & 0xFF) }, "Receipt mean current"),
new iPerlDataWrite(MessageID.RadioPassthrough, 0x18A2, new byte[] { (byte)0x4A, (byte)0x53, (byte)0x3B, (byte)0x8F,
new iPerlDataWrite(MessageID.MetrologyMemory, 0x198E, new byte[] { (byte)(2510 & 0xFF), (byte)((2510 >> 8) & 0xFF) }, "Receipt mean current")
};
// check meter status: 1-Idle, 2-Active, 3-Test, 4-End Of Life
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 1, 1, out byte[] rdData))
{
int eMeterState = (int)((SByte)rdData[0]);
switch (eMeterState)
{
case 1: // Idle -> Test -> Active
dataToBeWritten.Add(new iPerlDataWrite(MessageID.Command, 0x0000, new byte[] { (byte)Command.SetTestMode }, "Set test mode"));
dataToBeWritten.Add(new iPerlDataWrite(MessageID.Command, 0x0000, new byte[] { (byte)Command.SetActiveMode }, "Set active mode"));
break;
case 3: // Test Mode -> Active
dataToBeWritten.Add(new iPerlDataWrite(MessageID.Command, 0x0000, new byte[] { (byte)Command.SetActiveMode }, "Set active mode"));
break;
}
}
dataToBeWritten.Add(new iPerlDataWrite(MessageID.RadioPassthrough, 0x1804, new byte[] { (byte)1 }, "System Status"));
dataToBeWritten.Add(new iPerlDataWrite(MessageID.RadioPassthrough, 0x1898, new byte[] { (byte)3 }, "WakeUpInterval"));
dataToBeWritten.Add(new iPerlDataWrite(MessageID.RadioPassthrough, 0x18A2, new byte[] { (byte)0x4A, (byte)0x53, (byte)0x3B, (byte)0x8F,
(byte)0x70, (byte)0x31, (byte)0xC2, (byte)0x5D,
(byte)0x6F, (byte)0x2D, (byte)0xE8, (byte)0x07,
(byte)0x6E, (byte)0x0F, (byte)0x97, (byte)0xC3, }, "AES Key Crypted"),
};
(byte)0x6E, (byte)0x0F, (byte)0x97, (byte)0xC3, }, "AES Key Crypted"));
int successfyllyWrittenFlags = 0; /// Ones in this word represent communication failures, LSB represents the first step
int mask = 1;
@@ -2419,7 +2457,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr StartTestingSealedMeter(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr StartTestingSealedMeter(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -2489,7 +2527,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr EndTestingSealedMeter(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr EndTestingSealedMeter(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead.CommFailed) return CommErr.CommFailed;
@@ -2540,21 +2578,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
}
}
static CommErr GetQ2PreCorrectionsFormRest(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
static CommErr GetQ2PreCorrectionsFormRest(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (!ProcessData.IsQ2PreCorrectionCalculated)
{
ProcessData.IsQ2PreCorrectionCalculated = true;
commonWMType = ihead.WMType_ID;
bool success = iPerlCommunicationSeq.GetQ2PreCorrectionsOrBackups(cfg, commonWMType,
bool success = iPerlCommunicationSeq.GetQ2PreCorrectionsOrBackups(cfg, wm.WMTypeId(),
out ProcessData.CalculatedQ2PreCorrectionLR,
out ProcessData.CalculatedQ2PreCorrectionRL);
}
else if (ihead.WMType_ID != commonWMType)
{
resultStr = string.Format("Different WZ_Typ: {0} ({1} expected)", ihead.WMType_ID, commonWMType);
return CommErr.WrongIPerlType;
}
resultStr = string.Format("Q2 pre-corrections: LR={0} RL={1}", ProcessData.CalculatedQ2PreCorrectionLR, ProcessData.CalculatedQ2PreCorrectionRL);
return CommErr.None;
@@ -2573,6 +2605,27 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
return CommErr.None;
}
static CommErr Simulate(IperlHead ihead, WaterMeter wm, ref string resultStr)
{
string[] arguments = multiTestParams[currentActivityStep].Activity.Split(new char[] { ' ' });
if (arguments.Length < 2 || arguments[1].ToLower() != "iperls") return CommErr.None;
if (ihead.CommFailed) return CommErr.CommFailed;
string[] pcbNrs = new string[] { "831232435539", "831232435562",
"831232435587", "831232432141",
"831232432497", "831232763641" };
if (wm.WMPosition > 0 && wm.WMPosition <= pcbNrs.Length)
{
ihead.SerialNr = wm.SerialNr = pcbNrs[wm.WMPosition - 1];
}
resultStr = string.Format("PCB Nr. = {0}", wm.SerialNr ?? "<null>");
return CommErr.None;
}
#endif /// IPERL
#endregion
@@ -2740,9 +2793,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
if (meterRslt != null && iperlHeads[i] != null)
{
#if ORACLE_DB
meterRslt.WaterMeter.WaterMeterData.WMTypeId = iperlHeads[i].WMType_ID;
#endif
meterRslt.WaterMeter.SerialNr = iperlHeads[i].SerialNr;
meterRslt.Passed = (!iperlHeads[i].CommFailed && !iperlHeads[i].Disabled);
meterRslt.TestDone = true;
@@ -2754,6 +2804,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
UiBridge.Bridge.OnTestCompleted(this, new UiBridge.TestCompletedEventArgs(string.Empty, null));
}
#if IPERL
private MenuItem NewMenuItem(string text, string tag)
{
MenuItem menuItem = new MenuItem { Text = text, Tag = tag };
@@ -2803,6 +2854,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
Application.DoEvents(); // Refresh UI
}
}
#endif /// IPERL
#region Check boxes edit mode support
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -11,6 +11,9 @@ using RestClient;
using TBF.Rig.Sequences;
using TBF.Resources;
using TBF.UiBridge;
using Results;
using Results.Entities;
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
namespace TBF.Rig.TestMethods.iPerlCommunication
{
@@ -22,9 +25,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
public const string StrictQ2ErrorCheckStr = "Strict Q2 error check ";
public const string Q2correctionCheckCmd = "Q2 correction check ";
public const string IperlCheckCmd = "iPERL_check ";
public const string SimulateCmd = "simulate ";
System.Windows.Forms.Form modelessDlg;
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethod method, Test test, iPerlCommunicationParams testParams);
///
@@ -71,17 +75,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// Get 'wmType' from IperlHead procedure parameters
int wmType = 0;
if (IperlHeads != null)
#if IPERL
foreach (var wm in ProcessData.BatchRslts.Batch.WaterMeters)
{
foreach (var ih in IperlHeads)
if (wm != null && !wm.Disabled && wm.WMTypeId() > 0)
{
if (ih.WMType_ID > 0)
{
wmType = ih.WMType_ID;
break;
}
wmType = wm.WMTypeId();
break;
}
}
#endif
if (cfg.UseWebService)
{
@@ -288,7 +291,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = "simulate "))
else if (testParams.Activity.ToLower().Contains(cmd = SimulateCmd))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
@@ -301,6 +304,46 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound nok") MakeSimulatedCompound(test, 1, 0, 4.7f, 0.9f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound rise") MakeSimulatedCompound(test, 1, 0, 0.7f, 0.0f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound fall") MakeSimulatedCompound(test, 1, 0, 0.7f, 0.9f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "iperls")
{
string[] pcbNrs = new string[] { "831232435539", "831232435562", "831232435587",
"831232432141", "831232432497", "831232763641" };
TestRslt tstRslt = BatchRslts.GetTestRslt(test.Name, test.Part);
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
/// Auxiliary results ... not required
/// Main results
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.TestDone = true;
tstRslt.StartTime = tstRslt.Batch.StartTime;
tstRslt.EndTime = DateTime.Now;
tstRslt.FlowSetTime = 0;
tstRslt.MassOfEvapWater = 0;
tstRslt.TestTime = 1;
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
{
MeterTestRslt meterRslt =
BatchRslts.GetMeterTestRslt(test.Name, i, CompoundMeterId.Single);
if (meterRslt != null)
{
meterRslt.WaterMeter.SerialNr = pcbNrs[i % pcbNrs.Length];
meterRslt.Passed = true;
meterRslt.TestDone = true;
}
//if (iperlHeads[i] != null)
//{
// iperlHeads[i].CommFailed = iperlHeads[i].Disabled = false;
// iperlHeads[i].SerialNr = pcbNrs[i % pcbNrs.Length];
//}
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(Common.Utils.GetTestName(test.Name, 1, 1), 0)));
@@ -311,8 +354,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
//------------------------------------------------
State.Create(string.Format("iPerlCommunicationSeq : {0}", testParams.Activity))
.AddOperation(checkUiOp)
.EnterState();
.AddOperation(checkUiOp)
.EnterState();
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e))
@@ -383,7 +426,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
try
{
GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfg.BaseUrl);
client.GetToken("ReadUser", "sensus", "https://sluprimadev/SensusCore/api/v1/Locations/1/Login2").Wait();
client.GetToken("ReadUser", "sensus", "https://deluh1web03.world.fluidtechnology.net/SensusCore/api/v1/Locations/1/Login2").Wait();
Q2PreCorrection response = client.GetQ2Correction(string.Format(cfg.RelativeUrl, wmType)).Result;
if (response != null && response.AreDataCalculated)
{
@@ -574,15 +617,18 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt oriMeterRslt = ProcessData.BatchRslts.GetMeterTestRslt(oriTestName, i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
var q3mtr = ProcessData.BatchRslts.GetMeterTestRslt("Q3", i);
double q3error = (q3mtr != null) ? q3mtr.Error : 0;
Results.Entities.MeterTestRslt oriMeterRslt = ProcessData.BatchRslts.GetMeterTestRslt(oriTestName, i);
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i);
/// Reference to iPerl water meter or null:
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath != null) && (sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (meterRslt != null && oriMeterRslt != null)
if (iPerl != null && meterRslt != null && oriMeterRslt != null)
{
#if ORACLE_DB
meterRslt.ErrorBC = oriMeterRslt.Error;
@@ -593,22 +639,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
meterRslt.VolumeRef = oriMeterRslt.VolumeRef;
meterRslt.TestTime = oriMeterRslt.TestTime;
if (iPerl == null || ((iPerl.Q2CorrRL == 0) && (iPerl.Q2CorrLR == 0)))
{
/// Either no iPerl head or no Q2 correction
meterRslt.Error = oriMeterRslt.Error;
}
else if (isPlus)
if (q3error * oriMeterRslt.Error < 0)
{
/// iPerl with Q2 correction => generate an artificial error equal to +1/10 of the original one (relative to Q2 target error)
double targetError = iPerl.CalibTargetQ2;
meterRslt.Error = targetError + 0.1 * (oriMeterRslt.Error - targetError);
meterRslt.Error = 0.1 * oriMeterRslt.Error;
}
else
{
/// iPerl with Q2 correction => generate an artificial error equal to -1/10 of the original one (relative to Q2 target error)
double targetError = iPerl.CalibTargetQ2;
meterRslt.Error = targetError - 0.1 * (oriMeterRslt.Error - targetError);
meterRslt.Error = - 0.1 * oriMeterRslt.Error;
}
meterRslt.VolumeMeter = meterRslt.VolumeRef * (100.0 + meterRslt.Error) / 100.0;
@@ -897,14 +936,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
meterRslt.TestDone = meterRsltQ2ac.TestDone;
tstRslt.TestDone = true;
double targetError = 0;
if ((sensPath != null) && (sensPath.RegisterReaders != null) && (sensPath.RegisterReaders.Length > i) && (sensPath.RegisterReaders[i] is iPerlHead.IperlHead))
{
targetError = (sensPath.RegisterReaders[i] as iPerlHead.IperlHead).CalibTargetQ2;
}
if ((((meterRsltQ2bc.Error - targetError) < -0.51) && (meterRsltQ2ac.Error < meterRsltQ2bc.Error)) ||
(((meterRsltQ2bc.Error - targetError) > +0.51) && (meterRsltQ2ac.Error > meterRsltQ2bc.Error)))
if (((meterRsltQ2bc.Error < -0.51) && (meterRsltQ2ac.Error < meterRsltQ2bc.Error)) ||
((meterRsltQ2bc.Error > +0.51) && (meterRsltQ2ac.Error > meterRsltQ2bc.Error)))
{
meterRslt.Passed = false; /// Q2 correction check failed
}
@@ -58,11 +58,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public double LtrsPerPulse { get { return 1 / PulsesPerLtr; } }
public double CalibTarget { get { return iperlHeadCfg.ProcParams.CalibTarget; } }
public double CalibTargetQ2 { get { return iperlHeadCfg.ProcParams.CalibTargetQ2; } }
public ushort FactorLimitLo { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitHi; } }
public Counting InitFlowDir { get { return (iperlHeadCfg != null && iperlHeadCfg.ProcParams != null) ? iperlHeadCfg.ProcParams.Counting : Counting.Arbitrary; } }
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
/// Properties set by the Begin and the End form
@@ -70,10 +68,17 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
{
get
{
if (ConfigStruct != null) return ConfigStruct.GetPcbNrString();
else return string.Empty;
if (ConfigStruct != null)
return ConfigStruct.GetPcbNrString();
else if (simulatedPcbNr != null)
return simulatedPcbNr;
else
return string.Empty;
}
set
{
simulatedPcbNr = value;
}
set { }
}
public bool Disabled;
@@ -154,6 +159,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public double WMVolume { get { return wmVolume; } }
public double WMTestTime { get { return wmTestTime; } }
string simulatedPcbNr = null;
int wmPulses;
int wmRefPulses;
double beginWMState;
@@ -215,11 +222,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
/// <param name="nominalFlow">Nominal flow in m3/h</param>
/// <param name="currentFactor">0 or the current Q2 correction factor when updating the factor</param>
/// <returns>Calculated Q2 correction factor</returns>
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt q2adjResult, double calibTarget, double nominalFlow, int currentFactor = 0)
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt currentQ2Result, int currentFactor, double nominalFlow, double errorTarget = 0)
{
double nominalTestFlowLph = Common.Units.ConvertTo(Common.Unit.lph, nominalFlow);
double volumeRefShiftedToTarget = q2adjResult.VolumeRef * (1.0 + calibTarget / 100.0);
double q2adjErrorShiftedToTarget = Config.Formulas.ErrorFromVolumes(q2adjResult.VolumeMeter, volumeRefShiftedToTarget);
double nominalTestFlowLph = Units.ConvertTo(Unit.lph, nominalFlow);
double volumeRefShiftedToTarget = currentQ2Result.VolumeRef * (1.0 + errorTarget / 100.0);
double q2adjErrorShiftedToTarget = Config.Formulas.ErrorFromVolumes(currentQ2Result.VolumeMeter, volumeRefShiftedToTarget);
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
const double B = 8.0; /// Raw units per minute, 8
@@ -228,14 +235,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
double F = D / (nominalTestFlowLph * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
double q2CorrectionFactor = Convert.ToDouble(currentFactor)
- (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / q2adjResult.VolumeMeter);
/// Do not change the factor for an invalid measurement (q2adjResult.VolumeMeter == 0)
double q2CorrectionFactor = (Math.Abs(currentQ2Result.VolumeMeter) <= float.Epsilon) ? Convert.ToDouble(currentFactor) :
Convert.ToDouble(currentFactor) - (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / currentQ2Result.VolumeMeter);
log.WarnFormat("CalculateQ2CorrectionFactor() : Pos={0}, PCB#={1}, Error={2}%, CalTarget={3}%, Q2CorrFactor={4}",
log.WarnFormat("CalculateQ2CorrectionFactor() : Pos={0}, PCB#={1}, Error={2}%, Target={3}%, Current factor={4} New factor={5}",
Name,
SerialNr,
q2adjResult.Error.ToString("F2"),
calibTarget.ToString("F1"),
currentQ2Result.Error.ToString("F2"),
errorTarget.ToString("F3"),
currentFactor.ToString("F1"),
q2CorrectionFactor.ToString("F1"));
return q2CorrectionFactor;
@@ -462,6 +471,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
Q2CorrRL = 0;
Q2CorrLR = 0;
simulatedPcbNr = null;
dataStreamState = DataStreamState.Flush;
currentFlowDir = InitFlowDir;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.IO;
@@ -18,33 +18,27 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public MeterType MeterType;
public float CalibTarget; /// Target error after calibration in [%]
public float CalibTargetQ2; /// Target error at Q2 after Q2 correction in [%]
public int FactorLimitLo; /// Lower limit for the calibration factor
public int FactorLimitHi; /// Upper limit for the calibration factor
public Counting Counting; /// Initial iPerl counting (Artbitrary, Positive or Negative)
public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
public override void InitializeAll()
{
MeterType = MeterType.AutoDetect;
CalibTarget = 0;
CalibTargetQ2 = 0;
FactorLimitLo = 1000;
FactorLimitHi = 8000;
Counting = Counting.Arbitrary;
WMType_ID = 2; /// Value for iPerl DN15
}
string[] paramNames = new string[]
{
"iPerl type",
"Calib. target [%]",
"Calib. target at Q2 [%]",
"Calib. factor Lo",
"Calib. factor Hi",
"Counting",
"WM type ID",
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
@@ -72,11 +66,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
{
case 0: return MeterType.ToString();
case 1: return CalibTarget.ToString();
case 2: return CalibTargetQ2.ToString();
case 3: return FactorLimitLo.ToString();
case 4: return FactorLimitHi.ToString();
case 5: return Counting.ToString();
case 6: return WMType_ID.ToString();
case 2: return FactorLimitLo.ToString();
case 3: return FactorLimitHi.ToString();
case 4: return Counting.ToString();
default: return string.Empty;
}
}
@@ -92,16 +84,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
}
break;
case 1: CalibTarget = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 2: CalibTargetQ2 = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 3: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None;
case 4: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None;
case 5:
case 2: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None;
case 3: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None;
case 4:
for (Counting c = 0; c < Counting.Count; c++)
{
if (c.ToString().Equals(strValue)) { Counting = c; return CfgUpdateFlags.None; }
}
break;
case 6: WMType_ID = int.Parse(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
@@ -121,18 +111,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
break;
case 1:
case 2:
if (Utils.TryParseSFloat(strValue, out fDummy) && fDummy >= -10.0f && fDummy <= 10.0f) return true;
break;
case 2:
case 3:
case 4:
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true;
break;
case 5:
case 4:
for (Counting c = 0; c < Counting.Count; c++) if (c.ToString().Equals(strValue)) return true;
break;
case 6: /// WMType_ID
if (int.TryParse(strValue, out iDummy)) return true;
break;
default:
message = "Invalid index";
@@ -147,11 +133,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
{
prms.MeterType = this.MeterType;
prms.CalibTarget = this.CalibTarget;
prms.CalibTargetQ2 = this.CalibTargetQ2;
prms.FactorLimitLo = this.FactorLimitLo;
prms.FactorLimitHi = this.FactorLimitHi;
prms.Counting = this.Counting;
prms.WMType_ID = this.WMType_ID;
}
public IParamsProvider Clone()
+10 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2017-2021 Sensus Slovensko a.s.
/// Copyright (c) 2017-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -192,8 +192,17 @@ namespace TBF.Rig.Various.ErrorFlags
{
/// No error indicator;
}
#if IPERL
else if ((mtrQ3.Error > 0 && mtrQ2.Error > 0 && mtrQ1.Error > 0 && (mtrQ3.Error > 1 ||
mtrQ2.Error > mtrQ2.ErrLimHi() / 2 ||
mtrQ1.Error > mtrQ1.ErrLimHi() / 2))
|| (mtrQ3.Error < 0 && mtrQ2.Error < 0 && mtrQ1.Error < 0 && (mtrQ3.Error < -1 ||
mtrQ2.Error < mtrQ2.ErrLimLo() / 2 ||
mtrQ1.Error < mtrQ1.ErrLimLo() / 2)))
#else
else if (((mtrQ3.Error > mtrQ3.ErrLimHi() / 2) && (mtrQ2.Error > mtrQ2.ErrLimHi() / 2) && (mtrQ1.Error > mtrQ1.ErrLimHi() / 2)) ||
((mtrQ3.Error < mtrQ3.ErrLimLo() / 2) && (mtrQ2.Error < mtrQ2.ErrLimLo() / 2) && (mtrQ1.Error < mtrQ1.ErrLimLo() / 2)))
#endif
{
if (errorsCfg.TestParams.E15 == (sbyte)ErrorFlagsMode.Info)
{
+42 -5
View File
@@ -117,6 +117,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualBasic">
<Private>True</Private>
</Reference>
@@ -144,6 +145,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Security" />
@@ -186,6 +188,7 @@
<Compile Include="Rig\Configs\ParamsProvider\ComponentCfgCtrl.designer.cs">
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\DataChangeArgs.cs" />
<Compile Include="Rig\DataContainers\BackupAndSecurityOptions\Component.cs" />
<Compile Include="Rig\DataContainers\BackupAndSecurityOptions\ComponentCfg.cs" />
<Compile Include="Rig\DataContainers\BackupAndSecurityOptions\ComponentFactory.cs" />
@@ -241,6 +244,7 @@
<Compile Include="Rig\DataEntry\DataStream\TestStartEndForm.designer.cs">
<DependentUpon>TestStartEndForm.cs</DependentUpon>
</Compile>
<Compile Include="Rig\DataEntry\DEItem.cs" />
<Compile Include="Rig\DataEntry\Double24\CycleBeginningForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -556,6 +560,23 @@
<DependentUpon>TestStartEndForm.cs</DependentUpon>
</Compile>
<Compile Include="Rig\DataEntry\DEUtils.cs" />
<Compile Include="Rig\DataEntry\Uni\CycleBgEnForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Rig\DataEntry\Uni\CycleBgEnForm.designer.cs">
<DependentUpon>CycleBgEnForm.cs</DependentUpon>
</Compile>
<Compile Include="Rig\DataEntry\Uni\EntryForm.cs" />
<Compile Include="Rig\DataEntry\Uni\EntryFormCfg.cs" />
<Compile Include="Rig\DataEntry\Uni\EntryFormNoStartEnd.cs" />
<Compile Include="Rig\DataEntry\Uni\Factory.cs" />
<Compile Include="Rig\DataEntry\Uni\FactoryNoStartEnd.cs" />
<Compile Include="Rig\DataEntry\Uni\TestStartEndForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Rig\DataEntry\Uni\TestStartEndForm.designer.cs">
<DependentUpon>TestStartEndForm.cs</DependentUpon>
</Compile>
<Compile Include="Rig\DataEntry\WMStates\EntryForm.cs" />
<Compile Include="Rig\DataEntry\WMStates\EntryFormCfg.cs" />
<Compile Include="Rig\DataEntry\WMStates\EntryFormCfgCtrl.cs">
@@ -1169,6 +1190,7 @@
<Compile Include="Rig\Output\Printers\OnePerMeter\PrinterCfgCtrl.designer.cs">
<DependentUpon>PrinterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\Output\Printers\PrinterStatus.cs" />
<Compile Include="Rig\Output\Printers\Zapiska\FactoryCompound.cs" />
<Compile Include="Rig\Output\Printers\Zapiska\FactoryHeatMeters.cs" />
<Compile Include="Rig\Output\Printers\Zapiska\FactorySingle.cs" />
@@ -2200,6 +2222,12 @@
<Compile Include="UI\Bench\Components\SelectComponentClassDlg.designer.cs">
<DependentUpon>SelectComponentClassDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\CalibCertificateCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Bench\Metrology\CalibCertificateCtrl.Designer.cs">
<DependentUpon>CalibCertificateCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\IMetrologyDlgTab.cs" />
<Compile Include="UI\Bench\Metrology\MetrologyDlg.cs">
<SubType>Form</SubType>
@@ -2207,11 +2235,11 @@
<Compile Include="UI\Bench\Metrology\MetrologyDlg.designer.cs">
<DependentUpon>MetrologyDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgBalanceTab.cs">
<Compile Include="UI\Bench\Metrology\MetrologyDlgScaleTab.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgBalanceTab.designer.cs">
<DependentUpon>MetrologyDlgBalanceTab.cs</DependentUpon>
<Compile Include="UI\Bench\Metrology\MetrologyDlgScaleTab.designer.cs">
<DependentUpon>MetrologyDlgScaleTab.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgBuoyancyTab.cs">
<SubType>UserControl</SubType>
@@ -2980,6 +3008,12 @@
<EmbeddedResource Include="Rig\DataEntry\StandardCamera\TestStartEndForm.resx">
<DependentUpon>TestStartEndForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\DataEntry\Uni\CycleBgEnForm.resx">
<DependentUpon>CycleBgEnForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\DataEntry\Uni\TestStartEndForm.resx">
<DependentUpon>TestStartEndForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\DataEntry\WMStates\EntryFormCfgCtrl.resx">
<DependentUpon>EntryFormCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
@@ -3406,11 +3440,14 @@
<EmbeddedResource Include="UI\Bench\Components\SelectComponentClassDlg.resx">
<DependentUpon>SelectComponentClassDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\CalibCertificateCtrl.resx">
<DependentUpon>CalibCertificateCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlg.resx">
<DependentUpon>MetrologyDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgBalanceTab.resx">
<DependentUpon>MetrologyDlgBalanceTab.cs</DependentUpon>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgScaleTab.resx">
<DependentUpon>MetrologyDlgScaleTab.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgBuoyancyTab.resx">
<DependentUpon>MetrologyDlgBuoyancyTab.cs</DependentUpon>
+162
View File
@@ -0,0 +1,162 @@
namespace TBF.UI.Bench.Metrology
{
partial class CalibCertificateCtrl
{
/// <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.groupBox = new System.Windows.Forms.GroupBox();
this.openCertificateButton = new System.Windows.Forms.Button();
this.showCertificateButton = new System.Windows.Forms.Button();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.certIdLabel = new System.Windows.Forms.Label();
this.groupBox.SuspendLayout();
this.SuspendLayout();
//
// groupBox
//
this.groupBox.Controls.Add(this.certIdLabel);
this.groupBox.Controls.Add(this.openCertificateButton);
this.groupBox.Controls.Add(this.showCertificateButton);
this.groupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.groupBox.Controls.Add(this.calibDateTimePicker);
this.groupBox.Controls.Add(this.calibValidDateLabel);
this.groupBox.Controls.Add(this.calibDateLabel);
this.groupBox.Controls.Add(this.calibCertificateNrTextBox);
this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox.Location = new System.Drawing.Point(0, 0);
this.groupBox.Name = "groupBox";
this.groupBox.Size = new System.Drawing.Size(240, 100);
this.groupBox.TabIndex = 0;
this.groupBox.TabStop = false;
this.groupBox.Text = "Calibration certificate";
//
// openCertificateButton
//
this.openCertificateButton.Enabled = false;
this.openCertificateButton.Location = new System.Drawing.Point(177, 22);
this.openCertificateButton.Name = "openCertificateButton";
this.openCertificateButton.Size = new System.Drawing.Size(56, 26);
this.openCertificateButton.TabIndex = 28;
this.openCertificateButton.Text = "Path";
this.openCertificateButton.UseVisualStyleBackColor = true;
this.openCertificateButton.Click += new System.EventHandler(this.openCertificateButton_Click);
//
// showCertificateButton
//
this.showCertificateButton.Location = new System.Drawing.Point(177, 48);
this.showCertificateButton.Name = "showCertificateButton";
this.showCertificateButton.Size = new System.Drawing.Size(56, 39);
this.showCertificateButton.TabIndex = 27;
this.showCertificateButton.Text = "Show";
this.showCertificateButton.UseVisualStyleBackColor = true;
this.showCertificateButton.Click += new System.EventHandler(this.showCertificateButton_Click);
//
// calibExpirationDateTimePicker
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(74, 67);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(97, 20);
this.calibExpirationDateTimePicker.TabIndex = 26;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(74, 45);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(97, 20);
this.calibDateTimePicker.TabIndex = 25;
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(9, 70);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 24;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(9, 48);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 23;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(74, 23);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(97, 20);
this.calibCertificateNrTextBox.TabIndex = 22;
//
// certIdLabel
//
this.certIdLabel.AutoSize = true;
this.certIdLabel.Location = new System.Drawing.Point(9, 26);
this.certIdLabel.Name = "certIdLabel";
this.certIdLabel.Size = new System.Drawing.Size(18, 13);
this.certIdLabel.TabIndex = 29;
this.certIdLabel.Text = "ID";
//
// CalibCertificateCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox);
this.Name = "CalibCertificateCtrl";
this.Size = new System.Drawing.Size(240, 100);
this.groupBox.ResumeLayout(false);
this.groupBox.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox;
private System.Windows.Forms.Button openCertificateButton;
private System.Windows.Forms.Button showCertificateButton;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label certIdLabel;
}
}
@@ -0,0 +1,140 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Windows.Forms;
using TBF.Resources;
using TBF.Rig.GenericDevices;
namespace TBF.UI.Bench.Metrology
{
public partial class CalibCertificateCtrl : UserControl
{
string certPath; /// Path to a calibration certificate PDF document
ToolTip toolTip;
public CalibCertificateCtrl()
{
InitializeComponent();
Localize();
certPath = string.Empty;
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toolTip = new ToolTip();
toolTip.UseFading = true;
toolTip.UseAnimation = true;
toolTip.IsBalloon = true;
toolTip.ShowAlways = true;
toolTip.AutoPopDelay = 1000;
toolTip.InitialDelay = 1000;
toolTip.ReshowDelay = 500;
toolTip.SetToolTip(showCertificateButton, certPath);
}
void Localize()
{
groupBox.Text = Strings.Calibration_certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
showCertificateButton.Text = Strings.Show;
}
public void Unlock()
{
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
openCertificateButton.Enabled = true;
showCertificateButton.Enabled = true;
}
public void Refresh(ICalibInfoCfg calibInfoCfg)
{
calibCertificateNrTextBox.Text = calibInfoCfg.CalibCertificateNr;
certPath = calibInfoCfg.CertPath;
calibDateTimePicker.Value = (calibInfoCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : calibInfoCfg.CalibDate;
calibExpirationDateTimePicker.Value = (calibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : calibInfoCfg.CalibValidDate;
toolTip.SetToolTip(showCertificateButton, certPath);
}
public void Update(ICalibInfoCfg calibInfoCfg)
{
calibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
calibInfoCfg.CertPath = certPath;
calibInfoCfg.CalibDate = calibDateTimePicker.Value;
calibInfoCfg.CalibValidDate = calibExpirationDateTimePicker.Value;
}
public void Refresh(ICalibRangesCfg calibRangesCfg, int rngIx)
{
calibCertificateNrTextBox.Text = calibRangesCfg.GetCalibCertificate(rngIx);
certPath = calibRangesCfg.GetCertPath(rngIx);
calibDateTimePicker.Value = (calibRangesCfg.GetCalibDate(rngIx) < Constants.MinDate) ? Constants.MinDate : calibRangesCfg.GetCalibDate(rngIx);
calibExpirationDateTimePicker.Value = (calibRangesCfg.GetCalibValidDate(rngIx) < Constants.MinDate) ? Constants.MinDate : calibRangesCfg.GetCalibValidDate(rngIx);
toolTip.SetToolTip(showCertificateButton, certPath);
}
public void Update(ICalibRangesCfg calibRangesCfg, int rngIx)
{
calibRangesCfg.SetCalibCertificate(rngIx, calibCertificateNrTextBox.Text);
calibRangesCfg.SetCertPath(rngIx, certPath);
calibRangesCfg.SetCalibDate(rngIx, calibDateTimePicker.Value);
calibRangesCfg.SetCalibValidDate(rngIx, calibExpirationDateTimePicker.Value);
}
private void openCertificateButton_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog()
{
CheckFileExists = true,
InitialDirectory = @"C:\TBF\Certificates",
Filter = string.Format("{0} (*.pdf)|*.pdf|{1} (*.*)|*.*", Strings.PDF_files, Strings.All_files),
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
certPath = openFileDialog.FileName;
toolTip.SetToolTip(showCertificateButton, certPath);
}
}
private void showCertificateButton_Click(object sender, EventArgs e)
{
var apps = new string[] { @"C:\Program Files\Microsoft\Edge\Application\msedge.exe",
@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
@"C:\Program Files\Mozilla Firefox\firefox.exe",
@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe",
@"C:\Program Files\Google\Chrome\Application\chrome.exe",
@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" };
if (!string.IsNullOrEmpty(certPath) && File.Exists(certPath))
{
foreach (var app in apps)
{
if (File.Exists(app))
{
using (var process = new System.Diagnostics.Process())
{
process.StartInfo.FileName = app;
process.StartInfo.Arguments = certPath.Replace(" ", "%20"); ///argument
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
}
break;
}
}
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+1 -1
View File
@@ -105,7 +105,7 @@ namespace TBF.UI.Bench.Metrology
{
balancesCount++;
TabPage tabPage = new TabPage(" " + cmpnt.Name + " ");
MetrologyDlgBalanceTab uiControl = new MetrologyDlgBalanceTab();
MetrologyDlgScaleTab uiControl = new MetrologyDlgScaleTab();
uiControl.MeterEntity = cmpnt;
uiControl.BalanceCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as Rig.GenericDevices.IScaleCfg;
uiControl.Dock = DockStyle.Fill;
+1 -1
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
using System;
using System.Collections.Generic;
+17 -95
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -32,23 +32,16 @@ namespace TBF.UI.Bench.Metrology
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.densityCorrTextBox = new System.Windows.Forms.TextBox();
this.densityCorrLabel = new System.Windows.Forms.Label();
this.temperatureTextBox = new System.Windows.Forms.TextBox();
this.temperatureLabel = new System.Windows.Forms.Label();
this.densityTextBox = new System.Windows.Forms.TextBox();
this.densityLabel = new System.Windows.Forms.Label();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
@@ -61,7 +54,7 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.densityCorrTextBox);
this.splitContainer1.Panel1.Controls.Add(this.densityCorrLabel);
this.splitContainer1.Panel1.Controls.Add(this.temperatureTextBox);
@@ -69,63 +62,13 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel1.Controls.Add(this.densityTextBox);
this.splitContainer1.Panel1.Controls.Add(this.densityLabel);
this.splitContainer1.Size = new System.Drawing.Size(554, 300);
this.splitContainer1.SplitterDistance = 110;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 1;
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(323, 16);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(208, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(120, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(54, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate";
//
// densityCorrTextBox
//
this.densityCorrTextBox.Enabled = false;
this.densityCorrTextBox.Location = new System.Drawing.Point(185, 81);
this.densityCorrTextBox.Location = new System.Drawing.Point(178, 81);
this.densityCorrTextBox.Name = "densityCorrTextBox";
this.densityCorrTextBox.Size = new System.Drawing.Size(110, 20);
this.densityCorrTextBox.TabIndex = 5;
@@ -133,7 +76,7 @@ namespace TBF.UI.Bench.Metrology
// densityCorrLabel
//
this.densityCorrLabel.AutoSize = true;
this.densityCorrLabel.Location = new System.Drawing.Point(37, 84);
this.densityCorrLabel.Location = new System.Drawing.Point(30, 84);
this.densityCorrLabel.Name = "densityCorrLabel";
this.densityCorrLabel.Size = new System.Drawing.Size(132, 13);
this.densityCorrLabel.TabIndex = 4;
@@ -142,7 +85,7 @@ namespace TBF.UI.Bench.Metrology
// temperatureTextBox
//
this.temperatureTextBox.Enabled = false;
this.temperatureTextBox.Location = new System.Drawing.Point(185, 43);
this.temperatureTextBox.Location = new System.Drawing.Point(178, 43);
this.temperatureTextBox.Name = "temperatureTextBox";
this.temperatureTextBox.Size = new System.Drawing.Size(110, 20);
this.temperatureTextBox.TabIndex = 3;
@@ -151,7 +94,7 @@ namespace TBF.UI.Bench.Metrology
// temperatureLabel
//
this.temperatureLabel.AutoSize = true;
this.temperatureLabel.Location = new System.Drawing.Point(37, 46);
this.temperatureLabel.Location = new System.Drawing.Point(30, 46);
this.temperatureLabel.Name = "temperatureLabel";
this.temperatureLabel.Size = new System.Drawing.Size(112, 13);
this.temperatureLabel.TabIndex = 2;
@@ -160,7 +103,7 @@ namespace TBF.UI.Bench.Metrology
// densityTextBox
//
this.densityTextBox.Enabled = false;
this.densityTextBox.Location = new System.Drawing.Point(185, 17);
this.densityTextBox.Location = new System.Drawing.Point(178, 17);
this.densityTextBox.Name = "densityTextBox";
this.densityTextBox.Size = new System.Drawing.Size(110, 20);
this.densityTextBox.TabIndex = 1;
@@ -169,31 +112,18 @@ namespace TBF.UI.Bench.Metrology
// densityLabel
//
this.densityLabel.AutoSize = true;
this.densityLabel.Location = new System.Drawing.Point(37, 20);
this.densityLabel.Location = new System.Drawing.Point(30, 20);
this.densityLabel.Name = "densityLabel";
this.densityLabel.Size = new System.Drawing.Size(82, 13);
this.densityLabel.TabIndex = 0;
this.densityLabel.Text = "Density [kg/m3]";
//
// calibExpirationDateTimePicker
// calibCertificateCtrl
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(120, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(120, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
this.calibCertificateCtrl.Location = new System.Drawing.Point(307, 7);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 6;
//
// MetrologyDlgDensityTab
//
@@ -207,8 +137,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.ResumeLayout(false);
}
@@ -222,12 +150,6 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label densityLabel;
private System.Windows.Forms.TextBox densityCorrTextBox;
private System.Windows.Forms.Label densityCorrLabel;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,11 +1,12 @@
///
/// Copyright (c) 2013-2019 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common;
using Config;
using Config.Entities;
using TBF.Resources;
@@ -32,16 +33,11 @@ namespace TBF.UI.Bench.Metrology
public IList<MeasurementCorrection> ToBeRemoved { get; set; }
MetrologyDlg parent;
bool unlocked;
bool valuesModified;
bool valuesModified;
public MetrologyDlgDensityTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
ToBeRemoved = new List<MeasurementCorrection>();
valuesModified = false;
}
@@ -55,9 +51,9 @@ namespace TBF.UI.Bench.Metrology
Localize();
/// Panel1
densityLabel.Text = string.Format("{0} [{1}]", Strings.Density, Common.Unit.kgpm3.ToDescription());
temperatureLabel.Text = string.Format("{0} [{1}]", Strings.At_temperature, Common.Unit.C.ToDescription());
densityCorrLabel.Text = string.Format("{0} [{1}]", Strings.Density_correction, Common.Unit.kgpm3.ToDescription());
densityLabel.Text = string.Format("{0} [{1}]", Strings.Density, Unit.kgpm3.ToDescription());
temperatureLabel.Text = string.Format("{0} [{1}]", Strings.At_temperature, Unit.C.ToDescription());
densityCorrLabel.Text = string.Format("{0} [{1}]", Strings.Density_correction, Unit.kgpm3.ToDescription());
/// Panel2
@@ -66,22 +62,16 @@ namespace TBF.UI.Bench.Metrology
void Localize()
{
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
}
void RefreshAll()
void RefreshAll()
{
if (DensityCfg != null)
{
densityTextBox.Text = DensityCfg.RealDensity.ToString();
temperatureTextBox.Text = DensityCfg.AtTemperature.ToString();
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(DensityCfg.RealDensity, DensityCfg.AtTemperature).ToString("F5");
calibCertificateNrTextBox.Text = DensityCfg.CalibCertificateNr;
calibDateTimePicker.Value = (DensityCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : DensityCfg.CalibDate;
calibExpirationDateTimePicker.Value = (DensityCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : DensityCfg.CalibValidDate;
densityCorrTextBox.Text = Formulas.DensityCorrection(DensityCfg.RealDensity, DensityCfg.AtTemperature).ToString("F5");
calibCertificateCtrl.Refresh(DensityCfg);
}
}
@@ -89,9 +79,7 @@ namespace TBF.UI.Bench.Metrology
{
densityTextBox.Enabled = true;
temperatureTextBox.Enabled = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
}
public void OkBtnClicked()
@@ -106,9 +94,7 @@ namespace TBF.UI.Bench.Metrology
Config.Data.AtTemperature = DensityCfg.AtTemperature = Utils.ParseUDouble(temperatureTextBox.Text);
}
DensityCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
DensityCfg.CalibDate = calibDateTimePicker.Value.Date;
DensityCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(DensityCfg);
Component modified = DensityCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
@@ -157,7 +143,7 @@ namespace TBF.UI.Bench.Metrology
if (Utils.TryParseUDouble(densityTextBox.Text, out density) &&
Utils.TryParseUDouble(temperatureTextBox.Text, out temp))
{
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(density, temp).ToString();
densityCorrTextBox.Text = Formulas.DensityCorrection(density, temp).ToString();
}
}
+20 -98
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -32,11 +32,6 @@ namespace TBF.UI.Bench.Metrology
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.nameGroupBox = new System.Windows.Forms.GroupBox();
this.pressFromToLabel = new System.Windows.Forms.Label();
this.tempFromToLabel = new System.Windows.Forms.Label();
@@ -47,13 +42,11 @@ namespace TBF.UI.Bench.Metrology
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.nameGroupBox.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.SuspendLayout();
@@ -68,7 +61,7 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
//
@@ -76,59 +69,9 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(650, 400);
this.splitContainer1.SplitterDistance = 102;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 2;
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(186, 10);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(228, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(140, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(69, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate nr.";
//
// nameGroupBox
//
this.nameGroupBox.Controls.Add(this.pressFromToLabel);
@@ -136,7 +79,7 @@ namespace TBF.UI.Bench.Metrology
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
this.nameGroupBox.Name = "nameGroupBox";
this.nameGroupBox.Size = new System.Drawing.Size(160, 86);
this.nameGroupBox.Size = new System.Drawing.Size(160, 99);
this.nameGroupBox.TabIndex = 5;
this.nameGroupBox.TabStop = false;
this.nameGroupBox.Text = "Component";
@@ -172,16 +115,16 @@ namespace TBF.UI.Bench.Metrology
this.testGroupBox.Controls.Add(this.measuredTextBox);
this.testGroupBox.Controls.Add(this.correctedLabel);
this.testGroupBox.Controls.Add(this.measuredLabel);
this.testGroupBox.Location = new System.Drawing.Point(424, 10);
this.testGroupBox.Location = new System.Drawing.Point(428, 10);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(170, 88);
this.testGroupBox.Size = new System.Drawing.Size(170, 99);
this.testGroupBox.TabIndex = 4;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Correction test";
//
// correctedTextBox
//
this.correctedTextBox.Location = new System.Drawing.Point(91, 37);
this.correctedTextBox.Location = new System.Drawing.Point(87, 54);
this.correctedTextBox.Name = "correctedTextBox";
this.correctedTextBox.ReadOnly = true;
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
@@ -189,7 +132,7 @@ namespace TBF.UI.Bench.Metrology
//
// measuredTextBox
//
this.measuredTextBox.Location = new System.Drawing.Point(91, 15);
this.measuredTextBox.Location = new System.Drawing.Point(87, 28);
this.measuredTextBox.Name = "measuredTextBox";
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
this.measuredTextBox.TabIndex = 4;
@@ -198,7 +141,7 @@ namespace TBF.UI.Bench.Metrology
// correctedLabel
//
this.correctedLabel.AutoSize = true;
this.correctedLabel.Location = new System.Drawing.Point(17, 40);
this.correctedLabel.Location = new System.Drawing.Point(13, 57);
this.correctedLabel.Name = "correctedLabel";
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
this.correctedLabel.TabIndex = 3;
@@ -207,7 +150,7 @@ namespace TBF.UI.Bench.Metrology
// measuredLabel
//
this.measuredLabel.AutoSize = true;
this.measuredLabel.Location = new System.Drawing.Point(17, 18);
this.measuredLabel.Location = new System.Drawing.Point(13, 31);
this.measuredLabel.Name = "measuredLabel";
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
this.measuredLabel.TabIndex = 2;
@@ -220,33 +163,21 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(650, 294);
this.listViewEx.Size = new System.Drawing.Size(650, 284);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
//
// calibExpirationDateTimePicker
// calibCertificateCtrl
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
this.calibCertificateCtrl.Location = new System.Drawing.Point(182, 10);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 6;
//
// MetrologyDlgDiverterTab
//
@@ -260,8 +191,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.nameGroupBox.ResumeLayout(false);
this.nameGroupBox.PerformLayout();
this.testGroupBox.ResumeLayout(false);
@@ -281,15 +210,8 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label correctedLabel;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox nameGroupBox;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.Label pressFromToLabel;
private System.Windows.Forms.Label tempFromToLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,13 +1,13 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Common.Forms;
using Config.Entities;
using TBF.Resources;
using TBF.UI.Shared;
@@ -52,10 +52,6 @@ namespace TBF.UI.Bench.Metrology
public MetrologyDlgDiverterTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
}
@@ -97,11 +93,6 @@ namespace TBF.UI.Bench.Metrology
{
nameGroupBox.Text = Strings.Component;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
testGroupBox.Text = Strings.Test_measured_corrected;
measuredLabel.Text = Strings.Measured;
correctedLabel.Text = Strings.Corrected;
@@ -111,9 +102,7 @@ namespace TBF.UI.Bench.Metrology
{
if (CalibInfoCfg != null)
{
calibCertificateNrTextBox.Text = CalibInfoCfg.CalibCertificateNr;
calibDateTimePicker.Value = (CalibInfoCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibDate;
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
calibCertificateCtrl.Refresh(CalibInfoCfg);
}
listViewEx.Items.Clear();
@@ -209,9 +198,7 @@ namespace TBF.UI.Bench.Metrology
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
if (listViewEx.SelectedItems.Count == 1)
{
@@ -228,10 +215,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
CalibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
CalibInfoCfg.CalibDate = calibDateTimePicker.Value.Date;
CalibInfoCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(CalibInfoCfg);
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}
@@ -332,7 +316,7 @@ namespace TBF.UI.Bench.Metrology
CultureInfo.InvariantCulture,
out measured))
{
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
correctedTextBox.Text = corrected.ToString();
}
}
+20 -98
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -32,11 +32,6 @@ namespace TBF.UI.Bench.Metrology
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.nameGroupBox = new System.Windows.Forms.GroupBox();
this.pressFromToLabel = new System.Windows.Forms.Label();
this.tempFromToLabel = new System.Windows.Forms.Label();
@@ -47,13 +42,11 @@ namespace TBF.UI.Bench.Metrology
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.nameGroupBox.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.SuspendLayout();
@@ -68,7 +61,7 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
//
@@ -76,59 +69,9 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(650, 400);
this.splitContainer1.SplitterDistance = 102;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 2;
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(186, 10);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(228, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(140, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(69, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate nr.";
//
// nameGroupBox
//
this.nameGroupBox.Controls.Add(this.pressFromToLabel);
@@ -136,7 +79,7 @@ namespace TBF.UI.Bench.Metrology
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
this.nameGroupBox.Name = "nameGroupBox";
this.nameGroupBox.Size = new System.Drawing.Size(160, 86);
this.nameGroupBox.Size = new System.Drawing.Size(160, 99);
this.nameGroupBox.TabIndex = 5;
this.nameGroupBox.TabStop = false;
this.nameGroupBox.Text = "Component";
@@ -172,16 +115,16 @@ namespace TBF.UI.Bench.Metrology
this.testGroupBox.Controls.Add(this.measuredTextBox);
this.testGroupBox.Controls.Add(this.correctedLabel);
this.testGroupBox.Controls.Add(this.measuredLabel);
this.testGroupBox.Location = new System.Drawing.Point(424, 10);
this.testGroupBox.Location = new System.Drawing.Point(429, 10);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(170, 88);
this.testGroupBox.Size = new System.Drawing.Size(170, 99);
this.testGroupBox.TabIndex = 4;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Correction test";
//
// correctedTextBox
//
this.correctedTextBox.Location = new System.Drawing.Point(91, 37);
this.correctedTextBox.Location = new System.Drawing.Point(91, 50);
this.correctedTextBox.Name = "correctedTextBox";
this.correctedTextBox.ReadOnly = true;
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
@@ -189,7 +132,7 @@ namespace TBF.UI.Bench.Metrology
//
// measuredTextBox
//
this.measuredTextBox.Location = new System.Drawing.Point(91, 15);
this.measuredTextBox.Location = new System.Drawing.Point(91, 25);
this.measuredTextBox.Name = "measuredTextBox";
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
this.measuredTextBox.TabIndex = 4;
@@ -198,7 +141,7 @@ namespace TBF.UI.Bench.Metrology
// correctedLabel
//
this.correctedLabel.AutoSize = true;
this.correctedLabel.Location = new System.Drawing.Point(17, 40);
this.correctedLabel.Location = new System.Drawing.Point(17, 53);
this.correctedLabel.Name = "correctedLabel";
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
this.correctedLabel.TabIndex = 3;
@@ -207,7 +150,7 @@ namespace TBF.UI.Bench.Metrology
// measuredLabel
//
this.measuredLabel.AutoSize = true;
this.measuredLabel.Location = new System.Drawing.Point(17, 18);
this.measuredLabel.Location = new System.Drawing.Point(17, 28);
this.measuredLabel.Name = "measuredLabel";
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
this.measuredLabel.TabIndex = 2;
@@ -220,33 +163,21 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(650, 294);
this.listViewEx.Size = new System.Drawing.Size(650, 284);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
//
// calibExpirationDateTimePicker
// calibCertificateCtrl
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
this.calibCertificateCtrl.Location = new System.Drawing.Point(183, 10);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 6;
//
// MetrologyDlgEvaporationTab
//
@@ -260,8 +191,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.nameGroupBox.ResumeLayout(false);
this.nameGroupBox.PerformLayout();
this.testGroupBox.ResumeLayout(false);
@@ -281,15 +210,8 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label correctedLabel;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox nameGroupBox;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.Label pressFromToLabel;
private System.Windows.Forms.Label tempFromToLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,13 +1,13 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Common.Forms;
using Config.Entities;
using TBF.Resources;
using TBF.UI.Shared;
@@ -52,10 +52,6 @@ namespace TBF.UI.Bench.Metrology
public MetrologyDlgEvaporationTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
}
@@ -97,11 +93,6 @@ namespace TBF.UI.Bench.Metrology
{
nameGroupBox.Text = Strings.Component;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
testGroupBox.Text = Strings.Test_measured_corrected;
measuredLabel.Text = Strings.Measured;
correctedLabel.Text = Strings.Corrected;
@@ -109,12 +100,7 @@ namespace TBF.UI.Bench.Metrology
void RefreshAll()
{
if (CalibInfoCfg != null)
{
calibCertificateNrTextBox.Text = CalibInfoCfg.CalibCertificateNr;
calibDateTimePicker.Value = (CalibInfoCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibDate;
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
}
if (CalibInfoCfg != null) calibCertificateCtrl.Refresh(CalibInfoCfg);
listViewEx.Items.Clear();
foreach (var corr in MeterEntity.Corrections)
@@ -209,9 +195,7 @@ namespace TBF.UI.Bench.Metrology
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
if (listViewEx.SelectedItems.Count == 1)
{
@@ -228,10 +212,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
CalibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
CalibInfoCfg.CalibDate = calibDateTimePicker.Value.Date;
CalibInfoCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(CalibInfoCfg);
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}
+17 -95
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -32,15 +32,9 @@ namespace TBF.UI.Bench.Metrology
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
this.unitLabel = new System.Windows.Forms.Label();
this.unitComboBox = new System.Windows.Forms.ComboBox();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.nameGroupBox = new System.Windows.Forms.GroupBox();
this.pressFromToLabel = new System.Windows.Forms.Label();
this.tempFromToLabel = new System.Windows.Forms.Label();
@@ -55,7 +49,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.nameGroupBox.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.SuspendLayout();
@@ -70,9 +63,9 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
//
@@ -80,9 +73,16 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(650, 400);
this.splitContainer1.SplitterDistance = 102;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 2;
//
// calibCertificateCtrl
//
this.calibCertificateCtrl.Location = new System.Drawing.Point(182, 10);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 11;
//
// unitLabel
//
this.unitLabel.AutoSize = true;
@@ -101,76 +101,6 @@ namespace TBF.UI.Bench.Metrology
this.unitComboBox.TabIndex = 9;
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(186, 10);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(228, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibExpirationDateTimePicker
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(140, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(69, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate nr.";
//
// nameGroupBox
//
this.nameGroupBox.Controls.Add(this.pressFromToLabel);
@@ -214,9 +144,9 @@ namespace TBF.UI.Bench.Metrology
this.testGroupBox.Controls.Add(this.measuredTextBox);
this.testGroupBox.Controls.Add(this.correctedLabel);
this.testGroupBox.Controls.Add(this.measuredLabel);
this.testGroupBox.Location = new System.Drawing.Point(424, 10);
this.testGroupBox.Location = new System.Drawing.Point(428, 10);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(170, 88);
this.testGroupBox.Size = new System.Drawing.Size(170, 99);
this.testGroupBox.TabIndex = 4;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Correction test";
@@ -262,9 +192,10 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(650, 294);
this.listViewEx.Size = new System.Drawing.Size(650, 284);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
@@ -283,8 +214,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.nameGroupBox.ResumeLayout(false);
this.nameGroupBox.PerformLayout();
this.testGroupBox.ResumeLayout(false);
@@ -304,17 +233,10 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label correctedLabel;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox nameGroupBox;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.Label pressFromToLabel;
private System.Windows.Forms.Label tempFromToLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
private System.Windows.Forms.Label unitLabel;
private System.Windows.Forms.ComboBox unitComboBox;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,6 +8,7 @@ using System.Windows.Forms;
using log4net;
using Common;
using Common.Forms;
using Config;
using Config.Entities;
using TBF.Resources;
using TBF.UI.Shared;
@@ -61,10 +62,6 @@ namespace TBF.UI.Bench.Metrology
public MetrologyDlgFlowMeterTab(int rangeIx1, bool isLastFlowMeterRange)
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
this.rangeIx = rangeIx1;
this.isLastFlowMeterRange = isLastFlowMeterRange;
toBeRemoved = new List<MeasurementCorrection>();
@@ -127,11 +124,6 @@ namespace TBF.UI.Bench.Metrology
void Localize()
{
nameGroupBox.Text = Strings.Component;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
testGroupBox.Text = Strings.Test_measured_corrected;
}
@@ -139,9 +131,7 @@ namespace TBF.UI.Bench.Metrology
{
if (CalibInfoCfg != null)
{
calibCertificateNrTextBox.Text = CalibInfoCfg.GetCalibCertificate(rangeIx1);
calibDateTimePicker.Value = (CalibInfoCfg.GetCalibDate(rangeIx1) < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.GetCalibDate(rangeIx1);
calibExpirationDateTimePicker.Value = (CalibInfoCfg.GetCalibValidDate(rangeIx1) < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.GetCalibValidDate(rangeIx1);
calibCertificateCtrl.Refresh(CalibInfoCfg, rangeIx1);
}
listViewEx.Items.Clear();
@@ -169,7 +159,7 @@ namespace TBF.UI.Bench.Metrology
}
else
{
double error = Config.Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
}
@@ -222,7 +212,7 @@ namespace TBF.UI.Bench.Metrology
{
correction = Units.IsDefaultUnit(currentUnit) ? difference
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
error = Config.Formulas.ErrorFromVolumes(measurement, measurement + correction);
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
}
else
@@ -244,7 +234,7 @@ namespace TBF.UI.Bench.Metrology
/// Update error (if possible)
if (measurement != 0)
{
error = Config.Formulas.ErrorFromVolumes(measurement, measurement + correction);
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
}
else
@@ -268,7 +258,7 @@ namespace TBF.UI.Bench.Metrology
{
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
{
correction = Config.Formulas.CorrectionFromError(measurement, error);
correction = Formulas.CorrectionFromError(measurement, error);
(item.Tag as MeasurementCorrection).Correction = correction;
difference = Units.IsDefaultUnit(currentUnit)
? correction
@@ -289,9 +279,7 @@ namespace TBF.UI.Bench.Metrology
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
if (listViewEx.SelectedItems.Count == 1)
{
@@ -308,9 +296,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
CalibInfoCfg.SetCalibCertificate(rangeIx, calibCertificateNrTextBox.Text);
CalibInfoCfg.SetCalibDate(rangeIx, calibDateTimePicker.Value.Date);
CalibInfoCfg.SetCalibValidDate(rangeIx, calibExpirationDateTimePicker.Value.Date);
calibCertificateCtrl.Update(CalibInfoCfg, rangeIx);
}
catch
{
+20 -98
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018 Senus Slovensko a.s.
/// Copyright (c) 2018-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -32,11 +32,6 @@ namespace TBF.UI.Bench.Metrology
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.nameGroupBox = new System.Windows.Forms.GroupBox();
this.pressFromToLabel = new System.Windows.Forms.Label();
this.tempFromToLabel = new System.Windows.Forms.Label();
@@ -47,13 +42,11 @@ namespace TBF.UI.Bench.Metrology
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.nameGroupBox.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.SuspendLayout();
@@ -68,7 +61,7 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
//
@@ -76,59 +69,9 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(650, 400);
this.splitContainer1.SplitterDistance = 102;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 2;
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(186, 10);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(228, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(140, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(69, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate nr.";
//
// nameGroupBox
//
this.nameGroupBox.Controls.Add(this.pressFromToLabel);
@@ -136,7 +79,7 @@ namespace TBF.UI.Bench.Metrology
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
this.nameGroupBox.Name = "nameGroupBox";
this.nameGroupBox.Size = new System.Drawing.Size(160, 86);
this.nameGroupBox.Size = new System.Drawing.Size(160, 99);
this.nameGroupBox.TabIndex = 5;
this.nameGroupBox.TabStop = false;
this.nameGroupBox.Text = "Component";
@@ -172,16 +115,16 @@ namespace TBF.UI.Bench.Metrology
this.testGroupBox.Controls.Add(this.measuredTextBox);
this.testGroupBox.Controls.Add(this.correctedLabel);
this.testGroupBox.Controls.Add(this.measuredLabel);
this.testGroupBox.Location = new System.Drawing.Point(424, 10);
this.testGroupBox.Location = new System.Drawing.Point(428, 10);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(170, 88);
this.testGroupBox.Size = new System.Drawing.Size(170, 99);
this.testGroupBox.TabIndex = 4;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Correction test";
//
// correctedTextBox
//
this.correctedTextBox.Location = new System.Drawing.Point(91, 37);
this.correctedTextBox.Location = new System.Drawing.Point(88, 43);
this.correctedTextBox.Name = "correctedTextBox";
this.correctedTextBox.ReadOnly = true;
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
@@ -189,7 +132,7 @@ namespace TBF.UI.Bench.Metrology
//
// measuredTextBox
//
this.measuredTextBox.Location = new System.Drawing.Point(91, 15);
this.measuredTextBox.Location = new System.Drawing.Point(88, 18);
this.measuredTextBox.Name = "measuredTextBox";
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
this.measuredTextBox.TabIndex = 4;
@@ -198,7 +141,7 @@ namespace TBF.UI.Bench.Metrology
// correctedLabel
//
this.correctedLabel.AutoSize = true;
this.correctedLabel.Location = new System.Drawing.Point(17, 40);
this.correctedLabel.Location = new System.Drawing.Point(14, 46);
this.correctedLabel.Name = "correctedLabel";
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
this.correctedLabel.TabIndex = 3;
@@ -207,7 +150,7 @@ namespace TBF.UI.Bench.Metrology
// measuredLabel
//
this.measuredLabel.AutoSize = true;
this.measuredLabel.Location = new System.Drawing.Point(17, 18);
this.measuredLabel.Location = new System.Drawing.Point(14, 21);
this.measuredLabel.Name = "measuredLabel";
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
this.measuredLabel.TabIndex = 2;
@@ -220,33 +163,21 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(650, 294);
this.listViewEx.Size = new System.Drawing.Size(650, 284);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
//
// calibExpirationDateTimePicker
// calibCertificateCtrl
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
this.calibCertificateCtrl.Location = new System.Drawing.Point(182, 10);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 6;
//
// MetrologyDlgLevelMeterTab
//
@@ -260,8 +191,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.nameGroupBox.ResumeLayout(false);
this.nameGroupBox.PerformLayout();
this.testGroupBox.ResumeLayout(false);
@@ -281,15 +210,8 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label correctedLabel;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox nameGroupBox;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.Label pressFromToLabel;
private System.Windows.Forms.Label tempFromToLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,13 +1,13 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Common.Forms;
using Config.Entities;
using TBF.Resources;
using TBF.UI.Shared;
@@ -52,10 +52,6 @@ namespace TBF.UI.Bench.Metrology
public MetrologyDlgLevelMeterTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
}
@@ -97,11 +93,6 @@ namespace TBF.UI.Bench.Metrology
{
nameGroupBox.Text = Strings.Component;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
testGroupBox.Text = Strings.Test_measured_corrected;
measuredLabel.Text = Strings.Measured;
correctedLabel.Text = Strings.Corrected;
@@ -109,12 +100,7 @@ namespace TBF.UI.Bench.Metrology
void RefreshAll()
{
if (CalibInfoCfg != null)
{
calibCertificateNrTextBox.Text = CalibInfoCfg.CalibCertificateNr;
calibDateTimePicker.Value = (CalibInfoCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibDate;
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
}
if (CalibInfoCfg != null) calibCertificateCtrl.Refresh(CalibInfoCfg);
listViewEx.Items.Clear();
foreach (var corr in MeterEntity.Corrections)
@@ -209,9 +195,7 @@ namespace TBF.UI.Bench.Metrology
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
if (listViewEx.SelectedItems.Count == 1)
{
@@ -228,10 +212,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
CalibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
CalibInfoCfg.CalibDate = calibDateTimePicker.Value.Date;
CalibInfoCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(CalibInfoCfg);
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}
@@ -332,7 +313,7 @@ namespace TBF.UI.Bench.Metrology
CultureInfo.InvariantCulture,
out measured))
{
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
correctedTextBox.Text = corrected.ToString();
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -40,11 +40,6 @@ namespace TBF.UI.Bench.Metrology
this.resistanceLabel = new System.Windows.Forms.Label();
this.temperatureLabel = new System.Windows.Forms.Label();
this.resistanceTextBox = new System.Windows.Forms.TextBox();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.its90CalibrationCoefficientsGroupBox = new System.Windows.Forms.GroupBox();
this.c7TextBox = new System.Windows.Forms.TextBox();
this.c7Label = new System.Windows.Forms.Label();
@@ -62,13 +57,11 @@ namespace TBF.UI.Bench.Metrology
this.r0TextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.its90CalibrationCoefficientsGroupBox.SuspendLayout();
this.nameGroupBox.SuspendLayout();
this.its27CalibrationCoefficientsGroupBox.SuspendLayout();
@@ -93,21 +86,21 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.radioButton2);
this.splitContainer1.Panel1.Controls.Add(this.radioButton1);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.its90CalibrationCoefficientsGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.its27CalibrationCoefficientsGroupBox);
this.splitContainer1.Size = new System.Drawing.Size(668, 400);
this.splitContainer1.SplitterDistance = 300;
this.splitContainer1.Size = new System.Drawing.Size(700, 400);
this.splitContainer1.SplitterDistance = 250;
this.splitContainer1.TabIndex = 1;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(462, 24);
this.radioButton2.Location = new System.Drawing.Point(498, 14);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(187, 17);
this.radioButton2.TabIndex = 11;
@@ -118,7 +111,7 @@ namespace TBF.UI.Bench.Metrology
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(235, 24);
this.radioButton1.Location = new System.Drawing.Point(271, 14);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(187, 17);
this.radioButton1.TabIndex = 10;
@@ -132,9 +125,9 @@ namespace TBF.UI.Bench.Metrology
this.testGroupBox.Controls.Add(this.resistanceLabel);
this.testGroupBox.Controls.Add(this.temperatureLabel);
this.testGroupBox.Controls.Add(this.resistanceTextBox);
this.testGroupBox.Location = new System.Drawing.Point(16, 155);
this.testGroupBox.Location = new System.Drawing.Point(16, 164);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(208, 77);
this.testGroupBox.Size = new System.Drawing.Size(240, 77);
this.testGroupBox.TabIndex = 9;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Test";
@@ -173,56 +166,6 @@ namespace TBF.UI.Bench.Metrology
this.resistanceTextBox.TabIndex = 4;
this.resistanceTextBox.TextChanged += new System.EventHandler(this.measuredTextBox_TextChanged);
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(16, 54);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(208, 95);
this.calibrationGroupBox.TabIndex = 6;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 68);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 43);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(105, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(95, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(54, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate";
//
// its90CalibrationCoefficientsGroupBox
//
this.its90CalibrationCoefficientsGroupBox.Controls.Add(this.c7TextBox);
@@ -233,7 +176,7 @@ namespace TBF.UI.Bench.Metrology
this.its90CalibrationCoefficientsGroupBox.Controls.Add(this.b7Label);
this.its90CalibrationCoefficientsGroupBox.Controls.Add(this.a7Label);
this.its90CalibrationCoefficientsGroupBox.Controls.Add(this.r0Label);
this.its90CalibrationCoefficientsGroupBox.Location = new System.Drawing.Point(230, 54);
this.its90CalibrationCoefficientsGroupBox.Location = new System.Drawing.Point(266, 40);
this.its90CalibrationCoefficientsGroupBox.Name = "its90CalibrationCoefficientsGroupBox";
this.its90CalibrationCoefficientsGroupBox.Size = new System.Drawing.Size(220, 140);
this.its90CalibrationCoefficientsGroupBox.TabIndex = 5;
@@ -313,7 +256,7 @@ namespace TBF.UI.Bench.Metrology
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
this.nameGroupBox.Name = "nameGroupBox";
this.nameGroupBox.Size = new System.Drawing.Size(208, 40);
this.nameGroupBox.Size = new System.Drawing.Size(240, 40);
this.nameGroupBox.TabIndex = 4;
this.nameGroupBox.TabStop = false;
this.nameGroupBox.Text = "Component";
@@ -326,7 +269,7 @@ namespace TBF.UI.Bench.Metrology
this.its27CalibrationCoefficientsGroupBox.Controls.Add(this.r0TextBox);
this.its27CalibrationCoefficientsGroupBox.Controls.Add(this.label2);
this.its27CalibrationCoefficientsGroupBox.Controls.Add(this.label3);
this.its27CalibrationCoefficientsGroupBox.Location = new System.Drawing.Point(459, 54);
this.its27CalibrationCoefficientsGroupBox.Location = new System.Drawing.Point(495, 40);
this.its27CalibrationCoefficientsGroupBox.Name = "its27CalibrationCoefficientsGroupBox";
this.its27CalibrationCoefficientsGroupBox.Size = new System.Drawing.Size(190, 140);
this.its27CalibrationCoefficientsGroupBox.TabIndex = 3;
@@ -384,25 +327,12 @@ namespace TBF.UI.Bench.Metrology
this.label3.TabIndex = 8;
this.label3.Text = "R0";
//
// calibDateTimePicker
// calibCertificateCtrl
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(105, 40);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(95, 20);
this.calibDateTimePicker.TabIndex = 17;
//
// calibExpirationDateTimePicker
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(105, 64);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(95, 20);
this.calibExpirationDateTimePicker.TabIndex = 18;
this.calibCertificateCtrl.Location = new System.Drawing.Point(16, 58);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 12;
//
// MetrologyDlgPlatinumResistanceTMeterTab
//
@@ -410,7 +340,7 @@ namespace TBF.UI.Bench.Metrology
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "MetrologyDlgPlatinumResistanceTMeterTab";
this.Size = new System.Drawing.Size(668, 400);
this.Size = new System.Drawing.Size(700, 400);
this.Load += new System.EventHandler(this.MetrologyDlgBalanceTab_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
@@ -418,8 +348,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.ResumeLayout(false);
this.testGroupBox.ResumeLayout(false);
this.testGroupBox.PerformLayout();
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.its90CalibrationCoefficientsGroupBox.ResumeLayout(false);
this.its90CalibrationCoefficientsGroupBox.PerformLayout();
this.nameGroupBox.ResumeLayout(false);
@@ -449,11 +377,6 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label r0Label;
private System.Windows.Forms.TextBox c7TextBox;
private System.Windows.Forms.Label c7Label;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox bTextBox;
private System.Windows.Forms.Label label1;
@@ -463,7 +386,6 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,11 +1,11 @@
///
/// Copyright (c) 2016-2020 Senus Slovensko a.s.
/// Copyright (c) 2016-2023 Senus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config;
using Config.Entities;
using TBF.Resources;
@@ -19,12 +19,7 @@ namespace TBF.UI.Bench.Metrology
/// Component entity that has a list of 'measurement-correction' pairs
/// to be updated in the database on OK.
/// </summary>
public Component MeterEntity
{
get { return meterEntity; }
set { meterEntity = value; }
}
Component meterEntity;
public Component MeterEntity { get; set; }
/// <summary>
/// Balance configuration (with buoyancy parameters)
@@ -34,30 +29,19 @@ namespace TBF.UI.Bench.Metrology
/// <summary>
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
/// </summary>
public IList<MeasurementCorrection> ToBeRemoved
{
get { return toBeRemoved; }
set { toBeRemoved = value; }
}
IList<MeasurementCorrection> toBeRemoved;
public IList<MeasurementCorrection> ToBeRemoved { get; set; }
MetrologyDlg parent;
bool unlocked;
public MetrologyDlgPlatinumResistanceTMeterTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
ToBeRemoved = new List<MeasurementCorrection>();
}
private void MetrologyDlgBalanceTab_Load(object sender, System.EventArgs e)
{
if (meterEntity == null) return;
if (MeterEntity == null) return;
parent = ParentForm as MetrologyDlg;
@@ -75,11 +59,6 @@ namespace TBF.UI.Bench.Metrology
{
nameGroupBox.Text = Strings.Component;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
testGroupBox.Text = Strings.Test;
resistanceLabel.Text = string.Format("{0} [Ω]", Strings.Resistance);
temperatureLabel.Text = string.Format("{0} [°C]", Strings.Temperature);
@@ -95,9 +74,7 @@ namespace TBF.UI.Bench.Metrology
{
if (TempMeterCfg != null)
{
calibCertificateNrTextBox.Text = TempMeterCfg.CalibCertificateNr;
calibDateTimePicker.Value = (TempMeterCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : TempMeterCfg.CalibDate;
calibExpirationDateTimePicker.Value = (TempMeterCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : TempMeterCfg.CalibValidDate;
calibCertificateCtrl.Refresh(TempMeterCfg);
radioButton1.Checked = TempMeterCfg.UseITS90;
radioButton2.Checked = !TempMeterCfg.UseITS90;
@@ -115,11 +92,7 @@ namespace TBF.UI.Bench.Metrology
public void Unlock()
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
radioButton1.Enabled = true;
radioButton2.Enabled = true;
@@ -140,9 +113,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
TempMeterCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
TempMeterCfg.CalibDate = calibDateTimePicker.Value.Date;
TempMeterCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(TempMeterCfg);
TempMeterCfg.UseITS90 = radioButton1.Checked;
@@ -182,14 +153,14 @@ namespace TBF.UI.Bench.Metrology
double a7 = Utils.ParseEDouble(a7TextBox.Text);
double b7 = Utils.ParseEDouble(b7TextBox.Text);
double c7 = Utils.ParseEDouble(c7TextBox.Text);
temperature = Config.Formulas.PlatinumResistanceTM_ITS90_R2T(resistance, R001C, a7, b7, c7);
temperature = Formulas.PlatinumResistanceTM_ITS90_R2T(resistance, R001C, a7, b7, c7);
}
else
{
double R0 = Utils.ParseUDouble(r0TextBox.Text);
double a = Utils.ParseEDouble(aTextBox.Text);
double b = Utils.ParseEDouble(bTextBox.Text);
temperature = Config.Formulas.PlatinumResistanceTM_ITS27_R2T(resistance, R0, a, b);
temperature = Formulas.PlatinumResistanceTM_ITS27_R2T(resistance, R0, a, b);
}
temperatureTextBox.Text = temperature.ToString();
}
@@ -203,25 +174,11 @@ namespace TBF.UI.Bench.Metrology
}
}
public void CancelBtnClicked()
{
}
public void AddOne()
{
}
public void RemoveSelected()
{
}
public void MoveUpSelected()
{
}
public void MoveDownSelected()
{
}
public void CancelBtnClicked() { }
public void AddOne() { }
public void RemoveSelected() { }
public void MoveUpSelected() { }
public void MoveDownSelected() { }
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
{
+17 -95
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
/// Copyright (c) 2013-2023 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
@@ -34,13 +34,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.unitLabel = new System.Windows.Forms.Label();
this.unitComboBox = new System.Windows.Forms.ComboBox();
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
this.calibCertificateNrLabel = new System.Windows.Forms.Label();
this.testGroupBox = new System.Windows.Forms.GroupBox();
this.correctedTextBox = new System.Windows.Forms.TextBox();
this.measuredTextBox = new System.Windows.Forms.TextBox();
@@ -49,11 +42,11 @@ namespace TBF.UI.Bench.Metrology
this.componentLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibCertificateCtrl = new TBF.UI.Bench.Metrology.CalibCertificateCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.calibrationGroupBox.SuspendLayout();
this.testGroupBox.SuspendLayout();
this.SuspendLayout();
//
@@ -67,9 +60,9 @@ namespace TBF.UI.Bench.Metrology
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.calibCertificateCtrl);
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.componentLabel);
this.splitContainer1.Panel1.Controls.Add(this.cmpntNameLabel);
@@ -78,7 +71,7 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(650, 300);
this.splitContainer1.SplitterDistance = 110;
this.splitContainer1.SplitterDistance = 112;
this.splitContainer1.TabIndex = 2;
//
// unitLabel
@@ -99,85 +92,15 @@ namespace TBF.UI.Bench.Metrology
this.unitComboBox.TabIndex = 9;
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
//
// calibrationGroupBox
//
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibDateTimePicker);
this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibDateLabel);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox);
this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel);
this.calibrationGroupBox.Location = new System.Drawing.Point(204, 12);
this.calibrationGroupBox.Name = "calibrationGroupBox";
this.calibrationGroupBox.Size = new System.Drawing.Size(208, 86);
this.calibrationGroupBox.TabIndex = 7;
this.calibrationGroupBox.TabStop = false;
this.calibrationGroupBox.Text = "Calibration";
//
// calibExpirationDateTimePicker
//
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibExpirationDateTimePicker.Enabled = false;
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(117, 59);
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibExpirationDateTimePicker.TabIndex = 19;
//
// calibDateTimePicker
//
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
this.calibDateTimePicker.Enabled = false;
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.calibDateTimePicker.Location = new System.Drawing.Point(117, 37);
this.calibDateTimePicker.Name = "calibDateTimePicker";
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.calibDateTimePicker.TabIndex = 18;
//
// calibValidDateLabel
//
this.calibValidDateLabel.AutoSize = true;
this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62);
this.calibValidDateLabel.Name = "calibValidDateLabel";
this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13);
this.calibValidDateLabel.TabIndex = 14;
this.calibValidDateLabel.Text = "Valid until";
//
// calibDateLabel
//
this.calibDateLabel.AutoSize = true;
this.calibDateLabel.Location = new System.Drawing.Point(17, 40);
this.calibDateLabel.Name = "calibDateLabel";
this.calibDateLabel.Size = new System.Drawing.Size(30, 13);
this.calibDateLabel.TabIndex = 12;
this.calibDateLabel.Text = "Date";
//
// calibCertificateNrTextBox
//
this.calibCertificateNrTextBox.Enabled = false;
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(117, 15);
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
this.calibCertificateNrTextBox.TabIndex = 11;
//
// calibCertificateNrLabel
//
this.calibCertificateNrLabel.AutoSize = true;
this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18);
this.calibCertificateNrLabel.Name = "calibCertificateNrLabel";
this.calibCertificateNrLabel.Size = new System.Drawing.Size(54, 13);
this.calibCertificateNrLabel.TabIndex = 10;
this.calibCertificateNrLabel.Text = "Certificate";
//
// testGroupBox
//
this.testGroupBox.Controls.Add(this.correctedTextBox);
this.testGroupBox.Controls.Add(this.measuredTextBox);
this.testGroupBox.Controls.Add(this.correctedLabel);
this.testGroupBox.Controls.Add(this.measuredLabel);
this.testGroupBox.Location = new System.Drawing.Point(428, 12);
this.testGroupBox.Location = new System.Drawing.Point(442, 9);
this.testGroupBox.Name = "testGroupBox";
this.testGroupBox.Size = new System.Drawing.Size(200, 86);
this.testGroupBox.Size = new System.Drawing.Size(200, 100);
this.testGroupBox.TabIndex = 4;
this.testGroupBox.TabStop = false;
this.testGroupBox.Text = "Test";
@@ -241,14 +164,22 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(650, 186);
this.listViewEx.Size = new System.Drawing.Size(650, 184);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
//
// calibCertificateCtrl
//
this.calibCertificateCtrl.Location = new System.Drawing.Point(196, 9);
this.calibCertificateCtrl.Name = "calibCertificateCtrl";
this.calibCertificateCtrl.Size = new System.Drawing.Size(240, 100);
this.calibCertificateCtrl.TabIndex = 11;
//
// MetrologyDlgPressMeterTab
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -262,8 +193,6 @@ namespace TBF.UI.Bench.Metrology
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.calibrationGroupBox.ResumeLayout(false);
this.calibrationGroupBox.PerformLayout();
this.testGroupBox.ResumeLayout(false);
this.testGroupBox.PerformLayout();
this.ResumeLayout(false);
@@ -281,15 +210,8 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.TextBox measuredTextBox;
private System.Windows.Forms.Label correctedLabel;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox calibrationGroupBox;
private System.Windows.Forms.Label calibValidDateLabel;
private System.Windows.Forms.Label calibDateLabel;
private System.Windows.Forms.TextBox calibCertificateNrTextBox;
private System.Windows.Forms.Label calibCertificateNrLabel;
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
private System.Windows.Forms.Label unitLabel;
private System.Windows.Forms.ComboBox unitComboBox;
}
private CalibCertificateCtrl calibCertificateCtrl;
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,6 +8,7 @@ using System.Windows.Forms;
using log4net;
using Common;
using Common.Forms;
using Config;
using Config.Entities;
using TBF.Resources;
using TBF.UI.Shared;
@@ -57,10 +58,6 @@ namespace TBF.UI.Bench.Metrology
public MetrologyDlgPressMeterTab()
{
InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat;
calibDateTimePicker.MinDate = Constants.MinDate;
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
}
@@ -113,20 +110,11 @@ namespace TBF.UI.Bench.Metrology
{
componentLabel.Text = Strings.Component;
testGroupBox.Text = Strings.Test_measured_corrected;
calibrationGroupBox.Text = Strings.Calibration;
calibCertificateNrLabel.Text = Strings.Certificate;
calibDateLabel.Text = Strings.Date;
calibValidDateLabel.Text = Strings.Valid_until;
}
void RefreshAll()
void RefreshAll()
{
if (CalibInfoCfg != null)
{
calibCertificateNrTextBox.Text = CalibInfoCfg.CalibCertificateNr;
calibDateTimePicker.Value = (CalibInfoCfg.CalibDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibDate;
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
}
if (CalibInfoCfg != null) calibCertificateCtrl.Refresh(CalibInfoCfg);
listViewEx.Items.Clear();
foreach (var corr in MeterEntity.Corrections) AddOneLVI(corr);
@@ -150,7 +138,7 @@ namespace TBF.UI.Bench.Metrology
}
else
{
double error = Config.Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
}
@@ -194,8 +182,9 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement))
{
measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
(item.Tag as MeasurementCorrection).Measurement = measurement;
/// Update error (if possible)
@@ -203,7 +192,7 @@ namespace TBF.UI.Bench.Metrology
{
correction = Units.IsDefaultUnit(currentUnit) ? difference
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
error = Config.Formulas.ErrorFromVolumes(measurement, measurement + correction);
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
}
else
@@ -225,7 +214,7 @@ namespace TBF.UI.Bench.Metrology
/// Update error (if possible)
if (measurement != 0)
{
error = Config.Formulas.ErrorFromVolumes(measurement, measurement + correction);
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
}
else
@@ -249,7 +238,7 @@ namespace TBF.UI.Bench.Metrology
{
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
{
correction = Config.Formulas.CorrectionFromError(measurement, error);
correction = Formulas.CorrectionFromError(measurement, error);
(item.Tag as MeasurementCorrection).Correction = correction;
difference = Units.IsDefaultUnit(currentUnit)
? correction
@@ -270,9 +259,7 @@ namespace TBF.UI.Bench.Metrology
{
unlocked = true;
calibCertificateNrTextBox.Enabled = true;
calibDateTimePicker.Enabled = true;
calibExpirationDateTimePicker.Enabled = true;
calibCertificateCtrl.Unlock();
if (listViewEx.SelectedItems.Count == 1)
{
@@ -289,10 +276,7 @@ namespace TBF.UI.Bench.Metrology
{
try
{
CalibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
CalibInfoCfg.CalibDate = calibDateTimePicker.Value.Date;
CalibInfoCfg.CalibValidDate = calibExpirationDateTimePicker.Value.Date;
calibCertificateCtrl.Update(CalibInfoCfg);
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}

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