#ifndef CBUFFER_H
#define CBUFFER_H

#include "Applications.h"

#define CBUFFER_SLOTS_COUNT	5
#define CBUFFER_SLOT_LENGTH 2000

//Struktura uchovava informace o datech ve fronte
typedef struct CBUFFER_DATA
{
	unsigned char data[CBUFFER_SLOT_LENGTH];	//Vlastni data k odeslani	
	OS_CONNECT target;							//Cil pro odeslani dat
	ANSWER completed;							//Info, jestli byla data zpracovana
}CBUFFER_DATA;



/****************************************************************************
	Trida kruhoveho bufferu pro uchovani dat k odeslani pomoci seriovych portu.
	Odeslana data jsou oznacena a mohou byt prepsana dalsimi daty

*****************************************************************************/
class CBuffer
{
private:
	CBUFFER_DATA dataBuff[CBUFFER_SLOTS_COUNT];						//Zasobnik s daty
	char dataTop;													//index dat, ktera maji byt odeslana
	char dataCurrent;												//index pozice, kam mohou byt vlozena dalsi data
	
public:	
	CBuffer(void);													//Konstruktor
	ANSWER InsertData(OS_CONNECT target, unsigned char * input);	//VLozeni dat
	ANSWER SendNextData(void);										//Predani dat nizsi vrstve - ovladaci UARTu
	ANSWER DataPending(void);										//vraci flagy o stavu bufferu
	ANSWER DataFull(void);
	void Init();													//Inicializace
	~CBuffer(void);													//Destruktor
};



#endif