|
/* =============================================================================
* This notice must be untouched at all times.
*
* Copyright IntelliWizard Inc.
* All rights reserved.
* LICENSE: LGPL
* Web: http://www.intelliwizard.com
* eMail: info@intelliwizard.com
* We provide technical support for non-commercial or commercial UML StateWizard users.
* -----------------------------------------------------------------------------
* Filename: ServiceCall.cpp
*
* -----------------------------------------------------------------------------
* General description of this file:
*
* Service call agent.
* -----------------------------------------------------------------------------
* Revision History
* -----------------------------------------------------------------------------
* Version Date Author Revision Detail
* 1.0.0 2004/11/26 Initial
* ===========================================================================*/
/* =============================================================================
* INCLUDE FILES
* ===========================================================================*/
#include "sme.h"
#include "SrvAgent.h"
#include "ServiceCall.h"
/* =============================================================================
* LOCAL CONSTANTS
* ===========================================================================*/
/* =============================================================================
* LOCAL STRUCTURES AND OTHER TYPEDEFS
* ===========================================================================*/
/*==============================================================================
* LOCAL MACROS
* ===========================================================================*/
/*==============================================================================
* GLOBAL Variables
* ===========================================================================*/
extern HWND g_hSimWndHdle;
/******************************************************************************************
* DESCRIPTION: Make a service call by posting a message.
* INPUT:
long nSrvCallId: Call ID
void * pCallData: Function parameter data;
int nDataSize: Function parameter size.
* OUTPUT: None.
* NOTE:
* This function will allocate a memory block for parameter data. Simulator should free this
* memory block after receives a service call request.
********************************************************************************************/
BOOL AgtPostServiceCall(long nSrvCallId, void * pCallData, int nDataSize)
{
if (g_hSimWndHdle==NULL) return FALSE;
unsigned long nMsgSize = sizeof(SME_SRV_CALL_DATA_HDR_T) + nDataSize;
SME_SRV_CALL_DATA_HDR_T *pHdr = (SME_SRV_CALL_DATA_HDR_T *)(new char[nMsgSize]);
pHdr->nSrvCallId = nSrvCallId;
pHdr->nDataLen = nDataSize;
if (pCallData!=NULL && nDataSize>0)
{
void *pDataCopy = SME_HDR2CALLDATA(pHdr);
memcpy(pDataCopy, pCallData, nDataSize);
};
return PostMessage(g_hSimWndHdle,
WM_SRV_CALL_ID,
(WPARAM)pHdr,
(LPARAM)nMsgSize);
}
/******************************************************************************************
* DESCRIPTION: Make a service call by sending a message.
* INPUT:
long nSrvCallId: Call ID
void * pCallData: Function parameter data;
int nDataSize: Function parameter size.
* OUTPUT: None.
* NOTE:
* This function will NOT allocate a memory block for parameter data. Simulator should NOT free this
* memory block after receives a service calln request.
********************************************************************************************/
BOOL AgtSendServiceCall(long nSrvCallId, void * pCallData, int nDataSize)
{
if (g_hSimWndHdle==NULL) return FALSE;
unsigned long nMsgSize = sizeof(SME_SRV_CALL_DATA_HDR_T) + nDataSize;
SME_SRV_CALL_DATA_HDR_T *pHdr = (SME_SRV_CALL_DATA_HDR_T *)(new char[nMsgSize]);
pHdr->nSrvCallId = nSrvCallId;
pHdr->nDataLen = nDataSize;
if (pCallData!=NULL && nDataSize>0)
{
void *pDataCopy = SME_HDR2CALLDATA(pHdr);
memcpy(pDataCopy, pCallData, nDataSize);
};
// The SendMessage function sends the specified message to a window or windows. The function calls
// the window procedure for the specified window and does not return until the window procedure
// has processed the message.
// The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.
SendMessage(g_hSimWndHdle,
WM_SRV_CALL_ID,
(WPARAM)pHdr,
(LPARAM)nMsgSize);
return TRUE;
}
/******************************************************************************************
* DESCRIPTION: When a service call ends, delete the service call header.
* INPUT:
pHdr: Service call data header
* OUTPUT: None.
* NOTE:
********************************************************************************************/
BOOL AgtEndServiceCall(SME_SRV_CALL_DATA_HDR_T* pHdr)
{
if (pHdr!=NULL)
{
delete pHdr;
return TRUE;
} else return FALSE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.