Skip to content

Commit

Permalink
add support for function attributes (embedded)
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed Sep 7, 2023
1 parent 64e0a2f commit 956c8da
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion avlos/definitions/remote_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from avlos.mixins.named_node import NamedNode
from avlos.mixins.meta_node import MetaNode
from avlos.mixins.impex_node import ImpexNode
from avlos.mixins.func_attr_node import FuncAttrNode


class RemoteAttribute(CommNode, NamedNode, MetaNode, ImpexNode):
class RemoteAttribute(CommNode, NamedNode, MetaNode, ImpexNode, FuncAttrNode):
"""
Remote Endpoint with a value, parent and a comms channel
"""
Expand All @@ -15,6 +16,7 @@ def __init__(
name,
summary,
dtype,
func_attr=None,
getter_name=None,
setter_name=None,
unit=None,
Expand All @@ -25,6 +27,7 @@ def __init__(
CommNode.__init__(self)
NamedNode.__init__(self, name)
MetaNode.__init__(self, meta_dict=meta)
FuncAttrNode.__init__(self, func_attr)
self.summary = summary
self.dtype = dtype
self.unit = unit
Expand Down
3 changes: 3 additions & 0 deletions avlos/definitions/remote_bitmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from avlos.mixins.meta_node import MetaNode
from avlos.mixins.impex_node import ImpexNode
from avlos.datatypes import DataType
from avlos.mixins.func_attr_node import FuncAttrNode


class RemoteBitmask(CommNode, NamedNode, MetaNode, ImpexNode):
Expand All @@ -16,6 +17,7 @@ def __init__(
self,
name,
summary,
func_attr=None,
getter_name=None,
setter_name=None,
flags=None,
Expand All @@ -27,6 +29,7 @@ def __init__(
CommNode.__init__(self)
NamedNode.__init__(self, name)
MetaNode.__init__(self, meta_dict=meta)
FuncAttrNode.__init__(self, func_attr)
self.summary = summary
self.bitmask = flags # flags is needed to deserialize
self.getter_name = getter_name
Expand Down
3 changes: 3 additions & 0 deletions avlos/definitions/remote_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from avlos.mixins.meta_node import MetaNode
from avlos.mixins.impex_node import ImpexNode
from avlos.datatypes import DataType
from avlos.mixins.func_attr_node import FuncAttrNode


class RemoteEnum(CommNode, NamedNode, MetaNode, ImpexNode):
Expand All @@ -16,6 +17,7 @@ def __init__(
self,
name,
summary,
func_attr=None,
getter_name=None,
setter_name=None,
options=None,
Expand All @@ -27,6 +29,7 @@ def __init__(
CommNode.__init__(self)
NamedNode.__init__(self, name)
MetaNode.__init__(self, meta_dict=meta)
FuncAttrNode.__init__(self, func_attr)
self.summary = summary
self.options = options # options is needed to deserialize
self.getter_name = getter_name
Expand Down
3 changes: 3 additions & 0 deletions avlos/definitions/remote_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from avlos.mixins.comm_node import CommNode
from avlos.mixins.named_node import NamedNode
from avlos.mixins.meta_node import MetaNode
from avlos.mixins.func_attr_node import FuncAttrNode


class RemoteFunction(CommNode, NamedNode, MetaNode):
Expand All @@ -22,6 +23,7 @@ def __init__(
summary,
caller_name,
arguments,
func_attr=None,
dtype=None,
unit=None,
rst_target=None,
Expand All @@ -31,6 +33,7 @@ def __init__(
CommNode.__init__(self)
NamedNode.__init__(self, name)
MetaNode.__init__(self, meta_dict=meta)
FuncAttrNode.__init__(self, func_attr)
self.summary = summary
self.dtype = dtype
self.unit = unit
Expand Down
1 change: 1 addition & 0 deletions avlos/definitions/remote_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class RemoteNodeSchema(Schema):
flags = BitmaskField()
options = EnumField()
unit = UnitField()
func_attr = fields.String(default=None)
getter_name = fields.String()
setter_name = fields.String()
caller_name = fields.String()
Expand Down
4 changes: 4 additions & 0 deletions avlos/mixins/func_attr_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class FuncAttrNode:
def __init__(self, func_attr):
self.func_attr = func_attr
2 changes: 1 addition & 1 deletion avlos/templates/fw_endpoints.c.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ uint32_t _avlos_get_proto_hash(void)

{%- for attr in instance | endpoints %}

uint8_t avlos_{{attr.full_name | replace(".", "_") }}(uint8_t * buffer, uint8_t * buffer_len, Avlos_Command cmd)
{% if attr.func_attr -%}{{attr.func_attr}} {% endif %}uint8_t avlos_{{attr.full_name | replace(".", "_") }}(uint8_t * buffer, uint8_t * buffer_len, Avlos_Command cmd)
{
{%- if attr.getter_name %}

Expand Down
3 changes: 3 additions & 0 deletions tests/definition/good_device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ remote_attributes:
summary: Move to
caller_name: move_to
dtype: void
func_attr: TM_RAMFUNC
arguments:
- name: position
dtype: float
Expand Down Expand Up @@ -81,11 +82,13 @@ remote_attributes:
meta: {dynamic: True}
getter_name: encoder_get_pos_estimate
summary: Retrieve the encoder position estimate.
func_attr: TM_RAMFUNC
- name: bandwidth
dtype: float
unit: rad/s
meta: {export: True}
getter_name: encoder_get_bandwidth
setter_name: encoder_set_bandwidth
summary: Access the encoder observer bandwidth.
func_attr: TM_RAMFUNC

0 comments on commit 956c8da

Please sign in to comment.