Ejemplo n.º 1
0
            /**
             * Sends instrumentation tap event to all registered listeners
             */
            private void sendTapEvent(RadioLog.Common.SafeBitArray bitset, Shift shift, bool decision)
            {
                foreach (IListener <SymbolEvent> tap in mDecoder.GetListeners())
                {
                    SymbolEvent sEvent = new SymbolEvent(bitset.CloneFromIndexToIndex(0, mSymbolLength), mSymbolLength, decision, shift);

                    tap.Receive(sEvent);
                }
            }
Ejemplo n.º 2
0
        public static RadioLog.Common.SafeBitArray interleave(RadioLog.Common.SafeBitArray message, int start, int end)
        {
            RadioLog.Common.SafeBitArray original = message.CloneFromIndexToIndex(start, end);

            /* Clear block bits in source message */
            message.ClearRange(start, end);

            /* Iterate only the set bits in the original message and apply
             * the deinterleave -- we don't have to evaluate the 0 bits */
            for (int i = original.nextSetBit(0);
                 i >= 0 && i < INTERLEAVE.Length;
                 i = original.nextSetBit(i + 1))
            {
                message.SetBit(start + INTERLEAVE[i]);
            }

            return(message);
        }
Ejemplo n.º 3
0
        private CRC detectAndCorrect(int start, int end)
        {
            RadioLog.Common.SafeBitArray original = mMessage.CloneFromIndexToIndex(start, end);

            CRC retVal = CRCFleetsync.check(original);

            //Attempt to correct single-bit errors
            if (retVal == CRC.FAILED_PARITY)
            {
                int[] errorBitPositions = CRCFleetsync.findBitErrors(original);

                if (errorBitPositions != null)
                {
                    foreach (int errorBitPosition in errorBitPositions)
                    {
                        mMessage.flip(start + errorBitPosition);
                    }

                    retVal = CRC.CORRECTED;
                }
            }

            return(retVal);
        }
Ejemplo n.º 4
0
            private void checkComplete()
            {
                if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.NID))
                {
                    int value = mMessage.getInt(Decoders.P25.Message.P25Message.DUID);

                    Decoders.P25.Reference.DataUnitID duid = Decoders.P25.Reference.DataUnitID.fromValue(value);

                    if (duid != Decoders.P25.Reference.DataUnitID.UNKN)
                    {
                        setDUID(duid);
                    }
                    else
                    {
                        mComplete = true;
                    }
                }
                else if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.HDU) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.LDU1) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.LDU2) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.PDU2) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.PDU3) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.TDU) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.TDULC) ||
                         mDUID.Equals(Decoders.P25.Reference.DataUnitID.UNKN))
                {
                    mComplete = true;
                    mFramer.dispatch(new Decoders.P25.Message.P25Message(mMessage.Clone(), mDUID));
                }
                else if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.PDU1))
                {
                    int blocks    = mMessage.getInt(Decoders.P25.Message.PDUMessage.PDU_HEADER_BLOCKS_TO_FOLLOW);
                    int padBlocks = mMessage.getInt(Decoders.P25.Message.PDUMessage.PDU_HEADER_PAD_BLOCKS);

                    int blockCount = blocks + padBlocks;

                    if (blockCount == 24 || blockCount == 32)
                    {
                        setDUID(Decoders.P25.Reference.DataUnitID.PDU2);
                    }
                    else if (blockCount == 36 || blockCount == 48)
                    {
                        setDUID(Decoders.P25.Reference.DataUnitID.PDU3);
                    }
                    else
                    {
                        mFramer.dispatch(new Decoders.P25.Message.PDUMessage(mMessage.Clone(), mDUID));
                        mComplete = true;
                    }
                }
                else if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.TSBK1))
                {
                    /* Remove interleaving */
                    Decoders.P25.P25Interleave.deinterleave(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Remove trellis encoding */
                    mFramer.mHalfRate.decode(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Construct the message */
                    int tsbkSystem1 = mMessage.getInt(Decoders.P25.Message.P25Message.NAC);

                    RadioLog.Common.SafeBitArray tsbkBuffer1 = new RadioLog.Common.SafeBitArray(mMessage.CloneFromIndexToIndex(TSBK_BEGIN, TSBK_DECODED_END), 96);

                    Decoders.P25.Message.TSBKMessage tsbkMessage1 = Decoders.P25.Message.TSBKMessageFactory.getMessage(tsbkSystem1, tsbkBuffer1);

                    if (tsbkMessage1.isLastBlock())
                    {
                        mComplete = true;
                    }
                    else
                    {
                        setDUID(Decoders.P25.Reference.DataUnitID.TSBK2);
                        mMessage.SetPointer(TSBK_BEGIN);
                    }

                    mFramer.dispatch(tsbkMessage1);
                }
                else if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.TSBK2))
                {
                    /* Remove interleaving */
                    Decoders.P25.P25Interleave.deinterleave(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Remove trellis encoding */
                    mFramer.mHalfRate.decode(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Construct the message */
                    int tsbkSystem2 = mMessage.getInt(Decoders.P25.Message.P25Message.NAC);

                    RadioLog.Common.SafeBitArray tsbkBuffer2 = new RadioLog.Common.SafeBitArray(mMessage.CloneFromIndexToIndex(TSBK_BEGIN, TSBK_DECODED_END), 98);

                    Decoders.P25.Message.TSBKMessage tsbkMessage2 = Decoders.P25.Message.TSBKMessageFactory.getMessage(tsbkSystem2, tsbkBuffer2);

                    if (tsbkMessage2.isLastBlock())
                    {
                        mComplete = true;
                    }
                    else
                    {
                        setDUID(Decoders.P25.Reference.DataUnitID.TSBK3);
                        mMessage.SetPointer(TSBK_BEGIN);
                    }

                    mFramer.dispatch(tsbkMessage2);
                }
                else if (mDUID.Equals(Decoders.P25.Reference.DataUnitID.TSBK3))
                {
                    /* Remove interleaving */
                    Decoders.P25.P25Interleave.deinterleave(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Remove trellis encoding */
                    mFramer.mHalfRate.decode(mMessage, TSBK_BEGIN, TSBK_END);

                    /* Construct the message */
                    int tsbkSystem3 = mMessage.getInt(Decoders.P25.Message.P25Message.NAC);

                    RadioLog.Common.SafeBitArray tsbkBuffer3 = new RadioLog.Common.SafeBitArray(mMessage.CloneFromIndexToIndex(TSBK_BEGIN, TSBK_DECODED_END), 96);

                    Decoders.P25.Message.TSBKMessage tsbkMessage3 = Decoders.P25.Message.TSBKMessageFactory.getMessage(tsbkSystem3, tsbkBuffer3);

                    mComplete = true;

                    mFramer.dispatch(tsbkMessage3);
                }
                else
                {
                    mComplete = true;
                }
            }