Ejemplo n.º 1
0
        public void Process(CNTRL_MSG controlParam, IQ inData)
        {
            if (controlParam == CNTRL_MSG.DATA_IN)
            {
                if (IsSyncReady)
                {
                    DataOut.Process(inData);
                }
                else
                {
                    Process(inData);
                    if (IsSyncReady)
                    {
                        int Start1, Start2;
                        int End1, End2;

                        DataOut.Process(CNTRL_MSG.SYNC_DETECTED);

                        Start1 = CurrentIndex;
                        End1   = DataLength;
                        Start2 = 0;        // initially disable a second run
                        End2   = CurrentIndex;
                        for (int i = Start1; i < End1; i++)
                        {
                            DataOut.Process(Data[i] * this.CorrRotate);
                        }
                        // Do second calculation loop if wrap-around was detected
                        for (int i = Start2; i < End2; i++)
                        {
                            DataOut.Process(Data[i] * this.CorrRotate);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Process(CNTRL_MSG controlParam, IQ data)
        {
            if (controlParam == CNTRL_MSG.DATA_IN)
            {
                // encode the I bit
                // encode the Q bit
                FFTInBuffer[CurrFreqIndex + FFT_START_INDEX]             = data;
                FFTInBuffer[FFTSize - (CurrFreqIndex + FFT_START_INDEX)] = data.C;  // Conjugate
                GeneratorsDone[CurrFreqIndex] = true;

                // Advance current frequency index and check for wrap-around
                CurrFreqIndex++; if (CurrFreqIndex >= NFREQ)
                {
                    CurrFreqIndex = 0;
                }
                if (GeneratorsDone[CurrFreqIndex])
                {
                    CalculateOutput();
                    foreach (float samp in OutputBuffer)
                    {
                        DataOut.Process(samp);
                    }
                }
            }
            else if (controlParam == CNTRL_MSG.FINISH)
            {
                CalculateOutput(OutputBuffer, 0);
                foreach (float samp in OutputBuffer)
                {
                    DataOut.Process(samp);
                }
                // re-initialize index
                CurrFreqIndex = 0;
            }
        }
Ejemplo n.º 3
0
        public void Process(CNTRL_MSG controlParam, float incomingSample)
        {
            if (controlParam == CNTRL_MSG.DATA_IN)
            {
                bool  SamplesReady = false;
                float I, Q;
                IQ    Data;

                sE = Coeff1 * sE + Coeff2 * incomingSample * incomingSample;
                for (int idx = 0; idx < NFREQ; idx++)
                {
                    gI[idx].Process(incomingSample, out I);
                    gQ[idx].Process(incomingSample, out Q);

                    if (InSyncProcess && (CorrSymbolIndex == idx))
                    {
                        // If we are in Sync mode for that channel - just pass samples
                        fI[idx].Process(I, out I);
                        fQ[idx].Process(Q, out Q);
                        if (CorrSymbol.Process(new IQ(I, Q)) > 0)
                        {
                            InSyncProcess = false;
                            // Sync mode just ended, and the data is ready
                            int NewIdx = CorrSymbol.SymbolCorrection;
                            for (int i = 0; i < NFREQ; i++)
                            {
                                // Adjust all FIRs/Decimators
                                fI[i].DecimateIndex = NewIdx;
                                fQ[i].DecimateIndex = NewIdx;
                            }
                            // Get all the data from the symbol corrector
                            while (CorrSymbol.Count > 0)
                            {
                                Data = CorrSymbol.GetData() * Correction[idx].Next();
                                DataOut.Process(Data);
                                fE[idx] = Coeff1 * fE[idx] + Coeff2 * Data.R2;
                            }
                        }
                    }
                    else
                    {
                        fI[idx].Decimate(I, out I);
                        SamplesReady = fQ[idx].Decimate(Q, out Q) > 0;
                        if (SamplesReady)
                        {
                            Data = new IQ(I, Q) * Correction[idx].Next();
                            DataOut.Process(Data);
                            fE[idx] = Coeff1 * fE[idx] + Coeff2 * Data.R2;
                        }
                    }
                }
                // All symbols go sequentially in the data queues, and NEW_SYMBOL messages are used
                //  to act as delimiters
                if (SamplesReady && (NFREQ > 1))
                {
                    DataOut.Process(CNTRL_MSG.NEW_SYMBOL);
                }
            }
        }
Ejemplo n.º 4
0
        public void Process(CNTRL_MSG controlParam, IQ data)
        {
            if (controlParam == CNTRL_MSG.DATA_IN)
            {
                PrepareOutputBuffer(OutputBuffer, 0);
                // encode the I bit
                fI[CurrFreqIndex].Interpolate(data.I, TempModBuffer);
                gI[CurrFreqIndex].GenerateAdd(TempModBuffer, OutputBuffer); // Modulate a carrier with symbol

                // encode the Q bit
                fQ[CurrFreqIndex].Interpolate(data.Q, TempModBuffer);
                gQ[CurrFreqIndex].GenerateAdd(TempModBuffer, OutputBuffer); // Modulate a carrier with symbol
                GeneratorsDone[CurrFreqIndex] = true;

                // Advance current frequency index and check for wrap-around
                CurrFreqIndex++; if (CurrFreqIndex >= NFREQ)
                {
                    CurrFreqIndex = 0;
                }
                if (GeneratorsDone[CurrFreqIndex])
                {
                    foreach (float samp in OutputBuffer)
                    {
                        DataOut.Process(samp);
                    }
                }
            }
            else if (controlParam == CNTRL_MSG.FINISH)
            {
                for (int i = 0; i < NFREQ; i++)
                {
                    if (!GeneratorsDone[i])
                    {
                        // encode the I bit
                        fI[i].Interpolate(0, TempModBuffer);
                        gI[i].GenerateAdd(TempModBuffer, OutputBuffer); // Modulate a carrier with symbol

                        // encode the Q bit
                        fQ[i].Interpolate(0, TempModBuffer);
                        gQ[i].GenerateAdd(TempModBuffer, OutputBuffer); // Modulate a carrier with symbol
                        GeneratorsDone[i] = true;
                    }
                }
                foreach (float samp in OutputBuffer)
                {
                    DataOut.Process(samp);
                }
                // re-initialize index
                CurrFreqIndex = 0;
            }
        }
Ejemplo n.º 5
0
 public void Process(CNTRL_MSG controlParam, float incomingSample)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         IQ Data;
         if (SamplesCounter >= 0)
         {
             AccumEnergy += incomingSample * incomingSample;
             FFTInBuffer[SamplesCounter] = new IQ(incomingSample, 0) / InputCorr.Value;
         }
         InputCorr.Next();
         SamplesCounter++;
         if (SamplesCounter >= FFTSize)
         {
             SamplesCounter = FFTSize - BlockSize;
             FFTDemodulator.ProcessFFT(FFTInBuffer, FFTOutBuffer);
             FrameEnergy = (2.0f * AccumEnergy) / FFTSize;
             AccumEnergy = 0;
             for (int i = 0; i < NFREQ; i++)
             {
                 Data = FFTOutBuffer[i + FFT_START_INDEX] * OutputCorr[i];
                 DataOut.Process(Data);
             }
         }
     }
 }
Ejemplo n.º 6
0
 public void Process(CNTRL_MSG controlParam, float incomingSample)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         IQ  Data;
         IQ  Target;
         IQ  Diff;
         int BitData;
         IQGenerator.Process(incomingSample, out Data);
         IQDemodulator.Process(Data);
         while (IQDemodulator.Count > 0)
         {
             Data = IQDemodulator.GetData();
             if (Data != IQ.ZERO)
             {
                 if (FirstSymbol)
                 {
                     FirstSymbol     = false;
                     Target          = Constellation.IQ_Simple_BPSK[Constellation.Bits_Simple_BPSK[InitialValue]];
                     Diff            = Target / Data;
                     this.CorrRotate = Diff / Data.R2;
                     IQDecoder.StartCorrectionProcess(SymbolsToDetectCorrection);
                     IQDecoder.PreviousIQ = Target;
                 }
                 IQDecoder.Process(Data * CorrRotate, out BitData);
                 DataOut.Process(BitData);
                 // Re-adjust constellation
                 Diff            = IQDecoder.Target / Data;
                 this.CorrRotate = Diff / Data.R2;
             }
         }
     }
 }
Ejemplo n.º 7
0
 public void Process(CNTRL_MSG controlParam, byte bitData)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         DataOut.Process(bitData);
         if (MatchFound)
         {
             Index++;
         }
         else
         {
             CurrentData = (CurrentData << 1) | (bitData & 0x01);
             if (((CurrentData ^ Target) & TargetMask) == 0)
             {
                 MatchFound = true;
                 Index      = NumBits;
                 DataOut.Process(CNTRL_MSG.EOM_DETECTED);
             }
         }
     }
 }
