Example #1
0
 public static void EndLesson()
 {
     BaseHelper.Go("A0");
     GlobalFlowControl.Lesson.Starting = false;
     try
     {
         Synthesizer.SetSpeed(0);
         LessonStatusHelper.Update("", null, "ended", null, null, null);
         if (_thread != null && _thread.IsAlive)
         {
             form2.CloseForm();
             if (_robotCommands != null)
             {
                 _robotCommands.StopSpeak();
             }
             if (_thread != null && _thread.IsAlive)
             {
                 _thread.Abort();
             }
         }
     }
     catch
     {
     }
 }
Example #2
0
        public static void Start(string lessonName, int startSlideNum, string voiceName)
        {
            Debug.WriteLine("Start lesson" + Directory.GetCurrentDirectory());
            GlobalFlowControl.Lesson.ResetAll();
            //UpperBodyHelper.MoveRandomlyAllMotors();
            RobotActionHelper.MoveDuringLesson();
            form2 = new LessonSpeechUI();

            form2.ShowForm();

            _lessonName    = lessonName;
            QuestionNumber = 0;

            _thread = new Thread(new ThreadStart(() =>
            {
                int endSlideNum = FileHelper.GetLessonSlidesNumber(lessonName);
                string codePath = FileHelper.BasePath + @"\" + lessonName + @"\code.pptx";
                progData        = PowerpointHelper.GetSlidesData(codePath);

                for (CurrentSlideNumber = 1; CurrentSlideNumber <= endSlideNum; CurrentSlideNumber++)
                {
                    if (CurrentSlideNumber < startSlideNum)
                    {
                        RobotProgSlide _currentProgSlide = progData[CurrentSlideNumber - 1];

                        var commands = _currentProgSlide.Commands;

                        foreach (var cmd in commands)
                        {
                            if (cmd.Type.ToLower() == "start" && cmd.Value.ToLower() == "quiz")
                            {
                                QuestionNumber++;
                            }
                        }
                    }
                    else
                    {
                        while (LessonHelper.PauseRequested)
                        {
                            Thread.Sleep(1000); // Remove busy waiting overloading
                        }

                        Debug.WriteLine("Current Slide -----------" + CurrentSlideNumber);
                        LessonStatusHelper.Update(lessonName, CurrentSlideNumber, "started", null, null, null);

                        RobotProgSlide _currentProgSlide = progData[CurrentSlideNumber - 1];
                        _robotCommands = new RobotCommands(_currentProgSlide.Commands);

                        _robotCommands.OnCommandUpdate += _robotCommands_OnCommandUpdate;
                        _robotCommands.Execute();
                    }
                }
                OnLessonEnded();
            }));
            _thread.Start();
        }
Example #3
0
 public static void ForceStop()
 {
     try
     {
         LessonStatusHelper.Update(null, null, null, null, null, null);
         if (_thread != null && _thread.IsAlive)
         {
             form2.CloseForm();
             if (_robotCommands != null)
             {
                 _robotCommands.StopSpeak();
             }
             _thread.Abort();
         }
     }
     catch
     {
     }
 }