iPerl heads (WM positions) can be disabled by a user (port from branch iPerl-12) : Part 1, auxiliary changes.

This commit is contained in:
Milan Hanajik 2017-10-11 08:47:36 +02:00
parent 98105cbf21
commit 328d6b7fa7
11 changed files with 134 additions and 9 deletions

View File

@ -0,0 +1,45 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Drawing;
using System.Windows.Forms;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
public class CheckBoxImage : PictureBox
{
private bool cchecked;
private readonly Image ci;
private readonly Image uci;
public CheckBoxImage()
: this(new Bitmap(TBF.Properties.Resources.SwitchOn), new Bitmap(TBF.Properties.Resources.SwitchOff), true)
{
SizeMode = PictureBoxSizeMode.StretchImage;
}
public CheckBoxImage(Image checkedimage, Image uncheckedimage, bool initState)
: base()
{
ci = checkedimage;
uci = uncheckedimage;
Click += (sender, e) => { Checked = !Checked; };
Checked = initState;
}
public bool Checked
{
get { return cchecked; }
set
{
if (Enabled)
{
Image = value ? ci : uci;
cchecked = value;
}
}
}
}
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Copyright (c) 2015-2017 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
@ -10,13 +10,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
public int ThreadId;
public int WMNr;
public iPerlHead.IperlHead Ihead;
public Results.Entities.WaterMeter Wm;
public string CommMessage;
public CommErr CommErr;
public CommCompletedEventArgs(int threadId, int wmNr, string commMessage)
public CommCompletedEventArgs(int threadId, int wmNr, iPerlHead.IperlHead ihead, Results.Entities.WaterMeter wm, string commMessage, CommErr commErr)
{
this.ThreadId = threadId;
this.WMNr = wmNr;
this.Ihead = ihead;
this.Wm = wm;
this.CommMessage = commMessage;
this.CommErr = commErr;
}
}
}

View File

@ -39,6 +39,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
CalibFactorOoRange, /// E = 14
MissingTest, /// F = 15
RFPowerRecordMissing, /// 10H = 16
HeadDisabledByUser, /// 11H = 17
}
@ -259,9 +260,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Label[] labels;
PictureBox[] counters;
TextBox[] messages;
CheckBoxImage[] checkBoxes;
static IList<IperlHead> iperlHeads;
static IList<int> waterMeterPositions; /// keeps original indices in RegisterReaders list
static IList<int> waterMeterPositions; /// keeps original 0-based indices in RegisterReaders list
Modbus.QuidoRS.QuidoRS quido;
@ -702,7 +704,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, resultStr));
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, ihead, wm, resultStr, error));
}
else if (ihead.CommFailed || error == CommErr.CommFailed)
{
@ -710,8 +712,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
wm.ResultCode |= (((int)error << 16) | ((int)tests[i].ItemNr << 20));
}
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, "Watermeter is disabled"));
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, ihead, wm, "Watermeter is disabled", error));
}
else
{
@ -720,7 +722,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
wm.ResultCode |= (((int)error << 16) | ((int)tests[i].ItemNr << 20));
}
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, string.Format("{0} failed ({1}) !!!", activity, error)));
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, ihead, wm, string.Format("{0} failed ({1}) !!!", activity, error), error));
rfidDataLogger.ErrorFormat("Group={0}, Board={1}, {2} failed ({3}) !!!", currentGroup, ihead.MuxBoardNrOrGroup14, activity, error);
ihead.CommFailed = true;
}
@ -732,7 +734,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (!wmFound)
{
OnCommCompleted(null, new CommCompletedEventArgs(threadID, -1, string.Empty)); /// Send negative wmNr
OnCommCompleted(null, new CommCompletedEventArgs(threadID, -1, null, null, string.Empty, CommErr.None)); /// Send negative wmNr
}
if (stopWorkerThreads) break;

View File

@ -110,6 +110,26 @@ namespace TBF.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap SwitchOff {
get {
object obj = ResourceManager.GetObject("SwitchOff", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap SwitchOn {
get {
object obj = ResourceManager.GetObject("SwitchOn", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -148,4 +148,9 @@
<data name="Empty" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\empty.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
<data name="SwitchOff" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\switch-off.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SwitchOn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\switch-on.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data></root>

View File

@ -1554,6 +1554,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to &apos;{0}&apos; activity failed ({1}) !!!.
/// </summary>
internal static string failed_0_1_exclamation {
get {
return ResourceManager.GetString("failed_0_1_exclamation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to create a sample database:.
/// </summary>
@ -1734,6 +1743,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Head was disabled by the user.
/// </summary>
internal static string Head_was_disabled_by_the_user {
get {
return ResourceManager.GetString("Head_was_disabled_by_the_user", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Header.
/// </summary>
@ -3552,6 +3570,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to RFID communication failed.
/// </summary>
internal static string RFID_communication_failed {
get {
return ResourceManager.GetString("RFID_communication_failed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ROI Data.
/// </summary>

View File

@ -1765,6 +1765,15 @@
<data name="Do_you_want_to_update_related_tests_and_procedures" xml:space="preserve">
<value>Do you want to update related tests and procedures?</value>
</data>
<data name="RFID_communication_failed" xml:space="preserve">
<value>RFID communication failed</value>
</data>
<data name="Head_was_disabled_by_the_user" xml:space="preserve">
<value>Head was disabled by the user</value>
</data>
<data name="failed_0_1_exclamation" xml:space="preserve">
<value>'{0}' activity failed ({1}) !!!</value>
</data>
<data name="Control_water_temp_chdr" xml:space="preserve">
<value>Control water temp.</value>
</data>

View File

@ -138,4 +138,10 @@
<data name="OkBtnText" xml:space="preserve">
<value>Áno</value>
</data>
<data name="Head_was_disabled_by_the_user" xml:space="preserve">
<value>Hlavica bola vypnutá používateľom</value>
</data>
<data name="RFID_communication_failed" xml:space="preserve">
<value>Zlyhala RFID komunikácia</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -930,6 +930,9 @@
<Compile Include="BenchControl\TestMethods\GrabImage\Factory.cs" />
<Compile Include="BenchControl\TestMethods\GrabImage\GrabImageSeq.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\AllCompletedEventArgs.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\CheckBoxImage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BenchControl\TestMethods\iPerlCommunication\CommCompletedEventArgs.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlCommunicationParams.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlCommunicationSeq.cs" />
@ -2592,6 +2595,8 @@
<None Include="Resources\RoiStyle2.bmp" />
<None Include="Resources\RoiStyle3.bmp" />
<Content Include="Resources\empty.png" />
<Content Include="Resources\switch-off.png" />
<Content Include="Resources\switch-on.png" />
<Content Include="SampleConfig\config.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>