Ejemplo n.º 8
0
 public void ProcessEncode(CNTRL_MSG controlParam, byte dataByte)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         Storage[PutX, PutY] = dataByte;
         NextPutPos(ref PutX, ref PutY);
         PutCounter--;
         if (PutCounter == 0)
         {
             ProcessEncode();
             EncodeOut.Process(CNTRL_MSG.INTERLEAVER_FRAME);
             while (GetCounter > 0)
             {
                 EncodeOut.Process(Storage[GetX, GetY]);
                 NextGetPos(ref GetX, ref GetY);
                 GetCounter--;
             }
             this.Init();
         }
     }
 }
Ejemplo n.º 9
0
        public int Process(IQ inData)
        {
            FrameEnergy += (inData.P - DataBuffer[PutIndex].P);
            if (PutCounter == DataSize)
            {
                // when the buffer is filled - calculate the optimum sampling offset
                DataOut.Process(CNTRL_MSG.SYMBOL_DETECTED);
                ProcessIQ();
                SlicingIndex = CalculateCorrections();

                // Now send out accumulated symbols with correct slicing
                for (int i = 0; i < NumSymbols; i++)
                {
                    IQ IQData = DataBuffer[DecimFactor * i + SlicingIndex];
                    OutputData.Enqueue(IQData);
                    DataOut.Process(IQData);
                }
                if (0 == SlicingIndex)     // Remember - currently we are at index 0
                {
                    OutputData.Enqueue(inData);
                    DataOut.Process(inData);
                }
            }

            if (PutCounter > DataSize)
            {
                // Do re-calculation on boundaries
                if ((PutCounter % DataSize) == 0)
                {
                    DataOut.Process(CNTRL_MSG.SYMBOL_DETECTED);
                    ProcessIQ();
                    int NewSamplingIndex = CalculateCorrections();
                    // Remember - currently we are at index 0
                    if (CalculateIndexCorrection(SlicingIndex, NewSamplingIndex, out SkipSample))
                    {
                        OutputData.Enqueue(inData);
                        DataOut.Process(inData);
                    }
                    SlicingIndex = NewSamplingIndex;
                }
                // On the DecimFactor boundaries:
                if ((PutIndex % DecimFactor) == SlicingIndex)
                {
                    if (SkipSample)
                    {
                        SkipSample = false; // deactivate flag
                    }
                    else
                    {
                        // 1. send the data
                        OutputData.Enqueue(inData);
                        DataOut.Process(inData);
                    }
                }
            }
            DataBuffer[PutIndex++] = inData;
            PutCounter++;
            return(OutputData.Count);
        }
