/*************************************************************************\
* "$RCSfile: CCpuLoad.hpp,v $"                                            *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2011-09-07 16:29:34 $                      *
*     by                $Author: goebel $
*     Revision        : $Revision: 1.5 $                                  *
\*************************************************************************/
/*! \file CCpuLoad.hpp
*	\brief Header CCpuLoad Class
*	\author (c) 2007 - 2013 IMAGO Technologies GmbH
*
*	$Revision: 1.5 $
*	$Date: 2011-09-07 16:29:34 $
**************************************************************************/

#ifndef _CCPULOAD_
#define _CCPULOAD_

/*************************************************************************/
/*! @brief CPU load class

	Management of CPU load, frame rate, ...
**************************************************************************/
class CCpuLoad
{
private:
	CCpuLoad();
	static CCpuLoad *m_pThis;

public:
	static CCpuLoad *CreateInstance();
	//! Gets CCpuLoad instance.
	static CCpuLoad *GetInstance() { return m_pThis; };
	static void DisposeInstance();

	static void CpuLoadTask();
	void DrawCpuLoad(CIMAGE *pImage, int xOff, int yOff);
	void DrawTemperature(CIMAGE *pImage, int xOff, int yOff);
	void DrawFrame(CIMAGE *pImage, int xOff, int yOff);

	//! Returns current CPU load.
	int GetCPULoad() const
		{ return m_CpuLoadBuffer[CPUMAXBUFFER - 1]; }
	//! Returns current camera frame rate.
	int GetCameraFrameRate() const
		{ return m_FrameCountBuffer[FRAMEMAXBUFFER - 1]; }
	//! Returns current display frame rate.
	int GetDisplayFrameRate() const
		{ return m_DisplayCountBuffer[FRAMEMAXBUFFER - 1]; }
	//! Returns current temperature.
	int GetTemperature() const
		{ return m_TemperatureBuffer[TEMPMAXBUFFER - 1]; }
	//! Increments frame counter.
	static void IncrementFrameCounter()
		{ m_FrameCounter++; }
	//! Increments display counter.
	static void IncrementDisplayCounter()
		{ m_DisplayCounter++; }

protected:
	//! Constants
	enum eCONST
	{
		CPUMAXBUFFER = 100,		//!< Size of CPU load history
		TEMPMAXBUFFER = 100,	//!< Size of temperature history
		FRAMEMAXBUFFER = 100,	//!< Size of fps history
		YPOS = 112,				//!< y position
		TEMPCYC = 10			//!< Cycles for temperature measurement
	};

	void CpuLoadLoop();

	static int m_FrameCounter;
	static int m_DisplayCounter;

	int m_CpuLoadBuffer[CPUMAXBUFFER];			//!< Buffer for CPU load history
	char m_TemperatureBuffer[TEMPMAXBUFFER];	//!< Buffer for temperature history
	short m_FrameCountBuffer[FRAMEMAXBUFFER];	//!< Buffer for fps history (camera)
	short m_DisplayCountBuffer[FRAMEMAXBUFFER];	//!< Buffer for fps history (display)
};

#endif

/*************************************************************************/
