ITS
RepetitionPacketBuffer.cpp
Go to the documentation of this file.
2 
3 static QVector<RepetitionPacketEntry> m_repetitionPacketBuffer;
4 
6 {
7  m_mutex = new QMutex;
8 }
9 
11 {
12  if(gnDR.maximumRepetitionTime == 0 || gnDR.repetitionInterval == 0)
13  return;
14 
15  printf("RPB add toLOCK\n");
16  m_mutex->lock();
17  printf("RPB add locked\n");
19  QObject::connect(rpe, SIGNAL(isOver()), this, SLOT(erase()));
20  QObject::connect(rpe, SIGNAL(sendPacket(gnDataRequest_t)), this, SLOT(sendPacketIndication(gnDataRequest_t)));
21  QObject::connect(this, SIGNAL(killAll()), rpe, SLOT(kill()));
22  m_repetitionPacketBuffer.push_back(rpe);
23  printf("RPB add toUNLOCK\n");
24  m_mutex->unlock();
25  printf("RPB add UNLOCKED\n");
26 
27  QThread* th = new QThread;
28  rpe->moveToThread(th);
29  QObject::connect(th, SIGNAL(started()), rpe, SLOT(execute()));
30  th->start();
31 }
32 
34 {
35  emit killAll();
36  printf("RPB clear toLOCK\n");
37  m_mutex->lock();
38  printf("RPB clear locked\n");
40  printf("RPB clear toUNLOCK\n");
41  m_mutex->unlock();
42  printf("RPB clear UNLOCKED\n");
43 }
44 
46 {
47  int j = 0;
48  printf("RPB erase toLOCK\n");
49  m_mutex->lock();
50  printf("RPB erase locked\n");
51  for(QVector<RepetitionPacketEntry*>::Iterator i = m_repetitionPacketBuffer.begin();j < m_repetitionPacketBuffer.size(); ++i, j++)
52  if(!(*i)->timer()->isActive())
53  m_repetitionPacketBuffer.erase(i);
54  printf("RPB erase toUNLOCK\n");
55  m_mutex->unlock();
56  printf("RPB erase UNLOCKED\n");
57 }
58 
60 {
61  emit sendPacketToGn(packet);
62 }
gnDataRequest_t structure is the GN data request definition.
Definition: GNDataRequest.h:46
quint16 * repetitionInterval
Definition: GNDataRequest.h:56
void addPacket(gnDataRequest_t gnDR)
addPacket Add packet to the buffer.
quint16 * maximumRepetitionTime
Definition: GNDataRequest.h:57
void clear()
clear Clear the buffer.
QVector< RepetitionPacketEntry * > m_repetitionPacketBuffer
RepetitionPacketBuffer()
RepetitionPacketBuffer Default constructor.
void killAll()
killAll Signal used to kill all the entries.
void erase()
erase Slot used to erase entry.
static QVector< RepetitionPacketEntry > m_repetitionPacketBuffer
Buffer used to repeat packet.
void sendPacketToGn(gnDataRequest_t packet)
sendPacketToGn Signal used to send packet.
void sendPacketIndication(gnDataRequest_t packet)
sendPacketIndication Slot used to notify of sending packet.