Пример #1
0
        private void Session_RDSFrameReceivedEvent(Framework.RDSCommand frame, RDSSession session)
        {
            //Get type
            if (frame.GetType() != typeof(BasicDataRDSCommand))
            {
                return;
            }
            BasicDataRDSCommand cmd = (BasicDataRDSCommand)frame;

            //Set data in buffer
            stationNameBuffer[cmd.stationNameIndex]     = cmd.letterA;
            stationNameBuffer[cmd.stationNameIndex + 1] = cmd.letterB;

            //Set chunk flag
            if (cmd.stationNameIndex == 0)
            {
                _firstChunkDecoded = true;
            }

            //Update final station name, if any
            if (cmd.stationNameIndex == 6 && _firstChunkDecoded)
            {
                stationName = new string(stationNameBuffer);
                RDSFeatureStationName_StationNameUpdatedEvent?.Invoke(stationName);
            }

            //Send event
            RDSFeatureStationName_StationBufferUpdatedEvent?.Invoke(stationNameBuffer, cmd.stationNameIndex);
        }
Пример #2
0
        private void Session_RDSFrameReceivedEvent(Framework.RDSCommand frame, RDSSession session)
        {
            //Get type
            if (frame.GetType() != typeof(RadioTextRDSCommand))
            {
                return;
            }
            RadioTextRDSCommand cmd = (RadioTextRDSCommand)frame;

            //Set if the clear flag has been changed
            //http://www.interactive-radio-system.com/docs/EN50067_RDS_Standard.pdf defines that a screen clear should happen
            if (_lastClearFlag != cmd.clear)
            {
                //Clear the buffer
                for (var i = 0; i < textBuffer.Length; i++)
                {
                    textBuffer[i] = (char)0x00;
                }

                //Set the buffer
                _lastClearFlag     = cmd.clear;
                _firstChunkDecoded = false;

                //Send event
                RDSFeatureRadioText_RadioTextClearedUpdatedEvent?.Invoke();
            }
            else
            {
                //Set data in buffer
                textBuffer[cmd.offset + 0] = cmd.letterA;
                textBuffer[cmd.offset + 1] = cmd.letterB;
                textBuffer[cmd.offset + 2] = cmd.letterC;
                textBuffer[cmd.offset + 3] = cmd.letterD;

                //Set chunk flag
                if (cmd.offset == 0)
                {
                    _firstChunkDecoded = true;
                }

                //Update final station name, if any
                //http://www.interactive-radio-system.com/docs/EN50067_RDS_Standard.pdf defines that the final message must end with \r. We use that to determine when the message is fully written
                if ((cmd.letterA == '\r' || cmd.letterB == '\r' || cmd.letterC == '\r' || cmd.letterD == '\r') && _firstChunkDecoded)
                {
                    radioText = new string(textBuffer);
                    RDSFeatureRadioText_RadioTextUpdatedEvent?.Invoke(radioText);
                }
            }

            //Send event
            RDSFeatureRadioText_RadioTextBufferUpdatedEvent?.Invoke(textBuffer, cmd.offset, 4);
        }