亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? playerdevice.cc

?? 一個機器人平臺
?? CC
?? 第 1 頁 / 共 2 頁
字號:
/* *  Stage : a multi-robot simulator. *  Copyright (C) 2001, 2002 Richard Vaughan, Andrew Howard and Brian Gerkey. * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * * Desc: Add player interaction to basic entity class * Author: Richard Vaughan, Andrew Howard * Date: 7 Dec 2000 * CVS info: $Id: playerdevice.cc,v 1.50.2.1 2003/05/24 01:11:19 inspectorg Exp $ */#if HAVE_CONFIG_H  #include <config.h>#endif#include <sys/types.h>#include <math.h>#include <string.h>#include <netinet/in.h>#include <stdio.h>#include <stdlib.h>#include <sys/time.h>#include <unistd.h>#if HAVE_VALUES_H  #include <values.h>  // for MAXFLOAT#endif#include <sys/mman.h>#include <fcntl.h>#include <errno.h>#include <sys/stat.h>#include <sys/file.h>#include <iomanip>#include <iostream>//#define DEBUG//#define VERBOSE//#undef DEBUG//#undef VERBOSE#include "playerdevice.hh"#include "world.hh"#include "worldfile.hh"#include "gui.hh"#include "library.hh"///////////////////////////////////////////////////////////////////////////// Minimal constructor// Requires a pointer to the parent and a pointer to the world.CPlayerEntity::CPlayerEntity(LibraryItem *libit, CWorld *world, CEntity *parent_entity )  : CEntity( libit, world, parent_entity ){  //PRINT_DEBUG( "CEntity::CEntity()" );  this->lock_byte = world->GetEntityCount();    // init the player ID structure - subclasses will set this properly  memset( &m_player, 0, sizeof(m_player) );    // init the player IO structure - subclasses will set these properly  m_info_len    = sizeof( player_stage_info_t ); // same size for all types  m_data_len    = 0; // type specific - set in subclasses  m_command_len = 0; // ditto  m_config_len  = 0; // ditto  m_reply_len   = 0; // ditto    m_info_io     = NULL; // instance specific pointers into mmap  m_data_io     = NULL;   m_command_io  = NULL;  m_config_io   = NULL;  m_reply_io    = NULL;    m_reqqueue = NULL;  m_repqueue = NULL;    // Set the filename used for this device's mmap  this->device_filename[0] = 0;}///////////////////////////////////////////////////////////////////////////// DestructorCPlayerEntity::~CPlayerEntity(){}void CPlayerEntity::Update( double sim_time ){  //PRINT_DEBUG1( "subs: %d\n", this->subscribed );  //int subs = this->Subscribed();  // if our subscription state has changed, generate an property change event  //if( this->last_sub != subs )  // this->SetProperty(     CEntity::Update( sim_time );}///////////////////////////////////////////////////////////////////////////// Load the entity from the world filebool CPlayerEntity::Load(CWorldFile *worldfile, int section){  CEntity::Load( worldfile, section );  // Read the player port (default 0)  m_player.port = worldfile->ReadInt(section, "port", 0 );    // if the port wasn't set, and our parent is a player device,  // default to the parent's port  if (m_player.port == 0 && RTTI_ISPLAYERP(m_parent_entity) )    {      m_player.port = dynamic_cast<CPlayerEntity*>(m_parent_entity)->m_player.port;    }  // Read the device index  m_player.index = worldfile->ReadInt(section, "index", 0);    // m_player.code is uniquely set in a subclass's constructor  //PRINT_DEBUG2( "port: %d index %d", m_player.port, m_player.index );  if( m_player.port == 0 )    printf( "\nWarning: Player device (%s:%d:%d) has zero port. Missing 'port' property in world file?\n",	    this->lib_entry->token, m_player.port, m_player.index );  return true;}bool CPlayerEntity::Save(CWorldFile *worldfile, int section){  return CEntity::Save( worldfile, section );  // can't currently change port / index dynamically}///////////////////////////////////////////////////////////////////////////// Startup routine// A virtual function that lets entitys do some initialization after// everything has been loaded.bool CPlayerEntity::Startup( void ){  CEntity::Startup();  // we set up a mmapped file in the tmp filesystem to share  // data with player    player_stage_info_t* playerIO = 0;    size_t mem = SharedMemorySize();     snprintf( this->device_filename, sizeof(this->device_filename), "%s/%d.%d.%d",             m_world->m_device_dir, m_player.port, m_player.code, m_player.index );    PRINT_DEBUG1("creating device %s", device_filename);  int tfd;  if( (tfd = open( this->device_filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR )) == -1 )  {          PRINT_DEBUG2( "failed to open file %s for device at %p\n"                  "assuming this is a client device!\n",                   this->device_filename, this );          // make some memory to store the data    assert( playerIO = (player_stage_info_t*) new char[ mem ] );    // remove the filename so we don't try to unlink it    this->device_filename[0] = 0;    PRINT_DEBUG("successfully created client IO buffers");  }  else  {    // make the file the right size    if( ftruncate( tfd, mem ) < 0 )    {      PRINT_ERR1( "failed to set file size: %s", strerror(errno) );      return false;    }          // it's a little larger than a player_stage_info_t, but that's the     // first part of the buffer, so we'll call it that    playerIO =       (player_stage_info_t*)mmap( NULL, mem, PROT_READ | PROT_WRITE,                                   MAP_SHARED, tfd, (off_t) 0);          if (playerIO == MAP_FAILED )    {      PRINT_ERR1( "Failed to map memory: %s", strerror(errno) );      return false;    }          close( tfd ); // can close fd once mapped        //PRINT_DEBUG("successfully mapped shared memory");        //PRINT_DEBUG2( "S: mmapped %d bytes at %p\n", mem, playerIO );  }    // try a lock  assert( Lock() );    // Initialise entire space  memset(playerIO, 0, mem);    // set the pointers into the shared memory region  m_info_io    = playerIO; // info is the first record  m_data_io    = (uint8_t*)m_info_io + m_info_len;  m_command_io = (uint8_t*)m_data_io + m_data_len;   m_config_io  = (uint8_t*)m_command_io + m_command_len;  m_reply_io   = (uint8_t*)(m_config_io +                             (m_config_len * sizeof(playerqueue_elt_t)));    m_info_io->len = SharedMemorySize(); // total size of all the shared data  m_info_io->lockbyte = this->lock_byte; // record lock on this byte    // set the lengths in the info structure  m_info_io->data_len    =  (uint32_t)m_data_len;  m_info_io->command_len =  (uint32_t)m_command_len;  m_info_io->config_len  =  (uint32_t)m_config_len;  m_info_io->reply_len   =  (uint32_t)m_reply_len;    m_info_io->data_avail    =  0;  m_info_io->command_avail =  0;  m_info_io->config_avail  =  0;    m_info_io->player_id.port = m_player.port;  m_info_io->player_id.index = m_player.index;  m_info_io->player_id.code = m_player.code;  m_info_io->subscribed = 0;  // create the PlayerQueue entitys that we'll use to access requests and  // replies.  pass in the chunks of memory that are already mmap()ed  assert(m_reqqueue = new PlayerQueue(m_config_io,m_config_len));  assert(m_repqueue = new PlayerQueue(m_reply_io,m_reply_len));    // initialize the driver name with something sensible, in case the device  // doesn't set it  strncpy((char*)(this->m_info_io->drivername), "stage_device",           sizeof(this->m_info_io->drivername));#ifdef DEBUG  printf( "\t\t(%p) (%d,%d,%d) IO at %p\n"          "\t\ttotal: %d\tinfo: %d\tdata: %d (%d)\tcommand: %d (%d)\tconfig: %d (%d)\n ",          this,          m_info_io->player_id.port,          m_info_io->player_id.code,          m_info_io->player_id.index,          m_info_io,          m_info_len + m_data_len + m_command_len + m_config_len,          m_info_len,          m_info_io->data_len, m_data_len,          m_info_io->command_len, m_command_len,          m_info_io->config_len, m_config_len );#endif    // try  an unlock  assert( Unlock() );    // store our driver name in the player IO structure.  // use the worldfile token as the driver name to avoid possible confusion  this->SetDriverName( (char*)this->lib_entry->token );  return true;}///////////////////////////////////////////////////////////////////////////// Shutdown routinevoid CPlayerEntity::Shutdown(){  CEntity::Shutdown();  if( this->device_filename[0] )    // remove our name in the filesystem    if( unlink( this->device_filename ) == -1 )      PRINT_DEBUG2( "Device failed to unlink it's IO file:%s %s", 		    this->device_filename, strerror(errno) );}///////////////////////////////////////////////////////////////////////////// Compute the total shared memory size for the deviceint CPlayerEntity::SharedMemorySize( void ){  return( m_info_len + m_data_len + m_command_len +           (m_config_len * sizeof(playerqueue_elt_t)) +          (m_reply_len * sizeof(playerqueue_elt_t)));}// Copy data from the shared memory segmentsize_t CPlayerEntity::GetIOData( void* dest, size_t dest_len,                                   void* src, uint32_t* avail ){  size_t len;    assert( dest ); // the caller must have somewhere to put this data  if( src == 0 )  // this device doesn't have any data here    return 0;     // so bail right away  Lock();  len = 0;  // If there is data available...  if (*avail > 0)  {    // If the data fits...    if ((size_t) *avail <= dest_len)    {      memcpy( dest, src, *avail);      len = *avail;    }    else    {      PRINT_ERR2("command buffer overflow; (%d > %d)", *avail, dest_len);      len = 0;    }  }  Unlock();  return len;}size_t CPlayerEntity::GetData( void* data, size_t len ){  //PRINT_DEBUG( "f" );  return GetIOData( data, len, m_data_io, &m_info_io->data_avail );}size_t CPlayerEntity::GetCommand( void* data, size_t len ){  //PRINT_DEBUG( "f" );  return GetIOData( data, len, m_command_io, &m_info_io->command_avail );}///////////////////////////////////////////////////////////////////////////// Copy data into the shared memory segmentsize_t CPlayerEntity::PutIOData( void* dest, size_t dest_len,  			   void* src, size_t src_len,			   uint32_t* ts_sec, uint32_t* ts_usec, 			   uint32_t* avail ){    Lock();  assert( dest );  assert( src );  assert( src_len > 0 );  assert( dest_len > 0 );    if( src_len == 0 )    printf( "WIERD! attempt to write no bytes into a buffer" );  if( src_len <= dest_len ) // if there is room for the data  {    memcpy( dest, src, src_len); // export the data    // update the availability and timestamps    *avail    = src_len;    *ts_sec   = m_world->m_sim_timeval.tv_sec;    *ts_usec  = m_world->m_sim_timeval.tv_usec;  }  else  {    PRINT_ERR2( "failed trying to put %d bytes; io buffer is "                "%d bytes.)\n", src_len, dest_len  );          src_len = 0; // indicate failure  }    Unlock();    return src_len;}////////////////////////////////////////////////////////////////////////////// Write to the driver name segment of the IO buffer//// this is called at the end of CPlayerEntity::Startup() with the// worldfile token for this device.void CPlayerEntity::SetDriverName( char* name ){  Lock();  assert(name);  strncpy((char*)(this->m_info_io->drivername), name,           sizeof(this->m_info_io->drivername));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99免费精品视频| 激情亚洲综合在线| 欧洲生活片亚洲生活在线观看| 国产精品乱码人人做人人爱| av成人免费在线| 亚洲欧美日韩在线| 欧美精品一二三四| 久久69国产一区二区蜜臀| 久久精品视频一区二区| a亚洲天堂av| 亚洲国产精品自拍| 欧美成人三级在线| av在线不卡电影| 午夜久久久影院| 久久久久国产精品厨房| 972aa.com艺术欧美| 日韩中文欧美在线| 国产午夜一区二区三区| 91电影在线观看| 激情综合色播五月| 亚洲精品国产无天堂网2021| 欧美一区中文字幕| 不卡的av电影| 日韩高清不卡一区二区| 欧美国产日产图区| 欧美性猛交xxxx黑人交| 国产老肥熟一区二区三区| 亚洲另类在线制服丝袜| 精品国产电影一区二区| aaa国产一区| 热久久国产精品| 136国产福利精品导航| 日韩精品一区二区三区swag| 91一区二区在线| 久久成人免费网| 亚洲激情男女视频| 精品第一国产综合精品aⅴ| 在线中文字幕不卡| 国产成都精品91一区二区三| 日本在线不卡视频| 一区二区三区精品久久久| 国产亚洲视频系列| 欧美一区二区成人| 99这里都是精品| 国产精品一区一区三区| 亚洲高清免费在线| 自拍偷拍欧美激情| 国产亚洲综合av| 精品卡一卡二卡三卡四在线| 欧美自拍丝袜亚洲| 97se狠狠狠综合亚洲狠狠| 国产老肥熟一区二区三区| 免费成人小视频| 亚洲第一会所有码转帖| 亚洲欧洲综合另类| 欧美国产在线观看| 国产三级欧美三级日产三级99| 欧美一卡2卡三卡4卡5免费| 一本大道综合伊人精品热热| 成人av综合在线| 国产69精品久久777的优势| 国产乱淫av一区二区三区 | 国产精品资源站在线| 五月天丁香久久| 亚洲最快最全在线视频| 亚洲人成精品久久久久久| 国产精品网曝门| 中文字幕免费不卡| 亚洲国产成人在线| 国产精品美女久久久久aⅴ| 久久精品人人做人人综合| 久久综合久色欧美综合狠狠| 日韩精品一区二区在线观看| 欧美一二三在线| 欧美一区二区视频在线观看2020 | www.综合网.com| 国产成人免费9x9x人网站视频| 激情深爱一区二区| 久久99精品久久久久久| 国内不卡的二区三区中文字幕| 久久国产麻豆精品| 国产一区二区在线观看免费| 激情图片小说一区| 国产经典欧美精品| 不卡视频免费播放| 色噜噜久久综合| 精品视频123区在线观看| 911精品国产一区二区在线| 日韩一区二区三区电影在线观看 | 欧美日韩aaaaa| 欧美一区二区日韩| 久久尤物电影视频在线观看| 国产色综合一区| 亚洲人成7777| 午夜免费久久看| 国产综合色视频| 成人动漫精品一区二区| 日本乱人伦一区| 欧美久久久影院| 26uuu精品一区二区在线观看| 国产欧美一区二区精品婷婷| 亚洲欧洲日韩一区二区三区| 亚洲国产视频在线| 国产一区二区三区免费看| 成人av电影在线播放| 欧美日韩免费在线视频| 欧美r级在线观看| 亚洲色图清纯唯美| 日韩二区三区在线观看| 国产一区二区三区电影在线观看 | 香蕉加勒比综合久久| 精品一区二区三区香蕉蜜桃 | 久久免费偷拍视频| 樱花草国产18久久久久| 毛片一区二区三区| av一区二区三区四区| 91麻豆精品国产91久久久资源速度| 久久综合久久综合九色| 亚洲一区二区三区小说| 精品一区中文字幕| 欧美性色黄大片| 中文字幕久久午夜不卡| 天堂va蜜桃一区二区三区漫画版| 国产aⅴ综合色| 欧美一区二区三区视频免费| 国产精品午夜久久| 美女在线观看视频一区二区| 不卡的电影网站| 精品国精品自拍自在线| 亚洲精品大片www| 国产不卡免费视频| 欧美日韩美少妇| 国产精品久久久久一区二区三区| 日本欧美加勒比视频| 91蝌蚪porny| 久久精品一区二区三区不卡牛牛 | 国产尤物一区二区| 欧美日韩视频在线第一区| 国产精品久久二区二区| 久久99热国产| 欧美福利视频一区| 亚洲另类一区二区| 成人高清视频在线| 久久尤物电影视频在线观看| 人人狠狠综合久久亚洲| 精品婷婷伊人一区三区三| 亚洲三级电影网站| 国产福利91精品一区二区三区| 欧美一区二区久久久| 亚洲无线码一区二区三区| 色先锋aa成人| 国产精品久久久久四虎| 成人妖精视频yjsp地址| 亚洲精品在线观| 国模无码大尺度一区二区三区| 制服丝袜亚洲播放| 午夜精品国产更新| 欧美日韩和欧美的一区二区| 一区二区三区高清| 欧洲av在线精品| 亚洲精品免费视频| 色视频一区二区| 亚洲精品一二三四区| av不卡在线观看| 亚洲欧美日韩一区| 91麻豆免费在线观看| 中文字幕一区在线| 色综合久久久网| 一区二区三区久久久| 精品视频在线免费看| 亚洲18色成人| 日韩欧美高清dvd碟片| 久久99精品国产.久久久久| 精品国产伦一区二区三区观看方式 | 成人久久久精品乱码一区二区三区 | 国产精品素人视频| 99久久婷婷国产| 伊人色综合久久天天| 欧美日韩激情一区二区三区| 免费看欧美女人艹b| 久久影院午夜片一区| 成人美女视频在线看| 亚洲精品v日韩精品| 欧美日韩中文字幕一区二区| 男女男精品视频网| 久久精子c满五个校花| www.日韩大片| 亚洲福利一区二区三区| 日韩欧美色综合| 成人av影院在线| 亚洲不卡在线观看| 精品国产乱码久久久久久牛牛| 国产91精品久久久久久久网曝门| 成人免费在线视频观看| 欧美色老头old∨ideo| 精品写真视频在线观看| 亚洲欧洲韩国日本视频| 欧美日韩国产欧美日美国产精品| 久久精品国产亚洲5555| 亚洲三级理论片|