示例#1
0
/**
* \brief         StartHardware
* \param         void
* \return        S_OK for success, S_FALSE for failure
* \authors       [email protected]
* \date          05.29.2015 Created
*/
HRESULT CDIL_LIN_Kvaser::StartHardware(void)
{
    // VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_HW_INTERFACE_SELECTED, ERR_IMPROPER_STATE);

    // USES_CONVERSION;
    HRESULT hResult = S_OK;

    //Connect to the network
    hResult = nConnect(TRUE);
    if (hResult == defERR_OK)
    {
        hResult = S_OK;
        sg_bCurrState = STATE_CONNECTED;
        // SetEvent(g_hDataEvent);
        vCreateTimeModeMapping(0);
    }
    else
    {
        //log the error for open port failure
        //vRetrieveAndLog(hResult, __FILE__, __LINE
        for ( int i = 0; i < 16; i++ )
        {
            // [email protected]
            // sg_aodChannels[i].m_nMapIdChecksumType.clear();
            m_MapIdClient[i].clear();
        }

        hResult = ERR_LOAD_HW_INTERFACE;
    }

    //If everything is ok start the read thread
    if (hResult == S_OK)
    {
        sg_sParmRThread.m_pBuffer = this;
        if (sg_sParmRThread.bStartThread(LINMsgReadThreadProc_LIN_Kvaser))
        {
            hResult = S_OK;
        }
        else
        {
            sg_pIlog->vLogAMessage(A2T(__FILE__), __LINE__, _("Could not start the read thread"));
        }
    }

    return hResult;
}
HRESULT CDIL_ISOLAR_EVE_VLIN::LIN_StartHardware(void)
{
    m_Ctrl_Status = NORMAL_ACTIVE;

    /* Transit into 'CREATE TIME MAP' state */
    sg_byCurrState = CREATE_MAP_TIMESTAMP;
    vCreateTimeModeMapping();
    if (sg_sParmRThread.bStartThread(LinMsgReadThreadProc_LIN_ISolar_Eve))
    {
        return S_OK;
    }
    else
    {
        return S_FALSE;
    }

}
HRESULT CDIL_LIN_VectorXL::PreStartHardware(void)
{
    VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_HW_INTERFACE_SELECTED, ERR_IMPROPER_STATE);

    USES_CONVERSION;
    HRESULT hResult = S_OK;

    //Connect to the network
    hResult = nConnect(TRUE);
    if (hResult == S_OK)
    {
        hResult = S_OK;
        sg_bCurrState = STATE_PRE_CONNECT;
        vCreateTimeModeMapping(g_hDataEvent[0]);
    }
    else
    {
        //log the error for open port failure
        //vRetrieveAndLog(hResult, __FILE__, __LINE
        for ( int i = 0; i < 16; i++ )
        {
            sg_aodChannels[i].m_nMapIdChecksumType.clear();
            m_MapIdClient[i].clear();
        }

        hResult = ERR_LOAD_HW_INTERFACE;
    }

    //If everything is ok start the read thread
    if (hResult == S_OK)
    {
        sg_sParmRThread.m_pBuffer = this;
        if (sg_sParmRThread.bStartThread(LINMsgReadThreadProc_LIN_Vector_XL))
        {
            hResult = S_OK;
        }

    }

    return hResult;
}