DataEntry.S620 supports production tracing, S/Ns from OraDB + disp., flash and beep, ver. 2.26.1592

This commit is contained in:
Milan Hanajik 2021-02-02 12:30:27 +01:00
parent 2e75d91adc
commit 3bf8b4fe54
19 changed files with 2754 additions and 3713 deletions

37
Common/BackgroundBeep.cs Normal file
View File

@ -0,0 +1,37 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Threading;
namespace Common
{
public class BackgroundBeep
{
static Thread beepThread;
static AutoResetEvent signalBeep;
static BackgroundBeep()
{
signalBeep = new AutoResetEvent(false);
beepThread = new Thread(() =>
{
while (true)
{
signalBeep.WaitOne(); /// waits for an event
Console.Beep(500, 400); /// frequency (Hz), duration (ms)
}
}, 1);
beepThread.IsBackground = true;
beepThread.Start();
}
/// <summary>
/// Invokes one beep in a separate thread (non-blocking function)
/// </summary>
public static void Beep()
{
signalBeep.Set();
}
}
}

View File

@ -41,6 +41,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BackgroundBeep.cs" />
<Compile Include="SerializableDictionary.cs" /> <Compile Include="SerializableDictionary.cs" />
<Compile Include="UIControls\CoolButtonCtrl.cs"> <Compile Include="UIControls\CoolButtonCtrl.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>

View File

@ -131,25 +131,6 @@ namespace TBF.BenchControl.DataEntry.S620.CheckItems
break; break;
case CodeType.DateMMYY: case CodeType.DateMMYY:
if (part.LifetimeManagement == LifetimeManagement.OneYear)
{
int mmyy;
if (!int.TryParse(scannedCodeTextBox.Text, out mmyy))
{
error = PartError.WrongPart;
}
else
{
int batteryMonthsSince2000 = 12 * (mmyy % 100) + (mmyy / 100);
int monthsSince2000 = 12 * (DateTime.Now.Year - 2000) + DateTime.Now.Month;
int age = monthsSince2000 - batteryMonthsSince2000;
if (age < 0 || age > 12 + parent.ExtraBatteryLifetime)
{
error = PartError.WrongPart;
}
}
}
break; break;
} }
} }

View File

