Ejemplo n.º 1
0
        public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
        {
//			Logging.Info("SWaitingToStart::processEvent - Entry");
            do
            {
                // save the starting values
                parent.CurrentColor       = color;
                parent.StartingIntensity  = intensity;
                parent.CurrentIntensity   = intensity;
                parent.StartEventPosition = position;
                parent.EndEventPosition   = position;

                // we ignore events that are close to black
                if (5 > intensity)
                {
                    // dont bother
                    parent.StateMachine = parent.WaitingToStart;
                    break;
                }

                // next state Wait for a scond event to arrive
                parent.StateMachine = parent.HoldingOneEvent;
            } while (false);
//			Logging.Info("SWaitingToStart::processEvent - Exit");
        }         // processEvent
Ejemplo n.º 2
0
        public void closeChannel(Vixen2xSequenceImportSM parent)
        {
            // save the data
            EffectNode node = parent.GenerateSetLevelEffect(parent.CurrentIntensity, parent.StartEventPosition, parent.EndEventPosition, parent.TargetNode, parent.CurrentColor);
            if (node != null)
            {
                parent.Sequence.InsertData(node);
            }

            // set back to the waiting for the channel to open
            parent.StateMachine = parent.IgnoreEvents;
        }
Ejemplo n.º 3
0
        }         // processEvent

        public void closeChannel(Vixen2xSequenceImportSM parent)
        {
            // save the data
            EffectNode node = parent.GeneratePulseEffect(parent.StartingIntensity, parent.CurrentIntensity, parent.StartEventPosition, parent.EndEventPosition, parent.TargetNode, parent.CurrentColor);

            if (node != null)
            {
                parent.Sequence.InsertData(node);
            }

            // set back to the waiting for the channel to open
            parent.StateMachine = parent.IgnoreEvents;
        } // closeChannel
Ejemplo n.º 4
0
        public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
        {
            // is the intensity and color the same as it was?
            if ((parent.CurrentColor == color) && (parent.CurrentIntensity == intensity))
            {
                // we are in a block of similar events
                parent.StateMachine = parent.SingleIntensityMultipleEvents;

                // update the current end position
                parent.EndEventPosition = position;
            }
            else
            {
                // something has changed. Write out the current data and start a new block
                closeChannel(parent);
                parent.StateMachine = parent.WaitingToStart;
                parent.processEvent(position, color, intensity);
            }
        }         // processEvent
