Exemple #1
0
        private List<SubStrategy> _subStrategies = null; // Toutes les sous stratégies

        #endregion Fields

        #region Constructors

        // Public ---------------------------------------------------------------------------------
        public Strategy(String strategyName)
        {
            // Si le nom est non nul, on ajoute ce nom à la stratégie
            if (strategyName != null)
                _strategyName = strategyName;

            // Creation du premier objet pour la partie décisionnelle
            _subStrategies = new List<SubStrategy>();
            _subStrategies.Add(new SubStrategy(PrivateConst.mainStrategyName, 0));

            // Creation de la position du robot initial
            _initialPos = new RobotAction(0);
            _initialPos.cmdType = EnumCmdType.CmdType_Blocking;             // Blocking Action
            _initialPos.cmd = EnumCmd.App_SetNewPos;                        // Defines the first robot position
            _initialPos.param2 = "1500";                                    // X
            _initialPos.param3 = "1000";                                    // Y
            _initialPos.param4 = "0";                                       // Angle
            _initialPos.activeSensors.DesactivateAllSensors();              // Do not use bumpers

            // Creation de la vitesse par défaut
            _defaultSpeed = 50;
            _defaultPivotSpeed = 50;

            _debugTool = new DebugTool(DebugTool.EDebugToolType.Console);
        }
Exemple #2
0
 public DisplayPos(RobotAction robotAction)
 {
     if (robotAction != null)
     {
         _robotAction = robotAction;
         _initialPos = new List<RobotPos>();
     }
 }
Exemple #3
0
 /// <summary>
 /// Permet de mettre à jour les données de l'objet en cours à partir d'un autre objet passé en paramètre
 /// </summary>
 /// <param name="newValues">Objet contenant les nouvelles valeurs à assigner</param>
 public void UpdateValue(RobotAction newValues)
 {
     if (newValues != null)
     {
         this.ID = newValues.ID;
         this.cmd = newValues.cmd;
         this.cmdType = newValues.cmdType;
         this.param1 = newValues.param1;
         this.param2 = newValues.param2;
         this.param3 = newValues.param3;
         this.param4 = newValues.param4;
         this.nextID = newValues.nextID;
         this.timeoutID = newValues.timeoutID;
         this.activeSensors.ForceSensors(newValues.activeSensors.Activated);
     }
 }
Exemple #4
0
 public static int ComparisonID(RobotAction firstRobotAction, RobotAction secondRobotAction)
 {
     if(firstRobotAction != null)
     {
         if(secondRobotAction != null)
         {
             return (firstRobotAction.ID - secondRobotAction.ID);
         }
         else
             return 1;
     }
     else
     {
         if(secondRobotAction != null)
             return -1;
         else
             return 0;
     }
 }
