/// <summary> /// The optional next step to run /// </summary> /// <param name="context"></param> /// <returns></returns> protected async Task Next(ISequenceContext context) { if (NextStep != null) { await NextStep.RunAsync(context); } }
public override void PreProcess(CancellationTokenSource cancellationTokenSource = null) { if (cancellationTokenSource != null) { CancellationTknSource = cancellationTokenSource; } try { if (_sequenceContext == null || SequenceChanged() || _sequence == null) { if (_sequenceContext != null) { DisposeCurrentContext(); } var entry = SequenceManager.GetSequenceAsync(ShowItem.SequencePath); entry.Wait(); var sequenceEntry = entry.Result; if (sequenceEntry == null) { Logging.Error("Failed to preprocess sequence {1} because it could not be loaded.", ShowItem.Name); return; } //Give up to 30 seconds for the sequence to load. int retryCount = 0; while (sequenceEntry.SequenceLoading && retryCount < 30) { retryCount++; Logging.Info("Waiting for sequence to load. {1}", ShowItem.Name); Thread.Sleep(1); } if (sequenceEntry.Sequence == null) { Logging.Error("Failed to preprocess sequence {1} because it could not be loaded.", ShowItem.Name); return; } _sequence = sequenceEntry.Sequence; //Initialize the media if we have it so any audio effects can be rendered LoadMedia(); ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), _sequence); Parallel.ForEach(_sequence.SequenceData.EffectData.Cast <IEffectNode>(), RenderEffect); context.SequenceEnded += sequence_Ended; _sequenceContext = context; } PreProcessingCompleted = true; } catch (Exception ex) { Logging.Error("Could not pre-render sequence " + ShowItem.SequencePath + "; ", ex); } }
private void _Execute(TimeSpan startTime, TimeSpan endTime) { _CommitChanges(); Cursor = Cursors.WaitCursor; try { listBoxRuntimeErrors.Items.Clear(); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), Sequence); if (_context == null) { MessageBox.Show(this, "Unable to play this sequence. See error log for details.", "Script Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } _context.SequenceEnded += _context_SequenceEnded; _context.Message += _context_Message; _context.Error += _context_Error; _context.Play(startTime, endTime); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Cursor = Cursors.Default; } }
private void _context_SequenceEnded(object sender, SequenceEventArgs e) { _context.Error -= _context_Error; _context.Message -= _context_Message; _context.SequenceEnded -= _context_SequenceEnded; VixenSystem.Contexts.ReleaseContext(_context); _context = null; }
public override async Task RunAsync(ISequenceContext context) { await _asyncFunc(context, async sequenceContext => { await Next(sequenceContext); }); await Task.FromResult(0); }
protected override void Dispose(bool disposing) { if (disposing) { DisposeCurrentContext(); } _sequence = null; _sequenceContext = null; base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { DisposeCurrentContext(); } SequenceManager.ConsumerFinished(ShowItem.SequencePath); _sequenceContext = null; base.Dispose(disposing); }
/// <summary> /// Play a sequence of a given file name. /// </summary> /// <param name="sequence"></param> /// <returns></returns> public static ContextStatus PlaySequence(Sequence sequence) { var status = new ContextStatus(); if (sequence == null) { throw new ArgumentNullException("sequence"); } IEnumerable <IContext> contexts = VixenSystem.Contexts.Where(x => x.Name.Equals(sequence.Name) && (x.IsRunning || x.IsPaused)); if (contexts.Any(x => x.IsPaused)) { foreach (var context in contexts) { if (context.IsPaused) { context.Resume(); } } status.Message = string.Format("Resumed {0}", sequence.Name); } else { string fileName = HttpUtility.UrlDecode(sequence.FileName); ISequence seq = SequenceService.Instance.Load(fileName); if (seq != null) { Logging.Info(string.Format("Web - Prerendering effects for sequence: {0}", sequence.Name)); Parallel.ForEach(seq.SequenceData.EffectData.Cast <IEffectNode>(), effectNode => effectNode.Effect.PreRender()); ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext( new ContextFeatures(ContextCaching.NoCaching), seq); context.ContextEnded += context_ContextEnded; context.Play(TimeSpan.Zero, seq.Length); status.State = ContextStatus.States.Playing; status.Sequence = new Sequence() { Name = context.Sequence.Name, FileName = fileName }; status.Message = string.Format("Playing sequence {0} of length {1}", sequence.Name, seq.Length); } else { status.Message = string.Format("Sequence {0} not found.", fileName); } } return(status); }
private void DisposeCurrentContext() { _sequenceContext.SequenceEnded -= sequence_Ended; VixenSystem.Contexts.ReleaseContext(_sequenceContext); _sequenceContext.Dispose(); TimedSequence tSequence = (sequence as TimedSequence); tSequence.Dispose(); sequence = null; _sequenceContext = null; }
public ISequenceContext CreateSequenceContext(ContextFeatures contextFeatures, ISequence sequence) { ISequenceExecutor executor = Vixen.Services.SequenceTypeService.Instance.CreateSequenceExecutor(sequence); ISequenceContext context = (ISequenceContext)_CreateContext(ContextTargetType.Sequence, contextFeatures); if (executor != null && context != null) { context.Executor = executor; context.Sequence = sequence; _AddContext(context); } return(context); }
public ISequenceContext CreateSequenceContext(ContextFeatures contextFeatures, ISequence sequence) { ISequenceExecutor executor = Vixen.Services.SequenceTypeService.Instance.CreateSequenceExecutor(sequence); ISequenceContext context = (ISequenceContext)_CreateContext(ContextTargetType.Sequence, contextFeatures); if (executor != null && context != null) { context.Executor = executor; context.Sequence = sequence; _AddContext(context); } VixenSystem.Instrumentation.AddValue(_contextUpdateTimeValue); return(context); }
public override void PreProcess(CancellationTokenSource cancellationTokenSource = null) { if (cancellationTokenSource != null) { CancellationTknSource = cancellationTokenSource; } try { //Console.WriteLine("PreProcess: " + ShowItem.Name + " : " + (_sequenceContext == null)); if (_sequenceContext == null || SequenceChanged()) { if (_sequenceContext != null) { DisposeCurrentContext(); } _sequence = SequenceService.Instance.Load(ShowItem.Sequence_FileName); //Initialize the media if we have it so any audio effects can be rendered LoadMedia(); // Why doesn't this work? //IContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.ContextLevelCaching), sequence); ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), _sequence); // Parallel doesn't work here. Causes multiple sequences to be run at the same time //foreach (IEffectNode effectNode in sequence.SequenceData.EffectData.Cast<IEffectNode>()) Parallel.ForEach(_sequence.SequenceData.EffectData.Cast <IEffectNode>(), RenderEffect); context.SequenceEnded += sequence_Ended; _sequenceContext = context; } PreProcessingCompleted = true; } catch (Exception ex) { Logging.ErrorException("Could not pre-render sequence " + ShowItem.Sequence_FileName + "; ", ex); } }
private void PlaySequence(HttpRequestHead request, IHttpResponseDelegate response) { HttpResponseHead headers; var status = new Status(); NameValueCollection parms = GetParameters(request); if (!parms.HasKeys() && parms["name"] != null) { headers = GetHeaders(0, HttpStatusCode.BadRequest.ToString()); response.OnResponse(headers, new BufferedProducer("")); return; } string fileName = HttpUtility.UrlDecode(parms["name"]); if (_context != null && (_context.IsRunning)) { status.Message = string.Format("Already playing {0}", _context.Sequence.Name); } else { ISequence sequence = SequenceService.Instance.Load(fileName); if (sequence == null) { headers = GetOkHeaders(0); headers.Status = HttpStatusCode.NotFound.ToString(); response.OnResponse(headers, new BufferedProducer("")); return; } Logging.Info(string.Format("Web - Prerendering effects for sequence: {0}", sequence.Name)); Parallel.ForEach(sequence.SequenceData.EffectData.Cast <IEffectNode>(), effectNode => effectNode.Effect.PreRender()); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), sequence); _context.ContextEnded += context_ContextEnded; _context.Play(TimeSpan.Zero, sequence.Length); status.Message = string.Format("Playing sequence {0} of length {1}", sequence.Name, sequence.Length); } SerializeResponse(status, response); }
public override async Task RunAsync(ISequenceContext context) { context.Data.Add(_key, _value); await Next(context); }
public override void PreProcess(CancellationTokenSource cancellationTokenSource = null) { if (cancellationTokenSource != null) CancellationTknSource = cancellationTokenSource; try { //Console.WriteLine("PreProcess: " + ShowItem.Name + " : " + (_sequenceContext == null)); if (_sequenceContext == null || SequenceChanged()) { if (_sequenceContext != null) { DisposeCurrentContext(); } sequence = SequenceService.Instance.Load(ShowItem.Sequence_FileName); // Why doesn't this work? //IContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.ContextLevelCaching), sequence); ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), sequence); // Parallel doesn't work here. Causes multiple sequences to be run at the same time //foreach (IEffectNode effectNode in sequence.SequenceData.EffectData.Cast<IEffectNode>()) Parallel.ForEach(sequence.SequenceData.EffectData.Cast<IEffectNode>(), effectNode => effectNode.Effect.PreRender()); context.SequenceEnded += sequence_Ended; _sequenceContext = context; } PreProcessingCompleted = true; } catch (Exception ex) { Logging.Error("Could not pre-render sequence " + ShowItem.Sequence_FileName + "; " + ex.Message); } }
private void DisposeCurrentContext() { _sequenceContext.SequenceEnded -= sequence_Ended; VixenSystem.Contexts.ReleaseContext(_sequenceContext); _sequenceContext.Dispose(); TimedSequence tSequence = (sequence as TimedSequence); tSequence.Dispose(); sequence = null; _sequenceContext = null; }
private void OpenSequenceContext(ISequence sequence) { if (_context != null) { CloseSequenceContext(); } //_context = (ProgramContext)VixenSystem.Contexts.CreateContext(Sequence); //_context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.ContextLevelCaching), Sequence); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), Sequence); if (_context == null) { Logging.Error(@"Null context when attempting to play sequence."); MessageBox.Show(@"Unable to play this sequence. See error log for details."); return; } TimelineControl.grid.Context = _context; _context.SequenceStarted += context_SequenceStarted; _context.SequenceEnded += context_SequenceEnded; //_context.ProgramEnded += _context_ProgramEnded; _context.ContextEnded += context_ContextEnded; updateButtonStates(); }
private void OnExecutionStateChanged(object sender, EventArgs e) { Console.WriteLine("tse: state changed: " + Execution.State); if (Execution.State.Equals("Closing")) { if (_context != null) CloseSequenceContext(); _context = null; } else if (Execution.State.Equals("Open")) { OpenSequenceContext(_sequence); } }
private void _Execute(TimeSpan startTime, TimeSpan endTime) { _CommitChanges(); Cursor = Cursors.WaitCursor; try { listBoxRuntimeErrors.Items.Clear(); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), Sequence); if (_context == null) { MessageBox.Show(this, "Unable to play this sequence. See error log for details.", "Script Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } _context.SequenceEnded += _context_SequenceEnded; _context.Message += _context_Message; _context.Error += _context_Error; _context.Play(startTime, endTime); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Cursor = Cursors.Default; } }
private void _context_SequenceEnded(object sender, SequenceEventArgs e) { _context.Error -= _context_Error; _context.Message -= _context_Message; _context.SequenceEnded -= _context_SequenceEnded; VixenSystem.Contexts.ReleaseContext(_context); _context = null; }
private void OpenSequenceContext(ISequence sequence) { if (_context != null) { CloseSequenceContext(); } //_context = (ProgramContext)VixenSystem.Contexts.CreateContext(Sequence); //_context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.ContextLevelCaching), Sequence); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), Sequence); if (_context == null) { Logging.Error(@"TimedSequenceEditor: <OpenSequenceContext> - null _context when attempting to play sequence!"); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Unable to play this sequence. See error log for details.", @"Unable to Play", false, false); messageBox.ShowDialog(); return; } TimelineControl.grid.Context = _context; _context.SequenceStarted += context_SequenceStarted; _context.SequenceEnded += context_SequenceEnded; //_context.ProgramEnded += _context_ProgramEnded; _context.ContextEnded += context_ContextEnded; UpdateButtonStates(); }
protected override void Dispose(bool disposing) { if (disposing) { DisposeCurrentContext(); } SequenceManager.ConsumerFinished(ShowItem.Sequence_FileName); _sequenceContext = null; base.Dispose(disposing); }
internal Sequence(ISequenceReader stepReader, ISequenceContext context) { _stepReader = stepReader; _context = context; }
public override async Task RunAsync(ISequenceContext context) { await Next(context); }
/// <summary> /// Run an individual step. /// </summary> /// <param name="context"></param> /// <returns></returns> public abstract Task RunAsync(ISequenceContext context);
protected override void Dispose(bool disposing) { if (disposing) { DisposeCurrentContext(); } sequence = null; _sequenceContext = null; base.Dispose(disposing); }
public override async Task RunAsync(ISequenceContext context) { await Task.FromResult(0); throw new InvalidOperationException(); }
private void OpenSequenceContext(Vixen.Sys.ISequence sequence) { if(_context != null) { CloseSequenceContext(); } //_context = (ProgramContext)VixenSystem.Contexts.CreateContext(Sequence); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.ContextLevelCaching), Sequence); if(_context == null) { MessageBox.Show("Unable to play this sequence. See error log for details."); return; } _context.SequenceStarted += context_SequenceStarted; _context.SequenceEnded += context_SequenceEnded; //_context.ProgramEnded += _context_ProgramEnded; _context.ContextEnded += context_ContextEnded; updateButtonStates(); }
public override void PreProcess(CancellationTokenSource cancellationTokenSource = null) { if (cancellationTokenSource != null) CancellationTknSource = cancellationTokenSource; try { if (_sequenceContext == null || SequenceChanged() || _sequence == null) { if (_sequenceContext != null) { DisposeCurrentContext(); } var entry = SequenceManager.GetSequenceAsync(ShowItem.Sequence_FileName); entry.Wait(); var sequenceEntry = entry.Result; if (sequenceEntry == null) { Logging.Error("Failed to preprocess sequence {1} because it could not be loaded.", ShowItem.Name); return; } //Give up to 30 seconds for the sequence to load. int retryCount = 0; while (sequenceEntry.SequenceLoading && retryCount<30) { retryCount++; Logging.Info("Waiting for sequence to load. {1}", ShowItem.Name); Thread.Sleep(1); } if (sequenceEntry.Sequence == null) { Logging.Error("Failed to preprocess sequence {1} because it could not be loaded.", ShowItem.Name); return; } _sequence = sequenceEntry.Sequence; //Initialize the media if we have it so any audio effects can be rendered LoadMedia(); ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), _sequence); Parallel.ForEach(_sequence.SequenceData.EffectData.Cast<IEffectNode>(), RenderEffect); context.SequenceEnded += sequence_Ended; _sequenceContext = context; } PreProcessingCompleted = true; } catch (Exception ex) { Logging.Error("Could not pre-render sequence " + ShowItem.Sequence_FileName + "; ",ex); } }
private void PlaySequence(HttpRequestHead request, IHttpResponseDelegate response) { HttpResponseHead headers; var status = new Status(); NameValueCollection parms = GetParameters(request); if(!parms.HasKeys() && parms["name"] != null) { headers = GetHeaders(0, HttpStatusCode.BadRequest.ToString()); response.OnResponse(headers,new BufferedProducer("")); return; } string fileName = HttpUtility.UrlDecode(parms["name"]); if (_context != null && (_context.IsRunning)) { status.Message = string.Format("Already playing {0}", _context.Sequence.Name); } else { ISequence sequence = SequenceService.Instance.Load(fileName); if (sequence == null) { headers = GetOkHeaders(0); headers.Status = HttpStatusCode.NotFound.ToString(); response.OnResponse(headers, new BufferedProducer("")); return; } Logging.Info(string.Format("Web - Prerendering effects for sequence: {0}", sequence.Name)); Parallel.ForEach(sequence.SequenceData.EffectData.Cast<IEffectNode>(), effectNode => effectNode.Effect.PreRender()); _context = VixenSystem.Contexts.CreateSequenceContext(new ContextFeatures(ContextCaching.NoCaching), sequence); _context.ContextEnded += context_ContextEnded; _context.Play(TimeSpan.Zero, sequence.Length); status.Message = string.Format("Playing sequence {0} of length {1}", sequence.Name, sequence.Length); } SerializeResponse(status,response); }