コード例 #1
0
/**
 * @brief
 *  Registers the buffer pBufObj to the client ClientID.
 *
 * @param byAction
 *  contains one of the values MSGBUF_ADD or MSGBUF_CLEAR.
 * @param ClientID
 *  ClientID, is the client ID.
 * @param [in,out]  pBufObj
 *  pBufObj, is pointer to CBaseCANBufFSE object.
 *
 * @return
 *  S_FALSE for failure.
 *  S_OK for success,
 *
 * @remarks  TODO: Don't forget to fill in the remarks!
 */
HRESULT CDIL_CAN_IXXAT_VCI::CAN_ManageMsgBuf(BYTE byAction, DWORD ClientID, CBaseCANBufFSE* pBufObj)
{
#ifdef _IXXAT_DEBUG
    LogMessage(TRUE, "------> CDIL_CAN_IXXAT_VCI::CAN_ManageMsgBuf  - Action: %u  ClientID: %u\n", byAction, ClientID);
#endif
    HRESULT hResult = S_FALSE;
    if (pBufObj)
    {
        CClientBuffer* pClientBuf = m_ClientList.GetClientByID(ClientID);
        if (pClientBuf)
        {
            if (byAction == MSGBUF_ADD)
            {
                /* Add msg buffer */
                hResult = pClientBuf->AddMsgBuf(pBufObj);
            }
            else if (byAction == MSGBUF_CLEAR)
            {
                /* clear msg buffer */
                if (pBufObj != nullptr)
                {
                    hResult = pClientBuf->RemoveMsgBuf(pBufObj);
                }
                else
                {
                    // remove all message buffers
                    hResult = pClientBuf->RemoveAllMsgBuf();
                }
            }
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }
    else
    {
        if (byAction == MSGBUF_CLEAR)
        {
            /* clear msg buffer */
            hResult = m_ClientList.RemoveAllMsgBufOnAllClients();
        }
    }
    return hResult;
}
コード例 #2
0
HRESULT CCommanDIL_Flexray::FLEXRAY_ManageMsgBuf(BYTE byAction, DWORD ClientID, CBaseFLEXBufFSE* pBufObj)
{
    HRESULT hResult = S_FALSE;
    if (pBufObj)
    {
        CClientBuffer* pClientBuf = m_ClientList.GetClientByID(ClientID);
        if (pClientBuf)
        {
            if (byAction == MSGBUF_ADD)
            {
                /* Add msg buffer */
                hResult = pClientBuf->AddMsgBuf(pBufObj);
            }
            else if (byAction == MSGBUF_CLEAR)
            {
                /* clear msg buffer */
                if (pBufObj != NULL)
                {
                    hResult = pClientBuf->RemoveMsgBuf(pBufObj);
                }
                else
                {
                    // remove all message buffers
                    hResult = pClientBuf->RemoveAllMsgBuf();
                }
            }
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }
    else
    {
        if (byAction == MSGBUF_CLEAR)
        {
            /* clear msg buffer */
            hResult = m_ClientList.RemoveAllMsgBufOnAllClients();
        }
    }
    return hResult;
}