#ifndef __TCORE_DEFINITIONS_H
#define __TCORE_DEFINITIONS_H

//Manager Definitions
#define SC_SYSTEM_STATUS		1
#define SC_API_ERROR			2
#define SC_API_RESULT			3
#define SC_MAIN_THREAD			4
#define SC_TIMER				5
#define SC_GENERAL_QUERY	6
#define SC_STOP_TCORE				7
#define SC_REGISTS_API				8

#define SYSTEM_STATUS_READY		0 //API Usage only
#define SYSTEM_STATUS_INIT		1
#define SYSTEM_STATUS_START		2
#define SYSTEM_STATUS_UPDATE	3
#define SYSTEM_STATUS_ENSTOP	4
#define SYSTEM_STATUS_STOP		5
#define SYSTEM_STATUS_UNLOAD	6
#define SYSTEM_STATUS_LOCKSCREEN		7
#define SYSTEM_STATUS_UNLOCKSCREEN	8
#define SYSTEM_STATUS_LOGINOK		9
#define SYSTEM_STATUS_LOGINFAIL	10
#define SYSTEM_STATUS_MESSAGE	11

#define DECLARE_TYPE_MANAGER	1
#define DECLARE_TYPE_MONITOR	2

//#define MSG_TYPE_MONITOR		0
#define MSG_TYPE_PUBLISH		1
#define MSG_TYPE_ASK			2
#define MSG_TYPE_ASK_ONCE		3
#define MSG_TYPE_SUBCOUNT		4

//BaseData Definitions
#define DT_VALUE			1
#define DT_STRING			2
#define DT_HASHTABLE		3
#define DT_COOKIE			4
#define DT_HASHCOOKIE		5
#define DT_BASEDATA			6
#define DT_HASHDATA			7
#define DT_REPLACEBY		10
#define DT_STREAM			11
#define DT_SERIALIZE		12
#define DT_MERGE_FROM_DATA	13
#define DT_MERGE_FROM_MSG2	14
#define DT_CLEAR			15
#define DT_STREAMBYFIELDS	16
#define DT_SERIALIZEBYFIELDS 17
#define DT_TOPIC			20
#define DT_DATAID			21
#define DT_PARSE_2D_MSG		22
#define DT_DELAY_COMMIT		23
#define DT_INCREASE_SIZE_VALUE 24
#define DT_INCREASE_SIZE_STRING 25

#define ST_ALL				0x00FF
#define ST_VALUE			0x0001
#define ST_STRING			0x0002
#define ST_HASHTABLE		0x0004
#define ST_COOKIE			0x0008
#define ST_HASHCOOKIE		0x0010
#define ST_BASEDATA			0x0020
#define ST_HASHDATA			0x0040
#define ST_ALL_INDEX		0xFF00
#define ST_VALUE_INDEX		0x0100
#define ST_STRING_INDEX		0x0200
#define ST_HASHTABLE_KEY	0x0400
#define ST_COOKIE_INDEX		0x0800
#define ST_HASHCOOKIE_KEY	0x1000
#define ST_BASEDATA_INDEX	0x2000
#define ST_HASHDATA_KEY		0x4000

#define DUTYPE_UPDATE_BY_CHILD	-1

#define NUM_NO_VALUE	0x8000000000000000
#define STR_NO_VALUE	_T("~%")
#define LONG_NO_VALUE	0x80000000

//Request Type
#define RT_LOAD_MANAGER		1
#define RT_UNLOAD_MANAGER	2
#define RT_SET_MANAGER_INFO	3
#define RT_IF_TOPIC_EXIST	4
#define RT_MAIN_THREAD		5
#define RT_REMOVE_TOPIC_DATA 6
#define RT_SET_TIMER		7
#define RT_KILL_TIMER		8
#define RT_SYSTEM_QUIT		9
#define RT_SYSTEM_NAME		10
#define RT_WRITE_LOG		11
#define RT_GENERAL_QUERY	12
#define RT_SHOW_MESSAGE	13
#define RT_MAIN_WINDOW		14
#define RT_REG_MANAGER		15
#define RT_TOPIC_REPLACE		16
#define RT_LOG_COM_VERSION		17
#define RT_THIRDPARTYAPP_STOP_TCORE			18
//Follwing are API Use Only
#define RT_ASYNC_BRIDGE_LOCK	100
#define RT_ASYNC_BRIDGE_UNLOCK	101
#define RT_SET_PRIVATE_STORAGE	102
#define RT_SET_GLOBAL_STORAGE	103
#define RT_SYNQUERY_SECURITYINFO	104
#define RT_SYNQUERY_STRING	105
#define RT_SYNQUERY_PERSONAL	106
#define RT_PRIORITY_CHANGE				107
#define RT_REGISTERS_API				108
#define RT_REGISTERS_PROCID		109

