Skip to content
Snippets Groups Projects
Commit c8e04e51 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

Fix metadata loading for rblocks with a fixed number of instances.

parent 66b8339c
No related branches found
No related tags found
No related merge requests found
...@@ -101,51 +101,46 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc, ...@@ -101,51 +101,46 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc,
throw new PacketExceptionFileFormat("Too many number of blocks in the packet type."); throw new PacketExceptionFileFormat("Too many number of blocks in the packet type.");
maxNumberOfBlock[i] = atoi(nblocks); maxNumberOfBlock[i] = atoi(nblocks);
if(!idref) if(idref) {
{
stringstream ss;
ss << "idref attribute not defined for rblock" << rbNode.attribute("name").value();
throw new PacketExceptionFileFormat(ss.str().c_str());
}
string query = string("//field[@id=\"")+idref.value()+"\"]"; string query = string("//field[@id=\"")+idref.value()+"\"]";
pugi::xml_node numberofblocksid = doc.select_nodes(query.c_str())[0].node(); pugi::xml_node numberofblocksid = doc.select_nodes(query.c_str())[0].node();
pugi::xml_node nodetmp = rbNode; pugi::xml_node nodetmp = rbNode;
unsigned int level = 0; unsigned int level = 0;
while(nodetmp.parent() != numberofblocksid.parent()) while(nodetmp.parent() != numberofblocksid.parent()) {
{
// if the parent is a packet means that the id is not in the fixed part of the // if the parent is a packet means that the id is not in the fixed part of the
// recursive rblocks nor the sourcedatafield. So test the datafieldheader // recursive rblocks nor the sourcedatafield. So test the datafieldheader
// and header, otherwise complain. // and header, otherwise complain.
if(string(nodetmp.parent().name()).compare("packet") == 0) if(string(nodetmp.parent().name()).compare("packet") == 0) {
{
string idparentnodename = numberofblocksid.parent().name(); string idparentnodename = numberofblocksid.parent().name();
if(idparentnodename.compare("datafieldheader") == 0) if(idparentnodename.compare("datafieldheader") == 0) {
{
// we have already add 1 level because nodetmp in this case is // we have already add 1 level because nodetmp in this case is
// the sourcedatafield node // the sourcedatafield node
} }
else if(idparentnodename.compare("header") == 0) else if(idparentnodename.compare("header") == 0) {
{
// we add just one level for the same reason above // we add just one level for the same reason above
level++; level++;
} }
else else {
{
std::stringstream ss; std::stringstream ss;
ss << "Error on id association. Id'" << idref.value() << "' doesn't exists. idref defined by rblock '" << rbNode.attribute("name").value() << "'."; ss << "Error on id association. Id'" << idref.value() << "' doesn't exists. idref defined by rblock '" << rbNode.attribute("name").value() << "'.";
throw new PacketExceptionFileFormat(ss.str().c_str()); throw new PacketExceptionFileFormat(ss.str().c_str());
} }
break; break;
} }
level++; level++;
nodetmp = nodetmp.parent(); nodetmp = nodetmp.parent();
} }
headerLevelOfNBlockIndex[i] = level; headerLevelOfNBlockIndex[i] = level;
indexOfNBlock[i] = physicalIndex[numberofblocksid]; indexOfNBlock[i] = physicalIndex[numberofblocksid];
pugi::xml_attribute offsetAttr = numberofblocksid.attribute("numberofblocksoffset"); }
else {
headerLevelOfNBlockIndex[i] = 0;
indexOfNBlock[i] = 0;
}
pugi::xml_attribute offsetAttr = rbNode.attribute("numberofblocksoffset");
const char* offset; const char* offset;
if(offsetAttr) if(offsetAttr)
offset = offsetAttr.value(); offset = offsetAttr.value();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment