
#include <stdio.h>  
#include <time.h>


#include "../../core/api.h"

typedef struct
{                
char * Name;
void * FunctionPtr;
}tsAPI_Functions;

extern unsigned char ktapi_bin[];

tReadMonitor _ReadMonitor=NULL;
tSetCPUThrottle _SetCPUThrottle=NULL;
tSetBKLControl _SetBKLControl=NULL;
tDisableWD _DisableWD=NULL;
tEnableWD _EnableWD=NULL;
tSetWDTimerInterval _SetWDTimerInterval=NULL;
tSetWDTimer _SetWDTimer=NULL;
tGetMac _GetMac=NULL;
tSetGPIODir _SetGPIODir=NULL;
tReadGPIO _ReadGPIO=NULL;
tWriteGPIO _WriteGPIO=NULL;
tSetClrGPIO _SetClrGPIO=NULL;
tSmBus_PorcessCall _SmBus_PorcessCall=NULL;
tSmBus_WriteBlock _SmBus_WriteBlock=NULL;
tSmBus_WriteWord _SmBus_WriteWord=NULL;
tSmBus_WriteByte _SmBus_WriteByte=NULL;
tSmBus_SendByte _SmBus_SendByte=NULL;
tReadBoardHeader _ReadBoardHeader=NULL;
tGetBoardName _GetBoardName=NULL;
tSetFanSpeed _SetFanSpeed=NULL;
tSelectFanTempTacChannel _SelectFanTempTacChannel=NULL;
tSetFanTarget _SetFanTarget=NULL;
tSetFanMode _SetFanMode=NULL;
tStartThermalCruise _StartThermalCruise=NULL;
tGetIntruderStatus _GetIntruderStatus=NULL;
tClrIntruderStatus _ClrIntruderStatus=NULL;
tSmBus_RecvByte _SmBus_RecvByte=NULL;
tSmBus_ReadByte _SmBus_ReadByte=NULL;
tSmBus_ReadWord _SmBus_ReadWord=NULL;
tSmBus_ReadBlock _SmBus_ReadBlock=NULL;
tSmBus_ReadBytes _SmBus_ReadBytes=NULL;
tReadHWMonitorItems _ReadHWMonitorItems=NULL;
tGetHWMonitorItem _GetHWMonitorItem=NULL;
tGetPartNumber _GetPartNumber=NULL;
tGetSerialNumber _GetSerialNumber=NULL;




tsAPI_Functions API_Functions[]=
{
{"ReadMonitor",&_ReadMonitor},	
{"SetCPUThrottle",&_SetCPUThrottle},
{"SetBKLControl",&_SetBKLControl},
{"DisableWD",&_DisableWD},
{"EnableWD",&_EnableWD},
{"SetWDTimerInterval",&_SetWDTimerInterval},
{"SetWDTimer",&_SetWDTimer},
{"GetMac",&_GetMac},
{"SetGPIODir",&_SetGPIODir},
{"ReadGPIO",&_ReadGPIO},
{"WriteGPIO",&_WriteGPIO},
{"SetClrGPIO",&_SetClrGPIO},
{"SmBus_PorcessCall",&_SmBus_PorcessCall},
{"SmBus_WriteBlock",&_SmBus_WriteBlock},
{"SmBus_WriteWord",&_SmBus_WriteWord},
{"SmBus_WriteByte",&_SmBus_WriteByte},
{"SmBus_SendByte",&_SmBus_SendByte},
{"ReadBoardHeader",&_ReadBoardHeader},
{"GetBoardName",&_GetBoardName},
{"SetFanSpeed",&_SetFanSpeed},
{"SelectFanTempTacChannel",&_SelectFanTempTacChannel},
{"SetFanTarget",&_SetFanTarget},
{"SetFanMode",&_SetFanMode},
{"StartThermalCruise",&_StartThermalCruise},
{"GetIntruderStatus",&_GetIntruderStatus},
{"ClrIntruderStatus",&_ClrIntruderStatus},
{"SmBus_RecvByte",&_SmBus_RecvByte},
{"SmBus_ReadByte",&_SmBus_ReadByte},
{"SmBus_ReadWord",&_SmBus_ReadWord},
{"SmBus_ReadBlock",&_SmBus_ReadBlock},
{"SmBus_ReadBytes",&_SmBus_ReadBytes},

{"ReadHWMonitorItems",&_ReadHWMonitorItems},
{"GetHWMonitorItem",&_GetHWMonitorItem},

{"GetPartNumber",&_GetPartNumber},

{"GetSerialNumber",&_GetSerialNumber},





{NULL,NULL}	
};

