当前位置: 首页>>代码示例>>C++>>正文


C++ SimpleXMLTransfer::getChild方法代码示例

本文整理汇总了C++中SimpleXMLTransfer::getChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleXMLTransfer::getChild方法的具体用法?C++ SimpleXMLTransfer::getChild怎么用?C++ SimpleXMLTransfer::getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLTransfer的用法示例。


在下文中一共展示了SimpleXMLTransfer::getChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: putBackIntoCfg

void T_AxisMapper::putBackIntoCfg(SimpleXMLTransfer* cfgfile)
{
#if DEBUG_TX_INTERFACE > 0
  printf("T_AxisMapper::putBackIntoCfg(SimpleXMLTransfer* config)\n");
  printf(" --> %s\n", child_in_cfg.c_str());
#endif
  SimpleXMLTransfer* item;
  SimpleXMLTransfer* group;
  SimpleXMLTransfer* item2;

  try
  {
    item = cfgfile->getChild(child_in_cfg);
    group = item->getChild("bindings.axes");

    for (int i = T_AxisMapper::AILERON; i <= T_AxisMapper::PITCH; i++)
    {
      item2 = group->getChild(Global::inputDev->AxisStringsXML[i], true);
      item2->setAttributeOverwrite("axis", c_func[i]);
      item2->setAttributeOverwrite("polarity", doubleToString(c_inv[i]));
    }
  
    item2 = item->getChild("bindings");
    item2->setAttributeOverwrite("radio_type", RadioTypeStrings[radio_type]);
  }
  catch (XMLException e)
  {
    fprintf(stderr, "*** T_AxisMapper: XMLException: %s\n", e.what());
  }
}
开发者ID:gmorph,项目名称:crrcsim-ardupilot,代码行数:30,代码来源:inputdev.cpp

示例2: init

void T_AxisMapper::init(SimpleXMLTransfer* cfgfile, std::string childname)
{
#if DEBUG_TX_INTERFACE > 0
  printf("T_AxisMapper::init(cfg, child)\n");
  printf(" <-- %s\n", childname.c_str());
#endif
  SimpleXMLTransfer* inter;
  SimpleXMLTransfer* bindings;
  SimpleXMLTransfer* group;
  SimpleXMLTransfer* item;
  
  child_in_cfg = childname;

  // try to load config
  try
  {
    inter = cfgfile->getChild(childname, true);
    bindings  = inter->getChild("bindings", true);
    group     = bindings->getChild("axes", true);
  
    for (int i = T_AxisMapper::AILERON; i <= T_AxisMapper::PITCH; i++)
    {
      int default_axis = -1;
      float default_polarity = 1.0;

      // special handling for some default values
      if (i == T_AxisMapper::AILERON)
      {
        default_axis = 0;
      }
      else if (i == T_AxisMapper::ELEVATOR)
      {
        default_axis = 1;
        if (iface->inputMethod() != T_TX_Interface::eIM_joystick)
        {
          default_polarity = -1.0;
        }
      }
      
      item = group->getChild(Global::inputDev->AxisStringsXML[i], true);
      c_func[i] = item->attributeAsInt("axis", default_axis);
      c_inv[i]  = item->attributeAsDouble("polarity", default_polarity);
    }

    std::string radio = 
      strU(bindings->attribute("radio_type", RadioTypeStrings[CUSTOM]));

    for (int n=0; n < NR_OF_RADIO_TYPES; n++)
    {
      if (radio.compare(strU(RadioTypeStrings[n])) == 0)
      {
        setRadioType(n);
      }
    }
  }
  catch (XMLException e)
  {
    fprintf(stderr, "*** T_AxisMapper: XMLException: %s\n", e.what());
  }
}
开发者ID:gmorph,项目名称:crrcsim-ardupilot,代码行数:60,代码来源:inputdev.cpp

示例3: initSound

