Example #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;
        }
Example #2
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();
        }
 /// <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();
 }
        /// <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);
        }
Example #5
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();
            }
        }
Example #6
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();
        }