int KT_API_Open_Status=_API_se_Error;


int Count=0;


void __attribute__((constructor)) SO_Open(void)
{
//	printf("SO_Open\n");
	KT_API_Set_Internal(&ktapi_bin);
}

void __attribute__((destructor)) SO_Close(void)
{
	//printf("SO_Close\n");

}

void OutputDebugString(char * Text)
{
	// printf("%s\n",Text);
}

/*
HANDLE hLockMutex;

void __cdecl DLL_DebugOut(char * Text)
{
	OutputDebugString(Text);
}

 
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{



	switch(fdwReason)
	{
	/ *	
		VOID InitializeCriticalSection(

    LPCRITICAL_SECTION lpCriticalSection 	// address of critical section object  
   ); * /
	case DLL_PROCESS_ATTACH:
		Proc_DebugOut=&DLL_DebugOut;
		
		hLockMutex=CreateMutex(NULL,FALSE,"Global\\KTAPI");
		OutputDebugString("CreateMutex");
		if (hLockMutex==NULL)
		{
			hLockMutex=OpenMutex(0,FALSE,"Global\\KTAPI");
			OutputDebugString("OpenMutex");
		}
	
		/ *
		IsKT_API_Open=KT_API_Open();
		if (IsKT_API_Open==TRUE)
		{
			
		}* /                
		Internal_API=KTAPI_BIN;	  
		break;
		
	case DLL_PROCESS_DETACH:
	
		OutputDebugString("CloseHandle");
		ReleaseMutex(hLockMutex);
		CloseHandle(hLockMutex);
		/ *
		if (IsKT_API_Open==TRUE)
		{
			KT_API_Close();	
		}* /
		break;
					
	}
	
	
	
	return TRUE;
}
*/
int LockDriver(void)
{
	return _API_se_OK;

/*
	if (WaitForSingleObject(hLockMutex,INFINITE)==WAIT_OBJECT_0)
	{
		OutputDebugString("LockDriver OK");
		return _API_se_OK;
	}
	else
	{
		OutputDebugString("LockDriver Failed");
		return _API_se_Error;
	}
	*/
}
void UnLockDriver(void)
{
/*
	OutputDebugString("UnLockDriver");
	ReleaseMutex(hLockMutex);
	*/
}


int __cdecl Get_KT_API(_API_ * * ptr)
{
	*ptr=KT_API;

	return KT_API_Open_Status;

}

int __cdecl KT_API_Get_OS_String(char **Text)
{
	*Text=OS_String;
	return _API_se_OK;
}


void Fix_All_KTAPI_Imports(void)
{
tsAPI_Functions * Function;


	Function=API_Functions;
	while(Function->Name!=NULL)
	{
		
		if (KT_API_Open_Status==_API_se_OK)
		{
		
			if (KT_API_GetFunction(Function->Name,Function->FunctionPtr)==_API_se_Error)
			{
				*(unsigned int *)Function->FunctionPtr=0;
			}
		}
		else
		{
			*(unsigned int *)Function->FunctionPtr=0;
		}
			
		Function++;
	}
	

	
	
}

int __cdecl KT_API_GetFunction(char * Name,void *pFunction)
{
int Status;

	Status=LockDriver();
	if (Status==_API_se_OK)
	{
		Status=_KT_API_GetFunction(Name,pFunction);
		UnLockDriver();
	}
	return Status;
}

int __cdecl KT_API_Open(int sf)
{
	KT_API_Open_Status=LockDriver();
	OutputDebugString("_KT_API_Open");

	if (KT_API_Open_Status==_API_se_OK)
	{
	
		KT_API_Open_Status=_KT_API_Open(sf);
		OutputDebugString("Fix_All_KTAPI_Imports");
		Fix_All_KTAPI_Imports();
		UnLockDriver();
	}
	
	return KT_API_Open_Status;
}

int __cdecl KT_API_Close(void)
{

	if (KT_API_Open_Status==_API_se_OK)
	{
		
		KT_API_Open_Status=_API_se_Error;	
		Fix_All_KTAPI_Imports();

	} 

	return _KT_API_Close();
}


int __cdecl KT_API_Set_Internal(void * Set_KTAPI_BIN)
{
	Internal_API=Set_KTAPI_BIN;	  
	
	return  _API_se_OK;
}



