blob: fd4e5a752fad7b09699bbc3967351a7162e6cde0 [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 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * See the COPYING file in the main directory for details.
20 */
21
22#include "radioVector.h"
23
24radioVector::radioVector(const signalVector& wVector, GSM::Time& wTime)
25 : signalVector(wVector), mTime(wTime)
26{
27}
28
29GSM::Time radioVector::time() const
30{
31 return mTime;
32}
33
34void radioVector::setTime(const GSM::Time& wTime)
35{
36 mTime = wTime;
37}
38
39bool radioVector::operator>(const radioVector& other) const
40{
41 return mTime > other.mTime;
42}
43
44unsigned VectorFIFO::size()
45{
46 return mQ.size();
47}
48
49void VectorFIFO::put(radioVector *ptr)
50{
51 mQ.put((void*) ptr);
52}
53
54radioVector *VectorFIFO::get()
55{
56 return (radioVector*) mQ.get();
57}
58
59GSM::Time VectorQueue::nextTime() const
60{
61 GSM::Time retVal;
62 mLock.lock();
63
64 while (mQ.size()==0)
65 mWriteSignal.wait(mLock);
66
67 retVal = mQ.top()->time();
68 mLock.unlock();
69
70 return retVal;
71}
72
73radioVector* VectorQueue::getStaleBurst(const GSM::Time& targTime)
74{
75 mLock.lock();
76 if ((mQ.size()==0)) {
77 mLock.unlock();
78 return NULL;
79 }
80
81 if (mQ.top()->time() < targTime) {
82 radioVector* retVal = mQ.top();
83 mQ.pop();
84 mLock.unlock();
85 return retVal;
86 }
87 mLock.unlock();
88
89 return NULL;
90}
91
92radioVector* VectorQueue::getCurrentBurst(const GSM::Time& targTime)
93{
94 mLock.lock();
95 if ((mQ.size()==0)) {
96 mLock.unlock();
97 return NULL;
98 }
99
100 if (mQ.top()->time() == targTime) {
101 radioVector* retVal = mQ.top();
102 mQ.pop();
103 mLock.unlock();
104 return retVal;
105 }
106 mLock.unlock();
107
108 return NULL;
109}