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


/**************************************************************************
INCLUDE FILE
**************************************************************************/
#include <stdio.h>
#include <STDLIb.h>
#include <process.h>
#include <errno.h>
#include <string.h>

#include "hardtest.h"
#include "drv.h"
#include ".\..\Periph\PcDetec.h"
#include "..\periph\lcd.h"

extern int errno;
/**************************************************************************
<FUNCTION>
	<NAME>LoadDriverJites</NAME>
	<TYPE >GLOBAL</TYPE>
	<DESCRIPTION>
		Load all driver jites
	</DESCRIPTION>
</PARAMETERS>
<RETURNS>
		<TYPE>interger</TYPE>
		<DESCRIPTION>
			if -1 then error
			if 1 then
		</DESCRIPTION>
</RETURNS>
</FUNCTION>
**************************************************************************/
void LoadDriverJites(enum e_PcType hPcType)
{
	switch(hPcType)
	{
//		case eJiteMavVer1:
//		{
//			break;
//		}
//		case eJiteMavVer2:
//		{
//			break;
//		}
//		case eJiteUrneVer1:
//		{
//			break;
//		}
//		case eJiteUrneVer2:
//		{
//			break;
//		}
		default:
			{
				printf("\r\ndzine.com");
				if(spawnl(P_WAIT, "a:\\drvjites\\DZINE.COM", NULL) == -1)
					{
						printf("\r\nerror");
					}
				printf("\r\nExecute drv");
				drv();
				/*execl("a:\\drvjites\\drv.exe", NULL);*/
			}
	};
}
void RunJiteMav(void)
{
	
	printf("\r\ncopy a:\\mav\\message* .\r\n");
	if(system("copy a:\\mav\\message* .") == -1)
	{	
		printf("error");
	};
	
	printf("\r\ncopy a\\mav\\machvots.ind .\r\n");
	if(system("copy a:\\mav\\machvots.ind .") == -1)
	{
		printf("\r\nerror");
	};

	printf("\r\copy a:\\mav\\*.tbl .\r\n");
	if(system("copy a:\\mav\\*.tbl .") == -1)
	{
		printf("\r\nerror");
	};

//	printf("copy  a:\\mav\\*.bmp .");
//	if(system("copy a:\\mav\\*.bmp .") == -1 )
//	{
//		printf("\r\nerror");
//	};

	printf("\r\n Blanc\r\n");
	//if(spawnl(P_NOWAIT, "a:\\mav\\blanc.exe","-LPCURSOR", NULL)  == -1)
	//if(spawnl(P_WAIT, "a:blanc.exe"," -LPCURSOR", NULL)  == -1)
	if(spawnl(P_WAIT, "a:blanc.exe", NULL)  == -1)
	{
//		char *pzBuf;
//		pzBuf = strerror(errno);
//		printf("\r\n%s",pzBuf);
		perror("blanc error \r\n");
	};
}

/**************************************************************************
<FUNCTION>
	<NAME>main</NAME>
	<TYPE >GLOBAL</TYPE>
	<DESCRIPTION>
		cette fonction détecte le type de pc, et les types de périphérique présent sur ce pc
	</DESCRIPTION>
</PARAMETERS>
<RETURNS>
		<TYPE>interger</TYPE>
		<DESCRIPTION>
			if -1 then error
			if 1 then
		</DESCRIPTION>
</RETURNS>
</FUNCTION>
**************************************************************************/

/************************************************************
*************************************************************/
int main(void)
{
	int iResult = 0;
	enum  e_PcType hpcType = TypeOfPc();
	
	switch(hpcType)
	{
		case eDigivotMav:
			{
				break;
			}
		case eDigivotUrne:
			{
				break;
			}
		case eJiteMavVer1:
			{
				printf("terminal mav jites 1");
				LoadDriverJites(hpcType);
				RunJiteMav();
				break;
			}
		case eJiteMavVer2:
			{
				printf("terminal mav jites 2");
				LoadDriverJites(hpcType);
				RunJiteMav();
				break;
			}
		case eJiteUrneVer1:
			{
				Lcd_Init();
				Lcd_Affiche(0,0,"       ");
				Lcd_Affiche(0,0,"URNES 1");
				LoadDriverJites(hpcType);
				break;
			}
		case eJiteUrneVer2:
			{
				Lcd_Init();
				Lcd_Affiche(0,0,"       ");
				Lcd_Affiche(0,0,"URNES 2");
				LoadDriverJites(hpcType);
				break;
			}
		default:
			{
				/*msg_erreur("Voting Terminal ?");*/
				printf("error terminal");
				break;
			}
	}
	return iResult;
}
