⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macros.h

📁 基于TB板卡的FSK编程,telcobridges fsk develop
💻 H
📖 第 1 页 / 共 3 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VoiceLink TB640 sample (FSK)
 |
 |	Filename:   	macros.h
 |
 |	Copyright:  	TelcoBridges 2002-2003, All Rights Reserved
 |
 |	Description:	This file contains definition of utility macros
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.9 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Define header file
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifndef __MACROS_H__
#define __MACROS_H__



/*--------------------------------------------------------------------------------------------------------------------------------
 |  C++ support
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

#ifndef WIN32
	#include <pthread.h>
#endif

/*--------------------------------------------------------------------------------------------------------------------------------
 |  Forward declarations
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Defines
 *------------------------------------------------------------------------------------------------------------------------------*/

/* The following defines create the apppropriate function inlining according to the selected OS */
#define	INLINE						__inline

/* Define the max length of an error line displayed by the CLI */
#define TB640_FSK_CLI_MAX_ERROR_LINE_SIZE				120

/* Define the number of "error log" lines that are remembered by the CLI */
#define TB640_FSK_CLI_MAX_NB_ERROR_LINES				512

/* Define the number of "error log" lines that are displayer by the CLI */
#define TB640_FSK_CLI_MAX_NB_ERROR_LINES_VIEWED		8

/* vsnprintf is defined differently under windows than other operating system */
#ifdef WIN32
#define		VSNPRINTF					_vsnprintf
#else
#define		VSNPRINTF					vsnprintf
#endif

typedef enum _TRACE_LEVEL
{
	TRACE_LEVEL_0		= 0,
	TRACE_LEVEL_1		= 1,
	TRACE_LEVEL_2		= 2,
	TRACE_LEVEL_3		= 3,
	TRACE_LEVEL_4		= 4,
	TRACE_LEVEL_MAX		= 4,
	TRACE_LEVEL_ALWAYS	= 0xFFFFFFFE,
	TRACE_LEVEL_ERROR	= 0xFFFFFFFF
} TRACE_LEVEL, *PTRACE_LEVEL;

/*--------------------------------------------------------------------------------------------------------------------------------
 |  Types
 *------------------------------------------------------------------------------------------------------------------------------*/


/* Bit value to instruct the GUI to refresh the display */
#define TB640_FSK_CLI_REFRESH_DISPLAY					(1<<0)

/* Bit value to instruct the GUI to do a force refresh */
#define TB640_FSK_CLI_FORCE_REFRESH						(1<<30)

/* Bit value to instruct the GUI to clear the screen before refreshing */
#define TB640_FSK_CLI_CLEAR_BEFORE_REFRESH				(1<<31)


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Global variables
 *------------------------------------------------------------------------------------------------------------------------------*/
extern volatile TBX_BOOL			g_fPrintInErrorBuffer;
extern volatile TBX_UINT32			g_un32ErrorLineId;
extern volatile TBX_UINT32			g_un32ErrorLineWriteIndex;
extern volatile TBX_UINT32			g_un32ErrorLineReadIndex;
extern volatile TBX_CHAR			g_aszErrorLines [TB640_FSK_CLI_MAX_NB_ERROR_LINES+1] [TB640_FSK_CLI_MAX_ERROR_LINE_SIZE];


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Macros
 *------------------------------------------------------------------------------------------------------------------------------*/
#define TB640_FSK_SERVICE_FUNCTION(__FunctionName__)											\
	TBX_RESULT __FunctionName__ (																\
	  IN		PTB640_FSK_CALL_CONTEXT	in_pCallContext)										\

#define TB640_FSK_STATE_ADD_HISTORY(__ptr__,__Max__,__StateName__, __Event__)		\
			{																					\
				PTB640_FSK_HISTORY_ENTRY		pEntry;											\
																								\
				/* Write the history into the log array */										\
				pEntry = &((__ptr__)->aHistoryEntry [(__ptr__)->un32HistoryWriteIdx]);			\
				pEntry->un32Timestamp = time(NULL);												\
				pEntry->CurrentState = (__StateName__);											\
				pEntry->un32Event = (TBX_UINT32)(__Event__);									\
																								\
				/* Increment the write pointer */												\
				(__ptr__)->un32HistoryWriteIdx++;												\
				if ((__ptr__)->un32HistoryWriteIdx >= (__Max__))								\
				{																				\
					(__ptr__)->un32HistoryWriteIdx = 0;											\
				}																				\
																								\
				/* Check for collision with read pointer */										\
				if ((__ptr__)->un32HistoryWriteIdx == (__ptr__)->un32HistoryReadIdx)			\
				{																				\
					/* Increment the read pointer */											\
					(__ptr__)->un32HistoryReadIdx++;											\
					if ((__ptr__)->un32HistoryReadIdx >= (__Max__))								\
					{																			\
						(__ptr__)->un32HistoryReadIdx = 0;										\
					}																			\
				}																				\
			}