void CRRCAirplaneLaRCSim::initSound(SimpleXMLTransfer* xml)
{
  SimpleXMLTransfer* cfg = XMLModelFile::getConfig(xml);
  SimpleXMLTransfer* sndcfg = cfg->getChild("sound", true);
  int children = sndcfg->getChildCount();
  int units = sndcfg->getInt("units", 0);
  
  for (int i = 0; i < children; i++)
  {
    SimpleXMLTransfer *child = sndcfg->getChildAt(i);
    std::string name = child->getName();
    
    if (name.compare("sample") == 0)
    {
      T_AirplaneSound *sample;

      // assemble relative path
      std::string soundfile;
      soundfile           = child->attribute("filename");

      // other sound attributes
      int sound_type      = child->getInt("type", SOUND_TYPE_GLIDER);
      double dPitchFactor = child->getDouble("pitchfactor", 0.002);
      double dMaxVolume   = child->getDouble("maxvolume", 1.0);
  
      if (dMaxVolume < 0.0)
      {
        dMaxVolume = 0.0;
      }
      else if (dMaxVolume > 1.0)
      {
        dMaxVolume = 1.0;
      }

  //~ if (cfg->indexOfChild("power") < 0)
    //~ max_thrust = 0;
  //~ else
    //~ max_thrust = 1;
  
      if (soundfile != "")
      {
        // Get full path (considering search paths). 
        soundfile = FileSysTools::getDataPath("sounds/" + soundfile);
      }
      
      // File ok? Use default otherwise.
      if (!FileSysTools::fileExists(soundfile))
        soundfile = FileSysTools::getDataPath("sounds/fan.wav");
    
      std::cout << "soundfile: " << soundfile << "\n";
      //~ std::cout << "max_thrust: " << max_thrust << "\n";
      std::cout << "soundserver: " << Global::soundserver << "\n";
  
      // Only make noise if a sound file is available
      if (soundfile != "" && Global::soundserver != (CRRCAudioServer*)0)
      {        
        std::cout << "Using airplane sound " << soundfile << ", type " << sound_type << ", max vol " << dMaxVolume << std::endl;
        
        if (sound_type == SOUND_TYPE_GLIDER)
        {
          T_GliderSound *glidersound;
          float flMinRelV, flMaxRelV, flMaxDist;
          flMinRelV = (float)child->getDouble("v_min", 1.5);
          flMaxRelV = (float)child->getDouble("v_max", 4.0);
          flMaxDist = (float)child->getDouble("dist_max", 300);
          
          if (units == 1)
          {
            // convert from metric units to ft.
            flMaxDist *= M_TO_FT;
          }
          
          glidersound = new T_GliderSound(soundfile.c_str(), Global::soundserver->getAudioSpec());
          glidersound->setMinRelVelocity(flMinRelV);
          glidersound->setMaxRelVelocity(flMaxRelV);
          glidersound->setMaxDistanceFeet(flMaxDist);
          sample = glidersound;
        }
        else
        {
          sample = new T_EngineSound(soundfile.c_str(), Global::soundserver->getAudioSpec());
        }
                
        sample->setType(sound_type);
        sample->setPitchFactor(dPitchFactor);
        sample->setMaxVolume(dMaxVolume);
        sample->setChannel(Global::soundserver->playSample((T_SoundSample*)sample));
        sound.push_back(sample);
      }
    }
  }
}
开发者ID:ajakubek,项目名称:crrcsim_extensions,代码行数:92,代码来源:crrc_loadair.cpp

示例4: XMLException

void CRRC_AirplaneSim_MCopter01::LoadFromXML(SimpleXMLTransfer* xml, int nVerbosity)
{
  if (xml->getString("type").compare("mcopter01") != 0 ||
      xml->getInt("version") != 1)
  {
    throw XMLException("file is not for mcopter01");
  }    
    
  SimpleXMLTransfer* i;
  SimpleXMLTransfer* cfg = XMLModelFile::getConfig(xml);  
  
  {
    double to_slug;
    double to_slug_ft_ft;
    
    i = cfg->getChild("mass_inertia");
    switch (i->getInt("units"))
    {
     case 0:    
      to_slug       = 1;
      to_slug_ft_ft = 1;
      break;
     case 1:
      to_slug       = KG_TO_SLUG;
      to_slug_ft_ft = KG_M_M_TO_SLUG_FT_FT;
      break;
     default:
      {
        throw std::runtime_error("Unknown units in mass_inertia");
      }
      break;
    }
    Mass  = i->getDouble("Mass") * to_slug;
    I_xx  = i->getDouble("I_xx") * to_slug_ft_ft;
    I_yy  = i->getDouble("I_yy") * to_slug_ft_ft;
    I_zz  = i->getDouble("I_zz") * to_slug_ft_ft;
    I_xz  = i->getDouble("I_xz") * to_slug_ft_ft;
  }
    
  {
    speed_damp       = cfg->getDouble("aero.speed.damp");
    roll_damp1       = cfg->getDouble("aero.roll.damp1", 0);
    yaw_damp1        = cfg->getDouble("aero.yaw.damp1",  0);    
    roll_damp2       = cfg->getDouble("aero.roll.damp2", 0);    
    yaw_damp2        = cfg->getDouble("aero.yaw.damp2",  0);    
        
    yaw_dist         = cfg->getDouble("aero.yaw.dist", 0);    
    roll_dist        = cfg->getDouble("aero.roll.dist", 0);
    pitch_dist       = cfg->getDouble("aero.pitch.dist", roll_dist);
    
    // The ground effect parameters should be quite independent of the helicopter
    // parameters...shouldn't they? However, they can be adjusted.
    dGEDistMul  = xml->getDouble("GroundEffect.dist.mul",  1.5);

    {
      double tau  = xml->getDouble("Disturbance.tau_filter", 0.2);
      dist_t_init = xml->getDouble("Disturbance.time",       0.2);

      filt_rnd_yaw.SetTau(tau);
      filt_rnd_roll.SetTau(tau);
      filt_rnd_pitch.SetTau(tau);
    }
  }  
  
  wheels.init(xml, 0);
  dRotorRadius = wheels.getWingspan()*0.5;
  dRotorZ      = wheels.getZHigh();

  wheels.init(xml, 0);
  dRotorRadius = wheels.getWingspan()*0.5;
  dRotorZ      = wheels.getZHigh();

  props.clear();
  i = cfg->getChild("aero.props");
  for (int n=0; n<i->getChildCount(); n++)
    props.push_back(Propdata(i->getChildAt(n)));

  if (power.size() == 0)
  {    
    for (unsigned int n=0; n<props.size(); n++)
      power.push_back(new Power::Power(cfg, nVerbosity));
    dURef = 0.7 * cfg->getDouble("power.battery.U_0");
  }
  else
  {
    for (unsigned int n=0; n<power.size(); n++)
      power[n]->ReloadParams(cfg, nVerbosity);
  }
  
  controllers.clear();  
  Controller::LoadList(cfg->getChild("controllers"), controllers);  
}
开发者ID:KISSMonX,项目名称:crrcsim-pprz,代码行数:92,代码来源:fdm_mcopter01.cpp


注:本文中的SimpleXMLTransfer::getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。