void TaskThreadProcess() { while (true) { switch (state) { case TaskFinDeMatchStates.Init: servoPositionsRequested = new Dictionary <ServoId, int>(); servoPositionsRequested.Add(ServoId.PorteDrapeau, (int)TaskDrapeauPositionsInit.Drapeau); OnHerkulexPositionRequest(servoPositionsRequested); state = TaskFinDeMatchStates.Attente; break; case TaskFinDeMatchStates.Attente: break; /**********************Ouverture drapeau**************************************/ case TaskFinDeMatchStates.FinDeMatch: OnPilotageVentouse(5, 0); OnPilotageVentouse(6, 0); OnPilotageVentouse(7, 0); state = TaskFinDeMatchStates.FinDeMatchAttente; parentManager.OnEnableMotors(false); servoPositionsRequested = new Dictionary <ServoId, int>(); servoPositionsRequested.Add(ServoId.PorteDrapeau, (int)TaskDrapeauPositionsOpen.Drapeau); OnHerkulexPositionRequest(servoPositionsRequested); break; case TaskFinDeMatchStates.FinDeMatchAttente: state = TaskFinDeMatchStates.Finished; break; /**********************Finished task**************************************/ case TaskFinDeMatchStates.Finished: isFinished = true; state = TaskFinDeMatchStates.Attente; break; } Thread.Sleep(10); } }
void TaskThreadProcess() { while (true) { if (timeStamp.ElapsedMilliseconds < 99999) { switch (state) { case TaskStrategyState.Attente: break; case TaskStrategyState.InitialPositioning: //Le positionnement initial est manuel de manière à pouvoir coller deux robots très proches sans mouvement parasite parentStrategyManager.OnEnableMotors(false); //Le jack force le retour à cet état //parentStrategyManager.taskDistributeur.Init(); RefBoxMessage message = new RefBoxMessage(); message.command = RefBoxCommand.STOP; message.targetTeam = "224.16.32.79"; message.robotID = 0; parentStrategyManager.OnRefereeBoxReceivedCommand(message); indexPrise = 0; state = TaskStrategyState.InitialPositioningEnCours; break; case TaskStrategyState.InitialPositioningEnCours: if (!Jack) { parentStrategyManager.taskBrasDroit.Init(); parentStrategyManager.taskBrasGauche.Init(); parentStrategyManager.taskBrasCentre.Init(); parentStrategyManager.taskBrasDrapeau.Init(); parentStrategyManager.taskPhare.Init(); parentStrategyManager.taskWindFlag.Init(); parentStrategyManager.taskBalade.Init(); parentStrategyManager.taskDepose.Init(); parentStrategyManager.taskFinDeMatch.Init(); parentStrategyManager.OnEnableMotors(true); message = new RefBoxMessage(); message.command = RefBoxCommand.START; message.targetTeam = "224.16.32.79"; message.robotID = 0; parentStrategyManager.OnRefereeBoxReceivedCommand(message); parentStrategyManager.OnCollision(parentStrategyManager.robotId, parentStrategyManager.robotCurentLocation); //On génère artificellement une collision pour resetter Kalman et le reste autour de la position courante. state = TaskStrategyState.Phare; if (isFirstRun) { isFirstRun = false; StartSw(); } } break; case TaskStrategyState.PushFlags: parentStrategyManager.taskWindFlag.Start(); state = TaskStrategyState.PushFlagsEnCours; break; case TaskStrategyState.PushFlagsEnCours: if (parentStrategyManager.taskWindFlag.isFinished) { state = TaskStrategyState.Distributeurs; } break; case TaskStrategyState.Phare: parentStrategyManager.taskPhare.Start(); state = TaskStrategyState.PhareEnCours; break; case TaskStrategyState.PhareEnCours: if (parentStrategyManager.taskPhare.isFinished) { state = TaskStrategyState.PushFlags; } break; case TaskStrategyState.Distributeurs: if (parentStrategyManager.Team == Equipe.Jaune) { if (indexPrise < locsPoseJaune.Count && indexPrise < locsPriseJaune.Count) { parentStrategyManager.taskDistributeur.Start(locsPriseJaune[indexPrise], locsPoseJaune[indexPrise]); indexPrise++; state = TaskStrategyState.DistributeursEnCours; } else { state = TaskStrategyState.Attente; } } else if (parentStrategyManager.Team == Equipe.Bleue) { if (indexPrise < locsPoseBleue.Count && indexPrise < locsPriseBleue.Count) { parentStrategyManager.taskDistributeur.Start(locsPriseBleue[indexPrise], locsPoseBleue[indexPrise]); indexPrise++; state = TaskStrategyState.DistributeursEnCours; } else { state = TaskStrategyState.InitialPositioningEnCours; } } break; case TaskStrategyState.DistributeursEnCours: if (parentStrategyManager.taskDistributeur.isFinished) { state = TaskStrategyState.Distributeurs; } break; default: state = TaskStrategyState.Phare; break; } } else { Init(); if (!isStoped) { parentStrategyManager.taskFinDeMatch.Start(); timeStamp.Stop(); } isStoped = true; } Thread.Sleep(1); } }