trait = "has-limits"
doc = """
The has-limits trait extends the has-positions trait with limits.
It's assumed that any position within the limits is valid.
"""
requires = ["has-position"]

[config]

[config.limits]
type = "array"
items = "double"
default = [-inf, +inf]
doc = "Configuration limits are strictly optional."

[config.out_of_limits]
type = "enum"
name = "out_of_limits"
symbols = ["closest", "ignore", "error"]
default = "closest"
doc = "Control behavior of daemon when set_position is given a value outside of limits."

[state]

[state.hw_limits]
type = "array"
items = "double"
default = [-inf, +inf]

[messages]

[messages.get_limits]
doc = "Get daemon limits.Limits will be the <a href='https://en.wikipedia.org/wiki/Intersection_(set_theory)'>intersection</a> of config limits and driver limits (when appliciable)."
response = {"type"="array", "items"="double"}

[messages.in_limits]
doc = "Check if a given position is within daemon limits."
request = [
  {"name"="position", "type"="double"}
]
response = "boolean"

[fields]

[fields.limits]
type = "record"
name = "field"
fields = {"getter"="get_limits", "dynamic"=true, "kind"="normal", "type"={"type"="array", "items"="double"}}
