Skip to content

Commit

Permalink
update to new soft signal API
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Apr 19, 2024
1 parent 86647ca commit 7988efd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/ophyd_async/sim/demo/sim_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class SimMotor(StandardReadable, Movable, Stoppable):
def __init__(self, prefix: str, name="", instant=True) -> None:
def __init__(self, name="", instant=True) -> None:
"""
Simulated motor device
Expand All @@ -23,12 +23,10 @@ def __init__(self, prefix: str, name="", instant=True) -> None:
self._move_task: Optional[asyncio.Task] = None

# Define some signals
self.user_setpoint = soft_signal_rw(float, prefix + "user_setpoint", 0)
self.user_readback, self._user_readback = soft_signal_r_and_backend(
float, prefix + "user_readback", 0
)
self.velocity = soft_signal_rw(float, prefix + "velocity", 1.0)
self.egu = soft_signal_rw(float, prefix + "egu", "mm")
self.user_setpoint = soft_signal_rw(float, 0)
self.user_readback, self._user_readback = soft_signal_r_and_backend(float, 0)
self.velocity = soft_signal_rw(float, 1.0)
self.egu = soft_signal_rw(float, "mm")

# Set name and signals for read() and read_configuration()
self.set_readable_signals(
Expand Down
Empty file added tests/sim/demo/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions tests/sim/demo/test_sim_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def test_move_sim_in_plan():

async def test_slow_move():
async with DeviceCollector():
m1 = SimMotor("M1", "sim_motor1", instant=False)
m1 = SimMotor("M1", instant=False)

await m1.velocity.set(20)

Expand All @@ -40,7 +40,7 @@ async def test_slow_move():

async def test_stop():
async with DeviceCollector():
m1 = SimMotor("M1", "sim_motor1", instant=False)
m1 = SimMotor("M1", instant=False)

# this move should take 10 seconds but we will stop it after 0.2
move_status = m1.set(10)
Expand Down

0 comments on commit 7988efd

Please sign in to comment.