public static double Make(RaceInfo raceInfo, CynthiaPar cp ,CallOfTheRace callOfTheRace, double weight, double beatenLengths) { double distanceInFeet =0.0; double cynthiaPar = 0.0; double timeForTheCall = 0.0; switch (callOfTheRace) { case CallOfTheRace.First: distanceInFeet = raceInfo.FirstCallInFeet; timeForTheCall = raceInfo.FirstCall; cynthiaPar = cp.FirstCall; break; case CallOfTheRace.Second: distanceInFeet = raceInfo.SecondCallInFeet; timeForTheCall = raceInfo.SecondCall; cynthiaPar = cp.MidCall; break; case CallOfTheRace.Final: distanceInFeet = raceInfo.DistanceOfTheRaceInFeet; timeForTheCall = raceInfo.FinalTime; cynthiaPar = cp.FinalCall; break; } double d = distanceInFeet; double t = timeForTheCall; double w = weight; double dt = (120.0 - w) * 0.035; double unadjustedFigure = (distanceInFeet / cynthiaPar) - (distanceInFeet - beatenLengths * 10.0) / (t + dt); return unadjustedFigure + Adjustment(raceInfo, callOfTheRace); }
private void AddToGrid(CynthiaPar p1, CynthiaPar p2) { int rowIndex = _grid.Rows.Add(); DataGridViewCellCollection cells = _grid.Rows[rowIndex].Cells; cells[0].Value = p1.Distance; cells[1].Value = p1.Surface; cells[2].Value = p1.AboutFlag; cells[3].Value = p1.CynthiaClassification; cells[4].Value = Utilities.ConvertTimeToMMSSFifth(p1.FirstCall); cells[5].Value = Utilities.ConvertTimeToMMSSFifth(p1.MidCall); cells[6].Value = Utilities.ConvertTimeToMMSSFifth(p1.FinalCall); cells[7].Value = Utilities.ConvertTimeToMMSSFifth( p2.FirstCall); cells[8].Value = Utilities.ConvertTimeToMMSSFifth(p2.MidCall); cells[9].Value = Utilities.ConvertTimeToMMSSFifth(p2.FinalCall); double firstCallDiff = p1.FirstCall - p2.FirstCall; double secondCallDiff = p1.MidCall - p2.MidCall; double finalCallDiff = p1.FinalCall - p2.FinalCall; cells[10].Value = string.Format("{0:0.000}", finalCallDiff); cells[11].Value = string.Format("{0:0.000}", secondCallDiff); cells[12].Value = string.Format("{0:0.000}", finalCallDiff); double timeDiffPerFurlong = finalCallDiff / p1.DistanceInFurlongs; cells[13].Value = string.Format("{0:0.000}", timeDiffPerFurlong); if (p1.Surface == "T") { if (p1.IsRoute) { _timeDiffTurfRoute.Add(timeDiffPerFurlong); } else { _timeDiffTurfSprint.Add(timeDiffPerFurlong); } } else { if (p1.IsRoute) { _timeDiffDirtRoute.Add(timeDiffPerFurlong); } else { _timeDiffDirtSprint.Add(timeDiffPerFurlong); } } }
void CalculateAdjustedProjections(CynthiaPar cp0, CynthiaPar cp1, BrisPastPerformance pp) { double firstCallProjectionDiff = FirstCallAdjustment(cp0, cp1); double secondCallProjectionDiff = SecondCallAdjustment(cp0, cp1); double finalCallProjectionDiff = FinalCallAdjustment(cp0, cp1); BrisPastPerformance.FractionCallsToUseForCynthia f = pp.FractionsToUseForCynthia; double firstCallProjection = firstCallProjectionDiff + f.FirstCall; double secondCallProjection = secondCallProjectionDiff + f.SecondCall; double finalCallProjection = finalCallProjectionDiff + f.FinalCall; double variantDiff = (pp.AvgVariant-pp.TrackVariant) / 10.0; _txtboxFirstCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(firstCallProjection + (variantDiff * 1.0 / 4.0)); _txtboxSecondCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(secondCallProjection + (variantDiff * 2.0 / 3.0)); _txtboxFinalCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(finalCallProjection + (variantDiff * 4.0 / 4.0)); }
private void CalculateProjections(CynthiaPar cp0, CynthiaPar cp1, BrisPastPerformance pp) { double firstCallProjectionDiff = FirstCallAdjustment(cp0, cp1); double secondCallProjectionDiff = SecondCallAdjustment(cp0, cp1); double finalCallProjectionDiff = FinalCallAdjustment(cp0, cp1); BrisPastPerformance.FractionCallsToUseForCynthia f = pp.FractionsToUseForCynthia; double firstCallProjection = firstCallProjectionDiff + f.FirstCall; double secondCallProjection = secondCallProjectionDiff + f.SecondCall; double finalCallProjection = finalCallProjectionDiff + f.FinalCall; _txtboxFirstCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(firstCallProjection); _txtboxSecondCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(secondCallProjection); _txtboxFinalCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(finalCallProjection); }
double FirstCallAdjustment(CynthiaPar cp0, CynthiaPar cp1) { return ( (cp0.TrackCode != cp1.TrackCode) || (cp0.DistanceInYards != cp1.DistanceInYards)) ? cp0.FirstCall -cp1.FirstCall : 0.0; }
private void CalculateAdjustments(CynthiaPar cp0, CynthiaPar cp1) { _txtboxFirstCallAdj.Text = FirstCallAdjustment(cp0, cp1).ToString(); _txtboxSecondCallAdj.Text = SecondCallAdjustment(cp0, cp1).ToString(); _txtboxFinalCallAdj.Text = FinalCallAdjustment(cp0, cp1).ToString(); }
bool ShowCynthiaParsToGrid(DataGridView g, CynthiaPar cp, BrisPastPerformance pp) { bool cynthiaParWasChanged = false; g.Columns.Clear(); g.Columns.Add("Track", "Track"); g.Columns.Add("Class", "Class"); g.Columns.Add("Dist", "Dist"); g.Columns.Add("Surf", "Surf"); g.Columns.Add("About", "About"); g.Columns.Add("AvVar", "AvVar"); g.Columns.Add("1stCall", "1stCall"); g.Columns.Add("2ndCall", "2ndCall"); g.Columns.Add("Final", "Final"); if (cp.IsValid) { int i = g.Rows.Add(); g[0, i].Value = cp.TrackCode; g[1, i].Value = cp.CynthiaClassification; g[2, i].Value = cp.Distance; g[3, i].Value = cp.Surface; g[4, i].Value = cp.AboutFlag; g[6, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.FirstCall); g[7, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.MidCall); g[8, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.FinalCall); } else { string msg = string.Format("Sorry Cynthia par not found for \n {0} \n You want to add it manually? ", cp.ToString()); if (MessageBox.Show(msg, "Not found", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { AddCynthiaParManuallyForm f = new AddCynthiaParManuallyForm(cp); f.ShowDialog(); if (null != pp) { pp.Parent.ReloadCynthiaParForTheRace(); } else { return ShowCynthiaParsToGrid(_gridTodaysRacePars, _horse.Parent.CynthiaParsForTheRace, null); } cynthiaParWasChanged = true; } catch(Exception ex) { MessageBox.Show(ex.Message); } } } return cynthiaParWasChanged; }
private double SecondCallAdjustment(CynthiaPar cp0, CynthiaPar cp1) { return ((cp0.TrackCode != cp1.TrackCode) || (cp0.DistanceInYards != cp1.DistanceInYards)) ? cp0.MidCall - cp1.MidCall : 0.0; }
public void ReloadCynthiaParForTheRace() { _cynthiaParForTheRace = null; }
public AddCynthiaParManuallyForm(CynthiaPar cp) { _cp = cp; InitializeComponent(); }
private CynthiaPar FindMatch(CynthiaPar p1, List<CynthiaPar> par2) { foreach (CynthiaPar p2 in par2) { if (p1.Distance == p2.Distance && p1.Surface == p2.Surface && p1.AboutFlag == p2.AboutFlag && p1.CynthiaClassification == p2.CynthiaClassification) { return p2; } } return null; }