2020 record_metadata_from_datatype ,
2121)
2222from fastcs .transport .epics .options import EpicsIOCOptions
23+ from fastcs .transport .epics .util import controller_pv_prefix
2324from fastcs .util import snake_to_pascal
2425
2526EPICS_MAX_NAME_LENGTH = 60
@@ -111,27 +112,26 @@ def _add_sub_controller_pvi_info(pv_prefix: str, parent: ControllerAPI):
111112 parent: Controller to add PVI refs for
112113
113114 """
114- parent_pvi = ":" . join ([ pv_prefix ] + parent . path + [ " PVI"])
115+ parent_pvi = f" { controller_pv_prefix ( pv_prefix , parent ) } : PVI"
115116
116117 for child in parent .sub_apis .values ():
117- child_pvi = ":" . join ([ pv_prefix ] + child . path + [ " PVI"])
118+ child_pvi = f" { controller_pv_prefix ( pv_prefix , child ) } : PVI"
118119 child_name = child .path [- 1 ].lower ()
119120
120121 _add_pvi_info (child_pvi , parent_pvi , child_name )
121-
122122 _add_sub_controller_pvi_info (pv_prefix , child )
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 ():
129- path = controller_api .path
129+ pv_prefix = controller_pv_prefix (root_pv_prefix , controller_api )
130+
130131 for attr_name , attribute in controller_api .attributes .items ():
131132 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 } " )
134133
134+ full_pv_name_length = len (f"{ pv_prefix } :{ pv_name } " )
135135 if full_pv_name_length > EPICS_MAX_NAME_LENGTH :
136136 attribute .enabled = False
137137 print (
@@ -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 (
@@ -224,32 +224,31 @@ async def async_write_display(value: T):
224224
225225 record .set (cast_to_epics_type (attribute .datatype , value ), process = False )
226226
227- record = _make_record (
228- f"{ pv_prefix } :{ pv_name } " , attribute , on_update = on_update , out_record = True
229- )
227+ record = _make_record (pv , attribute , on_update = on_update , out_record = True )
230228
231229 _add_attr_pvi_info (record , pv_prefix , attr_name , "w" )
232230
233231 attribute .add_write_display_callback (async_write_display )
234232
235233
236234def _create_and_link_command_pvs (
237- pv_prefix : str , root_controller_api : ControllerAPI
235+ root_pv_prefix : str , root_controller_api : ControllerAPI
238236) -> None :
239237 for controller_api in root_controller_api .walk_api ():
240- path = controller_api .path
238+ pv_prefix = controller_pv_prefix (root_pv_prefix , controller_api )
239+
241240 for attr_name , method in controller_api .command_methods .items ():
242241 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 :
242+
243+ if len (f"{ pv_prefix } :{ pv_name } " ) > EPICS_MAX_NAME_LENGTH :
245244 print (
246245 f"Not creating PV for { attr_name } as full name would exceed"
247246 f" { EPICS_MAX_NAME_LENGTH } characters"
248247 )
249248 method .enabled = False
250249 else :
251250 _create_and_link_command_pv (
252- _pv_prefix ,
251+ pv_prefix ,
253252 pv_name ,
254253 attr_name ,
255254 method ,
0 commit comments