summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-12-22 17:29:16 +0000
committeremkael <emkael@tlen.pl>2014-12-22 17:29:16 +0000
commit96ad0d57de6c17173cc677190ed0040931671840 (patch)
tree7d5356b7a6e24e277f5d5f384f3833180f8caa79
parent78b88a41a23a2b4630ca82024664673559623b5a (diff)
* 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
-rw-r--r--Analizator9000/Analizator9000/Accumulator.cs20
1 files 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
/// <summary>
/// List (well, a stack) of deals to process.
/// </summary>
- private Stack<String> deals;
+ protected Stack<String> deals;
/// <summary>
/// A back-reference to calling Form, for progress presentation purposes.
/// </summary>
- private Form1 form;
+ protected Form1 form;
/// <summary>
/// List of contracts to analyze in BCalc notation (integers for denomination and declarer).
/// </summary>
- private Dictionary<int, List<int>> contracts;
+ protected Dictionary<int, List<int>> contracts;
/// <summary>
/// Results file handle (version of StreamWriter initialized as synchronized).
/// </summary>
- private TextWriter outputFile;
+ protected TextWriter outputFile;
/// <summary>
/// Filename for analysis output.
/// </summary>
@@ -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();
/// <summary>
/// Callback method for worker threads, ends the single deal analysis, updates the total result and fires next analysis if necessary.
/// </summary>
@@ -264,7 +268,7 @@ namespace Analizator9000
/// Feeds the overall results with chunks of data from single contract analysis.
/// </summary>
/// <param name="result">Result of BCalc analysis.</param>
- private void update(BCalcResult result)
+ protected virtual void update(BCalcResult result)
{
int tricks = result.tricks;
int suit = BCalcWrapper.denominations.IndexOf(result.trumpSuit);