#ifndef DOPRINT_H_
#define DOPRINT_H_

#include "gvalue.h"
#include "record.h"

//dAddrSdram_PrintBuf

#define PrintEntry_Size	128
#define PrintBuf_Count	8000	

typedef union{
	unsigned int D32[32];
	unsigned char D8[PrintEntry_Size];
	struct{
		char Text[124];
		unsigned int Len;
	}Body;
}TMsgEntry;

typedef union{
	char Text[3][64];
	struct{
		char DateAddr[64];
		char Msg[64];
		char Dscp[64];
	}body;
}TPrintText;

class TDoPrint{
	public:
		TRecordEntry EntryTmp;
	
		unsigned char State;
		TPrintText PrintText;
	
		struct{
			int WriteInx;
			int ReadInx;
			unsigned char Addr;
			TMsgEntry wEntry[3];
			TMsgEntry rEntry;
			int wEntryTextLen;
		}Buf;
		struct{
			int AllTextCount;
			int sCount;
			int DoingInx;
			int oSequence;
		}Sections;
		
		int IsTryGetState;
		
		unsigned char RecData[12];
		TDateTimeBytes DateTimeCovered;
	public:
		TDoPrint(){};
		void Init();
		void ReInit();
			
		int GetPrintTextEndPst(char * pText);
		unsigned int GetPrintTextLen(char * pText);
		void StrcatText(char * pSrc,char * pAdd);
			
		void FillTextWithDateTime();
		void FillCtlNum();
		void FillCtlNumNoSpace();
		void FillTextWithPath();
		void FillTextWithDType();

		void FillText4PowerOff();
		void FillText4PowerUp();
		void FillText4MsgReset();
		void FillText4MsgMute();
		void FillText4MsgMask();
		void FillText4MsgUnMask();
		void FillText4MsgDateTimeSet();
		void FillText4AllowSet();
		void FillText4AlramSetOnOff();
		void FillText4BusPadOn();
		void FillText4BusPadOff();
		void FillText4DirectPadManualAllowOn();
		void FillText4DirectPadManualAllowOff();
		void FillText4DirectPadNodeOn();
		void FillText4DirectPadNodeOff();
		void FillText4UserCheck();
		void FillText4LinkageGo(unsigned char Data1);
		void AddOnFaultMsg(void);
		void OperateAddConfirmMsg(int NeedDrawCfg);
		
		void FillOperateText(TRecordCommon OperateEntryTmp, int aForce =0);
		void FillFaultText(TRecordCommon FaultEntryTmp, int aForce =0);
		void FillLinkageText(TRecordCommon LinkageEntryTmp, int aForce =0);
		void FillFireText(TRecordCommon FireEntryTmp, int aForce =0);
		void FillSvText(TRecordCommon SvEntryTmp, int aForce =0);
		
		void GetDescpEntry(TRecordCommon DescpEntryTmp);
		void DescpTextBufInsert(TRecordCommon aEntryTmp, unsigned int Descp);
	
		void ClearPrintText();
		void Print();
		void DescpTextBufInsertByAssign(char *p);
		void PrintHistory(int MsgType, TRecordCommon aEntryTmp, char *pDescp);
	
		void TryGetState();
		unsigned int GetPrintState();
		
		void SetBufInsertSequence();
		void BufInsert();
		void SetBufInsert();
		void PrintSection();
		void BufFillPrintingBuf();
		void oProcess();
		void iProcess();
			
		void Task10Ms();
};











#endif
