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


/**************************************************************************
INCLUDE FILE
**************************************************************************/
#include <conio.h>
#include <time.h>
#include <stdio.h>

#include "..\comp\alarmbox\AlrBxDig.h"

/**************************************************************************
LOCAL VARIABLES
Always start with « static »-keyword
**************************************************************************/

/**************************************************************************
<METHOD>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
    <RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
    </RETURNS>
</METHOD>
**************************************************************************/
CAlarmBoxDigivot::CAlarmBoxDigivot()
{
	m_absStatus = eNotConnected;
	m_iPort = ePortNone;

	//
	if(!(inp(ePort3BC + 1) & 0x08))
	{
		m_absStatus 	= eConnected;
		m_iPort 		= ePort3BC;
	}

	if(!(inp(ePort378 + 1) & 0x08))// == 0x00)
	{
		m_absStatus 	= eConnected;
		m_iPort		= ePort378;
	}
	if(!(inp(ePort278 + 1) & 0x08))// == 0x00)
	{
		m_absStatus  = eConnected;
		m_iPort		= ePort278;
	}
	ResetLeds();
}

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

}



/**************************************************************************
<METHOD>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
    <RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
    </RETURNS>
</METHOD>
**************************************************************************/
CAlarmBox* CAlarmBoxDigivot::Instance(void)
{
    if(m_hInst == NULL)
    {
        m_hInst = new CAlarmBoxDigivot();
    }
    return m_hInst;
}

/**************************************************************************
<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>
**************************************************************************/
void CAlarmBoxDigivot::ResetLeds(void)
{
	if(m_iPort != ePortNone)
	{
	    int iC;
	    iC = inp(m_iPort) & ~(eValGreenLed | eValRedLed);
	    outp(m_iPort, iC | eValAllOff);
	}
}

/**************************************************************************
<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>
**************************************************************************/
void CAlarmBoxDigivot::SetGreenLed(void)
{
	if(m_iPort != ePortNone)
	{
	    int iC;
	    iC = inp(m_iPort) & ~(eValGreenLed | eValRedLed);
	    outp(m_iPort, iC | eValRedLed);
	}
}

/**************************************************************************
<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>
**************************************************************************/
void CAlarmBoxDigivot::SetRedLed(void)
{
	if(m_iPort != ePortNone)
	{
	    int iC;
	    iC = inp(m_iPort) & ~(eValGreenLed | eValRedLed);
	    outp(m_iPort, iC | eValGreenLed);
	}
}

/**************************************************************************
<METHOD>
	<NAME></NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
</METHOD>
**************************************************************************/
void CAlarmBoxDigivot::SetLeds(void)
{
	if(m_iPort != ePortNone)
	{
	    int iC;
	    iC = inp(m_iPort) & ~(eValGreenLed | eValRedLed);
	    outp(m_iPort, iC | eValAllOn);
	}
}

/**************************************************************************
<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 CAlarmBoxDigivot::ButtonPressed(void)
{
	unsigned char ucRep;
	if(m_iPort != ePortNone)
		ucRep = (unsigned char)inp(m_iPort + 1) & 0x08;
   return ~ucRep;
}