Ejemplo n.º 10
0
 public void Process(CNTRL_MSG controlParam, IQ inData)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         if (PutIndex < DataSize)
         {
             DataBuffer[PutIndex] = inData;
         }
         else if ((PutIndex % DecimFactor) == SlicingIndex)
         {
             DataOut.Process(inData);
         }
         PutIndex++;
         if (PutIndex == DataSize)
         {
             CalculateCorrections();
             foreach (IQ IQData in OutputData)
             {
                 DataOut.Process(IQData);
             }
         }
     }
 }
Ejemplo n.º 11
0
 public void Process(CNTRL_MSG controlParam, float incomingSample)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         IQ   Data;
         bool DataReady = true;
         for (int idx = 0; idx < NFREQ; idx++)
         {
             IQGens[idx].Process(incomingSample, out Data);
             IQDemod[idx].Process(Data);
             DataReady = DataReady && (IQDemod[idx].Count > 0);
         }
         if (DataReady)
         {
             DataOut.Process(CNTRL_MSG.NEW_SYMBOL);
             for (int idx = 0; idx < NFREQ; idx++)
             {
                 Data = IQDemod[idx].GetData() * CorrRotate[idx];
                 DataOut.Process(Data);
             }
         }
     }
 }
Ejemplo n.º 12
0
 void Process()
 {
     // Go thru every polynomial and prepare "Rate" bits for each input bit
     for (int i = 0; i < this.Rate; i++)
     {
         if ((PunctureMask & (1 << CurrentMaskCounter)) != 0)   // If bit is 1 in the Mask -> place result
         {
             DataOut.Process((byte)(Bitcount(CurrentState & Polynomial[i]) & 0x0001));
         }
         if (++CurrentMaskCounter >= PunctureSize)
         {
             CurrentMaskCounter = 0;
         }
     }
     // Update the State
     CurrentState >>= 1;
 }
