Ejemplo n.º 1
0
        private void _loopPlay()
        {
            // Stop whatever is driving this crazy train.
            lock (_endCheckTimer)
            {
                _endCheckTimer.Enabled = false;
            }

            TimingSource.Stop();

            //Reset our position. No need to stop the media, we will just reset its position.
            TimingSource.Position = StartTime;

            OnSequenceReStarted(new SequenceStartedEventArgs(Sequence, TimingSource, StartTime, EndTime));

            //Fire it back up again.
            TimingSource.Start();

            while (TimingSource.Position == StartTime)
            {
                Thread.Sleep(1);                 //Give the train a chance to get out of the station.
            }

            _endCheckTimer.Enabled = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Completes the generation process and restarts all the contexts that were running when the BeginGeneration method was called.
 /// </summary>
 public void EndGeneration()
 {
     TimingSource.Stop();
     VixenSystem.Elements.ClearStates();
     if (_context != null)
     {
         VixenSystem.Contexts.ReleaseContext(_context);
     }
     foreach (var runningContext in _runningContexts)
     {
         runningContext.Resume();
     }
     //restart the devices
     VixenSystem.OutputDeviceManagement.ResumeAll();
 }
Ejemplo n.º 3
0
        private void _Play(TimeSpan startTime, TimeSpan endTime)
        {
            if (IsRunning)
            {
                return;
            }
            if (Sequence == null)
            {
                return;
            }

            // Only hook the input stream during execution.
            // Hook before starting the behaviors.
            //_HookDataListener();

            // Bound the execution range.
            StartTime        = _CoerceStartTime(startTime);
            EndTime          = _CoerceEndTime(endTime);
            _IsTimedSequence = EndTime >= StartTime;

            if (StartTime == EndTime)
            {
                //We are done before we get started
                _syncContext.Post(x => _Stop(), null);
            }

            TimingSource = Sequence.GetTiming() ?? _GetDefaultTimingSource();

            _LoadMedia();

            _StartMedia();

            TimingSource.Position = StartTime;
            TimingSource.Start();

            // Start the crazy train.
            IsRunning = true;

            while (TimingSource.Position == StartTime)
            {
                Thread.Sleep(1);                 //Give the train a chance to get out of the station.
            }

            _endCheckTimer.Start();
        }
Ejemplo n.º 4
0
        private void _Resume()
        {
            if (!IsPaused)
            {
                return;
            }

            if (!_endCheckTimer.Enabled && Sequence != null)
            {
                IsPaused = false;

                TimingSource.Resume();

                _ResumeMedia();

                _endCheckTimer.Enabled = true;
            }
        }
Ejemplo n.º 5
0
        private void _Pause()
        {
            if (!IsRunning || IsPaused)
            {
                return;
            }

            if (_endCheckTimer.Enabled)
            {
                IsPaused = true;

                TimingSource.Pause();

                _PauseMedia();

                _endCheckTimer.Enabled = false;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes the generator processes to begin the data extraction
 /// </summary>
 public void BeginGeneration()
 {
     //Stop the output devices from driving the execution engine.
     VixenSystem.OutputDeviceManagement.PauseAll();
     _runningContexts = VixenSystem.Contexts.Where(x => x.IsRunning);
     foreach (var runningContext in _runningContexts)
     {
         runningContext.Pause();
     }
     _outputCount = VixenSystem.OutputControllers.GetAll().Sum(x => x.OutputCount);
     VixenSystem.Elements.ClearStates();
     //Special context to pre cache commands. We don't need all the other fancy executor or timing as we will advance it ourselves
     _context          = VixenSystem.Contexts.GetCacheCompileContext();
     _context.Sequence = Sequence;
     _context.Start();
     TimingSource.Start();
     UpdateState();
 }
Ejemplo n.º 7
0
        private void _Resume()
        {
            if (!IsPaused)
            {
                return;
            }

            if (!_endCheckTimer.IsRunning && Sequence != null)
            {
                IsPaused = false;

                TimingSource.Resume();

                _ResumeMedia();

                _endCheckTimer.Start();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Create a cache of the entire sequence command outputs
        /// </summary>
        private void _BuildSequenceCache()
        {
            //Need some hooks in here for progess....... Need to think about that.
            //Stop the output devices from driving the execution engine.
            VixenSystem.OutputDeviceManagement.PauseAll();
            IEnumerable <IContext> runningContexts = VixenSystem.Contexts.Where(x => x.IsRunning);

            foreach (var runningContext in runningContexts)
            {
                runningContext.Pause();
            }
            _outputCount = VixenSystem.OutputControllers.GetAll().Sum(x => x.OutputCount);
            VixenSystem.Elements.ClearStates();
            //Special context to pre cache commands. We don't need all the other fancy executor or timing as we will advance it ourselves
            PreCachingSequenceContext context = VixenSystem.Contexts.GetCacheCompileContext();

            context.Sequence = Sequence;
            TimingSource.Start();
            context.Start();

            while (TimingSource.Position <= Sequence.Length && IsRunning)
            {
                List <CommandOutput> commands = _UpdateState(TimingSource.Position);
                Cache.OutputStateListAggregator.AddCommands(commands);
                //Advance the timing
                TimingSource.Increment();
            }

            TimingSource.Stop();
            context.Stop();
            foreach (var runningContext in runningContexts)
            {
                runningContext.Resume();
            }

            VixenSystem.Contexts.ReleaseContext(_context);
            //restart the devices
            VixenSystem.OutputDeviceManagement.ResumeAll();
            IsRunning = false;
            //Cache is now ready to use or save.
            //cache.Save();
            // To load the cache use the following
            //ISequenceCache cache2 = SequenceService.Instance.LoadCache(cache.SequenceFilePath);
        }
Ejemplo n.º 9
0
        private void _Play(TimeSpan startTime, TimeSpan endTime)
        {
            if (IsRunning)
            {
                return;
            }
            if (Sequence == null)
            {
                return;
            }

            // Only hook the input stream during execution.
            // Hook before starting the behaviors.
            _HookDataListener();

            // Bound the execution range.
            StartTime = _CoerceStartTime(startTime);
            EndTime   = _CoerceEndTime(endTime);

            TimingSource = Sequence.GetTiming() ?? _GetDefaultTimingSource();

            _LoadMedia();

            _StartMedia();

            TimingSource.Position = StartTime;
            TimingSource.Start();

            // Start the crazy train.
            IsRunning = true;

            // Fire the first event manually because it takes a while for the timer
            // to elapse the first time.
            _CheckForNaturalEnd();

            // If there is no length, we may have been stopped as a cascading result
            // of that update.
            if (IsRunning)
            {
                _endCheckTimer.Start();
            }
        }
Ejemplo n.º 10
0
        private void _Stop()
        {
            if (!IsRunning)
            {
                return;
            }

            // Stop whatever is driving this crazy train.
            lock (_endCheckTimer) {
                _endCheckTimer.Stop(false);
            }

            // Release the hook before the behaviors are shut down so that
            // they can affect the sequence.
            //_UnhookDataListener();

            TimingSource.Stop();
            _StopMedia();

            IsRunning = false;
            IsPaused  = false;
        }
Ejemplo n.º 11
0
        private void _loopPlay()
        {
            TimingSource.Stop();
            // Stop whatever is driving this crazy train.
            lock (_endCheckTimer)
            {
                _endCheckTimer.Stop();
            }
            //Stop running to trigger events to reset the sequence
            IsRunning = false;
            //Reset our position. No need to stop the media, we will just reset its position.
            TimingSource.Position = StartTime;
            Thread.Sleep(50);             //Give everything a chance to stop before we fire it all back up again.
            //Fire it back up again.
            IsRunning = true;
            TimingSource.Start();

            while (TimingSource.Position == StartTime)
            {
                Thread.Sleep(1);                 //Give the train a chance to get out of the station.
            }

            _endCheckTimer.Start();
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets the command outputs for the current interval and then increments the timing source.
 /// </summary>
 /// <returns>Command outputs or null if there are no more intervals.</returns>
 public void NextInterval()
 {
     //Advance the timing
     TimingSource.Increment();
     UpdateState();
 }