(1) Adjustment.WMErrorsForm48, (2) MeretRS485Address = new byte[6] for IZRAEL_50

This commit is contained in:
Milan Hanajik 2020-03-30 12:03:30 +02:00
parent 68ce0578e2
commit f00196c4a8
6 changed files with 1737 additions and 4 deletions

View File

@ -131,8 +131,12 @@ namespace TBF.BenchControl.Elde
public float[] EtCalib = new float[8] { 1, 1, 1, 1, 1, 1, 1, 1 };
#elif MUNICH || TORINO_50 || BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || TORUN_50 || CEVAK_40 || TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL || MURES_40 || FUZHOU_50 || SLM_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || FUZHOU_100 || ALZIR_25
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
#if IZRAEL_50
public byte[] MeretRS485Address = new byte[6];
#else
public byte[] MeretRS485Address = new byte[4];
#endif
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
#elif IZRAEL_50 || SLM_END
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
public byte[] MeretRS485Address = new byte[7]; /// Modbus addresses of Pr1, Pr2, Pr3, Pr4, Pr5, Pr6, T9 (Izrael) or Pr1, Pr2, Pr3, Pr4, T9, T10 (SLM END)

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@ -25,7 +25,11 @@ namespace TBF.BenchControl.TestMethods.Adjustment
{
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
if (Config.Data.WMsCount > 12)
if (Config.Data.WMsCount > 24)
{
myRef.modelessDlg = new WMErrorsForm48(waterMeters);
}
else if (Config.Data.WMsCount > 12)
{
myRef.modelessDlg = new WMErrorsForm24(waterMeters);
}

View File

@ -0,0 +1,275 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.Adjustment
{
public partial class WMErrorsForm48 : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(WMErrorsForm48));
const int MaxWMsCount = 48; /// Implementation limit of this form
///
/// Updated in constructor
///
readonly int waterMetersCount; /// Number of text boxes for serial numbers
readonly bool[] disabled;
int textBoxesCount;
Label[] labels;
TextBox[] errors;
Rectangle[] rects;
///
/// Updated in OnAdjustmentInProgress()
///
double[] error; /// Created in constructor
double errLimLo;
double errLimHi;
///
/// Set to 'true' when the form closes
///
public bool Completed { get { return completed; } }
bool completed;
/// <summary> Parameterless constructor for 3 watermeters </summary>
public WMErrorsForm48()
{
InitializeComponent();
ControlBox = false;
textBoxesCount = MaxWMsCount;
labels = new Label[MaxWMsCount]
{
wmErrorLabel1, wmErrorLabel2, wmErrorLabel3, wmErrorLabel4, wmErrorLabel5,
wmErrorLabel6, wmErrorLabel7, wmErrorLabel8, wmErrorLabel9, wmErrorLabel10,
wmErrorLabel11, wmErrorLabel12, wmErrorLabel13, wmErrorLabel14, wmErrorLabel15,
wmErrorLabel16, wmErrorLabel17, wmErrorLabel18, wmErrorLabel19, wmErrorLabel20,
wmErrorLabel21, wmErrorLabel22, wmErrorLabel23, wmErrorLabel24, wmErrorLabel25,
wmErrorLabel26, wmErrorLabel27, wmErrorLabel28, wmErrorLabel29, wmErrorLabel30,
wmErrorLabel31, wmErrorLabel32, wmErrorLabel33, wmErrorLabel34, wmErrorLabel35,
wmErrorLabel36, wmErrorLabel37, wmErrorLabel38, wmErrorLabel39, wmErrorLabel40,
wmErrorLabel41, wmErrorLabel42, wmErrorLabel43, wmErrorLabel44, wmErrorLabel45,
wmErrorLabel46, wmErrorLabel47, wmErrorLabel48,
};
errors = new TextBox[MaxWMsCount]
{
wmErrorTextBox1, wmErrorTextBox2, wmErrorTextBox3, wmErrorTextBox4, wmErrorTextBox5,
wmErrorTextBox6, wmErrorTextBox7, wmErrorTextBox8, wmErrorTextBox9, wmErrorTextBox10,
wmErrorTextBox11, wmErrorTextBox12, wmErrorTextBox13, wmErrorTextBox14, wmErrorTextBox15,
wmErrorTextBox16, wmErrorTextBox17, wmErrorTextBox18, wmErrorTextBox19, wmErrorTextBox20,
wmErrorTextBox21, wmErrorTextBox22, wmErrorTextBox23, wmErrorTextBox24, wmErrorTextBox25,
wmErrorTextBox26, wmErrorTextBox27, wmErrorTextBox28, wmErrorTextBox29, wmErrorTextBox30,
wmErrorTextBox31, wmErrorTextBox32, wmErrorTextBox33, wmErrorTextBox34, wmErrorTextBox35,
wmErrorTextBox36, wmErrorTextBox37, wmErrorTextBox38, wmErrorTextBox39, wmErrorTextBox40,
wmErrorTextBox41, wmErrorTextBox42, wmErrorTextBox43, wmErrorTextBox44, wmErrorTextBox45,
wmErrorTextBox46, wmErrorTextBox47, wmErrorTextBox48,
};
rects = new Rectangle[MaxWMsCount];
for (int i = 0; i < MaxWMsCount; i++)
{
int row = i % 24;
int col = i / 24;
rects[i] = new Rectangle(350 + col * 557, 22 + row * 34, 230, 25);
}
completed = false;
/// Attach to 'AdjustmentInProgress' handler
UiBridge.Bridge.AdjustmentInProgressHandler += delegate(object sender, UiBridge.AdjustmentInProgressEventArgs args)
{
if (InvokeRequired)
{
Invoke(new EventHandler<UiBridge.AdjustmentInProgressEventArgs>(OnAdjustmentInProgress), sender, args);
}
else OnAdjustmentInProgress(sender, args);
};
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public WMErrorsForm48(IList<GenericDevices.IWaterMeter> waterMeters)
: this()
{
waterMetersCount = Math.Min(Config.Data.WMsCount, waterMeters.Count);
ShuffleTextBoxes(waterMetersCount, Config.Data.LineSize);
disabled = new bool[waterMetersCount];
for (int i = 0; i < waterMetersCount; i++)
{
if (i < MaxWMsCount) disabled[i] = waterMeters[i].Disabled;
}
error = new double[waterMetersCount];
}
/// <summary>
/// Make sure the layout of labels/text boxes on the screen
/// corresponds to the layout of watermeters of the test bench.
/// </summary>
/// <param name="wmsCount">Number of watermeters</param>
/// <param name="lineSize">Number of watermeters in one line</param>
void ShuffleTextBoxes(int wmsCount, int lineSize)
{
if ((wmsCount < textBoxesCount) && (lineSize > 0))
{
int nrLines = (wmsCount + lineSize - 1) / lineSize;
int gap = (textBoxesCount - wmsCount) / nrLines;
int dest = 0;
for (int l = 0; l < nrLines; l++)
{
for (int i = 0; i < lineSize; i++)
{
labels[dest] = labels[l * lineSize + l * gap + i];
errors[dest] = errors[l * lineSize + l * gap + i];
rects[dest] = rects[l * lineSize + l * gap + i];
dest++;
}
}
textBoxesCount = wmsCount;
}
}
void Localize()
{
Text = Strings.Water_Meter_States;
for (int i = 0; i < textBoxesCount; i++)
{
labels[i].Text = string.Format("WM{0} {1}", i + 1, Strings.Error_pct);
}
okButton.Text = Strings.OkBtnText;
}
private void WMErrorsForm48_Load(object sender, EventArgs e)
{
Localize();
//Height = 50 + 90 * WaterMetersCount;
for (int i = 0; i < textBoxesCount; i++)
{
labels[i].Visible = errors[i].Visible = (disabled == null || i >= disabled.Length || !disabled[i]);
errors[i].Text = "---";
}
}
private void okButton_Click(object sender, EventArgs e)
{
completed = true;
Close();
}
void OnAdjustmentInProgress(object sender, UiBridge.AdjustmentInProgressEventArgs args)
{
string testName = args.TestName;
Results.Entities.TestRslt tr = TBF.BenchControl.Sequences.ProcessData.BatchRslts.GetTestRslt(testName, 0);
if (tr != null)
{
errLimLo = tr.ErrLimLo() + tr.ErrLimMargin();
errLimHi = tr.ErrLimHi() - tr.ErrLimMargin();
int count = Math.Min(waterMetersCount, TBF.BenchControl.Sequences.ProcessData.BatchRslts.WMPositionsCount);
for (int i = 0; i < count; i++)
{
Results.Entities.MeterTestRslt mtr = TBF.BenchControl.Sequences.ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
if (mtr != null) error[i] = mtr.Error;
}
Redraw();
}
}
void Redraw()
{
for (int i = 0; i < textBoxesCount; i++)
{
errors[i].Text = error[i].ToString("F1");
Invalidate(rects[i]);
}
}
private void WMErrorsForm_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics graphics = this.CreateGraphics();
for (int i = 0; i < waterMetersCount; i++)
{
if (!disabled[i])
{
PaintOne(graphics, rects[i], error[i], errLimLo, errLimHi);
}
}
}
void PaintOne(System.Drawing.Graphics g, Rectangle r, double value, double limLo, double limHi)
{
Rectangle rect1 = new Rectangle(r.Left, r.Top, r.Width / 3, r.Height);
Rectangle rect2 = new Rectangle(r.Left + r.Width / 3, r.Top, r.Width / 3, r.Height);
Rectangle rect3 = new Rectangle(r.Left + 2 * (r.Width / 3), r.Top, r.Width / 3, r.Height);
Rectangle rectCent = new Rectangle(r.Left + r.Width / 2 - 1, r.Top, 3, r.Height);
Brush redBrush = new SolidBrush(Color.FromName("Salmon"));
Brush greenBrush = new SolidBrush(Color.FromName("LightGreen"));
Brush centBrush = new SolidBrush(Color.FromName("Green"));
g.FillRectangle(redBrush, rect1);
g.FillRectangle(greenBrush, rect2);
g.FillRectangle(redBrush, rect3);
g.FillRectangle(centBrush, rectCent);
int x0 = r.Left + r.Width / 2;
int dx = r.Height / 3;
int x = (int)((double)r.Width * (2.0 * value - limLo - limHi) / (limHi - limLo) / 6.0f + 0.5f);
if (x0 - dx + x >= r.Left && x0 + dx + x < r.Left + r.Width)
{
Point[] triangle = new Point[3]
{
new Point(x0 - dx + x, r.Top),
new Point(x0 + dx + x, r.Top),
new Point(x0 + x, r.Top + 2 * r.Height / 3),
};
Brush blackBrush = new SolidBrush(Color.Black);
g.FillPolygon(blackBrush, triangle);
}
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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>

View File

@ -1110,6 +1110,12 @@
<Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm24.designer.cs">
<DependentUpon>WMErrorsForm24.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm48.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm48.designer.cs">
<DependentUpon>WMErrorsForm48.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\ChangeFlowDirection\ChangeFlowDirectionSeq.cs" />
<Compile Include="BenchControl\TestMethods\ChangeFlowDirection\Factory.cs" />
<Compile Include="BenchControl\TestMethods\ChangeFlowDirection\TestMethod.cs" />
@ -2906,6 +2912,9 @@
<EmbeddedResource Include="BenchControl\TestMethods\Adjustment\WMErrorsForm24.resx">
<DependentUpon>WMErrorsForm24.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\Adjustment\WMErrorsForm48.resx">
<DependentUpon>WMErrorsForm48.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\DiverterTest\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>