Пример #1
0
int CLogObjectCAN::Der_SetConfigData(xmlNodePtr pNodePtr)
{
    int nResult = S_OK;
    SFILTERAPPLIED_CAN sFilterApplied;
    CStringArray omStrFilters;

    if (S_OK == sFilterApplied.nSetXMLConfigData(pNodePtr->doc))
    {
        while(pNodePtr != NULL) //TODO:Move To Utils
        {
            if ( pNodePtr->xmlChildrenNode != NULL )
            {
                if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Filter")))
                {
                    xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
                    if(NULL != key)
                    {
                        omStrFilters.Add((char*)key);
                        xmlFree(key);
                    }
                }
            }
            pNodePtr = pNodePtr->next;
        }
        sFilterApplied.nGetFiltersFromName(m_sFilterApplied, omStrFilters);
    }
    return nResult;
}
Пример #2
0
int CLogObjectCAN::Der_SetConfigData(xmlNodePtr pNodePtr)
{
    int nResult = S_OK;
    SFILTERAPPLIED_CAN sFilterApplied;
    CStringArray omStrFilters;
    map<string, int> mapFilters;
    if (S_OK == sFilterApplied.nSetXMLConfigData(pNodePtr->doc, CAN))
    {
        while(pNodePtr != NULL) //TODO:Move To Utils
        {
            if ( pNodePtr->xmlChildrenNode != NULL )
            {
                if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Filter")))
                {
                    int nEnabled = 1;
                    xmlAttrPtr pAttr = pNodePtr->properties;
                    while (pAttr)
                    {
                        // walk through all the attributes and find the required one
                        if (pAttr->type == XML_ATTRIBUTE_NODE)
                        {
                            std::string strAttrName((char*)pAttr->name);
                            if ((strAttrName == "IsEnabled") )
                            {
                                nEnabled = atoi((char*)pAttr->children->content);
                                break; // found
                            }
                        }
                        pAttr = pAttr->next;
                    }

                    xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
                    if(NULL != key)
                    {
                        mapFilters[(char*)key] = nEnabled;
                        xmlFree(key);
                    }
                }
            }
            pNodePtr = pNodePtr->next;
        }
        //sFilterApplied.nGetFiltersFromName(m_sFilterApplied, omStrFilters);
        sFilterApplied.nGetFiltersFromName(m_sFilterApplied, mapFilters);
    }
    return nResult;
}
Пример #3
0
int CReplayFile::nLoadXMLConfig(xmlNodePtr pNodePtr)
{
    int nRetValue = S_OK;
    xmlNodePtr pTempNode = pNodePtr;
    CStringArray omStrFilters;
    while( NULL != pNodePtr )
    {
        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Log_File_Path")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                if(PathIsRelative((char*)key) == TRUE)
                {
                    std::string omStrConfigFolder;
                    std::string omPath;
                    char configPath[MAX_PATH];
                    AfxGetMainWnd()->SendMessage(MSG_GET_CONFIGPATH, (WPARAM)configPath, 0);
                    CUtilFunctions::nGetBaseFolder(configPath, omStrConfigFolder );
                    char chAbsPath[MAX_PATH];
                    PathCombine(chAbsPath, omStrConfigFolder.c_str(), (char*)key);
                    m_omStrFileName = chAbsPath;
                }
                else
                {
                    m_omStrFileName = (char*)key;
                }
                xmlFree(key);
            }
        }

        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"IsEnabled")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_bEnabled = xmlUtils::getBooleanValue((char*)key);
                xmlFree(key);
            }
        }


        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Retain_Recored_Time")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_nTimeMode = xmlUtils::getBooleanValue((char*)key);
                xmlFree(key);
            }
        }
        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Message_Delay")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_unMsgTimeDelay = atoi((char*)key);
                xmlFree(key);
            }
        }

        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Is_Cyclic_Mode")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_nReplayMode = (int)xmlUtils::getBooleanValue((char*)key);
                xmlFree(key);
            }
        }


        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Cyclic_Delay")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_unCycleTimeDelay = atoi((char*)key);
                xmlFree(key);
            }
        }
        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"IsInteractive")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                m_bInteractive = (int)xmlUtils::getBooleanValue((char*)key);
                xmlFree(key);
            }
        }
        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Replay_Message_Direction")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                this->m_ouReplayMsgType = xmlUtils::bGetDirection((char*)key);
                xmlFree(key);
            }
        }

        if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Filter")))
        {
            xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1);
            if(NULL != key)
            {
                omStrFilters.Add((char*)key);
                xmlFree(key);
            }
        }
        pNodePtr = pNodePtr->next;
    }
    //Filters

    if( omStrFilters.GetSize() > 0 && pTempNode != NULL)
    {
        SFILTERAPPLIED_CAN sFilterApplied;
        if( sFilterApplied.nSetXMLConfigData(pTempNode->doc) == S_OK)
        {
            sFilterApplied.nGetFiltersFromName(m_sFilterApplied, omStrFilters);
            /*
            int nRealFilters = 0;
            for(int i = 0; i < omStrFilters.GetSize(); i++)
            {
                int nIndex = GetFilterNameIndex((LPCSTR)omStrFilters.GetAt(i), sFilterApplied);
                if(nIndex >= 0)
                {
                    nRealFilters++;
                }
                else
                {
                    omStrFilters.RemoveAt(i);
                }
            }
            m_sFilterApplied.m_bEnabled = sFilterApplied.m_bEnabled;
            m_sFilterApplied.m_ushTotal = omStrFilters.GetSize();
            m_sFilterApplied.m_psFilters = new SFILTERSET[m_sFilterApplied.m_ushTotal];

            for(int i = 0; i < omStrFilters.GetSize(); i++)
            {
                int nIndex = GetFilterNameIndex((LPCSTR)omStrFilters.GetAt(i), sFilterApplied);
                if(nIndex >= 0)
                {
                    m_sFilterApplied.m_psFilters[i].bClone(sFilterApplied.m_psFilters[nIndex]);
                }
            }*/
        }

    }
    return nRetValue;
}