/// <summary>
        /// Timer of launching operations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpTimer_Tick(object sender, EventArgs e)
        {
            //according to the operation to be executed
            switch (operation)
            {
            case ProcessOperation.Check:
                //The errors of all the diagrams are checked
                List <DiagramError> errors = new List <DiagramError>();
                foreach (Diagram diagram in this.project.Functions)
                {
                    Generator.CheckDiagram(diagram, errors);
                }
                //If there are errors, it is reported
                if (errors.Count != 0)
                {
                    bool onlyWarnings = false;
                    //the errors are checked
                    foreach (DiagramError error in errors)
                    {
                        //If any of the errors is not a warning
                        if (error.Type == ErrorType.Error)
                        {
                            onlyWarnings         = true;
                            this.opTimer.Enabled = false;
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbCheckDiagram.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lCheckDiagram.Text      = ProcessMessages.CHECKDIAGRAM_ERROR;
                            this.lCheckDiagram.ForeColor = Color.FromArgb(208, 0, 0);
                            break;
                        }
                    }
                    //If they are only warnings
                    if (!onlyWarnings)
                    {
                        //The warning message is displayed
                        this.pbCheckDiagram.Image    = this.icons.Images[(int)OperationState.Warning];
                        this.lCheckDiagram.Text      = ProcessMessages.CHECKDIAGRAM_WARNING;
                        this.lCheckDiagram.ForeColor = Color.FromArgb(200, 140, 0);
                        //it passes to the following operation
                        this.operation            = ProcessOperation.Generate;
                        this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running];
                    }
                    //The error event is launched
                    if (this.DiagramErrors != null)
                    {
                        this.DiagramErrors(this, new ProcessEventArgs(errors));
                    }
                }
                else
                {
                    this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Finish];
                    this.lCheckDiagram.Text   = ProcessMessages.CHECKDIAGRAM_OK;
                    //it passes to the following operation
                    this.operation            = ProcessOperation.Generate;
                    this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running];
                }
                break;

            case ProcessOperation.Generate:
                //Generates the source code for the diagrams
                try
                {
                    // The code is generated
                    AsmGenerator.GenerateCode(this.project.MainFunction, this.project.Subfunctions, this.project.Variables, this.project.AsmFile);
                    this.lGenerateCode.Text   = ProcessMessages.GENERATECODE_OK;
                    this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Finish];
                    //it passes to the following operation
                    this.operation           = ProcessOperation.Compile;
                    this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Running];
                }
                catch { }
                break;

            case ProcessOperation.Compile:
                //The generated source code is compiled
                try
                {
                    //The project is compiled
                    if (AsmCompiler.Compile(this.project.AsmFile))
                    {
                        this.lCompileCode.Text   = ProcessMessages.COMPILECODE_OK;
                        this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Finish];
                        //it passes to the following operation
                        this.operation            = ProcessOperation.Program;
                        this.opTimer.Interval     = 50;
                        this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Running];
                    }
                    else
                    {
                        this.opTimer.Enabled = false;
                        //The Close button is enabled
                        this.bClose.Enabled = true;
                        //The error is displayed
                        this.pbCompileCode.Image    = this.icons.Images[(int)OperationState.Error];
                        this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0);
                        this.lCompileCode.Text      = ProcessMessages.COMPILECODE_ERROR;
                    }
                }
                //Code compilation failed
                catch (CompilerException ex)
                {
                    this.opTimer.Enabled = false;
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.pbCompileCode.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lCompileCode.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Access denied":
                        this.lCompileCode.Text = ProcessMessages.ACCES_DENIED;
                        break;

                    default:
                        this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Program:
                //Launches the recording process
                this.opTimer.Enabled = false;
                //MOway Driver events are logged
                Controller.Controller mController = Controller.Controller.GetController();
                mController.ProgrammingProgress  += new ProgressEventHandler(MController_ProgrammingProgress);
                mController.ProgrammingCompleted += new EventHandler(MController_ProgrammingCompleted);
                mController.ProgrammingCanceled  += new EventHandler(MController_ProgrammingCanceled);
                try
                {
                    //It checks the memory of the micro...
                    int response = mController.CheckPicMemory(this.project.HexFile);
                    if (response == 1)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_201 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    else if (response == 2)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_202 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    //Timer is enabled to limit the recording process to 15 seconds
                    this.tProgramLimited.Enabled = true;
                    //It launches the recording of the mOway
                    mController.ProgramMoway(this.project.HexFile);
                }
                //Timer is enabled to limit the recording process to 15 seconds
                catch (ControllerException ex)
                {
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lProgramMoway.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Moway disconnected":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_DISCONNECTED;
                        break;

                    case "Moway busy":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_BUSY;
                        break;

                    default:
                        this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Close:
                //Close the form
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;
            }
        }
        /// <summary>
        /// Timer of launching operations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpTimer_Tick(object sender, EventArgs e)
        {
            //According to the operation to run
            switch (operation)
            {
            case ProcessOperation.Program:
                //launches the process of recording
                this.opTimer.Enabled = false;
                //the driver of the mOway events are logged
                Controller.Controller mController = Controller.Controller.GetController();
                mController.ProgrammingProgress  += new ProgressEventHandler(MController_ProgrammingProgress);
                mController.ProgrammingCompleted += new EventHandler(MController_ProgrammingCompleted);
                mController.ProgrammingCanceled  += new EventHandler(MController_ProgrammingCanceled);
                try
                {
                    //checks the memory of the micro...
                    int response = mController.CheckPicMemory(this.hexFile);
                    if (response == 1)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_201 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    else if (response == 2)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_202 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    //It enables the timer which is limited to 15 seconds the recording process
                    this.tProgramLimited.Enabled = true;
                    //the mOway recording is released
                    mController.ProgramMoway(this.hexFile);
                }
                //error in the launch of the recording process
                catch (ControllerException ex)
                {
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.bClose.Enabled          = true;
                    this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lProgramMoway.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Moway disconnected":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_DISCONNECTED;
                        break;

                    case "Moway busy":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_BUSY;
                        break;

                    default:
                        this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Close:
                //close the form
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;
            }
        }