Exemplo n.º 1
0
Element writeSoftwareRadio( RadioRepresentation &swrDesc)
{
    Element e("softwareradio");

    //Write all the controllers
    vector<ControllerDescription> controllers = swrDesc.getControllers();
    vector<ControllerDescription>::iterator conIt;
    for(conIt=controllers.begin();conIt!=controllers.end();conIt++)
    {
        Element currentController = writeController(*conIt);
        e.InsertEndChild(currentController);
    }

    //Write all the engines
    vector<EngineDescription> engines = swrDesc.getEngines();
    vector<EngineDescription>::iterator engIt;
    for(engIt=engines.begin();engIt!=engines.end();engIt++)
    {
        Element currentEngine = writeEngine(*engIt);
        e.InsertEndChild(currentEngine);
    }

    //Write all the links
    vector<LinkDescription> links = swrDesc.getLinks();
    vector<LinkDescription>::iterator linkIt;
    for(linkIt=links.begin();linkIt!=links.end();linkIt++)
    {
        Element currentLink = writeLink(*linkIt);
        e.InsertEndChild(currentLink);
    }

    return e;
}
Exemplo n.º 2
0
void readSoftwareRadio(Element &headElem, RadioRepresentation& theRadio)
{
    //Check for illegal nodes here
    Iterator< Node > c;
    for ( c = c.begin(&headElem); c != c.end(); c++ )
    {
        if(c->Type() == TiXmlNode::ELEMENT)
        {
            string s = c->Value();
            if(s != "controller" && s != "engine" && s!= "link")
            {
                LOG(LFATAL) << "Illegal element in xml file: " << s;
                throw XmlParsingException("Illegal element in xml file: " + s);
            }
        }
    }

    //Parse all the controllers
    Iterator< Element > child("controller");
    for ( child = child.begin(&headElem); child != child.end(); child++ )
    {
        ControllerDescription con = readController(*child);
        theRadio.addControllerDescription(con);
    }

    //Parse all the engines
    Iterator< Element > child1("engine");
    for ( child1 = child1.begin(&headElem); child1 != child1.end(); child1++ )
    {
        EngineDescription eng = readEngine(*child1);
        theRadio.addEngineDescription(eng);
    }

    //Parse all the links
    Iterator< Element > child2("link");
    for ( child2 = child2.begin(&headElem); child2 != child2.end(); child2++ )
    {
        LinkDescription link = readLink(*child2);
        theRadio.addLinkDescription(link);
    }
}
Exemplo n.º 3
0
void XmlParser::parseXmlString( std::string &xml, RadioRepresentation &radio)
{
    try{
        Document doc;
        doc.Parse(xml);

        //Pull out the root element
        Element* head = doc.FirstChildElement();
        string headValue = head->Value();
        if( headValue == "softwareradio")
        {
            readSoftwareRadio(*head, radio);
        }else{
            throw XmlParsingException("The top element of the xml configuration must be softwareradio.");
        }

        //Instruct the radio description to build a graph of the radio
        radio.buildGraphs();
    }
    catch( Exception& ex )
    {
        throw XmlParsingException(ex.what());
    }
}
Exemplo n.º 4
0
    void EngineManager::loadRadio(RadioRepresentation rad)
    {
        //Set the current radio representation
        radioRep_ = rad;

        //Set the controller repositories in the ControllerManager
        controllerManager_.addRepository(reps_.contRepository);

        //Load the controllers
        vector<ControllerDescription> conts = rad.getControllers();
        vector<ControllerDescription>::iterator contIt;
        for(contIt=conts.begin(); contIt!=conts.end(); ++contIt)
        {
            controllerManager_.loadController(contIt->type);
        }

        engineGraph_ = rad.getEngineGraph();

        //Create the engines
        EngVertexIterator i, iend;
        for(b::tie(i,iend) = vertices(engineGraph_); i != iend; ++i)
        {
            //Get the engine description
            EngineDescription current = engineGraph_[*i];

            //Add the engine to our vector
            engines_.push_back(createEngine(current));
        }

        //Do a topological sort of the graph
        deque<unsigned> topoOrder;
        topological_sort(engineGraph_, front_inserter(topoOrder), b::vertex_index_map(b::identity_property_map()));

        //Go through graph in topological order and set buffers
        for(deque<unsigned>::iterator i = topoOrder.begin(); i != topoOrder.end(); ++i)
        {
            //Get input buffers
            vector< b::shared_ptr< DataBufferBase > > inputBuffers, outputBuffers;
            EngInEdgeIterator edgeIt, edgeItEnd;
            for(b::tie(edgeIt, edgeItEnd) = in_edges(*i, engineGraph_); edgeIt != edgeItEnd; ++edgeIt)
            {
                inputBuffers.push_back(engineGraph_[*edgeIt].theBuffer);
            }

            //Load the engine, passing in the input buffers
            outputBuffers = engines_[*i].loadEngine(engineGraph_[*i], inputBuffers);

            //Set the ouput buffers in the graph edges
            EngOutEdgeIterator outEdgeIt, outEdgeItEnd;
            for(b::tie(outEdgeIt, outEdgeItEnd) = out_edges(*i, engineGraph_); outEdgeIt != outEdgeItEnd; ++outEdgeIt)
            {
                for(vector< b::shared_ptr< DataBufferBase > >::iterator it = outputBuffers.begin(); it != outputBuffers.end(); ++it)
                {
                    LinkDescription first = (*it)->getLinkDescription();
                    LinkDescription second = engineGraph_[*outEdgeIt];
                    if(sameLink(first, second))
                    {
                        engineGraph_[*outEdgeIt].theBuffer = *it;
                        engineGraph_[*outEdgeIt].theBuffer->setLinkDescription( second );
                    }
                }
            }
        }
    }