liveshot-protocol

Builders for protocol data formats used in LiveShot.

LiveShot protocol

Protocol specification for data formats used in LiveShot. The protocol is implemented through various builders.

This section contains definitions of the data objects used by LiveShot. These objects represent the data format provided by the parser library, and accepted by the display library.

Range
This definition is considered a draft and is subject to change.

  • < string >host The display name of the host of the shooting. This is typically the name of the host club, ex: 'Rygge SKL'
  • < string >name The range display name, ex: '100m'
  • < string >relay The display name for the relay, ex: '1'
  • < iterable >cards
    • Contains zero or more < Card > objects, the keys of this object can be anything, as long as they iterate in the correct order. Typically this is just an array containing zero or more cards.

Card

  • < string >lane
    The display name for the lane, ex: '1'
  • < Shooter >shooter
    See Shooter below.
  • < Result >result
    See Result below.
  • < CardConfig >config
    See CardConfig below.

CardBuilder should be used to create Card objects, including its subobjects.

Shooter

  • < string >name
    The display name for the shooter, ex: 'Martin V. Larsen'
  • < string >club
    The display name of the club of the shooter, ex: 'Rygge'
  • < string >className
    The class of the shooter, ex: 'V55'
  • < string >category
    The the category of the shooter, ex: 'LF'

Either use ShooterBuilder to build directly, or use the convenience methods of CardBuilder to build indirectly.

Result

  • < string >seriesName
    The display name for the series, ex: 'Prone'
  • < string >seriesSum The sum of the current series, formatted for display, ex: '50'
  • < string >totalSum The total sum of the card, formatted for display, ex: '150'
  • < boolean >marking Indicates whether this is a marking series (i.e. 'tellende'). Used for displaying test triangle on test series.
  • < iterable >shots
    • Contains zero or more < Shot > objects, the keys of this object can be anything, as long as they iterate in the correct order. Typically these keys are just normal numeric indices as in an array.

Either use ResultBuilder to build directly, or use the convenience methods of CardBuilder to build indirectly.

Shot

  • < number >x
    The x-coordinate of the center of the shot. This should be normalized, such that -1 <= x <= 1.
  • < number >y
    The y-coordinate of the center of the shot. This should be normalized, such that -1 <= y <= 1.
  • < string >value
    value is the shot value, appropriately formatted for display, ex: 'X.0'

Either use ShotBuilder to build directly, or use addShotData of ResultBuilder or CardBuilder.

CardConfig

  • < number >gaugeSize
    The size of the gauge (similar to diameter of the bullet) relative to the target size. For instance, if the target diameter is 1000mm, and the gauge diameter is 8mm, the value of gaugeSize should be 8mm / 1000mm = .008.
  • < string >targetID For valid values of targetID, see List of implemented targets in liveshot-core.

ConfigBuilder should be used to create CardConfig objects.

RangeBuilder
Builds Range objects. All setters return reference to the builder, for convenience.

var range = new RangeBuilder()
    .setHost('Rygge SKL')
    .setName('300m')
    .setRelay('1')
    .setCards(cards)
    .getRange();
  • (static method) RangeBuilder.createBlankRange() - ( Range )
    Creates and returns a new empty range, with all fields present, but set to empty placeholder values.
  • (static method) RangeBuilder.sanitizeRange(< object >rawRange) - ( Range )
    Creates a new Range object and copies all relevant fields from rawRange, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Range object.
  • reset() - ( RangeBuilder )
    Resets the current range. Returns pointer to the builder for convenience.
  • getRange() - ( Range )
    Returns a copy of the current range
  • setHost(< string >host) - ( RangeBuilder )
  • setName(< string >range) - ( RangeBuilder )
  • setRelay(< string >relay) - ( RangeBuilder )
  • setCards(< iterable >cards) - ( RangeBuilder ) cards should be as described above. This method iterates through the provided cards and adds them to an empty array.
  • resetCards() - ( RangeBuilder )
    Resets the current list of cards
  • addCard(< Card >card) - ( RangeBuilder ) Adds a Card object to the cards key of the current range. These cards are inserted in the same order they are added.

