Pass number of items and days

This commit is contained in:
Peter L Jones 2020-03-21 18:57:18 +00:00
parent f20d7feab1
commit 32e56ff0c6
6 changed files with 44 additions and 17 deletions

View file

@ -27,11 +27,13 @@
/* Abstract class *************************************************************/ /* Abstract class *************************************************************/
AHistoryGraph::AHistoryGraph() : AHistoryGraph::AHistoryGraph( const int iNumItemsHistory,
const int iMaxDaysHistory ) :
sFileName ( "" ), sFileName ( "" ),
bDoHistory ( false ), bDoHistory ( false ),
vHistoryDataFifo ( NUM_ITEMS_HISTORY ), vHistoryDataFifo ( iNumItemsHistory ),
iNumTicksX ( 0 ), // number of days in history iNumTicksX ( 0 ), // number of days in history
iHistMaxDays ( iMaxDaysHistory ),
BackgroundColor ( "white" ), // background BackgroundColor ( "white" ), // background
FrameColor ( "black" ), // frame FrameColor ( "black" ), // frame
@ -136,7 +138,7 @@ void AHistoryGraph::Update ( )
curDate = QDate::currentDate(); curDate = QDate::currentDate();
// set oldest date to draw // set oldest date to draw
QDate minDate = curDate.addDays ( MAX_DAYS_HISTORY * -1 ); QDate minDate = curDate.addDays ( iHistMaxDays * -1 );
// get oldest date in history // get oldest date in history
QDate oldestDate = curDate.addDays ( 1 ); // one day in the future QDate oldestDate = curDate.addDays ( 1 ); // one day in the future
@ -298,9 +300,10 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
/* JPEG History Graph implementation ******************************************/ /* JPEG History Graph implementation ******************************************/
CJpegHistoryGraph::CJpegHistoryGraph() : CJpegHistoryGraph::CJpegHistoryGraph( const int iNumItemsHistory,
AHistoryGraph(), const int iMaxDaysHistory ) :
PlotPixmap ( 1, 1, QImage::Format_RGB32 ), AHistoryGraph ( iNumItemsHistory, iMaxDaysHistory ),
PlotPixmap ( 1, 1, QImage::Format_RGB32 ),
iAxisFontWeight ( -1 ) iAxisFontWeight ( -1 )
{ {
// scale pixmap to correct size // scale pixmap to correct size
@ -403,9 +406,10 @@ void CJpegHistoryGraph::point ( const unsigned int x, const unsigned int y, cons
/* SVG History Graph implementation *******************************************/ /* SVG History Graph implementation *******************************************/
CSvgHistoryGraph::CSvgHistoryGraph() : CSvgHistoryGraph::CSvgHistoryGraph( const int iNumItemsHistory,
AHistoryGraph(), const int iMaxDaysHistory ) :
svgImage ( "" ), AHistoryGraph ( iNumItemsHistory, iMaxDaysHistory ),
svgImage ( "" ),
svgStreamWriter ( &svgImage ) svgStreamWriter ( &svgImage )
{ {
// set SVG veiwBox to correct size to ensure correct scaling // set SVG veiwBox to correct size to ensure correct scaling

View file

@ -53,7 +53,8 @@ public:
HIT_SERVER_STOP HIT_SERVER_STOP
}; };
AHistoryGraph(); AHistoryGraph( const int iNumItemsHistory,
const int iMaxDaysHistory );
~AHistoryGraph() { } ~AHistoryGraph() { }
void Start ( const QString& sNewFileName ); void Start ( const QString& sNewFileName );
@ -81,6 +82,7 @@ protected:
bool bDoHistory; bool bDoHistory;
CFIFO<SHistoryData> vHistoryDataFifo; CFIFO<SHistoryData> vHistoryDataFifo;
unsigned int iNumTicksX; // Class global, not sure why unsigned int iNumTicksX; // Class global, not sure why
int iHistMaxDays;
QString BackgroundColor; QString BackgroundColor;
QString FrameColor; QString FrameColor;
@ -133,7 +135,8 @@ class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph
Q_OBJECT Q_OBJECT
public: public:
CJpegHistoryGraph(); CJpegHistoryGraph( const int iNumItemsHistory,
const int iMaxDaysHistory );
virtual void Update ( ); virtual void Update ( );
protected: protected:
@ -157,7 +160,8 @@ class CSvgHistoryGraph : public QObject, virtual public AHistoryGraph
Q_OBJECT Q_OBJECT
public: public:
CSvgHistoryGraph(); CSvgHistoryGraph( const int iNumItemsHistory,
const int iMaxDaysHistory );
virtual void Update(); virtual void Update();
protected: protected:

View file

@ -198,6 +198,8 @@ void CHighPrecisionTimer::run()
// CServer implementation ****************************************************** // CServer implementation ******************************************************
CServer::CServer ( const int iNewMaxNumChan, CServer::CServer ( const int iNewMaxNumChan,
const int iNumItemsHistory,
const int iMaxDaysHistory,
const QString& strLoggingFileName, const QString& strLoggingFileName,
const quint16 iPortNumber, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
@ -212,6 +214,7 @@ CServer::CServer ( const int iNewMaxNumChan,
const ELicenceType eNLicenceType ) : const ELicenceType eNLicenceType ) :
iMaxNumChannels ( iNewMaxNumChan ), iMaxNumChannels ( iNewMaxNumChan ),
Socket ( this, iPortNumber ), Socket ( this, iPortNumber ),
Logging ( iNumItemsHistory, iMaxDaysHistory ),
JamRecorder ( strRecordingDirName ), JamRecorder ( strRecordingDirName ),
bEnableRecording ( !strRecordingDirName.isEmpty() ), bEnableRecording ( !strRecordingDirName.isEmpty() ),
bWriteStatusHTMLFile ( false ), bWriteStatusHTMLFile ( false ),

View file

@ -119,6 +119,8 @@ class CServer : public QObject
public: public:
CServer ( const int iNewMaxNumChan, CServer ( const int iNewMaxNumChan,
const int iNumItemsHistory,
const int iMaxDaysHistory,
const QString& strLoggingFileName, const QString& strLoggingFileName,
const quint16 iPortNumber, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,

View file

@ -25,6 +25,15 @@
#include "serverlogging.h" #include "serverlogging.h"
// Server logging -------------------------------------------------------------- // Server logging --------------------------------------------------------------
CServerLogging::CServerLogging( const int iNumItemsHistory,
const int iMaxDaysHistory ) :
JpegHistoryGraph ( iNumItemsHistory, iMaxDaysHistory ),
SvgHistoryGraph ( iNumItemsHistory, iMaxDaysHistory ),
bDoLogging ( false ),
File ( DEFAULT_LOG_FILE_NAME )
{
}
CServerLogging::~CServerLogging() CServerLogging::~CServerLogging()
{ {
// close logging file of open // close logging file of open
@ -82,8 +91,8 @@ void CServerLogging::AddServerStopped()
*this << strLogStr; // in log file *this << strLogStr; // in log file
// add element to history and update on server stop // add element to history and update on server stop
JpegHistoryGraph.Add ( QDateTime::currentDateTime(), CJpegHistoryGraph::HIT_SERVER_STOP ); JpegHistoryGraph.Add ( QDateTime::currentDateTime(), AHistoryGraph::HIT_SERVER_STOP );
SvgHistoryGraph.Add ( QDateTime::currentDateTime(), CJpegHistoryGraph::HIT_SERVER_STOP ); SvgHistoryGraph.Add ( QDateTime::currentDateTime(), AHistoryGraph::HIT_SERVER_STOP );
JpegHistoryGraph.Update(); JpegHistoryGraph.Update();
SvgHistoryGraph.Update(); SvgHistoryGraph.Update();
@ -140,7 +149,7 @@ void CServerLogging::ParseLogFile ( const QString& strFileName )
if ( strAddress.isEmpty() ) if ( strAddress.isEmpty() )
{ {
// server stop // server stop
JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP ); JpegHistoryGraph.Add ( curDateTime, AHistoryGraph::HIT_SERVER_STOP );
SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP ); SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP );
} }
else else

View file

@ -38,8 +38,9 @@
class CServerLogging class CServerLogging
{ {
public: public:
CServerLogging() : bDoLogging ( false ), CServerLogging( const int iNumItemsHistory,
File ( DEFAULT_LOG_FILE_NAME ) {} const int iMaxDaysHistory );
virtual ~CServerLogging(); virtual ~CServerLogging();
void Start ( const QString& strLoggingFileName ); void Start ( const QString& strLoggingFileName );
@ -56,4 +57,8 @@ protected:
CSvgHistoryGraph SvgHistoryGraph; CSvgHistoryGraph SvgHistoryGraph;
bool bDoLogging; bool bDoLogging;
QFile File; QFile File;
private:
int iHistNumItems;
int iHistMaxDays;
}; };