trait = "has-position"
doc = """
Daemons with this trait have one specific value that describes their current position.
This position can be set (using the set_position method).
In general, these daemons may not be able to reach exactly the set position.
The destination (get_destination) returns exactly the set position, while the position (get_position) returns the current actual position of the daemon.
These daemons should start motion and become busy when set_daemon is called.
They should release busy once they arrive as close as possible to the destination, and their position should not change until set_position is called again.
"""
requires = []

[state]

[state.position]
type = "double"
default = nan

[state.destination]
type = "double"
default = nan

[messages]

[messages.get_destination]
doc = "Get current daemon destination."
response = "double"

[messages.get_units]
doc = "Get units of daemon. These units apply to the position and destination fields."
response = ["null", "string"]

[messages.get_position]
doc = "Get current daemon position."
response = "double"

[messages.set_position]
doc = "Give the daemon a new destination, and begin motion towards that destination."
request = [
  {"name"="position", "type"="double"}
]

[messages.set_relative]
doc = "Give the daemon a new destination relative to its current position. Daemon will immediately begin motion towards new destination. Returns new destination."
request = [
  {"name"="distance", "type"="double"}
]
response = "double"

[fields]

[fields.position]
type = "record"
name = "field"
fields = {"getter"="get_position", "setter"="set_position", "dynamic"=true, "kind"="hinted", "type"="double"}

[fields.destination]
type = "record"
name = "field"
fields = {"getter"="get_destination", "dynamic"=true, "kind"="normal", "type"="double"}