DebugMode 'FailureDuringOperation' added. Redrawing results and reading iPerl opto-port more robust with extra exception handling, version 1.5.96.

This commit is contained in:
Milan Hanajik
2015-08-24 13:52:06 +02:00
parent 31fc49485a
commit d4399c23ca
5 changed files with 103 additions and 79 deletions
@@ -135,80 +135,93 @@ namespace TBF.Screens
/// </summary>
void RedrawAll()
{
///
/// Determine whether combined meter results are displayed
///
combined = ((testResults != null) &&
(testResults.Count > 0) &&
(testResults[0].MetersKind == Entities.MetersKind.Combined));
this.SuspendLayout();
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
bool[] wmIsEnabled = new bool[Program.WMsCount];
try
{
///
/// Determine whether combined meter results are displayed
///
combined = ((testResults != null) &&
(testResults.Count > 0) &&
(testResults[0].MetersKind == Entities.MetersKind.Combined));
if (combined)
{
enabledWMsCount = Program.CompoundWMsCount;
}
else
{
for (int mtr0 = 0; mtr0 < Program.WMsCount; mtr0++)
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
bool[] wmIsEnabled = new bool[Program.WMsCount];
if (combined)
{
if (testResults != null)
{
for (int t = 0; t < testResults.Count; t++)
{
if ((testResults[t].Meters.Count > mtr0) && !testResults[t].Meters[mtr0].Disabled)
{
wmIsEnabled[mtr0] = true;
enabledWMsCount++;
break;
}
}
}
enabledWMsCount = Program.CompoundWMsCount;
}
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + NrMetersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == Forms.ResultsConfig.Meters.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int mtr = 1; mtr <= (combined ? Program.CompoundWMsCount : Program.WMsCount); mtr++)
{
if (combined || (testResults != null && testResults.Count > 0 && wmIsEnabled[mtr - 1]))
else
{
if (TestsArrangement == Forms.ResultsConfig.TestsAre.Rows)
for (int mtr0 = 0; mtr0 < Program.WMsCount; mtr0++)
{
ListView lview = GetResultsTestsAreRows(mtr, mtr);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
if (testResults != null)
{
for (int t = 0; t < testResults.Count; t++)
{
if ((testResults[t].Meters.Count > mtr0) && !testResults[t].Meters[mtr0].Disabled)
{
wmIsEnabled[mtr0] = true;
enabledWMsCount++;
break;
}
}
}
}
else
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + NrMetersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == Forms.ResultsConfig.Meters.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int mtr = 1; mtr <= (combined ? Program.CompoundWMsCount : Program.WMsCount); mtr++)
{
if (combined || (testResults != null && testResults.Count > 0 && wmIsEnabled[mtr - 1]))
{
ListView lview = GetResultsTestsAreColumns(mtr, mtr);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
if (TestsArrangement == Forms.ResultsConfig.TestsAre.Rows)
{
ListView lview = GetResultsTestsAreRows(mtr, mtr);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
else
{
ListView lview = GetResultsTestsAreColumns(mtr, mtr);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
}
}
}
catch (Exception e)
{
log.FatalFormat("Redrawing results failed : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
}
this.ResumeLayout(false);
}