Ejemplo n.º 5
0
        public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
        {
            // is the intensity and color the same as it was?
            if ((parent.CurrentColor == color) && (parent.CurrentIntensity == intensity))
            {
                // we are in a block of similar events
                parent.StateMachine = parent.SingleIntensityMultipleEvents;

                // update the current end position
                parent.EndEventPosition = position;
            }
            // is the intensity and color the same as it was?
            else if ((parent.CurrentColor == color) && (parent.CurrentIntensity < intensity))
            {
                // we are in a block of increasing intensity events
                parent.StateMachine = parent.RampUp;

                // update the current end position
                parent.EndEventPosition = position;
                parent.CurrentIntensity = intensity;
            }
            // is the intensity and color the same as it was?
            else if ((parent.CurrentColor == color) && (parent.CurrentIntensity > intensity) && (5 < intensity))
            {
                // we are in a block of increasing intensity events
                parent.StateMachine = parent.RampDown;

                // update the current end position
                parent.EndEventPosition = position;
                parent.CurrentIntensity = intensity;
            }
            else
            {
                // something has changed. Write out the current data and start a new block
                closeChannel(parent);
                parent.StateMachine = parent.WaitingToStart;
                parent.processEvent(position, color, intensity);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Convert parsedV2Sequence into a V3 sequence
        /// </summary>
        private void importSequenceData()
        {
            // instantiate the state machine to process incoming data
            Vixen2xSequenceImportSM import = new Vixen2xSequenceImportSM(Sequence, parsedV2Sequence.EventPeriod);

            // the current color is based on the intensity of a three channel group
            int red   = 0;
            int green = 0;
            int blue  = 0;

            // for each channel in the V2 sequence
            for (var currentElementNum = 0; currentElementNum < parsedV2Sequence.ElementCount; currentElementNum++)
            {
                // Check to see if we are processing more elements than we have mappings. This showed up as an error for a user
                if (currentElementNum >= mappings.Count)
                {
                    Logging.Error("importSequenceData: Trying to process more elements (" + parsedV2Sequence.ElementCount + ") than we have mappings. (" + mappings.Count + ")");
                    break;
                }
                ChannelMapping v2ChannelMapping = mappings[currentElementNum];

                // set the channel number and the time for each v2 event.
                import.OpenChannel(v2ChannelMapping.ElementNodeId, Convert.ToDouble(parsedV2Sequence.EventPeriod));

                // Logging.Debug("importSequenceData:currentElementNum: " + currentElementNum);

                string elementName      = v2ChannelMapping.ChannelName;
                Color  currentColor     = Color.FromArgb(255, 255, 255);
                byte   currentIntensity = 0;

                conversionProgressBar.UpdateProgressBar(currentElementNum);
                Application.DoEvents();

                // is this an unmapped output channel?
                if (Guid.Empty == v2ChannelMapping.ElementNodeId)
                {
                    // no output channel. Move on to the next input channel
                    continue;
                }                 // end no output channel defined

                // do we have a valid guid conversion?
                if (false == m_GuidToV2ChanList.ContainsKey(v2ChannelMapping.ElementNodeId))
                {
                    Logging.Error("importSequenceData: Configuration error. GUID: '" + v2ChannelMapping.ElementNodeId + "' not found in m_GuidToV2ChanList.");
                    continue;
                }

                // is this a valid pixel configuration
                if ((true == v2ChannelMapping.RgbPixel) && (3 != m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId].Count))
                {
                    Logging.Error("importSequenceData: Configuration error. Found '" + m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId].Count + "' V2 channels attached to element '" + elementName + "'. Expected 3(RGB). Converting element to non color mixing mode.");
                    v2ChannelMapping.RgbPixel = false;
                }

                // process each event for this V2 channel
                for (uint currentEventNum = 0; currentEventNum < parsedV2Sequence.EventsPerElement; currentEventNum++)
                {
                    // get the intensity for this V2 channel
                    currentIntensity = parsedV2Sequence.EventData[currentElementNum * parsedV2Sequence.EventsPerElement + currentEventNum];

                    // is this an RGB Pixel?
                    if (true == v2ChannelMapping.RgbPixel)
                    {
                        // Only process the RED channel of a three channel pixel
                        if (Color.Red != v2ChannelMapping.DestinationColor)
                        {
                            // this is not the red channel of a pixel
                            continue;
                        }                         // end not red pixel channel

                        red   = 0;
                        green = 0;
                        blue  = 0;

                        // process the input colors bound to this output channel
                        foreach (ChannelMapping v2Channel in m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId])
                        {
                            // Logging.Info("convertMapping: Processing V2 Channel '" + v2Channel.ChannelName + "' color intensity.");

                            switch (v2Channel.DestinationColor.Name)
                            {
                            case "Red":
                            {
                                red = Math.Max(red, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber) - 1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                break;
                            }                                             // end Red

                            case "Green":
                            {
                                green = Math.Max(green, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber) - 1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                break;
                            }                                             // end Green

                            case "Blue":
                            {
                                blue = Math.Max(blue, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber) - 1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                break;
                            }                                             // end Red

                            default:
                            {
                                Logging.Error("importSequenceData pixel conversion processing error. Skipping processing unexpected color '" + v2Channel.DestinationColor.Name + "' for V2 Channel '" + v2Channel.ChannelName + "(" + v2Channel.ChannelNumber + ")'. Color must be one of 'RED', 'GREEN' or 'BLUE'");
                                break;
                            }                     // end default
                            }                     // end switch on color
                        }                         // end process each V2 channel assigned to the v3 channel

                        // get the max intensity for this v2 channel set
                        currentIntensity = Convert.ToByte(Math.Min((int)255, Math.Max(red, Math.Max(green, blue))));

                        // Scale the color to full intensity and let the intensity value attenuate it.
                        if (0 != currentIntensity)
                        {
                            double multplier = Convert.ToDouble(byte.MaxValue) / Convert.ToDouble(currentIntensity);

                            red   = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(red) * multplier));
                            green = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(green) * multplier));
                            blue  = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(blue) * multplier));
                        }

                        // set the final color
                        currentColor = Color.FromArgb(red, green, blue);
                    }                     // end pixel processing
                    else
                    {
                        // set the non pixel color value
                        currentColor = mappings[currentElementNum].DestinationColor;
                    }                     // end non pixel processing

                    // process the event through the state machine.
                    import.processEvent(currentEventNum, currentColor, currentIntensity);
                }                 // end for each event in the element / channel

                // close this channel
                import.closeChannel();
            }     // end for each input channel
        }         // end importSequenceData
