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 17:38:09 +01:00
parent bfa506911c
commit a4331c8267
6 changed files with 75 additions and 95 deletions

View File

@ -13,7 +13,7 @@ namespace TBF.BenchControl.DataEntry.iPerl
public class EntryForm : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm, IHasWMStatesForm
{
private static readonly ILog log = LogManager.GetLogger(typeof(EntryForm));
public override string ToString() { return string.Format("DataEntry.Standard24({0})", Cfg.ToString(1)); }
public override string ToString() { return string.Format("DataEntry.iPerl({0})", Cfg.ToString(1)); }
readonly EntryFormCfg entryFormCfg;

View File

@ -24,29 +24,22 @@ namespace TBF.BenchControl.Sequences
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<string> testNames, IList<Generic.ITestParams> multiTestParams);
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
///
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<string> testNames, IList<Generic.ITestParams> multiTestParams)
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
{
try
{
/// 1st argument
IList<GenericDevices.IWaterMeter> wMtrs = new List<GenericDevices.IWaterMeter>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IWaterMeter) wMtrs.Add(rr as GenericDevices.IWaterMeter);
}
/// 2nd argument
/// 1nd argument
TestMethods.iPerlCommunication.TestMethodCfg iPerlCfg = cfg as TestMethods.iPerlCommunication.TestMethodCfg;
/// 3rd argument: as is
/// 2rd argument: as is
/// 4th argument
/// 3th argument
IList<TestMethods.iPerlCommunication.iPerlCommunicationParams> iPerlCommParams = new List<TestMethods.iPerlCommunication.iPerlCommunicationParams>();
foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as TestMethods.iPerlCommunication.iPerlCommunicationParams);
myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(wMtrs, iPerlCfg, testNames, iPerlCommParams);
myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(iPerlCfg, tests, iPerlCommParams);
myRef.modelessDlg.Show();
}
catch (Exception e)
@ -92,12 +85,12 @@ namespace TBF.BenchControl.Sequences
int simultWithPurgingCount = 0;
Generic.IComponentCfg simultWithPurgingCfg = null;
IList<string> simultWithPurgingNames = new List<string>();
IList<Config.Entities.Test> simultWithPurgingTests = new List<Config.Entities.Test>();
IList<Generic.ITestParams> simultWithPurgingParams = new List<Generic.ITestParams>();
int simultWithEvacuationCount = 0;
Generic.IComponentCfg simultWithEvacuationCfg = null;
IList<string> simultWithEvacuationNames = new List<string>();
IList<Config.Entities.Test> simultWithEvacuationTests = new List<Config.Entities.Test>();
IList<Generic.ITestParams> simultWithEvacuationParams = new List<Generic.ITestParams>();
StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked
@ -317,7 +310,7 @@ namespace TBF.BenchControl.Sequences
///
simultWithPurgingCount = 0;
simultWithPurgingCfg = null;
simultWithPurgingNames.Clear();
simultWithPurgingTests.Clear();
simultWithPurgingParams.Clear();
///
foreach (var test in StateMachine.Tests)
@ -341,7 +334,7 @@ namespace TBF.BenchControl.Sequences
break;
}
simultWithPurgingNames.Add(test.Name);
simultWithPurgingTests.Add(test);
simultWithPurgingParams.Add(testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams);
simultWithPurgingCount++;
}
@ -351,7 +344,7 @@ namespace TBF.BenchControl.Sequences
///
simultWithEvacuationCount = 0;
simultWithEvacuationCfg = null;
simultWithEvacuationNames.Clear();
simultWithEvacuationTests.Clear();
simultWithEvacuationParams.Clear();
///
for (int i = StateMachine.Tests.Count - 1; i >= simultWithPurgingCount; i--)
@ -377,7 +370,7 @@ namespace TBF.BenchControl.Sequences
break;
}
simultWithEvacuationNames.Insert(0, test.Name);
simultWithEvacuationTests.Insert(0, test);
simultWithEvacuationParams.Insert(0, testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams);
simultWithEvacuationCount++;
}
@ -389,7 +382,7 @@ namespace TBF.BenchControl.Sequences
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop;
/// Open iPerlCommunicationForm
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingNames, simultWithPurgingParams });
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingTests, simultWithPurgingParams });
}
///
@ -706,7 +699,7 @@ namespace TBF.BenchControl.Sequences
if (simultWithEvacuationCount > 0)
{
/// Open iPerlCommunicationForm
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationNames, simultWithEvacuationParams });
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams });
}
//--------------------------------------------------------

View File

@ -67,7 +67,7 @@ namespace TBF.BenchControl.Sequences
protected static BenchControl.FeedingPath inPath;
protected static BenchControl.BenchPath benchPath;
protected static BenchControl.OutputPath outPath;
protected static BenchControl.MetersPath sensPath;
public static BenchControl.MetersPath sensPath;
protected static TransitionSequence transitionBefore;
protected static TransitionSequence transitionAfter;

View File

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

View File

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

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.1.188.1")]
[assembly: AssemblyFileVersion("2.1.188.1")]
[assembly: AssemblyVersion("2.1.190.1")]
[assembly: AssemblyFileVersion("2.1.190.1")]