Fixes occasional problem/crash for an iPearl test with Parts when iPearls are activated after 'End', version 2.1.190.

This commit is contained in:
Milan Hanajik
2016-01-19 21:12:35 +01:00
parent bfa506911c
commit a4331c8267
6 changed files with 75 additions and 95 deletions
@@ -250,7 +250,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
bool formCompleted;
/// <summary> Number of text boxes for serial numbers </summary>
public readonly int WaterMetersCount;
public int WaterMetersCount;
int textBoxesCount;
@@ -267,7 +267,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// RFID multiplexer PCB / RFID serial port and worker thread related variables
///
static TestMethodCfg cfg;
static IList<string> testNames;
static IList<Config.Entities.Test> tests;
static IList<iPerlCommunicationParams> multiTestParams;
@@ -368,24 +368,56 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Constructor with a list of watermeters.
/// Creates a list of iPerl-s, re-shuffles UI conrols and allocates 'disabled' array.
/// Constructor for one iPerlCommunication 'test'
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg)
public iPerlCommunicationForm(TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams)
: this()
{
iPerlCommunicationForm.cfg = cfg;
iPerlCommunicationForm.tests = new List<Test>();
iPerlCommunicationForm.tests.Add(test);
iPerlCommunicationForm.multiTestParams = new List<iPerlCommunicationParams>();
iPerlCommunicationForm.multiTestParams.Add(testParams);
SequenceBase.sensPath = StateMachine.GetMetersPath(test);
activityLabel.Text = testParams.Activity;
ConstructorCommon();
}
/// <summary>
/// Constructor for multiple iPerlCommunication 'tests'
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(TestMethodCfg cfg, IList<Test> tests, IList<iPerlCommunicationParams> multiTestParams)
: this()
{
iPerlCommunicationForm.cfg = cfg;
iPerlCommunicationForm.tests = tests;
iPerlCommunicationForm.multiTestParams = multiTestParams;
this.WaterMetersCount = waterMeters.Count;
iPerlCommunicationForm.waterMeters = new List<WaterMeters.iPerl.WaterMeter>();
///
foreach (var wm in waterMeters)
if (multiTestParams.Count > 0)
{
WaterMeters.iPerl.WaterMeter iPerl = wm as WaterMeters.iPerl.WaterMeter;
iPerlCommunicationForm.waterMeters.Add(iPerl);
SequenceBase.sensPath = StateMachine.GetMetersPath(tests[0]);
activityLabel.Text = multiTestParams[0].Activity;
}
ConstructorCommon();
}
void ConstructorCommon()
{
waterMeters = new List<WaterMeters.iPerl.WaterMeter>();
foreach (var rr in SequenceBase.sensPath.RegisterReaders)
{
WaterMeters.iPerl.WaterMeter iPerl = rr as WaterMeters.iPerl.WaterMeter;
if (iPerl != null) waterMeters.Add(iPerl);
}
WaterMetersCount = waterMeters.Count;
ShuffleTextBoxes(this.WaterMetersCount, Config.Data.LineSize);
///
@@ -416,39 +448,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (iPerl.Group > lastGroup) lastGroup = iPerl.Group;
}
}
/// <summary>
/// Constructor for one iPerlCommunication 'test'
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg,
string testName, iPerlCommunicationParams testParams)
: this(waterMeters, cfg)
{
iPerlCommunicationForm.testNames = new List<string>();
iPerlCommunicationForm.testNames.Add(testName);
iPerlCommunicationForm.multiTestParams = new List<iPerlCommunicationParams>();
iPerlCommunicationForm.multiTestParams.Add(testParams);
activityLabel.Text = testParams.Activity;
}
/// <summary>
/// Constructor for multiple iPerlCommunication 'tests'
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg,
IList<string> testNames, IList<iPerlCommunicationParams> multiTestParams)
: this(waterMeters, cfg)
{
iPerlCommunicationForm.testNames = testNames;
iPerlCommunicationForm.multiTestParams = multiTestParams;
if (multiTestParams.Count > 0) activityLabel.Text = multiTestParams[0].Activity;
}
/// <summary>
/// Make sure the layout of labels/text boxes on the screen
@@ -546,7 +545,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
CommCompletedHandler = null;
AllCompletedHandler = null;
UpdateRfidCommResult(testNames); /// TODO: Pass the test info in a correct way
UpdateRfidCommResult(tests); /// TODO: Pass the test info in a correct way
TBF.UiBridge.Bridge.OnTestCompleted(this, new TBF.UiBridge.TestCompletedEventArgs(StateMachine.Tests[0].Name, 0));
@@ -600,7 +599,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
iPerlCommunicationParams testParams = multiTestParams[i];
TBF.UiBridge.TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 10, 140, 0, 0, 0 });
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.JustStarted));
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.JustStarted));
string activity = testParams.Activity; /// Current activity
@@ -668,7 +667,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
break;
}
wmNr++;
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.FlowSetting));
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.FlowSetting));
}
if (!wmFound)
@@ -682,7 +681,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (stopWorkerThreads) break;
} /// for (int group
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.Completed));
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.Completed));
activityStep++;
if (stopWorkerThreads) break;
@@ -1183,19 +1182,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Update test result representing RFID communication success/failure
/// </summary>
/// <param name="test"></param>
void UpdateRfidCommResult(IList<string> testNames)
void UpdateRfidCommResult(IList<Config.Entities.Test> tests)
{
DateTime endTime = DateTime.Now;
int testTime = StateMachine.Time - startTimeSec;
if (!testNames.Contains(StateMachine.Tests[0].Name))
if (!tests.Contains(StateMachine.Tests[0]))
{
testNames.Insert(0, StateMachine.Tests[0].Name); /// Add RFID test as th 1st item
tests.Insert(0, StateMachine.Tests[0]); /// Add RFID test as the 1st item
}
foreach (var testName in testNames)
foreach (var test in tests)
{
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part);
if (tstRslt != null)
{
@@ -1210,7 +1209,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
for (int i = 0; i < Math.Min(ProcessData.BatchRslts.WMPositionsCount, waterMeters.Count); i++)
{
Results.Entities.MeterTestRslt meterRslt =
ProcessData.BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
ProcessData.BatchRslts.GetMeterTestRslt(test.Name, i, Config.Entities.CompoundMeterId.Single);
WaterMeters.iPerl.WaterMeter iPerl = waterMeters[i] as WaterMeters.iPerl.WaterMeter;
@@ -21,23 +21,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams);
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams);
///
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams)
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams)
{
StringBuilder sb = new StringBuilder();
IList<GenericDevices.IWaterMeter> wMtrs = new List<GenericDevices.IWaterMeter>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IWaterMeter)
{
GenericDevices.IWaterMeter wm = rr as GenericDevices.IWaterMeter;
wMtrs.Add(wm);
sb.AppendFormat(" {0}", wm.Name);
}
}
log.ErrorFormat("OpenIPerlCommForm(wms:{0})", sb);
myRef.modelessDlg = new iPerlCommunicationForm(WaterMeters, cfg, testName, testParams);
myRef.modelessDlg = new iPerlCommunicationForm(cfg, test, testParams);
myRef.modelessDlg.Show();
}
@@ -135,7 +123,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Show the modeless dialog with error indication
///
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, cfg, test.Name, testParams });
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, cfg, test, testParams });
//------------------------------------------------
Bridge.OnActivity(this, Strings.iPerl_Communication_in_progress);