예제 #1
0
        public void Setup()
        {
            ResetEvent     = new ManualResetEvent(true);
            random         = new Random();
            faceController = new FaceController("COM11", 115200);
            m             = new Mouth("Microsoft David Desktop");
            eyeController = new EyeController();
            reader        = new reader();
            interpreter   = new Interpreter();

            keys        = reader.ReadKeys();
            oWM         = new OWMCurrent(keys[1]);
            oWMForecast = new OWMForecast(keys[1]);
            NewsAPI     = new NewsApiTop(keys[0]);


            ThreadStart eyethread  = new ThreadStart(processEyes);
            ThreadStart portwriter = new ThreadStart(writeData);

            //ThreadStart main = new ThreadStart(MainLoop);
            Eyes = eyeController.Eyes;
            m.MouthPosChanged         += mouthEventHandler;
            eyeController.EyesChanged += writeEyevals;
            faceController.POST();

            // start them

            Thread writerThread = new Thread(portwriter);
            //Thread interfaceThread = new Thread(main);
            Thread Eyethread = new Thread(eyethread);

            writerThread.Start();
            Thread.Sleep(3000);
            //interfaceThread.Start();
            Eyethread.Start();
        }
예제 #2
0
 private void speakWeather(Mouth mouth, Interpreter interpreter, OWMForecast oWMForecast, OWMCurrent oWM)
 {
     try
     {
         ForecastData fc       = oWMForecast.ForeCastWeahterData("cvk.jk5", "GB", "Coventry", 2);
         var          returned = oWM.GetCurrent("cv5", "GB", "Coventry", 2);
         mouth.speakMsg(string.Format(interpreter.CurrentSummary(returned)));
         mouth.speakMsg(interpreter.ForecastSummary(fc));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }