Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions docs/snippets/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,24 @@ def __init__(
index: int,
parameters: dict[str, TemperatureControllerParameter],
io: TemperatureControllerAttributeIO,
*,
path=None,
):
self._parameters = parameters
super().__init__(f"Ramp{index}", ios=[io])
super().__init__(f"Ramp{index}", ios=[io], path=path)

async def initialise(self):
for name, attribute in create_attributes(self._parameters).items():
self.add_attribute(name, attribute)


class TemperatureController(Controller):
def __init__(self, settings: IPConnectionSettings):
def __init__(self, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

self._io = TemperatureControllerAttributeIO(self._connection)
super().__init__(ios=[self._io])
super().__init__(ios=[self._io], path=path)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -129,19 +131,19 @@ async def initialise(self):
self.add_attribute(name, attribute)

for idx, ramp_parameters in enumerate(ramps_api):
name = f"Ramp{idx + 1:02d}"
ramp_controller = TemperatureRampController(
idx + 1, ramp_parameters, self._io
idx + 1, ramp_parameters, self._io, path=self.path + [name]
)
await ramp_controller.initialise()
self.add_sub_controller(f"Ramp{idx + 1:02d}", ramp_controller)
self.add_sub_controller(name, ramp_controller)

await self._connection.close()


epics_ca = EpicsCATransport()
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])


Expand Down
3 changes: 1 addition & 2 deletions docs/snippets/static04.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class TemperatureController(Controller):


epics_ca = EpicsCATransport()
controller = TemperatureController()
controller.set_path(["DEMO"])
controller = TemperatureController(path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions docs/snippets/static05.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class TemperatureController(Controller):

gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
controller = TemperatureController()
controller.set_path(["DEMO"])
controller = TemperatureController(path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
7 changes: 3 additions & 4 deletions docs/snippets/static06.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
class TemperatureController(Controller):
device_id = AttrR(String())

def __init__(self, settings: IPConnectionSettings):
super().__init__()
def __init__(self, settings: IPConnectionSettings, *, path=None):
super().__init__(path=path)

self._ip_settings = settings
self._connection = IPConnection()
Expand All @@ -25,8 +25,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])


Expand Down
7 changes: 3 additions & 4 deletions docs/snippets/static07.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ async def update(self, attr: AttrR[NumberT, IDAttributeIORef]):
class TemperatureController(Controller):
device_id = AttrR(String(), io_ref=IDAttributeIORef())

def __init__(self, settings: IPConnectionSettings):
def __init__(self, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[IDAttributeIO(self._connection)])
super().__init__(ios=[IDAttributeIO(self._connection)], path=path)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -47,8 +47,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions docs/snippets/static08.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ class TemperatureController(Controller):
device_id = AttrR(String(), io_ref=TemperatureControllerAttributeIORef("ID"))
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))

def __init__(self, settings: IPConnectionSettings):
def __init__(self, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -53,8 +55,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions docs/snippets/static09.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ class TemperatureController(Controller):
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))
ramp_rate = AttrRW(Float(), io_ref=TemperatureControllerAttributeIORef("R"))

def __init__(self, settings: IPConnectionSettings):
def __init__(self, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -60,8 +62,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
22 changes: 14 additions & 8 deletions docs/snippets/static10.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ class TemperatureRampController(Controller):
start = AttrRW(Int(), io_ref=TemperatureControllerAttributeIORef(name="S"))
end = AttrRW(Int(), io_ref=TemperatureControllerAttributeIORef(name="E"))

def __init__(self, index: int, connection: IPConnection) -> None:
def __init__(self, index: int, connection: IPConnection, *, path=None) -> None:
suffix = f"{index:02d}"
super().__init__(
f"Ramp{suffix}", ios=[TemperatureControllerAttributeIO(connection, suffix)]
f"Ramp{suffix}",
ios=[TemperatureControllerAttributeIO(connection, suffix)],
path=path,
)


Expand All @@ -59,17 +61,22 @@ class TemperatureController(Controller):
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))
ramp_rate = AttrRW(Float(), io_ref=TemperatureControllerAttributeIORef("R"))

