From 96ad0d57de6c17173cc677190ed0040931671840 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 22 Dec 2014 17:29:16 +0000 Subject: * adjusting result accumulator for inheritance purposes * fixing issue when number of deals was smaller than 10 (default accumulator portion) git-svn-id: https://svn.emkael.info/an9k@39 05ec0d5d-773b-4d93-9e23-c81a7ac79feb --- Analizator9000/Analizator9000/Accumulator.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Analizator9000/Analizator9000/Accumulator.cs b/Analizator9000/Analizator9000/Accumulator.cs index 9ed04cf..be5e714 100644 --- a/Analizator9000/Analizator9000/Accumulator.cs +++ b/Analizator9000/Analizator9000/Accumulator.cs @@ -26,19 +26,19 @@ namespace Analizator9000 /// /// List (well, a stack) of deals to process. /// - private Stack deals; + protected Stack deals; /// /// A back-reference to calling Form, for progress presentation purposes. /// - private Form1 form; + protected Form1 form; /// /// List of contracts to analyze in BCalc notation (integers for denomination and declarer). /// - private Dictionary> contracts; + protected Dictionary> contracts; /// /// Results file handle (version of StreamWriter initialized as synchronized). /// - private TextWriter outputFile; + protected TextWriter outputFile; /// /// Filename for analysis output. /// @@ -107,6 +107,10 @@ namespace Analizator9000 { portionSize = this.portionSize; } + if (portionSize > this.deals.Count) + { + portionSize = this.deals.Count; + } int toRun = Math.Min(portionSize, this.deals.Count); for (int i = 0; i < toRun; i++) { @@ -148,10 +152,10 @@ namespace Analizator9000 if (!this.abort) { String line = "#" + result.dealNo + ", " + result.declarer + " gra w " + result.trumpSuit + ", lew: " + result.tricks; - this.update(result); - this.form.setResult(this.getString()); this.form.addStatusLine(line); this.outputFile.WriteLine(line); + this.update(result); + this.form.setResult(this.getString()); } } catch (Exception ex) @@ -181,7 +185,7 @@ namespace Analizator9000 this.abort = true; } - private Object threadLock = new Object(); + protected Object threadLock = new Object(); /// /// Callback method for worker threads, ends the single deal analysis, updates the total result and fires next analysis if necessary. /// @@ -264,7 +268,7 @@ namespace Analizator9000 /// Feeds the overall results with chunks of data from single contract analysis. /// /// Result of BCalc analysis. - private void update(BCalcResult result) + protected virtual void update(BCalcResult result) { int tricks = result.tricks; int suit = BCalcWrapper.denominations.IndexOf(result.trumpSuit); -- cgit v1.2.3