void GaleShapleyAlgorithm::pairWomanAndMen() { while(currentMan_ != -1) { currentWoman_ = nextPreferredWoman(currentMan_); men_[currentMan_].nextWoman++; //PRINT_INFO("Man %d.", currentMan_); if(womanIsEngaged(currentWoman_)) { int rival = women_[currentWoman_].engagedTo; //PRINT_INFO("-- Woman is engaged."); //PRINT_INFO("-- Man dist=%.2f; Rival dist = %.2f.", men_[currentMan_].distances[currentWoman_], men_[rival].distances[currentWoman_]); if(men_[currentMan_].distances[currentWoman_] < men_[rival].distances[currentWoman_]) { // current man is more attractive //PRINT_INFO("-- Current is more attractive."); men_[rival].next = men_[currentMan_].next; men_[currentMan_].next = rival; men_[rival].engagedTo = -1; engage(currentMan_, currentWoman_); } else { // next try //PRINT_INFO("-- Next try"); continue; } } else { // woman is not engaged //PRINT_INFO("-- Woman is not engaged."); engage(currentMan_, currentWoman_); } currentMan_ = men_[currentMan_].next; } }
// Set the OpenGL mode to use for texture addressing in // the S and T dimensions respectively. void gTexture::setWrap(GLint wrapS, GLint wrapT) { engage(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT); disengage(); }
// Set the OpenGL texture-filtering mode to use for texture // magnification and minification respectively. void gTexture::setFilter(GLint magFilter, GLint minFilter) { engage(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); disengage(); }
void gTexture::loadData(GLint internalFormat, GLint format, GLint type, int width, int height, const void *data, bool mipmaps) { engage(); mWidth = width; mHeight = height; size_t lineSize = width * gTexture::getPixelSize(format, type); GLint alignment; glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); while ((lineSize & (alignment / 2)) != 0) { glPixelStorei(GL_UNPACK_ALIGNMENT, alignment / 2); glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); } if (data && mipmaps) { glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, data); glGenerateMipmap(GL_TEXTURE_2D); } else { glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, data); } disengage(); }
int main ( void ) { int8_t cmd[ 256 ]; uint8_t ret, evt = 0; while( 1 ) { ret = recv( cmd ); if( ret ) { cmd[ ret ] = 0x0A; send( cmd, ret + 1 ); } ret = inp(); if( ret != evt ) { evt = ret; if( evt & 0x10 ) engage( evt & 0x0F ); /*strcpy( cmd, "event: 0x00\n" ); cmd[ 9 ] = p_hex[ evt >> 4 ]; cmd[ 10 ] = p_hex[ evt & 0x0F ]; send( cmd, 12 ); */ } ret = uart_read(0,cmd,16); if (ret > 0) { send(cmd,ret); } } //print( "Hello World!\n" ); return( 0 ); }
int main(int argc, char* argv[]) { // main almost exclusively does parameter processing if (argc < 1) { show_usage(argv[0]); return 1; } std::string commandsFile = ""; bool runningAsChild = false; for (int i = 1; i < argc; ++i) { // iterate over argument vector std::string arg = argv[i]; if ((arg == "-h") || (arg == "--help")) { show_usage(argv[0]); return 0; } else if ((arg == "-c") || (arg == "--child")) { runningAsChild = true; } else if ((arg == "-C") || (arg == "--commands")) { if (i + 1 < argc) { // make sure we aren't at the end of argv commandsFile = argv[++i]; // oncrement 'i' so we don't get the argument as the next argv[i]. } else { std::cerr << "--commands option requires one argument." << std::endl; return 1; } } } engage(commandsFile, runningAsChild); return 0; }
void gTexture::allocateSpace(GLint internalFormat, GLint format, GLint type, int width, int height) { engage(); mWidth = width; mHeight = height; glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, NULL); disengage(); }
void QuadrotorPropulsion::addPWMToQueue(const hector_uav_msgs::MotorPWMConstPtr& pwm) { boost::mutex::scoped_lock lock(command_queue_mutex_); if (!motor_status_.on) { ROS_WARN_NAMED("quadrotor_propulsion", "Received new motor command. Enabled motors."); engage(); } ROS_DEBUG_STREAM_NAMED("quadrotor_propulsion", "Received motor command valid at " << pwm->header.stamp); command_queue_.push(pwm); command_condition_.notify_all(); }
int main(void) { printstr("OK\n"); if (init_video()) { return(1); } printstr(" Resetting disk..."); if (print_error(disk_reset(loader_setup.boot_drive), disk_errors, N_DISK_ERRORS, TRUE)) { return(1); } printstr(" Getting disk info..."); if (print_error(disk_info_standard(loader_setup.boot_drive, &disk_geometry.cylinder, &disk_geometry.head, &disk_geometry.sector), disk_errors, N_DISK_ERRORS, TRUE)) { return(1); } printstr("...OK\n"); printstr("Loading HIKernel ("); putl(loader_setup.kernel_sectors, 10); printstr(" sectors)...\n"); if (print_error(read_kernel(), disk_errors, N_DISK_ERRORS, TRUE)) { return(1); } printstr("Killing floppy motor...\n"); stop_floppy(); printstr("Starting the BOSS..."); engage(); update_cursor(); printstr("\nBack in the aMOS loader\n"); printstr("Can't play that funky music, giving it up\n"); printstr("Let down and hanging around\n"); for (;;) {} return(0); }
// Battle Lord void battleLordThink(ent_t *self) { //ent_t *temp; // navigation if(self->onPath == false) { if( (abs((self->locx - self->destx)) > 5) || (abs((self->locy - self->desty)) > 5) ) { move(self, self->destx, self->desty); //fprintf(stderr, "moving to destination\n"); } // scan for targets and deal with them if(self->ROE != 0) { if( (self->target != NULL) && (self->target->isDead == false) ) { engage(self); // fprintf(stderr,"My target's health is %i\n",self->target->health);}fprintf(stderr, "firing\n"); } else { self->target = NULL; scanForTarget(self); } } } else { if( (abs((self->locx - self->rallyx)) > 5) || (abs((self->locy - self->rallyy)) > 5) ) { move(self, self->rallyx, self->rallyy); //fprintf(stderr, "moving to rally point (%i,%i)\n",self->rallyx,self->rallyy); } else self->onPath = false; // temp = collision(self->rallyx,self->rallyy,self->sprite->w,self->sprite->h); // if(temp != NULL) // ; } }
void *gTexture::getData(GLint format, GLint type) { size_t lineSize = mWidth * gTexture::getPixelSize(format, type); GLint alignment; glGetIntegerv(GL_PACK_ALIGNMENT, &alignment); while ((lineSize & (alignment / 2)) != 0) { glPixelStorei(GL_PACK_ALIGNMENT, alignment / 2); glGetIntegerv(GL_PACK_ALIGNMENT, &alignment); } void *data = malloc(lineSize * mHeight); engage(); glGetTexImage(GL_TEXTURE_2D, 0, format, type, data); disengage(); return data; }
FileButton::FileButton(QTableWidget* parent) : QPushButton("Choose file...", parent) { connect(this, SIGNAL(clicked()), this, SLOT(engage())); }
void CameraTrigger::poll(void *arg) { CameraTrigger *trig = reinterpret_cast<CameraTrigger *>(arg); bool updated; orb_check(trig->_vcommand_sub, &updated); if (updated) { orb_copy(ORB_ID(vehicle_command), trig->_vcommand_sub, &trig->_command); if(trig->_command.command == vehicle_command_s::VEHICLE_CMD_DO_TRIGGER_CONTROL) { if(trig->_command.param1 < 1) { if(trig->_trigger_enabled) { trig->_trigger_enabled = false ; } } else if(trig->_command.param1 >= 1) { if(!trig->_trigger_enabled) { trig->_trigger_enabled = true ; } } // Set trigger rate from command if(trig->_command.param2 > 0) { trig->_integration_time = trig->_command.param2; param_set(trig->integration_time, &(trig->_integration_time)); } } } if(!trig->_trigger_enabled) { hrt_call_after(&trig->_pollcall, 1e6, (hrt_callout)&CameraTrigger::poll, trig); return; } else { engage(trig); hrt_call_after(&trig->_firecall, trig->_activation_time*1000, (hrt_callout)&CameraTrigger::disengage, trig); orb_copy(ORB_ID(sensor_combined), trig->_sensor_sub, &trig->_sensor); trig->_trigger.timestamp = trig->_sensor.timestamp; // get IMU timestamp trig->_trigger.seq = trig->_trigger_seq++; if (trig->_trigger_pub != nullptr) { orb_publish(ORB_ID(camera_trigger), trig->_trigger_pub, &trig->_trigger); } else { trig->_trigger_pub = orb_advertise(ORB_ID(camera_trigger), &trig->_trigger); } hrt_call_after(&trig->_pollcall, (trig->_transfer_time + trig->_integration_time)*1000, (hrt_callout)&CameraTrigger::poll, trig); } }