// Performs the sequence by stepping through each frame and executing the required
        // voice synthesizer, delay, and motion actions.
        private void RunSequenceThread()
        {
            if (!servoManager.IsConnected())
            {
                ErrorLogging.AddMessage(ErrorLogging.LoggingLevel.Warning, "Servo hardware is disconnected, running sequence '" + runningSequence.name + "' in simulation mode.");
            }

            // Disable the person tracking feature while a sequence is executing.
            servoManager.PersonTrackingEnable(false);

            ErrorLogging.AddMessage(ErrorLogging.LoggingLevel.Info, "RunSequence(): sequence '" + runningSequence.name + "' started.");

            foreach (Frame frame in runningSequence.GetFrames())
            {
                // Run the speech synthesizer asynchronously. Speaks while continuing to
                // perform moves in this and subsequent frames.
                if (frame.speechString != null)
                {
                    speechSynthesizer.SpeakAsync(frame.speechString);
                }

                // Go to the relevant PPT Slide
                // perform moves in this and subsequent frames.
                if (frame.pptIndex != null)
                {
                    if (pptController.IsPptActive())
                    {
                        pptController.GoToSlide(frame.pptIndex);
                    }
                }

                // Wait for the specified amount of time.
                if (frame.delay > 0)
                {
                    Thread.Sleep((int)(frame.delay * 1000));
                }

                // Move all servos in the frame list.
                if (frame.GetServoPositions().Count > 0)
                {
                    servoManager.MoveServos(frame.GetServoPositions(), frame.timeToDestination);
                }
            }

            ErrorLogging.AddMessage(ErrorLogging.LoggingLevel.Info, "RunSequence(): sequence '" + runningSequence.name + "' completed.");

            // Re-enable the person tracking feature.
            servoManager.PersonTrackingEnable(true);

            lock (sequenceLock)
            {
                sequenceIsRunning = false;
            }
        }
Ejemplo n.º 2
0
        // Performs servo motions for the current frame, and triggers an event when motion is complete.
        private void MoveServos(object sequenceThreadData)
        {
            Frame frame = ((SequenceThreadData)sequenceThreadData).frame;

            // Move all servos in the frame list.
            if (frame.GetServoPositions().Count > 0)
            {
                servoManager.MoveServos(frame.GetServoPositions(), frame.timeToDestination);
            }

            // Signal that motion is complete.
            ((SequenceThreadData)sequenceThreadData).resetEvent.Set();
        }