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()); } }
/****************************************************************************** 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; }
void FilterGraph::process(const std::vector<IFrame*>& inputs, IFrame& output) { // Init the filter graph if(!_isInit) init(inputs, output); // Check whether we can bypass the input audio buffers const bool bypassBuffers = _inputAudioFrameBuffers.empty() || (areInputFrameSizesEqual(inputs) && areFrameBuffersEmpty()); size_t minInputFrameSamplesNb = 0; if(!bypassBuffers) { // Fill the frame buffer with inputs for(size_t index = 0; index < inputs.size(); ++index) { if(!inputs.at(index)->getDataSize()) { LOG_DEBUG("Empty frame from filter graph input " << index << ". Remaining audio frames in buffer: " << _inputAudioFrameBuffers.at(index).getBufferSize()); continue; } _inputAudioFrameBuffers.at(index).addFrame(inputs.at(index)); } // Get the minimum input frames size minInputFrameSamplesNb = getMinInputFrameSamplesNb(inputs); } // Setup input frames into the filter graph for(size_t index = 0; index < inputs.size(); ++index) { // Retrieve frame from buffer or directly from input IFrame* inputFrame = (bypassBuffers)? inputs.at(index) : _inputAudioFrameBuffers.at(index).getFrameSampleNb(minInputFrameSamplesNb); const int ret = av_buffersrc_add_frame_flags(_filters.at(index)->getAVFilterContext(), &inputFrame->getAVFrame(), AV_BUFFERSRC_FLAG_PUSH); if(ret < 0) { throw std::runtime_error("Error when adding a frame to the source buffer used to start to process filters: " + getDescriptionFromErrorCode(ret)); } } // Pull filtered data from the filter graph for(;;) { const int ret = av_buffersink_get_frame(_filters.at(_filters.size() - 1)->getAVFilterContext(), &output.getAVFrame()); if(ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) break; if(ret < 0) { throw std::runtime_error("Error reading buffer from buffersink: " + getDescriptionFromErrorCode(ret)); } } }
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; }
/************************************************************************************** Function Name : vGetSignalList Input(s) : ETYPE_BUS eBus,int nChannel, DWORD dwMsgCode,std::list<std::string>& lstSigNames Output : void Functionality : Gets list of Signal names for the given Message Code. Member of : CExploreMsgSg Author(s) : Robin G.K. Date Created : 27.10.2015 Requirement ID : RS_FLX_08_09_10 ***************************************************************************************/ void CExploreMsgSg::vGetSignalList(ETYPE_BUS eBus,int nChannel, DWORD dwMsgCode,std::list<std::string>& lstSigNames) { ICluster* pCluster = nullptr; IBMNetWorkGetService* pouClusterConfig = m_pGlobalObj->m_ouClusterConfig; if(nullptr!=pouClusterConfig) { pouClusterConfig->GetDBService(eBus, nChannel, 0, &pCluster); } IFrame* ouframeStrct = nullptr; unsigned int unFrameId = dwMsgCode; switch (eBus) { case CAN: case LIN: case J1939: if (nullptr != pCluster) { pCluster->GetFrame(unFrameId, nullptr, &ouframeStrct); } break; } std::map< ISignal*, SignalInstanse> mapSignals; if(nullptr != pCluster && nullptr != ouframeStrct) { ouframeStrct->GetSignalList(mapSignals); } std::string omSignalName; for(auto itrSignal : mapSignals) { (itrSignal.first)->GetName(omSignalName); lstSigNames.push_back(omSignalName); } }
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())); }
void UnconditionalFrameEditDlg::vUpdateEditFrameDetails() { LinFrameProps ouFrameProps; ouFrameProps.m_eLinFrameType = eLinInvalidFrame; UID_ELEMENT uidFrame; IFrame* pFrame = *m_pouFrame; uidFrame = pFrame->GetUniqueId(); pFrame->GetProperties(ouFrameProps); //2. Set Frame Props ouFrameProps.m_unMsgSize = GetUnsignedInt(ui.comboFrameLength->currentText(), 10); ouFrameProps.m_nMsgId = GetUnsignedInt(ui.comboFrameId->currentText()); ouFrameProps.m_eLinFrameType = eLinUnconditionalFrame; pFrame->SetProperties(ouFrameProps); std::list<IEcu*> lstECUs; pFrame->GetEcus(eTx, lstECUs); UID_ELEMENT uidECU; for(auto itrECU : lstECUs) { uidECU = itrECU->GetUniqueId(); itrECU->UnMapFrame(eTx, uidFrame); pFrame->UnMapNode(eTx, uidECU); } lstECUs.clear(); for(auto itrECU : m_ouRxEcus) { uidECU = itrECU->GetUniqueId(); itrECU->UnMapFrame(eRx, uidFrame); pFrame->UnMapNode(eRx, uidECU); } //3. Map Tx ECU and Map Tx Frame to Ecu IEcu* pouEcu = nullptr; UID_ELEMENT unEcuID = INVALID_UID_ELEMENT; std::string strPublisher = ui.comboPublisher->currentText().toStdString(); m_pouLDFCluster->GetEcu(strPublisher, &pouEcu); if ( pouEcu != nullptr ) { pouEcu->GetUniqueId(unEcuID); pFrame->MapNode(eTx, unEcuID); pouEcu->MapFrame(eTx, uidFrame); } //4. Map Signals and Map RX frames TO ecu SignalInstanse ouSignalInstance; ouSignalInstance.m_nStartBit = INVALID_DATA; ouSignalInstance.m_nUpdateBitPos = INVALID_DATA; ISignal* pSignal = nullptr; std::list<IEcu*> ecuList; UID_ELEMENT uidSignal; for( unsigned int unIndex = 0; unIndex < ui.tableSignals->rowCount(); unIndex++) { //QTreeWidgetItem *treeItem = ui.treeSignals->topLevelItem(unIndex); uidSignal = ui.tableSignals->item(unIndex, 0)->data(Qt::UserRole).value<UID_ELEMENT>(); m_pouLDFCluster->GetElement(eSignalElement, uidSignal, (IElement**)&pSignal); ecuList.clear(); if(nullptr != pSignal) { pSignal->GetEcus(eTx, ecuList); } //Ldf contains one Ecu so take First Ecu only; auto itrTxEcu = ecuList.begin(); if ( itrTxEcu != ecuList.end() ) { UID_ELEMENT unTempEcuId = INVALID_UID_ELEMENT; (*itrTxEcu)->GetUniqueId(unTempEcuId); if ( unTempEcuId == unEcuID ) { ouSignalInstance.m_nStartBit = GetUnsignedInt(ui.tableSignals->item(unIndex, 1)->text(), 10); pFrame->MapSignal(uidSignal, ouSignalInstance); ecuList.clear(); if(nullptr != pSignal) { pSignal->GetEcus(eRx, ecuList); } for ( auto itrEcu : ecuList ) { itrEcu->MapFrame(eRx, uidFrame); } } } } //1. Set Frame Name pFrame->SetName(ui.editFrameName->text().toStdString()); }
void UnconditionalFrameEditDlg::vUpdateNewFrameDetails() { FrameProps ouFrameProps; UID_ELEMENT uidFrame; IFrame* pFrame = nullptr; m_pouLDFCluster->CreateElement(eFrameElement, (IElement**)&pFrame); //2. Set Frame Props unsigned int nLength = GetUnsignedInt(ui.comboFrameLength->currentText(), 10); //Always Dec ouFrameProps.m_ouLINUnConditionFrameProps.m_nLength = nLength; ouFrameProps.m_ouLINUnConditionFrameProps.m_unId = GetUnsignedInt(ui.comboFrameId->currentText()); ouFrameProps.m_eFrameType = eLIN_Unconditional; pFrame->SetProperties(ouFrameProps); //3. Map Tx ECU and Map Tx Frame to Ecu IEcu* pouEcu = nullptr; UID_ELEMENT unEcuID = INVALID_UID_ELEMENT; m_pouLDFCluster->GetEcu(ui.comboPublisher->currentText().toStdString(), &pouEcu); if ( pouEcu != nullptr ) { pouEcu->GetUniqueId(unEcuID); pFrame->MapNode(eTx, unEcuID); uidFrame = pFrame->GetUniqueId(); pouEcu->MapFrame(eTx, uidFrame); } //4. Map Signals and Map RX frames TO ecu SignalInstanse ouSignalInstance; ISignal* pSignal = nullptr; std::list<IEcu*> ecuList; UID_ELEMENT uidSignal; for( unsigned int unIndex = 0; unIndex < ui.tableSignals->rowCount(); unIndex++) { //QTreeWidgetItem *treeItem = ui.treeSignals->topLevelItem(unIndex); uidSignal = ui.tableSignals->item(unIndex, 0)->data(Qt::UserRole).value<UID_ELEMENT>(); m_pouLDFCluster->GetElement(eSignalElement, uidSignal, (IElement**)&pSignal); ecuList.clear(); if(nullptr != pSignal) { pSignal->GetEcus(eTx, ecuList); } //Ldf contains one Ecu so take First Ecu only; auto itrTxEcu = ecuList.begin(); if ( itrTxEcu != ecuList.end() ) { UID_ELEMENT unTempEcuId = INVALID_UID_ELEMENT; (*itrTxEcu)->GetUniqueId(unTempEcuId); if ( unTempEcuId == unEcuID ) { unsigned int unStartBit = GetUnsignedInt(ui.tableSignals->item(unIndex, 1)->text(), 10); ouSignalInstance.m_nStartBit =unStartBit; //ouSignalInstance.m_nStartBit = treeItem->text(1).toInt(); pFrame->MapSignal(uidSignal, ouSignalInstance); ecuList.clear(); if(nullptr != pSignal) { pSignal->GetEcus(eRx, ecuList); } for ( auto itrEcu : ecuList ) { itrEcu->MapFrame(eRx, uidFrame); } } } } //1. Set Frame Name pFrame->SetName(ui.editFrameName->text().toStdString()); *m_pouFrame = pFrame; }
HRESULT VerifyCurrentMessage(STCANDATA& sCanData, CTSExecutionCAN* pTSXCan) { AfxTrace(_("In VERIFY - Before Enter\n")); EnterCriticalSection(&(pTSXCan->m_omCritSecTS)); AfxTrace(_("In VERIFY - After Enter\n")); if(pTSXCan->m_bTimeOver == TRUE || pTSXCan->m_pCurrentVerify == nullptr) { LeaveCriticalSection(&(pTSXCan->m_omCritSecTS)); return S_FALSE; } UINT unCount; pTSXCan->m_pCurrentVerify->GetSubEntryCount(unCount); if(pTSXCan->m_MsgVerifiedList.GetCount() < (INT)unCount) { CVerify_MessageData ouMsgData; if(pTSXCan->m_pCurrentVerify->GetMessageFromId(sCanData.m_uDataInfo.m_sCANMsg.m_unMsgID, &ouMsgData) == S_OK) { if (pTSXCan->m_MsgVerifiedList.Find(sCanData.m_uDataInfo.m_sCANMsg.m_unMsgID) == nullptr) { UCHAR pucData[8] = {0}; memcpy(pucData, &sCanData.m_uDataInfo.m_sCANMsg.m_ucData, sCanData.m_uDataInfo.m_sCANMsg.m_ucDataLen); //Interprete The Messages IFrame* sMsg; pTSXCan->m_pCurrentVerify->m_ouDataBaseManager.nGetMessageInfo(ouMsgData.m_omMessageName, &sMsg); //pTSXCan->m_ouMsgInterpret.vSetMessageList(sMsgEntry); //pTSXCan->m_ouMsgInterpret.bInterpretMsgs(ouMsgData.m_dwMessageID, pucData, ouSignalInfo); if ( nullptr != sMsg ) { CMessageResult ouMsgResult; if ( ouMsgData.m_byChannelNumber == sCanData.m_uDataInfo.m_sCANMsg.m_ucChannel ) // solves issue #711, 4th bullet point { std::list<InterpreteSignals> signlaList; sMsg->InterpretSignals( pucData, sizeof( pucData ), signlaList, false ); if ( pTSXCan->bVerifyCanMessage( ouMsgData, signlaList, ouMsgResult ) == TRUE ) { //pTSXCan->m_nVerifyCount++; if ( pTSXCan->m_ouVerifyResult != nullptr && pTSXCan->m_bTimeOver == FALSE ) { //pTSXCan->TSX_DisplayMessage(ouMsgData.m_omMessageName); //pTSXCan->TSX_DisplayResult(CString("SUCCESS")); pTSXCan->m_ouVerifyResult->m_MessageResultList.AddTail( ouMsgResult ); } pTSXCan->m_MsgVerifiedList.AddTail( (UINT&)ouMsgData.m_dwMessageID ); } } } } } } if(pTSXCan->m_MsgVerifiedList.GetCount() == (INT)unCount) { //pTSXCan->m_nVerifyCount = 0; pTSXCan->m_pCurrentVerify = nullptr; pTSXCan->m_ouVerifyEvent.SetEvent(); //pTSXCan->m_ouReadThread.m_unActionCode = INVOKE_FUNC; } LeaveCriticalSection(&(pTSXCan->m_omCritSecTS)); return S_OK; }
/****************************************************************************** Function Name : TSX_VerifyMessage Input(s) : Output : HRESULT Functionality : Member of : CTSExecutionCAN Friend of : - Author(s) : Venkatanarayana Makam Date Created : 01/04/2011 Modifications : ******************************************************************************/ HRESULT CTSExecutionCAN::TSX_VerifyMessage(CBaseEntityTA* pEntity, CResultVerify& ouVerifyResult) { //TODO::Proper Handling Required UCHAR pucData[8]; INT dataSize = 8; STCANDATA sCanData; UINT unVerifyCount; HRESULT hResult = S_OK; CBaseEntityTA* pVerifyEntity; CVerify_MessageData ouVerifyData; CString omResult; IFrame* sMsg; CVerifyData ouVerify; pEntity->GetSubEntryCount(unVerifyCount); ouVerifyResult.m_MessageResultList.RemoveAll(); pEntity->GetEntityData(VERIFY, &ouVerify); ouVerifyResult.m_eResult = ouVerify.m_eAttributeError; //Loop For all Messages for(UINT j=0; j<unVerifyCount; j++) { pEntity->GetSubEntityObj(j, &pVerifyEntity); pVerifyEntity->GetEntityData(VERIFY_MESSAGE, &ouVerifyData); if(m_ouCanBufVFSE.ReadFromBuffer(&sCanData, (__int64)ouVerifyData.m_dwMessageID)==0) { dataSize = sCanData.m_uDataInfo.m_sCANMsg.m_ucDataLen; memcpy(pucData, &sCanData.m_uDataInfo.m_sCANMsg.m_ucData, sCanData.m_uDataInfo.m_sCANMsg.m_ucDataLen); } else { dataSize = 8; memset(pucData, 0, 8); } //Interprete The Messages SMSGENTRY* sMsgEntry = new SMSGENTRY; pEntity->m_ouDataBaseManager.nGetMessageInfo(ouVerifyData.m_omMessageName, &sMsg); if ( nullptr == sMsg ) { return S_FALSE; } std::list<InterpreteSignals> interPretedSignalList; sMsg->InterpretSignals( pucData, dataSize, interPretedSignalList, false ); CString strVerDisplay = _("Verifying Message ")+ouVerifyData.m_omMessageName; TSX_DisplayMessage(strVerDisplay); //Verify The Signals CMessageResult ouMsgResult; omResult = _("SUCCESS"); if( ouVerifyData.m_byChannelNumber == sCanData.m_uDataInfo.m_sCANMsg.m_ucChannel ) // solves issue #711, 4th bullet point { if ( bVerifyCanMessage( ouVerifyData, interPretedSignalList, ouMsgResult ) == FALSE ) { omResult = _("FAIL"); hResult = S_FALSE; } } else { omResult = _("FAIL"); hResult = S_FALSE; } ouVerifyResult.m_MessageResultList.AddTail(ouMsgResult); TSX_DisplayResult(omResult); //delete []pucData; } if( S_FALSE != hResult ) { ouVerifyResult.m_eResult = SUCCESS; } return hResult; }
/****************************************************************************** Function Name : GetData Input(s) : MSXML2::IXMLDOMNodePtr& pIDomNode Output : HRESULT Functionality : Fill the datastructure from xml node pIDomNode Member of : CVerify_MessageEntity Friend of : - Author(s) : Venkatanarayana Makam, GT-Derka Date Created : 06/04/2011 Modifications : ******************************************************************************/ HRESULT CVerify_MessageEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode) { IXMLDOMNode* pIDOMChildNode; LONG lCount; CComBSTR bstrNodeName; CComVariant NodeValue; CString omstrTemp; CSignalCondition ouSignalCondition; IXMLDOMNamedNodeMapPtr pIDOMAttributes; pIDOMAttributes = pIDomNode->Getattributes();// get_attributes((IXMLDOMNamedNodeMap**)&pIDOMAttributes); //Retrieving Message ID bstrNodeName = def_STR_TCATTRIB_ID; pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode); pIDOMChildNode->get_nodeTypedValue(&NodeValue); omstrTemp = strCopyBSTRToCString(NodeValue); m_ouData.m_dwMessageID = atoi((LPCSTR)omstrTemp); m_ouData.m_omMessageName = omstrTemp; if(m_ouDataBaseManager.bIsValidMessageID(m_ouData.m_dwMessageID)== FALSE) { //TODO::INVALID MSG POSSIBLE ONLY WHEN THE FILE IS EDITED WITH NOTEPAD. return -1; } pIDOMChildNode->Release(); //Retrieving Message UNIT bstrNodeName = _(def_STR_TCATTRIB_UNIT); pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode); pIDOMChildNode->get_nodeTypedValue(&NodeValue); omstrTemp = strCopyBSTRToCString(NodeValue); if(omstrTemp == "RAW") { m_ouData.m_eSignalUnitType = RAW; } else // else if(omstrTemp == "ENG") { m_ouData.m_eSignalUnitType = ENG; } pIDOMChildNode->Release(); //Retrieving Message Channel bstrNodeName = def_STR_TCATTRIB_CHANNEL; pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode); m_ouData.m_byChannelNumber = 0; // set default-value for the case, the number is incorrect or the whole argument is missing if (NULL != pIDOMChildNode) // avoid crash in case XML-file -without channel-information- is loaded { pIDOMChildNode->get_nodeTypedValue(&NodeValue); omstrTemp = strCopyBSTRToCString(NodeValue); m_ouData.m_byChannelNumber = atoi((LPCSTR)omstrTemp); pIDOMChildNode->Release(); } if(m_ouData.m_byChannelNumber == 0) // if casting fails (failure in xml) { m_ouData.m_byChannelNumber = 1; // set default channel */ m_lDefaultChannelUsed = 1; } //Retrieving Signals and their Data IFrame* sMsg; IXMLDOMNodeListPtr pIDOMSignalList; IXMLDOMNode* pIDOMSChildSignal; bstrNodeName = _(def_STR_SIGNAL_NODE); pIDOMSignalList = pIDomNode->selectNodes((_bstr_t)bstrNodeName); pIDOMSignalList->get_length(&lCount); INT nRetVal; nRetVal = m_ouDataBaseManager.nGetMessageName(m_ouData.m_dwMessageID, m_ouData.m_omMessageName); if(nRetVal != S_OK) { return nRetVal; } nRetVal = m_ouDataBaseManager.nGetMessageInfo(m_ouData.m_omMessageName, &sMsg); if ( sMsg == nullptr ) { return nRetVal; } UINT unSignalCount = sMsg->GetSignalCount(); //W4 Removal - Local variable not required //UINT unTSSignalCount = lCount; std::map<ISignal*, SignalInstanse> signalList; sMsg->GetSignalList( signalList); std::string signalName; for (auto signal : signalList ) //for(UINT i = 0; i < unSignalCount; i++) { CSignalCondition ouSignalData, ouTSSignalData; signal.first->GetName( signalName ); ouSignalData.m_omSigName = signalName.c_str(); ouSignalData.m_omCondition = ""; for(int i = 0; i < lCount; i++) { pIDOMSignalList->get_item(i, &pIDOMSChildSignal); vRetrieveConditionSignalValue(pIDOMSChildSignal, ouTSSignalData); if(ouSignalData.m_omSigName == ouTSSignalData.m_omSigName) { ouSignalData.m_omCondition = ouTSSignalData.m_omCondition; break; } } m_ouData.m_odSignalConditionList.AddTail(ouSignalData); } return S_OK; }
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; }
int LDFEditor::nValidateForCluster(list<ParsingResults>& ouErrors, list<ParsingResults>& ouWarnings) { //1. Ecu Validations std::map<UID_ELEMENT, IElement*> pElement; LDFDatabaseManager::GetDatabaseManager()->GetLDFCluster()->GetElementList(eEcuElement, pElement); bool bMasterFound = false; bool bSlaveFound = false; LinEcuProps ecuProps; for ( auto itr : pElement ) { IEcu* pEcu = (IEcu*)itr.second; if ( nullptr == pEcu ) { continue; } pEcu->GetProperties(ecuProps); if (ecuProps.m_eEcuType == eMaster) { bMasterFound = true; } else if (ecuProps.m_eEcuType == eSlave) { bSlaveFound = true; } } if ( false == bMasterFound ) { ParsingResults ouPasringResult; ouPasringResult.m_ouErrorType = eError; ouPasringResult.m_strActionTaken = ""; ouPasringResult.m_strErrorDesc = "Master ECU should be defined in LDF File"; ouPasringResult.m_unErrorCode = 1; ouPasringResult.m_unLineNum = 0; ouErrors.push_back(ouPasringResult); } if ( false == bSlaveFound ) { ParsingResults ouPasringResult; ouPasringResult.m_ouErrorType = eError; ouPasringResult.m_strActionTaken = ""; ouPasringResult.m_strErrorDesc = "Atleast One Slave should be Defined in LDF File"; ouPasringResult.m_unErrorCode = 1; ouPasringResult.m_unLineNum = 0; ouErrors.push_back(ouPasringResult); } //2. UnCondition Frames bool bUnconditionalFrameFound = false;; pElement.clear(); LDFDatabaseManager::GetDatabaseManager()->GetLDFCluster()->GetElementList(eFrameElement, pElement); LinFrameProps frameProps; for ( auto itr : pElement ) { IFrame* pFrame = (IFrame*)itr.second; if ( nullptr == pFrame ) { continue; } pFrame->GetProperties(frameProps); if (frameProps.m_eLinFrameType == eLinUnconditionalFrame) { bUnconditionalFrameFound = true; break; } } if ( false == bUnconditionalFrameFound ) { ParsingResults ouPasringResult; ouPasringResult.m_ouErrorType = eWarning; ouPasringResult.m_strActionTaken = ""; ouPasringResult.m_strErrorDesc = "Valid LDF File should Contain Atleast one Unconditional Frame"; ouPasringResult.m_unErrorCode = 1; ouPasringResult.m_unLineNum = 0; ouWarnings.push_back(ouPasringResult); } //3. Signals bool SignalFound = false; pElement.clear(); LDFDatabaseManager::GetDatabaseManager()->GetLDFCluster()->GetElementList(eSignalElement, pElement); LINSignalProps ouSignalProps; for ( auto itr : pElement ) { ISignal* pSignal = (ISignal*)itr.second; if ( nullptr == pSignal ) { continue; } pSignal->GetProperties(ouSignalProps); if ( ouSignalProps.m_ouSignalType == eSignalNormal ) { SignalFound = true; break; } } if ( false == SignalFound ) { ParsingResults ouPasringResult; ouPasringResult.m_ouErrorType = eWarning; ouPasringResult.m_strActionTaken = ""; ouPasringResult.m_strErrorDesc = "Valid LDF File should Contain Atleast one signal"; ouPasringResult.m_unErrorCode = 1; ouPasringResult.m_unLineNum = 0; ouWarnings.push_back(ouPasringResult); } //4. Tables bool TableFound = false; pElement.clear(); LDFDatabaseManager::GetDatabaseManager()->GetLDFCluster()->GetElementList(eScheduleTableElement, pElement); for ( auto itr : pElement ) { ScheduleTableProps ouTableProps; IScheduleTable* pTable = (IScheduleTable*)itr.second; if ( nullptr == pTable ) { continue; } pTable->GetProperties(ouTableProps); if ( ouTableProps.m_ouCLINSheduleTableItem.size() > 0 ) { TableFound = true; break; } } if ( false == TableFound ) { ParsingResults ouPasringResult; ouPasringResult.m_ouErrorType = eWarning; ouPasringResult.m_strActionTaken = ""; ouPasringResult.m_strErrorDesc = "Valid LDF File should Contain Atleast one Schedule Table"; ouPasringResult.m_unErrorCode = 1; ouPasringResult.m_unLineNum = 0; ouWarnings.push_back(ouPasringResult); } return 0; }
ERRORCODE NodeSimCodeGenerator::GenerateHeaderFile(std::fstream& fileHeader, INsCodeGenHelper* codeGenHelper, ICluster* cluster) { //1. includes std::string headers; fileHeader << codeGenHelper->GetProtocolIncludesHeaderName(cluster) << std::endl; //2. cluster NameSpace; std::string clusterName = GetClusterName(cluster); fileHeader << defNameSpace << TAG_SPACE << clusterName << TAG_OPENFBRACE << std::endl; //3. Pdu namespace fileHeader << defNameSpace <<" " <<"PDU" << TAG_OPENFBRACE <<std::endl; //4. Pdu Decl char chTemp[256]; std::string pduName; std::map<UID_ELEMENT, IElement*> pduList; cluster->GetElementList(ePduElement, pduList); IPduCodeGenHelper* pduCodeGenHelper = codeGenHelper->GetPduCodeGenHelper(); PduProps pduProps; for ( auto itrPdu : pduList ) { IPdu* pdu = (IPdu*)(itrPdu.second); pdu->GetProperties(pduProps); fileHeader << pduCodeGenHelper->GetDecl(pdu) << std::endl; fileHeader << TAG_OPENFBRACE << std::endl; fileHeader << TAG_PUBLICSTART << std::endl; sprintf_s(chTemp, sizeof(chTemp), TAG_DATABYTEDECL, pduProps.m_unByteLength); fileHeader << chTemp; fileHeader << pduCodeGenHelper->GetBaseClassDecl(pdu) << std::endl; fileHeader << pduCodeGenHelper->GetSignalsDecl(pdu)<< std::endl; fileHeader << "};" << std::endl; pduName = pduCodeGenHelper->GetUniqueName(pdu); fileHeader << "typedef" << " " << "_" << pduName << " " << pduName <<TAG_SEMICOLON << std::endl; } //5. Endl Pdu namespace fileHeader << TAG_CLOSEFBRACE << std::endl; //6. Frame Namespace start fileHeader << defNameSpace <<" " <<"Frame" << TAG_OPENFBRACE <<std::endl; //7. Using namespace fileHeader <<"using namespace PDU;" << std::endl; //8. Class Decleration std::string frameName; std::map<UID_ELEMENT, IElement*> frameList; cluster->GetElementList(eFrameElement, frameList); IFrameCodeGenHelper* frameCodeGenHelper = codeGenHelper->GetFrameCodeGenHelper(); std::map<IPdu*, PduInstanse> pduMap; for ( auto itrPdu : frameList ) { IFrame* frame = (IFrame*)(itrPdu.second); fileHeader << frameCodeGenHelper->GetDecl(frame) << std::endl; fileHeader << TAG_OPENFBRACE << std::endl; fileHeader << TAG_PUBLICSTART << std::endl; fileHeader << frameCodeGenHelper->GetBaseClassDecl(frame) << std::endl; fileHeader << frameCodeGenHelper->GetPdusDecl(frame)<< std::endl; pduMap.clear(); frame->GetPduList(pduMap); if ( pduMap.size() == 0 ) { fileHeader << frameCodeGenHelper->GetSignalsDecl(frame)<< std::endl; } fileHeader << "};" << std::endl; } //9. Endl Frame namespace fileHeader << TAG_CLOSEFBRACE << std::endl; //10. Endl cluster namespace fileHeader << TAG_CLOSEFBRACE << std::endl; //11. using namespaces fileHeader << "using namespace" << " " <<clusterName << "::" << "Frame" <<TAG_SEMICOLON << std::endl; fileHeader << "using namespace" << " " <<clusterName << "::" << "PDU" <<TAG_SEMICOLON << std::endl; return EC_SUCCESS; }
ERRORCODE NodeSimCodeGenerator::GenerateCppFile(std::fstream& fileHeader, INsCodeGenHelper* codeGenHelper, ICluster* cluster) { //1. Header path std::string dbAppPath; GetBusMasterDBCachePath(dbAppPath); std::string strChkSum; std::string headerfilePath; cluster->GetDBFileChecksum(strChkSum); char headerFilePath[MAX_PATH*2]; headerfilePath = strChkSum + ".h"; PathCombine(headerFilePath, dbAppPath.c_str(), headerfilePath.c_str()); fileHeader <<"#include " << AddDoubleQuotes(headerFilePath) <<std::endl ; //2. namespace cluster std::string clusterName = GetClusterName(cluster); fileHeader <<defNameSpace <<" " << clusterName <<"{" <<std::endl ; //3. Cluster Id fileHeader << "unsigned long long g_strClusterPath = " <<"0x" << strChkSum <<TAG_SEMICOLON << std::endl ; //4. Pdu namespace fileHeader << defNameSpace <<" " <<"PDU" << TAG_OPENFBRACE <<std::endl; //5. pdu definition std::string pduName; std::map<UID_ELEMENT, IElement*> pduList; cluster->GetElementList(ePduElement, pduList); IPduCodeGenHelper* pduCodeGenHelper = codeGenHelper->GetPduCodeGenHelper(); PduProps pduProps; for ( auto itrPdu : pduList ) { IPdu* pdu = (IPdu*)(itrPdu.second); fileHeader << pduCodeGenHelper->GetConstructorDef(pdu) <<":" <<std::endl; fileHeader << pduCodeGenHelper->GetBaseClassConstructorDef(pdu) <<std::endl; fileHeader << pduCodeGenHelper->GetSignalsConstructorDef(pdu) << std::endl; fileHeader << TAG_OPENFBRACE << std::endl << TAG_CLOSEFBRACE <<std::endl; } //6. Endl Pdu namespace fileHeader << TAG_CLOSEFBRACE << std::endl; //7. Frame Namespace start fileHeader << defNameSpace <<" " <<"Frame" << TAG_OPENFBRACE <<std::endl; //8. Using namespace fileHeader <<"using namespace PDU;" << std::endl; //9. Frame definition std::string frameName; std::map<UID_ELEMENT, IElement*> frameList; std::map<IPdu*, PduInstanse> pduMap; cluster->GetElementList(eFrameElement, frameList); IFrameCodeGenHelper* frameCodeGenHelper = codeGenHelper->GetFrameCodeGenHelper(); for ( auto itrFrame : frameList ) { IFrame* frame = (IFrame*)(itrFrame.second); fileHeader << frameCodeGenHelper->GetConstructorDef(frame) <<":" <<std::endl; fileHeader << frameCodeGenHelper->GetBaseClassConstructorDef(frame) <<std::endl; fileHeader << frameCodeGenHelper->GetPdusConstructorDef(frame) << std::endl; pduMap.clear(); frame->GetPduList(pduMap); if ( pduMap.size() == 0 ) { fileHeader << frameCodeGenHelper->GetSignalsConstructorDef(frame) << std::endl; } fileHeader << TAG_OPENFBRACE << std::endl << TAG_CLOSEFBRACE <<std::endl; } //10. Endl Frame namespace fileHeader << TAG_CLOSEFBRACE << std::endl; //11. Cluster namespace fileHeader << TAG_CLOSEFBRACE << std::endl; return EC_SUCCESS; }