/**************************************************************************
<MODULE NAME>
<FILENAME></FILENAME>
<HISTORY>
	<MODIFICATION>
		<DATE></DATE>
		<AUTHOR></AUTHOR>
		< DESCRIPTION>
		< /DESCRIPTION>
	</MODIFICATION>
</HISTORY>
</MODULE NAME>
**************************************************************************/


/**************************************************************************
INCLUDE FILE
**************************************************************************/
#include <time.h>
#include "..\comp\AlarmBox\AlarmBo.h"

/**************************************************************************
LOCAL VARIABLES
Always start with « static »-keyword
**************************************************************************/
/*
<VARIABLES>
	<NAME>m_hInst</NAME>
	<TYPE>CAlarmBox*</TYPE>
	<DESCRIPTION>
        Contien l'instance unique pour tout le programme sur la classe
        CAlarmBox.
	</DESCRIPTION>
	<DEFAULT_VALUE>NULL</DEFAULT_VALUE>
</VARIABLES>
*/
CAlarmBox* CAlarmBox::m_hInst = NULL;
/**************************************************************************
<FUNCTION>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
</PARAMETERS>
<RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
</RETURNS>
</FUNCTION>
**************************************************************************/
CAlarmBox::CAlarmBox()
{
	m_absStatus = eNotConnected;
	m_iPort = 0;
}

/**************************************************************************
<FUNCTION>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
</PARAMETERS>
<RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
</RETURNS>
</FUNCTION>
**************************************************************************/
CAlarmBox::~CAlarmBox()
{
}

void CAlarmBox::DestroyInst(void)
{
	if(m_hInst != NULL)
	{
		delete m_hInst;
		m_hInst = NULL;
	}
}
/**************************************************************************
<FUNCTION>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
</PARAMETERS>
<RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
</RETURNS>
</FUNCTION>
**************************************************************************/
CAlarmBox::e_AlarmBoxStatus CAlarmBox::GetStatus(void)
{
	return m_absStatus;
}

/**************************************************************************
<METHOD>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
	</PARAMETERS>
	<RETURNS>
			<TYPE></TYPE>
			<DESCRIPTION>
			</DESCRIPTION>
	</RETURNS>
</METHOD>
**************************************************************************/
unsigned char CAlarmBox::ButtonPressed(int Seconds)
{
	
	time_t	tmStartTime;
	time_t  	tmCurrentTime;
	tmStartTime = time(NULL);
	do
	{
		tmCurrentTime = time(NULL);
		if(ButtonPressed()== 0)
			return 0;
	}
	while(difftime(tmCurrentTime, tmStartTime) < Seconds);
	return -1;
	
	//return ButtonPressed();
}
