code style changes
This commit is contained in:
parent
4deae974c3
commit
d605ef6f9b
3 changed files with 132 additions and 108 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "historygraph.h"
|
#include "historygraph.h"
|
||||||
|
|
||||||
|
|
||||||
/* Abstract class *************************************************************/
|
/* Abstract class *************************************************************/
|
||||||
AHistoryGraph::AHistoryGraph() :
|
AHistoryGraph::AHistoryGraph() :
|
||||||
sFileName ( "" ),
|
sFileName ( "" ),
|
||||||
|
@ -75,6 +76,7 @@ void AHistoryGraph::Start ( const QString& sNewFileName )
|
||||||
{
|
{
|
||||||
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
||||||
tsConsoleStream << QString ( "AHistoryGraph::Start ( %1 )" ).arg ( sNewFileName ) << endl; // on console
|
tsConsoleStream << QString ( "AHistoryGraph::Start ( %1 )" ).arg ( sNewFileName ) << endl; // on console
|
||||||
|
|
||||||
if ( !sNewFileName.isEmpty() )
|
if ( !sNewFileName.isEmpty() )
|
||||||
{
|
{
|
||||||
// save file name
|
// save file name
|
||||||
|
@ -136,6 +138,7 @@ void AHistoryGraph::Update ( )
|
||||||
// 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
|
||||||
const int iNumItemsForHistory = vHistoryDataFifo.Size();
|
const int iNumItemsForHistory = vHistoryDataFifo.Size();
|
||||||
|
|
||||||
for ( i = 0; i < iNumItemsForHistory; i++ )
|
for ( i = 0; i < iNumItemsForHistory; i++ )
|
||||||
{
|
{
|
||||||
// only use valid dates
|
// only use valid dates
|
||||||
|
@ -190,6 +193,7 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
|
||||||
|
|
||||||
// grid (ticks) for x-axis
|
// grid (ticks) for x-axis
|
||||||
dayXSpace = static_cast<double> ( gridFrameWidth ) / ( iNumTicksX + 1 );
|
dayXSpace = static_cast<double> ( gridFrameWidth ) / ( iNumTicksX + 1 );
|
||||||
|
|
||||||
for ( i = 0; i < static_cast<int> ( iNumTicksX ); i++ )
|
for ( i = 0; i < static_cast<int> ( iNumTicksX ); i++ )
|
||||||
{
|
{
|
||||||
int iBottomExtraTickLen = 0;
|
int iBottomExtraTickLen = 0;
|
||||||
|
@ -220,6 +224,7 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
|
||||||
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
|
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
|
||||||
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
|
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
|
||||||
iYSpace = gridFrameHeight / ( iNumTicksY - 1 );
|
iYSpace = gridFrameHeight / ( iNumTicksY - 1 );
|
||||||
|
|
||||||
for ( i = 0; i < ( static_cast<int> ( iNumTicksY ) - 1 ); i++ )
|
for ( i = 0; i < ( static_cast<int> ( iNumTicksY ) - 1 ); i++ )
|
||||||
{
|
{
|
||||||
const int iCurY = gridFrameY + iYSpace * ( i + 1 );
|
const int iCurY = gridFrameY + iYSpace * ( i + 1 );
|
||||||
|
@ -258,6 +263,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
|
||||||
int curPointX = gridFrameX + static_cast<int> ( dayXSpace * ( static_cast<signed> ( iNumTicksX ) + iXAxisOffs ) );
|
int curPointX = gridFrameX + static_cast<int> ( dayXSpace * ( static_cast<signed> ( iNumTicksX ) + iXAxisOffs ) );
|
||||||
int curPointY = gridFrameY + static_cast<int> ( static_cast<double> (
|
int curPointY = gridFrameY + static_cast<int> ( static_cast<double> (
|
||||||
gridFrameHeight ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs );
|
gridFrameHeight ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs );
|
||||||
|
|
||||||
QString curPointColour = MarkerNewColor;
|
QString curPointColour = MarkerNewColor;
|
||||||
int curPointSize = iMarkerSizeNewCon;
|
int curPointSize = iMarkerSizeNewCon;
|
||||||
|
|
||||||
|
@ -281,6 +287,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
|
||||||
point ( curPointX - curPointSize / 2, curPointY - curPointSize / 2, curPointSize, curPointColour );
|
point ( curPointX - curPointSize / 2, curPointY - curPointSize / 2, curPointSize, curPointColour );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* JPEG History Graph implementation ******************************************/
|
/* JPEG History Graph implementation ******************************************/
|
||||||
CJpegHistoryGraph::CJpegHistoryGraph() :
|
CJpegHistoryGraph::CJpegHistoryGraph() :
|
||||||
AHistoryGraph(),
|
AHistoryGraph(),
|
||||||
|
@ -302,10 +309,17 @@ CJpegHistoryGraph::CJpegHistoryGraph() :
|
||||||
// Black = 87 // 900
|
// Black = 87 // 900
|
||||||
bool ok;
|
bool ok;
|
||||||
int weight = axisFontWeight.toInt( &ok );
|
int weight = axisFontWeight.toInt( &ok );
|
||||||
|
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
if (!QString("normal").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { iAxisFontWeight = 50; }
|
if ( !QString ( "normal" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
|
||||||
else if (!QString("bold").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { weight = 75; }
|
{
|
||||||
|
iAxisFontWeight = 50;
|
||||||
|
}
|
||||||
|
else if ( !QString ( "bold" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
|
||||||
|
{
|
||||||
|
weight = 75;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -324,6 +338,7 @@ CJpegHistoryGraph::CJpegHistoryGraph() :
|
||||||
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
||||||
tsConsoleStream << "CJpegHistoryGraph" << endl; // on console
|
tsConsoleStream << "CJpegHistoryGraph" << endl; // on console
|
||||||
|
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerDailyUpdate() ) );
|
this, SLOT ( OnTimerDailyUpdate() ) );
|
||||||
|
@ -377,6 +392,7 @@ void CJpegHistoryGraph::point ( const unsigned int x, const unsigned int y, cons
|
||||||
PlotPainter.drawPoint ( x, y );
|
PlotPainter.drawPoint ( x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* SVG History Graph implementation *******************************************/
|
/* SVG History Graph implementation *******************************************/
|
||||||
CSvgHistoryGraph::CSvgHistoryGraph() :
|
CSvgHistoryGraph::CSvgHistoryGraph() :
|
||||||
AHistoryGraph(),
|
AHistoryGraph(),
|
||||||
|
@ -398,6 +414,7 @@ CSvgHistoryGraph::CSvgHistoryGraph() :
|
||||||
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
||||||
tsConsoleStream << "CSvgHistoryGraph" << endl; // on console
|
tsConsoleStream << "CSvgHistoryGraph" << endl; // on console
|
||||||
|
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerDailyUpdate() ) );
|
this, SLOT ( OnTimerDailyUpdate() ) );
|
||||||
|
@ -425,7 +442,9 @@ void CSvgHistoryGraph::Save ( const QString sFileName )
|
||||||
svgStreamWriter.writeEndDocument();
|
svgStreamWriter.writeEndDocument();
|
||||||
|
|
||||||
QFile outf ( sFileName );
|
QFile outf ( sFileName );
|
||||||
if (!outf.open(QFile::WriteOnly)) {
|
|
||||||
|
if ( !outf.open ( QFile::WriteOnly ) )
|
||||||
|
{
|
||||||
throw std::runtime_error ( ( sFileName + " could not be written. Aborting." ).toStdString() );
|
throw std::runtime_error ( ( sFileName + " could not be written. Aborting." ).toStdString() );
|
||||||
}
|
}
|
||||||
QTextStream out ( &outf );
|
QTextStream out ( &outf );
|
||||||
|
|
|
@ -42,10 +42,12 @@
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QXmlStreamAttributes>
|
#include <QXmlStreamAttributes>
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// number of history items to store
|
// number of history items to store
|
||||||
#define NUM_ITEMS_HISTORY 600
|
#define NUM_ITEMS_HISTORY 600
|
||||||
|
|
||||||
|
|
||||||
/* Interface ******************************************************************/
|
/* Interface ******************************************************************/
|
||||||
class AHistoryGraph
|
class AHistoryGraph
|
||||||
{
|
{
|
||||||
|
@ -130,6 +132,7 @@ protected:
|
||||||
QTimer TimerDailyUpdate;
|
QTimer TimerDailyUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Implementations ************************************************************/
|
/* Implementations ************************************************************/
|
||||||
class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph
|
class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ void CServerLogging::Start ( const QString& strLoggingFileName )
|
||||||
{
|
{
|
||||||
// open file
|
// open file
|
||||||
File.setFileName ( strLoggingFileName );
|
File.setFileName ( strLoggingFileName );
|
||||||
|
|
||||||
if ( File.open ( QIODevice::Append | QIODevice::Text ) )
|
if ( File.open ( QIODevice::Append | QIODevice::Text ) )
|
||||||
{
|
{
|
||||||
bDoLogging = true;
|
bDoLogging = true;
|
||||||
|
@ -135,11 +136,12 @@ void CServerLogging::ParseLogFile ( const QString& strFileName )
|
||||||
|
|
||||||
// check if server stop or new client connection
|
// check if server stop or new client connection
|
||||||
QString strAddress = strlistCurLine.at ( 2 ).trimmed();
|
QString strAddress = strlistCurLine.at ( 2 ).trimmed();
|
||||||
|
|
||||||
if ( strAddress.isEmpty() )
|
if ( strAddress.isEmpty() )
|
||||||
{
|
{
|
||||||
// server stop
|
// server stop
|
||||||
JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
|
JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
|
||||||
SvgHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
|
SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue