HRESULT CMsgContainerCAN::GetInterPretedSignalList(STCAN_MSG& ouMsg, SSignalInfoArray& ouSSignalInfoArray, bool isHexMode)
{
    if (nullptr == mBmNetwork)
    {
        return S_FALSE;
    }
    IFrame* pouFrame = nullptr;
    ERRORCODE eResult = mBmNetwork->GetFrame(CAN, 0, ouMsg.m_unMsgID, nullptr, &pouFrame);
    ouSSignalInfoArray.RemoveAll();
    if (EC_SUCCESS == eResult && nullptr != pouFrame)
    {
        std::list<InterpreteSignals> ouSignal;
        std::string strName;
        pouFrame->GetName(strName);
        pouFrame->InterpretSignals(ouMsg.m_ucData, ouMsg.m_ucDataLen, ouSignal, isHexMode, true);
for (auto ouSignalInfo : ouSignal)   //Only C++11;
        {
            SSignalInfo ouSignal;
            ouSignal.m_omEnggValue = ouSignalInfo.m_omEnggValue.c_str();
            ouSignal.m_omRawValue = ouSignalInfo.m_omRawValue.c_str();
            ouSignal.m_omSigName = ouSignalInfo.m_omSigName.c_str();
            ouSignal.m_omUnit = ouSignalInfo.m_omUnit.c_str();
            ouSignal.m_msgName = strName.c_str();
            ouSSignalInfoArray.Add(ouSignal);
        }
        return S_OK;
    }
    return S_FALSE;
}
HRESULT CMsgContainerJ1939::GetMessageDetails(__int64 nMapIndex, unsigned int& msgId, CString& msgName, bool formatHexForId)
{
    if (nullptr == mBmNetwork)
    {
        return S_FALSE;
    }

    STJ1939_MSG sJ1939Msg;
    std::string strName = "";
    HRESULT hResult = hReadFromOWBuffer(&sJ1939Msg, nMapIndex);

    msgId = sJ1939Msg.m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN();

    IFrame* pouFrame = nullptr;

    ERRORCODE eResult = mBmNetwork->GetFrame(LIN, 0, msgId, nullptr, &pouFrame);
    if (EC_SUCCESS == eResult && nullptr != pouFrame)
    {
        pouFrame->GetName(strName);
        msgName = strName.c_str();
    }
    else
    {
        if (formatHexForId == true)
        {
            msgName.Format("%d", msgId);
        }
        else
        {
            msgName.Format("0x%X", msgId);
        }
    }
}
HRESULT CMsgContainerCAN::GetMessageName(STCANDATA& sCANMsg, CString& msgName, bool formatHexForId)
{
    if (IS_ERR_MESSAGE(sCANMsg.m_ucDataType))
    {
        GetErrorInfo(sCANMsg, msgName);
    }
    else
    {
        //Message Name
        std::string strName = "";
        IFrame* pouFrame = nullptr;
        ERRORCODE eResult = mBmNetwork->GetFrame(CAN, 0, sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID, nullptr, &pouFrame);
        if (EC_SUCCESS == eResult && nullptr != pouFrame)
        {
            pouFrame->GetName(strName);
            msgName = strName.c_str();
        }
        else
        {
            if (formatHexForId == true)
            {
                msgName.Format("0x%X", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID);
            }
            else
            {
                msgName.Format("%d", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID);
            }
        }
    }
    return S_OK;
}
HRESULT CMsgContainerJ1939::GetInterPretedSignalList(STJ1939_MSG& ouMsg, SSignalInfoArray& ouSSignalInfoArray, bool isHexMode)
{
    if (nullptr == mBmNetwork)
    {
        return S_FALSE;
    }
    IFrame* pouFrame = nullptr;
    ERRORCODE eResult = mBmNetwork->GetFrame(J1939, 0, ouMsg.m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN(), nullptr, &pouFrame);
    ouSSignalInfoArray.RemoveAll();
    if (EC_SUCCESS == eResult && nullptr != pouFrame)
    {
        std::list<InterpreteSignals> ouSignal;
        std::string strName;
        pouFrame->GetName(strName);
        pouFrame->InterpretSignals(ouMsg.m_pbyData, ouMsg.m_unDLC, ouSignal, isHexMode, true);
for (auto ouSignalInfo : ouSignal)   //Only C++11;
        {
            SSignalInfo ouSignal;
            ouSignal.m_omEnggValue = ouSignalInfo.m_omEnggValue.c_str();
            ouSignal.m_omRawValue = ouSignalInfo.m_omRawValue.c_str();
            ouSignal.m_omSigName = ouSignalInfo.m_omSigName.c_str();
            ouSignal.m_omUnit = ouSignalInfo.m_omUnit.c_str();
            ouSignal.m_msgName = strName.c_str();
            ouSSignalInfoArray.Add(ouSignal);
        }
    }
    return S_OK;
}
void SporadicFrameEditDlg::vPrepareUIForEditMode()
{
    IFrame* pouFrame = *m_pouFrame;
    std::string strName;

    if ( nullptr != pouFrame )
    {
        unsigned int nUid;
        pouFrame->GetFrameId(nUid);
        pouFrame->GetName(strName);

        QString strTitle = "Edit SporadicFrame - ";
        strTitle+= + strName.c_str();
        setWindowTitle(strTitle);

        ui.editFrameName->setText(strName.c_str());
    }
}
Example #6
0
/******************************************************************************
Function Name  :  nGetMessageName
Input(s)       :  UINT unMsgId - Message ID
                  CString& omstrMsgName  - message Name
Output         :  INT
Functionality  :  Returns the Message Name
Member of      :  CDataBaseMsgList
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
INT CDataBaseMsgList::nGetMessageName(UINT unMsgId, CString& omstrMsgName)
{
    int retVal = ERR_INVALID_DATABASE;

    if ( nullptr != mCurrentCluster )
    {
        IFrame* frame = nullptr;
        omstrMsgName = "";
        mCurrentCluster->GetFrame( unMsgId, nullptr, &frame );
        retVal = ERR_WRONG_ID;
        if ( nullptr != frame )
        {
            std::string frameName;
            frame->GetName( frameName );
            omstrMsgName = frameName.c_str();
            retVal = S_OK;
        }
    }
    return retVal;
}
ERRORCODE CCommonLDFGenerator::nGetConfigurableFrames(ostringstream& omConfigFrames, std::string strLDFVersion ,std::list<ConfigFrameDetails> listFrames)
{
    if(listFrames.size() <= 0 && strLDFVersion == defLIN_VERSION_1_3)
    {
        return EC_FAILURE;
    }

    std::string strFrameName;
    FrameProps omFrameProps;
    IFrame* pFrame = nullptr;
    UID_ELEMENT unElmntId = INVALID_UID_ELEMENT;

    omConfigFrames << defLIN_CONFIG_FRAMES << defOPEN_BRACE << endl;
    int ninde = 0;
for(auto itrFrame : listFrames)
    {
        unElmntId = itrFrame.m_uidFrame;
        m_ouCluster->GetElement(eFrameElement, unElmntId, (IElement**)&pFrame);

        if(nullptr != pFrame)
        {
            unsigned int unFrameId = 0;
            pFrame->GetName(strFrameName);
            pFrame->GetProperties(omFrameProps);
            pFrame->GetFrameId(unFrameId);

            if(strLDFVersion == defLIN_VERSION_2_0)// slave version
            {
                omConfigFrames << defTAB << defTWOTAB << strFrameName.c_str() << defEQUAL
                               << defHEX << std::hex << itrFrame.m_unConfigMsgId << defSEMICOLON;
            }
            else if(strLDFVersion == defLIN_VERSION_2_1)
            {
                omConfigFrames << defTAB << defTWOTAB << strFrameName.c_str() << defSEMICOLON;
            }
        }
    }
    omConfigFrames << defTWOTAB << defCLOSE_BRACE;

    return EC_SUCCESS;
}
HRESULT CMsgContainerJ1939::GetMessageName(STJ1939_MSG& msg, CString& msgName, bool formatHexForId)
{
    //Message Name
    std::string strName = "";
    IFrame* pouFrame = nullptr;
    ERRORCODE eResult = mBmNetwork->GetFrame(J1939, 0, msg.m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN(), nullptr, &pouFrame);
    if (EC_SUCCESS == eResult && nullptr != pouFrame)
    {
        pouFrame->GetName(strName);
        msgName = strName.c_str();
    }
    else
    {
        if (formatHexForId == true)
        {
            msgName.Format("0x%X", msg.m_sMsgProperties.m_uExtendedID.m_unExtID);
        }
        else
        {
            msgName.Format("%d", msg.m_sMsgProperties.m_uExtendedID.m_unExtID);
        }
    }
    return S_OK;
}
void UnconditionalFrameEditDlg::SetUpUi()
{
    IFrame* pFrame = *m_pouFrame;
    m_bIsDynFrame = false;
    std::string strName, strECUName;
    QString strValue;
    LinFrameProps ouFrameProps;
    ouFrameProps.m_eLinFrameType = eLinInvalidFrame;
    std::map<std::string, std::string> maSubscribers;
    std::list<IEcu*> lstTxECUs, lstRxECUs;
    ui.editFrameName->setValidator(new QRegExpValidator(QRegExp(defIdentifier_RegExp)));
    PopulateFrameIdCombo();
    PopulateFrameLengthCombo();
    vPopulatePublishers();
    vEnableDynamicFrame();

    if(m_eUIMode == eNew)
    {
        ui.comboFrameLength->setCurrentText("4");
        ui.comboFrameId->setCurrentText(defNONE);
        ui.comboPublisher->setCurrentText(defNONE);
        ui.tableSignals->setRowCount(0);
        setWindowTitle("Create Unconditional Frame");
    }
    else if(m_eUIMode == eEdit)
    {
        if (pFrame == nullptr)
        {
            return;
        }

        pFrame->GetName(strName);
        pFrame->GetProperties(ouFrameProps);

        QString strTitle = "Edit Unconditional Frame - ";
        strTitle+= + strName.c_str();
        setWindowTitle(strTitle);

        // Set FrameId
        strValue = GetString(ouFrameProps.m_nMsgId);
        ui.comboFrameId->setCurrentText(strValue);

        // Set Frame Length
        strValue = GetString(ouFrameProps.m_unMsgSize, 10);          //Always Dec
        ui.comboFrameLength->setCurrentText(strValue);
        m_omFrameLength = strValue.toStdString();

        pFrame->GetEcus(eTx, lstTxECUs);
        pFrame->GetEcus(eRx, lstRxECUs);

        // Set Frame Name
        ui.editFrameName->setText(QString::fromStdString(strName));

        // Adding ECUs to Publisherlst and Subscriberlst
        vAddSubscribers(lstRxECUs);

        // Set Publisher
        if(lstTxECUs.size() > 0)
        {
            std::list<IEcu*>::iterator itrTxECU = lstTxECUs.begin();
            ((IEcu*)*itrTxECU)->GetName(strECUName);
            ui.comboPublisher->setCurrentText(QString::fromStdString(strECUName));
            m_omStrPublisher = strECUName;
        }

        PopulateFrameSignals();

        // Dynamic Frame
        std::list<unsigned int> ouDyanamicFramelist;
        void* pDynFrameList;
        m_pouLDFCluster->GetProperties(eLdfDyanmicFrameList, &ouDyanamicFramelist);

        auto itr = std::find(ouDyanamicFramelist.begin(), ouDyanamicFramelist.end(), ouFrameProps.m_nMsgId);
        if(ouDyanamicFramelist.end() != itr)
        {
            ui.chkDynFrame->setChecked(true);
            m_bIsDynFrame = true;
        }

        //Store Rx Ecus;

        pFrame->GetEcus(eRx, m_ouRxEcus);


    }
    m_unFrameId = GetUnsignedInt(ui.comboFrameId->currentText());
    vExistingFrameDetails(GetUnsignedInt(ui.comboFrameId->currentText()));
}
ERRORCODE CCommonLDFGenerator::nGenerateScheduleItem(CSheduleTableItem omShceduleItem, ostringstream& omSchedItemStream)
{
    IFrame* pFrame = nullptr;

    m_ouCluster->GetElement(eFrameElement, omShceduleItem.m_nFrameId, (IElement**)&pFrame);

    std::string strFrameName, strEcuName, strLDFVersion;
    std::ostringstream omStream, omPIDs;

    if(nullptr != pFrame)
    {
        pFrame->GetName(strFrameName);
    }
    IEcu* pECU = nullptr;

    if(omShceduleItem.m_nNode != INVALID_UID_ELEMENT)
    {
        m_ouCluster->GetElement(eEcuElement, omShceduleItem.m_nNode, (IElement**)&pECU);

        if(nullptr != pECU)
        {
            pECU->GetName(strEcuName);
        }
    }

    UID_ELEMENT idFrame;
    LIN_Settings ouSettings;
    m_ouCluster->GetProperties(eLINClusterProperties, &ouSettings);
    nGetLDFVersion(ouSettings.m_dProtocolVers, strLDFVersion);

    switch (omShceduleItem.m_eDiagType)
    {
        case eLIN_NORMAL_FRAME_ID:
            omSchedItemStream << defTAB << strFrameName.c_str() << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_MASTER_FRAME_ID:
            omSchedItemStream << defTAB << defMASTER_REQUEST << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SLAVE_FRAME_ID:
            omSchedItemStream << defTAB << defSLAVE_RESP << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_ASSIGN_NAD_ID:
            if(strLDFVersion == defLIN_VERSION_2_0)
            {
                omSchedItemStream << defTAB << defASSIGN_NAD << defOPEN_BRACE
                                  << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[0] << defCOMMA
                                  << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[7] << defCOMMA
                                  << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[3] << defCOMMA
                                  << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[5]
                                  <<  defCLOSE_BRACE
                                  << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            }
            else if(strLDFVersion == defLIN_VERSION_2_1)
            {
                omSchedItemStream << defTAB << defASSIGN_NAD << defOPEN_BRACE <<  strEcuName.c_str() << defCLOSE_BRACE
                                  << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            }
            break;
        case eLIN_SID_COND_CHANGE_NAD:
            omSchedItemStream << defTAB << defCONDITIONALCHANGENAD << defOPEN_BRACE
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[0] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[3] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[4] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[5] << defCOMMA
                              << defHEX << std::hex <<std::uppercase <<  (int)omShceduleItem.m_chDataBytes[6] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[7]
                              << defCLOSE_BRACE << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_DATA_DUMP:
            omSchedItemStream << defTAB << defDATADUMP << defOPEN_BRACE << strEcuName.c_str() << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[3] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[4] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[5] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[6] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[7] << defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_SAVE_CONFIG:
            omSchedItemStream << defTAB << defSAVECONFIG << defOPEN_BRACE <<  strEcuName.c_str() << defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_ASSIGN_FRAME_RANGE:

            nGetFramePIDs(omShceduleItem, omPIDs);
            omSchedItemStream << defTAB << defASSIGN_FRAMEID_RANGE << defOPEN_BRACE << strEcuName.c_str() << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)( omShceduleItem.m_chDataBytes[3] )<<  omPIDs.str() << defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_FREEFORMAT:
            omSchedItemStream << defTAB << defFREEFORMAT << defOPEN_BRACE
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[0] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[1] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[2] << defCOMMA
                              << defHEX << std::hex <<std::uppercase  << (int)omShceduleItem.m_chDataBytes[3]<< defCOMMA
                              << defHEX << std::hex <<std::uppercase <<  (int)omShceduleItem.m_chDataBytes[4] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[5]  << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[6] << defCOMMA
                              << defHEX << std::hex <<std::uppercase <<  (int)omShceduleItem.m_chDataBytes[7] <<  defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_READ_BY_IDENTIFIER:
            omSchedItemStream << defTAB << defFREEFORMAT << defOPEN_BRACE << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[0]
                              << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[1] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[2] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[3] << defCOMMA
                              << defHEX << std::hex <<std::uppercase <<  (int)omShceduleItem.m_chDataBytes[4] << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[5]  << defCOMMA
                              << defHEX << std::hex <<std::uppercase << (int)omShceduleItem.m_chDataBytes[6]  << defCOMMA
                              << defHEX << std::hex <<std::uppercase <<  (int)omShceduleItem.m_chDataBytes[7] <<  defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_ASSIGN_FRAME_ID:
            idFrame = omShceduleItem.m_chDataBytes[7];
            m_ouCluster->GetElement(eFrameElement, idFrame, (IElement**)&pFrame);

            if(nullptr != pFrame)
            {
                pFrame->GetName(strFrameName);
            }
            omSchedItemStream << defTAB << defASSIGNFRAMEID << defOPEN_BRACE << strEcuName.c_str() << defCOMMA << strFrameName.c_str() << defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        case eLIN_SID_UNASSIGN_FRAME_ID:
            idFrame = omShceduleItem.m_chDataBytes[7];
            m_ouCluster->GetElement(eFrameElement, idFrame, (IElement**)&pFrame);

            if(nullptr != pFrame)
            {
                pFrame->GetName(strFrameName);
            }
            omSchedItemStream << defTAB << defUNASSIGNFRAMEID << defOPEN_BRACE << strEcuName.c_str() << defCOMMA << strFrameName.c_str() << defCLOSE_BRACE
                              << defDELAY << omShceduleItem.m_dDelay << defUNIT_MS << defSEMICOLON;
            break;
        default:
            break;
    }
    return EC_SUCCESS;
}