//API DoSomething FuncType
#define DS_WRITE_LOG		1
#define DS_QUERY_PERMISSION	2
#define DS_GET_PERMISSION	3
#define DS_SET_PRIVATE_STORAGE		4
#define DS_SUB_PRIVATE_STORAGE		5
#define DS_GET_PRIVATE_STORAGE		6
#define DS_SET_GLOBAL_STORAGE		7
#define DS_SUB_GLOBAL_STORAGE		8
#define DS_GET_GLOBAL_STORAGE		9
#define DS_GENERAL_QUERY					10
#define DS_REGISTERS_API						12
#define DS_SET_MEMBER_LOGIN_PROFILE	20
#define DS_SYSTEM_REQUEST_LOCK		30
#define DS_API_DUMP					31
#define DS_SYSTEM_SHOW_CORE			32
#define DS_SYSTEM_SET_LOCK_CONFIG	33
#define DS_RESET_COMMAND	100

//TCAsyncBridgeAPI Definitions
#define RETURN_UNTIL_SUCCEEDED	1
#define RETURN_UNTIL_LAUNCHTCORE_SUCCEEDED	8

#define TRADE_TYPE				1
#define TRADE_BROKERID			2
#define TRADE_ACCOUNT			3
#define TRADE_SYMBOL			4
#define TRADE_SIDE				5
#define TRADE_STRATEGY			6
#define TRADE_USERKEY1			7
#define TRADE_USERKEY2			8
#define TRADE_USERKEY3			9
#define TRADE_EXTCOMMANDS		10
#define TRADE_SYMBOL2			11
#define TRADE_SIDE2				12

#define TRADE_ORDERQTY			21
#define TRADE_ORDERTYPE			22
#define TRADE_POSITIONEFFECT	23
#define TRADE_TIMEINFORCE		24
#define TRADE_PRICE				25
#define	TRADE_STOPPRICE			26
#define TRADE_TRADETYPE			27
#define TRADE_EXCODE				28

///API Relative 
#define CONNECT_STATUS_DISCONNECTED	0
#define CONNECT_STATUS_CONNECTING	1
#define CONNECT_STATUS_CONNECTED	2
#define SYSTEM_STATUS_LOGINOK		9

#define CONNECT_RETURN_FAIL_LAUNCH_TCORE		-1	//TCore无法启动
#define CONNECT_RETURN_FAIL_WAIT_TCORE_TIMEOUT	-2	//等待TCore逾时
#define CONNECT_RETURN_FAIL_TCORE_UNAVAILABLE	-3	//无法连线TCore
#define CONNECT_RETURN_FAIL_CONNECT_TIMEOUT		-4	//连线TCore逾时
#define CONNECT_RETURN_FAIL_REGISTER_TIMEOUT	-5	//注册逾时
#define CONNECT_RETURN_FAIL_REGISTER_FAIL		-6	//注册失败
#define CONNECT_RETURN_FAIL_UNDEFIND_ERROR		-9	//其他错误
#define CONNECT_RETURN_FAIL			0				//无法载入TCAsyncBridgeAPI
#define CONNECT_RETURN_CONNECTING	1
#define CONNECT_RETURN_CONNECTED	2

//OnCommandMsg
#define COMMAND_MSG_TYPE_ERROR			1
#define COMMAND_MSG_SYSTEM_STATUS		2
#define COMMAND_MSG_BROKER_READY		3
#define COMMAND_MSG_PERMISSION_READY	4
#define COMMAND_MSG_PRIVATE_STORAGE_UPDATE		5
#define COMMAND_MSG_GLOBAL_STORAGE_UPDATE		6
#define COMMAND_MSG_GENERAL_QUERY_RESULT		7
#define COMMAND_MSG_ALERT_STATUS				8
#define COMMAND_MSG_MEMBER_LOGIN_PROFILE		20
#define COMMAND_MSG_STOP_TCORE		90

//OnCommandMsg(COMMAND_MSG_TYPE_ERROR)
#define ERROR_CODE_UNDEFINED			0
#define ERROR_CODE_CONNECT_FAIL			1
#define ERROR_CODE_REGISTER_FAIL		2
#define ERROR_OPERATE_BEFORE_CONNECTED	3
#define ERROR_BAD_DATA_PARAMETERS		4
#define ERROR_SUBQUOTE_DUPLICATED		5
#define ERROR_UNSUBQUOTE_FAILED			6

//OnCommandMsg(COMMAND_MSG_SYSTEM_STATUS)
#define CMSS_CORE_READY			-1
#define CMSS_CORE_DISCONNECTED	0
#define CMSS_CORE_CONNECTED		1

//OnSystemCommand(SC_API_RESULT) CAsyncBridgeAPI
#define API_RESULT_TYPE_PUBLISH	1
#define API_RESULT_TYPE_REQUEST	2

#endif //__TCORE_DEFINITIONS4_H