Skip to content

Commit

Permalink
make rtc triggerable; add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
co2e14 committed Dec 10, 2024
1 parent 887e192 commit 11d1e9d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ requires-python = ">=3.11"

[project.optional-dependencies]
dev = [
"ipython",
"bluesky",
"ophyd-async",
"copier",
Expand Down
12 changes: 8 additions & 4 deletions src/rtc6_fastcs/controller/rtc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ def __init__(

def correct_xy(self, x: int, y: int) -> tuple[int, int]:
"""Correct for transformations in the laser / oav optics"""
LOGGER.info(f"Correcting {(x,y)} by {self.coordinate_correction_matrix}")
print(f"Correcting {(x,y)} by {self.coordinate_correction_matrix}")
corrected = np.matmul(self.coordinate_correction_matrix, [x, y])
return (int(corrected[0]), int(corrected[1]))
as_ints = (int(corrected[0]), int(corrected[1]))
print(f"Result: {corrected} => {as_ints}")
return as_ints


class RtcListOperations(XYCorrectedConnectedSubController):
Expand Down Expand Up @@ -178,8 +180,10 @@ class AddLine(XYCorrectedConnectedSubController):
@command()
async def proc(self):
bindings = self._conn.get_bindings()
x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_line_to(x, y)
print(f"Current addline x: {self.x.get()}")
print(f"Current addline y: {self.y.get()}")
# x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_line_to(self.x.get(), self.y.get())

@command()
async def init_list(self):
Expand Down
7 changes: 4 additions & 3 deletions src/rtc6_fastcs/device.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ophyd_async.core import StandardReadable, AsyncStageable
from bluesky.protocols import Flyable
from bluesky.protocols import Triggerable
from ophyd_async.epics.core import (
epics_signal_rw,
epics_signal_r,
Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, prefix: str = "LIST:", name: str = "") -> None:
self.execute_list = epics_signal_x(prefix + "ExecuteList")


class Rtc6Eth(StandardReadable, AsyncStageable, Flyable):
class Rtc6Eth(StandardReadable, AsyncStageable, Triggerable):
def __init__(self, prefix: str = "RTC6ETH:", name: str = "") -> None:
super().__init__(name)
with self.add_children_as_readables():
Expand All @@ -90,7 +90,7 @@ async def stage(self):
await self.list.init_list.trigger()

@AsyncStatus.wrap
async def kickoff(self):
async def trigger(self):
"""Set the end of the list at the current position and set it to execute"""
await self.list.end_list.trigger()
await self.list.execute_list.trigger()
Expand All @@ -99,6 +99,7 @@ async def kickoff(self):
async def complete(self):
"""Wait for the current list execution to complete"""
# Todo add a signal for this with get_status
# and change trigger to kickoff

@AsyncStatus.wrap
async def unstage(self): ...
11 changes: 5 additions & 6 deletions src/rtc6_fastcs/plan_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def rectangle(rtc6: Rtc6Eth, x: int, y: int, origin: tuple[int, int] = (0, 0)):
def draw_square(rtc6: Rtc6Eth, size: int):
yield from bps.stage(rtc6)
yield from rectangle(rtc6, size, size)
yield from bps.kickoff(rtc6)
yield from bps.collect(rtc6)
yield from bps.trigger(rtc6)


LineInput = tuple[int, int]
Expand All @@ -52,8 +51,8 @@ def draw_polygon(rtc6: Rtc6Eth, points: list[LineInput]):
yield from jump(rtc6, *points[0])
for point in points[1:]:
yield from line(rtc6, *point)
yield from bps.kickoff(rtc6)
yield from bps.collect(rtc6)
yield from bps.trigger(rtc6)



@bpp.run_decorator
Expand All @@ -67,5 +66,5 @@ def draw_polygon_with_arcs(rtc6: Rtc6Eth, points: list[LineInput | ArcInput]):
yield from line(rtc6, *point)
else:
yield from arc(rtc6, *point)
yield from bps.kickoff(rtc6)
yield from bps.collect(rtc6)
yield from bps.trigger(rtc6)

0 comments on commit 11d1e9d

Please sign in to comment.