Ejemplo n.º 7
0
        /// <summary>
        /// Convert parsedV2Sequence into a V3 sequence
        /// </summary>
        private void importSequenceData()
        {
            // instantiate the state machine to process incoming data
            Vixen2xSequenceImportSM import = new Vixen2xSequenceImportSM(Sequence, parsedV2Sequence.EventPeriod);

            // the current color is based on the intensity of a three channel group
            int red = 0;
            int green = 0;
            int blue = 0;

            // for each channel in the V2 sequence
            for (var currentElementNum = 0; currentElementNum < parsedV2Sequence.ElementCount; currentElementNum++)
            {
                // Check to see if we are processing more elements than we have mappings. This showed up as an error for a user
                if (currentElementNum >= mappings.Count)
                {
                    Logging.Error("importSequenceData: Trying to process more elements (" + parsedV2Sequence.ElementCount + ") than we have mappings. (" + mappings.Count + ")");
                    break;
                }
                ChannelMapping v2ChannelMapping = mappings[currentElementNum];

                // set the channel number and the time for each v2 event.
                import.OpenChannel(v2ChannelMapping.ElementNodeId, Convert.ToDouble(parsedV2Sequence.EventPeriod));

                // Logging.Debug("importSequenceData:currentElementNum: " + currentElementNum);

                string elementName = v2ChannelMapping.ChannelName;
                Color currentColor = Color.FromArgb(255, 255, 255);
                byte currentIntensity = 0;

                conversionProgressBar.UpdateProgressBar(currentElementNum);
                Application.DoEvents();

                // is this an unmapped output channel?
                if (Guid.Empty == v2ChannelMapping.ElementNodeId)
                {
                    // no output channel. Move on to the next input channel
                    continue;
                } // end no output channel defined

                // do we have a valid guid conversion?
                if ( false == m_GuidToV2ChanList.ContainsKey( v2ChannelMapping.ElementNodeId ))
                {
                    Logging.Error("importSequenceData: Configuration error. GUID: '" + v2ChannelMapping.ElementNodeId + "' not found in m_GuidToV2ChanList.");
                    continue;
                }

                // is this a valid pixel configuration
                if ((true == v2ChannelMapping.RgbPixel) && (3 != m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId].Count))
                {
                    Logging.Error("importSequenceData: Configuration error. Found '" + m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId].Count + "' V2 channels attached to element '" + elementName + "'. Expected 3(RGB). Converting element to non color mixing mode.");
                    v2ChannelMapping.RgbPixel = false;
                }

                // process each event for this V2 channel
                for (uint currentEventNum = 0; currentEventNum < parsedV2Sequence.EventsPerElement; currentEventNum++)
                {
                    // get the intensity for this V2 channel
                    currentIntensity = parsedV2Sequence.EventData[currentElementNum * parsedV2Sequence.EventsPerElement + currentEventNum];

                    // is this an RGB Pixel?
                    if (true == v2ChannelMapping.RgbPixel)
                    {
                        // Only process the RED channel of a three channel pixel
                        if (Color.Red != v2ChannelMapping.DestinationColor)
                        {
                            // this is not the red channel of a pixel
                            continue;
                        } // end not red pixel channel

                        red = 0;
                        green = 0;
                        blue = 0;

                        // process the input colors bound to this output channel
                        foreach (ChannelMapping v2Channel in m_GuidToV2ChanList[v2ChannelMapping.ElementNodeId])
                        {
                            // Logging.Info("convertMapping: Processing V2 Channel '" + v2Channel.ChannelName + "' color intensity.");

                            switch (v2Channel.DestinationColor.Name)
                            {
                                case "Red":
                                    {
                                        red = Math.Max( red, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber)-1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                        break;
                                    } // end Red

                                case "Green":
                                    {
                                        green = Math.Max(green, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber) - 1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                        break;
                                    } // end Green

                                case "Blue":
                                    {
                                        blue = Math.Max(blue, parsedV2Sequence.EventData[(Convert.ToInt64(v2Channel.ChannelNumber) - 1) * parsedV2Sequence.EventsPerElement + currentEventNum]);
                                        break;
                                    } // end Red

                                default:
                                    {
                                        Logging.Error("importSequenceData pixel conversion processing error. Skipping processing unexpected color '" + v2Channel.DestinationColor.Name + "' for V2 Channel '" + v2Channel.ChannelName + "(" + v2Channel.ChannelNumber + ")'. Color must be one of 'RED', 'GREEN' or 'BLUE'");
                                        break;
                                    } // end default
                            } // end switch on color
                        } // end process each V2 channel assigned to the v3 channel

                        // get the max intensity for this v2 channel set
                        currentIntensity = Convert.ToByte(Math.Min( (int)255, Math.Max(red, Math.Max(green, blue))));

                        // Scale the color to full intensity and let the intensity value attenuate it.
                        if (0 != currentIntensity)
                        {
                            double multplier = Convert.ToDouble(byte.MaxValue) / Convert.ToDouble(currentIntensity);

                            red = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(red) * multplier));
                            green = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(green) * multplier));
                            blue = Math.Min(((int)255), Convert.ToInt32(Convert.ToDouble(blue) * multplier));
                        }

                        // set the final color
                        currentColor = Color.FromArgb(red, green, blue);
                    } // end pixel processing
                    else
                    {
                        // set the non pixel color value
                        currentColor = mappings[currentElementNum].DestinationColor;
                    } // end non pixel processing

                    // process the event through the state machine.
                    import.processEvent(currentEventNum, currentColor, currentIntensity);
                } // end for each event in the element / channel

                // close this channel
                import.closeChannel();
            } // end for each input channel
        }