Exemple #5
0
        /// <summary>
        /// Import a new strategy from an external file (given as parameter)
        /// </summary>
        /// <param name="inputFileName">filename of internal file</param>
        /// <param name="patternFileName">pattern file to use for the importation</param>
        /// <returns></returns>
        public int Import(String inputFileName, String patternFileName)
        {
            int Ret = -1;
            int patternLineIndex = 0;
            int importLineIndex = 0;
            int minLineIndex = 0;
            int nbLineToRemove = 0;
            int currentLineIndex = 0;
            int counter = 0;
            TextFile patternFile = new TextFile();                              // Fichier pattern pour l'import des données
            TextFile fileToImport = new TextFile();                             // Fichier à importer
            StructuredFile importFile = new StructuredFile();                   // Fichier utiliser pour lire les données
            List<String> patternLoop = new List<string>();                      // Pour stocker les lignes du pattern à repeter dans la rubrique LOOP
            String lineRead = "";                                               // Variable pour lire les données du fichier
            StructuredFileKey currentKey = null;

            try
            {
                // Verification des paramètres
                if ((inputFileName != null) && (patternFileName != null))
                {
                    // Lecture du fichier modele
                    patternFile.Load(patternFileName);

                    // Lecture du fichier à importer
                    fileToImport.Load(inputFileName);

                    // Si les fichiers sont valides, on les prépare pour les importer
                    if ((patternFile.Count() > 0) && (fileToImport.Count() > 0))
                    {
                        #region PreparationDesFichiers
                        // Suppression des tabulations
                        patternFile.ReplaceInFile("\t", "");
                        fileToImport.ReplaceInFile("\t", "");

                        // Suppression des lignes inutiles
                        patternFile.RemoveEmptyLine();
                        fileToImport.RemoveEmptyLine();

                        // Mise en correspondance des fichiers
                        // Recherche de l'index du début de boucle
                        importLineIndex = fileToImport.GetFirstIndexLine(PrivateConst.subStrategyBeginTag, 0);
                        patternLineIndex = patternFile.GetFirstIndexLine(PrivateConst.subStrategyBeginTag, 0);

                        // Verification de la presence de la boucle dans les 2 fichiers
                        if ((importLineIndex >= 0) && (patternLineIndex >= 0))
                        {
                            // Lecture du minimum de ligne
                            minLineIndex = Math.Min(importLineIndex, patternLineIndex);

                            // Verification si un ecart existe dans le positionnement du tag de debut de boucle
                            if (importLineIndex != patternLineIndex)
                            {

                                // Suppression des lignes en trop dans le fichier d'import
                                nbLineToRemove = importLineIndex - minLineIndex;
                                for (int i = 0; i < nbLineToRemove; i++)
                                    fileToImport.RemoveLine(minLineIndex);

                                // Suppression des lignes en trop dans le fichier de modèle
                                nbLineToRemove = patternLineIndex - minLineIndex;
                                for (int i = 0; i < nbLineToRemove; i++)
                                    patternFile.RemoveLine(minLineIndex);

                            }

                            // Creation des boucles
                            // 1 - Lecture des lignes du modèle
                            do
                            {
                                // Lecture de la ligne
                                lineRead = patternFile.GetLine(minLineIndex + 1);

                                // Verification du contenu
                                if ((lineRead != null) && (lineRead.Contains(PrivateConst.subStrategyBeginTag) == false) && (lineRead.Contains(PrivateConst.subStrategyEndTag) == false))
                                {
                                    patternLoop.Add(lineRead);      // Ajout de la ligne courante
                                    patternFile.RemoveLine(minLineIndex + 1);
                                }
                            }
                            while ((lineRead != null) && (lineRead.Contains(PrivateConst.subStrategyEndTag) == false));

                            if (patternLoop.Count() > 0)
                            {
                                // 2 - Duplication des données du modele en fonction des données du fichier à importer
                                currentLineIndex = minLineIndex + 1;    // On se place au début de la boucle
                                counter = 0;                            // Initialisation du compteur pour dupliquer le pattern
                                do
                                {
                                    // Lecture de la ligne
                                    lineRead = fileToImport.GetLine(currentLineIndex);

                                    if ((lineRead != null) && (lineRead.Contains(PrivateConst.subStrategyBeginTag) == false) && (lineRead.Contains(PrivateConst.subStrategyEndTag) == false))
                                    {
                                        // Verification du compteur
                                        if (counter >= patternLoop.Count())
                                            counter = 0;

                                        // Ajout de la ligne de pattern en conséquence
                                        patternFile.AddLine(patternLoop[counter], currentLineIndex);

                                        counter = counter + 1;
                                    }

                                    currentLineIndex = currentLineIndex + 1;
                                }
                                while ((lineRead != null) && (lineRead.Contains(PrivateConst.subStrategyEndTag) == false));
                            }
                        }

                        // Ajout des lignes dans le fichier d'import si les tailles ne correspondent pas
                        while(patternFile.Count() > fileToImport.Count())
                            fileToImport.AddLine("EMPTY LINE");

                        // Ajout des lignes dans le fichier pattern si les tailles ne correspondent pas
                        while (fileToImport.Count() > patternFile.Count())
                            patternFile.AddLine("EMPTY LINE");
                        #endregion

                        #region LectureDesDonnees
                        // Ajout du fichier pattern
                        importFile.SetPatternFile(patternFile);

                        // Lecture du fichier
                        importFile.Import(fileToImport);
                        #endregion

                        #region TraitementDesDonnees
                        if (importFile.Count() > 0)
                        {
                            // Lecture des groupes un par un
                            foreach (StructuredFileGroup currentGroup in importFile.GetAllGroup())
                            {
                                // Lecture de la clé contenant le nom de la Stategy
                                currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_SubStrategyName);

                                // Si la clé courante fait partie d'une stratégie
                                if(currentKey != null)
                                {
                                    // Si le group actuel appartient à une stratégie, lecture du nom de la stratégie
                                    String subStrategyName = currentKey.valueString;
                                    RobotAction actionToImport = new RobotAction();

                                    // Si il s'agit d'une action à ajouter à la stratégie
                                    if (actionToImport.Import(currentGroup) == true)
                                    {
                                        bool isAdded = false;

                                        for (int i = 0; i < _subStrategies.Count(); i++)
                                        {
                                            // Si la clé lue appartient à la stratégie courante, on l'ajoute
                                            if (subStrategyName == _subStrategies[i].Name)
                                            {
                                                _subStrategies[i].AddAction(actionToImport);
                                                isAdded = true;
                                            }
                                        }

                                        // Si la clé n'a pas été ajoutée, on l'ajoute
                                        if (isAdded == false)
                                        {
                                            int subStrategyID = Convert.ToInt32(Math.Floor(actionToImport.ID / 100.0));
                                            SubStrategy subStrategyToAdd = new SubStrategy(subStrategyName, subStrategyID);
                                            subStrategyToAdd.AddAction(actionToImport);
                                            _subStrategies.Add(subStrategyToAdd);
                                        }
                                    }
                                }
                                else
                                {
                                    // Sinon la clé est ajoutée aux variables globales de l'appli (si la clé est nécessaire)
                                    // Lecture du nom de la stratégie
                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_StrategyName);
                                    if (currentKey != null)
                                        _strategyName = currentKey.valueString;

                                    // Variables pour la position initiale
                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_InitialPosX);
                                    if (currentKey != null) { _initialPos.param2 = currentKey.valueString; }

                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_InitialPosY);
                                    if (currentKey != null) { _initialPos.param3 = currentKey.valueString; }

                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_InitialPosA);
                                    if (currentKey != null) { _initialPos.param4 = currentKey.valueString; }

                                    // Valeur par défaut
                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_DefaultSpeed);
                                    if (currentKey != null) { _defaultSpeed = currentKey.valueInt; }

                                    // Valeur par défaut
                                    currentKey = currentGroup.GetFirstKey(PrivateConst.TAG_DefaultPivotSpeed);
                                    if (currentKey != null) { _defaultPivotSpeed = currentKey.valueInt; }
                                }
                            }
                        }
                        #endregion

                    }
                }
            }
            catch (Exception ex)
            {
                _debugTool.WriteLine("Strategy Import() : " + ex.Message);
                Ret = -1;
            }

            return Ret;
        }
