blob: 84e39871afa2ba045b46972238f35a43f7ea73a6 [file] [log] [blame]
kurtis.heimerl8aea56e2011-11-26 03:18:30 +00001/*
2 * Written by Thomas Tsou <ttsou@vt.edu>
3 * Based on code by Harvind S Samra <hssamra@kestrelsp.com>
4 *
5 * Copyright 2011 Free Software Foundation, Inc.
6 *
Pau Espin Pedrol21d03d32019-07-22 12:05:52 +02007 * SPDX-License-Identifier: AGPL-3.0+
8 *
kurtis.heimerl8aea56e2011-11-26 03:18:30 +00009 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See the COPYING file in the main directory for details.
22 */
23
24#ifndef RADIOVECTOR_H
25#define RADIOVECTOR_H
26
27#include "sigProcLib.h"
28#include "GSMCommon.h"
Alexander Chemerisd734e2d2013-06-16 14:30:58 +040029#include "Interthread.h"
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000030
Thomas Tsoua2fe91a2013-11-13 22:48:11 -050031class radioVector {
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000032public:
Thomas Tsoua2fe91a2013-11-13 22:48:11 -050033 radioVector(GSM::Time& wTime, size_t size = 0,
34 size_t start = 0, size_t chans = 1);
35
36 radioVector(GSM::Time& wTime, signalVector *vector);
37 ~radioVector();
38
kurtis.heimerl06286132011-11-26 03:18:43 +000039 GSM::Time getTime() const;
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000040 void setTime(const GSM::Time& wTime);
41 bool operator>(const radioVector& other) const;
42
Thomas Tsou18820992013-11-14 18:04:10 -050043 signalVector *getVector(size_t chan = 0) const;
Thomas Tsoua2fe91a2013-11-13 22:48:11 -050044 bool setVector(signalVector *vector, size_t chan = 0);
45 size_t chans() const { return vectors.size(); }
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000046private:
Thomas Tsoua2fe91a2013-11-13 22:48:11 -050047 std::vector<signalVector *> vectors;
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000048 GSM::Time mTime;
49};
50
Thomas Tsoufa3a7872013-10-17 21:23:34 -040051class noiseVector : std::vector<float> {
52public:
Thomas Tsoua0179e32013-11-14 15:52:04 -050053 noiseVector(size_t size = 0);
Thomas Tsoufa3a7872013-10-17 21:23:34 -040054 bool insert(float val);
Thomas Tsou18820992013-11-14 18:04:10 -050055 float avg() const;
Thomas Tsoufa3a7872013-10-17 21:23:34 -040056
57private:
Thomas Tsoua0179e32013-11-14 15:52:04 -050058 size_t itr;
Thomas Tsoufa3a7872013-10-17 21:23:34 -040059};
60
Thomas Tsou204a9f12013-10-29 18:34:16 -040061class VectorFIFO : public InterthreadQueue<radioVector> { };
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000062
63class VectorQueue : public InterthreadPriorityQueue<radioVector> {
64public:
65 GSM::Time nextTime() const;
66 radioVector* getStaleBurst(const GSM::Time& targTime);
67 radioVector* getCurrentBurst(const GSM::Time& targTime);
Pau Espin Pedrol8b0c5362020-07-09 17:39:20 +020068 Mutex *getMutex() const { return &mLock; };
kurtis.heimerl8aea56e2011-11-26 03:18:30 +000069};
70
71#endif /* RADIOVECTOR_H */