wiki:ScoringFormulas

Version 43 (modified by Stein Tore Erdal, 12 years ago) (diff)

--

Scoring Formulas




Create a scoring formula (!! 20090517: NOTE: explanation is under work, by no means complete (or even correct) !!)

Does only apply to FS versions >= 1.2.13 (the prinsiple is the same for earlier versions but some details differ).

  1. Create a DLL (Class Library) named "!FsSf_<formula id>.dll".
  2. Set a reference to FsSf.dll.
  3. Set AssemblyTitle to <formula id>.
  4. Set AssemblyDescription to the description that should show when one select scoring formula in FS.
  5. Create a class named "Sf" implementing the interface FsSf.Isf
    (public class Sf : ISf ...)
  6. Compile and put the DLL in the folder where FsComp.exe is and it should show up on the list for selecting a scoring formula.

The "EditScoreFormula" method is called from FsComp when one select and edits a scoring formula.

The "ScoreTask" method is called when the menuitem Tasks > Score Task is used, or when any report is created (Reports > ...) and the task needs to be scored because there has been changes.

(any time one changes anything about one or more pilot's flightdata in a task, all FsResult? elements for that task will be removed).


From FsSf.dll:

/*

XML elements that have usefull information about the task and flightdata:
FsScoreFormula (attributes are set by the EditScoreFormula method)
FsTaskScoreParams (attributes are calculated before the ScoreTask method is called)
FsParticipants/FsParticipant/FsFlightData
FsParticipants/FsParticipant/FsResult

Example of FsTaskScoreParams:
ss_distance="37.706" 
task_distance="39.901" 
no_of_pilots_present="46" 
no_of_pilots_flying="45" 
no_of_pilots_lo="6" 
no_of_pilots_reaching_nom_dist="45" 
no_of_pilots_reaching_es="39" 
no_of_pilots_reaching_goal="39" 
sum_flown_distance="1659.459" 
best_dist="39.902" 
best_time="0.896388888888889" 
worst_time="2.06222222222222" 
no_of_pilots_in_competition="63"

*/

namespace ...
{
  public interface ISf
  {
    /// <summary>
    /// Should only change the FsParticipants/FsParticipant/FsResult under the xe_task_clone element.
    /// Remove any existing FsResult elements and add a new one for each pilot in task that has a FsFlightData element.
    /// FsParticipants/FsParticipant elements with no FsFlightData element is ABS and should not be counted in scoring.
    /// Empty FsFlightData element means DNF. DNF pilot may affect scoring.
    /// Best not to change anything else or FS might be confused.
    /// </summary>
    /// <param name="xe_task_clone">A clone of FsTask element. Should not have any parent.
    /// To access the rest of the fsdb xml document use OwnerDocument property of the param.</param>
    /// <param name="msg">any messages regarding scoring</param>
    /// <returns>true if task was scored, false if not.</returns>
    bool ScoreTask(XmlElement xe_task_clone, out string msg);

    /// <summary>
    /// Should provide a UI for setting scoring formula params.
    /// Should only change the xe_sf_clone element.
    /// Best not to change anything else or FS might be confused.
    /// </summary>
    /// <param name="xe_sf_clone">A clone of a FsScoreFormula element. Should not have any parent.
    /// To access the rest of the fsdb xml document use OwnerDocument property of the param.</param>
    /// <returns>Return true if any changes to xe_sf_clone where done, false if not.</returns>
    bool EditScoreFormula(XmlElement xe_sf_clone);
  }
}

Attachments (9)

Download all attachments as: .zip