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