Exemple #6
0
        /// <summary>
        /// Permet de vider la stratégie actuelle
        /// </summary>
        public void Clear()
        {
            _subStrategies = new List<SubStrategy>();
            _subStrategies.Add(new SubStrategy(PrivateConst.mainStrategyName, 0));

            _initialPos = new RobotAction(0);
            _initialPos.cmdType = EnumCmdType.CmdType_Blocking;             // Blocking Action
            _initialPos.cmd = EnumCmd.App_SetNewPos;                        // Defines the first robot position
            _initialPos.param2 = "0";                                       // X
            _initialPos.param3 = "0";                                       // Y
            _initialPos.param4 = "0";                                       // Angle
            _initialPos.activeSensors.DesactivateAllSensors();              // Do not use bumpers

            _defaultSpeed = 50;
        }
        private void UpdateData(object sender, EventArgs e)
        {
            _currentRobotAction = _mainModel.selectedRobotAction;

            if (_currentRobotAction != null)
            {
                // Copie de l'objet en local
                _modifiedRobotAction.ID = _currentRobotAction.ID;
                _modifiedRobotAction.cmd = _currentRobotAction.cmd;
                _modifiedRobotAction.cmdType = _currentRobotAction.cmdType;
                _modifiedRobotAction.nextID = _currentRobotAction.nextID;
                _modifiedRobotAction.param1 = _currentRobotAction.param1;
                _modifiedRobotAction.param2 = _currentRobotAction.param2;
                _modifiedRobotAction.param3 = _currentRobotAction.param3;
                _modifiedRobotAction.param4 = _currentRobotAction.param4;
                _modifiedRobotAction.timeoutID = _currentRobotAction.timeoutID;
                _modifiedRobotAction.activeSensors.ForceSensors(_currentRobotAction.activeSensors.Activated);

                LoadDisplayPos();

                if ((listPrevID.Count > 0) && (_currentRobotAction.ID != listPrevID[listPrevID.Count - 1].nextID))
                {
                    listPrevID.Clear();
                }
            }
            RaisePropertyChangedGrouped();
        }
        private RobotAction _modifiedRobotAction; // Action pour la mise à jour

        #endregion Fields

        #region Constructors

        // Public ---------------------------------------------------------------------------------
        public RobotActionVM()
        {
            _modifiedRobotAction = new RobotAction();
            _mainModel = MainModel.GetInstance;
            _mainModel.RobotActionChanged += new EventHandler(UpdateData);
        }
        private void AddNewCmdNotLinked()
        {
            int newID = -1;
            RobotAction newRobotAction = null;

            if (_mainModel.selectedSubStrategy != null)
            {
                newID = _mainModel.selectedSubStrategy.GetFreeID();

                if (newID > 0)
                {
                    newRobotAction = new RobotAction(newID);
                    newRobotAction.cmd = EnumCmd.App_Wait;
                    newRobotAction.nextID = -1;

                    _mainModel.selectedRobotAction = newRobotAction;
                    _mainModel.selectedSubStrategy.AddAction(newRobotAction);
                    _mainModel.UpdateRobotActionList();
                }
            }
        }
