IMotionDevice
Interface for motion control device drivers. Provides methods for controlling servo motors and actuators.
Namespace: DeviceBase
Inheritance
This interface extends IDevice.
Methods
Enable
Enables or disables a motion channel.
void Enable(int channel, bool value);
Parameters:
channel— The channel number.value—trueto enable,falseto disable.
IsEnabled
Checks if a motion channel is enabled.
bool IsEnabled(int channel);
Parameters:
channel— The channel number.
Returns: true if enabled, false if disabled.
TrapezoidalMove
Executes a trapezoidal motion profile move.
void TrapezoidalMove(
int channel,
int position,
int velocity,
int acceleration,
int deceleration
);
Parameters:
channel— The channel number.position— Target position in device units.velocity— Maximum velocity in device units per second.acceleration— Acceleration in device units per second squared.deceleration— Deceleration in device units per second squared.
Wait (Overload 1)
Waits for motion to complete on a channel (no timeout).
void Wait(int channel);
Parameters:
channel— The channel number.
Wait (Overload 2)
Waits for motion to complete on a channel with a timeout.
void Wait(int channel, int timeout);
Parameters:
channel— The channel number.timeout— Maximum wait time in milliseconds.
IsMoving
Checks if a channel is currently moving.
bool IsMoving(int channel);
Parameters:
channel— The channel number.
Returns: true if the channel is moving, false if stopped.
SetCommandPosition
Sets the command position for a channel.
void SetCommandPosition(double position);
Parameters:
position— The command position value.
SetActualPosition
Sets the actual position for a channel (typically used for homing or calibration).
void SetActualPosition(double position);
Parameters:
position— The actual position value.
Usage Example
IMotionDevice motionDevice = ...;
// Initialize device
motionDevice.Init(config);
// Enable the motor
motionDevice.Enable(0, true);
// Check if enabled
if (motionDevice.IsEnabled(0))
{
// Execute a move with trapezoidal profile
motionDevice.TrapezoidalMove(
channel: 0,
position: 10000,
velocity: 5000,
acceleration: 10000,
deceleration: 10000
);
// Wait for motion to complete (with 5 second timeout)
motionDevice.Wait(0, 5000);
// Check if still moving
bool moving = motionDevice.IsMoving(0);
}
// Disable when done
motionDevice.Enable(0, false);
// Dispose
motionDevice.Dispose();
Remarks
- Channels must be enabled before executing motion commands.
- The trapezoidal motion profile provides smooth acceleration and deceleration.
- Position, velocity, acceleration, and deceleration values are in device-specific units.
- Use
Waitwith timeout to prevent indefinite blocking on motion errors.