void SporadicFrameEditDlg::OnButtonClickOk() { if ( 0 == nValidateValues() ) { IFrame* pFrame; LinFrameProps ouFrameProps; ouFrameProps.m_eLinFrameType = eLinInvalidFrame; if ( eEdit == m_ouMode ) { pFrame = *m_pouFrame; } else { m_pLdfCluster->CreateElement(eFrameElement, (IElement**)&pFrame); *m_pouFrame = pFrame; } if ( nullptr != pFrame ) { pFrame->GetProperties(ouFrameProps); //Frame Type ouFrameProps.m_eLinFrameType = eLinSporadicFrame; ouFrameProps.m_ouLINSporadicFrameProps.m_pouUnconditionalFrame.clear(); //Conditional Frames int nRow = ui.tableFrames->rowCount(); IFrame* pouTempFrame; for ( int i = 0 ; i < nRow; i++ ) { QTableWidgetItem* pItem = ui.tableFrames->item(i, 0); UID_ELEMENT uid = pItem->data(Qt::UserRole).value<UID_ELEMENT>(); if ( Qt::Checked == pItem->checkState() ) { m_pLdfCluster->GetElement(eFrameElement, uid, (IElement**)&pouTempFrame); if ( nullptr != pouTempFrame ) { ouFrameProps.m_ouLINSporadicFrameProps.m_pouUnconditionalFrame[uid] = uid; } } } pFrame->SetProperties(ouFrameProps); //Frame Name pFrame->SetName(ui.editFrameName->text().toStdString()); } LDFDatabaseManager::GetDatabaseManager()->setDocumentModified(true); accept(); } }
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; }
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()); }
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; }