Exemple #10
0
        // Private functions ----------------------------------------------------------------------
        private RobotAction GetFirstRobotAction()
        {
            RobotAction Ret = null;

            if(_subStrategyID == 0)
                Ret = new RobotAction(1);
            else
                Ret = new RobotAction(_subStrategyID * 1000);

            Ret.cmd = EnumCmd.App_Wait;
            Ret.cmdType = EnumCmdType.CmdType_Blocking;
            Ret.param1 = "0";
            Ret.param2 = "0";
            Ret.param3 = "0";
            Ret.param4 = "1";
            Ret.nextID = 0;

            return Ret;
        }
Exemple #11
0
        /// <summary>
        /// Permet de mettre à jour l'action ayant l'id actionID avec les données en paramètre
        /// L'ID n'est pas mis à jour
        /// </summary>
        /// <param name="actionID">ID de l'action à mettre à jour</param>
        /// <param name="newAction">Nouvelles données à mettre à jour</param>
        /// <returns>True si l'ajout a été fait correctement, False sinon</returns>
        public bool UpdateAction(int actionID, RobotAction newAction)
        {
            bool Ret = false;

            if ((newAction != null) && (_actions != null) && (actionID > 0))
            {
                // Verification des ID
                newAction.ID = CheckID(newAction.ID);
                newAction.nextID = CheckLinkID(newAction.nextID);
                newAction.timeoutID = CheckLinkID(newAction.timeoutID);

                // On met à jour les données que si on modifie l'objet courant ou si le nouvel ID n'est pas utilisé
                if ((newAction.ID == actionID) || (GetAction(newAction.ID) == null))
                {
                    // On parcourt tous les objets pour mettre à jour les actions ayant le bon ID
                    foreach (RobotAction currentRobotAction in _actions)
                    {
                        if (currentRobotAction.ID == actionID)
                        {
                            currentRobotAction.UpdateValue(newAction);
                            Ret = true;
                        }
                    }
                }
            }

            return Ret;
        }
