Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (5 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

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

    r3 r15  
    2929using namespace flair::gui;
    3030
    31 namespace flair
    32 {
    33 namespace sensor
    34 {
     31namespace flair {
     32namespace sensor {
    3533
    36 SimuLaser::SimuLaser(const FrameworkManager* parent,string name,uint32_t dev_id,uint8_t priority) : Thread(parent,name,priority), LaserRangeFinder(parent,name)
    37 {
    38     data_rate=new SpinBox(GetGroupBox()->NewRow(),"data rate"," Hz",1,500,1,50);
     34SimuLaser::SimuLaser(const FrameworkManager *parent, string name,
     35                     uint32_t dev_id, uint8_t priority)
     36    : Thread(parent, name, priority), LaserRangeFinder(parent, name) {
     37  data_rate =
     38      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(),360*sizeof(float)); //****
     40  ostringstream dev_name;
     41  dev_name << "simu_Laser_" << dev_id;
     42  shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     43                        360 * sizeof(float)); //****
    4344}
    4445
    45 SimuLaser::SimuLaser(const IODevice* parent,string name,uint32_t dev_id) : Thread(parent,name,0), LaserRangeFinder(parent,name)
    46 {
    47     data_rate=NULL;
     46SimuLaser::SimuLaser(const IODevice *parent, string name, uint32_t dev_id)
     47    : Thread(parent, name, 0), LaserRangeFinder(parent, name) {
     48  data_rate = NULL;
    4849
    49     ostringstream dev_name;
    50     dev_name << "simu_Laser_" << dev_id;
    51     shmem=new SharedMem((Thread*)this,dev_name.str().c_str(),360*sizeof(float));
     50  ostringstream dev_name;
     51  dev_name << "simu_Laser_" << dev_id;
     52  shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     53                        360 * sizeof(float));
    5254}
    5355
    54 SimuLaser::~SimuLaser()
    55 {
    56     SafeStop();
    57     Join();
     56SimuLaser::~SimuLaser() {
     57  SafeStop();
     58  Join();
    5859}
    5960
    60 void SimuLaser::Run(void)
    61 {
    62     float z[360];
     61void SimuLaser::Run(void) {
     62  float z[360];
    6363
    64     if(data_rate==NULL)
    65     {
    66         Thread::Err("not applicable for simulation part.\n");
    67         return;
     64  if (data_rate == NULL) {
     65    Thread::Err("not applicable for simulation part.\n");
     66    return;
     67  }
     68
     69  SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
     70
     71  while (!ToBeStopped()) {
     72    WaitPeriod();
     73
     74    shmem->Read((char *)z, 360 * sizeof(float));
     75
     76    if (data_rate->ValueChanged() == true) {
     77      SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
    6878    }
    69 
    70     SetPeriodUS((uint32_t)(1000000./data_rate->Value()));
    71 
    72     while(!ToBeStopped())
    73     {
    74         WaitPeriod();
    75 
    76         shmem->Read((char*)z,360*sizeof(float));
    77 
    78         if(data_rate->ValueChanged()==true)
    79         {
    80             SetPeriodUS((uint32_t)(1000000./data_rate->Value()));
    81         }
    82         for(int i=0; i<360; i++)
    83         {
    84             output->SetValue(i,0,z[i]); //*******
    85         }
    86         output->SetDataTime(GetTime());
    87         ProcessUpdate(output);
     79    for (int i = 0; i < 360; i++) {
     80      output->SetValue(i, 0, z[i]); //*******
    8881    }
     82    output->SetDataTime(GetTime());
     83    ProcessUpdate(output);
     84  }
    8985}
    9086
Note: See TracChangeset for help on using the changeset viewer.