Ejemplo n.º 1
0
        public Vixen2xSequenceImporterForm(string Vixen2File, Vixen.Module.IModuleDataModel staticModuleData)
        {
            InitializeComponent();

            channelMappings = new List<ChannelMapping>();

            //I think this was the correct way to implement this.
            StaticModuleData = (Vixen2xSequenceStaticData) staticModuleData;

            vixen2ImportFile = Vixen2File;

            //Add known information:
            vixen2SequenceTextBox.Text = vixen2ImportFile;

            //Go ahead and build the map for the sequence that we have.
            ParseV2SequenceData();

            //we parsed the sequence so go ahead and for now set our ChannelMappings to the parsed data
            //If the user selects one from the listbox we will make an adjustment.
            channelMappings = parsedV2Sequence.mappings;

            if (StaticModuleData.Vixen2xMappings.Count > 0) {
                LoadMaps();
            }
            else {
                mapExists = false;
                //use the profilename for now
                vixen2ToVixen3MappingTextBox.Text = parsedV2Sequence.ProfileName;
            }
        }
Ejemplo n.º 2
0
        public virtual bool Read(string filePath, Vixen.Sys.Sequence sequence)
        {
            // A sequence is a bit different because a specific instance type has
            // to be created from a module, so this method cannot create the instance.

            // A sequence's name is coupled to its file name.
            sequence.Name = Path.GetFileName(filePath);
            XElement element = Helper.LoadXml(filePath);
            Vixen.Sys.Sequence.ReadXml(element, sequence);
            return true;
        }
Ejemplo n.º 3
0
        public override void UpdateState(int chainIndex, Vixen.Commands.ICommand[] outputStates)
        {
            _outputStates = outputStates;

            if (serialPortIsValid)
            {
                if (_holdPort)
                {
                    _eventTrigger.Set();
                }
                else
                {
                    if (!_serialPort.IsOpen)
                    {
                        _serialPort.Open();
                    }
                    FireEvent();
                    _serialPort.Close();
                }
            }
        }
        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();
        }
        private void loadSequence(Vixen.Sys.ISequence sequence)
        {
            // check if it's the right type of sequence that we know how to deal with. If not, complain bitterly.
            if(sequence is TimedSequence)
                _sequence = (TimedSequence)sequence;
            else {
                throw new NotImplementedException("Cannot use sequence type with a Timed Sequence Editor");
            }

            // default the sequence to 1 minute if it's not set
            if(_sequence.Length == TimeSpan.Zero)
                _sequence.Length = _defaultSequenceTime;

            SequenceLength = _sequence.Length;

            // update our program context with this sequence
            OpenSequenceContext(sequence);

            // clear out all the old data
            loadSystemNodesToRows();

            // load the new data: get all the commands in the sequence, and make a new element for each of them.
            _effectNodeToElement = new Dictionary<EffectNode, Element>();
            foreach(EffectNode node in _sequence.SequenceData.EffectData) {
                addElementForEffectNode(node);
            }

            populateGridWithMarks();

            populateWaveformAudio();

            //Original code set modified to always be true upon loading a sequence.
            //sequenceModified();
            //This path is followed for new and existing sequences so we need to determine which we have and set modified accordingly.
            //Added logic to determine if the sequence has a filepath to set modified JU 8/1/2012.

            _SetTimingToolStripEnabledState();

            if(String.IsNullOrEmpty(_sequence.FilePath)) {
                sequenceModified();
            } else {
                sequenceNotModified();
            }
        }
Ejemplo n.º 6
0
        private void SequenceNotify(Vixen.Export.ExportNotifyType notifyType)
        {
            _currentState = notifyType;
            switch(notifyType)
            {
                case ExportNotifyType.NETSAVE:
                {
                    SequenceNetSave();
                    break;
                }

                case ExportNotifyType.LOADING:
                {
                    SequenceLoading();
                    break;
                }

                case ExportNotifyType.SAVING:
                {
                    SequenceSaving();
                    break;
                }

                case ExportNotifyType.EXPORTING:
                {
                    SequenceExporting();
                    break;
                }

                case ExportNotifyType.COMPLETE:
                {
                    SequenceEnded();
                    break;
                }

                default:
                {
                    break;
                }
            }
        }
Ejemplo n.º 7
0
 void SequenceCacheStarted(object sender, Vixen.Cache.Event.CacheStartedEventArgs e)
 {
     SavePosition = 0;
     if (SequenceNotify != null)
     {
         SequenceNotify(ExportNotifyType.LOADING);
     }
 }