@ -18,6 +18,8 @@ namespace TBF.BenchControl.DataEntry.S620
public bool UsesCameras() { return false; } public bool UsesCameras() { return false; }
readonly EntryFormCfg entryFormCfg; readonly EntryFormCfg entryFormCfg;
readonly TBF.BenchControl.Output.DB.ProductionTracing.Tracing tracing;
IRegReader[] regReaders; IRegReader[] regReaders;
/// <summary> /// <summary>
@ -64,11 +66,14 @@ namespace TBF.BenchControl.DataEntry.S620
{ {
} }
public EntryForm(Generic.IComponentCfg cfg) public EntryForm(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg) : base(cfg)
{ {
entryFormCfg = cfg as EntryFormCfg; entryFormCfg = cfg as EntryFormCfg;
tracing = (TBF.BenchControl.Output.DB.ProductionTracing.Tracing)TbfComponents.FindComponent(cfg.ParentName, components);
if (tracing == null) throw new Exception("Cannot find " + Name + " parent");
disabled = new bool[Config.Data.WMsCount]; disabled = new bool[Config.Data.WMsCount];
wmStartState = new double[Config.Data.WMsCount]; wmStartState = new double[Config.Data.WMsCount];
wmStartStateStr = new string[Config.Data.WMsCount]; wmStartStateStr = new string[Config.Data.WMsCount];
@ -120,15 +125,29 @@ namespace TBF.BenchControl.DataEntry.S620
delegate void EntryFormDlgt(EntryForm myRef); delegate void EntryFormDlgt(EntryForm myRef);
/// ///
void OpenMechanicalMetersDlg(EntryForm myRef) void OnCycleStart(EntryForm myRef)
{ {
myRef.modelessDlg = new FormForMechanicalMeters(waterMeters, entryFormCfg.SkipFailedMeters); if (entryFormCfg.ProductionTracing)
{
myRef.modelessDlg = new FormForMechanicalMetersWithTracing(waterMeters, entryFormCfg.MaxWMsCount, entryFormCfg.CloseButton, false);
}
else
{
myRef.modelessDlg = new FormForMechanicalMeters(waterMeters);
}
modelessDlg.Show(); modelessDlg.Show();
} }
/// ///
void OpenMechanicalMetersWithTracingDlg(EntryForm myRef) void OnCycleEnd(EntryForm myRef)
{ {
myRef.modelessDlg = new FormForMechanicalMetersWithTracing(waterMeters, entryFormCfg.SkipFailedMeters); if (entryFormCfg.ProductionTracing)
{
myRef.modelessDlg = new FormForMechanicalMetersWithTracing(waterMeters, entryFormCfg.MaxWMsCount, entryFormCfg.CloseButton, true);
}
else
{
myRef.modelessDlg = new FormForMechanicalMeters(waterMeters);
}
modelessDlg.Show(); modelessDlg.Show();
} }
/// ///
@ -152,17 +171,11 @@ namespace TBF.BenchControl.DataEntry.S620
{ {
default: default:
case CurrentOp.ShowFormAtCycleBeginning: case CurrentOp.ShowFormAtCycleBeginning:
Program.MainWnd.Invoke(new EntryFormDlgt(OnCycleStart), this);
return; return;
case CurrentOp.ShowFormAtCycleEnd: case CurrentOp.ShowFormAtCycleEnd:
if (entryFormCfg.ProductionTracing) Program.MainWnd.Invoke(new EntryFormDlgt(OnCycleEnd), this);
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenMechanicalMetersWithTracingDlg), this);
}
else
{
Program.MainWnd.Invoke(new EntryFormDlgt(OpenMechanicalMetersDlg), this);
}
break; break;
case CurrentOp.EnterTestStartStates: case CurrentOp.EnterTestStartStates:
@ -186,49 +199,39 @@ namespace TBF.BenchControl.DataEntry.S620
if (!resultSaved) /// This is to save the result only once if (!resultSaved) /// This is to save the result only once
{ {
if (currentOp == CurrentOp.ShowFormAtCycleEnd) if (currentOp == CurrentOp.ShowFormAtCycleBeginning)
{ {
if (!entryFormCfg.ProductionTracing) ICycleBeginOrEndForm dlg = (modelessDlg as ICycleBeginOrEndForm);
if (dlg != null)
{ {
FormForMechanicalMeters dlg = (modelessDlg as FormForMechanicalMeters); for (int i = 0; i < waterMeters.Count; i++)
if (dlg != null)
{ {
for (int i = 0; i < waterMeters.Count; i++) if (waterMeters[i] != null)
{ {
if (waterMeters[i] != null) waterMeters[i].Disabled = disabled[i] = dlg.Disabled[i];
{ waterMeters[i].SerialNr = dlg.BodyNrText[i];
waterMeters[i].Disabled = disabled[i] = dlg.Disabled[i];
waterMeters[i].SerialNr = dlg.BodyNrText[i];
#if ORACLE_DB
waterMeters[i].AssignedSerialNr = dlg.AssignedSerialNr[i];
waterMeters[i].Prefix = dlg.Prefix;
waterMeters[i].Suffix = dlg.Suffix;
waterMeters[i].CompleteSerialNr = dlg.CompleteSerialNr[i];
#endif
if (dlg.PurchaseOrder != null) waterMeters[i].PurchaseOrder = dlg.PurchaseOrder;
}
} }
} }
} }
else }
else if (currentOp == CurrentOp.ShowFormAtCycleEnd)
{
ICycleBeginOrEndForm dlg = (modelessDlg as ICycleBeginOrEndForm);
if (dlg != null)
{ {
FormForMechanicalMetersWithTracing dlg = (modelessDlg as FormForMechanicalMetersWithTracing); for (int i = 0; i < waterMeters.Count; i++)
if (dlg != null)
{ {
for (int i = 0; i < waterMeters.Count; i++) if (waterMeters[i] != null)
{ {
if (waterMeters[i] != null) waterMeters[i].Disabled = disabled[i] = dlg.Disabled[i];
{ waterMeters[i].SerialNr = dlg.BodyNrText[i];
waterMeters[i].Disabled = disabled[i] = dlg.Disabled[i];
waterMeters[i].SerialNr = dlg.BodyNrText[i];
#if ORACLE_DB #if ORACLE_DB
waterMeters[i].AssignedSerialNr = dlg.AssignedSerialNr[i]; waterMeters[i].AssignedSerialNr = dlg.AssignedSerialNr[i];
waterMeters[i].Prefix = dlg.Prefix; waterMeters[i].Prefix = dlg.Prefix;
waterMeters[i].Suffix = dlg.Suffix; waterMeters[i].Suffix = dlg.Suffix;
waterMeters[i].CompleteSerialNr = dlg.CompleteSerialNr[i]; waterMeters[i].CompleteSerialNr = dlg.CompleteSerialNr[i];
#endif #endif
if (dlg.PurchaseOrder != null) waterMeters[i].PurchaseOrder = dlg.PurchaseOrder; if (dlg.PurchaseOrder != null) waterMeters[i].PurchaseOrder = dlg.PurchaseOrder;
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2020 Sensus Slovensko a.s. /// Copyright (c) 2020-2021 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -9,7 +9,7 @@ using TBF.BenchControl.Generic;
namespace TBF.BenchControl.DataEntry.S620 namespace TBF.BenchControl.DataEntry.S620
{ {
public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg public class EntryFormCfg : ComponentCfgBase, Generic.IChildComponentCfg
{ {
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0]; public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; } public override XmlSerializer GetSerializer() { return Serializer; }
@ -19,7 +19,8 @@ namespace TBF.BenchControl.DataEntry.S620
/// ///
/// Serialized parameters /// Serialized parameters
/// ///
public bool SkipFailedMeters; public int MaxWMsCount;
public char CloseButton;
public bool ProductionTracing; public bool ProductionTracing;
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
@ -29,15 +30,21 @@ namespace TBF.BenchControl.DataEntry.S620
: this() : this()
{ {
Name = name; Name = name;
ParentName = "ProductionMonitoring";
Factory = factory; Factory = factory;
ParentName = string.Empty; MaxWMsCount = 20;
SkipFailedMeters = false; CloseButton = '+';
ProductionTracing = false; ProductionTracing = true;
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("Name={0}, SkipFailedMeters={1}, ProductionTracing={2}", Name, SkipFailedMeters, ProductionTracing); return string.Format("Name={0}, MaxWMsCount={1}, CloseButton={2}, ProductionTracing={3}, Parent={4}",
Name,
MaxWMsCount,
(CloseButton == '+') ? "+" : (CloseButton == '\t') ? "Tab" : "none",
ProductionTracing,
string.IsNullOrEmpty(ParentName) ? "-" : ParentName);
} }
} }
} }

View File

@ -11,7 +11,9 @@ namespace TBF.BenchControl.DataEntry.S620
{ {
public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl
{ {
public bool ShowMore { get { return false; } } ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
EntryFormCfg config; EntryFormCfg config;
public IComponentCfg Config public IComponentCfg Config
@ -32,12 +34,30 @@ namespace TBF.BenchControl.DataEntry.S620
private void EntryFormCfgCtrl_Load(object sender, EventArgs e) private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{ {
Localize(); Localize();
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
{
foreach (var cmpnt in parent.TbfComponents)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Output.DB.ProductionTracing.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
closeButtonComboBox.Items.Add("<none>");
closeButtonComboBox.Items.Add("Tab");
closeButtonComboBox.Items.Add("+");
Redraw(); Redraw();
} }
void Localize() void Localize()
{ {
skipFailedMetersCheckBox.Text = "Preskočiť zlé vodomery pri skenovaní";
productionTracingCheckBox.Text = "Sledovanie výroby"; productionTracingCheckBox.Text = "Sledovanie výroby";
} }
@ -50,21 +70,41 @@ namespace TBF.BenchControl.DataEntry.S620
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName; classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
skipFailedMetersCheckBox.Checked = config.SkipFailedMeters; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
maxWMsCountTextBox.Text = config.MaxWMsCount.ToString();
closeButtonComboBox.Text = (config.CloseButton == '+') ? "+" : (config.CloseButton == '\t') ? "Tab" : "<none>";
productionTracingCheckBox.Checked = config.ProductionTracing; productionTracingCheckBox.Checked = config.ProductionTracing;
} }
public void Unlock() public void Unlock()
{ {
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
skipFailedMetersCheckBox.Enabled = true; parentNameComboBox.Enabled = true;
maxWMsCountTextBox.Enabled = true;
closeButtonComboBox.Enabled = true;
productionTracingCheckBox.Enabled = true; productionTracingCheckBox.Enabled = true;
} }
public CfgUpdateFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
int dummy;
CfgUpdateFlags flags = CfgUpdateFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.None;
return flags; if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(maxWMsCountTextBox.Text, out dummy) || dummy <= 0 || dummy > 40)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Max. water meters count'";
}
if (!closeButtonComboBox.Items.Contains(closeButtonComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Close button'";
}
return flags;
} }
public CfgUpdateFlags UpdateCfg() public CfgUpdateFlags UpdateCfg()
@ -74,7 +114,9 @@ namespace TBF.BenchControl.DataEntry.S620
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text; config.Name = nameTextBox.Text;
config.SkipFailedMeters = skipFailedMetersCheckBox.Checked; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.MaxWMsCount = int.Parse(maxWMsCountTextBox.Text);
config.CloseButton = (closeButtonComboBox.Text == "+") ? '+' : (closeButtonComboBox.Text == "Tab") ? '\t' : '\0';
config.ProductionTracing = productionTracingCheckBox.Checked; config.ProductionTracing = productionTracingCheckBox.Checked;
return flags; return flags;

View File

@ -34,14 +34,19 @@ namespace TBF.BenchControl.DataEntry.S620
this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label(); this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.skipFailedMetersCheckBox = new System.Windows.Forms.CheckBox();
this.productionTracingCheckBox = new System.Windows.Forms.CheckBox(); this.productionTracingCheckBox = new System.Windows.Forms.CheckBox();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.parentNameLabel = new System.Windows.Forms.Label();
this.closeButtonComboBox = new System.Windows.Forms.ComboBox();
this.closeButtonLabel = new System.Windows.Forms.Label();
this.maxWMsCountTextBox = new System.Windows.Forms.TextBox();
this.maxWMsCountLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// nameTextBox // nameTextBox
// //
this.nameTextBox.Enabled = false; this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(93, 57); this.nameTextBox.Location = new System.Drawing.Point(155, 58);
this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2; this.nameTextBox.TabIndex = 2;
@ -49,7 +54,7 @@ namespace TBF.BenchControl.DataEntry.S620
// nameLabel // nameLabel
// //
this.nameLabel.AutoSize = true; this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(35, 60); this.nameLabel.Location = new System.Drawing.Point(18, 61);
this.nameLabel.Name = "nameLabel"; this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1; this.nameLabel.TabIndex = 1;
@ -58,45 +63,92 @@ namespace TBF.BenchControl.DataEntry.S620
// classNameLabel // classNameLabel
// //
this.classNameLabel.AutoSize = true; this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(90, 33); this.classNameLabel.Location = new System.Drawing.Point(152, 33);
this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0; this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName"; this.classNameLabel.Text = "ComonentName";
// //
// skipFailedMetersCheckBox
//
this.skipFailedMetersCheckBox.AutoSize = true;
this.skipFailedMetersCheckBox.Enabled = false;
this.skipFailedMetersCheckBox.Location = new System.Drawing.Point(93, 89);
this.skipFailedMetersCheckBox.Name = "skipFailedMetersCheckBox";
this.skipFailedMetersCheckBox.Size = new System.Drawing.Size(182, 17);
this.skipFailedMetersCheckBox.TabIndex = 3;
this.skipFailedMetersCheckBox.Text = "Skip failed meters while scanning";
this.skipFailedMetersCheckBox.UseVisualStyleBackColor = true;
//
// productionTracingCheckBox // productionTracingCheckBox
// //
this.productionTracingCheckBox.AutoSize = true; this.productionTracingCheckBox.AutoSize = true;
this.productionTracingCheckBox.Enabled = false; this.productionTracingCheckBox.Enabled = false;
this.productionTracingCheckBox.Location = new System.Drawing.Point(93, 112); this.productionTracingCheckBox.Location = new System.Drawing.Point(155, 169);
this.productionTracingCheckBox.Name = "productionTracingCheckBox"; this.productionTracingCheckBox.Name = "productionTracingCheckBox";
this.productionTracingCheckBox.Size = new System.Drawing.Size(112, 17); this.productionTracingCheckBox.Size = new System.Drawing.Size(112, 17);
this.productionTracingCheckBox.TabIndex = 5; this.productionTracingCheckBox.TabIndex = 9;
this.productionTracingCheckBox.Text = "Production tracing"; this.productionTracingCheckBox.Text = "Production tracing";
this.productionTracingCheckBox.UseVisualStyleBackColor = true; this.productionTracingCheckBox.UseVisualStyleBackColor = true;
// //
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(155, 84);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(18, 87);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(67, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent name";
//
// closeButtonComboBox
//
this.closeButtonComboBox.Enabled = false;
this.closeButtonComboBox.FormattingEnabled = true;
this.closeButtonComboBox.Location = new System.Drawing.Point(155, 137);
this.closeButtonComboBox.Name = "closeButtonComboBox";
this.closeButtonComboBox.Size = new System.Drawing.Size(130, 21);
this.closeButtonComboBox.TabIndex = 8;
//
// closeButtonLabel
//
this.closeButtonLabel.AutoSize = true;
this.closeButtonLabel.Location = new System.Drawing.Point(18, 140);
this.closeButtonLabel.Name = "closeButtonLabel";
this.closeButtonLabel.Size = new System.Drawing.Size(66, 13);
this.closeButtonLabel.TabIndex = 7;
this.closeButtonLabel.Text = "Close button";
//
// maxWMsCountTextBox
//
this.maxWMsCountTextBox.Enabled = false;
this.maxWMsCountTextBox.Location = new System.Drawing.Point(155, 111);
this.maxWMsCountTextBox.Name = "maxWMsCountTextBox";
this.maxWMsCountTextBox.Size = new System.Drawing.Size(27, 20);
this.maxWMsCountTextBox.TabIndex = 6;
//
// maxWMsCountLabel
//
this.maxWMsCountLabel.AutoSize = true;
this.maxWMsCountLabel.Location = new System.Drawing.Point(18, 114);
this.maxWMsCountLabel.Name = "maxWMsCountLabel";
this.maxWMsCountLabel.Size = new System.Drawing.Size(123, 13);
this.maxWMsCountLabel.TabIndex = 5;
this.maxWMsCountLabel.Text = "Max. water meters count";
//
// EntryFormCfgCtrl // EntryFormCfgCtrl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.maxWMsCountTextBox);
this.Controls.Add(this.maxWMsCountLabel);
this.Controls.Add(this.closeButtonComboBox);
this.Controls.Add(this.closeButtonLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.productionTracingCheckBox); this.Controls.Add(this.productionTracingCheckBox);
this.Controls.Add(this.skipFailedMetersCheckBox);
this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel); this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel); this.Controls.Add(this.classNameLabel);
this.Name = "EntryFormCfgCtrl"; this.Name = "EntryFormCfgCtrl";
this.Size = new System.Drawing.Size(300, 200); this.Size = new System.Drawing.Size(333, 200);
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -108,7 +160,12 @@ namespace TBF.BenchControl.DataEntry.S620
private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.CheckBox skipFailedMetersCheckBox;
private System.Windows.Forms.CheckBox productionTracingCheckBox; private System.Windows.Forms.CheckBox productionTracingCheckBox;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.ComboBox closeButtonComboBox;
private System.Windows.Forms.Label closeButtonLabel;
private System.Windows.Forms.TextBox maxWMsCountTextBox;
private System.Windows.Forms.Label maxWMsCountLabel;
} }
} }

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2020 Sensus Slovensko a.s. /// Copyright (c) 2020-2021 Sensus Slovensko a.s.
/// ///
using System.Collections.Generic; using System.Collections.Generic;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
@ -14,7 +14,7 @@ namespace TBF.BenchControl.DataEntry.S620
public IComponent DummyComponent() { return new EntryForm(); } public IComponent DummyComponent() { return new EntryForm(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryForm(cfg); } public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryForm(cfg, components); }
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this.GetType().Namespace.Substring(17), this); } public IComponentCfg DefaultConfig() { return new EntryFormCfg(this.GetType().Namespace.Substring(17), this); }

View File

@ -13,7 +13,7 @@ using System.Drawing;
namespace TBF.BenchControl.DataEntry.S620 namespace TBF.BenchControl.DataEntry.S620
{ {
public partial class FormForMechanicalMeters : Form, GenericDevices.IHasCompleted public partial class FormForMechanicalMeters : Form, ICycleBeginOrEndForm, GenericDevices.IHasCompleted
{ {
private static readonly ILog log = LogManager.GetLogger(typeof(FormForMechanicalMeters)); private static readonly ILog log = LogManager.GetLogger(typeof(FormForMechanicalMeters));
@ -22,14 +22,29 @@ namespace TBF.BenchControl.DataEntry.S620
readonly int wmsCount; readonly int wmsCount;
readonly bool skipFailed; readonly bool skipFailed;
/// To be retrieved after the form is closed /// To be retrieved after the form is closed
public string PurchaseOrder; string purchaseOrder;
public string[] BodyNrText; public string PurchaseOrder { get { return purchaseOrder; } set { purchaseOrder = value; } }
public int[] AssignedSerialNr;
public string[] CompleteSerialNr; string[] bodyNrText;
public bool[] Disabled; public string[] BodyNrText { get { return bodyNrText; } set { bodyNrText = value; } }
public string Prefix; /// S/N prefix - Loaded from Oracle DB table VT_AUFTRAG_PD
public string Suffix; /// S/N suffix - Loaded from Oracle DB table VT_AUFTRAG_PD int[] assignedSerialNr;
public int[] AssignedSerialNr { get { return assignedSerialNr; } set { assignedSerialNr = value; } }
string[] completeSerialNr;
public string[] CompleteSerialNr { get { return completeSerialNr; } set { completeSerialNr = value; } }
bool[] disabled;
public bool[] Disabled { get { return disabled; } set { disabled = value; } }
string prefix; /// S/N prefix - Loaded from Oracle DB table VT_AUFTRAG_PD
public string Prefix { get { return prefix; } set { prefix = value; } }
string suffix; /// S/N suffix - Loaded from Oracle DB table VT_AUFTRAG_PD
public string Suffix { get { return suffix; } set { suffix = value; } }
/// Loaded from Oracle DB table VT_AUFTRAG_PD /// Loaded from Oracle DB table VT_AUFTRAG_PD
int firstSN; /// First serial number int firstSN; /// First serial number
@ -70,8 +85,8 @@ namespace TBF.BenchControl.DataEntry.S620
firstSN = 0; firstSN = 0;
snDigits = 0; snDigits = 0;
pcsCount = 0; pcsCount = 0;
Prefix = null; prefix = null;
Suffix = null; suffix = null;
foundMeters = new List<BodySerNrResult>(); foundMeters = new List<BodySerNrResult>();
foundSNsWithinRange = new List<int>(); foundSNsWithinRange = new List<int>();
@ -153,17 +168,17 @@ namespace TBF.BenchControl.DataEntry.S620
/// Constructor /// Constructor
/// </summary> /// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param> /// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public FormForMechanicalMeters(IList<Results.Entities.WaterMeter> waterMeters, bool skipFailed) public FormForMechanicalMeters(IList<Results.Entities.WaterMeter> waterMeters)
: this() : this()
{ {
this.waterMeters = waterMeters; this.waterMeters = waterMeters;
this.wmsCount = waterMeters.Count; this.wmsCount = waterMeters.Count;
this.skipFailed = skipFailed; this.skipFailed = false;
BodyNrText = new string[wmsCount]; bodyNrText = new string[wmsCount];
AssignedSerialNr = new int[wmsCount]; assignedSerialNr = new int[wmsCount];
CompleteSerialNr = new string[wmsCount]; completeSerialNr = new string[wmsCount];
Disabled = new bool[wmsCount]; disabled = new bool[wmsCount];
ShuffleTextBoxes(wmsCount, Config.Data.LineSize); ShuffleTextBoxes(wmsCount, Config.Data.LineSize);
} }
@ -286,23 +301,23 @@ namespace TBF.BenchControl.DataEntry.S620
private void okButton_Click(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e)
{ {
PurchaseOrder = orderCB.Text; purchaseOrder = orderCB.Text;
Program.LocalSettings.UpdateHistory(orderCB.Text, ref Program.LocalSettings.PurchaseOrderHistory); Program.LocalSettings.UpdateHistory(orderCB.Text, ref Program.LocalSettings.PurchaseOrderHistory);
Program.LocalSettings.UpdateHistory(firstSNRangeCB.Text, ref Program.LocalSettings.FirstSNHistory); Program.LocalSettings.UpdateHistory(firstSNRangeCB.Text, ref Program.LocalSettings.FirstSNHistory);
Program.LocalSettings.UpdateHistory(lastSNRangeCB.Text, ref Program.LocalSettings.LastSNHistory); Program.LocalSettings.UpdateHistory(lastSNRangeCB.Text, ref Program.LocalSettings.LastSNHistory);
Program.LocalSettings.LastSNTexts = BodyNrText; Program.LocalSettings.LastSNTexts = bodyNrText;
int itmp; int itmp;
for (int i = 0; i < Math.Min(wmsCount, textBoxesCount); i++) for (int i = 0; i < Math.Min(wmsCount, textBoxesCount); i++)
{ {
BodyNrText[i] = bodyNrBoxes[i].Text; bodyNrText[i] = bodyNrBoxes[i].Text;
AssignedSerialNr[i] = int.TryParse(serialNrBoxes[i].Text, out itmp) ? itmp : 0; assignedSerialNr[i] = int.TryParse(serialNrBoxes[i].Text, out itmp) ? itmp : 0;
CompleteSerialNr[i] = string.Format("{0}{1}{2}", completeSerialNr[i] = string.Format("{0}{1}{2}",
(Prefix != null) ? Prefix : string.Empty, (prefix != null) ? prefix : string.Empty,
AssignedSerialNr[i].ToString(string.Format("D{0}", Math.Max(snDigits, 1))), assignedSerialNr[i].ToString(string.Format("D{0}", Math.Max(snDigits, 1))),
(Suffix != null) ? Suffix : string.Empty); (suffix != null) ? suffix : string.Empty);
Disabled[i] = !checkBoxes[i].Checked; disabled[i] = !checkBoxes[i].Checked;
} }
completed = true; completed = true;
@ -544,10 +559,10 @@ namespace TBF.BenchControl.DataEntry.S620
void ProcessPO() void ProcessPO()
{ {
if (ReadPurchaseOrderParamsFromDB(ProcessData.OracleDB.SelectedDB, orderCB.Text, out firstSN, out snDigits, out pcsCount, out Prefix, out Suffix)) if (ReadPurchaseOrderParamsFromDB(ProcessData.OracleDB.SelectedDB, orderCB.Text, out firstSN, out snDigits, out pcsCount, out prefix, out suffix))
{ {
prefixTextBox.Text = (Prefix != null) ? Prefix : string.Empty; prefixTextBox.Text = (prefix != null) ? prefix : string.Empty;
suffixTextBox.Text = (Suffix != null) ? Suffix : string.Empty; suffixTextBox.Text = (suffix != null) ? suffix : string.Empty;
snDigitsTextBox.Text = snDigits.ToString(); snDigitsTextBox.Text = snDigits.ToString();
firstSNTextBox.Text = firstSN.ToString(string.Format("D{0}", snDigits)); firstSNTextBox.Text = firstSN.ToString(string.Format("D{0}", snDigits));
pcsCountTextBox.Text = pcsCount.ToString(); pcsCountTextBox.Text = pcsCount.ToString();

View File

@ -0,0 +1,18 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
namespace TBF.BenchControl.DataEntry.S620
{
public interface ICycleBeginOrEndForm
{
string PurchaseOrder { get; set; }
string[] BodyNrText { get; set; }
int[] AssignedSerialNr { get; set; }
string[] CompleteSerialNr { get; set; }
bool[] Disabled { get; set; }
string Prefix { get; set; } /// S/N prefix - Loaded from Oracle DB table VT_AUFTRAG_PD
string Suffix { get; set; } /// S/N suffix - Loaded from Oracle DB table VT_AUFTRAG_PD
}
}

View File

@ -466,20 +466,18 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
if (worksteps.Count != 1) return Retv.Error; if (worksteps.Count != 1) return Retv.Error;
Workstep vWS; TracingDB.ScanVerificationInfo info;
Part vP;
bool vRP;
/// ///
if (!TracingDB.DB.AnalyzeProcess(session, processes[0], worksteps[0], out vWS, out vRP, out vP)) if (null == (info = TracingDB.DB.AnalyzeProcess(session, processes[0], worksteps[0])))
{ {
return Retv.Error; /// Unable to return Retv.Error; /// Unable to
} }
///
currentProcess = processes[0]; currentProcess = processes[0];
currentWorkstep = worksteps[0]; currentWorkstep = worksteps[0];
verifiedWorkstep = vWS; verifiedWorkstep = info.Workstep;
verifiedPart = vP; verifiedPart = info.Part;
verifyReferencePart = vRP; verifyReferencePart = info.VerifyReferencePart;
} }

View File

@ -254,7 +254,7 @@ namespace TBF
public string[] RemarkHistory; public string[] RemarkHistory;
[XmlIgnore] [XmlIgnore]
public int RemarksHistoryCount { get { return (RemarkHistory != null) ? RemarkHistory.Length : 0; } } public int RemarksHistoryCount { get { return (RemarkHistory != null) ? RemarkHistory.Length : 0; } }
/// Tester history /// Tester history
public string[] TesterHistory; public string[] TesterHistory;
[XmlIgnore] [XmlIgnore]
@ -293,6 +293,12 @@ namespace TBF
/// Backup values of Q2 pre-corrections from REST services (point.X = LR, point.Y = RL) /// Backup values of Q2 pre-corrections from REST services (point.X = LR, point.Y = RL)
public TracingDB.SerializableDictionary<int, Point> Q2PreCorrections; public TracingDB.SerializableDictionary<int, Point> Q2PreCorrections;
/// Production tracing
public string LastWorkflow;
public string LastWStep;
public TracingDB.SerializableDictionary<string, string> LastData;
[XmlArrayAttribute("RsltsClmnWidths")] [XmlArrayAttribute("RsltsClmnWidths")]
public int[] RsltsClmnWidths; public int[] RsltsClmnWidths;
[XmlIgnore] [XmlIgnore]

View File

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

View File

@ -374,6 +374,7 @@
<DependentUpon>FormForMechanicalMetersWithTracing.cs</DependentUpon> <DependentUpon>FormForMechanicalMetersWithTracing.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BenchControl\DataEntry\S620\ICheckItem.cs" /> <Compile Include="BenchControl\DataEntry\S620\ICheckItem.cs" />
<Compile Include="BenchControl\DataEntry\S620\ICycleBeginOrEndForm.cs" />
<Compile Include="BenchControl\DataEntry\S620\TestStartEndForm.cs"> <Compile Include="BenchControl\DataEntry\S620\TestStartEndForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

@ -21,9 +21,11 @@ namespace TracingDB
public static ISession Session; public static ISession Session;
/// <summary> Connection string for all sessions </summary>
static string connectionString; /// <summary>
/// /// Connection string for all sessions
/// </summary>
private static string connectionString;
public static string ConnectionString public static string ConnectionString
{ {
get { return connectionString; } get { return connectionString; }
@ -166,20 +168,20 @@ namespace TracingDB
/// <summary> /// <summary>
/// Get process of the last record with the reference part code equal to 'pcbNumber' /// Get process of the last good record with the reference part code equal to 'serialNumber'
/// </summary> /// </summary>
/// <param name="session">DB session</param> /// <param name="session">DB session</param>
/// <param name="pcbNumber">PCB number (code)</param> /// <param name="serialNumber">Serial number</param>
/// <returns>Process</returns> /// <returns>Workflow of the specified part</returns>
public static Process GetProcess(ISession session, string pcbNumber) public static Process GetWorkflow(ISession session, string serialNumber)
{ {
if (string.IsNullOrEmpty(pcbNumber)) return null; if (string.IsNullOrEmpty(serialNumber)) return null;
try try
{ {
/// Read all already existing reference records with Code==pcbNumber, referenceRecords[0] will be the most recent one /// Read all already existing reference records with Code==pcbNumber, referenceRecords[0] will be the most recent one
var referenceRecords = session.QueryOver<ReferenceRecord>() var referenceRecords = session.QueryOver<ReferenceRecord>()
.Where(rr => (rr.Code == pcbNumber && rr.Result == 0)) .Where(rr => ((rr.Code == serialNumber) && (rr.Result == 0)))
.OrderBy(rr => rr.TimeStamp).Desc .OrderBy(rr => rr.TimeStamp).Desc
.List(); .List();
@ -234,13 +236,11 @@ namespace TracingDB
workflowDict.Add(wf.Id, wf); workflowDict.Add(wf.Id, wf);
workflowStepsDict.Add(wf.Id, steps); workflowStepsDict.Add(wf.Id, steps);
Workstep step; ScanVerificationInfo info;
bool verifyRefPart; if ((steps.Count == 1) && ((info = TracingDB.DB.AnalyzeProcess(session, wf, steps[0])) != null))
Part verifiedPart;
if (steps.Count == 1 && TracingDB.DB.AnalyzeProcess(session, wf, steps[0], out step, out verifyRefPart, out verifiedPart))
{ {
verifInfos.Add(wf.Id, new ScanVerificationInfo(step, verifyRefPart, verifiedPart)); verifInfos.Add(wf.Id, info);
log.WarnFormat("Workflow {0} :: Verified step={1} part={2} verify ref. part={3}", wf, step, verifiedPart, verifyRefPart); log.WarnFormat("Workflow {0} :: Verified step={1} part={2} verify ref. part={3}", wf, info.Workstep, info.Part, info.VerifyReferencePart);
} }
} }
@ -257,23 +257,17 @@ namespace TracingDB
/// <param name="process">Process to be analyzed</param> /// <param name="process">Process to be analyzed</param>
/// <param name="workstep">Workstep to be analyzed</param> /// <param name="workstep">Workstep to be analyzed</param>
/// <returns>true if there is a verified workstep and part</returns> /// <returns>true if there is a verified workstep and part</returns>
public static bool AnalyzeProcess(ISession dbSession, Process process, Workstep workstep, out Workstep verifiedWorkstep, out bool verifyReferencePart, out Part verifiedPart) public static ScanVerificationInfo AnalyzeProcess(ISession dbSession, Process process, Workstep workstep)
{ {
verifiedWorkstep = null; /// Disable any verification
verifyReferencePart = true;
verifiedPart = null;
if (process == null || workstep == null) return false;
try try
{ {
if (workstep.ReferencePart != null) if (workstep != null && workstep.ReferencePart != null)
{ {
IList<Workstep> worksteps = dbSession.QueryOver<Workstep>() IList<Workstep> worksteps = dbSession.QueryOver<Workstep>()
.Where(x => (x.Process == process)) .Where(x => (x.Process == process))
.Where(x => (x.WorkstepNr < workstep.WorkstepNr)) .Where(x => (x.WorkstepNr < workstep.WorkstepNr))
.OrderBy(x => x.WorkstepNr).Asc .OrderBy(x => x.WorkstepNr).Asc
.List<Workstep>(); .List();
for (int i = worksteps.Count - 1; i >= 0; i--) for (int i = worksteps.Count - 1; i >= 0; i--)
{ {
@ -281,21 +275,16 @@ namespace TracingDB
{ {
if (worksteps[i].ReferencePart.Id == workstep.ReferencePart.Id) if (worksteps[i].ReferencePart.Id == workstep.ReferencePart.Id)
{ {
/// Enable checking reference part /// Compare reference part of the current workstep and reference part of another workstep
verifiedWorkstep = worksteps[i]; return new ScanVerificationInfo(worksteps[i], true, workstep.ReferencePart);
verifiedPart = workstep.ReferencePart;
verifyReferencePart = true;
return true;
} }
foreach (var thisStepPart in workstep.Parts) foreach (var thisStepPart in workstep.Parts)
{ {
if (worksteps[i].ReferencePart.Id == thisStepPart.Id) if (worksteps[i].ReferencePart.Id == thisStepPart.Id)
{ {
verifiedWorkstep = worksteps[i]; /// Compare (non-reference) part of the current workstep and reference part of another workstep
verifiedPart = worksteps[i].ReferencePart; return new ScanVerificationInfo(worksteps[i], true, worksteps[i].ReferencePart);
verifyReferencePart = true;
return true;
} }
} }
} }
@ -305,28 +294,19 @@ namespace TracingDB
bool isUnique = (part.CodeLocation == CodeLocation.OnPart) && ((part.CodeType == CodeType.UniqueNr) bool isUnique = (part.CodeLocation == CodeLocation.OnPart) && ((part.CodeType == CodeType.UniqueNr)
|| (part.CodeType == CodeType.FlowtubeNr) || (part.CodeType == CodeType.FlowtubeNr)
|| (part.CodeType == CodeType.FlowtubeNrLU)); || (part.CodeType == CodeType.FlowtubeNrLU));
if (isUnique) if (isUnique)
{ {
if (part.Id == workstep.ReferencePart.Id) if (part.Id == workstep.ReferencePart.Id)
{ {
/// Enable checking reference part /// Enable checking reference part
verifiedWorkstep = worksteps[i]; return new ScanVerificationInfo(worksteps[i], false, part); /// !!!!!!!!!!!!!!!!!!
verifiedPart = part;
verifyReferencePart = false;
log.ErrorFormat("AnalyzeProcess(session , {0}, {1}) returned 'true' : verWorkstep = {2}, verPart = {3}, verRefPart = {4}",
process.Name, workstep.Name);
return true;
} }
foreach (var thisStepPart in workstep.Parts) foreach (var thisStepPart in workstep.Parts)
{ {
if (part.Id == thisStepPart.Id) if (part.Id == thisStepPart.Id)
{ {
verifiedWorkstep = worksteps[i]; return new ScanVerificationInfo(worksteps[i], false, part);
verifiedPart = part;
verifyReferencePart = false;
return true;
} }
} }
} }
@ -334,13 +314,15 @@ namespace TracingDB
} }
} }
log.ErrorFormat("AnalyzeProcess(session , {0}, {1}) returned 'false'", process.Name, workstep.Name); log.ErrorFormat("AnalyzeProcess(session , {0}, {1}) no ver. info found, returning 'null'",
return false; (process != null) ? process.Name : "null",
(workstep != null) ? workstep.Name : "null");
return null;
} }
catch (Exception exc) catch (Exception exc)
{ {
log.ErrorFormat("AnalyzeProcess(session , {0}, {1}) failed : {2}", process.Name, workstep.Name, exc.Message); log.ErrorFormat("AnalyzeProcess(session , {0}, {1}) failed : {2}", process.Name, workstep.Name, exc.Message);
return false; return null;
} }
} }

View File

@ -1,16 +1,17 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Common")] [assembly: AssemblyTitle("Production Monitoring")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")] [assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2015-2018 Sensus Slovensko, a.s.")] [assembly: AssemblyCopyright("Copyright © 2015-2021 Sensus Slovensko, a.s.")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -34,3 +35,4 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.110.0")] [assembly: AssemblyVersion("2.1.110.0")]
[assembly: AssemblyFileVersion("2.1.110.0")] [assembly: AssemblyFileVersion("2.1.110.0")]
[assembly: NeutralResourcesLanguageAttribute("")]