private static async Task ResetToZeroAsync(TestScriptExecutionContext context, TTechnicMotor motor, int expectedTime) { await motor.GotoPositionAsync(0, 10, 100); await Task.Delay(expectedTime); context.Assert(motor.AbsolutePosition, -3, 3); context.Assert(motor.Position, -3, 3); await context.ConfirmAsync("TachoMotor.GotoPositionAsync: has moved to zero position?"); }
private static async Task TestCase1_TachoMotorPositionByDegreesAsync(TestScriptExecutionContext context, TTechnicMotor motor) { context.Log.LogInformation("TachoMotor: Testing positioning by degress"); await motor.StartSpeedForDegreesAsync(45, 10, 100); await Task.Delay(2000); context.Assert(motor.AbsolutePosition, 42, 48); context.Assert(motor.Position, 42, 48); await motor.StartSpeedForDegreesAsync(45, 10, 100); await Task.Delay(2000); context.Assert(motor.AbsolutePosition, 87, 93); context.Assert(motor.Position, 87, 93); await motor.StartSpeedForDegreesAsync(45, 10, 100); await Task.Delay(2000); context.Assert(motor.AbsolutePosition, 132, 138); context.Assert(motor.Position, 132, 138); await motor.StartSpeedForDegreesAsync(45, 10, 100); await Task.Delay(2000); context.Assert(Math.Abs(motor.AbsolutePosition), 177, 180); context.Assert(motor.Position, 177, 183); await context.ConfirmAsync("TachoMotor.StartSpeedForDegreesAsync: Has moved 40 times CW each by 45°?"); }
private static async Task TestCase2_TachoMotorExplicitPositionAsync(TestScriptExecutionContext context, TTechnicMotor motor) { context.Log.LogInformation("TachoMotor: Testing explicit position from TachoMotor.SetZero"); await motor.GotoPositionAsync(360, 10, 100); await Task.Delay(2000); context.Assert(motor.AbsolutePosition, -3, 3); context.Assert(motor.Position, 357, 363); await context.ConfirmAsync("TachoMotor.GotoPositionAsync: has moved CW to zero position?"); await motor.GotoPositionAsync(810, 10, 100); await Task.Delay(4000); context.Assert(motor.AbsolutePosition, 87, 93); context.Assert(motor.Position, 807, 813); await context.ConfirmAsync("TachoMotor.GotoPositionAsync: Motor has moved CW by 360° + 90° and is exaclty 90° off zero?"); }