diff --git a/AppDiagnostic/App.config b/AppDiagnostic/App.config index 3bedfc101..7f5eaea7b 100644 --- a/AppDiagnostic/App.config +++ b/AppDiagnostic/App.config @@ -1,18 +1,19 @@ - + - + - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/AppDiagnostic/Properties/Resources.Designer.cs b/AppDiagnostic/Properties/Resources.Designer.cs index 5f4bc8a07..1b5dfe715 100644 --- a/AppDiagnostic/Properties/Resources.Designer.cs +++ b/AppDiagnostic/Properties/Resources.Designer.cs @@ -1,16 +1,17 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace AppDiagnostic.Properties { - using System; - - +namespace AppDiagnostic.Properties +{ + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -21,40 +22,48 @@ namespace AppDiagnostic.Properties { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - + internal class Resources + { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { + internal Resources() + { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AppDiagnostic.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { + internal static global::System.Globalization.CultureInfo Culture + { + get + { return resourceCulture; } - set { + set + { resourceCulture = value; } } diff --git a/AppDiagnostic/Properties/Settings.Designer.cs b/AppDiagnostic/Properties/Settings.Designer.cs new file mode 100644 index 000000000..10069d35f --- /dev/null +++ b/AppDiagnostic/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AppDiagnostic.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/OpticalHeadTest.cs b/TBF/Rig/TestMethods/iPerlCommunication/OpticalHeadTest.cs new file mode 100644 index 000000000..3edaced4e --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/OpticalHeadTest.cs @@ -0,0 +1,131 @@ +using Config.Resources; +using log4net; +using Sensus.iPerl.RfidCom.Helper; +using Sensus.iPerl.RfidCom.Services; +using Sensus.iPerl.RfidCom.Structures; +using System; +using System.Threading; +using TBF.Rig.Hart.Common; +using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead; +using static Sensus.iPerl.NfcHandler.MCI_Protocol; + +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"; + return "Error Open Sealing"; + } + + internal static string ReadRequest_PCB(IperlHead iHead) + { + try + { + byte[] pcb = null; + int readRetVal = iPerlCommunicationForm.ReadRequestPort(iHead, MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb); + if (readRetVal == 0) + { + 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) + { + return (ex.Message.ToString()); + } + } + + internal static string SetActiveMode(IperlHead iHead) + { + byte[] cmd = new byte[1] { (byte)Command.SetActiveMode }; + if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd)) + { + return "OK"; + } + else + { + return "Error Set Active Mode"; + } + } + + internal static string SetTestMode(IperlHead iHead) + { + byte[] cmd = new byte[1] { (byte)Command.SetTestMode }; + if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd)) + { + return "OK"; + } + else + { + return "Error Set Test Mode"; + } + } + +#if IPERL + internal static string TurnOffRadio(IperlHead iHead) + { + try + { + int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval + return 0 == retValue ? "OK" : "Error"; + } + catch (Exception ex) + { + return (ex.Message.ToString()); + } + } + + internal static string SetProductionMode(IperlHead iHead) + { + try + { + int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status + return 0 == retValue ? "OK" : "Error"; + } + catch (Exception ex) + { + return (ex.Message.ToString()); + } + } + + internal static string WriteRequestPort_u8_Customer_Text(IperlHead iHead) + { + string custText = "FF0123456789ABCDEF"; // Sample text to test write function + /*try + { + byte[] cmd = RfidHelper.HexStringToByteArray(custText); + if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.RadioParams, 0x1899, 9, cmd)) + { + 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(Params.u8_Customer_Text).ToString(); + } + } + catch (Exception ex) + { + return (ex.Message.ToString()); + }*/ + return $"Error COM{iHead.RfidComPortNr}"; + } + + internal static string SetRfidMode(IperlHead iHead) + { + iHead.SetRfidInterface(); + iHead.SetCommunicationInterface(CommunicationInterface.RFID); + return ($"OK - {Strings.Program_restart_is_required_to_apply_some_settings}"); + } + + internal static string SetNfcMode(IperlHead iHead) + { + iHead.SetNfcInterface(); + iHead.SetCommunicationInterface(CommunicationInterface.NFC); + return ($"OK - {Strings.Program_restart_is_required_to_apply_some_settings}"); + } +#endif /// IPERL + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/SequenceConditionOp.cs b/TBF/Rig/TestMethods/iPerlCommunication/SequenceConditionOp.cs new file mode 100644 index 000000000..cc9319161 --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/SequenceConditionOp.cs @@ -0,0 +1,44 @@ +/// +/// Copyright (c) 2022 Sensus Slovensko a.s. +/// +using TBF.Resources; + +namespace TBF.Rig.TestMethods.iPerlCommunication +{ + public enum ConditionID + { + A, + B, + C, + Count, + } + + public class SequenceConditionOp : IOperation + { + public const string ConditionNameFmt = "iPERL communication milestone {0}"; + + ConditionID id; + TestMethod testMethodComponent; + + public SequenceConditionOp(TestMethod testMethodComponent, ConditionID id) + { + this.testMethodComponent = testMethodComponent; + this.id = id; + } + + public void Start() { } + + public Event Run() + { + bool conditionMet = testMethodComponent.IperlCommMilestone[(int)id]; + return conditionMet ? Event.ConditionMet : Event.ConditionNotMet; + } + + public void Stop() { } + + public override string ToString() + { + return string.Format(ConditionNameFmt, id); + } + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.Designer.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.Designer.cs new file mode 100644 index 000000000..9e0f9487c --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.Designer.cs @@ -0,0 +1,137 @@ +namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead +{ + partial class IperlHeadTestCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.optoTestGroupBox = new System.Windows.Forms.GroupBox(); + this.optoListBox = new System.Windows.Forms.ListBox(); + this.rfidOutputListBox = new System.Windows.Forms.ListBox(); + this.RfidTestGroupBox = new System.Windows.Forms.GroupBox(); + this.label2 = new System.Windows.Forms.Label(); + this.rfidCommandComboBox = new System.Windows.Forms.ComboBox(); + this.commandTestButton = new System.Windows.Forms.Button(); + this.optoTestGroupBox.SuspendLayout(); + this.RfidTestGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // optoTestGroupBox + // + this.optoTestGroupBox.Controls.Add(this.optoListBox); + this.optoTestGroupBox.Location = new System.Drawing.Point(5, 4); + this.optoTestGroupBox.Name = "optoTestGroupBox"; + this.optoTestGroupBox.Size = new System.Drawing.Size(591, 161); + this.optoTestGroupBox.TabIndex = 2; + this.optoTestGroupBox.TabStop = false; + this.optoTestGroupBox.Text = "Opto-data"; + // + // optoListBox + // + this.optoListBox.FormattingEnabled = true; + this.optoListBox.ItemHeight = 16; + this.optoListBox.Location = new System.Drawing.Point(7, 22); + this.optoListBox.Name = "optoListBox"; + this.optoListBox.Size = new System.Drawing.Size(573, 132); + this.optoListBox.TabIndex = 0; + // + // rfidOutputListBox + // + this.rfidOutputListBox.FormattingEnabled = true; + this.rfidOutputListBox.ItemHeight = 16; + this.rfidOutputListBox.Location = new System.Drawing.Point(5, 54); + this.rfidOutputListBox.Name = "rfidOutputListBox"; + this.rfidOutputListBox.SelectionMode = System.Windows.Forms.SelectionMode.None; + this.rfidOutputListBox.Size = new System.Drawing.Size(575, 164); + this.rfidOutputListBox.TabIndex = 3; + // + // RfidTestGroupBox + // + this.RfidTestGroupBox.Controls.Add(this.rfidOutputListBox); + this.RfidTestGroupBox.Controls.Add(this.label2); + this.RfidTestGroupBox.Controls.Add(this.rfidCommandComboBox); + this.RfidTestGroupBox.Controls.Add(this.commandTestButton); + this.RfidTestGroupBox.Location = new System.Drawing.Point(5, 171); + this.RfidTestGroupBox.Name = "RfidTestGroupBox"; + this.RfidTestGroupBox.Size = new System.Drawing.Size(591, 224); + this.RfidTestGroupBox.TabIndex = 3; + this.RfidTestGroupBox.TabStop = false; + this.RfidTestGroupBox.Text = "RFID / NFC data"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(2, 25); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(69, 16); + this.label2.TabIndex = 2; + this.label2.Text = "Command"; + // + // rfidCommandComboBox + // + this.rfidCommandComboBox.FormattingEnabled = true; + this.rfidCommandComboBox.Location = new System.Drawing.Point(86, 19); + this.rfidCommandComboBox.Name = "rfidCommandComboBox"; + this.rfidCommandComboBox.Size = new System.Drawing.Size(341, 24); + this.rfidCommandComboBox.TabIndex = 1; + // + // commandTestButton + // + this.commandTestButton.Location = new System.Drawing.Point(449, 19); + this.commandTestButton.Name = "commandTestButton"; + this.commandTestButton.Size = new System.Drawing.Size(126, 24); + this.commandTestButton.TabIndex = 0; + this.commandTestButton.Text = "Send command"; + this.commandTestButton.UseVisualStyleBackColor = true; + this.commandTestButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.CommandTestButtonClick); + // + // IperlHeadTestCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.optoTestGroupBox); + this.Controls.Add(this.RfidTestGroupBox); + this.Name = "IperlHeadTestCtrl"; + this.Size = new System.Drawing.Size(611, 432); + this.Load += new System.EventHandler(this.UserControl_Load); + this.optoTestGroupBox.ResumeLayout(false); + this.RfidTestGroupBox.ResumeLayout(false); + this.RfidTestGroupBox.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox optoTestGroupBox; + private System.Windows.Forms.ListBox rfidOutputListBox; + private System.Windows.Forms.GroupBox RfidTestGroupBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox rfidCommandComboBox; + private System.Windows.Forms.Button commandTestButton; + private System.Windows.Forms.ListBox optoListBox; + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs new file mode 100644 index 000000000..69e82e0ca --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs @@ -0,0 +1,189 @@ +using System; +using System.Threading; +using System.Web.UI.WebControls; +using System.Windows.Forms; +using TBF.Rig.Sequences; + +namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead +{ + public partial class IperlHeadTestCtrl : UserControl + { + IperlHeadCfg config; + IperlHead iPerlHead; + Thread optoThread; + + private bool stopWorkerThread; + public event EventHandler OptoReceivedHandler; + + public IperlHeadTestCtrl(IperlHeadCfg config) + { + this.config = config; + InitializeComponent(); + if (config == null) return; + + iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default values for iPerlCommunication + + foreach(var head in ProcessData.IperlHeads) + { + if (head != null && head.Name == config.Name) { iPerlHead = head; } + } + + rfidCommandComboBox.DisplayMember = "Name"; + rfidCommandComboBox.ValueMember = "Value"; + var items = new[] + { + new {Name = "Read PCB", Value = "ReadPCB" }, + new {Name = "Set Test Mode", Value = "SetTestMode" }, + new {Name = "Set Active Mode", Value = "SetActiveMode" }, +#if DEBUG + new {Name = "Start Read Opto Data", Value = "ReadOptoData" }, + new {Name = "Stop Read Opto Data", Value = "StopReadOptoData" }, +#endif + new {Name = " ", Value = "" }, + new {Name = "Reset NFC Head", Value = "ResetNfcHead" }, + new {Name = "Set NFC Head Interface", Value = "SetNfcHead" }, + new {Name = "Set RFID Head interface", Value = "SetRfidHead" } + }; + /* + // CTRL+ALT+double click - hidden poweruser menu + if (((Keyboard.ModifierKeys & Keys.Control) == Keys.Control) && ((Keyboard.ModifierKeys & Keys.Alt) == Keys.Alt) && Users.CurrentUser.AuthorizedAs == AuthorizedAs.PowerUser) + { + Array.Resize(ref items, items.Length + 1); + items[items.Length - 1] = new { Name = "Kluc", Value = "Kluc" }; + } + */ + rfidCommandComboBox.DataSource = items; + + stopWorkerThread = false; + + OptoReceivedHandler += (EventHandler)((sndr, args) => + { + if (this.InvokeRequired) + this.Invoke((Delegate)new EventHandler(this.OnOptoReceived2), sndr, (object)args); + else + this.OnOptoReceived2(sndr, args); + }); + } + + public void OnOptoReceived2(object sender, OptoReceivedEventArgs args) + { + optoListBox.Items.Insert(0,args.Data); + } + + private void CommandTestButtonClick(object sender, MouseEventArgs e) + { + rfidOutputListBox.Items.Clear(); + + using (Tools.LogChecker logChecker = new Tools.LogChecker("RfidData", log4net.Core.Level.Debug)) + { + ListItem rfidListItem = new ListItem(); + rfidListItem.Attributes.Add("style", "font-weight:bold"); + switch (rfidCommandComboBox.SelectedValue) + { + case "ReadPCB": + rfidListItem.Text = $"PCB: {OpticalHeadTest.ReadRequest_PCB(iPerlHead)}"; + break; + case "SetTestMode": + rfidListItem.Text = OpticalHeadTest.SetTestMode(iPerlHead); + optoListBox.Items.Clear(); + stopWorkerThread = false; + optoThread = new Thread(OptoWorker); + if (!optoThread.IsAlive) + { + iPerlHead.StartDataStreamProcessing(); // open opto port + optoThread.Start(); + } + break; + case "SetActiveMode": + rfidListItem.Text = OpticalHeadTest.SetActiveMode(iPerlHead); + stopWorkerThread = true; + iPerlHead.StopDataStreamProcessing(); // close opto port + break; + case "ResetNfcHead": + iPerlHead.ResetNfcInterface(); + break; + case "SetNfcHead": + iPerlHead.SetNfcInterface(); + break; + case "SetRfidHead": + iPerlHead.SetRfidInterface(); + break; + case "ReadOptoData": + optoListBox.Items.Clear(); + stopWorkerThread = false; + optoThread = new Thread(OptoWorker); + if (optoThread.IsAlive) + { + stopWorkerThread = true; + iPerlHead.StopDataStreamProcessing(); // close opto port + } + if (!optoThread.IsAlive) + { + iPerlHead.StartDataStreamProcessing(); // open opto port + optoThread.Start(); + } + break; + case "StopReadOptoData": + stopWorkerThread = true; + iPerlHead.StopDataStreamProcessing(); // close opto port + break; + } + rfidOutputListBox.Items.Add(rfidListItem); + rfidOutputListBox.Items.AddRange(logChecker.Messages.ToArray()); + } + } + + private void OptoWorker() + { + while (!this.stopWorkerThread) + { + Thread.Sleep(250); + if (this.stopWorkerThread) + break; + + try + { + string buffer = iPerlHead.ReadOptoData(); + if (string.IsNullOrEmpty(buffer)) + { + this.OnOptoReceived((object)this, new OptoReceivedEventArgs(".")); + } + else + OnOptoReceived((object)this, new OptoReceivedEventArgs(buffer)); + } + catch (Exception ex) + { + this.OnOptoReceived((object)this, new OptoReceivedEventArgs(ex.Message)); + } + } + } + + public void OnOptoReceived(object sender, OptoReceivedEventArgs args) + { + if (this.OptoReceivedHandler == null) + return; + try + { + this.OptoReceivedHandler(sender, args); + } + catch (Exception ex) + { + } + } + + private void UserControl_Load(object sender, EventArgs e) + { + this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing); + } + + void ParentForm_FormClosing(object sender, FormClosingEventArgs e) + { + //OnHandleDestroyed(new EventArgs()); + stopWorkerThread = true; + if (optoThread != null) + { + optoThread.Abort(); + } + } + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.resx b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.resx new file mode 100644 index 000000000..d58980a38 --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/NfcServices.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/NfcServices.cs new file mode 100644 index 000000000..41fd422c4 --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/NfcServices.cs @@ -0,0 +1,315 @@ +using log4net; +using Sensus.iPerl.NfcHandler; +using Sensus.iPerl.RfidCom.Exceptions; +using System; +using System.Globalization; +using System.Text; +using System.Threading; +using static Sensus.iPerl.NfcHandler.MCI_Protocol; + +namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead +{ + internal class NfcServices + { + protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData"); + internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer) + { + for (int i = 0; i < cfg.MaxCommRetries; i++) + { + + NfcDataHandler _nfcDataHandler = new NfcDataHandler(); + MessageEventHandlers(_nfcDataHandler); + CR95HF_MessageEventHandlers(_nfcDataHandler._CR95HF_Reader); + ST25DV_MessageEventHandlers(_nfcDataHandler._ST25DV_Device); + MCI_MessageEventHandlers(_nfcDataHandler._MCI_Protocol); + NFCHeadConfig_MessageEventHandlers(_nfcDataHandler._NFCHead_Config); + try + { + rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} ReadRequest : {structName}, {offset}, {length}"); + OpenConnection(_nfcDataHandler, cfg, iperlHead); + + buffer = MciRead(_nfcDataHandler, cfg, structName, (ushort)offset, length); + _nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference + + CloseComPort(_nfcDataHandler); + + rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} ReadRequest : {structName}, {offset}, {length} ; Response= {ByteArrayToHexString(buffer)} ; Error: {_nfcDataHandler.LastErrorMessage}"); + + if (_nfcDataHandler.LastErrorCode != 0) + { + throw new RfidValidationException(_nfcDataHandler.LastErrorMessage); + } + + return Convert.ToInt32(_nfcDataHandler.LastErrorCode); //return 0; + } + catch (RfidValidationException) + { + Thread.Sleep(cfg.WaitTimeAfterFailure); + } + catch (Exception ex) + { + rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} ReadRequest Error: {ex.Message}"); + buffer = new byte[length]; + return 3; + } + } + buffer = new byte[length]; + return 3; + } + + internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, byte[] buffer) + { + NfcDataHandler _nfcDataHandler = new NfcDataHandler(); + MessageEventHandlers(_nfcDataHandler); + CR95HF_MessageEventHandlers(_nfcDataHandler._CR95HF_Reader); + ST25DV_MessageEventHandlers(_nfcDataHandler._ST25DV_Device); + MCI_MessageEventHandlers(_nfcDataHandler._MCI_Protocol); + NFCHeadConfig_MessageEventHandlers(_nfcDataHandler._NFCHead_Config); + try + { + rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} WriteRequest : {structName}, {offset}, {length}, {ByteArrayToHexString(buffer)}"); + OpenConnection(_nfcDataHandler, cfg, iperlHead); + + MciWrite(_nfcDataHandler, cfg, structName, (ushort)offset, length, buffer); + _nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference + + CloseComPort(_nfcDataHandler); + return 0; + } + catch (Exception ex) + { + rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} WriteRequest Error: {ex.Message}"); + return 3; + } + } + + private static void OpenConnection(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, IperlHead iperlHead) + { + string comPort = $"COM{iperlHead.RfidComPortNr}"; + int retryCount = 0 ; + Open: + nfcDataHandler.Close(); + Thread.Sleep(100); + if (nfcDataHandler.OpenConnection(comPort, cfg.BaudRate, cfg.DataBits, cfg.ParityBit, cfg.StopBits)) + { + rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} Port Open"); + + if (nfcDataHandler.ConnectReader()) + { + rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} Reader connected"); + if (!nfcDataHandler.ConnectDevice()) + { + rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect device."); + for (int i = 0; i < cfg.MaxCommRetries; i++) + { + if (nfcDataHandler.Echo()) break; + } + } + } + else + { + retryCount++; + rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect reader. Reconnect comport {retryCount}"); + if (retryCount < cfg.MaxCommRetries) + { + nfcDataHandler.Close(); + iperlHead.ResetNfcInterface(); // reset NFC head via optoport - switch to RFID and back to NFC interface + goto Open; + } + } + } + else + rfidDataLogger.Error($"Open NFC COM{iperlHead.RfidComPortNr} Port Failed"); + } + + private static void CloseComPort(NfcDataHandler nfcDataHandler) + { + nfcDataHandler.Close(); + } + + private static byte[] MciRead(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, StructName structName, ushort offset, int length) + { + bool isReadValues = false; + int retryCount = 0; + Read: + try + { + isReadValues = false; + long num1 = (long)length; + int timeoutMs = 4000; + byte payloadlength = Convert.ToByte(num1.ToString("X2"), 16); + if (nfcDataHandler.MCI_Read(structName, offset, payloadlength, timeoutMs)) + { + byte[] lastData = nfcDataHandler.LastData; + if ((long)lastData.Length >= num1) + { + rfidDataLogger.Info($"COM: MciRead ({structName},{offset},{length}) = {ByteArrayToHexString(lastData)}"); + return lastData; + } + else + rfidDataLogger.Info($"COM: MciRead ({structName},{offset},{length}) = {ByteArrayToHexString(lastData)}"); + } + else if (nfcDataHandler.LastErrorCode == (byte)0) + { + rfidDataLogger.Info($"MCI Error: Unidentified"); + retryCount++; + if (retryCount < cfg.MaxCommRetries) + goto Read; + } + else + { + rfidDataLogger.Info("Last error message: " + nfcDataHandler.LastErrorMessage); + retryCount++; + if (retryCount < cfg.MaxCommRetries) + goto Read; + } + } + catch (Exception ex) + { + rfidDataLogger.Error("MciRead Last error message: " + ex.Message); + retryCount++; + if (retryCount < cfg.MaxCommRetries) + goto Read; + } + return new byte[length]; + } + + private static void MciWrite(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, MCI_Protocol.StructName structName, ushort offset, int length, byte[] payload) + { + int retryCount = 0; + Write: + try + { + long num1 = (long)length; + int timeoutMs = 4000; + byte payloadlength = Convert.ToByte(num1); + if ((int)payloadlength != payload.Length) + rfidDataLogger.Error("Insufficient Payload -- Payload lenth : " + (object)payload.Length); + else if (nfcDataHandler.MCI_Write(structName, offset, payloadlength, payload, timeoutMs)) + { + // OK + } + else if (nfcDataHandler.LastErrorCode > (byte)0) + { + rfidDataLogger.Error("Last error message: " + nfcDataHandler.LastErrorMessage); + //int num2 = (int)MessageBox.Show(this._nfcDataHandler.LastErrorMessage); + } + } + catch (Exception ex) + { + rfidDataLogger.Error("MciWrite error message: " + ex.Message); + retryCount++; + if (retryCount < cfg.MaxCommRetries) + goto Write; + } + } + + private static void MciWriteCommand(NfcDataHandler nfcDataHandler, byte commandcode) + { + try + { + ushort offset = 0; + int timeoutMs = 4000; + byte payloadlength = 1; + byte[] payload = new byte[1] { commandcode }; + if (nfcDataHandler.MCI_Write(MCI_Protocol.StructName.Command, offset, payloadlength, payload, timeoutMs) || nfcDataHandler.LastErrorCode <= (byte)0) + return; + rfidDataLogger.Error("MciWriteCommand Last error message: " + nfcDataHandler.LastErrorMessage); + } + catch (Exception ex) + { + rfidDataLogger.Error("MciWriteCommand Last error message: " + ex.Message); + } + } + + public static string ByteArrayToHexString(byte[] data) + { + StringBuilder stringBuilder = new StringBuilder(); + foreach (byte num in data) + stringBuilder.Append(num.ToString("X2")); + return stringBuilder.ToString(); + } + + private static byte[] BuildPayLoad(string strPayLoad, int length) + { + byte[] collection; + + if (strPayLoad.Split(':').Length > 1) + { + uint timestamp = ConvertDateTimeToTimestamp(Convert.ToDateTime(DateTime.ParseExact(strPayLoad, "HH:mm:ss dd/MM/yyyy", (IFormatProvider)CultureInfo.InvariantCulture))); + byte[] bytes = BitConverter.GetBytes(timestamp); + return bytes; + } + else if (strPayLoad.Split(',').Length > 1) + { + string[] strArray = strPayLoad.Split(','); + collection = new byte[strArray.Length]; + for (int index3 = 0; index3 < strArray.Length; ++index3) + collection[index3] = Convert.ToByte(strArray[index3], 16); + return collection; + } + else + { + //int num = strPayLoad.Split(',').Length; + collection = HexStringToByteArray(strPayLoad.Substring(strPayLoad.Length - length * 2).ToUpper()); + Array.Reverse((Array)collection); + return collection; + } + } + + public static byte[] HexStringToByteArray(string hexString) + { + int length = hexString.Length; + byte[] byteArray = new byte[length / 2]; + for (int startIndex = 0; startIndex < length; startIndex += 2) + byteArray[startIndex / 2] = Convert.ToByte(hexString.Substring(startIndex, 2), 16); + return byteArray; + } + + private static uint ConvertDateTimeToTimestamp(DateTime datetime) + { + TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); + return (uint)((datetime - new DateTime(2000, 1, 1, 0, 0, 0).ToLocalTime()).TotalSeconds + utcOffset.TotalSeconds); + } + + #region EventHandlers + public static void MCI_MessageEventHandlers(MCI_Protocol e) + { + DelNfc_MCI_MessageHandler mciMessageHandler = new DelNfc_MCI_MessageHandler(OnHandler); + e.MessageEvent += mciMessageHandler; + } + + public static void ST25DV_MessageEventHandlers(ST25DV_Device e) + { + DelNfc_ST25DV_MessageHandler dvMessageHandler = new DelNfc_ST25DV_MessageHandler(OnHandler); + e.MessageEvent += dvMessageHandler; + } + + public static void CR95HF_MessageEventHandlers(CR95HF_Reader e) + { + DelNfc_CR95HF_MessageHandler hfMessageHandler = new DelNfc_CR95HF_MessageHandler(OnHandler); + e.MessageEvent += hfMessageHandler; + } + + public static void NFCHeadConfig_MessageEventHandlers(NFCHeadConfig e) + { + DelNfc_NFCHeadConfig_MessageHandler configMessageHandler = new DelNfc_NFCHeadConfig_MessageHandler(OnHandler); + e.MessageEvent += configMessageHandler; + } + + public static void MessageEventHandlers(NfcDataHandler e) + { + DelNfcMessageHandler nfcMessageHandler = new DelNfcMessageHandler(OnHandler); + e.MessageEvent += nfcMessageHandler; + } + + public static void OnHandler(object sender, NfcMessageEventArgs e) + { + if (e.Message == null) + return; + string message = e.Message.Replace("\n", " ").Replace("\r", ""); + rfidDataLogger.Debug(message); + } + #endregion + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/RfidServices.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/RfidServices.cs new file mode 100644 index 000000000..714697af5 --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/RfidServices.cs @@ -0,0 +1,123 @@ +using Sensus.iPerl.RfidCom.Exceptions; +using Sensus.iPerl.RfidCom.Helper; +using Sensus.iPerl.RfidCom; +using System; +using System.Text.RegularExpressions; +using System.Threading; +using log4net; + +namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead +{ + internal class RfidServices + { + protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData"); + private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm)); + + internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer) + { + for (int i = 0; i < cfg.MaxCommRetries; i++) + { + rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} reading: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},{offset}, {length}... timeout {cfg.CommTimeout})"); + using (RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}")) + { + try + { + byte[] response = writer.ReadRequest((byte)messageID, offset, length, cfg.CommTimeout); + string hexString = RfidHelper.ConvertByteArrayToHexString(response); + string swapHexString = RfidHelper.SwapHexcode(hexString); + string decString = RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(hexString)).ToString(); + + if (length > 10) + { + //if the result only contains "00"s we are working on the wrong COM port + // or the module just isn't connected + if (Regex.IsMatch(hexString, @"^(00)\1+$")) + { + rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) <- Error: No RFID signal."); + throw new RfidValidationException("Error_Rfid_NoSignal"); + } + + //if the result only contains "03"s the meter did not answer. + // Might be due to the module being positioned incorrectly. + if (Regex.IsMatch(hexString, @"^(03)\1+$")) + { + rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) <- Error: No meter signal."); + throw new RfidValidationException("Error_Rfid_NoAnswerFromMeter"); + } + } + + writer.ClosePort(); + buffer = response; + rfidDataLogger.Info($"{iperlHead.Name} ({iperlHead.SerialNr}): ReadRequestPort(COM{iperlHead.RfidComPortNr},...) returned HEX: {hexString}; SwapHexCodeToDecimal: {decString}"); + return 0; + } + catch (RfidDataNotAvailableException) + { + if (/*RfidHelper.IsPassThrough(messageID)*/ messageID == MessageID.ASICRegisterReadTest || messageID == MessageID.RadioPassthrough) + { + rfidDataLogger.Info($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {(i > 0 ? "<- Error: Invalid Pass-Through data." : "<- Info: Wait for Pass-Through data.")}"); + Thread.Sleep(cfg.PassThroughWaitTime); + } + else + { + Thread.Sleep(cfg.WaitTimeAfterFailure); + } + } + catch (RfidValidationException) + { + Thread.Sleep(cfg.WaitTimeAfterFailure); + } + catch (Exception ex) + { + rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {ex.Message}"); + Thread.Sleep(cfg.WaitTimeAfterFailure); + } + } + } + rfidDataLogger.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)"); + log.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)"); + buffer = new byte[length]; + return 3; + } + + internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer) + { + RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}"); + string payload = RfidHelper.ConvertByteArrayToHexString(buffer); + + for (var i = 0; i < cfg.MaxCommRetries; i++) + { + rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} writting: COM{iperlHead.RfidComPortNr}: WriteRequest ({messageID},{offset}, {length}, {payload}... timeout {cfg.CommTimeout})"); + try + { + if (writer.ClosePort()) writer.OpenPort(); + writer.WriteRequest((byte)messageID, offset, length, buffer, cfg.CommTimeout, false); + writer.ClosePort(); + rfidDataLogger.InfoFormat($"{iperlHead.Name}({iperlHead.SerialNr},COM{iperlHead.RfidComPortNr}): WriteRequestPort({messageID}, {offset}, {length}, {payload})"); + return 0; + } + catch (Exception ex) + { + if (messageID == MessageID.RadioPassthrough || messageID == MessageID.ASICRegisterReadTest) + { + 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(); + } + } + } + } + writer.ClosePort(); + rfidDataLogger.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}"); + log.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}"); + return 2; + } + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/SimulationServices.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/SimulationServices.cs new file mode 100644 index 000000000..5f6b46b69 --- /dev/null +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/SimulationServices.cs @@ -0,0 +1,61 @@ +using System; +using System.Linq; + +namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead +{ + internal class SimulationServices + { + const int Q2CorrFactorsAddr = 0x1878; + + internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer) + { + byte[] configurationBuffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + byte[] calibrationBuffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 }; + buffer = new byte[length]; + + if (messageID == MessageID.Configuration) + { + Array.Copy(GetPCB(iperlHead), 0, configurationBuffer, 16, 5); // set PCB Number according to iPerlHead configuration + Array.Copy(configurationBuffer,offset,buffer,0,length); + } + else if (messageID == MessageID.Calibration) + { + Array.Copy(calibrationBuffer, offset, buffer, 0, length); + } + else if ((messageID == MessageID.MetrologyMemory) && (offset == Q2CorrFactorsAddr) && (length == 2)) + { + buffer = new byte[2] { 0, 0 }; + } + else + { + buffer = new byte[length]; + } + + return iperlHead.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13 + } + + internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer) + { + return 0; + } + + private static Array GetPCB(IperlHead iperlHead) + { + string pcbStr = iperlHead.RfidComPortNr.ToString().PadRight(10,'0') + iperlHead.Position.ToString("D2"); + long decVal = Convert.ToInt64(pcbStr); + string nHexStr = decVal.ToString("X4"); + + string hexStr = ""; + for (int a = nHexStr.Length; a >= 1; a = a - 2) + { + hexStr = hexStr + nHexStr.Substring(a - 2, 2); + } + + return Enumerable.Range(0, hexStr.Length) + .Where(x => x % 2 == 0) + .Select(x => Convert.ToByte(hexStr.Substring(x, 2), 16)) + .ToArray(); + + } + } +} diff --git a/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.designer.cs b/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.designer.cs new file mode 100644 index 000000000..2b24c92ce --- /dev/null +++ b/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.designer.cs @@ -0,0 +1,581 @@ +/// +/// Copyright (c) 2021 Sensus Metering Systems +/// +namespace TBF.Rig.Uni.RegValveLowRegulTimeSaturation +{ + partial class RegValveCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.positionTextBox = new System.Windows.Forms.TextBox(); + this.positionLabel = new System.Windows.Forms.Label(); + this.parentNameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.adcClosedLabel = new System.Windows.Forms.Label(); + this.adcClosedTextBox = new System.Windows.Forms.TextBox(); + this.adcOpenTextBox = new System.Windows.Forms.TextBox(); + this.adcOpenLabel = new System.Windows.Forms.Label(); + this.parentNameComboBox = new System.Windows.Forms.ComboBox(); + this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox(); + this.stableTimeTextBox = new System.Windows.Forms.TextBox(); + this.stableTimeLabel = new System.Windows.Forms.Label(); + this.flowStableSecTextBox = new System.Windows.Forms.TextBox(); + this.flowStableSecLabel = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.setButton1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.ADC = new System.Windows.Forms.Label(); + this.getButton1 = new System.Windows.Forms.Button(); + this.pctTextBox1 = new System.Windows.Forms.TextBox(); + this.adcTextBox1 = new System.Windows.Forms.TextBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.setButton2 = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.getButton2 = new System.Windows.Forms.Button(); + this.pctTextBox2 = new System.Windows.Forms.TextBox(); + this.adcTextBox2 = new System.Windows.Forms.TextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.closeButton = new System.Windows.Forms.Button(); + this.openButton = new System.Windows.Forms.Button(); + this.adcTextBox = new System.Windows.Forms.TextBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.label4 = new System.Windows.Forms.Label(); + this.categoryComboBox = new System.Windows.Forms.ComboBox(); + this.categoryLabel = new System.Windows.Forms.Label(); + this.unitsComboBox = new System.Windows.Forms.ComboBox(); + this.unitsLabel = new System.Windows.Forms.Label(); + this.formatTextBox = new System.Windows.Forms.TextBox(); + this.formatLabel = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.regulMinStepsComboBox = new System.Windows.Forms.ComboBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.SuspendLayout(); + // + // positionTextBox + // + this.positionTextBox.Enabled = false; + this.positionTextBox.Location = new System.Drawing.Point(138, 114); + this.positionTextBox.Name = "positionTextBox"; + this.positionTextBox.Size = new System.Drawing.Size(46, 20); + this.positionTextBox.TabIndex = 8; + // + // positionLabel + // + this.positionLabel.AutoSize = true; + this.positionLabel.Location = new System.Drawing.Point(28, 117); + this.positionLabel.Name = "positionLabel"; + this.positionLabel.Size = new System.Drawing.Size(18, 13); + this.positionLabel.TabIndex = 7; + this.positionLabel.Text = "ID"; + // + // parentNameLabel + // + this.parentNameLabel.AutoSize = true; + this.parentNameLabel.Location = new System.Drawing.Point(28, 68); + this.parentNameLabel.Name = "parentNameLabel"; + this.parentNameLabel.Size = new System.Drawing.Size(69, 13); + this.parentNameLabel.TabIndex = 3; + this.parentNameLabel.Text = "Parent Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(138, 41); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(28, 44); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(135, 14); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(89, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComponentName"; + // + // adcClosedLabel + // + this.adcClosedLabel.AutoSize = true; + this.adcClosedLabel.Location = new System.Drawing.Point(28, 141); + this.adcClosedLabel.Name = "adcClosedLabel"; + this.adcClosedLabel.Size = new System.Drawing.Size(93, 13); + this.adcClosedLabel.TabIndex = 9; + this.adcClosedLabel.Text = "ADC when Closed"; + // + // adcClosedTextBox + // + this.adcClosedTextBox.Enabled = false; + this.adcClosedTextBox.Location = new System.Drawing.Point(138, 138); + this.adcClosedTextBox.Name = "adcClosedTextBox"; + this.adcClosedTextBox.Size = new System.Drawing.Size(46, 20); + this.adcClosedTextBox.TabIndex = 10; + // + // adcOpenTextBox + // + this.adcOpenTextBox.Enabled = false; + this.adcOpenTextBox.Location = new System.Drawing.Point(138, 162); + this.adcOpenTextBox.Name = "adcOpenTextBox"; + this.adcOpenTextBox.Size = new System.Drawing.Size(46, 20); + this.adcOpenTextBox.TabIndex = 12; + // + // adcOpenLabel + // + this.adcOpenLabel.AutoSize = true; + this.adcOpenLabel.Location = new System.Drawing.Point(28, 165); + this.adcOpenLabel.Name = "adcOpenLabel"; + this.adcOpenLabel.Size = new System.Drawing.Size(87, 13); + this.adcOpenLabel.TabIndex = 11; + this.adcOpenLabel.Text = "ADC when Open"; + // + // parentNameComboBox + // + this.parentNameComboBox.Enabled = false; + this.parentNameComboBox.FormattingEnabled = true; + this.parentNameComboBox.Location = new System.Drawing.Point(138, 65); + this.parentNameComboBox.Name = "parentNameComboBox"; + this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); + this.parentNameComboBox.TabIndex = 4; + // + // storedPosReuseCheckBox + // + this.storedPosReuseCheckBox.AutoSize = true; + this.storedPosReuseCheckBox.Enabled = false; + this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 262); + this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox"; + this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17); + this.storedPosReuseCheckBox.TabIndex = 17; + this.storedPosReuseCheckBox.Text = "Enable stored position re-use"; + this.storedPosReuseCheckBox.UseVisualStyleBackColor = true; + // + // stableTimeTextBox + // + this.stableTimeTextBox.Enabled = false; + this.stableTimeTextBox.Location = new System.Drawing.Point(138, 186); + this.stableTimeTextBox.Name = "stableTimeTextBox"; + this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20); + this.stableTimeTextBox.TabIndex = 14; + // + // stableTimeLabel + // + this.stableTimeLabel.AutoSize = true; + this.stableTimeLabel.Location = new System.Drawing.Point(28, 189); + this.stableTimeLabel.Name = "stableTimeLabel"; + this.stableTimeLabel.Size = new System.Drawing.Size(81, 13); + this.stableTimeLabel.TabIndex = 13; + this.stableTimeLabel.Text = "Stable time [ms]"; + // + // flowStableSecTextBox + // + this.flowStableSecTextBox.Enabled = false; + this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 210); + this.flowStableSecTextBox.Name = "flowStableSecTextBox"; + this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20); + this.flowStableSecTextBox.TabIndex = 16; + // + // flowStableSecLabel + // + this.flowStableSecLabel.AutoSize = true; + this.flowStableSecLabel.Location = new System.Drawing.Point(28, 213); + this.flowStableSecLabel.Name = "flowStableSecLabel"; + this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13); + this.flowStableSecLabel.TabIndex = 15; + this.flowStableSecLabel.Text = "Flow stable [s]"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.setButton1); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.ADC); + this.groupBox1.Controls.Add(this.getButton1); + this.groupBox1.Controls.Add(this.pctTextBox1); + this.groupBox1.Controls.Add(this.adcTextBox1); + this.groupBox1.Location = new System.Drawing.Point(10, 398); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(280, 59); + this.groupBox1.TabIndex = 19; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Measured value 1"; + // + // setButton1 + // + this.setButton1.Location = new System.Drawing.Point(229, 17); + this.setButton1.Name = "setButton1"; + this.setButton1.Size = new System.Drawing.Size(38, 33); + this.setButton1.TabIndex = 5; + this.setButton1.Text = "Set"; + this.setButton1.UseVisualStyleBackColor = true; + this.setButton1.Click += new System.EventHandler(this.setButton_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(209, 28); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 13); + this.label1.TabIndex = 4; + this.label1.Text = "%"; + // + // ADC + // + this.ADC.AutoSize = true; + this.ADC.Location = new System.Drawing.Point(11, 28); + this.ADC.Name = "ADC"; + this.ADC.Size = new System.Drawing.Size(32, 13); + this.ADC.TabIndex = 3; + this.ADC.Text = "ADC:"; + // + // getButton1 + // + this.getButton1.Location = new System.Drawing.Point(101, 18); + this.getButton1.Name = "getButton1"; + this.getButton1.Size = new System.Drawing.Size(38, 33); + this.getButton1.TabIndex = 2; + this.getButton1.Text = "Get"; + this.getButton1.UseVisualStyleBackColor = true; + this.getButton1.Click += new System.EventHandler(this.getButton1_Click); + // + // pctTextBox1 + // + this.pctTextBox1.Location = new System.Drawing.Point(160, 24); + this.pctTextBox1.Name = "pctTextBox1"; + this.pctTextBox1.Size = new System.Drawing.Size(46, 20); + this.pctTextBox1.TabIndex = 1; + // + // adcTextBox1 + // + this.adcTextBox1.Location = new System.Drawing.Point(47, 24); + this.adcTextBox1.Name = "adcTextBox1"; + this.adcTextBox1.Size = new System.Drawing.Size(44, 20); + this.adcTextBox1.TabIndex = 0; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.setButton2); + this.groupBox2.Controls.Add(this.label2); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Controls.Add(this.getButton2); + this.groupBox2.Controls.Add(this.pctTextBox2); + this.groupBox2.Controls.Add(this.adcTextBox2); + this.groupBox2.Location = new System.Drawing.Point(10, 462); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(280, 59); + this.groupBox2.TabIndex = 20; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Measured value 2"; + // + // setButton2 + // + this.setButton2.Location = new System.Drawing.Point(229, 17); + this.setButton2.Name = "setButton2"; + this.setButton2.Size = new System.Drawing.Size(38, 33); + this.setButton2.TabIndex = 5; + this.setButton2.Text = "Set"; + this.setButton2.UseVisualStyleBackColor = true; + this.setButton2.Click += new System.EventHandler(this.setButton_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(209, 28); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(15, 13); + this.label2.TabIndex = 4; + this.label2.Text = "%"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(11, 27); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(32, 13); + this.label3.TabIndex = 3; + this.label3.Text = "ADC:"; + // + // getButton2 + // + this.getButton2.Location = new System.Drawing.Point(101, 18); + this.getButton2.Name = "getButton2"; + this.getButton2.Size = new System.Drawing.Size(38, 33); + this.getButton2.TabIndex = 2; + this.getButton2.Text = "Get"; + this.getButton2.UseVisualStyleBackColor = true; + this.getButton2.Click += new System.EventHandler(this.getButton2_Click); + // + // pctTextBox2 + // + this.pctTextBox2.Location = new System.Drawing.Point(160, 24); + this.pctTextBox2.Name = "pctTextBox2"; + this.pctTextBox2.Size = new System.Drawing.Size(46, 20); + this.pctTextBox2.TabIndex = 1; + // + // adcTextBox2 + // + this.adcTextBox2.Location = new System.Drawing.Point(47, 24); + this.adcTextBox2.Name = "adcTextBox2"; + this.adcTextBox2.Size = new System.Drawing.Size(44, 20); + this.adcTextBox2.TabIndex = 0; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.closeButton); + this.groupBox3.Controls.Add(this.openButton); + this.groupBox3.Location = new System.Drawing.Point(10, 527); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(280, 60); + this.groupBox3.TabIndex = 21; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Regulation valve"; + // + // closeButton + // + this.closeButton.Location = new System.Drawing.Point(14, 19); + this.closeButton.Name = "closeButton"; + this.closeButton.Size = new System.Drawing.Size(107, 28); + this.closeButton.TabIndex = 1; + this.closeButton.Text = "Close"; + this.closeButton.UseVisualStyleBackColor = true; + this.closeButton.Click += new System.EventHandler(this.closeButton_Click); + // + // openButton + // + this.openButton.Location = new System.Drawing.Point(160, 19); + this.openButton.Name = "openButton"; + this.openButton.Size = new System.Drawing.Size(107, 28); + this.openButton.TabIndex = 0; + this.openButton.Text = "Open"; + this.openButton.UseVisualStyleBackColor = true; + this.openButton.Click += new System.EventHandler(this.openButton_Click); + // + // adcTextBox + // + this.adcTextBox.Location = new System.Drawing.Point(47, 14); + this.adcTextBox.Name = "adcTextBox"; + this.adcTextBox.Size = new System.Drawing.Size(44, 20); + this.adcTextBox.TabIndex = 21; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.label4); + this.groupBox4.Controls.Add(this.adcTextBox); + this.groupBox4.Location = new System.Drawing.Point(10, 352); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(279, 40); + this.groupBox4.TabIndex = 22; + this.groupBox4.TabStop = false; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(11, 17); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(32, 13); + this.label4.TabIndex = 22; + this.label4.Text = "ADC:"; + // + // categoryComboBox + // + this.categoryComboBox.Enabled = false; + this.categoryComboBox.FormattingEnabled = true; + this.categoryComboBox.Location = new System.Drawing.Point(138, 90); + this.categoryComboBox.Name = "categoryComboBox"; + this.categoryComboBox.Size = new System.Drawing.Size(130, 21); + this.categoryComboBox.TabIndex = 6; + // + // categoryLabel + // + this.categoryLabel.AutoSize = true; + this.categoryLabel.Location = new System.Drawing.Point(28, 93); + this.categoryLabel.Name = "categoryLabel"; + this.categoryLabel.Size = new System.Drawing.Size(49, 13); + this.categoryLabel.TabIndex = 5; + this.categoryLabel.Text = "Category"; + // + // unitsComboBox + // + this.unitsComboBox.Enabled = false; + this.unitsComboBox.FormattingEnabled = true; + this.unitsComboBox.Location = new System.Drawing.Point(138, 309); + this.unitsComboBox.Name = "unitsComboBox"; + this.unitsComboBox.Size = new System.Drawing.Size(80, 21); + this.unitsComboBox.TabIndex = 32; + // + // unitsLabel + // + this.unitsLabel.AutoSize = true; + this.unitsLabel.Location = new System.Drawing.Point(28, 312); + this.unitsLabel.Name = "unitsLabel"; + this.unitsLabel.Size = new System.Drawing.Size(78, 13); + this.unitsLabel.TabIndex = 31; + this.unitsLabel.Text = "Unit of setpoint"; + // + // formatTextBox + // + this.formatTextBox.Enabled = false; + this.formatTextBox.Location = new System.Drawing.Point(138, 285); + this.formatTextBox.Name = "formatTextBox"; + this.formatTextBox.Size = new System.Drawing.Size(130, 20); + this.formatTextBox.TabIndex = 30; + // + // formatLabel + // + this.formatLabel.AutoSize = true; + this.formatLabel.Location = new System.Drawing.Point(28, 288); + this.formatLabel.Name = "formatLabel"; + this.formatLabel.Size = new System.Drawing.Size(78, 13); + this.formatLabel.TabIndex = 29; + this.formatLabel.Text = "Setpoint format"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(28, 239); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(110, 13); + this.label5.TabIndex = 33; + this.label5.Text = "Regul. min. steps [ms]"; + // + // regulMinStepsComboBox + // + this.regulMinStepsComboBox.Enabled = false; + this.regulMinStepsComboBox.FormattingEnabled = true; + this.regulMinStepsComboBox.Location = new System.Drawing.Point(138, 236); + this.regulMinStepsComboBox.Name = "regulMinStepsComboBox"; + this.regulMinStepsComboBox.Size = new System.Drawing.Size(80, 21); + this.regulMinStepsComboBox.TabIndex = 34; + this.regulMinStepsComboBox.SelectedIndexChanged += new System.EventHandler(this.regulMinStepsComboBox_SelectedIndexChanged); + // + // RegValveCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.regulMinStepsComboBox); + this.Controls.Add(this.label5); + this.Controls.Add(this.unitsComboBox); + this.Controls.Add(this.unitsLabel); + this.Controls.Add(this.formatTextBox); + this.Controls.Add(this.formatLabel); + this.Controls.Add(this.categoryComboBox); + this.Controls.Add(this.categoryLabel); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.flowStableSecTextBox); + this.Controls.Add(this.flowStableSecLabel); + this.Controls.Add(this.stableTimeTextBox); + this.Controls.Add(this.stableTimeLabel); + this.Controls.Add(this.storedPosReuseCheckBox); + this.Controls.Add(this.parentNameComboBox); + this.Controls.Add(this.adcOpenTextBox); + this.Controls.Add(this.adcOpenLabel); + this.Controls.Add(this.adcClosedTextBox); + this.Controls.Add(this.adcClosedLabel); + this.Controls.Add(this.positionTextBox); + this.Controls.Add(this.positionLabel); + this.Controls.Add(this.parentNameLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "RegValveCfgCtrl"; + this.Size = new System.Drawing.Size(300, 700); + this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox positionTextBox; + private System.Windows.Forms.Label positionLabel; + private System.Windows.Forms.Label parentNameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label adcClosedLabel; + private System.Windows.Forms.TextBox adcClosedTextBox; + private System.Windows.Forms.TextBox adcOpenTextBox; + private System.Windows.Forms.Label adcOpenLabel; + private System.Windows.Forms.ComboBox parentNameComboBox; + private System.Windows.Forms.CheckBox storedPosReuseCheckBox; + private System.Windows.Forms.TextBox stableTimeTextBox; + private System.Windows.Forms.Label stableTimeLabel; + private System.Windows.Forms.TextBox flowStableSecTextBox; + private System.Windows.Forms.Label flowStableSecLabel; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button setButton1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label ADC; + private System.Windows.Forms.Button getButton1; + private System.Windows.Forms.TextBox pctTextBox1; + private System.Windows.Forms.TextBox adcTextBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button setButton2; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button getButton2; + private System.Windows.Forms.TextBox pctTextBox2; + private System.Windows.Forms.TextBox adcTextBox2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Button closeButton; + private System.Windows.Forms.Button openButton; + private System.Windows.Forms.TextBox adcTextBox; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox categoryComboBox; + private System.Windows.Forms.Label categoryLabel; + private System.Windows.Forms.ComboBox unitsComboBox; + private System.Windows.Forms.Label unitsLabel; + private System.Windows.Forms.TextBox formatTextBox; + private System.Windows.Forms.Label formatLabel; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox regulMinStepsComboBox; + } +} diff --git a/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.resx b/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/Rig/Uni/RegValveLowRegulTimeSaturation/RegValveCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBFTests/bin/Debug/SampleConfig/log4netConfig.xml b/TBFTests/bin/Debug/SampleConfig/log4netConfig.xml index 338d53558..44205cd62 100644 --- a/TBFTests/bin/Debug/SampleConfig/log4netConfig.xml +++ b/TBFTests/bin/Debug/SampleConfig/log4netConfig.xml @@ -38,12 +38,20 @@ + + + + + - + + + +