From aaa1f0015b6c093af491596d8ed9b2431f4a6234 Mon Sep 17 00:00:00 2001 From: "T. Thiery" Date: Sat, 3 Apr 2021 23:06:06 +0200 Subject: [PATCH] Add Input on Absolute and Relative Position #161 non-breaking --- .../TechnicMotorTestScript.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/SharpBrick.PoweredUp.TestScript/TechnicMotorTestScript.cs b/test/SharpBrick.PoweredUp.TestScript/TechnicMotorTestScript.cs index 5741c55..0c6001a 100644 --- a/test/SharpBrick.PoweredUp.TestScript/TechnicMotorTestScript.cs +++ b/test/SharpBrick.PoweredUp.TestScript/TechnicMotorTestScript.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using SharpBrick.PoweredUp.Deployment; @@ -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) @@ -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);