44
55from fastcs .attributes import Attribute , AttrR , AttrRW , AttrW
66from fastcs .controller_api import ControllerAPI
7+ from fastcs .transport .epics .util import controller_pv_prefix
78from fastcs .util import snake_to_pascal
89
910from ._pv_handlers import (
@@ -26,12 +27,6 @@ def _attribute_to_access(attribute: Attribute) -> AccessModeType:
2627 raise ValueError (f"Unknown attribute type { type (attribute )} " )
2728
2829
29- def get_pv_name (pv_prefix : str , * attribute_names : str ) -> str :
30- """Converts from an attribute name to a pv name."""
31- pv_formatted = ":" .join ([snake_to_pascal (attr ) for attr in attribute_names ])
32- return f"{ pv_prefix } :{ pv_formatted } " if pv_formatted else pv_prefix
33-
34-
3530async def parse_attributes (
3631 root_pv_prefix : str , root_controller_api : ControllerAPI
3732) -> list [StaticProvider ]:
@@ -40,33 +35,33 @@ async def parse_attributes(
4035 provider = StaticProvider (root_pv_prefix )
4136
4237 for controller_api in root_controller_api .walk_api ():
43- pv_prefix = get_pv_name (root_pv_prefix , * controller_api . path )
38+ pv_prefix = controller_pv_prefix (root_pv_prefix , controller_api )
4439
4540 pvi_tree .add_sub_device (pv_prefix , controller_api .description )
4641
4742 for attr_name , attribute in controller_api .attributes .items ():
48- pv_name = get_pv_name ( pv_prefix , attr_name )
43+ full_pv_name = f" { pv_prefix } : { snake_to_pascal ( attr_name )} "
4944 match attribute :
5045 case AttrRW ():
5146 attribute_pv = make_shared_write_pv (attribute )
5247 attribute_pv_rbv = make_shared_read_pv (attribute )
53- provider .add (pv_name , attribute_pv )
54- provider .add (f"{ pv_name } _RBV" , attribute_pv_rbv )
55- pvi_tree .add_signal (pv_name , "rw" )
48+ provider .add (f" { full_pv_name } " , attribute_pv )
49+ provider .add (f"{ full_pv_name } _RBV" , attribute_pv_rbv )
50+ pvi_tree .add_signal (f" { full_pv_name } " , "rw" )
5651 case AttrR ():
5752 attribute_pv = make_shared_read_pv (attribute )
58- provider .add (pv_name , attribute_pv )
59- pvi_tree .add_signal (pv_name , "r" )
53+ provider .add (f" { full_pv_name } " , attribute_pv )
54+ pvi_tree .add_signal (f" { full_pv_name } " , "r" )
6055 case AttrW ():
6156 attribute_pv = make_shared_write_pv (attribute )
62- provider .add (pv_name , attribute_pv )
63- pvi_tree .add_signal (pv_name , "w" )
57+ provider .add (f" { full_pv_name } " , attribute_pv )
58+ pvi_tree .add_signal (f" { full_pv_name } " , "w" )
6459
6560 for attr_name , method in controller_api .command_methods .items ():
66- pv_name = get_pv_name ( pv_prefix , attr_name )
61+ full_pv_name = f" { pv_prefix } : { snake_to_pascal ( attr_name )} "
6762 command_pv = make_command_pv (method .fn )
68- provider .add (pv_name , command_pv )
69- pvi_tree .add_signal (pv_name , "x" )
63+ provider .add (f" { full_pv_name } " , command_pv )
64+ pvi_tree .add_signal (f" { full_pv_name } " , "x" )
7065
7166 return [provider , pvi_tree .make_provider ()]
7267
0 commit comments