Skip to content

Add configurable movement simulation to i06-1 MockSuperConductingMagnetController #2188

Closed

Description

@oliwenmandiamond

MockSuperConductingMagnetController currently completes movements immediately. This is useful for most unit tests, but it means tests involving fly scans cannot exercise behaviour where the magnet position changes over time.

For example, when running a fly scan, the scaler may acquire multiple points while the magnet is moving. With the current instantaneous mock, the magnet jumps directly to its final position, so this behaviour cannot be tested.

The mock should support configurable simulated movement while retaining the current instantaneous behaviour by default.

The mock should be configurable with a number of movement steps and a total ramp time:

await scmc.connect(mock=MockSuperConductingMagnetController(steps=10, ramp_time=1))

This would cause a movement such as:

0.0 -> 1.0

to be simulated as approximately:

0.0
0.1
0.2
...
0.9
1.0

over one second.

The default should retain the existing behaviour:

await scmc.connect(mock=MockSuperConductingMagnetController())

where movements complete immediately.

Motivation

This allows integration/fly-scan tests to exercise realistic asynchronous behaviour, including:

Multiple detector/scaler readings while the magnet is moving.
Position updates occurring over time.
Fly scans where the motor and detector operate concurrently.
Correct completion of a movement only after the simulated motion has reached the target.
Behaviour when the movement distance is different from the configured/default example.

For example, with:

MockSuperConductingMagnetController(steps=10, ramp_time=1)

a fly scan can observe several readings at each intermediate position before the next position update.

Acceptance criteria

  • Existing tests using MockSuperConductingMagnetController continue to behave as before.
  • The mock can optionally simulate movement over a configurable number of steps.
  • The mock can optionally configure the total movement/ramp time.
  • Intermediate positions are calculated between the current position and target position rather than using a fixed step size.
  • The movement status does not complete until the target position has been reached.
  • Position updates trigger the normal signal callbacks/events used by the real controller.
  • Tests cover both instantaneous and simulated movement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions