Esempio n. 1
0
HRESULT CDIL_CAN_STUB::CAN_PerformClosureOperations(void)
{
    //First remove all the client
    for (UINT nCount = 0; nCount < sg_unClientCnt; nCount++)
    {
        CAN_RegisterClient(FALSE, sg_asClientToBufMap[nCount].dwClientID, "");
    }
    // First disconnect from the simulation engine
    CAN_DeselectHwInterface();
    // Then terminate the broker thread
    sg_sBrokerObjBusEmulation.bTerminateThread();
    // Close the notification event
    if (NULL != sg_hNotifyFinish)
    {
        CloseHandle(sg_hNotifyFinish);
        sg_hNotifyFinish = NULL;
    }
    // Delete the critical section
    DeleteCriticalSection(&sg_CSBroker);

    sg_pIlog = NULL;         // Log interface pointer

    SetCurrState(STATE_PRIMORDIAL);

    return S_OK;
}
Esempio n. 2
0
HRESULT Worker_Disconnect(ISimENG* /*pISimENGLoc*/, Base_WrapperErrorLogger* pIlogLoc)
{
    if (GetCurrState() == STATE_PRIMORDIAL)
    {
        sg_acErrStr = _("CAN_STUB_DeselectHwInterface called at STATE_PRIMORDIAL");
        return S_FALSE;
    }
    else if (GetCurrState() == STATE_RESET)
    {
        pIlogLoc->vLogAMessage(__FILE__, __LINE__,
                               (_("CAN_STUB_DeselectHwInterface called at improper state")));
        return S_FALSE;
    }

    // Close the message reading thread
    if(sg_unClientCnt <= 0 )
    {
        //Some Error Happened But Thread close is required.
        //sg_unClientCnt = 0 means there is no data flow and thread
        //force termination is safe.
        sg_sParmRThreadStub.bForceTerminateThread();
    }
    else
    {
        sg_sParmRThreadStub.bTerminateThread();
    }

    return S_OK;
}
Esempio n. 3
0
/* Function to stop msg read thread*/
BOOL bStopGraphReadThread()
{
    BOOL bReturn = FALSE;
    bReturn = m_ouGraphReadThread.bTerminateThread();
    m_ouGraphReadThread.m_hActionEvent = NULL;
    m_ouGraphReadThread.m_unActionCode = IDLE;
    return bReturn;
}
Esempio n. 4
0
HRESULT Worker_Disconnect(ISimENG* /*pISimENGLoc*/, Base_WrapperErrorLogger* pIlogLoc)
{
    if (GetCurrState() == STATE_PRIMORDIAL)
    {
        sg_acErrStr = "CAN_STUB_DeselectHwInterface called at STATE_PRIMORDIAL";
        return S_FALSE;
    }
    else if (GetCurrState() == STATE_RESET)
    {
        pIlogLoc->vLogAMessage(__FILE__, __LINE__,
                               ("CAN_STUB_DeselectHwInterface called at improper state"));
        return S_FALSE;
    }

    // Close the message reading thread
    sg_sParmRThreadStub.bTerminateThread();
    return S_OK;
}
Esempio n. 5
0
void CSimENG::FinalRelease()
{
    // Close the message relay worker thread
    sg_sThreadCtrlObj.bTerminateThread();

    DeleteCriticalSection(&sg_CriticalSection);
    DeleteCriticalSection(&sg_CSMsgEntry);

    if (NULL != sg_pbEntry)
    {
        delete[] sg_pbEntry;
        sg_pbEntry = NULL;
        sg_nEntryLen = 0;
    }

    if (NULL != sg_pbEntry2)
    {
        delete[] sg_pbEntry2;
        sg_pbEntry2 = NULL;
        sg_nEntryLen2 = 0;
    }
}
Esempio n. 6
0
HRESULT CDIL_Ethernet_Interface::  Ethernet_StopHardware(void)
{
    VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_CONNECTED, ERR_IMPROPER_STATE);

    HRESULT hResult = S_OK;

    //Terminate the read thread
    sg_sParmRThread.bTerminateThread();
    SetEvent(g_hInformStopTx);
    hResult = nConnect(FALSE);
    if (hResult == defERR_OK)
    {
        hResult = S_OK;
        sg_bCurrState = STATE_HW_INTERFACE_SELECTED;
    }
    else
    {
        //log the error for open port failure
        vRetrieveAndLog(hResult, __FILE__, __LINE__);
        hResult = ERR_LOAD_HW_INTERFACE;
    }

    return hResult;
}