Ejemplo n.º 8
0
        }         // processEvent

        public void closeChannel(Vixen2xSequenceImportSM parent)
        {
            // set back to the waiting for the first event state
            parent.StateMachine = parent.IgnoreEvents;
        } // closeChannel
Ejemplo n.º 9
0
 public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
 {
     // just ignore the data
 }         // processEvent
Ejemplo n.º 10
0
        public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
        {
            //			Logging.Info("SWaitingToStart::processEvent - Entry");
            do
            {
                // save the starting values
                parent.CurrentColor = color;
                parent.StartingIntensity = intensity;
                parent.CurrentIntensity = intensity;
                parent.StartEventPosition = position;
                parent.EndEventPosition = position;

                // we ignore events that are close to black
                if( 5 > intensity)
                {
                    // dont bother
                    parent.StateMachine = parent.WaitingToStart;
                    break;
                }

                // next state Wait for a scond event to arrive
                parent.StateMachine = parent.HoldingOneEvent;

            } while (false);
            //			Logging.Info("SWaitingToStart::processEvent - Exit");
        }
Ejemplo n.º 11
0
 public void closeChannel(Vixen2xSequenceImportSM parent)
 {
     // set back to the waiting for the first event state
     parent.StateMachine = parent.IgnoreEvents;
 }
Ejemplo n.º 12
0
 public void processEvent(Vixen2xSequenceImportSM parent, uint position, Color color, byte intensity)
 {
     // just ignore the data
 }