private void StopGame() { this.canDoMath = false; this.canSendPos = false; // Reset des liste de segment listPos = new List <PositionDataModel>(); listPos2 = new List <Position2DataModel>(); listForce = new List <ForceDataModel>(); listForce2 = new List <Force2DataModel>(); listVit = new List <VitesseModel>(); listVit2 = new List <Vitesse2Model>(); listError = new List <PprDataModel>(); satMoy = new List <double>(); this.ErrorPlotPoint.Clear(); this.VitessePlotPoint.Clear(); this.ErrorMoyPlot.Clear(); this.VitesseMoyPlot.Clear(); Application.Current.Dispatcher.Invoke(new Action(() => { Messenger.Default.Send <bool>(false, "RefreshPlot"); }), DispatcherPriority.Normal); this.pss.Pss.SendCommandFrame(CommandCodes.STOPnv); if (this.game != null) { this.game.onNewTrajectory -= new AxReaLabToUnity.NewTrajectoryHandler(game_onNewTrajectory); this.game.onLevelStarted -= new AxReaLabToUnity.NewLevelStartedHandler(game_onLevelStarted); this.game.onCheckpointReached -= new AxReaLabToUnity.NewCheckpointReachedHandler(game_onCheckpointReached); this.game.onLevelStopped -= new AxReaLabToUnity.NewLevelStoppedHandler(game_onLevelStopped); this.pss.Pss.PositionDataReceived -= new AxCommunication.onPositionDataReceived(Pss_PositionDataReceived); this.pss.Pss.Position2DataReceived -= new AxCommunication.onPosition2DataReceived(Pss_Position2DataReceived); this.pss.Pss.PprDataReceived += new AxCommunication.onPprDataReceived(Pss_PprDataReceived); this.pss.Pss.VitesseDataReceived -= new AxCommunication.onVitesseDataReceived(Pss_VitesseDataReceived); this.pss.Pss.Vitesse2DataReceived -= new AxCommunication.onVitesse2DataReceived(Pss_Vitesse2DataReceived); this.pss.Pss.ForceDataReceived -= new AxCommunication.onForceDataReceived(Pss_ForceDataReceived); this.pss.Pss.Force2DataReceived -= new AxCommunication.onForce2DataReceived(Pss_Force2DataReceived); this.pss.Pss.StreamingDone -= new EventHandler(Pss_StreamingDone); this.game.StopGame(); this.game = null; } // Gestion des états de l'interface this.gameStarted = false; RaisePropertyChanged("OptionsEnabled"); if (this.currentType == TypeMazeGame.BaseLine || this.currentType == TypeMazeGame.After || this.currentType == TypeMazeGame.Training || this.currentType == TypeMazeGame.NewCircuit) { this.CircuitsEnabled = true; } }
/// <summary> /// Fin de la calibration, quand la position est idéale /// </summary> private void StopCalibration() { if (this.game != null) { this.game.StopGame(); this.game = null; this.gameStarted = false; this.StopCalibrationCommand.RaiseCanExecuteChanged(); XDocument doc; if (File.Exists(this.pathPatient + "/InfoPatient.xml")) { doc = XDocument.Load(this.pathPatient + "/InfoPatient.xml"); if (Singleton.UniBi == true && Singleton.MainGaucheX == true) { doc.Root.Element("Uni_Gauche").Element("CalibrX").ReplaceNodes(this.calibrX / 100.0); doc.Root.Element("Uni_Gauche").Element("CalibrY").ReplaceNodes(this.calibrY / 100.0); } else if (Singleton.UniBi == true && Singleton.MainGaucheX == false) { doc.Root.Element("Uni_Droit").Element("CalibrX").ReplaceNodes(this.calibrX / 100.0); doc.Root.Element("Uni_Droit").Element("CalibrY").ReplaceNodes(this.calibrY / 100.0); } else if (Singleton.UniBi == false && Singleton.MainGaucheX == true) { doc.Root.Element("Bi_Gauche").Element("CalibrX").ReplaceNodes(this.calibrX / 100.0); doc.Root.Element("Bi_Gauche").Element("CalibrY").ReplaceNodes(this.calibrY / 100.0); } else if (Singleton.UniBi == false && Singleton.MainGaucheX == false) { doc.Root.Element("Bi_Droit").Element("CalibrX").ReplaceNodes(this.calibrX / 100.0); doc.Root.Element("Bi_Droit").Element("CalibrY").ReplaceNodes(this.calibrY / 100.0); } doc.Save(this.pathPatient + "/InfoPatient.xml"); Singleton.CalibrX = this.calibrX / 100.0; Singleton.CalibrY = this.calibrY / 100.0; } } this.pss.Pss.SendCommandFrame(CommandCodes.STOPnv); this.pss.Pss.PositionDataReceived -= new AxCommunication.onPositionDataReceived(Pss_PositionDataReceived); this.pss.Pss.Position2DataReceived -= new AxCommunication.onPosition2DataReceived(Pss_Position2DataReceived); this.canNext = true; NextViewModelCommand.RaiseCanExecuteChanged(); }
/// <summary> /// Début de la calibration de l'exercice /// </summary> private void StartCalibration() { this.pss.Pss.PositionDataReceived += new AxCommunication.onPositionDataReceived(Pss_PositionDataReceived); this.pss.Pss.Position2DataReceived += new AxCommunication.onPosition2DataReceived(Pss_Position2DataReceived); this.game = new MazeCircuitGame(0, 0, 9); this.game.StartGame(); this.gameStarted = true; this.StartCalibrationCommand.RaiseCanExecuteChanged(); //this.pss.Pss.PositionDataReceived +=new AxCommunication.onPositionDataReceived(Pss_PositionDataReceived); //this.pss.Pss.Position2DataReceived +=new AxCommunication.onPosition2DataReceived(Pss_Position2DataReceived); // Positionner le robot + init du mod calibration // Détermine quelle bornes envoyer au robot pour la calibration FrameExerciceDataModel frame = new FrameExerciceDataModel(); if (Singleton.UniBi) { // Unimanuel if (Singleton.MainGaucheX) { // gauche frame = new MazeCalibModel(547, 374, UniBiCodes.UnimanuelGauche).MakeFrame();//537 547 } else { // droite frame = new MazeCalibModel(556, 964, UniBiCodes.UnimanuelDroite).MakeFrame(); } } else { // Bimanuel if (Singleton.MainGaucheX) { // gauche frame = new MazeCalibModel(547, 964, UniBiCodes.BimanuelGaucheXDroiteY).MakeFrame(); } else { // droite frame = new MazeCalibModel(556, 374, UniBiCodes.BimanuelGaucheYDroiteX).MakeFrame(); } } // Envoie du mod de calibration pss.Pss.SendExerciceFrame(frame); pss.Pss.SendCommandFrame(CommandCodes.mode_libre); }
private void StartGame() { this.SendViscosite(); if (this.currentType == TypeMazeGame.BaseLine || this.currentType == TypeMazeGame.After || this.currentType == TypeMazeGame.Training) { // Si le jeu est fait en training ou base line on peut retenir le circuit fait et ne plus le proposer pour le new circuit this.lastCircuit = this.IndexOfCircuitChecked(); this.NewCircuitEnabled = true; } // Lancer le jeux en fonction du mode switch (currentType) { case TypeMazeGame.Null: break; case TypeMazeGame.Familiarisation: game = new MazeCircuitGame(2, 0, this.IndexOfCircuitChecked()); break; case TypeMazeGame.BaseLine: game = new MazeCircuitGame(0, 0, this.IndexOfCircuitChecked() + 1); break; case TypeMazeGame.Training: game = new MazeCircuitGame(1, 0, this.IndexOfCircuitChecked() + 1); break; case TypeMazeGame.Reaching: game = new MazeCircuitGame(0, ReachingRadius, 10); break; case TypeMazeGame.NewCircuit: game = new MazeCircuitGame(0, 0, this.IndexOfCircuitChecked() + 1); break; case TypeMazeGame.After: game = new MazeCircuitGame(0, 0, this.IndexOfCircuitChecked() + 1); break; default: break; } this.game.StartGame(); this.highScore = 0; // Gestion des états de l'interface this.gameStarted = true; RaisePropertyChanged("OptionsEnabled"); this.CircuitsEnabled = false; this.firstSegment = true; // Abonnements à tous les events this.game.onNewTrajectory += new AxReaLabToUnity.NewTrajectoryHandler(game_onNewTrajectory); this.game.onLevelStarted += new AxReaLabToUnity.NewLevelStartedHandler(game_onLevelStarted); this.game.onCheckpointReached += new AxReaLabToUnity.NewCheckpointReachedHandler(game_onCheckpointReached); this.game.onLevelStopped += new AxReaLabToUnity.NewLevelStoppedHandler(game_onLevelStopped); this.pss.Pss.PositionDataReceived += new AxCommunication.onPositionDataReceived(Pss_PositionDataReceived); this.pss.Pss.Position2DataReceived += new AxCommunication.onPosition2DataReceived(Pss_Position2DataReceived); this.pss.Pss.PprDataReceived += new AxCommunication.onPprDataReceived(Pss_PprDataReceived); this.pss.Pss.VitesseDataReceived += new AxCommunication.onVitesseDataReceived(Pss_VitesseDataReceived); this.pss.Pss.Vitesse2DataReceived += new AxCommunication.onVitesse2DataReceived(Pss_Vitesse2DataReceived); this.pss.Pss.ForceDataReceived += new AxCommunication.onForceDataReceived(Pss_ForceDataReceived); this.pss.Pss.Force2DataReceived += new AxCommunication.onForce2DataReceived(Pss_Force2DataReceived); this.pss.Pss.StreamingDone += new EventHandler(Pss_StreamingDone); this.newNameFile = this.FindFileName(this.pathToFile, this.currentType.ToString(), ".txt"); this.game.SetColor((int)this.currentColor); }