void BasicDeviceDriver::consume(const IMC::LoggingControl* msg) { if ((msg->getDestination() != getSystemId()) || (msg->getDestinationEntity() != getEntityId())) return; switch (msg->op) { case IMC::LoggingControl::COP_CURRENT_NAME: if (m_log_name_pending) { m_log_name_pending = false; openLog(m_ctx.dir_log / msg->name); } break; case IMC::LoggingControl::COP_STARTED: openLog(m_ctx.dir_log / msg->name); break; case IMC::LoggingControl::COP_STOPPED: closeLog(); break; } }
void consume(const IMC::VehicleCommand* vc) { if (vc->type == IMC::VehicleCommand::VC_REQUEST) return; if ((vc->getDestination() != getSystemId()) || (vc->getDestinationEntity() != getEntityId()) || (m_vreq_ctr != vc->request_id)) return; if (!pendingReply()) return; m_vc_reply_deadline = -1; bool error = vc->type == IMC::VehicleCommand::VC_FAILURE; // Ignore failure if it failed to stop calibration if (error && (vc->command == IMC::VehicleCommand::VC_STOP_CALIBRATION)) { debug("%s", vc->info.c_str()); error = false; } if (initMode() || execMode()) { if (error) changeMode(IMC::PlanControlState::PCS_READY, vc->info, false); return; } }
void Daemon::consume(const DUNE::IMC::EntityParameters* msg) { if (msg->getDestination() != getSystemId()) return; if (msg->getDestinationEntity() != getEntityId()) return; std::string task_name; try { task_name = m_ctx.entities.resolveTaskName(msg->name); } catch (...) { return; } IMC::MessageList<IMC::EntityParameter>::const_iterator itr = msg->params.begin(); for ( ; itr != msg->params.end(); ++itr) { if (m_ctx.config.get(task_name, (*itr)->name) != (*itr)->value) m_scfg.set(task_name, (*itr)->name, (*itr)->value); } m_scfg.writeToFile(m_scfg_file.c_str()); }
void consume(const IMC::SonarConfig* msg) { if (msg->getDestinationEntity() != getEntityId()) return; setRange(msg->max_range); }
void PyService::sendPyInfo(const python::object& py_info, const Time time, const python::tuple& dest_ent, const long dest_serv ) { Logger::debug3() << "PyService: (" << getName() << ") on Entity" << getEntityId() << "sending PyInfo" << endl; fPyEnt.sendPyInfo( py_info, time, dest_ent, dest_serv); // return; // EntityID e_id = py2EntityId( dest_ent ); // #ifdef SIMX_USE_PRIME // if ( theEntityManager().findEntityLpId(e_id) != // Control::getRank() ) // { // Logger::debug3() << "PyService on Entity " << getEntityId() // << " : Sending remotely, proceeding to pickle Python object" << endl; // shared_ptr<PyRemoteInfo> info; // theInfoManager().createInfo( info ); // if ( ! info->pickleData( py_info ) ) // { // Logger::error() << "PyService.C: Service on entity " << getEntityId() // << ": Error while pickling info. Not sending" << endl; // return; // } // else // succesful pickling, send it off // { // sendInfo( info, time, e_id, // static_cast<ServiceAddress>( dest_serv ) ); // } // } // else // destination entity lives on the same LP. Use regular PyInfo for sending // { // Logger::debug3() << "PyService on Entity " << getEntityId() // << " : Sending locally" << endl; // #endif // // either we are using SimEngine -- in which case sending local // // and remote infos use the same procedure -- or // // we are using SSF and sending locally. // shared_ptr<PyInfo> info; // theInfoManager().createInfo( info ); // info->setData( py_info ); // sendInfo( info, time, e_id, // static_cast<ServiceAddress>( dest_serv ) ); // #ifdef SIMX_USE_PRIME // } //close-out else block // #endif // //info->fData = boost::make_shared<boost::python::object>(py_info); }
//! Get the PlanSpecification from IMC::Message //! @param[in] plan_id ID of the plan //! @param[in] arg pointer to arg message //! @param[out] info string with the error in case of failure //! @return false if unable to get the spec bool parseArg(const std::string& plan_id, const IMC::Message* arg, std::string& info) { if (arg) { if (arg->getId() == DUNE_IMC_PLANSPECIFICATION) { const IMC::PlanSpecification* given_plan = static_cast<const IMC::PlanSpecification*>(arg); m_spec = *given_plan; m_spec.setSourceEntity(getEntityId()); } else { // Quick plan IMC::PlanManeuver spec_man; const IMC::Maneuver* man = static_cast<const IMC::Maneuver*>(arg); if (man) { spec_man.maneuver_id = arg->getName(); spec_man.data.set(*man); m_spec.clear(); m_spec.maneuvers.setParent(&m_spec); m_spec.plan_id = plan_id; m_spec.start_man_id = arg->getName(); m_spec.maneuvers.push_back(spec_man); } else { info = "undefined maneuver or plan"; return false; } } } else { // Search DB m_spec.clear(); if (!lookForPlan(plan_id, m_spec)) { info = m_reply.info; return false; } } return true; }
void CTDMServer::endGame() { _inEndGame = true; // Tiempo de espera hasta la siguiente partida _gameTime = _voteMap ? 40000 : 15000; // Notificar a los clientes de que estamos en la fase endGame Net::NetMessageType endGameMsg = Net::END_GAME; _netMgr->broadcast( &endGameMsg, sizeof(endGameMsg) ); // Desactivamos los componentes relevantes en el servidor para asegurarnos // de que aunque el cliente haga chetos no se muevan los jugadores sin permiso // ni se hagan daño. Logic::CEntity* player; std::vector<std::string> componentList; componentList.reserve(4); componentList.push_back("CAvatarController"); componentList.push_back("CPhysicController"); componentList.push_back("CLife"); componentList.push_back("CSpawnPlayer"); for(auto it = _playersMgr->begin(); it != _playersMgr->end(); ++it) { if( it->getEntityId().second ) { player = _map->getEntityByID( it->getEntityId().first ); player->deactivateComponents(componentList); } } // @todo // Parar la partida (el server y el cliente ya no hacen tick) // Poner la cámara mirando al jugador y que al girar el ratón rote alrededor // del player - cliente // Poner la cámara de los demás jugadores mirando al ganador - cliente // Mostrar el scoreboard durante unos 10 segundos - cliente // Si votemap está activo mostrar el menú de votemap durante unos 30 segs // Si votemap no está activo entonces pasar al siguiente mapa de los configurados // y si no ha habido ningun mapa puesto en lista salir }
void handleCAMUA(std::auto_ptr<NMEAReader>& stn) { unsigned src = 0; *stn >> src; unsigned dst = 0; *stn >> dst; // Get value. std::string val; *stn >> val; unsigned value = 0; std::sscanf(val.c_str(), "%04X", &value); if (value == c_code_abort_ack) { m_acop_out.op = IMC::AcousticOperation::AOP_ABORT_ACKED; m_acop_out.system = m_acop.system; dispatch(m_acop_out); resetOp(); } if (value == c_code_plan_ack) { inf(DTR("plan started")); m_pc->setDestination(m_pc->getSource()); m_pc->setDestinationEntity(m_pc->getSourceEntity()); m_pc->setSource(getSystemId()); m_pc->setSourceEntity(getEntityId()); m_pc->type = IMC::PlanControl::PC_SUCCESS; m_pc->flags = 0; dispatch(*m_pc); } else if (value & c_mask_qtrack) { unsigned beacon = (value & c_mask_qtrack_beacon) >> 10; unsigned range = (value & c_mask_qtrack_range); IMC::LblRangeAcceptance msg; msg.setSource(m_mimap[src]); msg.id = beacon; msg.range = range; msg.acceptance = IMC::LblRangeAcceptance::RR_ACCEPTED; dispatch(msg); inf("%s %u: %u", DTR("range to"), beacon, range); }
void consume(const IMC::EntityControl* msg) { if (msg->getDestinationEntity() != getEntityId()) return; m_active = (msg->op == IMC::EntityControl::ECO_ACTIVATE); if (m_active) { setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_ACTIVE); if (!m_log_file.is_open()) m_log_file.open((m_ctx.dir_log / m_log_filename / "Data.837").c_str(), std::ios::binary); } else { setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_IDLE); } }
//! Load a plan into the vehicle //! @param[in] plan_id name of the plan //! @param[in] arg argument which may either be a maneuver or a plan specification //! @param[in] plan_startup true if a plan will start right after //! @return true if plan is successfully loaded bool loadPlan(const std::string& plan_id, const IMC::Message* arg, bool plan_startup = false) { if ((initMode() && !plan_startup) || execMode()) { onFailure(DTR("cannot load plan now")); return false; } if (arg) { if (arg->getId() == DUNE_IMC_PLANSPECIFICATION) { const IMC::PlanSpecification* given_plan = static_cast<const IMC::PlanSpecification*>(arg); m_spec = *given_plan; m_spec.setSourceEntity(getEntityId()); } else { // Quick plan IMC::PlanManeuver spec_man; const IMC::Maneuver* man = static_cast<const IMC::Maneuver*>(arg); if (man) { spec_man.maneuver_id = arg->getName(); spec_man.data.set(*man); m_spec.clear(); m_spec.maneuvers.setParent(&m_spec); m_spec.plan_id = plan_id; m_spec.start_man_id = arg->getName(); m_spec.maneuvers.push_back(spec_man); } else { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan load failed: undefined maneuver or plan")); return false; } } } else { // Search DB m_spec.clear(); if (!lookForPlan(plan_id, m_spec)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan load failed: ") + m_reply.info); return false; } } if (!parsePlan(plan_startup)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan validation failed: ") + m_reply.info); return false; } m_pcs.plan_id = m_spec.plan_id; if (plan_startup) onSuccess(DTR("plan loaded"), false); else changeMode(IMC::PlanControlState::PCS_READY, DTR("plan loaded")); return true; }