#include "stdafx.h"
#include "ShowAlm.h"


CShowAlm::CShowAlm()
{
}


CShowAlm::~CShowAlm()
{
}


int CShowAlm::Add_ECG_Alm(INT	i32Type, INT	i32SubType, TCHAR * cTime, INT i32AlmThrd, INT	i32Result)
{
	struct _SHOW_ALM_ alm;

	alm.i32Type = i32Type;
	alm.i32SubType = i32SubType; 
	wcscpy_s(alm.cAlm, 32, n_cHRAlmL);
	wcscpy_s(alm.cTime, 32, cTime);
	alm.i32AlmThrd = i32AlmThrd;
	alm.i32Result = i32Result;

//	if (i32SubType == ALM_ECG_HR)

	m_ECGAlm.push_back(alm);
	return 0;
}



int CShowAlm::Get_ECG_Alm(struct _SHOW_ALM_ *alm, INT num)
{
	
	list<struct _SHOW_ALM_>::iterator i;
	struct _SHOW_ALM_ *a_alm;
	if (m_ECGAlm.size())
	{
		i = m_ECGAlm.begin();
		
		alm->i32Type = i->i32Type;
		alm->i32SubType = i->i32SubType;
		wcscpy_s(alm->cAlm, 32, i->cAlm);
		wcscpy_s(alm->cTime, 32, i->cTime);
		alm->i32AlmThrd = i->i32AlmThrd;
		alm->i32Result = i->i32Result;


		return 0;
	}
	
	
	return 1;
}



int CShowAlm::Del_ECG_Alm(INT num)
{
	list<struct _SHOW_ALM_>::iterator i;
	int j = 0;
	if (m_ECGAlm.size())
	{
		for (i = m_ECGAlm.begin(); (i != m_ECGAlm.end()) && (j <= num); i++)
		{
			if (j == num)
			{
				m_ECGAlm.erase(i);
				return 0;
			}
			j++;
		}
		
	}

	return 1;
}


int CShowAlm::Add_Resp_Temp_Alm(INT	i32Type, INT	i32SubType, TCHAR * cTime, INT i32AlmThrd, INT	i32Result)
{
	struct _SHOW_ALM_ alm;

	alm.i32Type = i32Type;
	alm.i32SubType = i32SubType;
	wcscpy_s(alm.cTime, 32, cTime);
	alm.i32AlmThrd = i32AlmThrd;
	alm.i32Result = i32Result;
	m_RespTempAlm.push_back(alm);
	return 0;
}



int CShowAlm::Get_Resp_Temp_Alm(struct _SHOW_ALM_ *alm, INT num)
{

	list<struct _SHOW_ALM_>::iterator i;
	struct _SHOW_ALM_ *a_alm;
	if (m_RespTempAlm.size())
	{
		i = m_RespTempAlm.begin();

		alm->i32Type = i->i32Type;
		alm->i32SubType = i->i32SubType;
		wcscpy_s(alm->cTime, 32, i->cTime);
		alm->i32AlmThrd = i->i32AlmThrd;
		alm->i32Result = i->i32Result;


		return 0;
	}


	return 1;
}



int CShowAlm::Del_Resp_Temp_Alm(INT num)
{
	list<struct _SHOW_ALM_>::iterator i;
	int j = 0;
	if (m_RespTempAlm.size())
	{
		for (i = m_RespTempAlm.begin(); (i != m_RespTempAlm.end()) && (j <= num); i++)
		{
			if (j == num)
			{
				m_RespTempAlm.erase(i);
				return 0;
			}
			j++;
		}

	}

	return 1;
}

int CShowAlm::Add_Oxy_NIBP_Alm(INT	i32Type, INT	i32SubType, TCHAR * cTime, INT i32AlmThrd, INT	i32Result)
{
	struct _SHOW_ALM_ alm;

	alm.i32Type = i32Type;
	alm.i32SubType = i32SubType;
	wcscpy_s(alm.cTime, 32, cTime);
	alm.i32AlmThrd = i32AlmThrd;
	alm.i32Result = i32Result;
	m_OxyNIBPAlm.push_back(alm);
	return 0;
}



int CShowAlm::Get_Oxy_NIBP_Alm(struct _SHOW_ALM_ *alm, INT num)
{

	list<struct _SHOW_ALM_>::iterator i;
	struct _SHOW_ALM_ *a_alm;
	if (m_OxyNIBPAlm.size())
	{
		i = m_OxyNIBPAlm.begin();

		alm->i32Type = i->i32Type;
		alm->i32SubType = i->i32SubType;
		wcscpy_s(alm->cTime, 32, i->cTime);
		alm->i32AlmThrd = i->i32AlmThrd;
		alm->i32Result = i->i32Result;


		return 0;
	}


	return 1;
}



int CShowAlm::Del_Oxy_NIBP_Alm(INT num)
{
	list<struct _SHOW_ALM_>::iterator i;
	int j = 0;
	if (m_OxyNIBPAlm.size())
	{
		for (i = m_OxyNIBPAlm.begin(); (i != m_OxyNIBPAlm.end()) && (j <= num); i++)
		{
			if (j == num)
			{
				m_OxyNIBPAlm.erase(i);
				return 0;
			}
			j++;
		}

	}

	return 1;
}


int CShowAlm::Add_AirOxy_Alm(INT	i32Type, INT	i32SubType, TCHAR * cTime, INT i32AlmThrd, INT	i32Result)
{
	struct _SHOW_ALM_ alm;

	alm.i32Type = i32Type;
	alm.i32SubType = i32SubType;
	wcscpy_s(alm.cTime, 32, cTime);
	alm.i32AlmThrd = i32AlmThrd;
	alm.i32Result = i32Result;
	m_AirOxyAlm.push_back(alm);
	return 0;
}




int CShowAlm::Get_AirOxy_Alm(struct _SHOW_ALM_ *alm, INT num)
{

	list<struct _SHOW_ALM_>::iterator i;
	struct _SHOW_ALM_ *a_alm;
	if (m_AirOxyAlm.size())
	{
		i = m_AirOxyAlm.begin();

		alm->i32Type = i->i32Type;
		alm->i32SubType = i->i32SubType;
		wcscpy_s(alm->cTime, 32, i->cTime);
		alm->i32AlmThrd = i->i32AlmThrd;
		alm->i32Result = i->i32Result;


		return 0;
	}


	return 1;
}



int CShowAlm::Del_AirOxy_Alm(INT num)
{
	list<struct _SHOW_ALM_>::iterator i;
	int j = 0;
	if (m_AirOxyAlm.size())
	{
		for (i = m_AirOxyAlm.begin(); (i != m_AirOxyAlm.end()) && (j <= num); i++)
		{
			if (j == num)
			{
				m_AirOxyAlm.erase(i);
				return 0;
			}
			j++;
		}

	}

	return 1;
}