int ReadMonitor(HWMON *Mon)
{
int Status;


	if (_ReadMonitor==NULL)
		Status=_API_se_Error;
	else		
	{
	
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_ReadMonitor(Mon);
			UnLockDriver();
		}
	}
	
	return Status;
}


int ReadBoardHeader(void * Buffer)
{
int Status;

	if (_ReadBoardHeader==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status= _ReadBoardHeader(Buffer);
			UnLockDriver();
		}
	}
	
	return Status;

}

//typedef char * (__cdecl *tGetBoardName)(void);


int GetBoardName(char * * Name)
{
int Status;

	if (_GetBoardName==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_GetBoardName(Name);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tGetSerialNumber)(char * * Number);

int GetSerialNumber(char * * Number)
{
int Status;

	if (_GetSerialNumber==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_GetSerialNumber(Number);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tGetPartNumber)(char * * Number);

int GetPartNumber(char * * Number)
{
int Status;

	if (_GetPartNumber==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_GetPartNumber(Number);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetFanSpeed)(unsigned int Speed);


int SetFanSpeed(unsigned int Speed)
{
int Status;
	if (_SetFanSpeed==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetFanSpeed(Speed);
			UnLockDriver();
		}
	}
	return Status;
		
}

//typedef int (__cdecl *tSelectFanTempTacChannel)(unsigned char Channel);

int SelectFanTempTacChannel(unsigned char Channel)
{
int Status;
	if (_SelectFanTempTacChannel==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SelectFanTempTacChannel(Channel);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetFanTarget)(unsigned int uiStt);

int SetFanTarget(unsigned int uiStt)
{
int Status;
	if (_SetFanTarget==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetFanTarget(uiStt);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetFanMode)(unsigned char ucSfm);

int SetFanMode(unsigned char ucSfm)
{
int Status;
	if (_SetFanMode==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetFanMode(ucSfm);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tStartThermalCruise)(void);

int StartThermalCruise(void)
{
int Status;
	if (_StartThermalCruise==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_StartThermalCruise();
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tGetIntruderStatus)(unsigned int *Status);

int GetIntruderStatus(unsigned int *Status)
{
int xStatus;
	if (_GetIntruderStatus==NULL)
		xStatus=_API_se_Error;
	else	
	{
		xStatus=LockDriver();
		if (xStatus==_API_se_OK)
		{
			xStatus=_GetIntruderStatus(Status);
			UnLockDriver();
		}
	}
	return xStatus;
}

//typedef int (__cdecl *tClrIntruderStatus)(void);

int ClrIntruderStatus(void)
{
int Status;
	if (_ClrIntruderStatus==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_ClrIntruderStatus();
			UnLockDriver();
		}
	}
	return Status;
}


//typedef int (__cdecl *tSmBus_RecvByte)(unsigned char ucDevAddr,unsigned char *ucpData);

int SmBus_RecvByte(unsigned char ucDevAddr,unsigned char *ucpData)
{
int Status;
	if (_SmBus_RecvByte==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_RecvByte(ucDevAddr,ucpData);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_ReadByte)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpData);

int SmBus_ReadByte(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpData)
{
int Status;
	if (_SmBus_ReadByte==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_ReadByte(ucDevAddr,ucCommandCode,ucpData);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_ReadWord)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData);

int SmBus_ReadWord(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData)
{
int Status;
	if (_SmBus_ReadWord==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_ReadWord(ucDevAddr,ucCommandCode,uspData);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_ReadBlock)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpByteCnt,unsigned char *ucpDataBuf);

int SmBus_ReadBlock(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char * ucpByteCnt,unsigned char *ucpDataBuf)
{
int Status;
	if (_SmBus_ReadBlock==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_ReadBlock(ucDevAddr,ucCommandCode,ucpByteCnt,ucpDataBuf);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_ReadBytes)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned int uiByteCnt,unsigned char *ucpDataBuf);

int SmBus_ReadBytes(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned int uiByteCnt,unsigned char *ucpDataBuf)
{
int Status;
	if (_SmBus_ReadBytes==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_ReadBytes(ucDevAddr,ucCommandCode,uiByteCnt,ucpDataBuf);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSmBus_SendByte)(unsigned char ucDevAddr,unsigned char ucCommandCode);

int SmBus_SendByte(unsigned char ucDevAddr,unsigned char ucCommandCode)
{
int Status;
	if (_SmBus_SendByte==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_SendByte(ucDevAddr,ucCommandCode);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_WriteByte)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char usData);

int SmBus_WriteByte(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char usData)
{
int Status;
	if (_SmBus_WriteByte==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_WriteByte(ucDevAddr,ucCommandCode,usData);
			UnLockDriver();
		}
	}
	return Status;
}
//typedef int (__cdecl *tSmBus_WriteWord)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short usData);

int SmBus_WriteWord(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short usData)
{
int Status;
	if (_SmBus_WriteWord==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_WriteWord(ucDevAddr,ucCommandCode,usData);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSmBus_WriteBlock)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char ucByteCnt,unsigned char *ucpDataBuf);

int SmBus_WriteBlock(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned char ucByteCnt,unsigned char *ucpDataBuf)
{
int Status;
	if (_SmBus_WriteBlock==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_WriteBlock(ucDevAddr,ucCommandCode,ucByteCnt,ucpDataBuf);
			UnLockDriver();
		}
	}
	return Status;
}
                                                                                                                        
//typedef int (__cdecl *tSmBus_PorcessCall)(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData);

int SmBus_PorcessCall(unsigned char ucDevAddr,unsigned char ucCommandCode,unsigned short *uspData)
{
int Status;
	if (_SmBus_PorcessCall==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SmBus_PorcessCall(ucDevAddr,ucCommandCode,uspData);
			UnLockDriver();
		}
	}
	return Status;
}



//typedef int (__cdecl *tSetClrGPIO)(unsigned char GPIO,int SetClr);

int SetClrGPIO(unsigned char GPIO,int SetClr)
{
int Status;
	if (_SetClrGPIO==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetClrGPIO(GPIO,SetClr);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tReadGPIO)(unsigned char GPIO,unsigned char *Data);

int ReadGPIO(unsigned char GPIO,unsigned char *Data)
{
int Status;
	if (_ReadGPIO==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_ReadGPIO(GPIO,Data);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tWriteGPIO)(unsigned char GPIO,unsigned char Data);

int WriteGPIO(unsigned char GPIO,unsigned char Data)
{
int Status;
	if (_WriteGPIO==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_WriteGPIO(GPIO,Data);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetGPIODir)(unsigned char GPIO);

int SetGPIODir(unsigned char GPIO)
{
int Status;
	if (_SetGPIODir==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetGPIODir(GPIO);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tGetMac)(unsigned char nMac,void * Buffer);  

int GetMac(unsigned char nMac,void * Buffer)
{
int Status;
	if (_GetMac==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_GetMac(nMac,Buffer);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetWDTimer)(unsigned char Time);

int SetWDTimer(unsigned char Time)
{
int Status;
	if (_SetWDTimer==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetWDTimer(Time);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetWDTimerInterval)(unsigned char VAL);

int SetWDTimerInterval(unsigned char VAL)
{
int Status;
	if (_SetWDTimerInterval==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetWDTimerInterval(VAL);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tEnableWD)(void);

int EnableWD(void)
{
int Status;
	if (_EnableWD==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_EnableWD();
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tDisableWD)(void);

int DisableWD(void)
{
int Status;
	if (_DisableWD==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_DisableWD();
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetBKLControl)(unsigned int Freq,unsigned int Duty);

int SetBKLControl(unsigned int Freq,unsigned int Duty)
{
int Status;
	if (_SetBKLControl==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetBKLControl(Freq,Duty);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tSetCPUThrottle)(unsigned char DUTY);

int SetCPUThrottle(unsigned char DUTY)
{
int Status;
	if (_SetCPUThrottle==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_SetCPUThrottle(DUTY);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tReadHWMonitorItems)(_pHWM_Item * Items);

int ReadHWMonitorItems(_pHWM_Item * Items)
{
int Status;
	if (_ReadHWMonitorItems==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_ReadHWMonitorItems(Items);
			UnLockDriver();
		}
	}
	return Status;
}

//typedef int (__cdecl *tGetHWMonitorItem)(_HWM_ID ID,float * Value);

int GetHWMonitorItem(_HWM_ID ID,float * Value)
{
int Status;
	if (_GetHWMonitorItem==NULL)
		Status=_API_se_Error;
	else	
	{
		Status=LockDriver();
		if (Status==_API_se_OK)
		{
			Status=_GetHWMonitorItem(ID,Value);

			UnLockDriver();
		}
	}
	return Status;
}

