Connection::Connection(ACE_Reactor * _reactor, Mcp::EventHandler * _mcpEventHandler, Consumer * _consumer, EventHandler * _eventHandler, const Parameters& _parameters) throw(Miro::Exception, Miro::EDevIO) : Super(_reactor, _mcpEventHandler, _parameters), rotateState(LIMP), rotateVelocity(0x0080), rotateAcceleration(0x0400), translateState(LIMP), translateVelocity(0x800), translateAcceleration(0x4000), stateMutex(), eventHandler(_eventHandler), baseConsumer(_consumer), batteryTimerId(-1) { // set base rotation and speed to zero and initiate an index report const iovec vec[3] = { { &MSG_ROT_LIMP, sizeof(Mcp::OutMessage)}, { &MSG_TRANS_LIMP, sizeof(Mcp::OutMessage)}, { &MSG_INDEX_REPORT, sizeof(OutMessage)} }; sendCommands(vec, 3); // trigger polling of the current battery voltage ACE_Time_Value batteryStart(BATTERYPOLL_START); ACE_Time_Value batteryPolling(BATTERYPOLL_INTERVAL); batteryTimerId = reactor_->schedule_timer(eventHandler, NULL, // no parameter batteryStart, // delay batteryPolling); // respawn every timeout sec. if (batteryTimerId == -1) throw Miro::ACE_Exception(errno, "failed to register battery poll timer"); }
void NetworkLocalBehavior::begin() { const int delay = 4; /* send empty commands */ for (int i = 0; i < delay; i++) { commands.push_back(vector<string>()); sendCommands(vector<string>(), socket); } }
Connection::~Connection() { // halt robot const iovec vec[2] = { {&MSG_ROT_LIMP, sizeof(OutMessage)}, {&MSG_TRANS_LIMP, sizeof(OutMessage)} }; sendCommands(vec, 2); // stop battery polling reactor_->cancel_timer(batteryTimerId); // deleting eventHandler handler delete eventHandler; }
void EntitiesResponse::serializeto_internal( BitStream &tgt ) const { EntityManager &ent_manager=m_client->current_map()->m_entities; tgt.StorePackedBits(1,m_incremental ? 2 : 3); // opcode 3 - full update. tgt.StoreBits(1,entReceiveUpdate); // passed to Entity::EntReceive as a parameter sendCommands(tgt); tgt.StoreBits(32,abs_time); //tgt.StoreBits(32,db_time); tgt.StoreBits(1,unkn2); if(unkn2) { //g_debug_info 0 //interpolation level 2 //g_bitcount_rel 1 } else { tgt.StoreBits(1,debug_info); tgt.StoreBits(1,m_interpolating); if(m_interpolating==1) { tgt.StoreBits(2,m_interpolation_level); tgt.StoreBits(2,m_interpolation_bits); } } //else debug_info = false; ent_manager.sendEntities(tgt); if(debug_info&&!unkn2) { ent_manager.sendDebuggedEntities(tgt); // while loop, sending entity id's and debug info for each ent_manager.sendGlobalEntDebugInfo(tgt); } sendServerPhysicsPositions(tgt); // These are not client specific ? sendControlState(tgt);// These are not client specific ? ent_manager.sendDeletes(tgt); // Client specific part sendClientData(tgt); //FIXME: Most Server messages must follow entity update. }
void Connection::setTranslateVelocity(unsigned long arg) throw(Miro::EDevIO) { Miro::Guard guard(stateMutex); if (translateVelocity != arg) { translateVelocity = arg; #ifdef DEBUG std::cerr << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << "() - " << arg << ": 0x" << std::hex << convertMMToEncoders(arg) << std::dec << std::endl; #endif OutMessage message(OP_TRANS_VEL, convertMMToEncoders(arg)); const iovec vec[2] = { {&message, sizeof(OutMessage)}, {&MSG_USER_MESSAGE, sizeof(OutMessage)} }; sendCommands(vec, 2); } }
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8/////////9/////////A ChopperMain::ChopperMain() : doSendControl_(false) { setWindowTitle("ChopperRemote"); resize(480, 550); QWidget *centralwidget = new QWidget(this); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); radar = new ProximityRadar(200, centralwidget); radar->setGeometry(QRect(0, 0, 400, 200)); cbSweep = new QCheckBox(centralwidget); cbSweep->setGeometry(QRect(10, 380, 201, 22)); cbSweep->setText("sweep"); cbLog = new QCheckBox(centralwidget); cbLog->setGeometry(QRect(10, 410, 191, 22)); cbLog->setText("log"); cbControl = new QCheckBox(centralwidget); cbControl->setGeometry(QRect(10, 440, 220, 22)); cbControl->setText("control"); plainTextEdit = new QPlainTextEdit(centralwidget); plainTextEdit->setGeometry(QRect(0, 470, 481, 80)); QPalette palComp; palComp.setColor(QPalette::Base, Qt::darkBlue); palComp.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); palComp.setColor(QPalette::Text, Qt::white); Heading = new QwtCompass(centralwidget); Heading->setGeometry(QRect(10, 230, 141, 131)); Heading->setLineWidth(4); Heading->setValue(0); Heading->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel); Heading->setScaleTicks(0, 0, 3); Heading->setScale(36, 5, 0); Heading->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130))); Heading->setPalette(palComp); QPalette palAtt; palAtt.setColor(QPalette::Base, Qt::darkBlue); palAtt.setColor(QPalette::Foreground, QColor(255,128,0).dark(120)); palAtt.setColor(QPalette::Text, Qt::white); Attitude = new AttitudeIndicator(centralwidget); Attitude->setGeometry(QRect(160, 230, 141, 131)); Attitude->setPalette(palAtt); Vario = new QwtScaleWidget(centralwidget); Vario->setGeometry(QRect(440, 10, 20, 421)); setCentralWidget(centralwidget); try { sercomm = new Communication("/dev/rfcomm0"); sercomm->addListener(Communication::LST_RANGER, boost::bind(&ProximityRadar::addReadingAny, radar, ::_1)); sercomm->addListener(Communication::LST_COMPASS, CompasValSetter(*Heading)); sercomm->addListener(Communication::LST_ACCEL, AttitudeSetter(*Attitude)); // sercomm->addListener(Communication::LST_TEXT, TextAdder(*plainTextEdit)); } catch(std::exception &ex) { std::stringstream sstr; sstr << "Could not establish a bluetooth connection to the chopper on \"/dev/rfcomm0\" with the following message:\n" << ex.what(); QMessageBox::critical(this, "No connection to the chopper", sstr.str().c_str(), QMessageBox::Ok); } connect(cbSweep, SIGNAL(stateChanged(int)), this, SLOT(enableRanger(int))); connect(cbLog, SIGNAL(stateChanged(int)), this, SLOT(enableLogging(int))); connect(cbControl, SIGNAL(stateChanged(int)), this, SLOT(enableControl(int))); TextAdder ta(*plainTextEdit); ta(boost::any(std::string("Welcome"))); #ifdef _DEBUG enableRanger(Qt::Checked); // enableLogging(Qt::Checked); #endif #ifdef __arm__ // assuming we are on the freerunner, so read the accelerometers #else // assuming we are on a notebook or computer, see if we have a joystick to read try { joyslis = new joystick_listener("/dev/input/js0"); sendCommands(); inputListener = boost::thread(boost::ref(*joyslis)); sercomm->addListener(Communication::LST_TEXT, boost::bind(&ChopperMain::sendCommands, this)); } catch(std::exception& ex) { std::stringstream sstr; sstr << "Could not connect to the joystick on \"/dev/input/js0\" with the following message:\n" << ex.what(); QMessageBox::critical(this, "No connection to the joystick", sstr.str().c_str(), QMessageBox::Ok); } #endif }
void SMTPClientSession::sendMessage(const MailMessage& message, const Recipients& recipients) { sendCommands(message, &recipients); transportMessage(message); }
void SMTPClientSession::sendMessage(const MailMessage& message) { sendCommands(message); transportMessage(message); }
void SSD1308::setColumnAddress(uint8_t start, uint8_t end) { uint8_t data[3] = { SET_COLUMN_ADDRESS, start, end }; sendCommands(3, data); }
void SSD1308::setPageAddress(uint8_t start, uint8_t end) { uint8_t data[3] = { SET_PAGE_ADDRESS, start, end }; sendCommands(3, data); }
void SSD1308::setMemoryAddressingMode(uint8_t mode) { uint8_t cmds[2] = { SET_MEMORY_ADDRESSING_MODE, mode }; sendCommands(2, cmds); }
void NetworkLocalBehavior::start(const Stage & stage, Character * owner, const std::vector<Command2*> & commands, bool reversed) { vector<string> current = local->currentCommands(stage, owner, commands, reversed); this->commands.push_back(current); sendCommands(current, socket); }