CardBuilder
Builds Card objects. All setters return reference to the builder, for convenience.

var card = new CardBuilder()
    .setLane('1')
    .setName('Martin V. Larsen')
    .setClub('Rygge')
    .setClassName('4')
    .setCategory('A')
    .setSeriesName('Ligg')
    .addShotData(.1, 0, 'X.0')
    .addShotData(0, -.1, 'X.0')
    .addShotData(.071, .071, 'X.0')
    .addShotData(.071, -.071, 'X.0')
    .addShotData(-.071, .071, 'X.0')
    .setSeriesSum('50')
    .setTotalSum('150')
    .setMarking(false)
    .setGaugeSize(.00533)
    .setTargetID('NO-DFS_300M')
    .getCard();
  • (static method) CardBuilder.createBlankCard() - ( Card )
    Creates and returns a new empty card, with all fields present, but set to empty placeholder values.
  • (static method) CardBuilder.sanitizeCard(< object >rawCard) - ( Card )
    Creates a new Card object and copies all relevant fields from rawCard, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Card object.
  • reset() - ( CardBuilder )
    Resets the current card. Returns pointer to the builder for convenience.
  • getCard() - ( Card )
    Returns a copy of the current card
  • setLane(< string >lane) - ( CardBuilder )
  • setName(< string >name) - ( CardBuilder )
  • setClub(< string >club) - ( CardBuilder )
  • setClassName(< string >className) - ( CardBuilder )
  • setCategory(< string >category) - ( CardBuilder )
  • setSeriesName(< string >seriesName) - ( CardBuilder )
  • setSeriesSum(< string >seriesSum) - ( CardBuilder )
  • setTotalSum(< string >totalSum) - ( CardBuilder )
  • setMarking(< boolean >marking) - ( CardBuilder )
  • setGaugeSize(< number >gaugeSize) - ( CardBuilder )
  • setTargetID(< string >targetID) - ( CardBuilder )
    For valid values of targetID, see List of implemented targets in liveshot-core.
  • setShooter(< Shooter >shooter) - ( CardBuilder )
    shooter should be as described above
  • setResult(< Result >result) - ( CardBuilder )
    result should be as described above
  • setConfig(< CardConfig >config) - ( CardBuilder )
    config should be as described above
  • setShots(< iterable >shots) - ( CardBuilder )
    shots should be as described above
  • resetShots() - ( CardBuilder )
    Resets the current list of shots
  • addShot(< Shot >shot) - ( CardBuilder )
    shot should be as described above
  • addShotData(< number >x, < number >y, < string >value) - ( CardBuilder )
    -1 <= x, y <= 1, where (x, y) represent the center of the shot
    value is the shot value, appropriately formatted for displaying

ShooterBuilder
Builds Shooter objects. All setters return reference to the builder, for convenience.

var shooter = new ShooterBuilder()
    .setName('Martin V. Larsen')
    .setClub('Rygge')
    .setClassName('4')
    .setCategory('A')
    .getShooter();
  • (static method) ShooterBuilder.createBlankShooter() - ( Shooter )
    Creates and returns a new empty shooter object, with all fields present, but set to empty placeholder values.
  • (static method) ShooterBuilder.sanitizeShooter(< object >rawShooter) - ( Shooter )
    Creates a new Shooter object and copies all relevant fields from rawShooter, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Shooter object.
  • reset() - ( ShooterBuilder )
    Resets the current shooter object.
  • getShooter() - ( Shooter )
    Returns a copy of the current shooter object
  • setShooter(< object >shooter) - ( ShooterBuilder )
    Copies all relevant fields from shooter
  • setName(< string >name) - ( ShooterBuilder )
  • setClub(< string >club) - ( ShooterBuilder )
  • setClassName(< string >className) - ( ShooterBuilder )
  • setCategory(< string >category) - ( ShooterBuilder )

