97 lines
1.7 KiB
C++
97 lines
1.7 KiB
C++
// **************************************************************************
|
|
//
|
|
// @RDE_HEADER@
|
|
//
|
|
// **************************************************************************
|
|
//
|
|
// $HeadURL$
|
|
// $LastChangedBy$
|
|
// $LastChangedDate$
|
|
// $LastChangedRevision$
|
|
//
|
|
// Implementation of the Class PrtCnvRadioTrafficThread
|
|
// **************************************************************************
|
|
#pragma once
|
|
|
|
#include "PrtCnvThread.hpp"
|
|
#include "PrtCnvRadioThread.hpp"
|
|
#include <QtCore/QMap>
|
|
#include <QtCore/QMutex>
|
|
|
|
namespace PrtCnv
|
|
{
|
|
/**
|
|
* This class handles the traffic counting for the
|
|
* incoming radio data
|
|
*/
|
|
class PrtCnvRadioTrafficThread final : public PrtCnvThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit PrtCnvRadioTrafficThread(PrtCnvThreadStarter* a_parent);
|
|
|
|
/**
|
|
* A new telegram arrived.
|
|
*/
|
|
void newTelegramArrived(unsigned int size);
|
|
|
|
/**
|
|
* Start the thread handling
|
|
*/
|
|
int32_t start() override;
|
|
|
|
protected Q_SLOTS:
|
|
/**
|
|
* Timeout to recalculate traffic load
|
|
*/
|
|
void onCalculateTrafficLoad();
|
|
|
|
/**
|
|
* Timeout to throw away old data
|
|
*/
|
|
void onCleanupTimeout();
|
|
|
|
protected:
|
|
/**
|
|
* The current traffic load
|
|
*/
|
|
PrtCnvRadioThread::E_TrafficLoad m_receiveLoad;
|
|
|
|
/**
|
|
* Full load
|
|
*/
|
|
unsigned int m_fullLoad;
|
|
|
|
/**
|
|
* High load
|
|
*/
|
|
unsigned int m_highLoad;
|
|
|
|
/**
|
|
* Hysterese
|
|
*/
|
|
unsigned int m_hystLoad;
|
|
|
|
/**
|
|
* Timeout for recalculation
|
|
*/
|
|
int m_calcTimeout;
|
|
|
|
/**
|
|
* Timeout until data is thrown away
|
|
*/
|
|
int m_cleanupTimeout;
|
|
|
|
/**
|
|
* Data access mutex
|
|
*/
|
|
QMutex m_mutex;
|
|
|
|
/**
|
|
* map<time, nTelegrams>
|
|
*/
|
|
QMap<time_t, unsigned int> m_data;
|
|
QMap<time_t, unsigned int> m_telegrams;
|
|
};
|
|
} // namespace PrtCnv
|