yaq/traits/is-discrete


The is-discrete trait is used for hardware that has a countable number of discrete positions, each with a unique identifier. This trait requires the has-position trait, and discrete hardware must support all of the 'normal' methods such as set_position and get_destination. Hardware with this trait simply offer an additional identifier mapping on top of the existing position and destination behavior. A convinience method 'set_identifier' allows clients to provide identifiers instead of raw positions, if desired.

requires

has-position

state

Daemons with the is-discrete trait will provide the following state information:

position_identifier (string)

position (number)
from has-position

destination (number)
from has-position

methods

Daemons with the is-discrete trait expose the following public methods:

get_position_identifiers ➜ {string: number ...}
Get position identifiers. Identifiers may not change at runtime.

set_identifier ➜ number
Set using an identifier.
Arguments:

identifier, {'type': 'string'}

get_identifier ➜ string|NULL
Get current identifier string. Current identifier may be None.

get_destination ➜ number
Get current daemon destination.
from has-position

get_units ➜ string
Get units of daemon. These units apply to the position and destination fields.
from has-position

get_position ➜ number
Get current daemon position.
from has-position

set_position
Give the daemon a new destination, and begin motion towards that destination.
from has-position
Arguments:

position, {'type': 'number'}

set_relative ➜ number
Give the daemon a new destination relative to its current position. Daemon will immediately begin motion towards new destination. Returns new destination.
from has-position
Arguments:

distance, {'type': 'number'}


built 2020-05-24 18:31:17                                      CC0: no copyright