Ejemplo n.º 13
0
        public int Process(IQ inData)
        {
            // Calculate Even interval (sampling point)
            if ((PutCounter >= StartActive) && (PutCounter < EndActive))
            {
                EvenAccum        += inData;
                EnergyAccum      += inData.P;
                FrameEnergyAccum += inData.R2;
            }

            // Calculate Odd interval (correction)
            if ((PutCounter >= StartHalfPoint) || (PutCounter < EndHalfPoint))
            {
                OddAccum += inData;
            }

            PutCounter++;

            if (PutCounter == HalfPoint)
            {
                OddIQ    = 2 * OddAccum / ActiveSamples;
                OddAccum = IQ.ZERO;
            }
            else if (PutCounter >= DecimFactor)
            {
                EvenIQ = 2 * EvenAccum / ActiveSamples;
                OutputData.Enqueue(EvenIQ);
                DataOut.Process(EvenIQ);

                FrequencyEn = EvenIQ.R2;
                SignalEn    = 2 * FrameEnergyAccum / ActiveSamples;

                PutCounter      = CalculateCorrections();
                SamplingOffset += PutCounter;

                PrevEvenIQ = EvenIQ;

                EvenAccum        = IQ.ZERO;
                EnergyAccum      = IQ.ZERO;
                FrameEnergyAccum = 0;
            }
            return(OutputData.Count);
        }
Ejemplo n.º 14
0
        public void Process(CNTRL_MSG controlParam, T incomingBit)
        {
            if (controlParam == CNTRL_MSG.DATA_IN)
            {
                DataArray[CurrentInIndex++] = incomingBit; if (CurrentInIndex >= MaxBits)
                {
                    CurrentInIndex = 0;
                }
                CurrentInCounter++;
                if (CurrentInCounter >= NumBitsIn)
                {
                    CurrentInCounter = 0;
                    int CurrentFrame = CurrentInIndex - NumBitsIn; if (CurrentFrame < 0)
                    {
                        CurrentFrame += MaxBits;
                    }
                    // Start from the beginning of the input block

                    int      CurrentOutIndex;
                    int      CurrentOutCounter;
                    BitGroup bg;

                    int CurrentBitGroupIndex = 0;
                    while (CurrentBitGroupIndex < MaxBitGroupIndex)
                    {
                        bg = BGArray[CurrentBitGroupIndex++];
                        CurrentOutIndex = CurrentFrame - bg.Position; if (CurrentOutIndex < 0)
                        {
                            CurrentOutIndex += MaxBits;
                        }
                        CurrentOutCounter = bg.Size;
                        while (CurrentOutCounter-- > 0)
                        {
                            DataOut.Process(DataArray[CurrentOutIndex++]); if (CurrentOutIndex >= MaxBits)
                            {
                                CurrentOutIndex = 0;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
 public void Process(CNTRL_MSG controlParam, byte incomingBit)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         DataArray[CurrentInIndex++] += (byte)((incomingBit == 0) ? -1 : 1); if (CurrentInIndex >= MaxBits)
         {
             CurrentInIndex = 0;
         }
         CurrentBGCounter--;
         if (CurrentBGCounter <= 0)
         {
             BitGroup bg = BGArray[CurrentBitGroupIndex++]; if (CurrentBitGroupIndex >= MaxBitGroupIndex)
             {
                 CurrentBitGroupIndex = 0;
             }
             CurrentInIndex = CurrentFrame - bg.Position; if (CurrentInIndex < 0)
             {
                 CurrentInIndex += MaxBits;
             }
             CurrentBGCounter = bg.Size;
         }
         CurrentInCounter++;
         if (CurrentInCounter >= NumBitsIn)
         {
             CurrentInCounter = 0;
             // Output data
             for (int i = 0; i < NumBitsOut; i++)
             {
                 DataOut.Process((byte)((DataArray[CurrentFrame++] > 0) ? 1 : 0)); if (CurrentFrame >= MaxBits)
                 {
                     CurrentFrame = 0;
                 }
             }
             Array.Clear(DataArray, CurrentFrame, NumBitsOut);
         }
     }
 }