Exemple #12
0
        /// <summary>
        /// Charge les informations de la substrategy à partir du fichier spécifié en paramètre
        /// Le chargement d'un fichier détruit toutes les données précédemment sauvegardée
        /// </summary>
        /// <param name="filename">Nom du fichier pour charger le fichier</param>
        /// <param name="forcedID">ID à utiliser à la place de l'ID du fichier</param>
        /// <returns>Retourne le nombre d'action chargée, -1 en cas d'erreur</returns>
        public int Load(String filename, int forcedID)
        {
            int Ret = -1;
            StructuredFile inputFile = new StructuredFile();
            StructuredFileGroup globalGroup = null;
            List<StructuredFileGroup> actionsGroup = null;
            StructuredFileKey currentKey = null;
            RobotAction currentAction = null;

            if (filename != null)
            {
                // Ouverture du fichier
                inputFile.Load(filename);

                // Destruction des données actuelles
                _subStrategyName = "Not Set";
                _actions = null;

                // Chargement des données génériques
                globalGroup = inputFile.GetGroupByID(0);
                if (globalGroup != null)
                {
                    currentKey = globalGroup.GetFirstKey("SubStrategyName");
                    if (currentKey != null)
                        _subStrategyName = currentKey.valueString;

                    if (forcedID > 0)
                    {
                        // Un ID a été imposé, nous l'utilisons
                        _subStrategyID = forcedID;
                    }
                    else
                    {
                        // Nous utilisons l'ID du fichier
                        currentKey = globalGroup.GetFirstKey("SubStrategyID");
                        if (currentKey != null)
                            _subStrategyID = currentKey.valueInt;
                    }
                }

                // Chargement des données liées aux actions
                actionsGroup = inputFile.GetAllGroup();
                if (actionsGroup != null)
                {
                    Ret = 0;
                    // Lecture de tous les groupes pour extraire les données liées aux actions
                    foreach (StructuredFileGroup currentGroup in actionsGroup)
                    {
                        // Nous ne devons extraire que les données des groupes > à 0
                        if (currentGroup.ID > 0)
                        {
                            currentAction = new RobotAction();
                            currentAction.Import(currentGroup);

                            // On ajoute l'objet que l'on vient d'importer s'il est valide
                            if (currentAction.cmd != EnumCmd.NotSet)
                            {
                                if (_actions == null)
                                {
                                    _actions = new List<RobotAction>();
                                }

                                // Verification des ID
                                currentAction.ID = CheckID(currentAction.ID);
                                currentAction.nextID = CheckLinkID(currentAction.nextID);
                                currentAction.timeoutID = CheckLinkID(currentAction.timeoutID);

                                _actions.Add(currentAction);
                                Ret = Ret + 1;
                            }
                        }
                    }
                }

            }

            SortRobotActions();

            return Ret;
        }
Exemple #13
0
        /// <summary>
        /// Ajoute un nouvel objet RobotAction dans la sub-stratégie
        /// Si l'ID est déjà utilisé, on met à jour les données avec l'objet en paramètre
        /// </summary>
        /// <param name="newAction">Nouvel objet à ajouter</param>
        /// <returns>True si l'ajout s'effectue correctement, False sinon</returns>
        public bool AddAction(RobotAction newAction)
        {
            bool Ret = false;

            if (newAction != null)
            {
                // Verification des ID
                newAction.ID = CheckID(newAction.ID);
                newAction.nextID = CheckLinkID(newAction.nextID);
                newAction.timeoutID = CheckLinkID(newAction.timeoutID);

                // On ajoute l'objet dans la liste
                if (_actions == null)
                {
                    _actions = new List<RobotAction>();
                    _actions.Add(GetFirstRobotAction());
                    _actions.Add(newAction);
                }
                else
                {
                    // On verifie si l'ID n'est pas déjà utilisé
                    RobotAction isPresent = GetAction(newAction.ID);
                    if (isPresent != null)
                    {
                        // L'ID existe déjà, on le met à jour
                        isPresent.UpdateValue(newAction);
                    }
                    else
                    {
                        // L'objet n'existe pas, on peut l'ajouter
                        _actions.Add(newAction);
                    }
                }

                Ret = true;
            }

            SortRobotActions();

            return Ret;
        }
