Skip to content

Commit

Permalink
Add Input on Absolute and Relative Position
Browse files Browse the repository at this point in the history
#161 non-breaking
  • Loading branch information
tthiery committed Apr 3, 2021
1 parent 8d76a23 commit aaa1f00
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/SharpBrick.PoweredUp.TestScript/TechnicMotorTestScript.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using SharpBrick.PoweredUp.Deployment;
Expand Down Expand Up @@ -40,6 +41,8 @@ public async Task ExecuteScriptAsync(Hub hub, TestScriptExecutionContext context
await TestCase5_TachoMotorAccelerationAsync(context, motor);

await TestCase6_BasicMotorAsync(context, motor);

await TestCase7_InputAsync(context, motor);
}

private static async Task TestCase1_TachoMotorPositionByDegreesAsync(TestScriptExecutionContext context, TTechnicMotor motor)
Expand Down Expand Up @@ -148,6 +151,23 @@ private static async Task TestCase6_BasicMotorAsync(TestScriptExecutionContext c
await ResetToZeroAsync(context, motor, 3000);
}

private async Task TestCase7_InputAsync(TestScriptExecutionContext context, TTechnicMotor motor)
{
context.Log.LogInformation("AbsoluteMotor: Input on Absolute and relative Position");

context.Log.LogInformation("Turn 90° clockwise");

await motor.AbsolutePositionObservable.Where(x => x.SI > 85 && x.SI < 95).FirstAsync().GetAwaiter();

context.Log.LogInformation("Turn 180° counter-clockwise");

await motor.AbsolutePositionObservable.Where(x => x.SI < -85 && x.SI > -95).FirstAsync().GetAwaiter();

context.Log.LogInformation("Turn 90° counter-clockwise");

await motor.PositionObservable.Where(x => x.SI < -175 && x.SI > -185).FirstAsync().GetAwaiter();
}

private static async Task ResetToZeroAsync(TestScriptExecutionContext context, TTechnicMotor motor, int expectedTime)
{
await motor.GotoPositionAsync(0, 10, 100);
Expand Down

0 comments on commit aaa1f00

Please sign in to comment.