From b31fe7adf60cf18c3154be0857ef33eb61f55ee9 Mon Sep 17 00:00:00 2001 From: Benedikt Schenkel Date: Fri, 15 Dec 2023 10:28:28 +0100 Subject: [PATCH] update preventEndPosition --- src/Point/Point.cs | 10 ++++++++-- src/Point/README.md | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Point/Point.cs b/src/Point/Point.cs index d7f33b7..f52bd8a 100644 --- a/src/Point/Point.cs +++ b/src/Point/Point.cs @@ -1,4 +1,4 @@ -using EulynxLive.FieldElementSubsystems.Configuration; +using EulynxLive.FieldElementSubsystems.Configuration; using EulynxLive.FieldElementSubsystems.Interfaces; using EulynxLive.Point.Proto; using Grpc.Core; @@ -125,7 +125,12 @@ public void SetAbilityToMove(AbilityToMoveMessage abilityToMoveMessage){ /// public async Task PreventEndPosition(SimulatedPositionMessage simulatedPositionMessage) { - _logger.LogInformation("Preventing end position {} with degraded point position {}.", simulatedPositionMessage.Position, simulatedPositionMessage.DegradedPosition); + if ((simulatedPositionMessage.Position == PreventedPosition.PreventedLeft && simulatedPositionMessage.DegradedPosition == PointDegradedPosition.DegradedRight) || + (simulatedPositionMessage.Position == PreventedPosition.PreventedRight && simulatedPositionMessage.DegradedPosition == PointDegradedPosition.DegradedLeft)) + { + _logger.LogWarning("Prevented position {} and degraded position {} are not compatible.", simulatedPositionMessage.Position, simulatedPositionMessage.DegradedPosition); + return; + } // Action a Trailed command immediately, otherwise store the prevented position for the next command. if (simulatedPositionMessage.Position == PreventedPosition.PreventTrailed) @@ -136,6 +141,7 @@ public async Task PreventEndPosition(SimulatedPositionMessage simulatedPositionM { _simulatedPointState.PreventedPosition = simulatedPositionMessage.Position; _simulatedPointState.DegradedPointPosition = simulatedPositionMessage.DegradedPosition.ConvertToDegradedPointPosition(); + _logger.LogInformation("Preventing end position {} with degraded point position {}.", _simulatedPointState.PreventedPosition, _simulatedPointState.DegradedPointPosition); } } diff --git a/src/Point/README.md b/src/Point/README.md index bd20a0e..7dc82d6 100644 --- a/src/Point/README.md +++ b/src/Point/README.md @@ -7,3 +7,17 @@ EULYNX Point Simulator - https://nodejs.org/en/ Then, execute `dotnet run` in this directory and open http://localhost:5000 in the browser. + + +## gRPC API + +`PreventEndPosition(SimulatedPositionMessage)` can be used to put the point in a degraded or no end position at all. +The following are the allowed parameter values and resulting point states: + +|SimulatedPositionMessage.position|SimulatedPositionMessage.degradedPosition|pointPosition|degradedPointPosition| +|--|--|--|--| +|UnintendedPosition| * | NoEndPosition | NotDegraded +|PreventedLeft|DegradedLeft| NoEndPosition | DegradedLeft +|PreventedRight|DegradedRight| NoEndPosition | DegradedRight +|PreventedLeft|NotDegraded| NoEndPosition | NotDegraded +|PreventedRight|NotDegraded| NoEndPosition | NotDegraded