Ejemplo n.º 8
0
        void SequenceCacheEnded(object sender, Vixen.Cache.Event.CacheEventArgs e)
        {
            SequenceSessionData sessionData = new SequenceSessionData();

            if (_exporting)
            {
                List<ICommand> commandList = new List<ICommand>();
                OutputStateListAggregator outAggregator = _preCachingSequenceEngine.Cache.OutputStateListAggregator;
                IEnumerable<Guid> outIds = outAggregator.GetOutputIds();
                int periods = outAggregator.GetCommandsForOutput(outIds.First()).Count() - 1;

                //Get a list of controller ids by index order
                IEnumerable<Guid> controllers = ControllerExportInfo.OrderBy(x => x.Index).Select(i => i.Id);

                //Now assemble a all their outputs by controller order.
                List<List<Guid>> controllerOutputs = new List<List<Guid>>();
                foreach (var controller in controllers)
                {
                    controllerOutputs.Add(VixenSystem.OutputControllers.GetController(controller).Outputs.Select(x => x.Id).ToList());
                }

                if (_cancelling == false)
                {
                    SequenceNotify(ExportNotifyType.SAVING);
                    sessionData.OutFileName = OutFileName;
                    sessionData.NumPeriods = periods;
                    sessionData.PeriodMS = UpdateInterval;
                    sessionData.ChannelNames = BuildChannelNames(outIds);
                    sessionData.TimeMS = _preCachingSequenceEngine.Sequence.Length.TotalMilliseconds;
                    sessionData.AudioFileName = AudioFilename;
                    try
                    {
                        _output.OpenSession(sessionData);
                        for (int j = 0; j < periods; j++)
                        {
                            SavePosition = Decimal.Round(((Decimal)j / (Decimal)periods) * 100, 2);
                            commandList.Clear();
                            //Iterate the controller output groups.
                            foreach (var controller in controllerOutputs)
                            {
                                //Grab commands for each output
                                foreach (Guid guid in controller)
                                {
                                    commandList.Add(outAggregator.GetCommandsForOutput(guid).ElementAt(j));
                                }

                            }

                            UpdateState(commandList.ToArray());
                        }

                        _output.CloseSession();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Save Error!");
                        throw ex;
                    }

                    _preCachingSequenceEngine.SequenceCacheEnded -= SequenceCacheEnded;
                    _preCachingSequenceEngine.SequenceCacheStarted -= SequenceCacheStarted;
                }

                if (SequenceNotify != null)
                {
                    SequenceNotify(ExportNotifyType.COMPLETE);
                }
            }
        }
Ejemplo n.º 9
0
        private void loadSequence(Vixen.Sys.ISequence sequence)
        {
            var taskQueue = new Queue<Task>();

            if (loadTimer == null) {
                loadTimer = new System.Timers.Timer();
                loadTimer.Elapsed += loadTimer_Elapsed;
                loadTimer.Interval = 250;
            }
            loadingWatch = Stopwatch.StartNew();
            loadTimer.Enabled = true;
            TimelineControl.SequenceLoading = true;

            // Let's get the window on the screen. Make it appear to instantly load.
            Invalidate(true);
            Update();

            try {
                // default the sequence to 1 minute if it's not set
                if (_sequence.Length == TimeSpan.Zero)
                    _sequence.Length = _defaultSequenceTime;

                SequenceLength = _sequence.Length;

                // update our program context with this sequence
                OpenSequenceContext(sequence);

                // clear out all the old data
                loadSystemNodesToRows();

                // load the new data: get all the commands in the sequence, and make a new element for each of them.
                _effectNodeToElement = new Dictionary<EffectNode, Element>();

                TimelineControl.grid.SuppressInvalidate = true; //Hold off invalidating the grid while we bulk load.
                TimelineControl.grid.SupressRendering = true; //Hold off rendering while we load elements.
                // This takes quite a bit of time so queue it up
                taskQueue.Enqueue(Task.Factory.StartNew(() =>
                                                            {
                                                                addElementsForEffectNodes(_sequence.SequenceData.EffectData);
                                                            }));
                // Now that it is queued up, let 'er rip and start background rendering when complete.
                Task.Factory.ContinueWhenAll(taskQueue.ToArray(), completedTasks =>
                                                                  	{
                                                                  		// Clear the loading toolbar
                                                                  		loadingWatch.Stop();
                                                                  		TimelineControl.SequenceLoading = false;
                                                                  		loadTimer.Enabled = false;
                                                                  		updateToolStrip4(string.Empty);
                                                                        TimelineControl.grid.SupressRendering = false;
                                                                        TimelineControl.grid.SuppressInvalidate = false;
                                                                  		TimelineControl.grid.RenderAllRows();
                                                                  	});

                populateGridWithMarks();

                var t2 = Task.Factory.StartNew(() => populateWaveformAudio());

                //This path is followed for new and existing sequences so we need to determine which we have and set modified accordingly.
                //Added logic to determine if the sequence has a filepath to set modified JU 8/1/2012.

                _SetTimingToolStripEnabledState();

                if (String.IsNullOrEmpty(_sequence.FilePath)) {
                    sequenceModified();
                }
                else {
                    sequenceNotModified();
                }
                PopulateAudioDropdown();

                MarksForm.Sequence = Sequence as TimedSequence;
                MarksForm.PopulateMarkCollectionsList(null);

                Logging.Debug(string.Format("Sequence {0} took {1} to load. ", sequence.Name, loadingWatch.Elapsed));
            }
            catch (Exception ee) {
                Logging.ErrorException("Error loading sequence.", ee);
            }
        }
