(1) Modbus.QuidoRS.ConfirmationForm added, (2) Use of QuidoRS in iPerlCommForm fixed - uses QuidoRS.Variant, ver. 2.18.1149

This commit is contained in:
Milan Hanajik
2019-02-25 11:05:21 +01:00
parent 7a40cfb1f2
commit ea7e727798
15 changed files with 416 additions and 10 deletions
@@ -0,0 +1,98 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using TBF.Resources;
namespace TBF.BenchControl.Modbus.QuidoRS
{
public partial class ConfirmationForm : Form
{
static readonly ILog log = LogManager.GetLogger(typeof(ConfirmationForm));
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
public ConfirmationForm(string message, Color backgroundColor)
{
InitializeComponent();
Localize();
messageLabel.Text = message;
BackColor = backgroundColor;
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(messageLabel.Text, messageLabel.Font).Width;
int rqrdFormWidth = (int)textWidth + 80; /// Form width calculated from the text width
if (rqrdFormWidth > Width)
{
int shift = (rqrdFormWidth - Width) / 2;
Width = rqrdFormWidth;
okButton.Left += shift;
}
completed = false;
StartForceCloseHandler();
}
void Localize()
{
okButton.Text = Strings.OkBtnText;
}
private void okButton_Click(object sender, EventArgs e)
{
completed = true;
Close();
}
private void MessageBoxForm_FormClosing(object sender, FormClosingEventArgs e)
{
completed = true;
}
#region Forced close handling
/// <summary>
/// Used by CoverTest, AskYesNoOp and MessageBoxOp.
/// </summary>
public void OnCloseThisForm(object sender, EventArgs args)
{
if (CloseThisFormHandler == null) return;
try
{
CloseThisFormHandler(sender, null);
}
catch (Exception e)
{
log.Error("CloseThisFormHandler(...) failed", e);
}
}
public event EventHandler<EventArgs> CloseThisFormHandler;
public void StartForceCloseHandler()
{
CloseThisFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired)
Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args);
else
OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
@@ -0,0 +1,85 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.BenchControl.Modbus.QuidoRS
{
partial class ConfirmationForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.okButton = new System.Windows.Forms.Button();
this.messageLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// okButton
//
this.okButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Location = new System.Drawing.Point(177, 99);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(98, 63);
this.okButton.TabIndex = 1;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// messageLabel
//
this.messageLabel.AutoSize = true;
this.messageLabel.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.messageLabel.Location = new System.Drawing.Point(34, 39);
this.messageLabel.Name = "messageLabel";
this.messageLabel.Size = new System.Drawing.Size(91, 23);
this.messageLabel.TabIndex = 4;
this.messageLabel.Text = "Message";
//
// ConfirmationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Goldenrod;
this.ClientSize = new System.Drawing.Size(454, 201);
this.Controls.Add(this.messageLabel);
this.Controls.Add(this.okButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ConfirmationForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.TopMost = true;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MessageBoxForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Label messageLabel;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -19,6 +19,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
readonly QuidoRSCfg quidoRSCfg;
readonly GenericDevices.IModbus modbus;
public QuidoVariant Variant { get { return quidoRSCfg.Variant; } }
private ushort currentOutputs;
private DateTime lastOutputsChange;
@@ -2,8 +2,10 @@
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using log4net;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.BenchControl.Modbus.QuidoRS
{
@@ -14,10 +16,27 @@ namespace TBF.BenchControl.Modbus.QuidoRS
const ushort BenchReadyValue = 0x01;
const ushort BenchErrorValue = 0x06;
const ushort BenchConfirmedValue = 0x02;
/// Set by the constructor
readonly QuidoRS quidoRS;
bool confirmed = false;
///
ConfirmationForm confirmationForm;
///
delegate void MessageBoxFormDlgt(ShowBenchErrorOp myRef);
///
void OpenFormDlg(ShowBenchErrorOp myRef)
{
myRef.confirmationForm = new ConfirmationForm(Strings.Mute_alarm, Color.Yellow);
confirmationForm.Show();
}
/// <summary>
/// Events: Event.None
/// </summary>
@@ -26,7 +45,6 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
if (quidoRS == null) throw new ArgumentNullException("quidoRS");
this.quidoRS = quidoRS;
log.Debug(this.ToString());
}
@@ -35,11 +53,22 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
log.WarnFormat("ShowBenchErrorOp.Start()");
quidoRS.SetOutputs(BenchErrorValue);
confirmed = false;
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
}
/// <summary>Run this operation</summary>
public Event Run()
{
if (confirmed || confirmationForm.Completed)
{
log.WarnFormat("ShowBenchWaitingOp.Run() --> Confirmed");
quidoRS.SetOutputs(BenchConfirmedValue);
confirmed = true;
confirmationForm = null;
}
return Event.None;
}
@@ -48,6 +77,12 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
log.WarnFormat("ShowBenchErrorOp.Stop()");
quidoRS.SetOutputs(BenchReadyValue);
if (confirmationForm != null)
{
confirmationForm.OnCloseThisForm(this, null);
confirmationForm = null;
}
}
}
}
@@ -2,8 +2,10 @@
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using log4net;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.BenchControl.Modbus.QuidoRS
{
@@ -14,10 +16,27 @@ namespace TBF.BenchControl.Modbus.QuidoRS
const ushort BenchReadyValue = 0x01;
const ushort BenchWaitingValue = 0x06;
const ushort BenchConfirmedValue = 0x02;
/// Set by the constructor
readonly QuidoRS quidoRS;
bool confirmed = false;
///
ConfirmationForm confirmationForm;
///
delegate void MessageBoxFormDlgt(ShowBenchWaitingOp myRef);
///
void OpenFormDlg(ShowBenchWaitingOp myRef)
{
myRef.confirmationForm = new ConfirmationForm(Strings.Mute_alarm, Color.Yellow);
confirmationForm.Show();
}
/// <summary>
/// Events: Event.None
/// </summary>
@@ -26,7 +45,6 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
if (quidoRS == null) throw new ArgumentNullException("quidoRS");
this.quidoRS = quidoRS;
log.Debug(this.ToString());
}
@@ -35,11 +53,22 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
log.WarnFormat("ShowBenchWaitingOp.Start()");
quidoRS.SetOutputs(BenchWaitingValue);
confirmed = false;
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
}
/// <summary>Run this operation</summary>
public Event Run()
{
if (confirmed || confirmationForm.Completed)
{
log.WarnFormat("ShowBenchWaitingOp.Run() --> Confirmed");
quidoRS.SetOutputs(BenchConfirmedValue);
confirmed = true;
confirmationForm = null;
}
return Event.None;
}
@@ -48,6 +77,12 @@ namespace TBF.BenchControl.Modbus.QuidoRS
{
log.WarnFormat("ShowBenchWaitingOp.Stop()");
quidoRS.SetOutputs(BenchReadyValue);
if (confirmationForm != null)
{
confirmationForm.OnCloseThisForm(this, null);
confirmationForm = null;
}
}
}
}
@@ -68,7 +68,7 @@ namespace TBF.BenchControl.TestMethods.ChangeFlowDirection
State.Create(string.Format("{0}({1}) : Turn the direction of watermeters", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.BenchWaitingOp)
.AddOperation(new Operations.MessageBoxOp("Otočte iPerly prosím."))
.AddOperation(new Operations.MessageBoxOp("iPerly jsou otočeny"))
.EnterState();
do
{
@@ -400,9 +400,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
foreach (var comp in StateMachine.Components)
{
if (comp is Modbus.QuidoRS.QuidoRS)
Modbus.QuidoRS.QuidoRS q = comp as Modbus.QuidoRS.QuidoRS;
if ((q != null) && (q.Variant == Modbus.QuidoRS.QuidoVariant.QuidoRS_2_16))
{
quido = comp as Modbus.QuidoRS.QuidoRS;
quido = q;
break;
}
}
@@ -632,7 +633,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Set QuidoRS outputs and start the whole communication process
/// by incrementing 'currentGroup'.
///
if (cfg.UseMuxBoards && quido != null)
if (cfg.UseMuxBoards && (quido != null))
{
quido.SetOutputs((ushort)(16 - currentGroup - 1));
Thread.Sleep(2000);
@@ -2256,7 +2257,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (currentGroup < lastGroup)
{
/// Go to the next step / next group
if (quido != null)
if (cfg.UseMuxBoards && (quido != null))
{
quido.SetOutputs((ushort)(16 - currentGroup - 1));
Thread.Sleep(2000);
@@ -2268,7 +2269,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
currentGroup = 0;
currentActivityStep++;
activityLabel.Text = multiTestParams[currentActivityStep].Activity;
if (quido != null)
if (cfg.UseMuxBoards && (quido != null))
{
quido.SetOutputs((ushort)(16 - currentGroup - 1));
Thread.Sleep(2000);
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1148.0")]
[assembly: AssemblyFileVersion("2.18.1148.0")]
[assembly: AssemblyVersion("2.18.1149.0")]
[assembly: AssemblyFileVersion("2.18.1149.0")]
+9
View File
@@ -2508,6 +2508,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Mute the alarm.
/// </summary>
internal static string Mute_alarm {
get {
return ResourceManager.GetString("Mute_alarm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name.
/// </summary>
+3
View File
@@ -1377,4 +1377,7 @@
<data name="Results" xml:space="preserve">
<value>Výsledky</value>
</data>
<data name="Mute_alarm" xml:space="preserve">
<value>Ztlumit sirénu</value>
</data>
</root>
+3
View File
@@ -1464,4 +1464,7 @@
<data name="Results" xml:space="preserve">
<value>Ergebnisse</value>
</data>
<data name="Mute_alarm" xml:space="preserve">
<value>Stummschaltung des Alarms</value>
</data>
</root>
+3
View File
@@ -1933,4 +1933,7 @@
<data name="Result" xml:space="preserve">
<value>Result</value>
</data>
<data name="Mute_alarm" xml:space="preserve">
<value>Mute the alarm</value>
</data>
</root>
+3
View File
@@ -165,4 +165,7 @@
<data name="Sensor" xml:space="preserve">
<value>Senzor</value>
</data>
<data name="Mute_alarm" xml:space="preserve">
<value>Stlmiť sirénu</value>
</data>
</root>
+9
View File
@@ -678,6 +678,12 @@
<DependentUpon>PressureMeterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Modbus\PressureMeter\Meret\ReadPressureOp.cs" />
<Compile Include="BenchControl\Modbus\QuidoRS\ConfirmationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BenchControl\Modbus\QuidoRS\ConfirmationForm.designer.cs">
<DependentUpon>ConfirmationForm.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Modbus\QuidoRS\QuidoRS.cs" />
<Compile Include="BenchControl\Modbus\QuidoRS\QuidoRSCfg.cs" />
<Compile Include="BenchControl\Modbus\QuidoRS\QuidoRSCfgCtrl.cs">
@@ -2581,6 +2587,9 @@
<EmbeddedResource Include="BenchControl\Modbus\PressureMeter\Meret\PressureMeterCfgCtrl.resx">
<DependentUpon>PressureMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Modbus\QuidoRS\ConfirmationForm.resx">
<DependentUpon>ConfirmationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Modbus\QuidoRS\QuidoRSCfgCtrl.resx">
<DependentUpon>QuidoRSCfgCtrl.cs</DependentUpon>
</EmbeddedResource>