Exemple #1
0
//!xerces start element event
void amis::io::NccFileReader::startElement(const   XMLCh* const    uri,
        const   XMLCh* const    localname,
        const   XMLCh* const    qname,
        const   Attributes&	attributes)
{
    //get the name of the node from xerces
    char *node_name_ = XMLString::transcode(qname);
    string node_name;
    node_name.assign(node_name_);
    XMLString::release(&node_name_);

    int lvl = isHeading(node_name);
    //if this is a heading node
    if (lvl > 0)
    {
        processHeading(lvl, &attributes);
    }
    else if(node_name.compare("span") == 0)
    {
        processSpan(&attributes);
    }
    else if(node_name.compare("div") == 0)
    {
        processDiv(&attributes);
    }
    else if(node_name.compare("meta") == 0 ||
            node_name.substr(0, 3).compare("dc:") == 0)
    {
        processMetadata(node_name, &attributes);
    }

    //special condition for links due to the nested <a> element
    else if (node_name.compare("a") == 0)
    {
        string href;
        href.assign(SimpleAttrs::get("href", &attributes));

        mbFlag_GetChars = true;
        mTempChars.erase();

        if (mListType == 0)
        {
            mpCurrentNavPoint->setContent(href);
        }
        else if (mListType == 1)
        {
            //nav list
            mpCurrentNavTarget->setContent(href);
        }
        else if (mListType == 2)
        {
            //page list
            mpCurrentPageTarget->setContent(href);
        }
    }

}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// X MODE //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void processFlightControlXMode(void) {
  // ********************** Calculate Flight Error ***************************
  calculateFlightError();
  
  // ********************** Update Yaw ***************************************
  processHeading();

  // ********************** Altitude Adjust **********************************
  //processAltitudeHold();

  // ********************** Calculate Motor Commands *************************
  if (armed && safetyCheck) {
    // Front = Front/Right, Back = Left/Rear, Left = Front/Left, Right = Right/Rear 
    motors.setMotorCommand(FRONT, throttle - motors.getMotorAxisCommand(PITCH) + motors.getMotorAxisCommand(ROLL) - motors.getMotorAxisCommand(YAW));
    motors.setMotorCommand(RIGHT, throttle - motors.getMotorAxisCommand(PITCH) - motors.getMotorAxisCommand(ROLL) + motors.getMotorAxisCommand(YAW));
    motors.setMotorCommand(LEFT, throttle + motors.getMotorAxisCommand(PITCH) + motors.getMotorAxisCommand(ROLL) + motors.getMotorAxisCommand(YAW));
    motors.setMotorCommand(REAR, throttle + motors.getMotorAxisCommand(PITCH) - motors.getMotorAxisCommand(ROLL) - motors.getMotorAxisCommand(YAW));
  } 

  // *********************** process min max motor command *******************
  processMinMaxMotorCommand();

  // Allows quad to do acrobatics by lowering power to opposite motors during hard manuevers
  if (flightMode == ACRO) {
    processHardManuevers();
  }

  // Apply limits to motor commands
  for (int motor = FRONT; motor < LASTMOTOR; motor++) {
    motors.setMotorCommand(motor, constrain(motors.getMotorCommand(motor), motors.getMinCommand(motor), motors.getMaxCommand(motor)));
  }

  // If throttle in minimum position, don't apply yaw
  if (receiver.getData(THROTTLE) < MINCHECK) {
    for (int motor = FRONT; motor < LASTMOTOR; motor++) {
      motors.setMotorCommand(motor, MINTHROTTLE);
    }
  }

  // ESC Calibration
  if (armed == OFF) {
    processCalibrateESC();
  }

  // *********************** Command Motors **********************
  if (armed == ON && safetyCheck == ON) {
    motors.write(); // Defined in Motors.h
  }
}
Exemple #3
0
//!xerces start element event
void amis::io::NcxFileReader::startElement(const   XMLCh* const    uri,
		const   XMLCh* const    localname,
		const   XMLCh* const    qname,
		const   Attributes&	attributes)
{
	char *node_name_ = XMLString::transcode(qname);
	string node_name;
	node_name.assign(node_name_);
	XMLString::release(&node_name_);

	if (node_name.compare("navMap") == 0)
	{
		mListType = 0;
	}
	//if this is a heading node
	else if (node_name.compare("navPoint") == 0)
	{ 
		processHeading(&attributes);
	}
	else if(node_name.compare("docTitle") == 0)
	{
		mpTitle = new amis::MediaGroup();
		mpCurrentMediaGroup = mpTitle;
	}
	else if(node_name.compare("docAuthor") == 0)
	{
		mpAuthor = new amis::MediaGroup();	
		mpCurrentMediaGroup = mpAuthor;
	}
	else if(node_name.compare("navLabel") == 0)
	{
		processNavLabel(&attributes);
	}
	else if(node_name.compare("text") == 0)
	{
		processText(&attributes);
	}
	else if(node_name.compare("audio") == 0)
	{
		processAudio(&attributes);
	}
	else if(node_name.compare("navTarget") == 0)
	{
		processNavTarget(&attributes);
	}
	else if(node_name.compare("pageTarget") == 0)
	{
		processPageTarget(&attributes);
	}
	else if(node_name.compare("content") == 0)
	{
		string src;
		src.assign(SimpleAttrs::get("src", &attributes));
		if (mListType == 0)
			mpCurrentNavPoint->setContent(src);
		else if(mListType == 2)
			mpCurrentPageTarget->setContent(src);
		else if(mListType == 1)
			mpCurrentNavTarget->setContent(src);
	}
	else if(node_name.compare("navList") == 0)
	{
		mListType = 1;
		string class_value;
		class_value.assign(SimpleAttrs::get("class", &attributes));
		int idx = mpNavModel->addNavList(class_value);
		amis::dtb::nav::NavList* p_list = mpNavModel->getNavList(idx);
	}
	else if(node_name.compare("pageList") == 0)
	{
		mListType = 2;
		amis::dtb::nav::PageList* p_list = mpNavModel->getPageList();
	}
	else if(node_name.compare("navInfo") == 0)
	{
		mpCurrentMediaGroup = new amis::MediaGroup();
		if (mListType == 0)
			mpNavModel->getNavMap()->setNavInfo(mpCurrentMediaGroup);
		else if (mListType == 2)
			mpNavModel->getPageList()->setNavInfo(mpCurrentMediaGroup);
		else if (mListType == 1)
			mpNavModel->getNavLists()->back()->setNavInfo(mpCurrentMediaGroup);
	}
	else if(node_name.compare("smilCustomTest") == 0)
	{
		processCustomTest(&attributes);
	}
}