Esempio n. 1
0
        /// <summary>
        /// Raises the <see cref="FrameParserBase{TypeIndentifier}.ReceivedHeaderFrame"/> event.
        /// </summary>
        /// <param name="frame"><see cref="IHeaderFrame"/> to send to <see cref="FrameParserBase{TypeIndentifier}.ReceivedHeaderFrame"/> event.</param>
        protected override void OnReceivedHeaderFrame(IHeaderFrame frame)
        {
            // We override this method so we can cache header frame when it's received
            base.OnReceivedHeaderFrame(frame);

            //// Cache new header frame for parsing subsequent configuration frame...
            HeaderFrame headerFrame = frame as HeaderFrame;

            if (headerFrame != null)
            {
                m_headerFrame = headerFrame;
            }
        }
Esempio n. 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 Macrodyne specific channel frame events, if any have been subscribed
            if (frame != null && (ReceivedDataFrame != null || ReceivedConfigurationFrame != null || ReceivedHeaderFrame != null))
            {
                DataFrame dataFrame = frame as DataFrame;

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

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

                        if (configFrame != null)
                        {
                            if (ReceivedConfigurationFrame != null)
                            {
                                ReceivedConfigurationFrame(this, new EventArgs <ConfigurationFrame>(configFrame));
                            }
                        }
                    }
                }
            }
        }