#define TB640_FSK_STATE_ENTRY(__StateName__)													\
			TB640_FSK_STATE_ACTION				ReturnAction = TB640_FSK_STATE_ACTION_WAIT;		\
			PTB640_FSK_ADAPTER_INFO				pAdapterInfo;									\
			PTB640_FSK_TRUNK_INFO				pTrunkInfo;										\
			PTB640_FSK_TRUNK_RESOURCE_INFO		pTrunkResInfo;									\
																								\
			pAdapterInfo = &(g_AppContext->ahAdapterInfo [in_pCallContext->un32AdapterIndex]);	\
			pTrunkInfo = &(pAdapterInfo->aTrunkInfo [in_pCallContext->un32TrunkIndex]);			\
			pTrunkResInfo = &(pTrunkInfo->aResourceInfo [in_pCallContext->un32TimeslotIndex]);	\
																								\
			TB640_FSK_STATE_ADD_HISTORY(pTrunkResInfo, TB640_FSK_NB_HISTORY_FOR_TIMESLOT, __StateName__, in_un32MsgId);		\
			TB640_FSK_STATE_ADD_HISTORY(in_pCallContext, TB640_FSK_NB_HISTORY_FOR_CALL, __StateName__, in_un32MsgId);			\
																								\
			switch (pTrunkResInfo->SubState)													\
			{																					\
				case TB640_FSK_CALL_APP_SUB_STATE_ENTRY:										\
					pTrunkResInfo->SubState = TB640_FSK_CALL_APP_SUB_STATE_PROCESS;			\


#define TB640_FSK_STATE_DECLARE_FIRST_EVENT(__Event__)											\
					break;																		\
				case TB640_FSK_CALL_APP_SUB_STATE_PROCESS:										\
					switch (in_un32MsgId)														\
					{																			\
					case (__Event__):															\


#define TB640_FSK_STATE_DECLARE_NEXT_EVENT(__Event__)											\
						break;																	\
					case (__Event__):															\

#define TB640_FSK_STATE_DECLARE_END																\
						break;																	\
					default:																	\
						break;																	\
					}																			\
					break;																		\
				default:																		\
					break;																		\
			}																					\

#define TB640_FSK_STATE_RETURN																	\
	TB640_FSK_STATE_DECLARE_END																	\
EndOfStateProcessing:																			\
			return ReturnAction;																\

#define TB640_FSK_STATE_RETURN2																	\
EndOfStateProcessing:																			\
			return ReturnAction;																\

#define TB640_FSK_CHANGE_STATE(__NextState__)													\
	pTrunkResInfo->SubState = TB640_FSK_CALL_APP_SUB_STATE_ENTRY;								\
	pTrunkResInfo->State = (__NextState__);														\
	ReturnAction = TB640_FSK_STATE_ACTION_CONTINUE;												\
	g_fRefreshDisplay |= (TB640_FSK_CLI_REFRESH_DISPLAY);										\
	goto EndOfStateProcessing;																	\

#define TB640_FSK_STATE_WAIT																	\
				ReturnAction = TB640_FSK_STATE_ACTION_WAIT;										\
				goto EndOfStateProcessing;														\


#define TB640_FSK_STATE_CONTINUE																\
				ReturnAction = TB640_FSK_STATE_ACTION_CONTINUE;									\
				goto EndOfStateProcessing;														\


#define TB640_FSK_DESTROY_CONTEXT																\
				ReturnAction = TB640_FSK_STATE_ACTION_DESTROY_CONTEXT;							\
				goto EndOfStateProcessing;														\

#define TB640_FSK_STATE_FUNCTION(__FunctionName__)												\
	TB640_FSK_STATE_ACTION __FunctionName__ (													\
	  IN		TBX_ASYNC_LIB_HANDLE		in_hLib,											\
	  IN		PTBX_ASYNC_OP_CONTEXT		in_pOpContext,										\
	  IN		PTB640_FSK_CALL_CONTEXT	in_pCallContext,										\
	  IN		TBX_UINT32					in_un32MsgId,										\
	  IN		PTBX_VOID					in_pMsgPayload)										\


#define TB640_FSK_SERVICE_FUNCTION_VAR()														\
	TBX_RESULT										result;										\
	PTB640_FSK_ADAPTER_INFO							pAdapterInfo;								\
	PTB640_FSK_TRUNK_INFO							pTrunkInfo;									\
	PTB640_FSK_TRUNK_RESOURCE_INFO					pTrunkResInfo;								\
	PTBX_ASYNC_REQUEST_CONTEXT						pAsyncRequest;								\
																								\
	CODE																						\
	{																							\
		pAsyncRequest = NULL;																	\
		pAdapterInfo = &(g_AppContext->ahAdapterInfo [in_pCallContext->un32AdapterIndex]);		\
		pTrunkInfo = &(pAdapterInfo->aTrunkInfo [in_pCallContext->un32TrunkIndex]);				\
		pTrunkResInfo = &(pTrunkInfo->aResourceInfo [in_pCallContext->un32TimeslotIndex]);		\

#define TB640_FSK_SERVICE_FUNCTION_ALLOC(__pVar,__un32Size,__MsgId)								\
		result = TBXAsyncCreateRequest (														\
		  pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx],								\
		  in_pCallContext->pOpContext,															\
		  (__MsgId),																			\
		  (__un32Size),																			\
		  TB640FskResponseMessageHandler,														\
		  &pAsyncRequest);																		\
		if (TBX_RESULT_FAILURE(result))															\
		{																						\
			TBX_EXIT_ERROR(result, 0, "Unable to create request context");						\

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -