Example #1
0
 /// <summary>
 /// Raises the <see cref="ReceivedUndeterminedFrame"/> event.
 /// </summary>
 /// <param name="frame"><see cref="IChannelFrame"/> to send to <see cref="ReceivedUndeterminedFrame"/> event.</param>
 protected virtual void OnReceivedUndeterminedFrame(IChannelFrame frame)
 {
     if ((object)ReceivedUndeterminedFrame != null)
     {
         ReceivedUndeterminedFrame(this, new EventArgs <IChannelFrame>(frame));
     }
 }
Example #2
0
        /// <summary>
        /// Casts the parsed <see cref="IChannelFrame"/> to its specific implementation (i.e., <see cref="DataFrame"/> or <see cref="ConfigurationFrame"/>).
        /// </summary>
        /// <param name="frame"><see cref="IChannelFrame"/> that was parsed by <see cref="FrameImageParserBase{TTypeIdentifier,TOutputType}"/> that implements protocol specific common frame header interface.</param>
        protected override void OnReceivedChannelFrame(IChannelFrame frame)
        {
            // Raise abstract channel frame events as a priority (i.e., IDataFrame, IConfigurationFrame, etc.)
            base.OnReceivedChannelFrame(frame);

            // Raise SEL Fast Message specific channel frame events, if any have been subscribed
            if (frame != null && (ReceivedDataFrame != null || ReceivedConfigurationFrame != null))
            {
                DataFrame dataFrame = frame as DataFrame;

                if (dataFrame != null)
                {
                    if (ReceivedDataFrame != null)
                    {
                        ReceivedDataFrame(this, new EventArgs <DataFrame>(dataFrame));
                    }
                }
                else
                {
                    ConfigurationFrame configFrame = frame as ConfigurationFrame;

                    if (configFrame != null)
                    {
                        if (ReceivedConfigurationFrame != null)
                        {
                            ReceivedConfigurationFrame(this, new EventArgs <ConfigurationFrame>(configFrame));
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Casts the parsed <see cref="IChannelFrame"/> to its specific implementation (i.e., <see cref="IDataFrame"/>, <see cref="IConfigurationFrame"/>, <see cref="ICommandFrame"/> or <see cref="IHeaderFrame"/>).
        /// </summary>
        /// <param name="frame"><see cref="IChannelFrame"/> that was parsed by <see cref="FrameImageParserBase{TTypeIdentifier,TOutputType}"/> that implements protocol specific common frame header interface.</param>
        protected virtual void OnReceivedChannelFrame(IChannelFrame frame)
        {
            switch (frame)
            {
            // Process frame types in order of likely occurrence
            case IDataFrame dataFrame:
                // Frame was a data frame
                OnReceivedDataFrame(dataFrame);
                break;

            case IConfigurationFrame configFrame:
                // Frame was a configuration frame
                OnReceivedConfigurationFrame(configFrame);
                break;

            case IHeaderFrame headerFrame:
                // Frame was a header frame
                OnReceivedHeaderFrame(headerFrame);
                break;

            case ICommandFrame commandFrame:
                // Frame was a command frame
                OnReceivedCommandFrame(commandFrame);
                break;

            default:
                // Frame type was undetermined
                OnReceivedUndeterminedFrame(frame);
                break;
            }
        }
Example #4
0
        // Static Methods

        // Create new header cell delegate handler
        internal static IHeaderCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState <IHeaderCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            parsedLength = 1;
            return(new HeaderCell(parent as IHeaderFrame, buffer[startIndex])
            {
                IDCode = (ushort)index
            });
        }
Example #5
0
        // Static Methods

        // Delegate handler to create a new BPA PDCstream data cell
        internal static IDataCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState <IDataCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            DataCell dataCell = new DataCell(parent as IDataFrame, (state as IDataFrameParsingState).ConfigurationFrame.Cells[index]);

            parsedLength = dataCell.ParseBinaryImage(buffer, startIndex, 0);

            return(dataCell);
        }
Example #6
0
        // Static Methods

        // Delegate handler to create a new IEEE C37.118 configuration cell
        internal static IConfigurationCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState <IConfigurationCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            ConfigurationCell configCell = new ConfigurationCell(parent as IConfigurationFrame);

            parsedLength = configCell.ParseBinaryImage(buffer, startIndex, 0);

            return(configCell);
        }
Example #7
0
        /// <summary>
        /// Casts the parsed <see cref="IChannelFrame"/> to its specific implementation (i.e., <see cref="DataFrame"/>, <see cref="ConfigurationFrame"/>, <see cref="CommandFrame"/> or <see cref="HeaderFrame"/>).
        /// </summary>
        /// <param name="frame"><see cref="IChannelFrame"/> that was parsed by <see cref="FrameImageParserBase{TTypeIdentifier,TOutputType}"/> that implements protocol specific common frame header interface.</param>
        protected override void OnReceivedChannelFrame(IChannelFrame frame)
        {
            // Raise abstract channel frame events as a priority (i.e., IDataFrame, IConfigurationFrame, etc.)
            base.OnReceivedChannelFrame(frame);

            // Raise IEEE 1344 specific channel frame events, if any have been subscribed
            if (frame != null && (ReceivedDataFrame != null || ReceivedConfigurationFrame != null || ReceivedHeaderFrame != null || ReceivedCommandFrame != null))
            {
                DataFrame dataFrame = frame as DataFrame;

                if (dataFrame != null)
                {
                    if (ReceivedDataFrame != null)
                    {
                        ReceivedDataFrame(this, new EventArgs <DataFrame>(dataFrame));
                    }
                }
                else
                {
                    ConfigurationFrame configFrame = frame as ConfigurationFrame;

                    if (configFrame != null && configFrame.CommonHeader.IsLastFrame)
                    {
                        if (ReceivedConfigurationFrame != null)
                        {
                            ReceivedConfigurationFrame(this, new EventArgs <ConfigurationFrame>(configFrame));
                        }
                    }
                    else
                    {
                        HeaderFrame headerFrame = frame as HeaderFrame;

                        if (headerFrame != null && headerFrame.CommonHeader.IsLastFrame)
                        {
                            if (ReceivedHeaderFrame != null)
                            {
                                ReceivedHeaderFrame(this, new EventArgs <HeaderFrame>(headerFrame));
                            }
                        }
                        else
                        {
                            CommandFrame commandFrame = frame as CommandFrame;

                            if (commandFrame != null)
                            {
                                if (ReceivedCommandFrame != null)
                                {
                                    ReceivedCommandFrame(this, new EventArgs <CommandFrame>(commandFrame));
                                }
                            }
                        }
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Casts the parsed <see cref="IChannelFrame"/> to its specific implementation (i.e., <see cref="IDataFrame"/>, <see cref="IConfigurationFrame"/>, <see cref="ICommandFrame"/> or <see cref="IHeaderFrame"/>).
        /// </summary>
        /// <param name="frame"><see cref="IChannelFrame"/> that was parsed by <see cref="FrameImageParserBase{TTypeIdentifier,TOutputType}"/> that implements protocol specific common frame header interface.</param>
        protected virtual void OnReceivedChannelFrame(IChannelFrame frame)
        {
            // Process frame types in order or likely occurrence
            if ((object)frame != null)
            {
                IDataFrame dataFrame = frame as IDataFrame;

                if ((object)dataFrame != null)
                {
                    // Frame was a data frame
                    OnReceivedDataFrame(dataFrame);
                }
                else
                {
                    IConfigurationFrame configFrame = frame as IConfigurationFrame;

                    if ((object)configFrame != null)
                    {
                        // Frame was a configuration frame
                        OnReceivedConfigurationFrame(configFrame);
                    }
                    else
                    {
                        IHeaderFrame headerFrame = frame as IHeaderFrame;

                        if ((object)headerFrame != null)
                        {
                            // Frame was a header frame
                            OnReceivedHeaderFrame(headerFrame);
                        }
                        else
                        {
                            ICommandFrame commandFrame = frame as ICommandFrame;

                            if ((object)commandFrame != null)
                            {
                                // Frame was a command frame
                                OnReceivedCommandFrame(commandFrame);
                            }
                            else
                            {
                                // Frame type was undetermined
                                OnReceivedUndeterminedFrame(frame);
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        // Static Methods

        // Delegate handler to create a new IEC 61850-90-5 data cell
        internal static IDataCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState <IDataCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            IDataFrameParsingState parsingState      = state as IDataFrameParsingState;
            IConfigurationCell     configurationCell = null;

            // With or without an associated configuration, we'll parse the data cell
            if (parsingState != null && parsingState.ConfigurationFrame != null)
            {
                configurationCell = parsingState.ConfigurationFrame.Cells[index];
            }

            DataCell dataCell = new DataCell(parent as IDataFrame, configurationCell);

            parsedLength = dataCell.ParseBinaryImage(buffer, startIndex, 0);

            return(dataCell);
        }
Example #10
0
        // Static Methods

        // Create new header cell delegate handler
        internal static IHeaderCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState<IHeaderCell> state, int index, byte[] binaryImage, int startIndex, out int parsedLength)
        {
            parsedLength = 1;
            return new HeaderCell(parent as IHeaderFrame, binaryImage[startIndex]) { IDCode = (ushort)index };
        }
Example #11
0
        /// <summary>
        /// Casts the parsed <see cref="IChannelFrame"/> to its specific implementation (i.e., <see cref="DataFrame"/>, <see cref="ConfigurationFrame"/>, <see cref="CommandFrame"/> or <see cref="HeaderFrame"/>).
        /// </summary>
        /// <param name="frame"><see cref="IChannelFrame"/> that was parsed by <see cref="FrameImageParserBase{TTypeIdentifier,TOutputType}"/> that implements protocol specific common frame header interface.</param>
        protected override void OnReceivedChannelFrame(IChannelFrame frame)
        {
            // Raise abstract channel frame events as a priority (i.e., IDataFrame, IConfigurationFrame, etc.)
            base.OnReceivedChannelFrame(frame);

            // Raise IEEE C37.118 specific channel frame events, if any have been subscribed
            if (frame != null && (ReceivedDataFrame != null || ReceivedConfigurationFrame2 != null || ReceivedConfigurationFrame1 != null || ReceivedHeaderFrame != null || ReceivedCommandFrame != null))
            {
                DataFrame dataFrame = frame as DataFrame;

                if (dataFrame != null)
                {
                    if (ReceivedDataFrame != null)
                    {
                        ReceivedDataFrame(this, new EventArgs <DataFrame>(dataFrame));
                    }
                }
                else
                {
                    // Configuration frame type 2 is more specific than type 1 (and more common), so we check it first
                    ConfigurationFrame2 configFrame2 = frame as ConfigurationFrame2;

                    if (configFrame2 != null)
                    {
                        if (ReceivedConfigurationFrame2 != null)
                        {
                            ReceivedConfigurationFrame2(this, new EventArgs <ConfigurationFrame2>(configFrame2));
                        }
                    }
                    else
                    {
                        ConfigurationFrame1 configFrame1 = frame as ConfigurationFrame1;

                        if (configFrame1 != null)
                        {
                            if (ReceivedConfigurationFrame1 != null)
                            {
                                ReceivedConfigurationFrame1(this, new EventArgs <ConfigurationFrame1>(configFrame1));
                            }
                        }
                        else
                        {
                            HeaderFrame headerFrame = frame as HeaderFrame;

                            if (headerFrame != null)
                            {
                                if (ReceivedHeaderFrame != null)
                                {
                                    ReceivedHeaderFrame(this, new EventArgs <HeaderFrame>(headerFrame));
                                }
                            }
                            else
                            {
                                CommandFrame commandFrame = frame as CommandFrame;

                                if (commandFrame != null)
                                {
                                    if (ReceivedCommandFrame != null)
                                    {
                                        ReceivedCommandFrame(this, new EventArgs <CommandFrame>(commandFrame));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #12
0
 /// <summary>
 /// Creates a new <see cref="ChannelCellBase"/> from serialization parameters.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
 /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
 protected ChannelCellBase(SerializationInfo info, StreamingContext context)
 {
     // Deserialize basic channel cell values
     m_parent = (IChannelFrame)info.GetValue("parent", typeof(IChannelFrame));
     m_idCode = info.GetUInt16("id");
 }
Example #13
0
 /// <summary>
 /// Raises the <see cref="ReceivedUndeterminedFrame"/> event.
 /// </summary>
 /// <param name="frame"><see cref="IChannelFrame"/> to send to <see cref="ReceivedUndeterminedFrame"/> event.</param>
 protected virtual void OnReceivedUndeterminedFrame(IChannelFrame frame)
 {
     ReceivedUndeterminedFrame?.Invoke(this, new EventArgs <IChannelFrame>(frame));
 }
Example #14
0
        // Static Methods

        // Create new command cell delegate handler
        internal static ICommandCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState<ICommandCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            parsedLength = 1;
            return new CommandCell(parent as ICommandFrame, buffer[startIndex])
            {
                IDCode = (ushort)index
            };
        }
Example #15
0
        // Static Methods

        // Delegate handler to create a new BPA PDCstream configuration cell
        internal static IConfigurationCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState<IConfigurationCell> state, int index, byte[] binaryImage, int startIndex, out int parsedLength)
        {
            ConfigurationCell configCell = new ConfigurationCell(parent as IConfigurationFrame);

            parsedLength = configCell.Initialize(binaryImage, startIndex, 0);

            return configCell;
        }
Example #16
0
        private ushort m_idCode;                // Numeric identifier of this logical unit of data (e.g., PMU ID code)

        #endregion

        #region [ Constructors ]

        /// <summary>
        /// Creates a new <see cref="ChannelCellBase"/> from specified parameters.
        /// </summary>
        /// <param name="parent">A reference to the parent <see cref="IChannelFrame"/> for this <see cref="ChannelCellBase"/>.</param>
        /// <param name="idCode">The numeric ID code for this <see cref="ChannelCellBase"/>.</param>
        protected ChannelCellBase(IChannelFrame parent, ushort idCode)
        {
            m_parent = parent;
            m_idCode = idCode;
        }
Example #17
0
        private ushort m_idCode;                // Numeric identifier of this logical unit of data (e.g., PMU ID code)

        #endregion

        #region [ Constructors ]

        /// <summary>
        /// Creates a new <see cref="ChannelCellBase"/> from specified parameters.
        /// </summary>
        /// <param name="parent">A reference to the parent <see cref="IChannelFrame"/> for this <see cref="ChannelCellBase"/>.</param>
        /// <param name="idCode">The numeric ID code for this <see cref="ChannelCellBase"/>.</param>
        protected ChannelCellBase(IChannelFrame parent, ushort idCode)
        {
            m_parent = parent;
            m_idCode = idCode;
        }
Example #18
0
 /// <summary>
 /// Creates a new <see cref="ChannelCellBase"/> from serialization parameters.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
 /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
 protected ChannelCellBase(SerializationInfo info, StreamingContext context)
 {
     // Deserialize basic channel cell values
     m_parent = (IChannelFrame)info.GetValue("parent", typeof(IChannelFrame));
     m_idCode = info.GetUInt16("id");
 }
Example #19
0
        // Static Methods

        // Delegate handler to create a new Macrodyne configuration cell
        internal static IConfigurationCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState <IConfigurationCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            parsedLength = 0;
            return(new ConfigurationCell(parent as ConfigurationFrame, null));
        }
Example #20
0
        // Static Methods

        // Delegate handler to create a new IEEE 1344 data cell
        internal static IDataCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState<IDataCell> state, int index, byte[] binaryImage, int startIndex, out int parsedLength)
        {
            DataCell dataCell = new DataCell(parent as IDataFrame, (state as IDataFrameParsingState).ConfigurationFrame.Cells[index]);

            parsedLength = dataCell.Initialize(binaryImage, startIndex, 0);

            return dataCell;
        }
Example #21
0
        // Static Methods

        // Delegate handler to create a new IEC 61850-90-5 data cell
        internal static IDataCell CreateNewCell(IChannelFrame parent, IChannelFrameParsingState<IDataCell> state, int index, byte[] buffer, int startIndex, out int parsedLength)
        {
            IDataFrameParsingState parsingState = state as IDataFrameParsingState;
            IConfigurationCell configurationCell = null;

            // With or without an associated configuration, we'll parse the data cell
            if (parsingState != null && parsingState.ConfigurationFrame != null)
                configurationCell = parsingState.ConfigurationFrame.Cells[index];

            DataCell dataCell = new DataCell(parent as IDataFrame, configurationCell);

            parsedLength = dataCell.ParseBinaryImage(buffer, startIndex, 0);

            return dataCell;
        }