//---------------------------------------------------------------------------
#include <stdio.h>

#pragma hdrstop

#ifndef linux
#include "..\..\core\api.h"
#else
#include "../../core/api.h"
#endif // linux
//---------------------------------------------------------------------------


tReadMonitor ReadMonitor;
          
tReadHWMonitorItems ReadHWMonitorItems;          
tGetBoardName GetBoardName;

tInternalTest InternalTest;

void __cdecl DebugOut(char *Text)
{
	printf("%s",Text);
}

int main(int argc, char* argv[])
{
HWMON HardwareMonitor;    
char * Name;
_pHWM_Item HM_Items;
	
	Proc_DebugOut=DebugOut;
	
	if (KT_API_Open(sfDISK))
	{
		printf("KTAPI Verion %d.%03d.%d.%d",KT_API->VersionMajor,KT_API->VersionMinor,KT_API->Build,KT_API->Type);
		
		if ( KT_API_GetFunction("GetBoardName",&GetBoardName))
		{	
			GetBoardName(&Name);
			printf(" - %s",Name);		
		}
		
		if (OS_String[0]!=0x00)
		{
			printf(" (%s)",OS_String);		
		}
		
		printf("\n");
		
		
		
		if ( KT_API_GetFunction("ReadHWMonitorItems",&ReadHWMonitorItems))
		{
			if (ReadHWMonitorItems(&HM_Items))
			{             
				while(HM_Items->ID!=_HWM_Last)
				{            
					switch(HM_Items->ID & _HWM_Type_Mask)
					{
					case _HWM_Type_Voltage:  
						printf("%-10s: %8.3f V\n",HM_Items->Name,HM_Items->Value);
						break;
					case _HWM_Type_Temperature:
						printf("%-10s: %8.1f C\n",HM_Items->Name,HM_Items->Value);
						break;
					case _HWM_Type_Fan:
						printf("%-10s: %8.0f RPM\n",HM_Items->Name,HM_Items->Value);
						break;
                    default:
						printf("%-10s: %8.3f\n",HM_Items->Name,HM_Items->Value);
						break;
						
					}
					HM_Items++;
					
				}
			}
		}
		else if ( KT_API_GetFunction("ReadMonitor",&ReadMonitor)) 
		{

			ReadMonitor(&HardwareMonitor);

			printf("VCORE\t  : %8.3f\n",HardwareMonitor.VCORE);
			printf("VCOREb\t  : %8.3f\n",HardwareMonitor.VCOREb);
			printf("VCC2_5\t  : %8.3f\n",HardwareMonitor.VCC2_5);
			printf("VCC3\t  : %8.3f\n",HardwareMonitor.VCC3);
			printf("VCC5\t  : %8.3f\n",HardwareMonitor.VCC5);
			printf("V12\t  : %8.3f\n",HardwareMonitor.V12);
			printf("SB3\t  : %8.3f\n",HardwareMonitor.SB3);
			printf("V -12\t  : %8.3f\n",HardwareMonitor.V_12);
			printf("SB5\t  : %8.3f\n",HardwareMonitor.SB5);
			printf("VBATT\t  : %8.3f\n",HardwareMonitor.VBATT);
			printf("CPUTemp\t  : %8.3f\n",HardwareMonitor.CPUTemp);
			printf("FAN\t  : %8.3f\n",HardwareMonitor.FAN);

		}

  /*                  
		if ( KT_API_GetFunction("InternalTest",&InternalTest))
		{
			printf("...\n");
			InternalTest();
		}
    */                

		KT_API_Close();
	}


	return 0;
}
//---------------------------------------------------------------------------
