Possibility to bypass "production tracing check" for a selected number of cycles, ver. 2.33.2104

This commit is contained in:
Milan Hanajik 2023-09-25 14:38:43 +02:00
parent 2ba6586a0e
commit 068b7fb3a2
10 changed files with 313 additions and 31 deletions

View File

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

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 {
@ -2274,6 +2274,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>
@ -5091,6 +5100,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 +5442,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 +6282,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>

View File

@ -1683,4 +1683,13 @@
<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>
</root>

View File

@ -2314,4 +2314,16 @@
<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>
</root>

19
TBF/Rig/DataChangeArgs.cs Normal file
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;
}
}
}

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

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
{
@ -91,7 +88,9 @@ namespace TBF.Rig.Output.DB.ProductionTracing
Workstep verifiedWorkstep;
Part verifiedPart; /// Applicable when verifyReferencePart == false
bool verifyReferencePart;
int CyclesToSkip;
public Tracing() {}
@ -137,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
@ -145,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
///
@ -242,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

View File

@ -2,18 +2,23 @@
/// 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,14 +39,24 @@ 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
@ -106,9 +121,27 @@ namespace TBF.Rig.Output.DB.ProductionTracing
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;
}
@ -141,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
}
}

View File

@ -40,6 +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.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
@ -125,10 +134,90 @@ namespace TBF.Rig.Output.DB.ProductionTracing
this.netAdapterComboBox.Size = new System.Drawing.Size(435, 21);
this.netAdapterComboBox.TabIndex = 8;
//
// cyclesToBypassTextBox
//
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;
//
// setCyclesToBypassButton
//
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.unlockBypassButton);
this.Controls.Add(this.bypassGroupBox);
this.Controls.Add(this.netAdapterComboBox);
this.Controls.Add(this.netAdapterLabel);
this.Controls.Add(this.saveTracingRecordsCheckBox);
@ -139,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();
@ -157,5 +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 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;
}
}

View File

@ -187,6 +187,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" />