ResultBuilder
Builds Result objects. All setters return reference to the builder, for convenience.

var result = new ResultBuilder()
    .setSeriesName('Ligg')
    .setSeriesSum('50')
    .setTotalSum('150')
    .setMarking(false)
    .addShot(shot)
    .addShotData(0, -.1, 'X.0')
    .addShotData(.071, .071, 'X.0')
    .addShotData(.071, -.071, 'X.0')
    .addShotData(-.071, .071, 'X.0')
    .getResult();
  • (static method) ResultBuilder.createBlankResult() - ( Result )
    Creates and returns a new empty result object, with all fields present, but set to empty placeholder values.
  • (static method) ResultBuilder.sanitizeResult(< object >rawResult) - ( Result )
    Creates a new Result object and copies all relevant fields from rawResult, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Result object.
  • reset() - ( ResultBuilder )
    Resets the current result object.
  • getResult() - ( Result )
    Returns a copy of the current result object
  • setResult(< Result >result) - ( ResultBuilder )
    Copies all relevant fields from result
  • setSeriesName(< string >seriesName) - ( ResultBuilder )
  • setSeriesSum(< string >seriesSum) - ( ResultBuilder )
  • setTotalSum(< string >totalSum) - ( ResultBuilder )
  • setMarking(< boolean >marking) - ( ResultBuilder )
  • setShots(< iterable >shots) - ( ResultBuilder )
    shots should be as described above
  • resetShots() - ( ResultBuilder )
    Resets the current list of shots
  • addShot(< Shot >shot) - ( ResultBuilder )
    shot should be as described above
  • addShotData(< number >x, < number >y, < string >value) - ( ResultBuilder )
    -1 <= x, y <= 1, where (x, y) represent the center of the shot
    value is the shot value, appropriately formatted for displaying

ShotBuilder

var shot = new ShotBuilder()
    .setPosition(.1, 0)
    .setValue('X.0')
    .getShot();

Builds Shot objects. All setters return reference to the builder, for convenience.

  • (static method) ShotBuilder.createBlankShot() - ( Shot )
    Creates and returns a new empty shot object, with all fields present, but set to empty placeholder values.
  • (static method) ShotBuilder.sanitizeShot(< object >rawShot) - ( Shot )
    Creates a new Shot object and copies all relevant fields from rawShot, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Shot object.
  • reset() - ( ShotBuilder )
    Resets the current shot object.
  • getShot() - ( Shot )
    Returns a copy of the current shot object
  • setValue(< string >value) - ( ShotBuilder )
  • setPosition(< number >x, < number >y) - ( ShotBuilder )
    x and y should be normalized (i.e. -1 <= x, y <= 1)
  • setX(< number >x) - ( ShotBuilder )
    x should be normalized (i.e. -1 <= x <= 1)
  • setY(< number >y) - ( ShotBuilder )
    y should be normalized (i.e. -1 <= y <= 1)

ConfigBuilder
Builds Config objects. All setters return reference to the builder, for convenience.

var config = new ConfigBuilder()
    .setGaugeSize(.00533)
    .setTargetID('NO-DFS_300M')
    .getConfig();
  • (static method) ConfigBuilder.createBlankConfig() - ( CardConfig )
    Creates and returns a new empty config object, with all fields present, but set to empty placeholder values.
  • (static method) ConfigBuilder.sanitizeConfig(< object >rawConfig) - ( Config )
    Creates a new Config object and copies all relevant fields from rawConfig, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a valid Config object.
  • reset() - ( ConfigBuilder )
    Resets the current config object.
  • getConfig() - ( CardConfig )
    Returns a copy of the current config object
  • setConfig(< object >config) - ( ConfigBuilder )
    Copies all relevant fields from config
  • setGaugeSize(< number >gaugeSize) - ( ConfigBuilder )
  • setTargetID(< string >targetID) - ( ConfigBuilder )
    For valid values of targetID, see List of implemented targets in liveshot-core.