コード例 #1
0
void Pincer::CheckButtons()
{
// Check Buttons and do what is requested..		
#if !MANUAL_MODE
		if(operatorJoystick->ButtonClickDown(GripGrabButton))
			Close();
	
		else if (operatorJoystick->ButtonClickDown(GripReleaseButton))
			Open();
#else
		if(operatorJoystick->GetRawButton(GripGrabButton)){
			SetMotorOutput(closingSpeed);
			controlMode = ManualMode;
			//printf("ManualClose %f\n", closingSpeed);
			
		}
		else if (operatorJoystick->GetRawButton(GripReleaseButton)){
			SetMotorOutput(openingSpeed);
			controlMode = ManualMode;
			//printf("ManualOpen %f\n", openingSpeed);
		}
		else if (controlMode == ManualMode){
			controlMode = OffMode;
			SetMotorOutput(0);
		}

#endif
		
		static bool wasRollerInButton = false;
		static bool wasRollerOutButton = false;

		bool isRollerInButton = operatorJoystick->GetRawButton(GripRollerInButton);
		bool isRollerOutButton = operatorJoystick->GetRawButton(GripRollerOutButton);


		if(isRollerInButton){
			RollIn();
		}
		else if (isRollerOutButton){
			RollOut();
		}
		else{
			if(wasRollerInButton || wasRollerOutButton){
				RollOff();
#if SIMULATOR
//				printf("Roller: Roller OFF\n");
#endif
			}	

		}
		wasRollerInButton = isRollerInButton;
		wasRollerOutButton = isRollerOutButton;
}
コード例 #2
0
ファイル: TinyLog.cpp プロジェクト: dfdqzp/practice
void Logger::output(std::string str, LOG_LEVEL level) {
        if (log_enable_ && level >= current_log_level_) {
            ostringstream log_str;
            log_str<< CurrentTimeToString()<<" ["<< syscall(SYS_gettid)<<"] "<< level_string[level] << str <<endl;
            if (to_stdout_) {
                cout<< log_str.str();
            }

            pthread_mutex_lock(&mutex_);
            std::ofstream file_stream(log_file_name_, std::ofstream::app);
            if (file_stream.is_open()) {
                file_stream << log_str.str();
                streampos pos = file_stream.tellp();
                file_stream.close();
                if (pos >= roll_out_size_) {
                    RollOut();
                }
            }
            pthread_mutex_unlock(&mutex_);
        }
}