示例#1
0
ReturnCodeSetGear CCar::SetGear(const int & gear)
{
	ReturnCodeSetGear wasError = ReturnCodeSetGear::GearOn;
	if (gear < 0 && m_direction == Direction::Forward)
	{
		wasError = ReturnCodeSetGear::GearNotOnReverse;
	}
	else if (gear < 0 && m_direction == Direction::Backward)
	{
		wasError = ReturnCodeSetGear::GearNotOnWithReverseSpeed;
	}
	else if (!CheckBound(gear, GEAR_RANGE))
	{
		wasError = ReturnCodeSetGear::NoGear;
	}
	else if (!CheckBound(m_speed, SPEED_RANGE.find(gear)->second))
	{
		wasError = ReturnCodeSetGear::GearNotOnWithSpeed;
	}
	else
	{
		m_gear = gear;
	}
	return wasError;
}
示例#2
0
 void PerconaFTIterator::Jump(const KeyObject& next)
 {
     DoJump(next);
     if (Valid())
     {
         CheckBound();
     }
 }
示例#3
0
 void PerconaFTIterator::Next()
 {
     ClearState();
     int ret = m_cursor->c_getf_next(m_cursor, 0, nil_callback, NULL);
     if (ret != 0)
     {
         m_valid = false;
         return;
     }
     CheckBound();
 }
示例#4
0
ReturnCodeSetSpeed CCar::SetSpeed(const int & speed)
{
	ReturnCodeSetSpeed wasError = ReturnCodeSetSpeed::SpeedOn;
	auto it = SPEED_RANGE.find(m_gear);
	if (!m_engineLaunched)
	{
		wasError = ReturnCodeSetSpeed::SpeedNotWithEngine;
	}
	else if (m_gear == 0 && speed > m_speed)
	{
		wasError = ReturnCodeSetSpeed::SpeedNotAddWithNeutralGear;
	}
	else if (!CheckBound(speed, it->second))
	{
		wasError = ReturnCodeSetSpeed::SpeedNotRange;
	}
	else
	{
		m_speed = speed;
		SetDirection();
	}
	return wasError;
}