#pragma once
#include "ECGFile.h"
#include "includes.h"


#define SHOW_BUFF_LENGTH		(1024*64)
#define CAPTURE_BUFF_LENGTH		(250*10)

#define ECG_LEAD_OFF_V			(1<<3)
#define ECG_LEAD_OFF_RA			(1<<2)
#define ECG_LEAD_OFF_LA			(1<<1)
#define ECG_LEAD_OFF_LL			(1<<0)

struct ECG_PATTERN
{
	UINT8 num;
	UINT8 data[5];
};

class CECGData
{
public:
	CECGData();
	~CECGData();
	int GetPrintData(struct GET_ECG_DATA *st);
	int GetSaveData(struct GET_ECG_DATA *st);
	int GetShowData(struct GET_ECG_DATA *st);
	
	int AddData2ShowBuf(struct GET_ECG_DATA *st);
	int AddData2SaveBuf(struct GET_ECG_DATA *st);
	int AddData2PrintBuf(struct GET_ECG_DATA *st);

	int GetRespShowData(struct GET_RESP_DATA *st);
	int AddData2RespShowBuf(struct GET_RESP_DATA *st);

	int GetOXYShowData(struct GET_OXY_DATA *st);
	int Add_PlethWave(UINT8 data);

	void copy_print_data(struct GET_ECG_DATA *st, int length);
	int ResetShowBuff();
	int ResetSaveBuff();
	int ResetPrintBuff();

	//心电导联连接和信号信息
	int Add_Lead_STS(UINT8 leadoff,UINT8 overload);
	int Get_Lead_STS(UINT8 *leadoff, UINT8 *overload);
	//心律
	int Add_HR(int hr);
	int Get_HR(int *hr);
	//心律
	int Add_Beat(int b);
	int Get_Beat(int *b);
	//ST值
	int Add_ST(int st1,int st2);
	int Get_ST(int *st1, int *st2);
	//ST 模板波形
	int Add_Pattern(struct ECG_PATTERN *st);
	

	//每个通道显示数据
	int *m_i32ShowBuf[12];
	int m_i32ShowDateW, m_i32ShowDateR, m_i32ShowDateLength;
	CCriticalSection g_CSECGDataShow;
	int m_i32HR, m_i32ST1, m_i32ST2;
	int m_i32LeadOff, m_i32LeadOverLoad;
	int m_i32PVCs;
	int m_i32Beat;


	//每个通道要保存的数据
	int *m_i32SaveData[12];
	int m_i32SaveDateW, m_i32SaveDateR, m_i32SaveDateLength;
	CCriticalSection g_CSECGDataSave;

	int *m_i32RespShowBuf;
	int m_i32RespShowDateW, m_i32RespShowDateR, m_i32RespShowDateLength;
	CCriticalSection g_CSRespDataShow;


	UINT16 u16PR;
	UINT16 u16Finger;
	UINT16 u16Beat;
	UINT16 u16Search;
	UINT16 u16Probe;
	UINT16 u16Bar;
	UINT16 u16Signal;

	int *m_i32PlethShowBuf;
	int m_i32PlethShowDateW, m_i32PlethShowDateR, m_i32PlethShowDateLength;
	CCriticalSection g_CSOxyDataShow;

	struct GET_ECG_DATA m_stGET_ECG_DATA;
	

	//每个通道要保存的打印的数据
	int *m_i32PrintData[12];
	int m_i32PrintDateW, m_i32PrintDateR, m_i32PrintDateLength;
	CCriticalSection g_CSECGDataPrint;
};

