iPerlCommunicationForm : Better try/catch, more logging, ver. 2.18.1152
This commit is contained in:
parent
138e436645
commit
5586f58c6e
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2019 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
using System;
|
||||
@ -24,5 +24,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
this.CommMessage = commMessage;
|
||||
this.CommErr = commErr;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Thread={0} WMNr0={1} IHead={2} WM={3} CommMsg={4} CommErr={5}",
|
||||
ThreadId,
|
||||
WMNr0,
|
||||
(Ihead != null) ? Ihead.Name : "null",
|
||||
Wm.WMPosition,
|
||||
(CommMessage != null) ? CommMessage : "null",
|
||||
CommErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2187,100 +2187,108 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
void DoOnCommCompleted(object sender, CommCompletedEventArgs data)
|
||||
{
|
||||
///
|
||||
/// Update the text message
|
||||
///
|
||||
if (data.WMNr0 >= 0) messages[data.WMNr0].Text = data.CommMessage;
|
||||
try
|
||||
{
|
||||
///
|
||||
/// Update the text message
|
||||
///
|
||||
if (data.WMNr0 >= 0) messages[data.WMNr0].Text = data.CommMessage;
|
||||
|
||||
///
|
||||
/// Update head active/inactive switch
|
||||
///
|
||||
if (data.WMNr0 >= 0 && data.CommErr == CommErr.HeadDisabledByUser)
|
||||
{
|
||||
/// iPerl head was disabled by the user
|
||||
ckbState[data.WMNr0] = false;
|
||||
checkBoxes[data.WMNr0].Checked = false;
|
||||
checkBoxes[data.WMNr0].Enabled = false;
|
||||
if (data.Ihead != null) data.Ihead.Disabled = true;
|
||||
if (data.Wm != null) data.Wm.Disabled = true;
|
||||
}
|
||||
else if (data.WMNr0 >= 0 && data.CommErr == CommErr.None)
|
||||
{
|
||||
/// One RFID communication successful => iPerl cannot be disabled by the user anymore
|
||||
ckbState[data.WMNr0] = true;
|
||||
checkBoxes[data.WMNr0].Checked = true;
|
||||
checkBoxes[data.WMNr0].Enabled = false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Update opto-communication indication
|
||||
///
|
||||
for (int i = 0; i < iperlHeads.Count; i++)
|
||||
{
|
||||
if (iperlHeads[i] == null || iperlHeads[i].Disabled)
|
||||
///
|
||||
/// Update head active/inactive switch
|
||||
///
|
||||
if (data.WMNr0 >= 0 && data.CommErr == CommErr.HeadDisabledByUser)
|
||||
{
|
||||
counters[i].BackColor = DisabledColor;
|
||||
/// iPerl head was disabled by the user
|
||||
ckbState[data.WMNr0] = false;
|
||||
checkBoxes[data.WMNr0].Checked = false;
|
||||
checkBoxes[data.WMNr0].Enabled = false;
|
||||
if (data.Ihead != null) data.Ihead.Disabled = true;
|
||||
if (data.Wm != null) data.Wm.Disabled = true;
|
||||
}
|
||||
else if (data.WMNr0 >= 0 && data.CommErr == CommErr.None)
|
||||
{
|
||||
/// One RFID communication successful => iPerl cannot be disabled by the user anymore
|
||||
ckbState[data.WMNr0] = true;
|
||||
checkBoxes[data.WMNr0].Checked = true;
|
||||
checkBoxes[data.WMNr0].Enabled = false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Update opto-communication indication
|
||||
///
|
||||
for (int i = 0; i < iperlHeads.Count; i++)
|
||||
{
|
||||
if (iperlHeads[i] == null || iperlHeads[i].Disabled)
|
||||
{
|
||||
counters[i].BackColor = DisabledColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHeads[i].CheckFlowDirection())
|
||||
{
|
||||
case OptoHeadState.OptoAndDirOK:
|
||||
counters[i].BackColor = OptoAndDirOKColor;
|
||||
break;
|
||||
|
||||
case OptoHeadState.DirNok:
|
||||
counters[i].BackColor = DirNokColor;
|
||||
break;
|
||||
|
||||
default:
|
||||
case OptoHeadState.OptoNok:
|
||||
counters[i].BackColor = OptoNokColor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !TURA_SPECIAL
|
||||
///
|
||||
/// Branch
|
||||
///
|
||||
lock (this)
|
||||
{
|
||||
completedCommCount++;
|
||||
if (cfg.UseMuxBoards && completedCommCount < muxBrdOrGroup14Nrs.Count) return;
|
||||
if (!cfg.UseMuxBoards && completedCommCount < 4) return;
|
||||
completedCommCount = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (currentGroup < lastGroup)
|
||||
{
|
||||
/// Go to the next step / next group
|
||||
if (quido != null)
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
currentGroup++;
|
||||
}
|
||||
else if (currentActivityStep + 1 < multiTestParams.Count)
|
||||
{
|
||||
currentGroup = 0;
|
||||
currentActivityStep++;
|
||||
activityLabel.Text = multiTestParams[currentActivityStep].Activity;
|
||||
if (quido != null)
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
currentGroup++;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHeads[i].CheckFlowDirection())
|
||||
{
|
||||
case OptoHeadState.OptoAndDirOK:
|
||||
counters[i].BackColor = OptoAndDirOKColor;
|
||||
break;
|
||||
|
||||
case OptoHeadState.DirNok:
|
||||
counters[i].BackColor = DirNokColor;
|
||||
break;
|
||||
|
||||
default:
|
||||
case OptoHeadState.OptoNok:
|
||||
counters[i].BackColor = OptoNokColor;
|
||||
break;
|
||||
}
|
||||
/// Wait until all threads are finished
|
||||
workerThreads[data.ThreadId].Join(2000);
|
||||
NormalClose();
|
||||
}
|
||||
}
|
||||
|
||||
#if !TURA_SPECIAL
|
||||
///
|
||||
/// Branch
|
||||
///
|
||||
lock (this)
|
||||
catch (Exception e)
|
||||
{
|
||||
completedCommCount++;
|
||||
if (cfg.UseMuxBoards && completedCommCount < muxBrdOrGroup14Nrs.Count) return;
|
||||
if (!cfg.UseMuxBoards && completedCommCount < 4) return;
|
||||
completedCommCount = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (currentGroup < lastGroup)
|
||||
{
|
||||
/// Go to the next step / next group
|
||||
if (cfg.UseMuxBoards && (quido != null))
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
currentGroup++;
|
||||
}
|
||||
else if (currentActivityStep + 1 < multiTestParams.Count)
|
||||
{
|
||||
currentGroup = 0;
|
||||
currentActivityStep++;
|
||||
activityLabel.Text = multiTestParams[currentActivityStep].Activity;
|
||||
if (cfg.UseMuxBoards && (quido != null))
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
currentGroup++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Wait until all threads are finished
|
||||
workerThreads[data.ThreadId].Join(2000);
|
||||
NormalClose();
|
||||
log.ErrorFormat("DoOnCommCompleted({0}) failed: {1}", data, e.Message);
|
||||
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1151.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1151.0")]
|
||||
[assembly: AssemblyVersion("2.18.1152.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1152.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user