liveshot-protocol
v0.1.0-b-14
Published
Builders for protocol data formats used in LiveShot.
Downloads
6
Readme
LiveShot protocol
Protocol specification for data formats used in LiveShot. The protocol is implemented through various builders.
Data Objects
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 is1000mm
, and the gauge diameter is8mm
, the value ofgaugeSize
should be8mm / 1000mm = .008
. - < string >
targetID
For valid values oftargetID
, see List of implemented targets in liveshot-core.
ConfigBuilder
should be used to create CardConfig
objects.
Builders
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 newRange
object and copies all relevant fields fromrawRange
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validRange
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 providedcards
and adds them to an empty array. - resetCards() - ( RangeBuilder )
Resets the current list of cards - addCard(< Card >card) - ( RangeBuilder )
Adds a
Card
object to thecards
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 newCard
object and copies all relevant fields fromrawCard
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validCard
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 oftargetID
, 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 shotvalue
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 newShooter
object and copies all relevant fields fromrawShooter
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validShooter
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 fromshooter
- 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 newResult
object and copies all relevant fields fromrawResult
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validResult
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 fromresult
- 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 shotvalue
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 newShot
object and copies all relevant fields fromrawShot
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validShot
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 newConfig
object and copies all relevant fields fromrawConfig
, omitting all non-relevant fields and inserting default values for missing fields. The returned object is guaranteed to be a validConfig
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 fromconfig
- setGaugeSize(< number >gaugeSize) - ( ConfigBuilder )
- setTargetID(< string >targetID) - ( ConfigBuilder )
For valid values oftargetID
, see List of implemented targets in liveshot-core.