Changeset 158 in flair-src for trunk/lib/FlairSensorActuator/src


Ignore:
Timestamp:
Mar 5, 2017, 10:50:56 AM (5 years ago)
Author:
Sanahuja Guillaume
Message:

corrected simu/device id for sensors

Location:
trunk/lib/FlairSensorActuator/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/SimuBldc.cpp

    r157 r158  
    3333
    3434SimuBldc::SimuBldc(const IODevice *parent, Layout *layout, string name,
    35                    uint8_t motors_count, uint32_t dev_id)
     35                   uint8_t motors_count, uint32_t modelId,uint32_t deviceId)
    3636    : Bldc(parent, layout, name, motors_count) {
    37   ostringstream dev_name;
    38   dev_name << "simu_bldc_" << dev_id;
    3937  shmem =
    40       new SharedMem(this, dev_name.str().c_str(), motors_count * sizeof(float));
     38      new SharedMem(this, ShMemName(modelId, deviceId), motors_count * sizeof(float));
    4139
    4240  GroupBox *groupbox = new GroupBox(layout->NewRow(), "simubldc");
     
    4745
    4846SimuBldc::SimuBldc(const Object *parent, string name, uint8_t motors_count,
    49                    uint32_t dev_id)
     47                   uint32_t modelId,uint32_t deviceId)
    5048    : Bldc(parent, name, motors_count) {
    51   ostringstream dev_name;
    52   dev_name << "simu_bldc_" << dev_id;
    5349  shmem =
    54       new SharedMem(this, dev_name.str().c_str(), motors_count * sizeof(float));
     50      new SharedMem(this, ShMemName(modelId, deviceId), motors_count * sizeof(float));
    5551
    5652  // reset values
     
    6561
    6662SimuBldc::~SimuBldc() {}
     63
     64string SimuBldc::ShMemName(uint32_t modelId,uint32_t deviceId) {
     65  ostringstream dev_name;
     66  dev_name << "simu" <<  modelId << "_bldc_" << deviceId;
     67  return dev_name.str().c_str();
     68}
    6769
    6870void SimuBldc::SetMotors(float *value) {
  • trunk/lib/FlairSensorActuator/src/SimuBldc.h

    r15 r158  
    4646  * \param name name
    4747  * \param motors_count number of motors
    48   * \param dev_id device id
     48  * \param modelId Model id
     49  * \param deviceId Bldc id of the Model
    4950  */
    5051  SimuBldc(const core::IODevice *parent, gui::Layout *layout, std::string name,
    51            uint8_t motors_count, uint32_t dev_id);
     52           uint8_t motors_count, uint32_t modelId,uint32_t deviceId);
    5253
    5354  /*!
     
    5960  * \param name name
    6061  * \param motors_count number of motors
    61   * \param dev_id device id
     62  * \param modelId Model id
     63  * \param deviceId Bldc id of the Model
    6264  */
    6365  SimuBldc(const core::Object *parent, std::string name, uint8_t motors_count,
    64            uint32_t dev_id);
     66           uint32_t modelId,uint32_t deviceId);
    6567
    6668  /*!
     
    107109  */
    108110  void SetMotors(float *value);
    109 
     111 
     112  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    110113  core::SharedMem *shmem;
    111114  gui::DoubleSpinBox *k;
  • trunk/lib/FlairSensorActuator/src/SimuCamera.cpp

    r157 r158  
    3333SimuCamera::SimuCamera(string name,
    3434                       uint16_t width, uint16_t height, uint8_t channels,
    35                        uint32_t dev_id, uint8_t priority)
     35                       uint32_t modelId,uint32_t deviceId, uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority),
    3737      Camera(name, width, height, cvimage::Type::Format::BGR) {
     
    4343
    4444  ostringstream dev_name;
    45   dev_name << "simu_cam_" << dev_id;
    46   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), buf_size, SharedMem::Type::producerConsumer);
     45  dev_name << "simu" <<  modelId << "_cam_" << deviceId;
     46  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId), buf_size, SharedMem::Type::producerConsumer);
    4747 
    4848  SetIsReady(true);
     
    5151//simulation part
    5252SimuCamera::SimuCamera(const IODevice *parent, string name, uint16_t width,
    53                        uint16_t height, uint8_t channels, uint32_t dev_id)
     53                       uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId)
    5454    : Thread(parent, name, 0), Camera(parent,name) {
    5555
    5656  buf_size = width * height * channels+sizeof(Time);
    5757 
    58   ostringstream dev_name;
    59   dev_name << "simu_cam_" << dev_id;
    60   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     58  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId),
    6159                        buf_size, SharedMem::Type::producerConsumer);
    6260  shmemReadBuf=NULL;
     
    6967  Join();
    7068  if(shmemReadBuf!=NULL) delete shmemReadBuf;
     69}
     70
     71string SimuCamera::ShMemName(uint32_t modelId,uint32_t deviceId) {
     72  ostringstream dev_name;
     73  dev_name << "simu" <<  modelId << "_cam_" << deviceId;
     74  return dev_name.str().c_str();
    7175}
    7276
  • trunk/lib/FlairSensorActuator/src/SimuCamera.h

    r151 r158  
    4242  * \param height height
    4343  * \param channels number of channels
    44   * \param dev_id device id
     44  * \param modelId Model id
     45  * \param deviceId Camera id of the Model
    4546  * \param priority priority of the Thread
    4647  */
    4748  SimuCamera(std::string name,
    48              uint16_t width, uint16_t height, uint8_t channels, uint32_t dev_id,
     49             uint16_t width, uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId,
    4950             uint8_t priority);
    5051
     
    6061  * \param height height
    6162  * \param channels number of channels
    62   * \param dev_id device id
     63  * \param modelId Model id
     64  * \param deviceId Camera id of the Model
    6365  */
    6466  SimuCamera(const core::IODevice *parent, std::string name, uint16_t width,
    65              uint16_t height, uint8_t channels, uint32_t dev_id);
     67             uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId);
    6668
    6769  /*!
     
    9597  */
    9698  void UpdateFrom(const core::io_data *data){};
     99 
     100  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    97101
    98102  size_t buf_size;
  • trunk/lib/FlairSensorActuator/src/SimuGps.cpp

    r157 r158  
    3939
    4040SimuGps::SimuGps(string name,
    41                  NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority)
     41                 NmeaGps::NMEAFlags_t NMEAFlags, uint32_t modelId,uint32_t deviceId,uint8_t priority)
    4242    : NmeaGps(name, NMEAFlags),Thread(getFrameworkManager(), name, priority) {
    4343
     
    4949  numberOfSatellites = new SpinBox(GetGroupBox()->NewRow(), "number of satellites", 1, 15, 1, 5);
    5050
    51   ostringstream dev_name;
    52   dev_name << "simu_gps_" << deviceId;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     51  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5452                        sizeof(gps_states_t));
    5553                       
     
    5856
    5957
    60 SimuGps::SimuGps(const IODevice *parent, string name, uint32_t deviceId)
     58SimuGps::SimuGps(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    6159    : NmeaGps(parent, name), Thread(parent, name, 0) {
    6260  dataRate = NULL;
    6361
    64   ostringstream dev_name;
    65   dev_name << "simu_gps_" << deviceId;
    66   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     62  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId),
    6763                        sizeof(gps_states_t));
    6864 
     
    7369  SafeStop();
    7470  Join();
     71}
     72
     73string SimuGps::ShMemName(uint32_t modelId,uint32_t deviceId) {
     74  ostringstream dev_name;
     75  dev_name << "simu" <<  modelId << "_gps_" << deviceId;
     76  return dev_name.str().c_str();
    7577}
    7678
  • trunk/lib/FlairSensorActuator/src/SimuGps.h

    r137 r158  
    4343  * \param name name
    4444  * \param NMEAFlags NMEA sentances to enable
    45   * \param deviceId device id
     45  * \param modelId Model id
     46  * \param deviceId Gps id of the Model
    4647  * \param priority priority of the Thread
    4748  */
    4849  SimuGps(std::string name,
    49           NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority);
     50          NmeaGps::NMEAFlags_t NMEAFlags, uint32_t modelId,uint32_t deviceId,uint8_t priority);
    5051
    5152  /*!
     
    5758  * \param parent parent
    5859  * \param name name
    59   * \param deviceId device id
     60  * \param modelId Model id
     61  * \param deviceId Gps id of the Model
    6062  */
    61   SimuGps(const core::IODevice *parent, std::string name, uint32_t deviceId);
     63  SimuGps(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6264
    6365  /*!
     
    9294    float vn;
    9395  } gps_states_t;
     96 
     97  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9498
    9599  core::SharedMem *shmem;
  • trunk/lib/FlairSensorActuator/src/SimuImu.cpp

    r157 r158  
    3434namespace sensor {
    3535
    36 SimuImu::SimuImu(string name, uint32_t dev_id,
     36SimuImu::SimuImu(string name, uint32_t modelId,uint32_t deviceId,
    3737                 uint8_t priority)
    3838    : Imu(name), Thread(getFrameworkManager(), name, priority) {
     
    4040      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 200);
    4141  ahrsData = new AhrsData((Imu *)this);
    42 
    43   ostringstream dev_name;
    44   dev_name << "simu_imu_" << dev_id;
    45   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     42 
     43  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    4644                        sizeof(imu_states_t));
    4745  SetIsReady(true);
    4846}
    4947
    50 SimuImu::SimuImu(const IODevice *parent, string name, uint32_t dev_id)
     48SimuImu::SimuImu(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    5149    : Imu(parent,name), Thread(parent, name, 0) {
    5250  dataRate = NULL;
    5351
    54   ostringstream dev_name;
    55   dev_name << "simu_imu_" << dev_id;
    56   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     52  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5753                        sizeof(imu_states_t));
    5854  SetIsReady(true);
     
    6258  SafeStop();
    6359  Join();
     60}
     61
     62string SimuImu::ShMemName(uint32_t modelId,uint32_t deviceId) {
     63  ostringstream dev_name;
     64  dev_name << "simu" <<  modelId << "_imu_" << deviceId;
     65  return dev_name.str().c_str();
    6466}
    6567
  • trunk/lib/FlairSensorActuator/src/SimuImu.h

    r137 r158  
    4242  *
    4343  * \param name name
    44   * \param dev_id device id
     44  * \param modelId Model id
     45  * \param deviceId Imu id of the Model
    4546  * \param priority priority of the Thread
    4647  */
    4748  SimuImu(std::string name,
    48           uint32_t dev_id, uint8_t priority);
     49          uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4950
    5051  /*!
     
    5657  * \param parent parent
    5758  * \param name name
    58   * \param dev_id device id
     59  * \param modelId Model id
     60  * \param deviceId Imu id of the Model
    5961  */
    60   SimuImu(const core::IODevice *parent, std::string name, uint32_t dev_id);
     62  SimuImu(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6163
    6264  /*!
     
    9395    float wz;
    9496  } imu_states_t;
     97 
     98  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9599
    96100  gui::SpinBox *dataRate;
  • trunk/lib/FlairSensorActuator/src/SimuLaser.cpp

    r157 r158  
    3333
    3434SimuLaser::SimuLaser(string name,
    35                      uint32_t dev_id, uint8_t priority)
     35                     uint32_t modelId,uint32_t deviceId, uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority), LaserRangeFinder(name) {
    3737  data_rate =
    3838      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
    3939
    40   ostringstream dev_name;
    41   dev_name << "simu_Laser_" << dev_id;
    42   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     40  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    4341                        360 * sizeof(float));
    4442  SetIsReady(true);
    4543}
    4644
    47 SimuLaser::SimuLaser(const IODevice *parent, string name, uint32_t dev_id)
     45SimuLaser::SimuLaser(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    4846    : Thread(parent, name, 0), LaserRangeFinder(parent, name) {
    4947  data_rate = NULL;
    5048
    51   ostringstream dev_name;
    52   dev_name << "simu_Laser_" << dev_id;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     49  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5450                        360 * sizeof(float));
    5551  SetIsReady(true);
     
    5955  SafeStop();
    6056  Join();
     57}
     58
     59string SimuLaser::ShMemName(uint32_t modelId,uint32_t deviceId) {
     60  ostringstream dev_name;
     61  dev_name << "simu" <<  modelId << "_laser_" << deviceId;
     62  return dev_name.str().c_str();
    6163}
    6264
  • trunk/lib/FlairSensorActuator/src/SimuLaser.h

    r137 r158  
    4141  *
    4242  * \param name name
    43   * \param dev_id device id
     43  * \param modelId Model id
     44  * \param deviceId LaserRangeFinder id of the Model
    4445  * \param priority priority of the Thread
    4546  */
    4647  SimuLaser(std::string name,
    47             uint32_t dev_id, uint8_t priority);
     48            uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4849
    4950  /*!
     
    5556  * \param parent parent
    5657  * \param name name
    57   * \param dev_id device id
     58  * \param modelId Model id
     59  * \param deviceId LaserRangeFinder id of the Model
    5860  */
    59   SimuLaser(const core::IODevice *parent, std::string name, uint32_t dev_id);
     61  SimuLaser(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6062
    6163  /*!
     
    8991  */
    9092  void Run(void);
    91 
     93 
     94  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9295  gui::SpinBox *data_rate;
    9396};
  • trunk/lib/FlairSensorActuator/src/SimuUs.cpp

    r157 r158  
    3232namespace sensor {
    3333
    34 SimuUs::SimuUs(string name, uint32_t dev_id,
     34SimuUs::SimuUs(string name, uint32_t modelId,uint32_t deviceId,
    3535               uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority), UsRangeFinder( name) {
     
    3838      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
    3939
    40   ostringstream dev_name;
    41   dev_name << "simu_us_" << dev_id;
    42   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), sizeof(float));
     40  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId), sizeof(float));
    4341
    4442  SetIsReady(true);
    4543}
    4644
    47 SimuUs::SimuUs(const IODevice *parent, string name, uint32_t dev_id)
     45SimuUs::SimuUs(const IODevice *parent, string name,uint32_t modelId,uint32_t deviceId)
    4846    : Thread(parent, name, 0), UsRangeFinder(parent,name) {
    4947  data_rate = NULL;
    5048
    51   ostringstream dev_name;
    52   dev_name << "simu_us_" << dev_id;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), sizeof(float));
     49  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId), sizeof(float));
    5450 
    5551  SetIsReady(true);
     
    5955  SafeStop();
    6056  Join();
     57}
     58
     59string SimuUs::ShMemName(uint32_t modelId,uint32_t deviceId) {
     60  ostringstream dev_name;
     61  dev_name << "simu" <<  modelId << "_us_" << deviceId;
     62  return dev_name.str().c_str();
    6163}
    6264
  • trunk/lib/FlairSensorActuator/src/SimuUs.h

    r137 r158  
    4141  *
    4242  * \param name name
    43   * \param dev_id device id
     43  * \param modelId Model id
     44  * \param deviceId UsRangeFinder id of the Model
    4445  * \param priority priority of the Thread
    4546  */
    4647  SimuUs(std::string name,
    47          uint32_t dev_id, uint8_t priority);
     48         uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4849
    4950  /*!
     
    5556  * \param parent parent
    5657  * \param name name
    57   * \param dev_id device id
     58  * \param modelId Model id
     59  * \param deviceId UsRangeFinder id of the Model
    5860  */
    59   SimuUs(const core::IODevice *parent, std::string name, uint32_t dev_id);
     61  SimuUs(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6062
    6163  /*!
     
    8991  */
    9092  void Run(void);
    91 
     93 
     94  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9295  gui::SpinBox *data_rate;
    9396};
Note: See TracChangeset for help on using the changeset viewer.