@@ -114,7 +114,7 @@ def _add_sub_controller_pvi_info(pv_prefix: str, parent: ControllerAPI):
114114 parent_pvi = ":" .join ([pv_prefix ] + parent .path + ["PVI" ])
115115
116116 for child in parent .sub_apis .values ():
117- child_pvi = ":" .join ([pv_prefix ] + child .path + ["PVI" ])
117+ child_pvi = ":" .join ([pv_prefix ] + _controller_pv_prefix ( child .path ) + ["PVI" ])
118118 child_name = child .path [- 1 ].lower ()
119119
120120 _add_pvi_info (child_pvi , parent_pvi , child_name )
@@ -123,14 +123,14 @@ def _add_sub_controller_pvi_info(pv_prefix: str, parent: ControllerAPI):
123123
124124
125125def _create_and_link_attribute_pvs (
126- pv_prefix : str , root_controller_api : ControllerAPI
126+ root_pv_prefix : str , root_controller_api : ControllerAPI
127127) -> None :
128128 for controller_api in root_controller_api .walk_api ():
129129 path = controller_api .path
130130 for attr_name , attribute in controller_api .attributes .items ():
131131 pv_name = snake_to_pascal (attr_name )
132- _pv_prefix = ":" .join ([pv_prefix ] + path )
133- full_pv_name_length = len (f"{ _pv_prefix } :{ pv_name } " )
132+ pv_prefix = ":" .join ([root_pv_prefix ] + _controller_pv_prefix ( path ) )
133+ full_pv_name_length = len (f"{ pv_prefix } :{ pv_name } " )
134134
135135 if full_pv_name_length > EPICS_MAX_NAME_LENGTH :
136136 attribute .enabled = False
@@ -152,15 +152,15 @@ def _create_and_link_attribute_pvs(
152152 attribute .enabled = False
153153 else :
154154 _create_and_link_read_pv (
155- _pv_prefix , f"{ pv_name } _RBV" , attr_name , attribute
155+ pv_prefix , f"{ pv_name } _RBV" , attr_name , attribute
156156 )
157157 _create_and_link_write_pv (
158- _pv_prefix , pv_name , attr_name , attribute
158+ pv_prefix , pv_name , attr_name , attribute
159159 )
160160 case AttrR ():
161- _create_and_link_read_pv (_pv_prefix , pv_name , attr_name , attribute )
161+ _create_and_link_read_pv (pv_prefix , pv_name , attr_name , attribute )
162162 case AttrW ():
163- _create_and_link_write_pv (_pv_prefix , pv_name , attr_name , attribute )
163+ _create_and_link_write_pv (pv_prefix , pv_name , attr_name , attribute )
164164
165165
166166def _create_and_link_read_pv (
@@ -234,22 +234,22 @@ async def async_write_display(value: T):
234234
235235
236236def _create_and_link_command_pvs (
237- pv_prefix : str , root_controller_api : ControllerAPI
237+ root_pv_prefix : str , root_controller_api : ControllerAPI
238238) -> None :
239239 for controller_api in root_controller_api .walk_api ():
240240 path = controller_api .path
241241 for attr_name , method in controller_api .command_methods .items ():
242242 pv_name = snake_to_pascal (attr_name )
243- _pv_prefix = ":" .join ([pv_prefix ] + path )
244- if len (f"{ _pv_prefix } :{ pv_name } " ) > EPICS_MAX_NAME_LENGTH :
243+ pv_prefix = ":" .join ([root_pv_prefix ] + _controller_pv_prefix ( path ) )
244+ if len (f"{ pv_prefix } :{ pv_name } " ) > EPICS_MAX_NAME_LENGTH :
245245 print (
246246 f"Not creating PV for { attr_name } as full name would exceed"
247247 f" { EPICS_MAX_NAME_LENGTH } characters"
248248 )
249249 method .enabled = False
250250 else :
251251 _create_and_link_command_pv (
252- _pv_prefix ,
252+ pv_prefix ,
253253 pv_name ,
254254 attr_name ,
255255 method ,
@@ -302,3 +302,7 @@ def _add_attr_pvi_info(
302302 }
303303 },
304304 )
305+
306+
307+ def _controller_pv_prefix (controller_path : list [str ]) -> list [str ]:
308+ return [snake_to_pascal (node ) for node in controller_path ]
0 commit comments