public bool CanMoveArm(RobotVO robot, ArmVO armMoved, ArmSide armSide) { ArmVO arm = armSide == ArmSide.Left ? robot.LeftArm : robot.RightArm; bool isElbowMovement = IsElbowMovement(arm, armMoved.Elbow); bool isWristMovement = IsWristMovement(arm, armMoved.Wrist); // Não se pode mexer mais de uma parte do braço por vez if (isElbowMovement && isWristMovement) { return(false); } if (isElbowMovement) { return(ChangeElbowMovement(arm, armMoved.Elbow)); } if (isWristMovement) { return(ChangeWristMovement(arm, armMoved.Wrist)); } //Não houve mudança return(true); }
public bool PutRightArm(long id, ArmVO rightArmMoved) { bool isRightArmMoved = false; using (var client = new HttpClient()) { client.BaseAddress = new Uri(_kraftwerkAPIUrl); var putTask = client.PutAsJsonAsync <ArmVO>($"api/Robot/{id}/LeftArm", rightArmMoved); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { isRightArmMoved = true; } else if (result.StatusCode == HttpStatusCode.BadRequest) { isRightArmMoved = false; } } return(isRightArmMoved); }
public bool ChangeWristMovement(ArmVO arm, WristMovement wristMovement) { if (arm.Elbow != ElbowMovement.StronglyContracted) { return(false); } return(true); }
public void NaoDevePermitirMovimentoDoPulso() { //Assert ArmVO arm = new ArmVO() { Elbow = ElbowMovement.InRest, Wrist = WristMovement.InRest }; WristMovement wristMovement = WristMovement.Rotate135Degrees; //Act var result = _armMovement.ChangeWristMovement(arm, wristMovement); //Assert Assert.False(result); }
public void DevePermitirMovimentoDoPulso() { //Arrange ArmVO arm = new ArmVO() { Elbow = ElbowMovement.StronglyContracted, Wrist = WristMovement.InRest }; WristMovement wristMovement = WristMovement.Rotate135Degrees; //Act var result = _armMovement.ChangeWristMovement(arm, wristMovement); //Assert Assert.True(result); }
private JsonResult ChangeWristPosition(long id, ArmVO arm, int newPositionWristNumeric, ArmSide armSide) { WristMovement newWristMovement; string movementDescription = string.Empty; bool isValidMovement = newPositionWristNumeric.TryParseEnum(out newWristMovement); if (isValidMovement) { arm.Wrist = newWristMovement; movementDescription = arm.Wrist.GetDescription(); bool isArmMoved = armSide == ArmSide.Left ? _robotService.PutLeftArm(id, arm) : _robotService.PutRightArm(id, arm); if (isArmMoved == false) { isValidMovement = false; } } return(Json(new { isValidMovement, description = movementDescription })); }
public ArmVO GetRightArm(long id) { ArmVO rightArm = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri(_kraftwerkAPIUrl); Task <HttpResponseMessage> responseTask = client.GetAsync($"api/robot/{id}/RightArm"); responseTask.Wait(); HttpResponseMessage result = responseTask.Result; if (result.IsSuccessStatusCode) { Task <ArmVO> readTask = result.Content.ReadAsAsync <ArmVO>(); readTask.Wait(); rightArm = readTask.Result; } } return(rightArm); }
public bool ChangeElbowMovement(ArmVO arm, ElbowMovement elbowMovement) => true;
private bool IsWristMovement(ArmVO arm, WristMovement wristMovement) => arm.Wrist != wristMovement;
private bool IsElbowMovement(ArmVO arm, ElbowMovement elbowMovement) => arm.Elbow != elbowMovement;