Пример #1
0
/**
 * \return S_OK for success, S_FALSE for failure
 *
 * Registers a client to the DIL. ClientID will have client id
 * which will be used for further client related calls
 */
HRESULT CDIL_CAN_MHS::CAN_RegisterClient(BOOL bRegister, DWORD& ClientID, char* pacClientName)
{
HRESULT hResult = S_FALSE;
INT Index;

if (bRegister)
  {
  if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
    {
    Index = 0;
    if (!bClientExist(pacClientName, Index))
      {
      //Currently store the client information
      if (_tcscmp(pacClientName, CAN_MONITOR_NODE) == 0)
        {
        //First slot is reserved to monitor node
        ClientID = 1;
        _tcscpy(sg_asClientToBufMap[0].m_acClientName, pacClientName);
        sg_asClientToBufMap[0].m_dwClientID = ClientID;
        sg_asClientToBufMap[0].m_unBufCount = 0;
        }
      else
        {
        if (!bClientExist(CAN_MONITOR_NODE, Index))
          Index = sg_unClientCnt + 1;
        else
          Index = sg_unClientCnt;
        ClientID = dwGetAvailableClientSlot();
        _tcscpy(sg_asClientToBufMap[Index].m_acClientName, pacClientName);
        sg_asClientToBufMap[Index].m_dwClientID = ClientID;
        sg_asClientToBufMap[Index].m_unBufCount = 0;
        }
      sg_unClientCnt++;
      hResult = S_OK;
      }
    else
      {
      ClientID = sg_asClientToBufMap[Index].m_dwClientID;
      hResult = ERR_CLIENT_EXISTS;
      }
    }
  else
    hResult = ERR_NO_MORE_CLIENT_ALLOWED;
  }
else
  {
  if (bRemoveClient(ClientID))
    hResult = S_OK;
  else
    hResult = ERR_NO_CLIENT_EXIST;
  }
return(hResult);
}
Пример #2
0
/**
 * Register Client
 */
HRESULT CDIL_CAN_STUB::CAN_RegisterClient(BOOL bRegister,DWORD& ClientID, TCHAR* pacClientName)
{
    USES_CONVERSION;    
    HRESULT hResult = S_FALSE;
    if (bRegister)
    {
        if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
        {        
            INT Index = 0;
            if (!bClientExist(pacClientName, Index))
            {   
                _tcscpy(sg_asClientToBufMap[sg_unClientCnt].pacClientName, pacClientName);
                if (PerformAnOperation(REGISTER) == S_OK)
                {
                    ClientID = sg_asClientToBufMap[sg_unClientCnt].dwClientID = sg_ushTempClientID;
                    sg_asClientToBufMap[sg_unClientCnt].hClientHandle = sg_hTmpClientHandle;
                    sg_asClientToBufMap[sg_unClientCnt].hPipeFileHandle = sg_hTmpPipeHandle;
                    sg_asClientToBufMap[sg_unClientCnt].unBufCount = 0;
                    sg_unClientCnt++;
                    hResult = S_OK;
                }
            }
            else
            {
                ClientID = sg_asClientToBufMap[Index].dwClientID;
                hResult = ERR_CLIENT_EXISTS;
            }
        }
        else
        {
            hResult = ERR_NO_MORE_CLIENT_ALLOWED;
        }
    }
    else
    {
        if (bRemoveClient(ClientID))
        {
            hResult = S_OK;
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }
    return hResult;
}
Пример #3
0
/**
* \brief         Performs closure operations.
* \param         void
* \return        S_OK if the CAN_StopHardware call successfull otherwise S_FALSE
*/
HRESULT CDIL_CAN_MHS::CAN_PerformClosureOperations(void)
{
HRESULT hResult = S_OK;

hResult = CAN_StopHardware();
// ------------------------------------
// Close driver
// ------------------------------------
CanDownDriver();

// Remove all the existing clients
while (sg_unClientCnt > 0)
  bRemoveClient(sg_asClientToBufMap[0].m_dwClientID);
/* Delete the critical section */
DeleteCriticalSection(&sg_DIL_CriticalSection);
sg_bCurrState = STATE_DRIVER_SELECTED;
return(hResult);
}
Пример #4
0
/**
* \brief         Registers a client to the DIL.
* \param[in]     bRegister, if TRUE signifies 'Register', FALSE indicates 'Unregister'
* \param[out]    ClientID, is Client ID assigned, will be used for further client related calls
* \param[in]     pacClientName, is the client name
* \return        S_OK for success, S_FALSE for failure
* \authors       Arunkumar Karri
* \date          07.10.2011 Created
*/
HRESULT CDIL_ISOLAR_EVE_VCAN::CAN_RegisterClient(BOOL bRegister, DWORD& ClientID, char* pacClientName)
{
    USES_CONVERSION;
    HRESULT hResult = S_FALSE;

    if (bRegister)
    {
        if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
        {
            INT Index = 0;
            if (!bClientExist(pacClientName, Index))
            {
                /* Currently store the client information */
                if (_tcscmp(pacClientName, CAN_MONITOR_NODE) == 0)
                {
                    /* First slot is reserved to monitor node */
                    ClientID = 1;
                    _tcscpy(sg_asClientToBufMap[0].pacClientName, pacClientName);
                    sg_asClientToBufMap[0].dwClientID = ClientID;
                    sg_asClientToBufMap[0].unBufCount = 0;
                }
                else
                {
                    //if (!bClientExist(CAN_MONITOR_NODE, Index))
                    //{
                    //    Index = sg_unClientCnt + 1;
                    //}
                    //else
                    //{
                    //    /*Index = sg_unClientCnt;*/
                    //}
                    Index = sg_unClientCnt;
                    ClientID = dwGetAvailableClientSlot();
                    _tcscpy(sg_asClientToBufMap[Index].pacClientName, pacClientName);

                    sg_asClientToBufMap[Index].dwClientID = ClientID;
                    sg_asClientToBufMap[Index].unBufCount = 0;
                }
                sg_unClientCnt++;
                hResult = S_OK;
            }
            else
            {
                ClientID = sg_asClientToBufMap[Index].dwClientID;
                hResult = ERR_CLIENT_EXISTS;
            }
        }
        else
        {
            hResult = ERR_NO_MORE_CLIENT_ALLOWED;
        }
    }
    else
    {
        if (bRemoveClient(ClientID))
        {
            hResult = S_OK;
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }

    return hResult;
}