Ejemplo n.º 1
0
ERRORCODE CCommonLDFGenerator::nGenerateScheduleTables()
{
    ostringstream omStringStream;
    std::map<UID_ELEMENT, IElement*> mapSchedTable;
    std::string strSchedTable, strFrameName;

    m_ouCluster->GetElementList(eScheduleTableElement, mapSchedTable);

    if(mapSchedTable.size() > 0)
    {
        omStringStream << defSCHEDULE_TABLES << defOPEN_BRACE << endl;
        IScheduleTable* pSchedTable;
        ScheduleTableProps pSchedProps;
for(auto itrSched : mapSchedTable)
        {
            pSchedTable = (IScheduleTable*)itrSched.second;

            if(nullptr != pSchedTable)
            {
                pSchedTable->GetName(strSchedTable);
                pSchedTable->GetProperties(pSchedProps);
            }

            omStringStream << defSPACE << strSchedTable.c_str() << defOPEN_BRACE << endl;

for(auto itrSchedItem : pSchedProps.m_ouCSheduleTableItem)
            {
                nGenerateScheduleItem(itrSchedItem, omStringStream);
            }

            omStringStream << defSPACE << defCLOSE_BRACE << endl;
        }

        omStringStream << defCLOSE_BRACE << endl;

        m_omFileStream << omStringStream.str();
    }
    else
    {
        omStringStream << defSCHEDULE_TABLES << defOPEN_BRACE << endl << defCLOSE_BRACE << endl;
        m_omFileStream << omStringStream.str();
    }

    return EC_NA;
}
Ejemplo n.º 2
0
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;
}