#include "XNetSDKTest.h"
#include "XNetSDKSyn.h"
#include "SystemInfo.h"
#include "SystemFunction.h"
USE_NS_NETSDK_CFG

int TestDevSystemConfig()
{
	printf("%s\r\n", __FUNCTION__);
	char c = 0;
	while((c = getchar()) != 'q')
	{
		switch(c)
		{
			/////////获取设备支持的功能/////////
		case 'a':
			{
				// [异步]获取设备能力级
				// XSDK_DevGetSysConfig(g_hDevice, JK_SystemFunction, 1234, 4000, JK_SystemFunction_MsgId);

				
				// [同步]获取设备能力级
				char szOutBuffer[40960] = {0};
				int  nInOutSize = sizeof(szOutBuffer);
				int nResult = XSDK_DevGetSysConfigSyn(g_hDevice, JK_SystemFunction, szOutBuffer, &nInOutSize, 4000, JK_SystemFunction_MsgId);
				
				if(nResult >= 0)
				{
					printf("Get Success String[%s]\r\n", szOutBuffer);

					SystemFunction cfg;
					cfg.Parse(szOutBuffer);		

					printf("AlarmFunction.AlarmConfig = %d\r\n", cfg.mAlarmFunction.AlarmConfig.Value());
				}
				else
				{
					printf("Get Fail String[%s], nResult = %d\r\n", szOutBuffer, nResult);
				}
			}
			break;
		case 'b':
			{
				// [异步]获取设备基本信息（版本信息等）
				//XSDK_DevGetSysConfig(g_hDevice, JK_SystemInfo, 123, 4000, JK_SystemInfo_MsgId);
				
				// [同步]获取设备基本信息（版本信息等）
				char szOutBuffer[40960] = {0};
				int  nInOutSize = sizeof(szOutBuffer);
				int nResult = XSDK_DevGetSysConfigSyn(g_hDevice, JK_SystemInfo, szOutBuffer, &nInOutSize, 4000, JK_SystemInfo_MsgId);
			
				if(nResult >= 0)
				{
					printf("Get Success String[%s]\r\n", szOutBuffer);

					SystemInfo cfg;
					cfg.Parse(szOutBuffer);		

					const char * SoftWareVersion = cfg.SoftWareVersion.ToString();
					printf("SoftWareVersion = %s\r\n", SoftWareVersion);
				}
				else
				{
					printf("Get Fail String[%s], nResult = %d\r\n", szOutBuffer, nResult);
				}
			}
			break;
		}
	}
	return 0;
}