Exemple #14
0
        static void Main(string[] args)
        {
            bool Validated = true;

            // ############################################################################################################################
            // ##### ActiveSensors
            // ############################################################################################################################
            #region ActiveSensors
            ActiveSensors testActiveSensors = new ActiveSensors();

            // Test 0200 : ActiveSensors __________________________________________________________________________________________________
            try
            {
                DisplaySeparator();
                Console.WriteLine("Test 0200 - Verification des objets ActiveSensors : \n");

                if (testActiveSensors.Activated == "(APP_PARAM_STRATEGYFLAG_NONE)")
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                testActiveSensors.ActivateSensors("APP_PARAM_STRATEGYFLAG_COLLISION_FRONT");
                testActiveSensors.ActivateSensors("APP_PARAM_STRATEGYFLAG_COLLISION_FRONT");
                testActiveSensors.ActivateSensors("APP_PARAM_STRATEGYFLAG_COLLISION_REAR");
                if (testActiveSensors.Activated == "(APP_PARAM_STRATEGYFLAG_COLLISION_FRONT + APP_PARAM_STRATEGYFLAG_COLLISION_REAR)")
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                testActiveSensors.DesactivateSensors("APP_PARAM_STRATEGYFLAG_COLLISION_FRONT");
                if (testActiveSensors.Activated == "(APP_PARAM_STRATEGYFLAG_COLLISION_REAR)")
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                testActiveSensors.DesactivateAllSensors();
                if (testActiveSensors.Activated == "(APP_PARAM_STRATEGYFLAG_NONE)")
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                testActiveSensors.ActivateSensors("APP_PARAM_STRATEGYFLAG_COLLISION_FRONT");
                testActiveSensors.ForceSensors("APP_PARAM_STRATEGYFLAG_COLLISION_REAR");
                if (testActiveSensors.Activated == "(APP_PARAM_STRATEGYFLAG_COLLISION_REAR)")
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Test 0200 Failed !!");
                Console.WriteLine(ex.Message);
                Validated = false;
            }
            #endregion
            // ############################################################################################################################
            // ##### RobotAction
            // ############################################################################################################################
            #region RobotAction
            RobotAction testAction = new RobotAction();

            // Test 0201 : RobotAction ____________________________________________________________________________________________________
            try
            {
                DisplaySeparator();
                Console.WriteLine("Test 0201 - Verification des objets Action : \n");
                Console.WriteLine(" -> Verification des private");
                // ------------------------------------------------------------------------------------------
                if (testAction.CheckPrivateFunction())
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                // ------------------------------------------------------------------------------------------
                Console.WriteLine(" -> Test de la fonction d'export() : ");
                testAction.ID = 1;
                testAction.cmd = EnumCmd.Mvt_UseMixedMode;
                testAction.cmdType = EnumCmdType.CmdType_Blocking;
                testAction.param1 = "11";
                testAction.param2 = "12";
                testAction.param3 = "13";
                testAction.param4 = "14";
                testAction.nextID = 100;
                testAction.timeoutID = 200;

                StructuredFileGroup output = testAction.Export();

                if (output != null)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                // ------------------------------------------------------------------------------------------
                Console.WriteLine(" -> Test de la fonction d'import() : ");
                testAction = new RobotAction();
                StructuredFileGroup inputData = new StructuredFileGroup(10);

                inputData.AddKey(new StructuredFileKey("Cmd", "Mvt_UseMixedMode"));
                inputData.AddKey(new StructuredFileKey("CmdType", "Blocking"));
                inputData.AddKey(new StructuredFileKey("Param1", 50));
                inputData.AddKey(new StructuredFileKey("Param2", 100));
                inputData.AddKey(new StructuredFileKey("Param3", 200));
                inputData.AddKey(new StructuredFileKey("Param4", 90.0));
                inputData.AddKey(new StructuredFileKey("ActiveSensors", "COLLISION_FRONT"));
                inputData.AddKey(new StructuredFileKey("nextID", 10));
                inputData.AddKey(new StructuredFileKey("timeoutID", 30));

                if (testAction.Import(inputData) == true)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("Test 0201 Failed !!");
                Console.WriteLine(ex.Message);
                Validated = false;
            }
            #endregion

            // ############################################################################################################################
            // ##### SubStrategy
            // ############################################################################################################################
            #region SubStrategy
            // Test 0202 : SubStrategy ____________________________________________________________________________________________________
            try
            {
                DisplaySeparator();
                // ------------------------------------------------------------------------------------------

                SubStrategy strategy1 = new SubStrategy("Strategy 1", 1);
                SubStrategy strategy2 = new SubStrategy("Strategy 2", 1);

                // Creation de l'action 1
                RobotAction Action1 = new RobotAction(1);
                Action1.cmd = EnumCmd.Mvt_UseMixedMode;
                Action1.cmdType = EnumCmdType.CmdType_Blocking;
                Action1.param1 = "1";
                Action1.param2 = "2";
                Action1.param3 = "3";
                Action1.param4 = "4";
                Action1.nextID = -1;
                Action1.timeoutID = -1;

                RobotAction Action10 = new RobotAction(10);
                Action1.cmd = EnumCmd.Mvt_UseMixedMode;
                Action1.cmdType = EnumCmdType.CmdType_Blocking;
                Action1.param1 = "10";
                Action1.param2 = "20";
                Action1.param3 = "30";
                Action1.param4 = "40";
                Action1.nextID = -1;
                Action1.timeoutID = -1;

                RobotAction Action2 = new RobotAction(2);
                Action2.cmd = EnumCmd.App_Wait;
                Action2.cmdType = EnumCmdType.CmdType_Blocking;
                Action2.param1 = "4";
                Action2.param2 = "3";
                Action2.param3 = "2";
                Action2.param4 = "1";
                Action2.nextID = -1;
                Action2.timeoutID = -1;

                strategy1.AddAction(Action1);   strategy1.AddAction(Action2);   strategy1.AddAction(Action10);
                strategy2.AddAction(Action1);   strategy2.AddAction(Action2);   strategy2.AddAction(Action10);

                Console.WriteLine("Test 0202 - SubStrategy : ");
                if (strategy1.Count() == 3)
                {
                    Console.Write(" Ok\n");
                } else {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Suppression d'une action : ");
                strategy1.RemoveAction(10);
                strategy2.RemoveAction(20);
                if ((strategy1.Count() == 2) && (strategy2.Count() == 3))
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Recherche d'une action : ");
                if ((strategy1.GetAction(1) != null) && (strategy1.GetAction(20) == null))
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Ajout d'une action existante : ");
                strategy2.AddAction(Action1);
                if (strategy2.Count() == 3)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Update d'une action existante : ");
                if ((strategy1.UpdateAction(1, Action1) == true) && (strategy1.UpdateAction(1, Action2) == false) && (strategy1.UpdateAction(50, new RobotAction(40)) == false))
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("Test 0202 Failed !!");
                Console.WriteLine(ex.Message);
                Validated = false;
            }
            #endregion

            // ############################################################################################################################
            // ##### Strategy
            // ############################################################################################################################
            #region Strategy
            // Test 0203 : Strategy _______________________________________________________________________________________________________
            try
            {
                DisplaySeparator();
                // ------------------------------------------------------------------------------------------

                SubStrategy subStrategy1 = new SubStrategy("Strategy 1", 1);
                SubStrategy subStrategy2 = new SubStrategy("Strategy 2", 1);
                Strategy testStrategy = new Strategy("Strategy");
                Strategy testLoadStrategy = new Strategy("LoadStrategy");

                // Creation de l'action 1
                RobotAction Action1 = new RobotAction(1); Action1.cmd = EnumCmd.Mvt_UseMixedMode; Action1.cmdType = EnumCmdType.CmdType_Blocking; Action1.param1 = "1"; Action1.param2 = "2"; Action1.param3 = "3"; Action1.param4 = "4"; Action1.nextID = -1; Action1.timeoutID = -1;
                RobotAction Action10 = new RobotAction(10); Action1.cmd = EnumCmd.Mvt_UseMixedMode; Action1.cmdType = EnumCmdType.CmdType_Blocking; Action1.param1 = "10"; Action1.param2 = "20"; Action1.param3 = "30"; Action1.param4 = "40"; Action1.nextID = -1; Action1.timeoutID = -1;
                RobotAction Action2 = new RobotAction(2); Action2.cmd = EnumCmd.App_Wait; Action2.cmdType = EnumCmdType.CmdType_Blocking; Action2.param1 = "4"; Action2.param2 = "3"; Action2.param3 = "2"; Action2.param4 = "1"; Action2.nextID = -1; Action2.timeoutID = -1;

                subStrategy1.AddAction(Action1); subStrategy1.AddAction(Action2); subStrategy1.AddAction(Action10);
                subStrategy2.AddAction(Action1); subStrategy2.AddAction(Action2); subStrategy2.AddAction(Action10);

                Console.WriteLine("Test 0203 - Strategy : ");
                Console.WriteLine(" -> Add + Update : ");

                testStrategy.UpdateMainStrategy(subStrategy1);
                testStrategy.UpdateSubStrategy(subStrategy1);
                Action1.cmd = EnumCmd.Mvt_Stop;
                subStrategy1.UpdateAction(Action1.ID, Action1);
                testStrategy.UpdateSubStrategy(subStrategy1);
                testStrategy.AddSubStrategy(subStrategy2);
                if (testStrategy.GetAllSubStrategy().Count == 2)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Remove : ");
                testStrategy.RemoveSubStrategy("Strategy 2");
                if (testStrategy.GetAllSubStrategy().Count == 1)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Remove : ");
                testStrategy.Clear();
                if (testStrategy.GetAllSubStrategy() == null)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Save : ");
                testStrategy.UpdateMainStrategy(subStrategy1);
                testStrategy.AddSubStrategy(subStrategy1);
                testStrategy.AddSubStrategy(subStrategy2);
                testStrategy.Save();
                if (true)
                {
                    Console.Write(" Ok (Verification manuelle du dossier de sortie)\n");
                }

                Console.WriteLine(" -> Load : ");
                testLoadStrategy.Load("Strategy");
                if (testLoadStrategy.GetAllSubStrategy().Count == 2)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Export : ");

                RobotAction Action100 = new RobotAction(100); Action100.cmd = EnumCmd.App_Wait; Action100.cmdType = EnumCmdType.CmdType_Blocking; Action100.param1 = "40"; Action100.param2 = "30"; Action100.param3 = "20"; Action100.param4 = "10"; Action100.nextID = 101; Action100.timeoutID = 901;
                RobotAction Action101 = new RobotAction(101); Action101.cmd = EnumCmd.Mvt_UseMixedMode; Action101.cmdType = EnumCmdType.CmdType_NonBlocking; Action101.param1 = "41"; Action101.param2 = "31"; Action101.param3 = "21"; Action101.param4 = "11.5"; Action101.nextID = 102; Action101.timeoutID = 902;
                RobotAction Action102 = new RobotAction(102); Action102.cmd = EnumCmd.MvtSimple_MoveInMM; Action102.cmdType = EnumCmdType.CmdType_Blocking; Action102.param1 = "42"; Action102.param2 = "32"; Action102.param3 = "22"; Action102.param4 = "12"; Action102.nextID = 103; Action102.timeoutID = 903;
                RobotAction Action103 = new RobotAction(103); Action103.cmd = EnumCmd.Mvt_UsePivotMode; Action103.cmdType = EnumCmdType.CmdType_NonBlocking; Action103.param1 = "43"; Action103.param2 = "33"; Action103.param3 = "23"; Action103.param4 = "13"; Action103.nextID = 104; Action103.timeoutID = 904;
                RobotAction Action200 = new RobotAction(200); Action200.cmd = EnumCmd.Mvt_UseSpline; Action200.cmdType = EnumCmdType.CmdType_NonBlocking; Action200.param1 = "44"; Action200.param2 = "34"; Action200.param3 = "24"; Action200.param4 = "14"; Action103.nextID = -1; Action200.timeoutID = 905;

                SubStrategy subStrategyExport1 = new SubStrategy("Export Strategy 1", 1);
                SubStrategy subStrategyExport2 = new SubStrategy("Export Strategy 2", 1);

                subStrategyExport1.AddAction(Action100); subStrategyExport1.AddAction(Action101);
                subStrategyExport2.AddAction(Action102); subStrategyExport2.AddAction(Action103); subStrategyExport2.AddAction(Action200);

                Strategy testExportStrategy = new Strategy("EXPORT_STRATEGY");
                testExportStrategy.AddSubStrategy(subStrategyExport1); testExportStrategy.AddSubStrategy(subStrategyExport2);

                testExportStrategy.Export("./Data/TestOutputStrategy.c", "./patternFiles/ImportPatternFile.spattern");
                if (true)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

                Console.WriteLine(" -> Import : ");

                Strategy testImportStrategy = new Strategy("ImportStrategy");

                testImportStrategy.Import("./Data/TestOutputStrategy.c", "./patternFiles/ImportPatternFile.spattern");
                testExportStrategy.Export("./Data/TestOutputStrategy_2.c", "./patternFiles/ImportPatternFile.spattern");
                if (true)
                {
                    Console.Write(" Ok\n");
                }
                else
                {
                    Console.Write(" Error !\n"); Validated = false;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("Test 0203 Failed !!");
                Console.WriteLine(ex.Message);
                Validated = false;
            }
            #endregion

            // Fin du programme -----------------------------------------------------------------------------
            DisplaySeparator();
            Console.Write("\nTest terminé. Etat du module : ");

            if(Validated == true)
            {
                Console.Write("Validé ! \n");
            }else
            {
                Console.Write("Invalide !\n");
            }
            Console.Read();
        }