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