Skip to content

Commit

Permalink
update preventEndPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
Scretch9 committed Dec 15, 2023
1 parent 3c1fe0a commit b31fe7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Point/Point.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EulynxLive.FieldElementSubsystems.Configuration;
using EulynxLive.FieldElementSubsystems.Configuration;
using EulynxLive.FieldElementSubsystems.Interfaces;
using EulynxLive.Point.Proto;
using Grpc.Core;
Expand Down Expand Up @@ -125,7 +125,12 @@ public void SetAbilityToMove(AbilityToMoveMessage abilityToMoveMessage){
/// <returns></returns>
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)
Expand All @@ -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);
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/Point/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b31fe7a

Please sign in to comment.