def __init__(self, ramp_count: int, settings: IPConnectionSettings):
def __init__(self, ramp_count: int, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

self._ramp_controllers: list[TemperatureRampController] = []
for index in range(1, ramp_count + 1):
controller = TemperatureRampController(index, self._connection)
name = f"R{index}"
controller = TemperatureRampController(
index, self._connection, path=self.path + [name]
)
self._ramp_controllers.append(controller)
self.add_sub_controller(f"R{index}", controller)
self.add_sub_controller(name, controller)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -78,8 +85,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(4, connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(4, connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
22 changes: 14 additions & 8 deletions docs/snippets/static11.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ class TemperatureRampController(Controller):
end = AttrRW(Int(), io_ref=TemperatureControllerAttributeIORef(name="E"))
enabled = AttrRW(Enum(OnOffEnum), io_ref=TemperatureControllerAttributeIORef("N"))

def __init__(self, index: int, connection: IPConnection) -> None:
def __init__(self, index: int, connection: IPConnection, *, path=None) -> None:
suffix = f"{index:02d}"
super().__init__(
f"Ramp{suffix}", ios=[TemperatureControllerAttributeIO(connection, suffix)]
f"Ramp{suffix}",
ios=[TemperatureControllerAttributeIO(connection, suffix)],
path=path,
)


Expand All @@ -66,17 +68,22 @@ class TemperatureController(Controller):
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))
ramp_rate = AttrRW(Float(), io_ref=TemperatureControllerAttributeIORef("R"))

def __init__(self, ramp_count: int, settings: IPConnectionSettings):
def __init__(self, ramp_count: int, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

self._ramp_controllers: list[TemperatureRampController] = []
for index in range(1, ramp_count + 1):
controller = TemperatureRampController(index, self._connection)
name = f"R{index}"
controller = TemperatureRampController(
index, self._connection, path=self.path + [name]
)
self._ramp_controllers.append(controller)
self.add_sub_controller(f"R{index}", controller)
self.add_sub_controller(name, controller)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -85,8 +92,7 @@ async def connect(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(4, connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(4, connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
22 changes: 14 additions & 8 deletions docs/snippets/static12.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ class TemperatureRampController(Controller):
actual = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("A"))
voltage = AttrR(Float())

def __init__(self, index: int, connection: IPConnection) -> None:
def __init__(self, index: int, connection: IPConnection, *, path=None) -> None:
suffix = f"{index:02d}"
super().__init__(
f"Ramp{suffix}", ios=[TemperatureControllerAttributeIO(connection, suffix)]
f"Ramp{suffix}",
ios=[TemperatureControllerAttributeIO(connection, suffix)],
path=path,
)


Expand All @@ -71,17 +73,22 @@ class TemperatureController(Controller):
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))
ramp_rate = AttrRW(Float(), io_ref=TemperatureControllerAttributeIORef("R"))

def __init__(self, ramp_count: int, settings: IPConnectionSettings):
def __init__(self, ramp_count: int, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

self._ramp_controllers: list[TemperatureRampController] = []
for index in range(1, ramp_count + 1):
controller = TemperatureRampController(index, self._connection)
name = f"R{index}"
controller = TemperatureRampController(
index, self._connection, path=self.path + [name]
)
self._ramp_controllers.append(controller)
self.add_sub_controller(f"R{index}", controller)
self.add_sub_controller(name, controller)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -98,8 +105,7 @@ async def update_voltages(self):
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(4, connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(4, connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
22 changes: 14 additions & 8 deletions docs/snippets/static13.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ class TemperatureRampController(Controller):
actual = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("A"))
voltage = AttrR(Float())

def __init__(self, index: int, connection: IPConnection) -> None:
def __init__(self, index: int, connection: IPConnection, *, path=None) -> None:
suffix = f"{index:02d}"
super().__init__(
f"Ramp{suffix}", ios=[TemperatureControllerAttributeIO(connection, suffix)]
f"Ramp{suffix}",
ios=[TemperatureControllerAttributeIO(connection, suffix)],
path=path,
)


Expand All @@ -72,17 +74,22 @@ class TemperatureController(Controller):
power = AttrR(Float(), io_ref=TemperatureControllerAttributeIORef("P"))
ramp_rate = AttrRW(Float(), io_ref=TemperatureControllerAttributeIORef("R"))

def __init__(self, ramp_count: int, settings: IPConnectionSettings):
def __init__(self, ramp_count: int, settings: IPConnectionSettings, *, path=None):
self._ip_settings = settings
self._connection = IPConnection()

super().__init__(ios=[TemperatureControllerAttributeIO(self._connection)])
super().__init__(
ios=[TemperatureControllerAttributeIO(self._connection)], path=path
)

self._ramp_controllers: list[TemperatureRampController] = []
for index in range(1, ramp_count + 1):
controller = TemperatureRampController(index, self._connection)
name = f"R{index}"
controller = TemperatureRampController(
index, self._connection, path=self.path + [name]
)
self._ramp_controllers.append(controller)
self.add_sub_controller(f"R{index}", controller)
self.add_sub_controller(name, controller)

async def connect(self):
await self._connection.connect(self._ip_settings)
Expand All @@ -106,8 +113,7 @@ async def disable_all(self) -> None:
gui_options = EpicsGUIOptions(output_dir=Path("."), title="Demo Temperature Controller")
epics_ca = EpicsCATransport(gui=gui_options)
connection_settings = IPConnectionSettings("localhost", 25565)
controller = TemperatureController(4, connection_settings)
controller.set_path(["DEMO"])
controller = TemperatureController(4, connection_settings, path=["DEMO"])
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
Expand Down
Loading
Loading