Ejemplo n.º 10
0
 public void Write(string filePath, Vixen.Sys.Sequence sequence)
 {
     // A sequence's name is coupled to its file name.
     sequence.Name = Path.GetFileName(filePath);
     Vixen.Sys.Sequence.WriteXml(sequence).Save(filePath);
 }
Ejemplo n.º 11
0
        public override void UpdateState(int chainIndex, Vixen.Commands.ICommand[] outputStates)
        {
            if (_sequenceStarted & sw.ElapsedMilliseconds >=25 & _myconductordata.savedata)
            {
                modmill = sw.ElapsedMilliseconds;

                if (modmill >= 50)
                {
                    selfheal = selfheal + (50 - modmill);
                    moddelay = 50;
                }
                else if (selfheal < 0)
                {
                    if ((modmill - 50) < selfheal)
                    {
                        moddelay = 50 + selfheal;
                        selfheal = 0;
                    }
                    else
                    {
                        moddelay = 50 + (modmill - 50);
                        selfheal = selfheal - (modmill - 50);
                    }
                }
                else
                {
                    moddelay = 50;
                }

                while ((sw.ElapsedMilliseconds <  moddelay) & (modmill < 50))
                {

                }

                curmill = sw.ElapsedMilliseconds;
                if ((curmill > 50) & (modmill <= 50))
                {
                    selfheal = selfheal + (50 - curmill);
                }

                sw.Reset();
                sw.Start();

                // zero out array (there has to be a better way of doing this)

                for (int i = 0; i < 16384; i++)
                {
                    mybuffer[i] = 0;
                }

                int ii = 0;

                // get the channel intensities from the system and put them in the mybuffer array
                //  we do not put them directly into the bytes array, since we have to do some post
                //  processing to get them in the correct order for the Conductor file

                foreach (ICommand command in outputStates)
                {
                    if (command == null)
                    {
                    }
                    else if (command is _8BitCommand)
                    {
                        mybuffer[ii] = (command as _8BitCommand).CommandValue;
                    }

                    ii++;
                }

                // put the buffered data into the correct sequence and in the right type (type of byte)
                // so we can write the binary file.

                for(int i=0; i < 4096 ;i++)
             			{
                    bytes[(i*4)] = Convert.ToByte(mybuffer[i]);
                    bytes[(i*4) + 1] = Convert.ToByte(mybuffer[i + 4096]);
                    bytes[(i*4) + 2] = Convert.ToByte(mybuffer[i + 8192]);
                    bytes[(i*4) + 3] = Convert.ToByte(mybuffer[i + 12288]);
                }

                // write the 16384 bytes to the binary file.  The entire song could be kept in the array
                // until the sequence is done and then write the whole array at once.  As it stands, the
                // write finishes in less than a millisecond, so speed is not of the essence, but should be
                // considered, since older computers may not be able to keep up.

                // each second of sequence will consume 327680 bytes or 320KB.  Therefore a minute will consume
                // 19660800 bytes or 18.75MB of memory per minute of sequence.  The average song is less than 5
                // minutes, so a 5 minute sequence will consume 93.75MB of memory.  This is within the
                // constraints of modern computers.

                if (curmill == 50)
                {
                    intervaldata[intervalcount] = intervalcount.ToString() + " , " + modmill.ToString() + " , " + curmill.ToString() + " , " + selfheal.ToString() + " , " + moddelay.ToString();
                }
                else
                {
                    intervaldata[intervalcount] = intervalcount.ToString() + " , " + modmill.ToString() + " , " + curmill.ToString() + " , " + selfheal.ToString() + " , " + moddelay.ToString() + "<---*-*-*-*-*-*-*-*-*-*-*-*-*";
                }

                intervalcount += 1;

                bw.Write(bytes);
            }
        }