|
8 | 8 | from softioc.pythonSoftIoc import RecordWrapper |
9 | 9 |
|
10 | 10 | from fastcs.attributes import AttrR, AttrRW, AttrW |
11 | | -from fastcs.controller import BaseController |
| 11 | +from fastcs.controller import BaseController, Controller |
12 | 12 | from fastcs.datatypes import Bool, DataType, Float, Int, String, T |
13 | 13 | from fastcs.exceptions import FastCSException |
14 | | -from fastcs.mapping import Mapping |
15 | 14 | from fastcs.transport.epics.util import ( |
16 | 15 | MBB_STATE_FIELDS, |
17 | 16 | attr_is_enum, |
@@ -46,24 +45,31 @@ def datatype_to_epics_fields(datatype: DataType) -> dict[str, Any]: |
46 | 45 |
|
47 | 46 | class EpicsIOC: |
48 | 47 | def __init__( |
49 | | - self, pv_prefix: str, mapping: Mapping, options: EpicsIOCOptions | None = None |
| 48 | + self, |
| 49 | + pv_prefix: str, |
| 50 | + controller: Controller, |
| 51 | + options: EpicsIOCOptions | None = None, |
50 | 52 | ): |
51 | 53 | self.options = options or EpicsIOCOptions() |
| 54 | + self._controller = controller |
52 | 55 | _add_pvi_info(f"{pv_prefix}:PVI") |
53 | | - _add_sub_controller_pvi_info(pv_prefix, mapping.controller) |
| 56 | + _add_sub_controller_pvi_info(pv_prefix, controller) |
54 | 57 |
|
55 | | - _create_and_link_attribute_pvs(pv_prefix, mapping) |
56 | | - _create_and_link_command_pvs(pv_prefix, mapping) |
| 58 | + _create_and_link_attribute_pvs(pv_prefix, controller) |
| 59 | + _create_and_link_command_pvs(pv_prefix, controller) |
57 | 60 |
|
58 | 61 | def run( |
59 | 62 | self, |
60 | 63 | dispatcher: AsyncioDispatcher, |
61 | | - context: dict[str, Any], |
62 | 64 | ) -> None: |
63 | 65 | builder.LoadDatabase() |
64 | 66 | softioc.iocInit(dispatcher) |
65 | 67 |
|
66 | 68 | if self.options.terminal: |
| 69 | + context = { |
| 70 | + "dispatcher": dispatcher, |
| 71 | + "controller": self._controller, |
| 72 | + } |
67 | 73 | softioc.interactive_ioc(context) |
68 | 74 |
|
69 | 75 |
|
@@ -131,8 +137,8 @@ def _add_sub_controller_pvi_info(pv_prefix: str, parent: BaseController): |
131 | 137 | _add_sub_controller_pvi_info(pv_prefix, child) |
132 | 138 |
|
133 | 139 |
|
134 | | -def _create_and_link_attribute_pvs(pv_prefix: str, mapping: Mapping) -> None: |
135 | | - for single_mapping in mapping.get_controller_mappings(): |
| 140 | +def _create_and_link_attribute_pvs(pv_prefix: str, controller: Controller) -> None: |
| 141 | + for single_mapping in controller.get_controller_mappings(): |
136 | 142 | path = single_mapping.controller.path |
137 | 143 | for attr_name, attribute in single_mapping.attributes.items(): |
138 | 144 | pv_name = attr_name.title().replace("_", "") |
@@ -322,8 +328,8 @@ def datatype_updater(datatype: DataType): |
322 | 328 | return record |
323 | 329 |
|
324 | 330 |
|
325 | | -def _create_and_link_command_pvs(pv_prefix: str, mapping: Mapping) -> None: |
326 | | - for single_mapping in mapping.get_controller_mappings(): |
| 331 | +def _create_and_link_command_pvs(pv_prefix: str, controller: Controller) -> None: |
| 332 | + for single_mapping in controller.get_controller_mappings(): |
327 | 333 | path = single_mapping.controller.path |
328 | 334 | for attr_name, method in single_mapping.command_methods.items(): |
329 | 335 | pv_name = attr_name.title().replace("_", "") |
|
0 commit comments