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; }
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; }